diff --git a/Gulpfile.ts b/Gulpfile.ts index 32fbf2c43e0..03046789fe1 100644 --- a/Gulpfile.ts +++ b/Gulpfile.ts @@ -935,7 +935,7 @@ gulp.task(loggedIOJsPath, /*help*/ false, [], (done) => { const temp = path.join(builtLocalDirectory, "temp"); mkdirP(temp, (err) => { if (err) { console.error(err); done(err); process.exit(1); } - exec(host, [LKGCompiler, "--types --outdir", temp, loggedIOpath], () => { + exec(host, [LKGCompiler, "--types", "--target es5", "--lib es5", "--outdir", temp, loggedIOpath], () => { fs.renameSync(path.join(temp, "/harness/loggedIO.js"), loggedIOJsPath); del(temp).then(() => done(), done); }, done); @@ -946,7 +946,13 @@ const instrumenterPath = path.join(harnessDirectory, "instrumenter.ts"); const instrumenterJsPath = path.join(builtLocalDirectory, "instrumenter.js"); gulp.task(instrumenterJsPath, /*help*/ false, [servicesFile], () => { const settings: tsc.Settings = getCompilerSettings({ - outFile: instrumenterJsPath + outFile: instrumenterJsPath, + target: "es5", + lib: [ + "es6", + "dom", + "scripthost" + ] }, /*useBuiltCompiler*/ true); return gulp.src(instrumenterPath) .pipe(newer(instrumenterJsPath)) diff --git a/lib/cancellationToken.js b/lib/cancellationToken.js index 378255a37ee..0e37b0689e0 100644 --- a/lib/cancellationToken.js +++ b/lib/cancellationToken.js @@ -49,7 +49,7 @@ function createCancellationToken(args) { return { isCancellationRequested: function () { return perRequestPipeName_1 !== undefined && pipeExists(perRequestPipeName_1); }, setRequest: function (requestId) { - currentRequestId_1 = currentRequestId_1; + currentRequestId_1 = requestId; perRequestPipeName_1 = namePrefix_1 + requestId; }, resetRequest: function (requestId) { diff --git a/lib/lib.d.ts b/lib/lib.d.ts index 126e5d82ac4..80e09b844cb 100644 --- a/lib/lib.d.ts +++ b/lib/lib.d.ts @@ -160,14 +160,14 @@ interface ObjectConstructor { * Creates an object that has the specified prototype or that has null prototype. * @param o Object to use as a prototype. May be null. */ - create(o: T | null): T | object; + create(o: object | null): any; /** * 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: object | null, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -175,14 +175,14 @@ interface ObjectConstructor { * @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; + defineProperty(o: any, p: string, attributes: PropertyDescriptor & ThisType): 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; + defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. @@ -345,53 +345,27 @@ interface String { * 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 | null; - - /** - * 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 | null; + match(regexp: string | RegExp): RegExpMatchArray | null; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ - replace(searchValue: string, replaceValue: string): string; + replace(searchValue: string | RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @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; + replace(searchValue: string | 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; + search(regexp: string | RegExp): number; /** * Returns a section of a string. @@ -406,14 +380,7 @@ interface String { * @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[]; + split(separator: string | RegExp, limit?: number): string[]; /** * Returns the substring at the specified location within a String object. @@ -543,7 +510,7 @@ interface NumberConstructor { declare const Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray + readonly raw: ReadonlyArray; } interface Math { @@ -881,9 +848,9 @@ interface RegExp { } interface RegExpConstructor { - new (pattern: RegExp): RegExp; + new (pattern: RegExp | string): RegExp; new (pattern: string, flags?: string): RegExp; - (pattern: RegExp): RegExp; + (pattern: RegExp | string): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; @@ -1070,37 +1037,49 @@ interface ReadonlyArray { * @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; + every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): 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; + some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): 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; + forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void): void; + forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => void, thisArg: Z): 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[]; + map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U): U[]; + map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => U, thisArg: Z): 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) => value is S, thisArg?: any): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: undefined): S[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: Z): S[]; /** * 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) => any, thisArg?: any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => any, thisArg: Z): 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. @@ -1217,55 +1196,73 @@ interface Array { * @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; + every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; + every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): 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; + some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; + some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): 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; + forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void): void; + forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: T[]) => void, thisArg: Z): 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(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; /** * 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(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; /** * 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(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; /** * 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(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; + map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U]; + map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; + map(this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; /** * 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[]; + map(callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; + map(callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): 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[]) => any, thisArg?: any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => any, thisArg: Z): 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. @@ -1377,14 +1374,19 @@ type Readonly = { */ type Pick = { [P in K]: T[P]; -} +}; /** * Construct a type with a set of properties K of type T */ type Record = { [P in K]: T; -} +}; + +/** + * Marker for contextual 'this' type + */ +interface ThisType { } /** * Represents a raw buffer of binary data, which is used to store data for the @@ -1401,7 +1403,7 @@ interface ArrayBuffer { /** * Returns a section of an ArrayBuffer. */ - slice(begin:number, end?:number): ArrayBuffer; + slice(begin: number, end?: number): ArrayBuffer; } interface ArrayBufferConstructor { @@ -1605,7 +1607,9 @@ interface Int8Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1624,7 +1628,9 @@ interface Int8Array { * @param thisArg 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) => any, thisArg?: any): Int8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any): Int8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any, thisArg: undefined): Int8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => any, thisArg: Z): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1635,7 +1641,9 @@ interface Int8Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1646,7 +1654,9 @@ interface Int8Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1655,7 +1665,9 @@ interface Int8Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1693,7 +1705,9 @@ interface Int8Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number): Int8Array; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg: undefined): Int8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => number, thisArg: Z): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1748,13 +1762,6 @@ interface Int8Array { */ 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. @@ -1777,7 +1784,9 @@ interface Int8Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -1829,7 +1838,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: ArrayLike): Int8Array; } declare const Int8Array: Int8ArrayConstructor; @@ -1878,7 +1891,9 @@ interface Uint8Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1897,7 +1912,9 @@ interface Uint8Array { * @param thisArg 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) => any, thisArg?: any): Uint8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any): Uint8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any, thisArg: undefined): Uint8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => any, thisArg: Z): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1908,7 +1925,9 @@ interface Uint8Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1919,7 +1938,9 @@ interface Uint8Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1928,7 +1949,9 @@ interface Uint8Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1966,7 +1989,9 @@ interface Uint8Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number): Uint8Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg: undefined): Uint8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => number, thisArg: Z): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2021,13 +2046,6 @@ interface Uint8Array { */ 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. @@ -2050,7 +2068,9 @@ interface Uint8Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2103,7 +2123,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: ArrayLike): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2152,7 +2176,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2171,7 +2197,9 @@ interface Uint8ClampedArray { * @param thisArg 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) => any, thisArg?: any): Uint8ClampedArray; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any): Uint8ClampedArray; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: undefined): Uint8ClampedArray; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: Z): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2182,7 +2210,9 @@ interface Uint8ClampedArray { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2193,7 +2223,9 @@ interface Uint8ClampedArray { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2202,7 +2234,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2240,7 +2274,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number): Uint8ClampedArray; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: undefined): Uint8ClampedArray; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: Z): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2295,19 +2331,12 @@ interface Uint8ClampedArray { */ 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; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2324,7 +2353,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2377,7 +2408,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: ArrayLike): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2425,7 +2460,9 @@ interface Int16Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2444,7 +2481,9 @@ interface Int16Array { * @param thisArg 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) => any, thisArg?: any): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg: undefined): Int16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => any, thisArg: Z): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2455,7 +2494,9 @@ interface Int16Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2466,7 +2507,9 @@ interface Int16Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2475,7 +2518,9 @@ interface Int16Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2513,7 +2558,9 @@ interface Int16Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number): Int16Array; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg: undefined): Int16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => number, thisArg: Z): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2568,13 +2615,6 @@ interface Int16Array { */ 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. @@ -2597,7 +2637,9 @@ interface Int16Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2650,7 +2692,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: ArrayLike): Int16Array; } declare const Int16Array: Int16ArrayConstructor; @@ -2699,7 +2745,9 @@ interface Uint16Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2718,7 +2766,9 @@ interface Uint16Array { * @param thisArg 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) => any, thisArg?: any): Uint16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any): Uint16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any, thisArg: undefined): Uint16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => any, thisArg: Z): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2729,7 +2779,9 @@ interface Uint16Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2740,7 +2792,9 @@ interface Uint16Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2749,7 +2803,9 @@ interface Uint16Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2787,7 +2843,9 @@ interface Uint16Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number): Uint16Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg: undefined): Uint16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => number, thisArg: Z): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2842,13 +2900,6 @@ interface Uint16Array { */ 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. @@ -2871,7 +2922,9 @@ interface Uint16Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2924,7 +2977,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: ArrayLike): Uint16Array; } declare const Uint16Array: Uint16ArrayConstructor; @@ -2972,7 +3029,9 @@ interface Int32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2991,7 +3050,9 @@ interface Int32Array { * @param thisArg 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) => any, thisArg?: any): Int32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any): Int32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any, thisArg: undefined): Int32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => any, thisArg: Z): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3002,7 +3063,9 @@ interface Int32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3013,7 +3076,9 @@ interface Int32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3022,7 +3087,9 @@ interface Int32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3060,7 +3127,9 @@ interface Int32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number): Int32Array; + map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number, thisArg: undefined): Int32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => number, thisArg: Z): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3115,13 +3184,6 @@ interface Int32Array { */ 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. @@ -3144,7 +3206,9 @@ interface Int32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3197,7 +3261,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: ArrayLike): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3245,7 +3313,9 @@ interface Uint32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3264,7 +3334,9 @@ interface Uint32Array { * @param thisArg 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) => any, thisArg?: any): Uint32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any): Uint32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any, thisArg: undefined): Uint32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => any, thisArg: Z): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3275,7 +3347,9 @@ interface Uint32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3286,7 +3360,9 @@ interface Uint32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3295,7 +3371,9 @@ interface Uint32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3333,7 +3411,9 @@ interface Uint32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number): Uint32Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg: undefined): Uint32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => number, thisArg: Z): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3388,13 +3468,6 @@ interface Uint32Array { */ 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. @@ -3417,7 +3490,9 @@ interface Uint32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3470,7 +3545,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: ArrayLike): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3518,7 +3597,9 @@ interface Float32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3537,7 +3618,9 @@ interface Float32Array { * @param thisArg 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) => any, thisArg?: any): Float32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any): Float32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any, thisArg: undefined): Float32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => any, thisArg: Z): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3548,7 +3631,9 @@ interface Float32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3559,7 +3644,9 @@ interface Float32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3568,7 +3655,9 @@ interface Float32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3606,7 +3695,9 @@ interface Float32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number): Float32Array; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg: undefined): Float32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => number, thisArg: Z): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3661,13 +3752,6 @@ interface Float32Array { */ 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. @@ -3690,7 +3774,9 @@ interface Float32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3743,7 +3829,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: ArrayLike): Float32Array; } declare const Float32Array: Float32ArrayConstructor; @@ -3792,7 +3882,9 @@ interface Float64Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3811,7 +3903,9 @@ interface Float64Array { * @param thisArg 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) => any, thisArg?: any): Float64Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any): Float64Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any, thisArg: undefined): Float64Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => any, thisArg: Z): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3822,7 +3916,9 @@ interface Float64Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3833,7 +3929,9 @@ interface Float64Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3842,7 +3940,9 @@ interface Float64Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3880,7 +3980,9 @@ interface Float64Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number): Float64Array; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg: undefined): Float64Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => number, thisArg: Z): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3935,13 +4037,6 @@ interface Float64Array { */ 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. @@ -3964,7 +4059,9 @@ interface Float64Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -4017,7 +4114,11 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: ArrayLike): Float64Array; } declare const Float64Array: Float64ArrayConstructor; @@ -4025,7 +4126,7 @@ declare const Float64Array: Float64ArrayConstructor; /// ECMAScript Internationalization API ///////////////////////////// -declare module Intl { +declare namespace Intl { interface CollatorOptions { usage?: string; localeMatcher?: string; @@ -4053,7 +4154,7 @@ declare module Intl { new (locales?: string | string[], options?: CollatorOptions): Collator; (locales?: string | string[], options?: CollatorOptions): Collator; supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[]; - } + }; interface NumberFormatOptions { localeMatcher?: string; @@ -4090,7 +4191,7 @@ declare module Intl { new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; - } + }; interface DateTimeFormatOptions { localeMatcher?: string; @@ -4133,7 +4234,7 @@ declare module Intl { new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[]; - } + }; } interface String { @@ -4258,8 +4359,8 @@ interface ConstrainLongRange extends LongRange { } interface ConstrainVideoFacingModeParameters { - exact?: string | string[]; - ideal?: string | string[]; + exact?: VideoFacingModeEnum | VideoFacingModeEnum[]; + ideal?: VideoFacingModeEnum | VideoFacingModeEnum[]; } interface CustomEventInit extends EventInit { @@ -4488,7 +4589,7 @@ interface MSAudioSendSignal { } interface MSConnectivity { - iceType?: string; + iceType?: MSIceType; iceWarningFlags?: MSIceWarningFlags; relayAddress?: MSRelayAddress; } @@ -4498,11 +4599,11 @@ interface MSCredentialFilter { } interface MSCredentialParameters { - type?: string; + type?: MSCredentialType; } interface MSCredentialSpec { - type?: string; + type?: MSCredentialType; id?: string; } @@ -4513,7 +4614,7 @@ interface MSDelay { interface MSDescription extends RTCStats { connectivity?: MSConnectivity; - transport?: string; + transport?: RTCIceProtocol; networkconnectivity?: MSNetworkConnectivityInfo; localAddr?: MSIPAddressInfo; remoteAddr?: MSIPAddressInfo; @@ -4637,11 +4738,11 @@ interface MSTransportDiagnosticsStats extends RTCStats { numConsentRespReceived?: number; interfaces?: MSNetworkInterfaceType; baseInterface?: MSNetworkInterfaceType; - protocol?: string; + protocol?: RTCIceProtocol; localInterface?: MSNetworkInterfaceType; - localAddrType?: string; - remoteAddrType?: string; - iceRole?: string; + localAddrType?: MSIceAddrType; + remoteAddrType?: MSIceAddrType; + iceRole?: RTCIceRole; rtpRtcpMux?: boolean; allocationTimeInMs?: number; msRtcEngineVersion?: string; @@ -4714,7 +4815,7 @@ interface MediaEncryptedEventInit extends EventInit { } interface MediaKeyMessageEventInit extends EventInit { - messageType?: string; + messageType?: MediaKeyMessageType; message?: ArrayBuffer; } @@ -4722,8 +4823,8 @@ interface MediaKeySystemConfiguration { initDataTypes?: string[]; audioCapabilities?: MediaKeySystemMediaCapability[]; videoCapabilities?: MediaKeySystemMediaCapability[]; - distinctiveIdentifier?: string; - persistentState?: string; + distinctiveIdentifier?: MediaKeysRequirement; + persistentState?: MediaKeysRequirement; } interface MediaKeySystemMediaCapability { @@ -4847,7 +4948,7 @@ interface MutationObserverInit { } interface NotificationOptions { - dir?: string; + dir?: NotificationDirection; lang?: string; body?: string; tag?: string; @@ -4946,8 +5047,8 @@ interface PushSubscriptionOptionsInit { interface RTCConfiguration { iceServers?: RTCIceServer[]; - iceTransportPolicy?: string; - bundlePolicy?: string; + iceTransportPolicy?: RTCIceTransportPolicy; + bundlePolicy?: RTCBundlePolicy; peerIdentity?: string; } @@ -4961,7 +5062,7 @@ interface RTCDtlsFingerprint { } interface RTCDtlsParameters { - role?: string; + role?: RTCDtlsRole; fingerprints?: RTCDtlsFingerprint[]; } @@ -4969,7 +5070,7 @@ interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; transport?: string; - candidateType?: string; + candidateType?: RTCStatsIceCandidateType; priority?: number; addressSourceUrl?: string; } @@ -4981,10 +5082,10 @@ interface RTCIceCandidateDictionary { foundation?: string; priority?: number; ip?: string; - protocol?: string; + protocol?: RTCIceProtocol; port?: number; - type?: string; - tcpType?: string; + type?: RTCIceCandidateType; + tcpType?: RTCIceTcpCandidateType; relatedAddress?: string; relatedPort?: number; msMTurnSessionId?: string; @@ -5005,7 +5106,7 @@ interface RTCIceCandidatePairStats extends RTCStats { transportId?: string; localCandidateId?: string; remoteCandidateId?: string; - state?: string; + state?: RTCStatsIceCandidatePairState; priority?: number; nominated?: boolean; writable?: boolean; @@ -5018,7 +5119,7 @@ interface RTCIceCandidatePairStats extends RTCStats { } interface RTCIceGatherOptions { - gatherPolicy?: string; + gatherPolicy?: RTCIceGatherPolicy; iceservers?: RTCIceServer[]; portRange?: MSPortRange; } @@ -5183,7 +5284,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; - degradationPreference?: string; + degradationPreference?: RTCDegradationPreference; } interface RTCRtpRtxParameters { @@ -5197,7 +5298,7 @@ interface RTCRtpUnhandled { } interface RTCSessionDescriptionInit { - type?: string; + type?: RTCSdpType; sdp?: string; } @@ -5223,9 +5324,9 @@ interface RTCSsrcRange { interface RTCStats { timestamp?: number; - type?: string; + type?: RTCStatsType; id?: string; - msType?: string; + msType?: MSStatsType; } interface RTCStatsReport { @@ -5250,11 +5351,11 @@ interface RequestInit { headers?: any; body?: any; referrer?: string; - referrerPolicy?: string; - mode?: string; - credentials?: string; - cache?: string; - redirect?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; integrity?: string; keepalive?: boolean; window?: any; @@ -5267,9 +5368,9 @@ interface ResponseInit { } interface ScopedCredentialDescriptor { - type?: string; + type?: ScopedCredentialType; id?: any; - transports?: string[]; + transports?: Transport[]; } interface ScopedCredentialOptions { @@ -5280,7 +5381,7 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - type?: string; + type?: ScopedCredentialType; algorithm?: string | Algorithm; } @@ -5510,7 +5611,7 @@ interface AudioContextBase extends EventTarget { readonly listener: AudioListener; onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - readonly state: string; + readonly state: AudioContextState; close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; @@ -5570,12 +5671,13 @@ declare var AudioListener: { interface AudioNode extends EventTarget { channelCount: number; - channelCountMode: string; - channelInterpretation: string; + channelCountMode: ChannelCountMode; + channelInterpretation: ChannelInterpretation; readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: number): void; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -5673,7 +5775,7 @@ interface BiquadFilterNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; readonly gain: AudioParam; - type: string; + type: BiquadFilterType; getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } @@ -6313,7 +6415,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { lineJoin: string; lineWidth: number; miterLimit: number; - msFillRule: string; + msFillRule: CanvasFillRule; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -6326,19 +6428,21 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { oImageSmoothingEnabled: boolean; beginPath(): void; clearRect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; + clip(fillRule?: CanvasFillRule): 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; drawFocusIfNeeded(element: Element): void; - 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; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; + fill(fillRule?: CanvasFillRule): 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; + isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean; measureText(text: string): TextMetrics; putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; restore(): void; @@ -6629,10 +6733,10 @@ declare var DOMException: { } interface DOMImplementation { - createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(): boolean; + hasFeature(feature: string | null, version: string | null): boolean; } declare var DOMImplementation: { @@ -6715,6 +6819,7 @@ interface DataTransfer { clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; + setDragImage(image: Element, x: number, y: number): void; } declare var DataTransfer: { @@ -6751,7 +6856,7 @@ declare var DataTransferItemList: { interface DeferredPermissionRequest { readonly id: number; - readonly type: string; + readonly type: MSWebViewPermissionType; readonly uri: string; allow(): void; deny(): void; @@ -7369,7 +7474,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Contains the title of the document. */ title: string; - readonly visibilityState: string; + readonly visibilityState: VisibilityState; /** * Sets or gets the color of the links that the user has visited. */ @@ -7384,7 +7489,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets or sets the version attribute specified in the declaration of an XML document. */ xmlVersion: string | null; - adoptNode(source: Node): Node; + adoptNode(source: T): T; captureEvents(): void; caretRangeFromPoint(x: number, y: number): Range; clear(): void; @@ -7561,7 +7666,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets a value indicating whether the object currently has focus. */ hasFocus(): boolean; - importNode(importedNode: Node, deep: boolean): Node; + importNode(importedNode: T, deep: boolean): T; msElementsFromPoint(x: number, y: number): NodeListOf; msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; /** @@ -7629,6 +7734,7 @@ declare var Document: { } interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; } declare var DocumentFragment: { @@ -7876,9 +7982,9 @@ declare var Event: { } interface EventTarget { - addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare var EventTarget: { @@ -7957,7 +8063,7 @@ declare var FocusEvent: { } interface FocusNavigationEvent extends Event { - readonly navigationReason: string; + readonly navigationReason: NavigationReason; readonly originHeight: number; readonly originLeft: number; readonly originTop: number; @@ -7971,7 +8077,12 @@ declare var FocusNavigationEvent: { } interface FormData { - append(name: any, value: any, blobName?: string): void; + append(name: string, value: string | Blob, fileName?: string): void; + delete(name: string): void; + get(name: string): FormDataEntryValue | null; + getAll(name: string): FormDataEntryValue[]; + has(name: string): boolean; + set(name: string, value: string | Blob, fileName?: string): void; } declare var FormData: { @@ -11133,7 +11244,7 @@ declare var History: { } interface IDBCursor { - readonly direction: string; + readonly direction: IDBCursorDirection; key: IDBKeyRange | IDBValidKey; readonly primaryKey: any; source: IDBObjectStore | IDBIndex; @@ -11285,7 +11396,7 @@ interface IDBRequest extends EventTarget { readonly error: DOMError; onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; - readonly readyState: string; + readonly readyState: IDBRequestReadyState; readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; @@ -11307,7 +11418,7 @@ interface IDBTransactionEventMap { interface IDBTransaction extends EventTarget { readonly db: IDBDatabase; readonly error: DOMError; - readonly mode: string; + readonly mode: IDBTransactionMode; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; onerror: (this: IDBTransaction, ev: Event) => any; @@ -11425,7 +11536,7 @@ declare var KeyboardEvent: { interface ListeningStateChangedEvent extends Event { readonly label: string; - readonly state: string; + readonly state: ListeningState; } declare var ListeningStateChangedEvent: { @@ -11516,7 +11627,7 @@ declare var MSAppAsyncOperation: { interface MSAssertion { readonly id: string; - readonly type: string; + readonly type: MSCredentialType; } declare var MSAssertion: { @@ -11548,7 +11659,7 @@ interface MSFIDOCredentialAssertion extends MSAssertion { readonly algorithm: string | Algorithm; readonly attestation: any; readonly publicKey: string; - readonly transportHints: string[]; + readonly transportHints: MSTransportType[]; } declare var MSFIDOCredentialAssertion: { @@ -11652,7 +11763,7 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; - navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; + navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; @@ -11907,7 +12018,7 @@ declare var MSWebViewSettings: { interface MediaDeviceInfo { readonly deviceId: string; readonly groupId: string; - readonly kind: string; + readonly kind: MediaDeviceKind; readonly label: string; } @@ -11974,7 +12085,7 @@ declare var MediaError: { interface MediaKeyMessageEvent extends Event { readonly message: ArrayBuffer; - readonly messageType: string; + readonly messageType: MediaKeyMessageType; } declare var MediaKeyMessageEvent: { @@ -12002,7 +12113,7 @@ declare var MediaKeySession: { interface MediaKeyStatusMap { readonly size: number; forEach(callback: ForEachCallback): void; - get(keyId: any): string; + get(keyId: any): MediaKeyStatus; has(keyId: any): boolean; } @@ -12023,7 +12134,7 @@ declare var MediaKeySystemAccess: { } interface MediaKeys { - createSession(sessionType?: string): MediaKeySession; + createSession(sessionType?: MediaKeySessionType): MediaKeySession; setServerCertificate(serverCertificate: any): Promise; } @@ -12161,7 +12272,7 @@ interface MediaStreamTrack extends EventTarget { onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; onunmute: (this: MediaStreamTrack, ev: Event) => any; readonly readonly: boolean; - readonly readyState: string; + readonly readyState: MediaStreamTrackState; readonly remote: boolean; applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; @@ -12382,7 +12493,7 @@ declare var NavigationEventWithReferrer: { interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; - gamepadInputEmulation: string; + gamepadInputEmulation: GamepadInputEmulationType; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -12429,15 +12540,15 @@ interface Node extends EventTarget { contains(child: Node): boolean; hasAttributes(): boolean; hasChildNodes(): boolean; - insertBefore(newChild: Node, refChild: Node | null): Node; + insertBefore(newChild: T, refChild: Node | null): T; isDefaultNamespace(namespaceURI: string | null): boolean; isEqualNode(arg: Node): boolean; isSameNode(other: Node): boolean; lookupNamespaceURI(prefix: string | null): string | null; lookupPrefix(namespaceURI: string | null): string | null; normalize(): void; - removeChild(oldChild: Node): Node; - replaceChild(newChild: Node, oldChild: Node): Node; + removeChild(oldChild: T): T; + replaceChild(newChild: Node, oldChild: T): T; readonly ATTRIBUTE_NODE: number; readonly CDATA_SECTION_NODE: number; readonly COMMENT_NODE: number; @@ -12539,14 +12650,14 @@ interface NotificationEventMap { interface Notification extends EventTarget { readonly body: string; - readonly dir: string; + readonly dir: NotificationDirection; readonly icon: string; readonly lang: string; onclick: (this: Notification, ev: Event) => any; onclose: (this: Notification, ev: Event) => any; onerror: (this: Notification, ev: Event) => any; onshow: (this: Notification, ev: Event) => any; - readonly permission: string; + readonly permission: NotificationPermission; readonly tag: string; readonly title: string; close(): void; @@ -12557,7 +12668,7 @@ interface Notification extends EventTarget { declare var Notification: { prototype: Notification; new(title: string, options?: NotificationOptions): Notification; - requestPermission(callback?: NotificationPermissionCallback): Promise; + requestPermission(callback?: NotificationPermissionCallback): Promise; } interface OES_element_index_uint { @@ -12647,7 +12758,7 @@ interface OscillatorNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any; - type: string; + type: OscillatorType; setPeriodicWave(periodicWave: PeriodicWave): void; start(when?: number): void; stop(when?: number): void; @@ -12690,9 +12801,9 @@ interface PannerNode extends AudioNode { coneInnerAngle: number; coneOuterAngle: number; coneOuterGain: number; - distanceModel: string; + distanceModel: DistanceModelType; maxDistance: number; - panningModel: string; + panningModel: PanningModelType; refDistance: number; rolloffFactor: number; setOrientation(x: number, y: number, z: number): void; @@ -12743,7 +12854,7 @@ interface PaymentRequest extends EventTarget { onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; - readonly shippingType: string | null; + readonly shippingType: PaymentShippingType | null; abort(): Promise; show(): Promise; addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; @@ -12772,7 +12883,7 @@ interface PaymentResponse { readonly payerPhone: string | null; readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; - complete(result?: string): Promise; + complete(result?: PaymentComplete): Promise; toJSON(): any; } @@ -12900,7 +13011,7 @@ interface PerformanceNavigationTiming extends PerformanceEntry { readonly requestStart: number; readonly responseEnd: number; readonly responseStart: number; - readonly type: string; + readonly type: NavigationType; readonly unloadEventEnd: number; readonly unloadEventStart: number; } @@ -12969,7 +13080,7 @@ declare var PeriodicWave: { } interface PermissionRequest extends DeferredPermissionRequest { - readonly state: string; + readonly state: MSWebViewPermissionState; defer(): void; } @@ -13099,7 +13210,7 @@ declare var ProgressEvent: { interface PushManager { getSubscription(): Promise; - permissionState(options?: PushSubscriptionOptionsInit): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; subscribe(options?: PushSubscriptionOptionsInit): Promise; } @@ -13111,7 +13222,7 @@ declare var PushManager: { interface PushSubscription { readonly endpoint: USVString; readonly options: PushSubscriptionOptions; - getKey(name: string): ArrayBuffer | null; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; toJSON(): any; unsubscribe(): Promise; } @@ -13148,7 +13259,7 @@ interface RTCDtlsTransportEventMap { interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; - readonly state: string; + readonly state: RTCDtlsTransportState; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; getRemoteCertificates(): ArrayBuffer[]; @@ -13165,7 +13276,7 @@ declare var RTCDtlsTransport: { } interface RTCDtlsTransportStateChangedEvent extends Event { - readonly state: string; + readonly state: RTCDtlsTransportState; } declare var RTCDtlsTransportStateChangedEvent: { @@ -13221,7 +13332,7 @@ interface RTCIceGathererEventMap { } interface RTCIceGatherer extends RTCStatsProvider { - readonly component: string; + readonly component: RTCIceComponent; onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; @@ -13251,19 +13362,19 @@ interface RTCIceTransportEventMap { } interface RTCIceTransport extends RTCStatsProvider { - readonly component: string; + readonly component: RTCIceComponent; readonly iceGatherer: RTCIceGatherer | null; oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null; onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; - readonly role: string; - readonly state: string; + readonly role: RTCIceRole; + readonly state: RTCIceTransportState; addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; - start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -13275,7 +13386,7 @@ declare var RTCIceTransport: { } interface RTCIceTransportStateChangedEvent extends Event { - readonly state: string; + readonly state: RTCIceTransportState; } declare var RTCIceTransportStateChangedEvent: { @@ -13295,8 +13406,8 @@ interface RTCPeerConnectionEventMap { interface RTCPeerConnection extends EventTarget { readonly canTrickleIceCandidates: boolean | null; - readonly iceConnectionState: string; - readonly iceGatheringState: string; + readonly iceConnectionState: RTCIceConnectionState; + readonly iceGatheringState: RTCIceGatheringState; readonly localDescription: RTCSessionDescription | null; onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; @@ -13306,7 +13417,7 @@ interface RTCPeerConnection extends EventTarget { onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; readonly remoteDescription: RTCSessionDescription | null; - readonly signalingState: string; + readonly signalingState: RTCSignalingState; addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; addStream(stream: MediaStream): void; close(): void; @@ -13389,7 +13500,7 @@ declare var RTCRtpSender: { interface RTCSessionDescription { sdp: string | null; - type: string | null; + type: RTCSdpType | null; toJSON(): any; } @@ -13448,7 +13559,7 @@ interface Range { createContextualFragment(fragment: string): DocumentFragment; deleteContents(): void; detach(): void; - expand(Unit: string): boolean; + expand(Unit: ExpandGranularity): boolean; extractContents(): DocumentFragment; getBoundingClientRect(): ClientRect; getClientRects(): ClientRectList; @@ -13501,18 +13612,18 @@ declare var ReadableStreamReader: { } interface Request extends Object, Body { - readonly cache: string; - readonly credentials: string; - readonly destination: string; + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; readonly headers: Headers; readonly integrity: string; readonly keepalive: boolean; readonly method: string; - readonly mode: string; - readonly redirect: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; readonly referrer: string; - readonly referrerPolicy: string; - readonly type: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; readonly url: string; clone(): Request; } @@ -13528,7 +13639,7 @@ interface Response extends Object, Body { readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly type: string; + readonly type: ResponseType; readonly url: string; clone(): Response; } @@ -15328,7 +15439,7 @@ declare var SVGZoomEvent: { interface ScopedCredential { readonly id: ArrayBuffer; - readonly type: string; + readonly type: ScopedCredentialType; } declare var ScopedCredential: { @@ -15445,7 +15556,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap { interface ServiceWorker extends EventTarget, AbstractWorker { onstatechange: (this: ServiceWorker, ev: Event) => any; readonly scriptURL: USVString; - readonly state: string; + readonly state: ServiceWorkerState; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -15521,7 +15632,7 @@ interface SourceBuffer extends EventTarget { appendWindowStart: number; readonly audioTracks: AudioTrackList; readonly buffered: TimeRanges; - mode: string; + mode: AppendMode; timestampOffset: number; readonly updating: boolean; readonly videoTracks: VideoTrackList; @@ -15757,7 +15868,7 @@ interface Text extends CharacterData { declare var Text: { prototype: Text; - new(): Text; + new(data?: string): Text; } interface TextEvent extends UIEvent { @@ -15940,7 +16051,7 @@ interface TouchEvent extends UIEvent { declare var TouchEvent: { prototype: TouchEvent; - new(): TouchEvent; + new(type: string, touchEventInit?: TouchEventInit): TouchEvent; } interface TouchList { @@ -16017,7 +16128,7 @@ interface URL { protocol: string; search: string; username: string; - readonly searchparams: URLSearchParams; + readonly searchParams: URLSearchParams; toString(): string; } @@ -16146,7 +16257,7 @@ declare var WEBGL_depth_texture: { interface WaveShaperNode extends AudioNode { curve: Float32Array | null; - oversample: string; + oversample: OverSampleType; } declare var WaveShaperNode: { @@ -16341,12 +16452,12 @@ interface WebGLRenderingContext { 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, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): 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, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; uniform1f(location: WebGLUniformLocation | null, x: number): void; uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform1i(location: WebGLUniformLocation | null, x: number): void; @@ -17407,6 +17518,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly top: Window; readonly window: Window; URL: typeof URL; + URLSearchParams: typeof URLSearchParams; Blob: typeof Blob; customElements: CustomElementRegistry; alert(message?: any): void; @@ -17415,7 +17527,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window captureEvents(): void; close(): void; confirm(message?: string): boolean; - departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; + departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -17440,6 +17552,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; scroll(options?: ScrollToOptions): void; scrollTo(options?: ScrollToOptions): void; scrollBy(options?: ScrollToOptions): void; @@ -17488,7 +17602,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly readyState: number; readonly response: any; readonly responseText: string; - responseType: string; + responseType: XMLHttpRequestResponseType; readonly responseURL: string; readonly responseXML: Document | null; readonly status: number; @@ -17653,6 +17767,7 @@ interface Body { blob(): Promise; json(): Promise; text(): Promise; + formData(): Promise; } interface CanvasPathMethods { @@ -18015,6 +18130,21 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. @@ -18059,6 +18189,7 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; + [index: number]: T; } interface BlobPropertyBag { @@ -18328,6 +18459,21 @@ interface PromiseRejectionEventInit extends EventInit { reason?: any; } +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + +interface TouchEventInit extends EventModifierInit { + touches?: Touch[]; + targetTouches?: Touch[]; + changedTouches?: Touch[]; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -18385,10 +18531,10 @@ interface NavigatorUserMediaErrorCallback { (error: MediaStreamError): void; } interface ForEachCallback { - (keyId: any, status: string): void; + (keyId: any, status: MediaKeyStatus): void; } interface NotificationPermissionCallback { - (permission: string): void; + (permission: NotificationPermission): void; } interface IntersectionObserverCallback { (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; @@ -18995,7 +19141,7 @@ declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; -declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; +declare function departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -19020,12 +19166,14 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function scroll(options?: ScrollToOptions): void; declare function scrollTo(options?: ScrollToOptions): void; declare function scrollBy(options?: ScrollToOptions): void; declare function toString(): string; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; declare function clearInterval(handle: number): void; declare function clearTimeout(handle: number): void; declare function setInterval(handler: (...args: any[]) => void, timeout: number): number; @@ -19095,12 +19243,84 @@ type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; type ScrollRestoration = "auto" | "manual"; +type FormDataEntryValue = string | File; +type AppendMode = "segments" | "sequence"; +type AudioContextState = "suspended" | "running" | "closed"; +type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; +type CanvasFillRule = "nonzero" | "evenodd"; +type ChannelCountMode = "max" | "clamped-max" | "explicit"; +type ChannelInterpretation = "speakers" | "discrete"; +type DistanceModelType = "linear" | "inverse" | "exponential"; +type ExpandGranularity = "character" | "word" | "sentence" | "textedit"; +type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad"; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type ListeningState = "inactive" | "active" | "disambiguation"; +type MSCredentialType = "FIDO_2_0"; +type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived"; +type MSIceType = "failed" | "direct" | "relay"; +type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics"; +type MSTransportType = "Embedded" | "USB" | "NFC" | "BT"; +type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny"; +type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications"; +type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; +type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request"; +type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type MediaKeysRequirement = "required" | "optional" | "not-allowed"; +type MediaStreamTrackState = "live" | "ended"; +type NavigationReason = "up" | "down" | "left" | "right"; +type NavigationType = "navigate" | "reload" | "back_forward" | "prerender"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom"; +type OverSampleType = "none" | "2x" | "4x"; +type PanningModelType = "equalpower"; +type PaymentComplete = "success" | "fail" | ""; +type PaymentShippingType = "shipping" | "delivery" | "pickup"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle"; +type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced"; +type RTCDtlsRole = "auto" | "client" | "server"; +type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed"; +type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay"; +type RTCIceComponent = "RTP" | "RTCP"; +type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"; +type RTCIceGatherPolicy = "all" | "nohost" | "relay"; +type RTCIceGathererState = "new" | "gathering" | "complete"; +type RTCIceGatheringState = "new" | "gathering" | "complete"; +type RTCIceProtocol = "udp" | "tcp"; +type RTCIceRole = "controlling" | "controlled"; +type RTCIceTcpCandidateType = "active" | "passive" | "so"; +type RTCIceTransportPolicy = "none" | "relay" | "all"; +type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed"; +type RTCSdpType = "offer" | "pranswer" | "answer"; +type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"; +type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled"; +type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed"; +type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ScopedCredentialType = "ScopedCred"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type Transport = "usb" | "nfc" | "ble"; +type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; ///////////////////////////// -/// WorkerGlobalScope APIs +/// WorkerGlobalScope APIs ///////////////////////////// -// These are only available in a Web Worker +// These are only available in a Web Worker declare function importScripts(...urls: string[]): void; @@ -19135,7 +19355,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * 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; @@ -19205,9 +19425,9 @@ interface TextStreamReader extends TextStreamBase { 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). - */ + * 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; /** diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 39a0c3da684..94fb13c32ed 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -98,8 +98,8 @@ interface ConstrainLongRange extends LongRange { } interface ConstrainVideoFacingModeParameters { - exact?: string | string[]; - ideal?: string | string[]; + exact?: VideoFacingModeEnum | VideoFacingModeEnum[]; + ideal?: VideoFacingModeEnum | VideoFacingModeEnum[]; } interface CustomEventInit extends EventInit { @@ -328,7 +328,7 @@ interface MSAudioSendSignal { } interface MSConnectivity { - iceType?: string; + iceType?: MSIceType; iceWarningFlags?: MSIceWarningFlags; relayAddress?: MSRelayAddress; } @@ -338,11 +338,11 @@ interface MSCredentialFilter { } interface MSCredentialParameters { - type?: string; + type?: MSCredentialType; } interface MSCredentialSpec { - type?: string; + type?: MSCredentialType; id?: string; } @@ -353,7 +353,7 @@ interface MSDelay { interface MSDescription extends RTCStats { connectivity?: MSConnectivity; - transport?: string; + transport?: RTCIceProtocol; networkconnectivity?: MSNetworkConnectivityInfo; localAddr?: MSIPAddressInfo; remoteAddr?: MSIPAddressInfo; @@ -477,11 +477,11 @@ interface MSTransportDiagnosticsStats extends RTCStats { numConsentRespReceived?: number; interfaces?: MSNetworkInterfaceType; baseInterface?: MSNetworkInterfaceType; - protocol?: string; + protocol?: RTCIceProtocol; localInterface?: MSNetworkInterfaceType; - localAddrType?: string; - remoteAddrType?: string; - iceRole?: string; + localAddrType?: MSIceAddrType; + remoteAddrType?: MSIceAddrType; + iceRole?: RTCIceRole; rtpRtcpMux?: boolean; allocationTimeInMs?: number; msRtcEngineVersion?: string; @@ -554,7 +554,7 @@ interface MediaEncryptedEventInit extends EventInit { } interface MediaKeyMessageEventInit extends EventInit { - messageType?: string; + messageType?: MediaKeyMessageType; message?: ArrayBuffer; } @@ -562,8 +562,8 @@ interface MediaKeySystemConfiguration { initDataTypes?: string[]; audioCapabilities?: MediaKeySystemMediaCapability[]; videoCapabilities?: MediaKeySystemMediaCapability[]; - distinctiveIdentifier?: string; - persistentState?: string; + distinctiveIdentifier?: MediaKeysRequirement; + persistentState?: MediaKeysRequirement; } interface MediaKeySystemMediaCapability { @@ -687,7 +687,7 @@ interface MutationObserverInit { } interface NotificationOptions { - dir?: string; + dir?: NotificationDirection; lang?: string; body?: string; tag?: string; @@ -786,8 +786,8 @@ interface PushSubscriptionOptionsInit { interface RTCConfiguration { iceServers?: RTCIceServer[]; - iceTransportPolicy?: string; - bundlePolicy?: string; + iceTransportPolicy?: RTCIceTransportPolicy; + bundlePolicy?: RTCBundlePolicy; peerIdentity?: string; } @@ -801,7 +801,7 @@ interface RTCDtlsFingerprint { } interface RTCDtlsParameters { - role?: string; + role?: RTCDtlsRole; fingerprints?: RTCDtlsFingerprint[]; } @@ -809,7 +809,7 @@ interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; transport?: string; - candidateType?: string; + candidateType?: RTCStatsIceCandidateType; priority?: number; addressSourceUrl?: string; } @@ -821,10 +821,10 @@ interface RTCIceCandidateDictionary { foundation?: string; priority?: number; ip?: string; - protocol?: string; + protocol?: RTCIceProtocol; port?: number; - type?: string; - tcpType?: string; + type?: RTCIceCandidateType; + tcpType?: RTCIceTcpCandidateType; relatedAddress?: string; relatedPort?: number; msMTurnSessionId?: string; @@ -845,7 +845,7 @@ interface RTCIceCandidatePairStats extends RTCStats { transportId?: string; localCandidateId?: string; remoteCandidateId?: string; - state?: string; + state?: RTCStatsIceCandidatePairState; priority?: number; nominated?: boolean; writable?: boolean; @@ -858,7 +858,7 @@ interface RTCIceCandidatePairStats extends RTCStats { } interface RTCIceGatherOptions { - gatherPolicy?: string; + gatherPolicy?: RTCIceGatherPolicy; iceservers?: RTCIceServer[]; portRange?: MSPortRange; } @@ -1023,7 +1023,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; - degradationPreference?: string; + degradationPreference?: RTCDegradationPreference; } interface RTCRtpRtxParameters { @@ -1037,7 +1037,7 @@ interface RTCRtpUnhandled { } interface RTCSessionDescriptionInit { - type?: string; + type?: RTCSdpType; sdp?: string; } @@ -1063,9 +1063,9 @@ interface RTCSsrcRange { interface RTCStats { timestamp?: number; - type?: string; + type?: RTCStatsType; id?: string; - msType?: string; + msType?: MSStatsType; } interface RTCStatsReport { @@ -1090,11 +1090,11 @@ interface RequestInit { headers?: any; body?: any; referrer?: string; - referrerPolicy?: string; - mode?: string; - credentials?: string; - cache?: string; - redirect?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; integrity?: string; keepalive?: boolean; window?: any; @@ -1107,9 +1107,9 @@ interface ResponseInit { } interface ScopedCredentialDescriptor { - type?: string; + type?: ScopedCredentialType; id?: any; - transports?: string[]; + transports?: Transport[]; } interface ScopedCredentialOptions { @@ -1120,7 +1120,7 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - type?: string; + type?: ScopedCredentialType; algorithm?: string | Algorithm; } @@ -1350,7 +1350,7 @@ interface AudioContextBase extends EventTarget { readonly listener: AudioListener; onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - readonly state: string; + readonly state: AudioContextState; close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; @@ -1410,12 +1410,13 @@ declare var AudioListener: { interface AudioNode extends EventTarget { channelCount: number; - channelCountMode: string; - channelInterpretation: string; + channelCountMode: ChannelCountMode; + channelInterpretation: ChannelInterpretation; readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: number): void; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -1513,7 +1514,7 @@ interface BiquadFilterNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; readonly gain: AudioParam; - type: string; + type: BiquadFilterType; getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } @@ -2153,7 +2154,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { lineJoin: string; lineWidth: number; miterLimit: number; - msFillRule: string; + msFillRule: CanvasFillRule; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -2166,19 +2167,21 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { oImageSmoothingEnabled: boolean; beginPath(): void; clearRect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; + clip(fillRule?: CanvasFillRule): 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; drawFocusIfNeeded(element: Element): void; - 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; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; + fill(fillRule?: CanvasFillRule): 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; + isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean; measureText(text: string): TextMetrics; putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; restore(): void; @@ -2469,10 +2472,10 @@ declare var DOMException: { } interface DOMImplementation { - createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(): boolean; + hasFeature(feature: string | null, version: string | null): boolean; } declare var DOMImplementation: { @@ -2555,6 +2558,7 @@ interface DataTransfer { clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; + setDragImage(image: Element, x: number, y: number): void; } declare var DataTransfer: { @@ -2591,7 +2595,7 @@ declare var DataTransferItemList: { interface DeferredPermissionRequest { readonly id: number; - readonly type: string; + readonly type: MSWebViewPermissionType; readonly uri: string; allow(): void; deny(): void; @@ -3209,7 +3213,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Contains the title of the document. */ title: string; - readonly visibilityState: string; + readonly visibilityState: VisibilityState; /** * Sets or gets the color of the links that the user has visited. */ @@ -3224,7 +3228,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets or sets the version attribute specified in the declaration of an XML document. */ xmlVersion: string | null; - adoptNode(source: Node): Node; + adoptNode(source: T): T; captureEvents(): void; caretRangeFromPoint(x: number, y: number): Range; clear(): void; @@ -3401,7 +3405,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets a value indicating whether the object currently has focus. */ hasFocus(): boolean; - importNode(importedNode: Node, deep: boolean): Node; + importNode(importedNode: T, deep: boolean): T; msElementsFromPoint(x: number, y: number): NodeListOf; msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; /** @@ -3469,6 +3473,7 @@ declare var Document: { } interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; } declare var DocumentFragment: { @@ -3716,9 +3721,9 @@ declare var Event: { } interface EventTarget { - addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare var EventTarget: { @@ -3797,7 +3802,7 @@ declare var FocusEvent: { } interface FocusNavigationEvent extends Event { - readonly navigationReason: string; + readonly navigationReason: NavigationReason; readonly originHeight: number; readonly originLeft: number; readonly originTop: number; @@ -3811,7 +3816,12 @@ declare var FocusNavigationEvent: { } interface FormData { - append(name: any, value: any, blobName?: string): void; + append(name: string, value: string | Blob, fileName?: string): void; + delete(name: string): void; + get(name: string): FormDataEntryValue | null; + getAll(name: string): FormDataEntryValue[]; + has(name: string): boolean; + set(name: string, value: string | Blob, fileName?: string): void; } declare var FormData: { @@ -6973,7 +6983,7 @@ declare var History: { } interface IDBCursor { - readonly direction: string; + readonly direction: IDBCursorDirection; key: IDBKeyRange | IDBValidKey; readonly primaryKey: any; source: IDBObjectStore | IDBIndex; @@ -7125,7 +7135,7 @@ interface IDBRequest extends EventTarget { readonly error: DOMError; onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; - readonly readyState: string; + readonly readyState: IDBRequestReadyState; readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; @@ -7147,7 +7157,7 @@ interface IDBTransactionEventMap { interface IDBTransaction extends EventTarget { readonly db: IDBDatabase; readonly error: DOMError; - readonly mode: string; + readonly mode: IDBTransactionMode; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; onerror: (this: IDBTransaction, ev: Event) => any; @@ -7265,7 +7275,7 @@ declare var KeyboardEvent: { interface ListeningStateChangedEvent extends Event { readonly label: string; - readonly state: string; + readonly state: ListeningState; } declare var ListeningStateChangedEvent: { @@ -7356,7 +7366,7 @@ declare var MSAppAsyncOperation: { interface MSAssertion { readonly id: string; - readonly type: string; + readonly type: MSCredentialType; } declare var MSAssertion: { @@ -7388,7 +7398,7 @@ interface MSFIDOCredentialAssertion extends MSAssertion { readonly algorithm: string | Algorithm; readonly attestation: any; readonly publicKey: string; - readonly transportHints: string[]; + readonly transportHints: MSTransportType[]; } declare var MSFIDOCredentialAssertion: { @@ -7492,7 +7502,7 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; - navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; + navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; @@ -7747,7 +7757,7 @@ declare var MSWebViewSettings: { interface MediaDeviceInfo { readonly deviceId: string; readonly groupId: string; - readonly kind: string; + readonly kind: MediaDeviceKind; readonly label: string; } @@ -7814,7 +7824,7 @@ declare var MediaError: { interface MediaKeyMessageEvent extends Event { readonly message: ArrayBuffer; - readonly messageType: string; + readonly messageType: MediaKeyMessageType; } declare var MediaKeyMessageEvent: { @@ -7842,7 +7852,7 @@ declare var MediaKeySession: { interface MediaKeyStatusMap { readonly size: number; forEach(callback: ForEachCallback): void; - get(keyId: any): string; + get(keyId: any): MediaKeyStatus; has(keyId: any): boolean; } @@ -7863,7 +7873,7 @@ declare var MediaKeySystemAccess: { } interface MediaKeys { - createSession(sessionType?: string): MediaKeySession; + createSession(sessionType?: MediaKeySessionType): MediaKeySession; setServerCertificate(serverCertificate: any): Promise; } @@ -8001,7 +8011,7 @@ interface MediaStreamTrack extends EventTarget { onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; onunmute: (this: MediaStreamTrack, ev: Event) => any; readonly readonly: boolean; - readonly readyState: string; + readonly readyState: MediaStreamTrackState; readonly remote: boolean; applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; @@ -8222,7 +8232,7 @@ declare var NavigationEventWithReferrer: { interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; - gamepadInputEmulation: string; + gamepadInputEmulation: GamepadInputEmulationType; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -8269,15 +8279,15 @@ interface Node extends EventTarget { contains(child: Node): boolean; hasAttributes(): boolean; hasChildNodes(): boolean; - insertBefore(newChild: Node, refChild: Node | null): Node; + insertBefore(newChild: T, refChild: Node | null): T; isDefaultNamespace(namespaceURI: string | null): boolean; isEqualNode(arg: Node): boolean; isSameNode(other: Node): boolean; lookupNamespaceURI(prefix: string | null): string | null; lookupPrefix(namespaceURI: string | null): string | null; normalize(): void; - removeChild(oldChild: Node): Node; - replaceChild(newChild: Node, oldChild: Node): Node; + removeChild(oldChild: T): T; + replaceChild(newChild: Node, oldChild: T): T; readonly ATTRIBUTE_NODE: number; readonly CDATA_SECTION_NODE: number; readonly COMMENT_NODE: number; @@ -8379,14 +8389,14 @@ interface NotificationEventMap { interface Notification extends EventTarget { readonly body: string; - readonly dir: string; + readonly dir: NotificationDirection; readonly icon: string; readonly lang: string; onclick: (this: Notification, ev: Event) => any; onclose: (this: Notification, ev: Event) => any; onerror: (this: Notification, ev: Event) => any; onshow: (this: Notification, ev: Event) => any; - readonly permission: string; + readonly permission: NotificationPermission; readonly tag: string; readonly title: string; close(): void; @@ -8397,7 +8407,7 @@ interface Notification extends EventTarget { declare var Notification: { prototype: Notification; new(title: string, options?: NotificationOptions): Notification; - requestPermission(callback?: NotificationPermissionCallback): Promise; + requestPermission(callback?: NotificationPermissionCallback): Promise; } interface OES_element_index_uint { @@ -8487,7 +8497,7 @@ interface OscillatorNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any; - type: string; + type: OscillatorType; setPeriodicWave(periodicWave: PeriodicWave): void; start(when?: number): void; stop(when?: number): void; @@ -8530,9 +8540,9 @@ interface PannerNode extends AudioNode { coneInnerAngle: number; coneOuterAngle: number; coneOuterGain: number; - distanceModel: string; + distanceModel: DistanceModelType; maxDistance: number; - panningModel: string; + panningModel: PanningModelType; refDistance: number; rolloffFactor: number; setOrientation(x: number, y: number, z: number): void; @@ -8583,7 +8593,7 @@ interface PaymentRequest extends EventTarget { onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; - readonly shippingType: string | null; + readonly shippingType: PaymentShippingType | null; abort(): Promise; show(): Promise; addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; @@ -8612,7 +8622,7 @@ interface PaymentResponse { readonly payerPhone: string | null; readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; - complete(result?: string): Promise; + complete(result?: PaymentComplete): Promise; toJSON(): any; } @@ -8740,7 +8750,7 @@ interface PerformanceNavigationTiming extends PerformanceEntry { readonly requestStart: number; readonly responseEnd: number; readonly responseStart: number; - readonly type: string; + readonly type: NavigationType; readonly unloadEventEnd: number; readonly unloadEventStart: number; } @@ -8809,7 +8819,7 @@ declare var PeriodicWave: { } interface PermissionRequest extends DeferredPermissionRequest { - readonly state: string; + readonly state: MSWebViewPermissionState; defer(): void; } @@ -8939,7 +8949,7 @@ declare var ProgressEvent: { interface PushManager { getSubscription(): Promise; - permissionState(options?: PushSubscriptionOptionsInit): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; subscribe(options?: PushSubscriptionOptionsInit): Promise; } @@ -8951,7 +8961,7 @@ declare var PushManager: { interface PushSubscription { readonly endpoint: USVString; readonly options: PushSubscriptionOptions; - getKey(name: string): ArrayBuffer | null; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; toJSON(): any; unsubscribe(): Promise; } @@ -8988,7 +8998,7 @@ interface RTCDtlsTransportEventMap { interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; - readonly state: string; + readonly state: RTCDtlsTransportState; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; getRemoteCertificates(): ArrayBuffer[]; @@ -9005,7 +9015,7 @@ declare var RTCDtlsTransport: { } interface RTCDtlsTransportStateChangedEvent extends Event { - readonly state: string; + readonly state: RTCDtlsTransportState; } declare var RTCDtlsTransportStateChangedEvent: { @@ -9061,7 +9071,7 @@ interface RTCIceGathererEventMap { } interface RTCIceGatherer extends RTCStatsProvider { - readonly component: string; + readonly component: RTCIceComponent; onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; @@ -9091,19 +9101,19 @@ interface RTCIceTransportEventMap { } interface RTCIceTransport extends RTCStatsProvider { - readonly component: string; + readonly component: RTCIceComponent; readonly iceGatherer: RTCIceGatherer | null; oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null; onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; - readonly role: string; - readonly state: string; + readonly role: RTCIceRole; + readonly state: RTCIceTransportState; addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; - start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -9115,7 +9125,7 @@ declare var RTCIceTransport: { } interface RTCIceTransportStateChangedEvent extends Event { - readonly state: string; + readonly state: RTCIceTransportState; } declare var RTCIceTransportStateChangedEvent: { @@ -9135,8 +9145,8 @@ interface RTCPeerConnectionEventMap { interface RTCPeerConnection extends EventTarget { readonly canTrickleIceCandidates: boolean | null; - readonly iceConnectionState: string; - readonly iceGatheringState: string; + readonly iceConnectionState: RTCIceConnectionState; + readonly iceGatheringState: RTCIceGatheringState; readonly localDescription: RTCSessionDescription | null; onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; @@ -9146,7 +9156,7 @@ interface RTCPeerConnection extends EventTarget { onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; readonly remoteDescription: RTCSessionDescription | null; - readonly signalingState: string; + readonly signalingState: RTCSignalingState; addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; addStream(stream: MediaStream): void; close(): void; @@ -9229,7 +9239,7 @@ declare var RTCRtpSender: { interface RTCSessionDescription { sdp: string | null; - type: string | null; + type: RTCSdpType | null; toJSON(): any; } @@ -9288,7 +9298,7 @@ interface Range { createContextualFragment(fragment: string): DocumentFragment; deleteContents(): void; detach(): void; - expand(Unit: string): boolean; + expand(Unit: ExpandGranularity): boolean; extractContents(): DocumentFragment; getBoundingClientRect(): ClientRect; getClientRects(): ClientRectList; @@ -9341,18 +9351,18 @@ declare var ReadableStreamReader: { } interface Request extends Object, Body { - readonly cache: string; - readonly credentials: string; - readonly destination: string; + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; readonly headers: Headers; readonly integrity: string; readonly keepalive: boolean; readonly method: string; - readonly mode: string; - readonly redirect: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; readonly referrer: string; - readonly referrerPolicy: string; - readonly type: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; readonly url: string; clone(): Request; } @@ -9368,7 +9378,7 @@ interface Response extends Object, Body { readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly type: string; + readonly type: ResponseType; readonly url: string; clone(): Response; } @@ -11168,7 +11178,7 @@ declare var SVGZoomEvent: { interface ScopedCredential { readonly id: ArrayBuffer; - readonly type: string; + readonly type: ScopedCredentialType; } declare var ScopedCredential: { @@ -11285,7 +11295,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap { interface ServiceWorker extends EventTarget, AbstractWorker { onstatechange: (this: ServiceWorker, ev: Event) => any; readonly scriptURL: USVString; - readonly state: string; + readonly state: ServiceWorkerState; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -11361,7 +11371,7 @@ interface SourceBuffer extends EventTarget { appendWindowStart: number; readonly audioTracks: AudioTrackList; readonly buffered: TimeRanges; - mode: string; + mode: AppendMode; timestampOffset: number; readonly updating: boolean; readonly videoTracks: VideoTrackList; @@ -11597,7 +11607,7 @@ interface Text extends CharacterData { declare var Text: { prototype: Text; - new(): Text; + new(data?: string): Text; } interface TextEvent extends UIEvent { @@ -11780,7 +11790,7 @@ interface TouchEvent extends UIEvent { declare var TouchEvent: { prototype: TouchEvent; - new(): TouchEvent; + new(type: string, touchEventInit?: TouchEventInit): TouchEvent; } interface TouchList { @@ -11857,7 +11867,7 @@ interface URL { protocol: string; search: string; username: string; - readonly searchparams: URLSearchParams; + readonly searchParams: URLSearchParams; toString(): string; } @@ -11986,7 +11996,7 @@ declare var WEBGL_depth_texture: { interface WaveShaperNode extends AudioNode { curve: Float32Array | null; - oversample: string; + oversample: OverSampleType; } declare var WaveShaperNode: { @@ -12181,12 +12191,12 @@ interface WebGLRenderingContext { 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, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): 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, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; uniform1f(location: WebGLUniformLocation | null, x: number): void; uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform1i(location: WebGLUniformLocation | null, x: number): void; @@ -13247,6 +13257,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly top: Window; readonly window: Window; URL: typeof URL; + URLSearchParams: typeof URLSearchParams; Blob: typeof Blob; customElements: CustomElementRegistry; alert(message?: any): void; @@ -13255,7 +13266,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window captureEvents(): void; close(): void; confirm(message?: string): boolean; - departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; + departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -13280,6 +13291,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; scroll(options?: ScrollToOptions): void; scrollTo(options?: ScrollToOptions): void; scrollBy(options?: ScrollToOptions): void; @@ -13328,7 +13341,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly readyState: number; readonly response: any; readonly responseText: string; - responseType: string; + responseType: XMLHttpRequestResponseType; readonly responseURL: string; readonly responseXML: Document | null; readonly status: number; @@ -13493,6 +13506,7 @@ interface Body { blob(): Promise; json(): Promise; text(): Promise; + formData(): Promise; } interface CanvasPathMethods { @@ -13855,6 +13869,21 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. @@ -13899,6 +13928,7 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; + [index: number]: T; } interface BlobPropertyBag { @@ -14168,6 +14198,21 @@ interface PromiseRejectionEventInit extends EventInit { reason?: any; } +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + +interface TouchEventInit extends EventModifierInit { + touches?: Touch[]; + targetTouches?: Touch[]; + changedTouches?: Touch[]; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -14225,10 +14270,10 @@ interface NavigatorUserMediaErrorCallback { (error: MediaStreamError): void; } interface ForEachCallback { - (keyId: any, status: string): void; + (keyId: any, status: MediaKeyStatus): void; } interface NotificationPermissionCallback { - (permission: string): void; + (permission: NotificationPermission): void; } interface IntersectionObserverCallback { (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; @@ -14835,7 +14880,7 @@ declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; -declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; +declare function departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -14860,12 +14905,14 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function scroll(options?: ScrollToOptions): void; declare function scrollTo(options?: ScrollToOptions): void; declare function scrollBy(options?: ScrollToOptions): void; declare function toString(): string; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; declare function clearInterval(handle: number): void; declare function clearTimeout(handle: number): void; declare function setInterval(handler: (...args: any[]) => void, timeout: number): number; @@ -14934,4 +14981,76 @@ type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; -type ScrollRestoration = "auto" | "manual"; \ No newline at end of file +type ScrollRestoration = "auto" | "manual"; +type FormDataEntryValue = string | File; +type AppendMode = "segments" | "sequence"; +type AudioContextState = "suspended" | "running" | "closed"; +type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; +type CanvasFillRule = "nonzero" | "evenodd"; +type ChannelCountMode = "max" | "clamped-max" | "explicit"; +type ChannelInterpretation = "speakers" | "discrete"; +type DistanceModelType = "linear" | "inverse" | "exponential"; +type ExpandGranularity = "character" | "word" | "sentence" | "textedit"; +type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad"; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type ListeningState = "inactive" | "active" | "disambiguation"; +type MSCredentialType = "FIDO_2_0"; +type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived"; +type MSIceType = "failed" | "direct" | "relay"; +type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics"; +type MSTransportType = "Embedded" | "USB" | "NFC" | "BT"; +type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny"; +type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications"; +type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; +type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request"; +type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type MediaKeysRequirement = "required" | "optional" | "not-allowed"; +type MediaStreamTrackState = "live" | "ended"; +type NavigationReason = "up" | "down" | "left" | "right"; +type NavigationType = "navigate" | "reload" | "back_forward" | "prerender"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom"; +type OverSampleType = "none" | "2x" | "4x"; +type PanningModelType = "equalpower"; +type PaymentComplete = "success" | "fail" | ""; +type PaymentShippingType = "shipping" | "delivery" | "pickup"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle"; +type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced"; +type RTCDtlsRole = "auto" | "client" | "server"; +type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed"; +type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay"; +type RTCIceComponent = "RTP" | "RTCP"; +type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"; +type RTCIceGatherPolicy = "all" | "nohost" | "relay"; +type RTCIceGathererState = "new" | "gathering" | "complete"; +type RTCIceGatheringState = "new" | "gathering" | "complete"; +type RTCIceProtocol = "udp" | "tcp"; +type RTCIceRole = "controlling" | "controlled"; +type RTCIceTcpCandidateType = "active" | "passive" | "so"; +type RTCIceTransportPolicy = "none" | "relay" | "all"; +type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed"; +type RTCSdpType = "offer" | "pranswer" | "answer"; +type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"; +type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled"; +type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed"; +type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ScopedCredentialType = "ScopedCred"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type Transport = "usb" | "nfc" | "ble"; +type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; \ No newline at end of file diff --git a/lib/lib.dom.iterable.d.ts b/lib/lib.dom.iterable.d.ts index 7557e4d06e3..382099148f6 100644 --- a/lib/lib.dom.iterable.d.ts +++ b/lib/lib.dom.iterable.d.ts @@ -24,10 +24,104 @@ interface DOMTokenList { [Symbol.iterator](): IterableIterator; } +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, string | File]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface Headers { + [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value pairs contained in this object. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all keys f the key/value pairs contained in this object. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values of the key/value pairs contained in this object. + */ + values(): IterableIterator; +} + interface NodeList { - [Symbol.iterator](): IterableIterator + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; } interface NodeListOf { - [Symbol.iterator](): IterableIterator + + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; + + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface URLSearchParams { + /** + * Returns an array of key, value pairs for every entry in the search params + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns a list of keys in the search params + */ + keys(): IterableIterator; + /** + * Returns a list of values in the search params + */ + values(): IterableIterator; + /** + * iterate over key/value pairs + */ + [Symbol.iterator](): IterableIterator<[string, string]>; } diff --git a/lib/lib.es2015.collection.d.ts b/lib/lib.es2015.collection.d.ts index bf36745dcf9..4d84af429be 100644 --- a/lib/lib.es2015.collection.d.ts +++ b/lib/lib.es2015.collection.d.ts @@ -37,7 +37,7 @@ declare var Map: MapConstructor; interface ReadonlyMap { forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; - get(key: K): V|undefined; + get(key: K): V | undefined; has(key: K): boolean; readonly size: number; } @@ -50,9 +50,9 @@ interface WeakMap { } interface WeakMapConstructor { - new (): WeakMap; + new (): WeakMap; new (entries?: [K, V][]): WeakMap; - readonly prototype: WeakMap; + readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -85,8 +85,8 @@ interface WeakSet { } interface WeakSetConstructor { - new (): WeakSet; - new (values?: T[]): WeakSet; - readonly prototype: WeakSet; + new (): WeakSet; + new (values?: T[]): WeakSet; + readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; diff --git a/lib/lib.es2015.core.d.ts b/lib/lib.es2015.core.d.ts index ae633957cd5..bf2edb82ca6 100644 --- a/lib/lib.es2015.core.d.ts +++ b/lib/lib.es2015.core.d.ts @@ -22,69 +22,75 @@ declare type PropertyKey = string | number | symbol; interface Array { /** - * 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 | undefined; + * 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: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg 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: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): 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. - */ + * 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): this; /** - * 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. - */ + * 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): this; } 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 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: (this: void, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ from(arrayLike: ArrayLike): Array; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * 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; } @@ -94,328 +100,332 @@ interface DateConstructor { interface Function { /** - * Returns the name of the function. Function names are read-only and can not be changed. - */ + * Returns the name of the function. Function names are read-only and can not be changed. + */ readonly name: string; } interface Math { /** - * Returns the number of leading zero bits in the 32-bit binary representation of a number. - * @param x A numeric expression. - */ + * 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 - */ + * 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 - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ cbrt(x: number): number; } 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. - */ + * 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 isFinite, 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. - */ + * Returns true if passed value is finite. + * Unlike the global isFinite, 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. - */ + * 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. - */ + * 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. - */ + * 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.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. - */ + * 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.MAX_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)). - */ + * 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. - */ + * 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. - */ + * 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 Object { /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: PropertyKey): boolean + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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; + * 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: object, ...sources: any[]): any; /** - * Returns an array of all symbol properties found directly on object o. - * @param o Object to retrieve the symbols from. - */ + * 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. - */ + * 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. - */ + * 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: object | null): 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. - */ + * 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. - */ + * 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 ReadonlyArray { - /** - * 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: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + /** + * 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: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg 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: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; } interface RegExp { /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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; } @@ -426,64 +436,64 @@ interface RegExpConstructor { interface String { /** - * 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. - */ + * 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 | undefined; /** - * 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. - */ + * 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. - */ + * 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" - */ + * 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: "NFC" | "NFD" | "NFKC" | "NFKD"): string; /** - * 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" - */ + * 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 - */ + * 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. - */ + * 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; /** - * Returns an HTML anchor element and sets the name attribute to the text value - * @param name - */ + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ anchor(name: string): string; /** Returns a HTML element */ @@ -496,10 +506,10 @@ interface String { bold(): string; /** Returns a HTML element */ - fixed(): string + fixed(): string; /** Returns a HTML element and sets the color attribute value */ - fontcolor(color: string): string + fontcolor(color: string): string; /** Returns a HTML element and sets the size attribute value */ fontsize(size: number): string; @@ -528,17 +538,17 @@ interface 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. - */ + * 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. - */ + * 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; } diff --git a/lib/lib.es2015.generator.d.ts b/lib/lib.es2015.generator.d.ts index 3166063a42e..d331a58b5c2 100644 --- a/lib/lib.es2015.generator.d.ts +++ b/lib/lib.es2015.generator.d.ts @@ -18,15 +18,55 @@ and limitations under the License. /// -interface GeneratorFunction extends Function { } +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; +} interface GeneratorFunctionConstructor { /** - * Creates a new Generator function. - * @param args A list of arguments the function accepts. - */ + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; diff --git a/lib/lib.es2015.iterable.d.ts b/lib/lib.es2015.iterable.d.ts index 3f9ffc62f3c..1fe1a0e0ca1 100644 --- a/lib/lib.es2015.iterable.d.ts +++ b/lib/lib.es2015.iterable.d.ts @@ -21,10 +21,10 @@ and limitations under the License. /// interface SymbolConstructor { - /** - * A method that returns the default iterator for an object. Called by the semantics of the - * for-of statement. - */ + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ readonly iterator: symbol; } @@ -51,35 +51,37 @@ interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } interface ArrayConstructor { /** - * 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 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: (this: void, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ from(iterable: Iterable): Array; } @@ -87,19 +89,19 @@ interface ReadonlyArray { /** Iterator */ [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -109,7 +111,7 @@ interface IArguments { } interface Map { - [Symbol.iterator](): IterableIterator<[K,V]>; + [Symbol.iterator](): IterableIterator<[K, V]>; entries(): IterableIterator<[K, V]>; keys(): IterableIterator; values(): IterableIterator; @@ -139,22 +141,22 @@ interface SetConstructor { interface WeakSet { } interface WeakSetConstructor { - new (iterable: Iterable): WeakSet; + new (iterable: Iterable): WeakSet; } interface Promise { } interface PromiseConstructor { /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises + * 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: Iterable>): Promise; - + /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * 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. @@ -163,7 +165,7 @@ interface PromiseConstructor { } declare namespace Reflect { - function enumerate(target: any): IterableIterator; + function enumerate(target: object): IterableIterator; } interface String { @@ -172,22 +174,22 @@ interface String { } /** - * 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -195,31 +197,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -227,33 +233,37 @@ 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; + * 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: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -262,33 +272,37 @@ interface Uint8ClampedArrayConstructor { /** - * 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; + * 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: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -296,31 +310,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -328,31 +346,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -360,31 +382,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -392,31 +418,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -424,31 +454,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -456,10 +490,14 @@ 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; + * 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: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; } diff --git a/lib/lib.es2015.promise.d.ts b/lib/lib.es2015.promise.d.ts index b628cb89015..81118e89d27 100644 --- a/lib/lib.es2015.promise.d.ts +++ b/lib/lib.es2015.promise.d.ts @@ -20,8 +20,8 @@ and limitations under the License. interface PromiseConstructor { /** - * A reference to the prototype. - */ + * A reference to the prototype. + */ readonly prototype: Promise; /** @@ -207,10 +207,10 @@ interface PromiseConstructor { 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. - */ + * 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; /** diff --git a/lib/lib.es2015.proxy.d.ts b/lib/lib.es2015.proxy.d.ts index 3b1d8828575..29b12d91e24 100644 --- a/lib/lib.es2015.proxy.d.ts +++ b/lib/lib.es2015.proxy.d.ts @@ -18,7 +18,7 @@ and limitations under the License. /// -interface ProxyHandler { +interface ProxyHandler { getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; @@ -32,11 +32,11 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): object + construct? (target: T, argArray: any, newTarget?: any): object; } interface ProxyConstructor { - revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; - new (target: T, handler: ProxyHandler): T + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T; } declare var Proxy: ProxyConstructor; diff --git a/lib/lib.es2015.reflect.d.ts b/lib/lib.es2015.reflect.d.ts index 53a087143c9..2bea5f1e59b 100644 --- a/lib/lib.es2015.reflect.d.ts +++ b/lib/lib.es2015.reflect.d.ts @@ -21,15 +21,15 @@ and limitations under the License. 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 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: PropertyKey): 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; -} \ No newline at end of file + function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: object, propertyKey: PropertyKey): boolean; + function get(target: object, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: object): object; + function has(target: object, propertyKey: PropertyKey): boolean; + function isExtensible(target: object): boolean; + function ownKeys(target: object): Array; + function preventExtensions(target: object): boolean; + function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: object, proto: any): boolean; +} diff --git a/lib/lib.es2015.symbol.d.ts b/lib/lib.es2015.symbol.d.ts index f1a87d316a0..a9cce33094b 100644 --- a/lib/lib.es2015.symbol.d.ts +++ b/lib/lib.es2015.symbol.d.ts @@ -27,29 +27,29 @@ interface Symbol { } interface SymbolConstructor { - /** - * A reference to the prototype. - */ + /** + * 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 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. - */ + * 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. - */ + * 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 | undefined; } diff --git a/lib/lib.es2015.symbol.wellknown.d.ts b/lib/lib.es2015.symbol.wellknown.d.ts index 4668862af5f..1d17534723a 100644 --- a/lib/lib.es2015.symbol.wellknown.d.ts +++ b/lib/lib.es2015.symbol.wellknown.d.ts @@ -21,64 +21,64 @@ and limitations under the License. /// 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. - */ + /** + * 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. - */ + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ readonly isConcatSpreadable: symbol; /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.match method. - */ + * 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. - */ + /** + * 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. - */ + * 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. - */ + /** + * 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. - */ + * 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. - */ + /** + * 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. - */ + /** + * 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. - */ + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ readonly unscopables: symbol; } @@ -157,7 +157,7 @@ interface Function { [Symbol.hasInstance](value: any): boolean; } -interface GeneratorFunction extends Function { +interface GeneratorFunction { readonly [Symbol.toStringTag]: "GeneratorFunction"; } @@ -174,50 +174,50 @@ interface PromiseConstructor { } 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. - */ + /** + * 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 | null; /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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[]; } @@ -227,45 +227,45 @@ interface RegExpConstructor { interface String { /** - * 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. - */ + * 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 | null; }): RegExpMatchArray | null; /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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 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[]; } /** - * 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. - */ + * 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"; } @@ -275,73 +275,73 @@ interface 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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "Float64Array"; } diff --git a/lib/lib.es2016.array.include.d.ts b/lib/lib.es2016.array.include.d.ts index f2e80297db0..734fa450daf 100644 --- a/lib/lib.es2016.array.include.d.ts +++ b/lib/lib.es2016.array.include.d.ts @@ -20,99 +20,99 @@ and limitations under the License. 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. - */ + * 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 ReadonlyArray { /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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.es2016.full.d.ts b/lib/lib.es2016.full.d.ts new file mode 100644 index 00000000000..737357fef6d --- /dev/null +++ b/lib/lib.es2016.full.d.ts @@ -0,0 +1,15468 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + + +/// + + +/// +/// + + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + +interface Algorithm { + name: string; +} + +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; +} + +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; +} + +interface CompositionEventInit extends UIEventInit { + data?: string; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface ConstrainBooleanParameters { + exact?: boolean; + ideal?: boolean; +} + +interface ConstrainDOMStringParameters { + exact?: string | string[]; + ideal?: string | string[]; +} + +interface ConstrainDoubleRange extends DoubleRange { + exact?: number; + ideal?: number; +} + +interface ConstrainLongRange extends LongRange { + exact?: number; + ideal?: number; +} + +interface ConstrainVideoFacingModeParameters { + exact?: VideoFacingModeEnum | VideoFacingModeEnum[]; + ideal?: VideoFacingModeEnum | VideoFacingModeEnum[]; +} + +interface CustomEventInit extends EventInit { + detail?: any; +} + +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceLightEventInit extends EventInit { + value?: number; +} + +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface DoubleRange { + max?: number; + min?: number; +} + +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + +interface EventInit { + scoped?: boolean; + bubbles?: boolean; + cancelable?: boolean; +} + +interface EventModifierInit extends UIEventInit { + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + modifierAltGraph?: boolean; + modifierCapsLock?: boolean; + modifierFn?: boolean; + modifierFnLock?: boolean; + modifierHyper?: boolean; + modifierNumLock?: boolean; + modifierOS?: boolean; + modifierScrollLock?: boolean; + modifierSuper?: boolean; + modifierSymbol?: boolean; + modifierSymbolLock?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface FocusEventInit extends UIEventInit { + relatedTarget?: EventTarget; +} + +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + +interface HashChangeEventInit extends EventInit { + newURL?: string; + oldURL?: string; +} + +interface IDBIndexParameters { + multiEntry?: boolean; + unique?: boolean; +} + +interface IDBObjectStoreParameters { + autoIncrement?: boolean; + keyPath?: IDBKeyPath; +} + +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + +interface KeyAlgorithm { + name?: string; +} + +interface KeyboardEventInit extends EventModifierInit { + code?: string; + key?: string; + location?: number; + repeat?: boolean; +} + +interface LongRange { + max?: number; + min?: number; +} + +interface MSAccountInfo { + rpDisplayName?: string; + userDisplayName?: string; + accountName?: string; + userId?: string; + accountImageUri?: string; +} + +interface MSAudioLocalClientEvent extends MSLocalClientEventBase { + networkSendQualityEventRatio?: number; + networkDelayEventRatio?: number; + cpuInsufficientEventRatio?: number; + deviceHalfDuplexAECEventRatio?: number; + deviceRenderNotFunctioningEventRatio?: number; + deviceCaptureNotFunctioningEventRatio?: number; + deviceGlitchesEventRatio?: number; + deviceLowSNREventRatio?: number; + deviceLowSpeechLevelEventRatio?: number; + deviceClippingEventRatio?: number; + deviceEchoEventRatio?: number; + deviceNearEndToEchoRatioEventRatio?: number; + deviceRenderZeroVolumeEventRatio?: number; + deviceRenderMuteEventRatio?: number; + deviceMultipleEndpointsEventCount?: number; + deviceHowlingEventCount?: number; +} + +interface MSAudioRecvPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioRecvSignal; + packetReorderRatio?: number; + packetReorderDepthAvg?: number; + packetReorderDepthMax?: number; + burstLossLength1?: number; + burstLossLength2?: number; + burstLossLength3?: number; + burstLossLength4?: number; + burstLossLength5?: number; + burstLossLength6?: number; + burstLossLength7?: number; + burstLossLength8OrHigher?: number; + fecRecvDistance1?: number; + fecRecvDistance2?: number; + fecRecvDistance3?: number; + ratioConcealedSamplesAvg?: number; + ratioStretchedSamplesAvg?: number; + ratioCompressedSamplesAvg?: number; +} + +interface MSAudioRecvSignal { + initialSignalLevelRMS?: number; + recvSignalLevelCh1?: number; + recvNoiseLevelCh1?: number; + renderSignalLevel?: number; + renderNoiseLevel?: number; + renderLoopbackSignalLevel?: number; +} + +interface MSAudioSendPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioSendSignal; + audioFECUsed?: boolean; + sendMutePercent?: number; +} + +interface MSAudioSendSignal { + noiseLevel?: number; + sendSignalLevelCh1?: number; + sendNoiseLevelCh1?: number; +} + +interface MSConnectivity { + iceType?: MSIceType; + iceWarningFlags?: MSIceWarningFlags; + relayAddress?: MSRelayAddress; +} + +interface MSCredentialFilter { + accept?: MSCredentialSpec[]; +} + +interface MSCredentialParameters { + type?: MSCredentialType; +} + +interface MSCredentialSpec { + type?: MSCredentialType; + id?: string; +} + +interface MSDelay { + roundTrip?: number; + roundTripMax?: number; +} + +interface MSDescription extends RTCStats { + connectivity?: MSConnectivity; + transport?: RTCIceProtocol; + networkconnectivity?: MSNetworkConnectivityInfo; + localAddr?: MSIPAddressInfo; + remoteAddr?: MSIPAddressInfo; + deviceDevName?: string; + reflexiveLocalIPAddr?: MSIPAddressInfo; +} + +interface MSFIDOCredentialParameters extends MSCredentialParameters { + algorithm?: string | Algorithm; + authenticators?: AAGUID[]; +} + +interface MSIPAddressInfo { + ipAddr?: string; + port?: number; + manufacturerMacAddrMask?: string; +} + +interface MSIceWarningFlags { + turnTcpTimedOut?: boolean; + turnUdpAllocateFailed?: boolean; + turnUdpSendFailed?: boolean; + turnTcpAllocateFailed?: boolean; + turnTcpSendFailed?: boolean; + udpLocalConnectivityFailed?: boolean; + udpNatConnectivityFailed?: boolean; + udpRelayConnectivityFailed?: boolean; + tcpNatConnectivityFailed?: boolean; + tcpRelayConnectivityFailed?: boolean; + connCheckMessageIntegrityFailed?: boolean; + allocationMessageIntegrityFailed?: boolean; + connCheckOtherError?: boolean; + turnAuthUnknownUsernameError?: boolean; + noRelayServersConfigured?: boolean; + multipleRelayServersAttempted?: boolean; + portRangeExhausted?: boolean; + alternateServerReceived?: boolean; + pseudoTLSFailure?: boolean; + turnTurnTcpConnectivityFailed?: boolean; + useCandidateChecksFailed?: boolean; + fipsAllocationFailure?: boolean; +} + +interface MSJitter { + interArrival?: number; + interArrivalMax?: number; + interArrivalSD?: number; +} + +interface MSLocalClientEventBase extends RTCStats { + networkReceiveQualityEventRatio?: number; + networkBandwidthLowEventRatio?: number; +} + +interface MSNetwork extends RTCStats { + jitter?: MSJitter; + delay?: MSDelay; + packetLoss?: MSPacketLoss; + utilization?: MSUtilization; +} + +interface MSNetworkConnectivityInfo { + vpn?: boolean; + linkspeed?: number; + networkConnectionDetails?: string; +} + +interface MSNetworkInterfaceType { + interfaceTypeEthernet?: boolean; + interfaceTypeWireless?: boolean; + interfaceTypePPP?: boolean; + interfaceTypeTunnel?: boolean; + interfaceTypeWWAN?: boolean; +} + +interface MSOutboundNetwork extends MSNetwork { + appliedBandwidthLimit?: number; +} + +interface MSPacketLoss { + lossRate?: number; + lossRateMax?: number; +} + +interface MSPayloadBase extends RTCStats { + payloadDescription?: string; +} + +interface MSPortRange { + min?: number; + max?: number; +} + +interface MSRelayAddress { + relayAddress?: string; + port?: number; +} + +interface MSSignatureParameters { + userPrompt?: string; +} + +interface MSTransportDiagnosticsStats extends RTCStats { + baseAddress?: string; + localAddress?: string; + localSite?: string; + networkName?: string; + remoteAddress?: string; + remoteSite?: string; + localMR?: string; + remoteMR?: string; + iceWarningFlags?: MSIceWarningFlags; + portRangeMin?: number; + portRangeMax?: number; + localMRTCPPort?: number; + remoteMRTCPPort?: number; + stunVer?: number; + numConsentReqSent?: number; + numConsentReqReceived?: number; + numConsentRespSent?: number; + numConsentRespReceived?: number; + interfaces?: MSNetworkInterfaceType; + baseInterface?: MSNetworkInterfaceType; + protocol?: RTCIceProtocol; + localInterface?: MSNetworkInterfaceType; + localAddrType?: MSIceAddrType; + remoteAddrType?: MSIceAddrType; + iceRole?: RTCIceRole; + rtpRtcpMux?: boolean; + allocationTimeInMs?: number; + msRtcEngineVersion?: string; +} + +interface MSUtilization { + packets?: number; + bandwidthEstimation?: number; + bandwidthEstimationMin?: number; + bandwidthEstimationMax?: number; + bandwidthEstimationStdDev?: number; + bandwidthEstimationAvg?: number; +} + +interface MSVideoPayload extends MSPayloadBase { + resolution?: string; + videoBitRateAvg?: number; + videoBitRateMax?: number; + videoFrameRateAvg?: number; + videoPacketLossRate?: number; + durationSeconds?: number; +} + +interface MSVideoRecvPayload extends MSVideoPayload { + videoFrameLossRate?: number; + recvCodecType?: string; + recvResolutionWidth?: number; + recvResolutionHeight?: number; + videoResolutions?: MSVideoResolutionDistribution; + recvFrameRateAverage?: number; + recvBitRateMaximum?: number; + recvBitRateAverage?: number; + recvVideoStreamsMax?: number; + recvVideoStreamsMin?: number; + recvVideoStreamsMode?: number; + videoPostFECPLR?: number; + lowBitRateCallPercent?: number; + lowFrameRateCallPercent?: number; + reorderBufferTotalPackets?: number; + recvReorderBufferReorderedPackets?: number; + recvReorderBufferPacketsDroppedDueToBufferExhaustion?: number; + recvReorderBufferMaxSuccessfullyOrderedExtent?: number; + recvReorderBufferMaxSuccessfullyOrderedLateTime?: number; + recvReorderBufferPacketsDroppedDueToTimeout?: number; + recvFpsHarmonicAverage?: number; + recvNumResSwitches?: number; +} + +interface MSVideoResolutionDistribution { + cifQuality?: number; + vgaQuality?: number; + h720Quality?: number; + h1080Quality?: number; + h1440Quality?: number; + h2160Quality?: number; +} + +interface MSVideoSendPayload extends MSVideoPayload { + sendFrameRateAverage?: number; + sendBitRateMaximum?: number; + sendBitRateAverage?: number; + sendVideoStreamsMax?: number; + sendResolutionWidth?: number; + sendResolutionHeight?: number; +} + +interface MediaEncryptedEventInit extends EventInit { + initDataType?: string; + initData?: ArrayBuffer; +} + +interface MediaKeyMessageEventInit extends EventInit { + messageType?: MediaKeyMessageType; + message?: ArrayBuffer; +} + +interface MediaKeySystemConfiguration { + initDataTypes?: string[]; + audioCapabilities?: MediaKeySystemMediaCapability[]; + videoCapabilities?: MediaKeySystemMediaCapability[]; + distinctiveIdentifier?: MediaKeysRequirement; + persistentState?: MediaKeysRequirement; +} + +interface MediaKeySystemMediaCapability { + contentType?: string; + robustness?: string; +} + +interface MediaStreamConstraints { + video?: boolean | MediaTrackConstraints; + audio?: boolean | MediaTrackConstraints; +} + +interface MediaStreamErrorEventInit extends EventInit { + error?: MediaStreamError; +} + +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + +interface MediaStreamTrackEventInit extends EventInit { + track?: MediaStreamTrack; +} + +interface MediaTrackCapabilities { + width?: number | LongRange; + height?: number | LongRange; + aspectRatio?: number | DoubleRange; + frameRate?: number | DoubleRange; + facingMode?: string; + volume?: number | DoubleRange; + sampleRate?: number | LongRange; + sampleSize?: number | LongRange; + echoCancellation?: boolean[]; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackConstraintSet { + width?: number | ConstrainLongRange; + height?: number | ConstrainLongRange; + aspectRatio?: number | ConstrainDoubleRange; + frameRate?: number | ConstrainDoubleRange; + facingMode?: string | string[] | ConstrainDOMStringParameters; + volume?: number | ConstrainDoubleRange; + sampleRate?: number | ConstrainLongRange; + sampleSize?: number | ConstrainLongRange; + echoCancelation?: boolean | ConstrainBooleanParameters; + deviceId?: string | string[] | ConstrainDOMStringParameters; + groupId?: string | string[] | ConstrainDOMStringParameters; +} + +interface MediaTrackConstraints extends MediaTrackConstraintSet { + advanced?: MediaTrackConstraintSet[]; +} + +interface MediaTrackSettings { + width?: number; + height?: number; + aspectRatio?: number; + frameRate?: number; + facingMode?: string; + volume?: number; + sampleRate?: number; + sampleSize?: number; + echoCancellation?: boolean; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackSupportedConstraints { + width?: boolean; + height?: boolean; + aspectRatio?: boolean; + frameRate?: boolean; + facingMode?: boolean; + volume?: boolean; + sampleRate?: boolean; + sampleSize?: boolean; + echoCancellation?: boolean; + deviceId?: boolean; + groupId?: boolean; +} + +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + +interface MouseEventInit extends EventModifierInit { + 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 NotificationOptions { + dir?: NotificationDirection; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + +interface PeriodicWaveConstraints { + disableNormalization?: boolean; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface PopStateEventInit extends EventInit { + state?: any; +} + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: RTCIceTransportPolicy; + bundlePolicy?: RTCBundlePolicy; + peerIdentity?: string; +} + +interface RTCDTMFToneChangeEventInit extends EventInit { + tone?: string; +} + +interface RTCDtlsFingerprint { + algorithm?: string; + value?: string; +} + +interface RTCDtlsParameters { + role?: RTCDtlsRole; + fingerprints?: RTCDtlsFingerprint[]; +} + +interface RTCIceCandidateAttributes extends RTCStats { + ipAddress?: string; + portNumber?: number; + transport?: string; + candidateType?: RTCStatsIceCandidateType; + priority?: number; + addressSourceUrl?: string; +} + +interface RTCIceCandidateComplete { +} + +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: RTCIceProtocol; + port?: number; + type?: RTCIceCandidateType; + tcpType?: RTCIceTcpCandidateType; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + +interface RTCIceCandidatePair { + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; +} + +interface RTCIceCandidatePairStats extends RTCStats { + transportId?: string; + localCandidateId?: string; + remoteCandidateId?: string; + state?: RTCStatsIceCandidatePairState; + priority?: number; + nominated?: boolean; + writable?: boolean; + readable?: boolean; + bytesSent?: number; + bytesReceived?: number; + roundTripTime?: number; + availableOutgoingBitrate?: number; + availableIncomingBitrate?: number; +} + +interface RTCIceGatherOptions { + gatherPolicy?: RTCIceGatherPolicy; + iceservers?: RTCIceServer[]; + portRange?: MSPortRange; +} + +interface RTCIceParameters { + usernameFragment?: string; + password?: string; + iceLite?: boolean; +} + +interface RTCIceServer { + urls?: any; + username?: string; + credential?: string; +} + +interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { + packetsReceived?: number; + bytesReceived?: number; + packetsLost?: number; + jitter?: number; + fractionLost?: number; +} + +interface RTCMediaStreamTrackStats extends RTCStats { + trackIdentifier?: string; + remoteSource?: boolean; + ssrcIds?: string[]; + frameWidth?: number; + frameHeight?: number; + framesPerSecond?: number; + framesSent?: number; + framesReceived?: number; + framesDecoded?: number; + framesDropped?: number; + framesCorrupted?: number; + audioLevel?: number; + echoReturnLoss?: number; + echoReturnLossEnhancement?: number; +} + +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + +interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { + packetsSent?: number; + bytesSent?: number; + targetBitrate?: number; + roundTripTime?: number; +} + +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + +interface RTCRTPStreamStats extends RTCStats { + ssrc?: string; + associateStatsId?: string; + isRemote?: boolean; + mediaTrackId?: string; + transportId?: string; + codecId?: string; + firCount?: number; + pliCount?: number; + nackCount?: number; + sliCount?: number; +} + +interface RTCRtcpFeedback { + type?: string; + parameter?: string; +} + +interface RTCRtcpParameters { + ssrc?: number; + cname?: string; + reducedSize?: boolean; + mux?: boolean; +} + +interface RTCRtpCapabilities { + codecs?: RTCRtpCodecCapability[]; + headerExtensions?: RTCRtpHeaderExtension[]; + fecMechanisms?: string[]; +} + +interface RTCRtpCodecCapability { + name?: string; + kind?: string; + clockRate?: number; + preferredPayloadType?: number; + maxptime?: number; + ptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; + options?: any; + maxTemporalLayers?: number; + maxSpatialLayers?: number; + svcMultiStreamSupport?: boolean; +} + +interface RTCRtpCodecParameters { + name?: string; + payloadType?: any; + clockRate?: number; + maxptime?: number; + ptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; +} + +interface RTCRtpContributingSource { + timestamp?: number; + csrc?: number; + audioLevel?: number; +} + +interface RTCRtpEncodingParameters { + ssrc?: number; + codecPayloadType?: number; + fec?: RTCRtpFecParameters; + rtx?: RTCRtpRtxParameters; + priority?: number; + maxBitrate?: number; + minQuality?: number; + resolutionScale?: number; + framerateScale?: number; + maxFramerate?: number; + active?: boolean; + encodingId?: string; + dependencyEncodingIds?: string[]; + ssrcRange?: RTCSsrcRange; +} + +interface RTCRtpFecParameters { + ssrc?: number; + mechanism?: string; +} + +interface RTCRtpHeaderExtension { + kind?: string; + uri?: string; + preferredId?: number; + preferredEncrypt?: boolean; +} + +interface RTCRtpHeaderExtensionParameters { + uri?: string; + id?: number; + encrypt?: boolean; +} + +interface RTCRtpParameters { + muxId?: string; + codecs?: RTCRtpCodecParameters[]; + headerExtensions?: RTCRtpHeaderExtensionParameters[]; + encodings?: RTCRtpEncodingParameters[]; + rtcp?: RTCRtcpParameters; + degradationPreference?: RTCDegradationPreference; +} + +interface RTCRtpRtxParameters { + ssrc?: number; +} + +interface RTCRtpUnhandled { + ssrc?: number; + payloadType?: number; + muxId?: string; +} + +interface RTCSessionDescriptionInit { + type?: RTCSdpType; + sdp?: string; +} + +interface RTCSrtpKeyParam { + keyMethod?: string; + keySalt?: string; + lifetime?: string; + mkiValue?: number; + mkiLength?: number; +} + +interface RTCSrtpSdesParameters { + tag?: number; + cryptoSuite?: string; + keyParams?: RTCSrtpKeyParam[]; + sessionParams?: string[]; +} + +interface RTCSsrcRange { + min?: number; + max?: number; +} + +interface RTCStats { + timestamp?: number; + type?: RTCStatsType; + id?: string; + msType?: MSStatsType; +} + +interface RTCStatsReport { +} + +interface RTCTransportStats extends RTCStats { + bytesSent?: number; + bytesReceived?: number; + rtcpTransportStatsId?: string; + activeConnection?: boolean; + selectedCandidatePairId?: string; + localCertificateId?: string; + remoteCertificateId?: string; +} + +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: ScopedCredentialType; + id?: any; + transports?: Transport[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: ScopedCredentialType; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + +interface UIEventInit extends EventInit { + view?: Window; + detail?: number; +} + +interface WebAuthnExtensions { +} + +interface WebGLContextAttributes { + failIfMajorPerformanceCaveat?: boolean; + 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 WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (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; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +declare var ANGLE_instanced_arrays: { + prototype: ANGLE_instanced_arrays; + new(): ANGLE_instanced_arrays; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +interface AnalyserNode extends AudioNode { + fftSize: number; + readonly 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 { + readonly animationName: string; + readonly elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +declare var AnimationEvent: { + prototype: AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; +} + +interface ApplicationCacheEventMap { + "cached": Event; + "checking": Event; + "downloading": Event; + "error": Event; + "noupdate": Event; + "obsolete": Event; + "progress": ProgressEvent; + "updateready": Event; +} + +interface ApplicationCache extends EventTarget { + oncached: (this: ApplicationCache, ev: Event) => any; + onchecking: (this: ApplicationCache, ev: Event) => any; + ondownloading: (this: ApplicationCache, ev: Event) => any; + onerror: (this: ApplicationCache, ev: Event) => any; + onnoupdate: (this: ApplicationCache, ev: Event) => any; + onobsolete: (this: ApplicationCache, ev: Event) => any; + onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; + onupdateready: (this: ApplicationCache, ev: Event) => any; + readonly status: number; + abort(): void; + swapCache(): void; + update(): void; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; + addEventListener(type: K, listener: (this: ApplicationCache, ev: ApplicationCacheEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; +} + +interface Attr extends Node { + readonly name: string; + readonly ownerElement: Element; + readonly prefix: string | null; + readonly specified: boolean; + value: string; +} + +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface AudioBuffer { + readonly duration: number; + readonly length: number; + readonly numberOfChannels: number; + readonly sampleRate: number; + copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; + copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; + getChannelData(channel: number): Float32Array; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + +interface AudioBufferSourceNodeEventMap { + "ended": MediaStreamErrorEvent; +} + +interface AudioBufferSourceNode extends AudioNode { + buffer: AudioBuffer | null; + readonly detune: AudioParam; + loop: boolean; + loopEnd: number; + loopStart: number; + onended: (this: AudioBufferSourceNode, ev: MediaStreamErrorEvent) => any; + readonly playbackRate: AudioParam; + start(when?: number, offset?: number, duration?: number): void; + stop(when?: number): void; + addEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioBufferSourceNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var AudioBufferSourceNode: { + prototype: AudioBufferSourceNode; + new(): AudioBufferSourceNode; +} + +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { + readonly currentTime: number; + readonly destination: AudioDestinationNode; + readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; + readonly sampleRate: number; + readonly state: AudioContextState; + close(): Promise; + 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; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; + createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; + createOscillator(): OscillatorNode; + createPanner(): PannerNode; + createPeriodicWave(real: Float32Array, imag: Float32Array, constraints?: PeriodicWaveConstraints): PeriodicWave; + createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; + createStereoPanner(): StereoPannerNode; + createWaveShaper(): WaveShaperNode; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; +} + +declare var AudioContext: { + prototype: AudioContext; + new(): AudioContext; +} + +interface AudioDestinationNode extends AudioNode { + readonly 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: ChannelCountMode; + channelInterpretation: ChannelInterpretation; + readonly context: AudioContext; + readonly numberOfInputs: number; + readonly numberOfOutputs: number; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: 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 { + readonly defaultValue: number; + value: number; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; +} + +declare var AudioParam: { + prototype: AudioParam; + new(): AudioParam; +} + +interface AudioProcessingEvent extends Event { + readonly inputBuffer: AudioBuffer; + readonly outputBuffer: AudioBuffer; + readonly playbackTime: number; +} + +declare var AudioProcessingEvent: { + prototype: AudioProcessingEvent; + new(): AudioProcessingEvent; +} + +interface AudioTrack { + enabled: boolean; + readonly id: string; + kind: string; + readonly label: string; + language: string; + readonly sourceBuffer: SourceBuffer; +} + +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface AudioTrackListEventMap { + "addtrack": TrackEvent; + "change": Event; + "removetrack": TrackEvent; +} + +interface AudioTrackList extends EventTarget { + readonly length: number; + onaddtrack: (this: AudioTrackList, ev: TrackEvent) => any; + onchange: (this: AudioTrackList, ev: Event) => any; + onremovetrack: (this: AudioTrackList, ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack | null; + item(index: number): AudioTrack; + addEventListener(type: K, listener: (this: AudioTrackList, ev: AudioTrackListEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: AudioTrack; +} + +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface BarProp { + readonly 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 { + readonly Q: AudioParam; + readonly detune: AudioParam; + readonly frequency: AudioParam; + readonly gain: AudioParam; + type: BiquadFilterType; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var BiquadFilterNode: { + prototype: BiquadFilterNode; + new(): BiquadFilterNode; +} + +interface Blob { + readonly size: number; + readonly 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 { + readonly style: CSSStyleDeclaration; +} + +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface CSSGroupingRule extends CSSRule { + readonly cssRules: CSSRuleList; + deleteRule(index: number): void; + insertRule(rule: string, index: number): number; +} + +declare var CSSGroupingRule: { + prototype: CSSGroupingRule; + new(): CSSGroupingRule; +} + +interface CSSImportRule extends CSSRule { + readonly href: string; + readonly media: MediaList; + readonly styleSheet: CSSStyleSheet; +} + +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface CSSKeyframesRule extends CSSRule { + readonly 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 { + readonly media: MediaList; +} + +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface CSSNamespaceRule extends CSSRule { + readonly namespaceURI: string; + readonly prefix: string; +} + +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface CSSPageRule extends CSSRule { + readonly pseudoClass: string; + readonly selector: string; + selectorText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface CSSRule { + cssText: string; + readonly parentRule: CSSRule; + readonly parentStyleSheet: CSSStyleSheet; + readonly type: number; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; +} + +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; +} + +interface CSSRuleList { + readonly length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} + +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface CSSStyleDeclaration { + alignContent: string | null; + alignItems: string | null; + alignSelf: string | null; + alignmentBaseline: string | null; + animation: string | null; + animationDelay: string | null; + animationDirection: string | null; + animationDuration: string | null; + animationFillMode: string | null; + animationIterationCount: string | null; + animationName: string | null; + animationPlayState: string | null; + animationTimingFunction: string | null; + backfaceVisibility: string | null; + background: string | null; + backgroundAttachment: string | null; + backgroundClip: string | null; + backgroundColor: string | null; + backgroundImage: string | null; + backgroundOrigin: string | null; + backgroundPosition: string | null; + backgroundPositionX: string | null; + backgroundPositionY: string | null; + backgroundRepeat: string | null; + backgroundSize: string | null; + baselineShift: string | null; + border: string | null; + borderBottom: string | null; + borderBottomColor: string | null; + borderBottomLeftRadius: string | null; + borderBottomRightRadius: string | null; + borderBottomStyle: string | null; + borderBottomWidth: string | null; + borderCollapse: string | null; + borderColor: string | null; + borderImage: string | null; + borderImageOutset: string | null; + borderImageRepeat: string | null; + borderImageSlice: string | null; + borderImageSource: string | null; + borderImageWidth: string | null; + borderLeft: string | null; + borderLeftColor: string | null; + borderLeftStyle: string | null; + borderLeftWidth: string | null; + borderRadius: string | null; + borderRight: string | null; + borderRightColor: string | null; + borderRightStyle: string | null; + borderRightWidth: string | null; + borderSpacing: string | null; + borderStyle: string | null; + borderTop: string | null; + borderTopColor: string | null; + borderTopLeftRadius: string | null; + borderTopRightRadius: string | null; + borderTopStyle: string | null; + borderTopWidth: string | null; + borderWidth: string | null; + bottom: string | null; + boxShadow: string | null; + boxSizing: string | null; + breakAfter: string | null; + breakBefore: string | null; + breakInside: string | null; + captionSide: string | null; + clear: string | null; + clip: string | null; + clipPath: string | null; + clipRule: string | null; + color: string | null; + colorInterpolationFilters: string | null; + columnCount: any; + columnFill: string | null; + columnGap: any; + columnRule: string | null; + columnRuleColor: any; + columnRuleStyle: string | null; + columnRuleWidth: any; + columnSpan: string | null; + columnWidth: any; + columns: string | null; + content: string | null; + counterIncrement: string | null; + counterReset: string | null; + cssFloat: string | null; + cssText: string; + cursor: string | null; + direction: string | null; + display: string | null; + dominantBaseline: string | null; + emptyCells: string | null; + enableBackground: string | null; + fill: string | null; + fillOpacity: string | null; + fillRule: string | null; + filter: string | null; + flex: string | null; + flexBasis: string | null; + flexDirection: string | null; + flexFlow: string | null; + flexGrow: string | null; + flexShrink: string | null; + flexWrap: string | null; + floodColor: string | null; + floodOpacity: string | null; + font: string | null; + fontFamily: string | null; + fontFeatureSettings: string | null; + fontSize: string | null; + fontSizeAdjust: string | null; + fontStretch: string | null; + fontStyle: string | null; + fontVariant: string | null; + fontWeight: string | null; + glyphOrientationHorizontal: string | null; + glyphOrientationVertical: string | null; + height: string | null; + imeMode: string | null; + justifyContent: string | null; + kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; + left: string | null; + readonly length: number; + letterSpacing: string | null; + lightingColor: string | null; + lineBreak: string | null; + lineHeight: string | null; + listStyle: string | null; + listStyleImage: string | null; + listStylePosition: string | null; + listStyleType: string | null; + margin: string | null; + marginBottom: string | null; + marginLeft: string | null; + marginRight: string | null; + marginTop: string | null; + marker: string | null; + markerEnd: string | null; + markerMid: string | null; + markerStart: string | null; + mask: string | null; + maxHeight: string | null; + maxWidth: string | null; + minHeight: string | null; + minWidth: string | null; + msContentZoomChaining: string | null; + msContentZoomLimit: string | null; + msContentZoomLimitMax: any; + msContentZoomLimitMin: any; + msContentZoomSnap: string | null; + msContentZoomSnapPoints: string | null; + msContentZoomSnapType: string | null; + msContentZooming: string | null; + msFlowFrom: string | null; + msFlowInto: string | null; + msFontFeatureSettings: string | null; + msGridColumn: any; + msGridColumnAlign: string | null; + msGridColumnSpan: any; + msGridColumns: string | null; + msGridRow: any; + msGridRowAlign: string | null; + msGridRowSpan: any; + msGridRows: string | null; + msHighContrastAdjust: string | null; + msHyphenateLimitChars: string | null; + msHyphenateLimitLines: any; + msHyphenateLimitZone: any; + msHyphens: string | null; + msImeAlign: string | null; + msOverflowStyle: string | null; + msScrollChaining: string | null; + msScrollLimit: string | null; + msScrollLimitXMax: any; + msScrollLimitXMin: any; + msScrollLimitYMax: any; + msScrollLimitYMin: any; + msScrollRails: string | null; + msScrollSnapPointsX: string | null; + msScrollSnapPointsY: string | null; + msScrollSnapType: string | null; + msScrollSnapX: string | null; + msScrollSnapY: string | null; + msScrollTranslation: string | null; + msTextCombineHorizontal: string | null; + msTextSizeAdjust: any; + msTouchAction: string | null; + msTouchSelect: string | null; + msUserSelect: string | null; + msWrapFlow: string; + msWrapMargin: any; + msWrapThrough: string; + opacity: string | null; + order: string | null; + orphans: string | null; + outline: string | null; + outlineColor: string | null; + outlineOffset: string | null; + outlineStyle: string | null; + outlineWidth: string | null; + overflow: string | null; + overflowX: string | null; + overflowY: string | null; + padding: string | null; + paddingBottom: string | null; + paddingLeft: string | null; + paddingRight: string | null; + paddingTop: string | null; + pageBreakAfter: string | null; + pageBreakBefore: string | null; + pageBreakInside: string | null; + readonly parentRule: CSSRule; + perspective: string | null; + perspectiveOrigin: string | null; + pointerEvents: string | null; + position: string | null; + quotes: string | null; + right: string | null; + rotate: string | null; + rubyAlign: string | null; + rubyOverhang: string | null; + rubyPosition: string | null; + scale: string | null; + stopColor: string | null; + stopOpacity: string | null; + stroke: string | null; + strokeDasharray: string | null; + strokeDashoffset: string | null; + strokeLinecap: string | null; + strokeLinejoin: string | null; + strokeMiterlimit: string | null; + strokeOpacity: string | null; + strokeWidth: string | null; + tableLayout: string | null; + textAlign: string | null; + textAlignLast: string | null; + textAnchor: string | null; + textDecoration: string | null; + textIndent: string | null; + textJustify: string | null; + textKashida: string | null; + textKashidaSpace: string | null; + textOverflow: string | null; + textShadow: string | null; + textTransform: string | null; + textUnderlinePosition: string | null; + top: string | null; + touchAction: string | null; + transform: string | null; + transformOrigin: string | null; + transformStyle: string | null; + transition: string | null; + transitionDelay: string | null; + transitionDuration: string | null; + transitionProperty: string | null; + transitionTimingFunction: string | null; + translate: string | null; + unicodeBidi: string | null; + verticalAlign: string | null; + visibility: string | null; + webkitAlignContent: string | null; + webkitAlignItems: string | null; + webkitAlignSelf: string | null; + webkitAnimation: string | null; + webkitAnimationDelay: string | null; + webkitAnimationDirection: string | null; + webkitAnimationDuration: string | null; + webkitAnimationFillMode: string | null; + webkitAnimationIterationCount: string | null; + webkitAnimationName: string | null; + webkitAnimationPlayState: string | null; + webkitAnimationTimingFunction: string | null; + webkitAppearance: string | null; + webkitBackfaceVisibility: string | null; + webkitBackgroundClip: string | null; + webkitBackgroundOrigin: string | null; + webkitBackgroundSize: string | null; + webkitBorderBottomLeftRadius: string | null; + webkitBorderBottomRightRadius: string | null; + webkitBorderImage: string | null; + webkitBorderRadius: string | null; + webkitBorderTopLeftRadius: string | null; + webkitBorderTopRightRadius: string | null; + webkitBoxAlign: string | null; + webkitBoxDirection: string | null; + webkitBoxFlex: string | null; + webkitBoxOrdinalGroup: string | null; + webkitBoxOrient: string | null; + webkitBoxPack: string | null; + webkitBoxSizing: string | null; + webkitColumnBreakAfter: string | null; + webkitColumnBreakBefore: string | null; + webkitColumnBreakInside: string | null; + webkitColumnCount: any; + webkitColumnGap: any; + webkitColumnRule: string | null; + webkitColumnRuleColor: any; + webkitColumnRuleStyle: string | null; + webkitColumnRuleWidth: any; + webkitColumnSpan: string | null; + webkitColumnWidth: any; + webkitColumns: string | null; + webkitFilter: string | null; + webkitFlex: string | null; + webkitFlexBasis: string | null; + webkitFlexDirection: string | null; + webkitFlexFlow: string | null; + webkitFlexGrow: string | null; + webkitFlexShrink: string | null; + webkitFlexWrap: string | null; + webkitJustifyContent: string | null; + webkitOrder: string | null; + webkitPerspective: string | null; + webkitPerspectiveOrigin: string | null; + webkitTapHighlightColor: string | null; + webkitTextFillColor: string | null; + webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; + webkitTransform: string | null; + webkitTransformOrigin: string | null; + webkitTransformStyle: string | null; + webkitTransition: string | null; + webkitTransitionDelay: string | null; + webkitTransitionDuration: string | null; + webkitTransitionProperty: string | null; + webkitTransitionTimingFunction: string | null; + webkitUserModify: string | null; + webkitUserSelect: string | null; + webkitWritingMode: string | null; + whiteSpace: string | null; + widows: string | null; + width: string | null; + wordBreak: string | null; + wordSpacing: string | null; + wordWrap: string | null; + writingMode: string | null; + zIndex: string | null; + zoom: string | null; + resize: string | null; + userSelect: string | null; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + item(index: number): string; + removeProperty(propertyName: string): string; + setProperty(propertyName: string, value: string | null, priority?: string): void; + [index: number]: string; +} + +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface CSSStyleRule extends CSSRule { + readonly readOnly: boolean; + selectorText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface CSSStyleSheet extends StyleSheet { + readonly cssRules: CSSRuleList; + cssText: string; + readonly id: string; + readonly imports: StyleSheetList; + readonly isAlternate: boolean; + readonly isPrefAlternate: boolean; + readonly ownerRule: CSSRule; + readonly owningElement: Element; + readonly pages: StyleSheetPageList; + readonly readOnly: boolean; + readonly 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 Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} + +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; +} + +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface CanvasRenderingContext2D extends Object, CanvasPathMethods { + readonly canvas: HTMLCanvasElement; + fillStyle: string | CanvasGradient | CanvasPattern; + font: string; + globalAlpha: number; + globalCompositeOperation: string; + imageSmoothingEnabled: boolean; + lineCap: string; + lineDashOffset: number; + lineJoin: string; + lineWidth: number; + miterLimit: number; + msFillRule: CanvasFillRule; + shadowBlur: number; + shadowColor: string; + shadowOffsetX: number; + shadowOffsetY: number; + strokeStyle: string | CanvasGradient | CanvasPattern; + textAlign: string; + textBaseline: string; + mozImageSmoothingEnabled: boolean; + webkitImageSmoothingEnabled: boolean; + oImageSmoothingEnabled: boolean; + beginPath(): void; + clearRect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: CanvasFillRule): 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; + drawFocusIfNeeded(element: Element): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; + fill(fillRule?: CanvasFillRule): 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?: CanvasFillRule): boolean; + measureText(text: string): TextMetrics; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: 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(path?: Path2D): 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; + readonly 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; +} + +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface ClientRect { + bottom: number; + readonly height: number; + left: number; + right: number; + top: number; + readonly width: number; +} + +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface ClientRectList { + readonly length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} + +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface ClipboardEvent extends Event { + readonly clipboardData: DataTransfer; +} + +declare var ClipboardEvent: { + prototype: ClipboardEvent; + new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; +} + +interface CloseEvent extends Event { + readonly code: number; + readonly reason: string; + readonly wasClean: boolean; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +declare var CloseEvent: { + prototype: CloseEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; +} + +interface Comment extends CharacterData { + text: string; +} + +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface CompositionEvent extends UIEvent { + readonly data: string; + readonly 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?: any, ...optionalParams: any[]): void; + dir(value?: any, ...optionalParams: any[]): void; + dirxml(value: any): void; + error(message?: any, ...optionalParams: any[]): void; + exception(message?: string, ...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; + table(...data: any[]): 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 | null; + normalize: boolean; +} + +declare var ConvolverNode: { + prototype: ConvolverNode; + new(): ConvolverNode; +} + +interface Coordinates { + readonly accuracy: number; + readonly altitude: number | null; + readonly altitudeAccuracy: number | null; + readonly heading: number | null; + readonly latitude: number; + readonly longitude: number; + readonly speed: number | null; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface Crypto extends Object, RandomSource { + readonly subtle: SubtleCrypto; +} + +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface CryptoKey { + readonly algorithm: KeyAlgorithm; + readonly extractable: boolean; + readonly type: string; + readonly 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 { + readonly 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 { + readonly name: string; + toString(): string; +} + +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface DOMException { + readonly code: number; + readonly message: string; + readonly name: string; + toString(): string; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; +} + +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; +} + +interface DOMImplementation { + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createHTMLDocument(title: string): Document; + hasFeature(feature: string | null, version: string | null): 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 { + readonly length: number; + contains(str: string): boolean; + item(index: number): string | null; + [index: number]: string; +} + +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface DOMStringMap { + [name: string]: string | undefined; +} + +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DOMTokenList { + readonly 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; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DataCue: { + prototype: DataCue; + new(): DataCue; +} + +interface DataTransfer { + dropEffect: string; + effectAllowed: string; + readonly files: FileList; + readonly items: DataTransferItemList; + readonly types: string[]; + clearData(format?: string): boolean; + getData(format: string): string; + setData(format: string, data: string): boolean; + setDragImage(image: Element, x: number, y: number): void; +} + +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface DataTransferItem { + readonly kind: string; + readonly type: string; + getAsFile(): File | null; + getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; +} + +declare var DataTransferItem: { + prototype: DataTransferItem; + new(): DataTransferItem; +} + +interface DataTransferItemList { + readonly length: number; + add(data: File): DataTransferItem | null; + clear(): void; + item(index: number): DataTransferItem; + remove(index: number): void; + [index: number]: DataTransferItem; +} + +declare var DataTransferItemList: { + prototype: DataTransferItemList; + new(): DataTransferItemList; +} + +interface DeferredPermissionRequest { + readonly id: number; + readonly type: MSWebViewPermissionType; + readonly uri: string; + allow(): void; + deny(): void; +} + +declare var DeferredPermissionRequest: { + prototype: DeferredPermissionRequest; + new(): DeferredPermissionRequest; +} + +interface DelayNode extends AudioNode { + readonly delayTime: AudioParam; +} + +declare var DelayNode: { + prototype: DelayNode; + new(): DelayNode; +} + +interface DeviceAcceleration { + readonly x: number | null; + readonly y: number | null; + readonly z: number | null; +} + +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface DeviceLightEvent extends Event { + readonly value: number; +} + +declare var DeviceLightEvent: { + prototype: DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; +} + +interface DeviceMotionEvent extends Event { + readonly acceleration: DeviceAcceleration | null; + readonly accelerationIncludingGravity: DeviceAcceleration | null; + readonly interval: number | null; + readonly rotationRate: DeviceRotationRate | null; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict | null, accelerationIncludingGravity: DeviceAccelerationDict | null, rotationRate: DeviceRotationRateDict | null, interval: number | null): void; +} + +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; +} + +interface DeviceOrientationEvent extends Event { + readonly absolute: boolean; + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number | null, beta: number | null, gamma: number | null, absolute: boolean): void; +} + +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; +} + +interface DeviceRotationRate { + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; +} + +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface DocumentEventMap extends GlobalEventHandlersEventMap { + "abort": UIEvent; + "activate": UIEvent; + "beforeactivate": UIEvent; + "beforedeactivate": UIEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "contextmenu": PointerEvent; + "dblclick": MouseEvent; + "deactivate": UIEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "fullscreenchange": Event; + "fullscreenerror": Event; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "mousedown": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSContentZoom": UIEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSInertiaStart": MSGestureEvent; + "MSManipulationStateChanged": MSManipulationEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "mssitemodejumplistitemremoved": MSSiteModeEvent; + "msthumbnailclick": MSSiteModeEvent; + "pause": Event; + "play": Event; + "playing": Event; + "pointerlockchange": Event; + "pointerlockerror": Event; + "progress": ProgressEvent; + "ratechange": Event; + "readystatechange": Event; + "reset": Event; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "selectionchange": Event; + "selectstart": Event; + "stalled": Event; + "stop": Event; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "touchcancel": TouchEvent; + "touchend": TouchEvent; + "touchmove": TouchEvent; + "touchstart": TouchEvent; + "volumechange": Event; + "waiting": Event; + "webkitfullscreenchange": Event; + "webkitfullscreenerror": Event; +} + +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { + /** + * Sets or gets the URL for the current document. + */ + readonly URL: string; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + readonly URLUnencoded: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + readonly 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. + */ + readonly all: HTMLAllCollection; + /** + * 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: HTMLCollectionOf; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollectionOf; + /** + * 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; + readonly 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. + */ + readonly compatMode: string; + cookie: string; + readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly 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. + */ + readonly 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: HTMLCollectionOf; + /** + * 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: HTMLCollectionOf; + readonly fullscreenElement: Element | null; + readonly fullscreenEnabled: boolean; + readonly head: HTMLHeadElement; + readonly hidden: boolean; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollectionOf; + /** + * Gets the implementation object of the current document. + */ + readonly implementation: DOMImplementation; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + readonly inputEncoding: string | null; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + readonly 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: HTMLCollectionOf; + /** + * Contains information about the current URL. + */ + readonly location: Location; + msCSSOMElementFloatMetrics: boolean; + msCapsLockWarningOff: boolean; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (this: Document, ev: UIEvent) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (this: Document, ev: UIEvent) => any; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (this: Document, 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: (this: Document, ev: UIEvent) => any; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (this: Document, ev: FocusEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (this: Document, ev: Event) => any; + oncanplaythrough: (this: Document, ev: Event) => any; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (this: Document, 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: (this: Document, ev: PointerEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (this: Document, 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: (this: Document, ev: UIEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, ev: DragEvent) => any; + ondrop: (this: Document, ev: DragEvent) => any; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (this: Document, ev: Event) => any; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (this: Document, ev: Event) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (this: Document, ev: MediaStreamErrorEvent) => any; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (this: Document, ev: ErrorEvent) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (this: Document, ev: FocusEvent) => any; + onfullscreenchange: (this: Document, ev: Event) => any; + onfullscreenerror: (this: Document, ev: Event) => any; + oninput: (this: Document, ev: Event) => any; + oninvalid: (this: Document, ev: Event) => any; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (this: Document, ev: Event) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (this: Document, ev: Event) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (this: Document, ev: Event) => any; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (this: Document, ev: WheelEvent) => any; + onmscontentzoom: (this: Document, ev: UIEvent) => any; + onmsgesturechange: (this: Document, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Document, ev: MSGestureEvent) => any; + onmsgestureend: (this: Document, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Document, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Document, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Document, ev: MSGestureEvent) => any; + onmsinertiastart: (this: Document, ev: MSGestureEvent) => any; + onmsmanipulationstatechanged: (this: Document, ev: MSManipulationEvent) => any; + onmspointercancel: (this: Document, ev: MSPointerEvent) => any; + onmspointerdown: (this: Document, ev: MSPointerEvent) => any; + onmspointerenter: (this: Document, ev: MSPointerEvent) => any; + onmspointerleave: (this: Document, ev: MSPointerEvent) => any; + onmspointermove: (this: Document, ev: MSPointerEvent) => any; + onmspointerout: (this: Document, ev: MSPointerEvent) => any; + onmspointerover: (this: Document, ev: MSPointerEvent) => any; + onmspointerup: (this: Document, 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: (this: Document, 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: (this: Document, ev: MSSiteModeEvent) => any; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (this: Document, ev: Event) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (this: Document, ev: Event) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (this: Document, ev: Event) => any; + onpointerlockchange: (this: Document, ev: Event) => any; + onpointerlockerror: (this: Document, ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (this: Document, ev: ProgressEvent) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (this: Document, ev: Event) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (this: Document, ev: Event) => any; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (this: Document, ev: Event) => any; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (this: Document, ev: UIEvent) => any; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (this: Document, ev: Event) => any; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (this: Document, ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (this: Document, ev: UIEvent) => any; + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (this: Document, ev: Event) => any; + onselectstart: (this: Document, ev: Event) => any; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (this: Document, ev: Event) => any; + onsubmit: (this: Document, ev: Event) => any; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (this: Document, ev: Event) => any; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (this: Document, 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: (this: Document, ev: Event) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (this: Document, ev: Event) => any; + onwebkitfullscreenchange: (this: Document, ev: Event) => any; + onwebkitfullscreenerror: (this: Document, ev: Event) => any; + plugins: HTMLCollectionOf; + readonly pointerLockElement: Element; + /** + * Retrieves a value that indicates the current state of the object. + */ + readonly readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + readonly referrer: string; + /** + * Gets the root svg element in the document hierarchy. + */ + readonly rootElement: SVGSVGElement; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollectionOf; + readonly scrollingElement: Element | null; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + readonly styleSheets: StyleSheetList; + /** + * Contains the title of the document. + */ + title: string; + readonly visibilityState: VisibilityState; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + readonly webkitCurrentFullScreenElement: Element | null; + readonly webkitFullscreenElement: Element | null; + readonly webkitFullscreenEnabled: boolean; + readonly webkitIsFullScreen: boolean; + readonly xmlEncoding: string | null; + xmlStandalone: boolean; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string | null; + adoptNode(source: T): T; + captureEvents(): void; + caretRangeFromPoint(x: number, y: number): Range; + 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 | null, 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: K): HTMLElementTagNameMap[K]; + createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: 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 | null, 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: Window, 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 | null, type: number, result: XPathResult | null): 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 | null; + getElementsByClassName(classNames: string): HTMLCollectionOf; + /** + * 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: K): ElementListTagNameMap[K]; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + /** + * 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: T, deep: boolean): T; + msElementsFromPoint(x: number, y: number): NodeListOf; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; + /** + * 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; + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Document: { + prototype: Document; + new(): Document; +} + +interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; +} + +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface DocumentType extends Node, ChildNode { + readonly entities: NamedNodeMap; + readonly internalSubset: string | null; + readonly name: string; + readonly notations: NamedNodeMap; + readonly publicId: string; + readonly systemId: string; +} + +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface DragEvent extends MouseEvent { + readonly 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 { + readonly attack: AudioParam; + readonly knee: AudioParam; + readonly ratio: AudioParam; + readonly reduction: number; + readonly release: AudioParam; + readonly threshold: AudioParam; +} + +declare var DynamicsCompressorNode: { + prototype: DynamicsCompressorNode; + new(): DynamicsCompressorNode; +} + +interface EXT_frag_depth { +} + +declare var EXT_frag_depth: { + prototype: EXT_frag_depth; + new(): EXT_frag_depth; +} + +interface EXT_texture_filter_anisotropic { + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +interface ElementEventMap extends GlobalEventHandlersEventMap { + "ariarequest": Event; + "command": Event; + "gotpointercapture": PointerEvent; + "lostpointercapture": PointerEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSGotPointerCapture": MSPointerEvent; + "MSInertiaStart": MSGestureEvent; + "MSLostPointerCapture": MSPointerEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "touchcancel": TouchEvent; + "touchend": TouchEvent; + "touchmove": TouchEvent; + "touchstart": TouchEvent; + "webkitfullscreenchange": Event; + "webkitfullscreenerror": Event; +} + +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { + readonly classList: DOMTokenList; + className: string; + readonly clientHeight: number; + readonly clientLeft: number; + readonly clientTop: number; + readonly clientWidth: number; + id: string; + innerHTML: string; + msContentZoomFactor: number; + readonly msRegionOverflow: string; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; + ongotpointercapture: (this: Element, ev: PointerEvent) => any; + onlostpointercapture: (this: Element, ev: PointerEvent) => any; + onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Element, ev: MSGestureEvent) => any; + onmsgestureend: (this: Element, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Element, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Element, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Element, ev: MSGestureEvent) => any; + onmsgotpointercapture: (this: Element, ev: MSPointerEvent) => any; + onmsinertiastart: (this: Element, ev: MSGestureEvent) => any; + onmslostpointercapture: (this: Element, ev: MSPointerEvent) => any; + onmspointercancel: (this: Element, ev: MSPointerEvent) => any; + onmspointerdown: (this: Element, ev: MSPointerEvent) => any; + onmspointerenter: (this: Element, ev: MSPointerEvent) => any; + onmspointerleave: (this: Element, ev: MSPointerEvent) => any; + onmspointermove: (this: Element, ev: MSPointerEvent) => any; + onmspointerout: (this: Element, ev: MSPointerEvent) => any; + onmspointerover: (this: Element, ev: MSPointerEvent) => any; + onmspointerup: (this: Element, ev: MSPointerEvent) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onwebkitfullscreenchange: (this: Element, ev: Event) => any; + onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; + readonly prefix: string | null; + readonly scrollHeight: number; + scrollLeft: number; + scrollTop: number; + readonly scrollWidth: number; + readonly tagName: string; + readonly assignedSlot: HTMLSlotElement | null; + slot: string; + readonly shadowRoot: ShadowRoot | null; + getAttribute(name: string): string | null; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNode(name: string): Attr; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + getElementsByTagName(name: K): ElementListTagNameMap[K]; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + 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(qualifiedName: 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; + closest(selector: string): Element | null; + scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; + scroll(options?: ScrollToOptions): void; + scroll(x: number, y: number): void; + scrollTo(options?: ScrollToOptions): void; + scrollTo(x: number, y: number): void; + scrollBy(options?: ScrollToOptions): void; + scrollBy(x: number, y: number): void; + insertAdjacentElement(position: string, insertedElement: Element): Element | null; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; + attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot; + addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Element: { + prototype: Element; + new(): Element; +} + +interface ErrorEvent extends Event { + readonly colno: number; + readonly error: any; + readonly filename: string; + readonly lineno: number; + readonly message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} + +declare var ErrorEvent: { + prototype: ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; +} + +interface Event { + readonly bubbles: boolean; + cancelBubble: boolean; + readonly cancelable: boolean; + readonly currentTarget: EventTarget; + readonly defaultPrevented: boolean; + readonly eventPhase: number; + readonly isTrusted: boolean; + returnValue: boolean; + readonly srcElement: Element | null; + readonly target: EventTarget; + readonly timeStamp: number; + readonly type: string; + readonly scoped: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + preventDefault(): void; + stopImmediatePropagation(): void; + stopPropagation(): void; + deepPath(): EventTarget[]; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; +} + +declare var Event: { + prototype: Event; + new(typeArg: string, eventInitDict?: EventInit): Event; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; +} + +interface EventTarget { + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + dispatchEvent(evt: Event): boolean; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var EventTarget: { + prototype: EventTarget; + new(): EventTarget; +} + +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + +interface External { +} + +declare var External: { + prototype: External; + new(): External; +} + +interface File extends Blob { + readonly lastModifiedDate: any; + readonly name: string; + readonly webkitRelativePath: string; +} + +declare var File: { + prototype: File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; +} + +interface FileList { + readonly length: number; + item(index: number): File; + [index: number]: File; +} + +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface FileReader extends EventTarget, MSBaseReader { + readonly error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface FocusEvent extends UIEvent { + readonly 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 FocusNavigationEvent extends Event { + readonly navigationReason: NavigationReason; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + +interface FormData { + append(name: string, value: string | Blob, fileName?: string): void; + delete(name: string): void; + get(name: string): FormDataEntryValue | null; + getAll(name: string): FormDataEntryValue[]; + has(name: string): boolean; + set(name: string, value: string | Blob, fileName?: string): void; +} + +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface GainNode extends AudioNode { + readonly gain: AudioParam; +} + +declare var GainNode: { + prototype: GainNode; + new(): GainNode; +} + +interface Gamepad { + readonly axes: number[]; + readonly buttons: GamepadButton[]; + readonly connected: boolean; + readonly id: string; + readonly index: number; + readonly mapping: string; + readonly timestamp: number; +} + +declare var Gamepad: { + prototype: Gamepad; + new(): Gamepad; +} + +interface GamepadButton { + readonly pressed: boolean; + readonly value: number; +} + +declare var GamepadButton: { + prototype: GamepadButton; + new(): GamepadButton; +} + +interface GamepadEvent extends Event { + readonly gamepad: Gamepad; +} + +declare var GamepadEvent: { + prototype: GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): 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 { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: 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; + download: 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; + readonly mimeType: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + readonly 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; + readonly 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; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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. + */ + readonly 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; + readonly 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 | null; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + download: 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; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface HTMLAreasCollection extends HTMLCollectionBase { +} + +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface HTMLAudioElement extends HTMLMediaElement { + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLBodyElementEventMap extends HTMLElementEventMap { + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "load": Event; + "message": MessageEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; + "resize": UIEvent; + "scroll": UIEvent; + "storage": StorageEvent; + "unload": Event; +} + +interface HTMLBodyElement extends HTMLElement { + aLink: any; + background: string; + bgColor: any; + bgProperties: string; + link: any; + noWrap: boolean; + onafterprint: (this: HTMLBodyElement, ev: Event) => any; + onbeforeprint: (this: HTMLBodyElement, ev: Event) => any; + onbeforeunload: (this: HTMLBodyElement, ev: BeforeUnloadEvent) => any; + onblur: (this: HTMLBodyElement, ev: FocusEvent) => any; + onerror: (this: HTMLBodyElement, ev: ErrorEvent) => any; + onfocus: (this: HTMLBodyElement, ev: FocusEvent) => any; + onhashchange: (this: HTMLBodyElement, ev: HashChangeEvent) => any; + onload: (this: HTMLBodyElement, ev: Event) => any; + onmessage: (this: HTMLBodyElement, ev: MessageEvent) => any; + onoffline: (this: HTMLBodyElement, ev: Event) => any; + ononline: (this: HTMLBodyElement, ev: Event) => any; + onorientationchange: (this: HTMLBodyElement, ev: Event) => any; + onpagehide: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; + onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; + onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; + onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; + onunload: (this: HTMLBodyElement, ev: Event) => any; + text: any; + vLink: any; + addEventListener(type: K, listener: (this: HTMLBodyElement, ev: HTMLBodyElementEventMap[K]) => 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly 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: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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", contextAttributes?: Canvas2DContextAttributes): CanvasRenderingContext2D | null; + getContext(contextId: "webgl" | "experimental-webgl", contextAttributes?: WebGLContextAttributes): WebGLRenderingContext | null; + getContext(contextId: string, contextAttributes?: {}): CanvasRenderingContext2D | WebGLRenderingContext | null; + /** + * 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(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface HTMLCollectionBase { + /** + * Sets or retrieves the number of objects in a collection. + */ + readonly length: number; + /** + * Retrieves an object from various collections. + */ + item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element | null; +} + +declare var HTMLCollection: { + prototype: HTMLCollection; + new(): HTMLCollection; +} + +interface HTMLDListElement extends HTMLElement { + compact: boolean; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollectionOf; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface HTMLDirectoryElement extends HTMLElement { + compact: boolean; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface HTMLDocument extends Document { + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface HTMLElementEventMap extends ElementEventMap { + "abort": UIEvent; + "activate": UIEvent; + "beforeactivate": UIEvent; + "beforecopy": ClipboardEvent; + "beforecut": ClipboardEvent; + "beforedeactivate": UIEvent; + "beforepaste": ClipboardEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "contextmenu": PointerEvent; + "copy": ClipboardEvent; + "cuechange": Event; + "cut": ClipboardEvent; + "dblclick": MouseEvent; + "deactivate": UIEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "mousedown": MouseEvent; + "mouseenter": MouseEvent; + "mouseleave": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSContentZoom": UIEvent; + "MSManipulationStateChanged": MSManipulationEvent; + "paste": ClipboardEvent; + "pause": Event; + "play": Event; + "playing": Event; + "progress": ProgressEvent; + "ratechange": Event; + "reset": Event; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "selectstart": Event; + "stalled": Event; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "volumechange": Event; + "waiting": Event; +} + +interface HTMLElement extends Element { + accessKey: string; + readonly children: HTMLCollection; + contentEditable: string; + readonly dataset: DOMStringMap; + dir: string; + draggable: boolean; + hidden: boolean; + hideFocus: boolean; + innerText: string; + readonly isContentEditable: boolean; + lang: string; + readonly offsetHeight: number; + readonly offsetLeft: number; + readonly offsetParent: Element; + readonly offsetTop: number; + readonly offsetWidth: number; + onabort: (this: HTMLElement, ev: UIEvent) => any; + onactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforeactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforecopy: (this: HTMLElement, ev: ClipboardEvent) => any; + onbeforecut: (this: HTMLElement, ev: ClipboardEvent) => any; + onbeforedeactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforepaste: (this: HTMLElement, ev: ClipboardEvent) => any; + onblur: (this: HTMLElement, ev: FocusEvent) => any; + oncanplay: (this: HTMLElement, ev: Event) => any; + oncanplaythrough: (this: HTMLElement, ev: Event) => any; + onchange: (this: HTMLElement, ev: Event) => any; + onclick: (this: HTMLElement, ev: MouseEvent) => any; + oncontextmenu: (this: HTMLElement, ev: PointerEvent) => any; + oncopy: (this: HTMLElement, ev: ClipboardEvent) => any; + oncuechange: (this: HTMLElement, ev: Event) => any; + oncut: (this: HTMLElement, ev: ClipboardEvent) => any; + ondblclick: (this: HTMLElement, ev: MouseEvent) => any; + ondeactivate: (this: HTMLElement, ev: UIEvent) => any; + ondrag: (this: HTMLElement, ev: DragEvent) => any; + ondragend: (this: HTMLElement, ev: DragEvent) => any; + ondragenter: (this: HTMLElement, ev: DragEvent) => any; + ondragleave: (this: HTMLElement, ev: DragEvent) => any; + ondragover: (this: HTMLElement, ev: DragEvent) => any; + ondragstart: (this: HTMLElement, ev: DragEvent) => any; + ondrop: (this: HTMLElement, ev: DragEvent) => any; + ondurationchange: (this: HTMLElement, ev: Event) => any; + onemptied: (this: HTMLElement, ev: Event) => any; + onended: (this: HTMLElement, ev: MediaStreamErrorEvent) => any; + onerror: (this: HTMLElement, ev: ErrorEvent) => any; + onfocus: (this: HTMLElement, ev: FocusEvent) => any; + oninput: (this: HTMLElement, ev: Event) => any; + oninvalid: (this: HTMLElement, ev: Event) => any; + onkeydown: (this: HTMLElement, ev: KeyboardEvent) => any; + onkeypress: (this: HTMLElement, ev: KeyboardEvent) => any; + onkeyup: (this: HTMLElement, ev: KeyboardEvent) => any; + onload: (this: HTMLElement, ev: Event) => any; + onloadeddata: (this: HTMLElement, ev: Event) => any; + onloadedmetadata: (this: HTMLElement, ev: Event) => any; + onloadstart: (this: HTMLElement, ev: Event) => any; + onmousedown: (this: HTMLElement, ev: MouseEvent) => any; + onmouseenter: (this: HTMLElement, ev: MouseEvent) => any; + onmouseleave: (this: HTMLElement, ev: MouseEvent) => any; + onmousemove: (this: HTMLElement, ev: MouseEvent) => any; + onmouseout: (this: HTMLElement, ev: MouseEvent) => any; + onmouseover: (this: HTMLElement, ev: MouseEvent) => any; + onmouseup: (this: HTMLElement, ev: MouseEvent) => any; + onmousewheel: (this: HTMLElement, ev: WheelEvent) => any; + onmscontentzoom: (this: HTMLElement, ev: UIEvent) => any; + onmsmanipulationstatechanged: (this: HTMLElement, ev: MSManipulationEvent) => any; + onpaste: (this: HTMLElement, ev: ClipboardEvent) => any; + onpause: (this: HTMLElement, ev: Event) => any; + onplay: (this: HTMLElement, ev: Event) => any; + onplaying: (this: HTMLElement, ev: Event) => any; + onprogress: (this: HTMLElement, ev: ProgressEvent) => any; + onratechange: (this: HTMLElement, ev: Event) => any; + onreset: (this: HTMLElement, ev: Event) => any; + onscroll: (this: HTMLElement, ev: UIEvent) => any; + onseeked: (this: HTMLElement, ev: Event) => any; + onseeking: (this: HTMLElement, ev: Event) => any; + onselect: (this: HTMLElement, ev: UIEvent) => any; + onselectstart: (this: HTMLElement, ev: Event) => any; + onstalled: (this: HTMLElement, ev: Event) => any; + onsubmit: (this: HTMLElement, ev: Event) => any; + onsuspend: (this: HTMLElement, ev: Event) => any; + ontimeupdate: (this: HTMLElement, ev: Event) => any; + onvolumechange: (this: HTMLElement, ev: Event) => any; + onwaiting: (this: HTMLElement, ev: Event) => any; + outerText: string; + spellcheck: boolean; + readonly style: CSSStyleDeclaration; + tabIndex: number; + title: string; + blur(): void; + click(): void; + dragDrop(): boolean; + focus(): void; + msGetInputContext(): MSInputMethodContext; + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the palette used for the embedded document. + */ + readonly palette: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + readonly pluginspage: string; + readonly 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: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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. + */ + readonly form: HTMLFormElement; + name: 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + readonly 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: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + +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. + */ + readonly elements: HTMLFormControlsCollection; + /** + * 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. + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [name: string]: any; +} + +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface HTMLFrameElementEventMap extends HTMLElementEventMap { + "load": Event; +} + +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. + */ + readonly contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + readonly 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: (this: HTMLFrameElement, ev: Event) => any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * 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: K, listener: (this: HTMLFrameElement, ev: HTMLFrameElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "load": Event; + "message": MessageEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; + "resize": UIEvent; + "scroll": UIEvent; + "storage": StorageEvent; + "unload": Event; +} + +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: (this: HTMLFrameSetElement, ev: Event) => any; + onbeforeprint: (this: HTMLFrameSetElement, ev: Event) => any; + onbeforeunload: (this: HTMLFrameSetElement, ev: BeforeUnloadEvent) => any; + /** + * Fires when the object loses the input focus. + */ + onblur: (this: HTMLFrameSetElement, ev: FocusEvent) => any; + onerror: (this: HTMLFrameSetElement, ev: ErrorEvent) => any; + /** + * Fires when the object receives focus. + */ + onfocus: (this: HTMLFrameSetElement, ev: FocusEvent) => any; + onhashchange: (this: HTMLFrameSetElement, ev: HashChangeEvent) => any; + onload: (this: HTMLFrameSetElement, ev: Event) => any; + onmessage: (this: HTMLFrameSetElement, ev: MessageEvent) => any; + onoffline: (this: HTMLFrameSetElement, ev: Event) => any; + ononline: (this: HTMLFrameSetElement, ev: Event) => any; + onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; + onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; + onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; + onunload: (this: HTMLFrameSetElement, ev: Event) => any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => 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: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface HTMLIFrameElementEventMap extends HTMLElementEventMap { + "load": Event; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + allowFullscreen: boolean; + allowPaymentRequest: boolean; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + readonly contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + readonly 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: (this: HTMLIFrameElement, ev: Event) => any; + readonly sandbox: DOMSettableTokenList; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * 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: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => 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. + */ + readonly complete: boolean; + crossOrigin: string | null; + readonly 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; + lowsrc: 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * The original height of the image resource before sizing. + */ + readonly naturalHeight: number; + /** + * The original width of the image resource before sizing. + */ + readonly naturalWidth: number; + sizes: string; + /** + * 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; + readonly x: number; + readonly y: number; + msGetAsCastingSource(): any; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): 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. + */ + readonly 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. + */ + readonly files: FileList | null; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly 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. + */ + readonly 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; + selectionDirection: string; + /** + * 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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; + webkitdirectory: boolean; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + readonly willValidate: boolean; + minLength: number; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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, direction?: string): 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; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLLIElement extends HTMLElement { + type: string; + /** + * Sets or retrieves the value of a list item. + */ + value: number; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface HTMLLabelElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly form: HTMLFormElement; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + import?: Document; + integrity: string; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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. + */ + readonly areas: HTMLAreasCollection; + /** + * Sets or retrieves the name of the object. + */ + name: string; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMarqueeElementEventMap extends HTMLElementEventMap { + "bounce": Event; + "finish": Event; + "start": Event; +} + +interface HTMLMarqueeElement extends HTMLElement { + behavior: string; + bgColor: any; + direction: string; + height: string; + hspace: number; + loop: number; + onbounce: (this: HTMLMarqueeElement, ev: Event) => any; + onfinish: (this: HTMLMarqueeElement, ev: Event) => any; + onstart: (this: HTMLMarqueeElement, ev: Event) => any; + scrollAmount: number; + scrollDelay: number; + trueSpeed: boolean; + vspace: number; + width: string; + start(): void; + stop(): void; + addEventListener(type: K, listener: (this: HTMLMarqueeElement, ev: HTMLMarqueeElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface HTMLMediaElementEventMap extends HTMLElementEventMap { + "encrypted": MediaEncryptedEvent; + "msneedkey": MSMediaKeyNeededEvent; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + readonly 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. + */ + readonly 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; + crossOrigin: string | null; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + readonly 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. + */ + readonly duration: number; + /** + * Gets information about whether the playback has ended or not. + */ + readonly ended: boolean; + /** + * Returns an object representing the current error state of the audio or video element. + */ + readonly error: MediaError; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + readonly mediaKeys: MediaKeys | null; + /** + * 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; + readonly msGraphicsTrustStatus: MSGraphicsTrust; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + readonly 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. + */ + readonly 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. + */ + readonly networkState: number; + onencrypted: (this: HTMLMediaElement, ev: MediaEncryptedEvent) => any; + onmsneedkey: (this: HTMLMediaElement, ev: MSMediaKeyNeededEvent) => any; + /** + * Gets a flag that specifies whether playback is paused. + */ + readonly 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. + */ + readonly 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. + */ + readonly seekable: TimeRanges; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + readonly seeking: boolean; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcObject: MediaStream | null; + readonly textTracks: TextTrackList; + readonly 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; + /** + * Resets the audio or video object and loads a new media resource. + */ + 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; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; + addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; +} + +interface HTMLMenuElement extends HTMLElement { + compact: boolean; + type: string; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface HTMLMeterElement extends HTMLElement { + high: number; + low: number; + max: number; + min: number; + optimum: number; + value: number; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMeterElement: { + prototype: HTMLMeterElement; + new(): HTMLMeterElement; +} + +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; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface HTMLOListElement extends HTMLElement { + compact: boolean; + /** + * The starting number. + */ + start: number; + type: string; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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. + */ + readonly 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. + */ + readonly 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly 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: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): 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. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + readonly 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. + */ + readonly text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; +} + +interface HTMLOptionsCollection extends HTMLCollectionOf { + length: number; + selectedIndex: number; + add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void; + remove(index: number): void; +} + +declare var HTMLOptionsCollection: { + prototype: HTMLOptionsCollection; + new(): HTMLOptionsCollection; +} + +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + +interface HTMLParagraphElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + clear: string; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface HTMLPictureElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + +interface HTMLPreElement extends HTMLElement { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly 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). + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + crossOrigin: string | null; + /** + * 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; + integrity: string; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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; + readonly options: HTMLOptionsCollection; + /** + * 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; + selectedOptions: HTMLCollectionOf; + /** + * 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly willValidate: boolean; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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; + sizes: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcset: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface HTMLSpanElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + disabled: boolean; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: HTMLCollectionOf; + /** + * 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: HTMLCollectionOf; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: HTMLCollectionOf; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the position of the object in the rows collection for the table. + */ + readonly rowIndex: number; + /** + * Retrieves the position of the object in the collection. + */ + readonly 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): HTMLTableDataCellElement; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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: HTMLCollectionOf; + /** + * 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: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface HTMLTemplateElement extends HTMLElement { + readonly content: DocumentFragment; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + +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. + */ + readonly 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly willValidate: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + minLength: number; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLTrackElement extends HTMLElement { + default: boolean; + kind: string; + label: string; + readonly readyState: number; + src: string; + srclang: string; + readonly track: TextTrack; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; +} + +interface HTMLUListElement extends HTMLElement { + compact: boolean; + type: string; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface HTMLUnknownElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLVideoElementEventMap extends HTMLMediaElementEventMap { + "MSVideoFormatChanged": Event; + "MSVideoFrameStepCompleted": Event; + "MSVideoOptimalLayoutChanged": Event; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the height of the video element. + */ + height: number; + msHorizontalMirror: boolean; + readonly msIsLayoutOptimalForPlayback: boolean; + readonly msIsStereo3D: boolean; + msStereo3DPackingMode: string; + msStereo3DRenderMode: string; + msZoom: boolean; + onMSVideoFormatChanged: (this: HTMLVideoElement, ev: Event) => any; + onMSVideoFrameStepCompleted: (this: HTMLVideoElement, ev: Event) => any; + onMSVideoOptimalLayoutChanged: (this: HTMLVideoElement, 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. + */ + readonly videoHeight: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + readonly videoWidth: number; + readonly webkitDisplayingFullscreen: boolean; + readonly 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: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface HashChangeEvent extends Event { + readonly newURL: string | null; + readonly oldURL: string | null; +} + +declare var HashChangeEvent: { + prototype: HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; +} + +interface History { + readonly length: number; + readonly state: any; + scrollRestoration: ScrollRestoration; + back(): void; + forward(): void; + go(delta?: number): void; + pushState(data: any, title: string, url?: string | null): void; + replaceState(data: any, title: string, url?: string | null): void; +} + +declare var History: { + prototype: History; + new(): History; +} + +interface IDBCursor { + readonly direction: IDBCursorDirection; + key: IDBKeyRange | IDBValidKey; + readonly primaryKey: any; + source: IDBObjectStore | IDBIndex; + advance(count: number): void; + continue(key?: IDBKeyRange | IDBValidKey): void; + delete(): IDBRequest; + update(value: any): IDBRequest; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; +} + +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; +} + +interface IDBCursorWithValue extends IDBCursor { + readonly value: any; +} + +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface IDBDatabaseEventMap { + "abort": Event; + "error": Event; +} + +interface IDBDatabase extends EventTarget { + readonly name: string; + readonly objectStoreNames: DOMStringList; + onabort: (this: IDBDatabase, ev: Event) => any; + onerror: (this: IDBDatabase, ev: Event) => any; + version: number; + onversionchange: (ev: IDBVersionChangeEvent) => any; + close(): void; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; + deleteObjectStore(name: string): void; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; + addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => 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[]; + readonly name: string; + readonly objectStore: IDBObjectStore; + readonly unique: boolean; + multiEntry: boolean; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + get(key: IDBKeyRange | IDBValidKey): IDBRequest; + getKey(key: IDBKeyRange | IDBValidKey): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; +} + +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface IDBKeyRange { + readonly lower: any; + readonly lowerOpen: boolean; + readonly upper: any; + readonly upperOpen: boolean; +} + +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + lowerBound(lower: any, open?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + upperBound(upper: any, open?: boolean): IDBKeyRange; +} + +interface IDBObjectStore { + readonly indexNames: DOMStringList; + keyPath: string | string[]; + readonly name: string; + readonly transaction: IDBTransaction; + autoIncrement: boolean; + add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; + clear(): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; + delete(key: IDBKeyRange | IDBValidKey): IDBRequest; + deleteIndex(indexName: string): void; + get(key: any): IDBRequest; + index(name: string): IDBIndex; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; +} + +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface IDBOpenDBRequestEventMap extends IDBRequestEventMap { + "blocked": Event; + "upgradeneeded": IDBVersionChangeEvent; +} + +interface IDBOpenDBRequest extends IDBRequest { + onblocked: (this: IDBOpenDBRequest, ev: Event) => any; + onupgradeneeded: (this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any; + addEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface IDBRequestEventMap { + "error": Event; + "success": Event; +} + +interface IDBRequest extends EventTarget { + readonly error: DOMError; + onerror: (this: IDBRequest, ev: Event) => any; + onsuccess: (this: IDBRequest, ev: Event) => any; + readonly readyState: IDBRequestReadyState; + readonly result: any; + source: IDBObjectStore | IDBIndex | IDBCursor; + readonly transaction: IDBTransaction; + addEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface IDBTransactionEventMap { + "abort": Event; + "complete": Event; + "error": Event; +} + +interface IDBTransaction extends EventTarget { + readonly db: IDBDatabase; + readonly error: DOMError; + readonly mode: IDBTransactionMode; + onabort: (this: IDBTransaction, ev: Event) => any; + oncomplete: (this: IDBTransaction, ev: Event) => any; + onerror: (this: IDBTransaction, ev: Event) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; + addEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; +} + +interface IDBVersionChangeEvent extends Event { + readonly newVersion: number | null; + readonly oldVersion: number; +} + +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + +interface ImageData { + data: Uint8ClampedArray; + readonly height: number; + readonly width: number; +} + +declare var ImageData: { + prototype: ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; +} + +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + +interface KeyboardEvent extends UIEvent { + readonly altKey: boolean; + readonly char: string | null; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly key: string; + readonly keyCode: number; + readonly locale: string; + readonly location: number; + readonly metaKey: boolean; + readonly repeat: boolean; + readonly shiftKey: boolean; + readonly which: number; + readonly code: string; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; +} + +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; +} + +interface ListeningStateChangedEvent extends Event { + readonly label: string; + readonly state: ListeningState; +} + +declare var ListeningStateChangedEvent: { + prototype: ListeningStateChangedEvent; + new(): ListeningStateChangedEvent; +} + +interface Location { + hash: string; + host: string; + hostname: string; + href: string; + readonly 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 { + readonly 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): Promise; + getViewId(view: any): any; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + pageHandlesAllApplicationActivations(enabled: boolean): void; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + terminateApp(exceptionObject: any): void; + readonly CURRENT: string; + readonly HIGH: string; + readonly IDLE: string; + readonly NORMAL: string; +} +declare var MSApp: MSApp; + +interface MSAppAsyncOperationEventMap { + "complete": Event; + "error": Event; +} + +interface MSAppAsyncOperation extends EventTarget { + readonly error: DOMError; + oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; + readonly readyState: number; + readonly result: any; + start(): void; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; +} + +interface MSAssertion { + readonly id: string; + readonly type: MSCredentialType; +} + +declare var MSAssertion: { + prototype: MSAssertion; + new(): MSAssertion; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} + +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface MSCredentials { + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; +} + +declare var MSCredentials: { + prototype: MSCredentials; + new(): MSCredentials; +} + +interface MSFIDOCredentialAssertion extends MSAssertion { + readonly algorithm: string | Algorithm; + readonly attestation: any; + readonly publicKey: string; + readonly transportHints: MSTransportType[]; +} + +declare var MSFIDOCredentialAssertion: { + prototype: MSFIDOCredentialAssertion; + new(): MSFIDOCredentialAssertion; +} + +interface MSFIDOSignature { + readonly authnrData: string; + readonly clientData: string; + readonly signature: string; +} + +declare var MSFIDOSignature: { + prototype: MSFIDOSignature; + new(): MSFIDOSignature; +} + +interface MSFIDOSignatureAssertion extends MSAssertion { + readonly signature: MSFIDOSignature; +} + +declare var MSFIDOSignatureAssertion: { + prototype: MSFIDOSignatureAssertion; + new(): MSFIDOSignatureAssertion; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} + +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface MSGestureEvent extends UIEvent { + readonly clientX: number; + readonly clientY: number; + readonly expansion: number; + readonly gestureObject: any; + readonly hwTimestamp: number; + readonly offsetX: number; + readonly offsetY: number; + readonly rotation: number; + readonly scale: number; + readonly screenX: number; + readonly screenY: number; + readonly translationX: number; + readonly translationY: number; + readonly velocityAngular: number; + readonly velocityExpansion: number; + readonly velocityX: number; + readonly 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; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; +} + +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; +} + +interface MSGraphicsTrust { + readonly constrictionActive: boolean; + readonly status: string; +} + +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface MSHTMLWebViewElement extends HTMLElement { + readonly canGoBack: boolean; + readonly canGoForward: boolean; + readonly containsFullScreenElement: boolean; + readonly documentTitle: string; + height: number; + readonly 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; + navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + navigateToString(contents: string): void; + navigateWithHttpRequestMessage(requestMessage: any): void; + refresh(): void; + stop(): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface MSInputMethodContextEventMap { + "MSCandidateWindowHide": Event; + "MSCandidateWindowShow": Event; + "MSCandidateWindowUpdate": Event; +} + +interface MSInputMethodContext extends EventTarget { + readonly compositionEndOffset: number; + readonly compositionStartOffset: number; + oncandidatewindowhide: (this: MSInputMethodContext, ev: Event) => any; + oncandidatewindowshow: (this: MSInputMethodContext, ev: Event) => any; + oncandidatewindowupdate: (this: MSInputMethodContext, ev: Event) => any; + readonly target: HTMLElement; + getCandidateWindowClientRect(): ClientRect; + getCompositionAlternatives(): string[]; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: K, listener: (this: MSInputMethodContext, ev: MSInputMethodContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface MSManipulationEvent extends UIEvent { + readonly currentState: number; + readonly inertiaDestinationX: number; + readonly inertiaDestinationY: number; + readonly lastState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; +} + +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; +} + +interface MSMediaKeyError { + readonly code: number; + readonly systemCode: number; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; +} + +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; +} + +interface MSMediaKeyMessageEvent extends Event { + readonly destinationURL: string | null; + readonly message: Uint8Array; +} + +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSMediaKeyNeededEvent extends Event { + readonly initData: Uint8Array | null; +} + +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface MSMediaKeySession extends EventTarget { + readonly error: MSMediaKeyError | null; + readonly keySystem: string; + readonly sessionId: string; + close(): void; + update(key: Uint8Array): void; +} + +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface MSMediaKeys { + readonly 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; + isTypeSupportedWithFeatures(keySystem: string, type?: string): string; +} + +interface MSPointerEvent extends MouseEvent { + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly 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 { + readonly length: number; + item(index: number): Range; + [index: number]: Range; +} + +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface MSSiteModeEvent extends Event { + readonly actionURL: string; + readonly buttonID: number; +} + +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface MSStream { + readonly type: string; + msClose(): void; + msDetachStream(): any; +} + +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSStreamReader extends EventTarget, MSBaseReader { + readonly 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: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface MSWebViewAsyncOperationEventMap { + "complete": Event; + "error": Event; +} + +interface MSWebViewAsyncOperation extends EventTarget { + readonly error: DOMError; + oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; + readonly readyState: number; + readonly result: any; + readonly target: MSHTMLWebViewElement; + readonly type: number; + start(): void; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; + addEventListener(type: K, listener: (this: MSWebViewAsyncOperation, ev: MSWebViewAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; +} + +interface MSWebViewSettings { + isIndexedDBEnabled: boolean; + isJavaScriptEnabled: boolean; +} + +declare var MSWebViewSettings: { + prototype: MSWebViewSettings; + new(): MSWebViewSettings; +} + +interface MediaDeviceInfo { + readonly deviceId: string; + readonly groupId: string; + readonly kind: MediaDeviceKind; + readonly label: string; +} + +declare var MediaDeviceInfo: { + prototype: MediaDeviceInfo; + new(): MediaDeviceInfo; +} + +interface MediaDevicesEventMap { + "devicechange": Event; +} + +interface MediaDevices extends EventTarget { + ondevicechange: (this: MediaDevices, ev: Event) => any; + enumerateDevices(): any; + getSupportedConstraints(): MediaTrackSupportedConstraints; + getUserMedia(constraints: MediaStreamConstraints): Promise; + addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaDevices: { + prototype: MediaDevices; + new(): MediaDevices; +} + +interface MediaElementAudioSourceNode extends AudioNode { +} + +declare var MediaElementAudioSourceNode: { + prototype: MediaElementAudioSourceNode; + new(): MediaElementAudioSourceNode; +} + +interface MediaEncryptedEvent extends Event { + readonly initData: ArrayBuffer | null; + readonly initDataType: string; +} + +declare var MediaEncryptedEvent: { + prototype: MediaEncryptedEvent; + new(type: string, eventInitDict?: MediaEncryptedEventInit): MediaEncryptedEvent; +} + +interface MediaError { + readonly code: number; + readonly msExtendedCode: number; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; +} + +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface MediaKeyMessageEvent extends Event { + readonly message: ArrayBuffer; + readonly messageType: MediaKeyMessageType; +} + +declare var MediaKeyMessageEvent: { + prototype: MediaKeyMessageEvent; + new(type: string, eventInitDict?: MediaKeyMessageEventInit): MediaKeyMessageEvent; +} + +interface MediaKeySession extends EventTarget { + readonly closed: Promise; + readonly expiration: number; + readonly keyStatuses: MediaKeyStatusMap; + readonly sessionId: string; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; +} + +declare var MediaKeySession: { + prototype: MediaKeySession; + new(): MediaKeySession; +} + +interface MediaKeyStatusMap { + readonly size: number; + forEach(callback: ForEachCallback): void; + get(keyId: any): MediaKeyStatus; + has(keyId: any): boolean; +} + +declare var MediaKeyStatusMap: { + prototype: MediaKeyStatusMap; + new(): MediaKeyStatusMap; +} + +interface MediaKeySystemAccess { + readonly keySystem: string; + createMediaKeys(): Promise; + getConfiguration(): MediaKeySystemConfiguration; +} + +declare var MediaKeySystemAccess: { + prototype: MediaKeySystemAccess; + new(): MediaKeySystemAccess; +} + +interface MediaKeys { + createSession(sessionType?: MediaKeySessionType): MediaKeySession; + setServerCertificate(serverCertificate: any): Promise; +} + +declare var MediaKeys: { + prototype: MediaKeys; + new(): MediaKeys; +} + +interface MediaList { + readonly 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 { + readonly matches: boolean; + readonly media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface MediaSource extends EventTarget { + readonly activeSourceBuffers: SourceBufferList; + duration: number; + readonly readyState: string; + readonly 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 MediaStreamEventMap { + "active": Event; + "addtrack": MediaStreamTrackEvent; + "inactive": Event; + "removetrack": MediaStreamTrackEvent; +} + +interface MediaStream extends EventTarget { + readonly active: boolean; + readonly id: string; + onactive: (this: MediaStream, ev: Event) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; + oninactive: (this: MediaStream, ev: Event) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; + addTrack(track: MediaStreamTrack): void; + clone(): MediaStream; + getAudioTracks(): MediaStreamTrack[]; + getTrackById(trackId: string): MediaStreamTrack | null; + getTracks(): MediaStreamTrack[]; + getVideoTracks(): MediaStreamTrack[]; + removeTrack(track: MediaStreamTrack): void; + stop(): void; + addEventListener(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStream: { + prototype: MediaStream; + new(streamOrTracks?: MediaStream | MediaStreamTrack[]): MediaStream; +} + +interface MediaStreamAudioSourceNode extends AudioNode { +} + +declare var MediaStreamAudioSourceNode: { + prototype: MediaStreamAudioSourceNode; + new(): MediaStreamAudioSourceNode; +} + +interface MediaStreamError { + readonly constraintName: string | null; + readonly message: string | null; + readonly name: string; +} + +declare var MediaStreamError: { + prototype: MediaStreamError; + new(): MediaStreamError; +} + +interface MediaStreamErrorEvent extends Event { + readonly error: MediaStreamError | null; +} + +declare var MediaStreamErrorEvent: { + prototype: MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; +} + +interface MediaStreamTrackEventMap { + "ended": MediaStreamErrorEvent; + "mute": Event; + "overconstrained": MediaStreamErrorEvent; + "unmute": Event; +} + +interface MediaStreamTrack extends EventTarget { + enabled: boolean; + readonly id: string; + readonly kind: string; + readonly label: string; + readonly muted: boolean; + onended: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; + onmute: (this: MediaStreamTrack, ev: Event) => any; + onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; + onunmute: (this: MediaStreamTrack, ev: Event) => any; + readonly readonly: boolean; + readonly readyState: MediaStreamTrackState; + readonly remote: boolean; + applyConstraints(constraints: MediaTrackConstraints): Promise; + clone(): MediaStreamTrack; + getCapabilities(): MediaTrackCapabilities; + getConstraints(): MediaTrackConstraints; + getSettings(): MediaTrackSettings; + stop(): void; + addEventListener(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStreamTrack: { + prototype: MediaStreamTrack; + new(): MediaStreamTrack; +} + +interface MediaStreamTrackEvent extends Event { + readonly track: MediaStreamTrack; +} + +declare var MediaStreamTrackEvent: { + prototype: MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; +} + +interface MessageChannel { + readonly port1: MessagePort; + readonly port2: MessagePort; +} + +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface MessageEvent extends Event { + readonly data: any; + readonly origin: string; + readonly ports: any; + readonly 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 MessagePortEventMap { + "message": MessageEvent; +} + +interface MessagePort extends EventTarget { + onmessage: (this: MessagePort, ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, transfer?: any[]): void; + start(): void; + addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface MimeType { + readonly description: string; + readonly enabledPlugin: Plugin; + readonly suffixes: string; + readonly type: string; +} + +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface MimeTypeArray { + readonly length: number; + item(index: number): Plugin; + namedItem(type: string): Plugin; + [index: number]: Plugin; +} + +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface MouseEvent extends UIEvent { + readonly altKey: boolean; + readonly button: number; + readonly buttons: number; + readonly clientX: number; + readonly clientY: number; + readonly ctrlKey: boolean; + readonly fromElement: Element; + readonly layerX: number; + readonly layerY: number; + readonly metaKey: boolean; + readonly movementX: number; + readonly movementY: number; + readonly offsetX: number; + readonly offsetY: number; + readonly pageX: number; + readonly pageY: number; + readonly relatedTarget: EventTarget; + readonly screenX: number; + readonly screenY: number; + readonly shiftKey: boolean; + readonly toElement: Element; + readonly which: number; + readonly x: number; + readonly 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 | null): void; +} + +declare var MouseEvent: { + prototype: MouseEvent; + new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; +} + +interface MutationEvent extends Event { + readonly attrChange: number; + readonly attrName: string; + readonly newValue: string; + readonly prevValue: string; + readonly relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly REMOVAL: number; +} + +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly 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 { + readonly addedNodes: NodeList; + readonly attributeName: string | null; + readonly attributeNamespace: string | null; + readonly nextSibling: Node | null; + readonly oldValue: string | null; + readonly previousSibling: Node | null; + readonly removedNodes: NodeList; + readonly target: Node; + readonly type: string; +} + +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface NamedNodeMap { + readonly length: number; + getNamedItem(name: string): Attr; + getNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; + item(index: number): Attr; + removeNamedItem(name: string): Attr; + removeNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; + setNamedItem(arg: Attr): Attr; + setNamedItemNS(arg: Attr): Attr; + [index: number]: Attr; +} + +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface NavigationCompletedEvent extends NavigationEvent { + readonly isSuccess: boolean; + readonly webErrorStatus: number; +} + +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface NavigationEvent extends Event { + readonly uri: string; +} + +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +interface NavigationEventWithReferrer extends NavigationEvent { + readonly referer: string; +} + +declare var NavigationEventWithReferrer: { + prototype: NavigationEventWithReferrer; + new(): NavigationEventWithReferrer; +} + +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; + readonly cookieEnabled: boolean; + gamepadInputEmulation: GamepadInputEmulationType; + readonly language: string; + readonly maxTouchPoints: number; + readonly mimeTypes: MimeTypeArray; + readonly msManipulationViewsEnabled: boolean; + readonly msMaxTouchPoints: number; + readonly msPointerEnabled: boolean; + readonly plugins: PluginArray; + readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; + readonly webdriver: boolean; + readonly hardwareConcurrency: number; + getGamepads(): Gamepad[]; + javaEnabled(): boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; + vibrate(pattern: number | number[]): boolean; +} + +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface Node extends EventTarget { + readonly attributes: NamedNodeMap; + readonly baseURI: string | null; + readonly childNodes: NodeList; + readonly firstChild: Node | null; + readonly lastChild: Node | null; + readonly localName: string | null; + readonly namespaceURI: string | null; + readonly nextSibling: Node | null; + readonly nodeName: string; + readonly nodeType: number; + nodeValue: string | null; + readonly ownerDocument: Document; + readonly parentElement: HTMLElement | null; + readonly parentNode: Node | null; + readonly previousSibling: Node | null; + textContent: string | null; + appendChild(newChild: T): T; + cloneNode(deep?: boolean): Node; + compareDocumentPosition(other: Node): number; + contains(child: Node): boolean; + hasAttributes(): boolean; + hasChildNodes(): boolean; + insertBefore(newChild: T, refChild: Node | null): T; + isDefaultNamespace(namespaceURI: string | null): boolean; + isEqualNode(arg: Node): boolean; + isSameNode(other: Node): boolean; + lookupNamespaceURI(prefix: string | null): string | null; + lookupPrefix(namespaceURI: string | null): string | null; + normalize(): void; + removeChild(oldChild: T): T; + replaceChild(newChild: Node, oldChild: T): T; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; +} + +declare var Node: { + prototype: Node; + new(): Node; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { + readonly FILTER_ACCEPT: number; + readonly FILTER_REJECT: number; + readonly FILTER_SKIP: number; + readonly SHOW_ALL: number; + readonly SHOW_ATTRIBUTE: number; + readonly SHOW_CDATA_SECTION: number; + readonly SHOW_COMMENT: number; + readonly SHOW_DOCUMENT: number; + readonly SHOW_DOCUMENT_FRAGMENT: number; + readonly SHOW_DOCUMENT_TYPE: number; + readonly SHOW_ELEMENT: number; + readonly SHOW_ENTITY: number; + readonly SHOW_ENTITY_REFERENCE: number; + readonly SHOW_NOTATION: number; + readonly SHOW_PROCESSING_INSTRUCTION: number; + readonly SHOW_TEXT: number; +} + +interface NodeIterator { + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly whatToShow: number; + detach(): void; + nextNode(): Node; + previousNode(): Node; +} + +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface NodeList { + readonly length: number; + item(index: number): Node; + [index: number]: Node; +} + +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: NotificationDirection; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: NotificationPermission; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + +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 { + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + readonly 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 OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + +interface OfflineAudioCompletionEvent extends Event { + readonly renderedBuffer: AudioBuffer; +} + +declare var OfflineAudioCompletionEvent: { + prototype: OfflineAudioCompletionEvent; + new(): OfflineAudioCompletionEvent; +} + +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; +} + +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; + addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => 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 OscillatorNodeEventMap { + "ended": MediaStreamErrorEvent; +} + +interface OscillatorNode extends AudioNode { + readonly detune: AudioParam; + readonly frequency: AudioParam; + onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any; + type: OscillatorType; + setPeriodicWave(periodicWave: PeriodicWave): void; + start(when?: number): void; + stop(when?: number): void; + addEventListener(type: K, listener: (this: OscillatorNode, ev: OscillatorNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OscillatorNode: { + prototype: OscillatorNode; + new(): OscillatorNode; +} + +interface OverflowEvent extends UIEvent { + readonly horizontalOverflow: boolean; + readonly orient: number; + readonly verticalOverflow: boolean; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; +} + +declare var OverflowEvent: { + prototype: OverflowEvent; + new(): OverflowEvent; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; +} + +interface PageTransitionEvent extends Event { + readonly persisted: boolean; +} + +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface PannerNode extends AudioNode { + coneInnerAngle: number; + coneOuterAngle: number; + coneOuterGain: number; + distanceModel: DistanceModelType; + maxDistance: number; + panningModel: PanningModelType; + 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 Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: PaymentShippingType | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: PaymentComplete): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + +interface PerfWidgetExternal { + readonly activeNetworkRequestCount: number; + readonly averageFrameTime: number; + readonly averagePaintTime: number; + readonly extraInformationEnabled: boolean; + readonly independentRenderingEnabled: boolean; + readonly irDisablingContentString: string; + readonly irStatusAvailable: boolean; + readonly maxCpuSpeed: number; + readonly paintRequestsPerSecond: number; + readonly performanceCounter: number; + readonly performanceCounterFrequency: number; + addEventListener(eventType: string, callback: Function): void; + getMemoryUsage(): number; + getProcessCpuUsage(): number; + getRecentCpuUsage(last: number | null): any; + getRecentFrames(last: number | null): any; + getRecentMemoryUsage(last: number | null): any; + getRecentPaintRequests(last: number | null): 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 { + readonly navigation: PerformanceNavigation; + readonly 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 { + readonly duration: number; + readonly entryType: string; + readonly name: string; + readonly 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 { + readonly redirectCount: number; + readonly type: number; + toJSON(): any; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly navigationStart: number; + readonly redirectCount: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly type: NavigationType; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; +} + +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + readonly connectEnd: number; + readonly connectStart: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly initiatorType: string; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; +} + +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface PerformanceTiming { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; + readonly secureConnectionStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface PeriodicWave { +} + +declare var PeriodicWave: { + prototype: PeriodicWave; + new(): PeriodicWave; +} + +interface PermissionRequest extends DeferredPermissionRequest { + readonly state: MSWebViewPermissionState; + defer(): void; +} + +declare var PermissionRequest: { + prototype: PermissionRequest; + new(): PermissionRequest; +} + +interface PermissionRequestedEvent extends Event { + readonly permissionRequest: PermissionRequest; +} + +declare var PermissionRequestedEvent: { + prototype: PermissionRequestedEvent; + new(): PermissionRequestedEvent; +} + +interface Plugin { + readonly description: string; + readonly filename: string; + readonly length: number; + readonly name: string; + readonly version: string; + item(index: number): MimeType; + namedItem(type: string): MimeType; + [index: number]: MimeType; +} + +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface PluginArray { + readonly 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 { + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly 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 { + readonly state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +declare var PopStateEvent: { + prototype: PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; +} + +interface Position { + readonly coords: Coordinates; + readonly timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + readonly code: number; + readonly message: string; + toString(): string; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; +} + +interface ProcessingInstruction extends CharacterData { + readonly target: string; +} + +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface ProgressEvent extends Event { + readonly lengthComputable: boolean; + readonly loaded: number; + readonly 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 PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + +interface RTCDTMFToneChangeEvent extends Event { + readonly tone: string; +} + +declare var RTCDTMFToneChangeEvent: { + prototype: RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; +} + +interface RTCDtlsTransportEventMap { + "dtlsstatechange": RTCDtlsTransportStateChangedEvent; + "error": Event; +} + +interface RTCDtlsTransport extends RTCStatsProvider { + ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; + readonly state: RTCDtlsTransportState; + readonly transport: RTCIceTransport; + getLocalParameters(): RTCDtlsParameters; + getRemoteCertificates(): ArrayBuffer[]; + getRemoteParameters(): RTCDtlsParameters | null; + start(remoteParameters: RTCDtlsParameters): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtlsTransport: { + prototype: RTCDtlsTransport; + new(transport: RTCIceTransport): RTCDtlsTransport; +} + +interface RTCDtlsTransportStateChangedEvent extends Event { + readonly state: RTCDtlsTransportState; +} + +declare var RTCDtlsTransportStateChangedEvent: { + prototype: RTCDtlsTransportStateChangedEvent; + new(): RTCDtlsTransportStateChangedEvent; +} + +interface RTCDtmfSenderEventMap { + "tonechange": RTCDTMFToneChangeEvent; +} + +interface RTCDtmfSender extends EventTarget { + readonly canInsertDTMF: boolean; + readonly duration: number; + readonly interToneGap: number; + ontonechange: (this: RTCDtmfSender, ev: RTCDTMFToneChangeEvent) => any; + readonly sender: RTCRtpSender; + readonly toneBuffer: string; + insertDTMF(tones: string, duration?: number, interToneGap?: number): void; + addEventListener(type: K, listener: (this: RTCDtmfSender, ev: RTCDtmfSenderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtmfSender: { + prototype: RTCDtmfSender; + new(sender: RTCRtpSender): RTCDtmfSender; +} + +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + +interface RTCIceCandidatePairChangedEvent extends Event { + readonly pair: RTCIceCandidatePair; +} + +declare var RTCIceCandidatePairChangedEvent: { + prototype: RTCIceCandidatePairChangedEvent; + new(): RTCIceCandidatePairChangedEvent; +} + +interface RTCIceGathererEventMap { + "error": Event; + "localcandidate": RTCIceGathererEvent; +} + +interface RTCIceGatherer extends RTCStatsProvider { + readonly component: RTCIceComponent; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; + onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; + createAssociatedGatherer(): RTCIceGatherer; + getLocalCandidates(): RTCIceCandidateDictionary[]; + getLocalParameters(): RTCIceParameters; + addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceGatherer: { + prototype: RTCIceGatherer; + new(options: RTCIceGatherOptions): RTCIceGatherer; +} + +interface RTCIceGathererEvent extends Event { + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; +} + +declare var RTCIceGathererEvent: { + prototype: RTCIceGathererEvent; + new(): RTCIceGathererEvent; +} + +interface RTCIceTransportEventMap { + "candidatepairchange": RTCIceCandidatePairChangedEvent; + "icestatechange": RTCIceTransportStateChangedEvent; +} + +interface RTCIceTransport extends RTCStatsProvider { + readonly component: RTCIceComponent; + readonly iceGatherer: RTCIceGatherer | null; + oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null; + onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; + readonly role: RTCIceRole; + readonly state: RTCIceTransportState; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; + createAssociatedTransport(): RTCIceTransport; + getNominatedCandidatePair(): RTCIceCandidatePair | null; + getRemoteCandidates(): RTCIceCandidateDictionary[]; + getRemoteParameters(): RTCIceParameters | null; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceTransport: { + prototype: RTCIceTransport; + new(): RTCIceTransport; +} + +interface RTCIceTransportStateChangedEvent extends Event { + readonly state: RTCIceTransportState; +} + +declare var RTCIceTransportStateChangedEvent: { + prototype: RTCIceTransportStateChangedEvent; + new(): RTCIceTransportStateChangedEvent; +} + +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: RTCIceConnectionState; + readonly iceGatheringState: RTCIceGatheringState; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: RTCSignalingState; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + +interface RTCRtpReceiverEventMap { + "error": Event; +} + +interface RTCRtpReceiver extends RTCStatsProvider { + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack | null; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; + getContributingSources(): RTCRtpContributingSource[]; + receive(parameters: RTCRtpParameters): void; + requestSendCSRC(csrc: number): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCRtpReceiver, ev: RTCRtpReceiverEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpReceiver: { + prototype: RTCRtpReceiver; + new(transport: RTCDtlsTransport | RTCSrtpSdesTransport, kind: string, rtcpTransport?: RTCDtlsTransport): RTCRtpReceiver; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCRtpSenderEventMap { + "error": Event; + "ssrcconflict": RTCSsrcConflictEvent; +} + +interface RTCRtpSender extends RTCStatsProvider { + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; + onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; + send(parameters: RTCRtpParameters): void; + setTrack(track: MediaStreamTrack): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCRtpSender, ev: RTCRtpSenderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpSender: { + prototype: RTCRtpSender; + new(track: MediaStreamTrack, transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): RTCRtpSender; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCSessionDescription { + sdp: string | null; + type: RTCSdpType | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + +interface RTCSrtpSdesTransportEventMap { + "error": Event; +} + +interface RTCSrtpSdesTransport extends EventTarget { + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; + readonly transport: RTCIceTransport; + addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCSrtpSdesTransport: { + prototype: RTCSrtpSdesTransport; + new(transport: RTCIceTransport, encryptParameters: RTCSrtpSdesParameters, decryptParameters: RTCSrtpSdesParameters): RTCSrtpSdesTransport; + getLocalParameters(): RTCSrtpSdesParameters[]; +} + +interface RTCSsrcConflictEvent extends Event { + readonly ssrc: number; +} + +declare var RTCSsrcConflictEvent: { + prototype: RTCSsrcConflictEvent; + new(): RTCSsrcConflictEvent; +} + +interface RTCStatsProvider extends EventTarget { + getStats(): Promise; + msGetStats(): Promise; +} + +declare var RTCStatsProvider: { + prototype: RTCStatsProvider; + new(): RTCStatsProvider; +} + +interface Range { + readonly collapsed: boolean; + readonly commonAncestorContainer: Node; + readonly endContainer: Node; + readonly endOffset: number; + readonly startContainer: Node; + readonly 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: ExpandGranularity): 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; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; +} + +declare var Range: { + prototype: Range; + new(): Range; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; +} + +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; + readonly referrer: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: ResponseType; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { + readonly target: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGAngle { + readonly unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; +} + +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; +} + +interface SVGAnimatedAngle { + readonly animVal: SVGAngle; + readonly baseVal: SVGAngle; +} + +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface SVGAnimatedBoolean { + readonly animVal: boolean; + baseVal: boolean; +} + +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface SVGAnimatedEnumeration { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface SVGAnimatedInteger { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGAnimatedLength { + readonly animVal: SVGLength; + readonly baseVal: SVGLength; +} + +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedLengthList { + readonly animVal: SVGLengthList; + readonly baseVal: SVGLengthList; +} + +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedNumber { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface SVGAnimatedNumberList { + readonly animVal: SVGNumberList; + readonly baseVal: SVGNumberList; +} + +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGAnimatedPreserveAspectRatio { + readonly animVal: SVGPreserveAspectRatio; + readonly baseVal: SVGPreserveAspectRatio; +} + +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface SVGAnimatedRect { + readonly animVal: SVGRect; + readonly baseVal: SVGRect; +} + +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface SVGAnimatedString { + readonly animVal: string; + baseVal: string; +} + +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface SVGAnimatedTransformList { + readonly animVal: SVGTransformList; + readonly baseVal: SVGTransformList; +} + +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface SVGCircleElement extends SVGGraphicsElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { + readonly clipPathUnits: SVGAnimatedEnumeration; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + readonly amplitude: SVGAnimatedNumber; + readonly exponent: SVGAnimatedNumber; + readonly intercept: SVGAnimatedNumber; + readonly offset: SVGAnimatedNumber; + readonly slope: SVGAnimatedNumber; + readonly tableValues: SVGAnimatedNumberList; + readonly type: SVGAnimatedEnumeration; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface SVGElementEventMap extends ElementEventMap { + "click": MouseEvent; + "dblclick": MouseEvent; + "focusin": FocusEvent; + "focusout": FocusEvent; + "load": Event; + "mousedown": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; +} + +interface SVGElement extends Element { + className: any; + onclick: (this: SVGElement, ev: MouseEvent) => any; + ondblclick: (this: SVGElement, ev: MouseEvent) => any; + onfocusin: (this: SVGElement, ev: FocusEvent) => any; + onfocusout: (this: SVGElement, ev: FocusEvent) => any; + onload: (this: SVGElement, ev: Event) => any; + onmousedown: (this: SVGElement, ev: MouseEvent) => any; + onmousemove: (this: SVGElement, ev: MouseEvent) => any; + onmouseout: (this: SVGElement, ev: MouseEvent) => any; + onmouseover: (this: SVGElement, ev: MouseEvent) => any; + onmouseup: (this: SVGElement, ev: MouseEvent) => any; + readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; + readonly viewportElement: SVGElement; + xmlbase: string; + addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface SVGElementInstance extends EventTarget { + readonly childNodes: SVGElementInstanceList; + readonly correspondingElement: SVGElement; + readonly correspondingUseElement: SVGUseElement; + readonly firstChild: SVGElementInstance; + readonly lastChild: SVGElementInstance; + readonly nextSibling: SVGElementInstance; + readonly parentNode: SVGElementInstance; + readonly previousSibling: SVGElementInstance; +} + +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface SVGElementInstanceList { + readonly length: number; + item(index: number): SVGElementInstance; +} + +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface SVGEllipseElement extends SVGGraphicsElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly mode: SVGAnimatedEnumeration; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly type: SVGAnimatedEnumeration; + readonly values: SVGAnimatedNumberList; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly k1: SVGAnimatedNumber; + readonly k2: SVGAnimatedNumber; + readonly k3: SVGAnimatedNumber; + readonly k4: SVGAnimatedNumber; + readonly operator: SVGAnimatedEnumeration; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly bias: SVGAnimatedNumber; + readonly divisor: SVGAnimatedNumber; + readonly edgeMode: SVGAnimatedEnumeration; + readonly in1: SVGAnimatedString; + readonly kernelMatrix: SVGAnimatedNumberList; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly orderX: SVGAnimatedInteger; + readonly orderY: SVGAnimatedInteger; + readonly preserveAlpha: SVGAnimatedBoolean; + readonly targetX: SVGAnimatedInteger; + readonly targetY: SVGAnimatedInteger; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly diffuseConstant: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly scale: SVGAnimatedNumber; + readonly xChannelSelector: SVGAnimatedEnumeration; + readonly yChannelSelector: SVGAnimatedEnumeration; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; +} + +interface SVGFEDistantLightElement extends SVGElement { + readonly azimuth: SVGAnimatedNumber; + readonly elevation: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly stdDeviationX: SVGAnimatedNumber; + readonly stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface SVGFEMergeNodeElement extends SVGElement { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly operator: SVGAnimatedEnumeration; + readonly radiusX: SVGAnimatedNumber; + readonly radiusY: SVGAnimatedNumber; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly dx: SVGAnimatedNumber; + readonly dy: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface SVGFEPointLightElement extends SVGElement { + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly specularConstant: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface SVGFESpotLightElement extends SVGElement { + readonly limitingConeAngle: SVGAnimatedNumber; + readonly pointsAtX: SVGAnimatedNumber; + readonly pointsAtY: SVGAnimatedNumber; + readonly pointsAtZ: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly baseFrequencyX: SVGAnimatedNumber; + readonly baseFrequencyY: SVGAnimatedNumber; + readonly numOctaves: SVGAnimatedInteger; + readonly seed: SVGAnimatedNumber; + readonly stitchTiles: SVGAnimatedEnumeration; + readonly type: SVGAnimatedEnumeration; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { + readonly filterResX: SVGAnimatedInteger; + readonly filterResY: SVGAnimatedInteger; + readonly filterUnits: SVGAnimatedEnumeration; + readonly height: SVGAnimatedLength; + readonly primitiveUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + setFilterRes(filterResX: number, filterResY: number): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface SVGForeignObjectElement extends SVGGraphicsElement { + readonly height: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGForeignObjectElement: { + prototype: SVGForeignObjectElement; + new(): SVGForeignObjectElement; +} + +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { + readonly gradientTransform: SVGAnimatedTransformList; + readonly gradientUnits: SVGAnimatedEnumeration; + readonly spreadMethod: SVGAnimatedEnumeration; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; +} + +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { + readonly height: SVGAnimatedLength; + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGLength { + readonly unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; +} + +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; +} + +interface SVGLengthList { + readonly 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 SVGGraphicsElement { + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { + readonly markerHeight: SVGAnimatedLength; + readonly markerUnits: SVGAnimatedEnumeration; + readonly markerWidth: SVGAnimatedLength; + readonly orientAngle: SVGAnimatedAngle; + readonly orientType: SVGAnimatedEnumeration; + readonly refX: SVGAnimatedLength; + readonly refY: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; +} + +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { + readonly height: SVGAnimatedLength; + readonly maskContentUnits: SVGAnimatedEnumeration; + readonly maskUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + 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 { + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGNumber { + value: number; +} + +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGNumberList { + readonly 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 SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; + 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: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface SVGPathSeg { + readonly pathSegType: number; + readonly pathSegTypeAsLetter: string; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly PATHSEG_UNKNOWN: number; +} + +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly 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 { + readonly 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, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { + readonly height: SVGAnimatedLength; + readonly patternContentUnits: SVGAnimatedEnumeration; + readonly patternTransform: SVGAnimatedTransformList; + readonly patternUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + 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 { + readonly 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 SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly fx: SVGAnimatedLength; + readonly fy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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 SVGGraphicsElement { + readonly height: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface SVGSVGElementEventMap extends SVGElementEventMap { + "SVGAbort": Event; + "SVGError": Event; + "resize": UIEvent; + "scroll": UIEvent; + "SVGUnload": Event; + "SVGZoom": SVGZoomEvent; +} + +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { + contentScriptType: string; + contentStyleType: string; + currentScale: number; + readonly currentTranslate: SVGPoint; + readonly height: SVGAnimatedLength; + onabort: (this: SVGSVGElement, ev: Event) => any; + onerror: (this: SVGSVGElement, ev: Event) => any; + onresize: (this: SVGSVGElement, ev: UIEvent) => any; + onscroll: (this: SVGSVGElement, ev: UIEvent) => any; + onunload: (this: SVGSVGElement, ev: Event) => any; + onzoom: (this: SVGSVGElement, ev: SVGZoomEvent) => any; + readonly pixelUnitToMillimeterX: number; + readonly pixelUnitToMillimeterY: number; + readonly screenPixelToMillimeterX: number; + readonly screenPixelToMillimeterY: number; + readonly viewport: SVGRect; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly 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): NodeListOf; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeListOf; + pauseAnimations(): void; + setCurrentTime(seconds: number): void; + suspendRedraw(maxWaitMilliseconds: number): number; + unpauseAnimations(): void; + unsuspendRedraw(suspendHandleID: number): void; + unsuspendRedrawAll(): void; + addEventListener(type: K, listener: (this: SVGSVGElement, ev: SVGSVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface SVGScriptElement extends SVGElement, SVGURIReference { + type: string; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface SVGStopElement extends SVGElement { + readonly offset: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface SVGStringList { + readonly 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 { + disabled: boolean; + media: string; + title: string; + type: string; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface SVGTextContentElement extends SVGGraphicsElement { + readonly lengthAdjust: SVGAnimatedEnumeration; + readonly 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; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; +} + +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + readonly method: SVGAnimatedEnumeration; + readonly spacing: SVGAnimatedEnumeration; + readonly startOffset: SVGAnimatedLength; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + readonly dx: SVGAnimatedLengthList; + readonly dy: SVGAnimatedLengthList; + readonly rotate: SVGAnimatedNumberList; + readonly x: SVGAnimatedLengthList; + readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface SVGTransform { + readonly angle: number; + readonly matrix: SVGMatrix; + readonly 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; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; +} + +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; +} + +interface SVGTransformList { + readonly 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 { + readonly SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + readonly SVG_UNIT_TYPE_UNKNOWN: number; + readonly SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { + readonly animatedInstanceRoot: SVGElementInstance; + readonly height: SVGAnimatedLength; + readonly instanceRoot: SVGElementInstance; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { + readonly viewTarget: SVGStringList; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface SVGZoomAndPan { + readonly zoomAndPan: number; +} + +declare var SVGZoomAndPan: { + readonly SVG_ZOOMANDPAN_DISABLE: number; + readonly SVG_ZOOMANDPAN_MAGNIFY: number; + readonly SVG_ZOOMANDPAN_UNKNOWN: number; +} + +interface SVGZoomEvent extends UIEvent { + readonly newScale: number; + readonly newTranslate: SVGPoint; + readonly previousScale: number; + readonly previousTranslate: SVGPoint; + readonly zoomRectScreen: SVGRect; +} + +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: ScopedCredentialType; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + +interface ScreenEventMap { + "MSOrientationChange": Event; +} + +interface Screen extends EventTarget { + readonly availHeight: number; + readonly availWidth: number; + bufferDepth: number; + readonly colorDepth: number; + readonly deviceXDPI: number; + readonly deviceYDPI: number; + readonly fontSmoothingEnabled: boolean; + readonly height: number; + readonly logicalXDPI: number; + readonly logicalYDPI: number; + readonly msOrientation: string; + onmsorientationchange: (this: Screen, ev: Event) => any; + readonly pixelDepth: number; + readonly systemXDPI: number; + readonly systemYDPI: number; + readonly width: number; + msLockOrientation(orientations: string | string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface ScriptNotifyEvent extends Event { + readonly callingUri: string; + readonly value: string; +} + +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface ScriptProcessorNodeEventMap { + "audioprocess": AudioProcessingEvent; +} + +interface ScriptProcessorNode extends AudioNode { + readonly bufferSize: number; + onaudioprocess: (this: ScriptProcessorNode, ev: AudioProcessingEvent) => any; + addEventListener(type: K, listener: (this: ScriptProcessorNode, ev: ScriptProcessorNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ScriptProcessorNode: { + prototype: ScriptProcessorNode; + new(): ScriptProcessorNode; +} + +interface Selection { + readonly anchorNode: Node; + readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; + readonly focusNode: Node; + readonly focusOffset: number; + readonly isCollapsed: boolean; + readonly rangeCount: number; + readonly 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; + setPosition(parentNode: Node, offset: number): void; + toString(): string; +} + +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: ServiceWorkerState; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + +interface SourceBuffer extends EventTarget { + appendWindowEnd: number; + appendWindowStart: number; + readonly audioTracks: AudioTrackList; + readonly buffered: TimeRanges; + mode: AppendMode; + timestampOffset: number; + readonly updating: boolean; + readonly 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 { + readonly length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + +interface StereoPannerNode extends AudioNode { + readonly pan: AudioParam; +} + +declare var StereoPannerNode: { + prototype: StereoPannerNode; + new(): StereoPannerNode; +} + +interface Storage { + readonly length: number; + clear(): void; + getItem(key: string): string | null; + key(index: number): string | null; + 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 { + readonly url: string; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; +} + +declare var StorageEvent: { + prototype: StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; +} + +interface StyleMedia { + readonly type: string; + matchMedium(mediaquery: string): boolean; +} + +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface StyleSheet { + disabled: boolean; + readonly href: string; + readonly media: MediaList; + readonly ownerNode: Node; + readonly parentStyleSheet: StyleSheet; + readonly title: string; + readonly type: string; +} + +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface StyleSheetList { + readonly length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} + +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface StyleSheetPageList { + readonly length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} + +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface SubtleCrypto { + decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike; + deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike; + deriveKey(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike; + digest(algorithm: AlgorithmIdentifier, data: BufferSource): PromiseLike; + encrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike; + exportKey(format: "jwk", key: CryptoKey): PromiseLike; + exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): PromiseLike; + exportKey(format: string, key: CryptoKey): PromiseLike; + generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): PromiseLike; + generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams | DhKeyGenParams, extractable: boolean, keyUsages: string[]): PromiseLike; + generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike; + importKey(format: "jwk", keyData: JsonWebKey, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + importKey(format: string, keyData: JsonWebKey | BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: BufferSource): PromiseLike; + unwrapKey(format: string, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier, unwrappedKeyAlgorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike; + verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: BufferSource, data: BufferSource): PromiseLike; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier): PromiseLike; +} + +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + +interface Text extends CharacterData { + readonly wholeText: string; + readonly assignedSlot: HTMLSlotElement | null; + splitText(offset: number): Text; +} + +declare var Text: { + prototype: Text; + new(data?: string): Text; +} + +interface TextEvent extends UIEvent { + readonly data: string; + readonly inputMethod: number; + readonly locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; +} + +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; +} + +interface TextMetrics { + readonly width: number; +} + +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface TextTrackEventMap { + "cuechange": Event; + "error": Event; + "load": Event; +} + +interface TextTrack extends EventTarget { + readonly activeCues: TextTrackCueList; + readonly cues: TextTrackCueList; + readonly inBandMetadataTrackDispatchType: string; + readonly kind: string; + readonly label: string; + readonly language: string; + mode: any; + oncuechange: (this: TextTrack, ev: Event) => any; + onerror: (this: TextTrack, ev: Event) => any; + onload: (this: TextTrack, ev: Event) => any; + readonly readyState: number; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; + addEventListener(type: K, listener: (this: TextTrack, ev: TextTrackEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; +} + +interface TextTrackCueEventMap { + "enter": Event; + "exit": Event; +} + +interface TextTrackCue extends EventTarget { + endTime: number; + id: string; + onenter: (this: TextTrackCue, ev: Event) => any; + onexit: (this: TextTrackCue, ev: Event) => any; + pauseOnExit: boolean; + startTime: number; + text: string; + readonly track: TextTrack; + getCueAsHTML(): DocumentFragment; + addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => 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 { + readonly length: number; + getCueById(id: string): TextTrackCue; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; +} + +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface TextTrackListEventMap { + "addtrack": TrackEvent; +} + +interface TextTrackList extends EventTarget { + readonly length: number; + onaddtrack: ((this: TextTrackList, ev: TrackEvent) => any) | null; + item(index: number): TextTrack; + addEventListener(type: K, listener: (this: TextTrackList, ev: TextTrackListEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: TextTrack; +} + +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface TimeRanges { + readonly length: number; + end(index: number): number; + start(index: number): number; +} + +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface Touch { + readonly clientX: number; + readonly clientY: number; + readonly identifier: number; + readonly pageX: number; + readonly pageY: number; + readonly screenX: number; + readonly screenY: number; + readonly target: EventTarget; +} + +declare var Touch: { + prototype: Touch; + new(): Touch; +} + +interface TouchEvent extends UIEvent { + readonly altKey: boolean; + readonly changedTouches: TouchList; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly keyCode: number; + readonly metaKey: boolean; + readonly shiftKey: boolean; + readonly targetTouches: TouchList; + readonly touches: TouchList; + readonly which: number; +} + +declare var TouchEvent: { + prototype: TouchEvent; + new(type: string, touchEventInit?: TouchEventInit): TouchEvent; +} + +interface TouchList { + readonly length: number; + item(index: number): Touch | null; + [index: number]: Touch; +} + +declare var TouchList: { + prototype: TouchList; + new(): TouchList; +} + +interface TrackEvent extends Event { + readonly track: VideoTrack | AudioTrack | TextTrack | null; +} + +declare var TrackEvent: { + prototype: TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; +} + +interface TransitionEvent extends Event { + readonly elapsedTime: number; + readonly propertyName: string; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +declare var TransitionEvent: { + prototype: TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; +} + +interface TreeWalker { + currentNode: Node; + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly 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 { + readonly detail: number; + readonly view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} + +declare var UIEvent: { + prototype: UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; +} + +interface URL { + hash: string; + host: string; + hostname: string; + href: string; + readonly origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + username: string; + readonly searchParams: URLSearchParams; + toString(): string; +} + +declare var URL: { + prototype: URL; + new(url: string, base?: string): URL; + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { + readonly mediaType: string; +} + +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface ValidityState { + readonly badInput: boolean; + readonly customError: boolean; + readonly patternMismatch: boolean; + readonly rangeOverflow: boolean; + readonly rangeUnderflow: boolean; + readonly stepMismatch: boolean; + readonly tooLong: boolean; + readonly typeMismatch: boolean; + readonly valid: boolean; + readonly valueMissing: boolean; +} + +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface VideoPlaybackQuality { + readonly corruptedVideoFrames: number; + readonly creationTime: number; + readonly droppedVideoFrames: number; + readonly totalFrameDelay: number; + readonly totalVideoFrames: number; +} + +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface VideoTrack { + readonly id: string; + kind: string; + readonly label: string; + language: string; + selected: boolean; + readonly sourceBuffer: SourceBuffer; +} + +declare var VideoTrack: { + prototype: VideoTrack; + new(): VideoTrack; +} + +interface VideoTrackListEventMap { + "addtrack": TrackEvent; + "change": Event; + "removetrack": TrackEvent; +} + +interface VideoTrackList extends EventTarget { + readonly length: number; + onaddtrack: (this: VideoTrackList, ev: TrackEvent) => any; + onchange: (this: VideoTrackList, ev: Event) => any; + onremovetrack: (this: VideoTrackList, ev: TrackEvent) => any; + readonly selectedIndex: number; + getTrackById(id: string): VideoTrack | null; + item(index: number): VideoTrack; + addEventListener(type: K, listener: (this: VideoTrackList, ev: VideoTrackListEventMap[K]) => 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 { + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WEBGL_debug_renderer_info { + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; +} + +declare var WEBGL_debug_renderer_info: { + prototype: WEBGL_debug_renderer_info; + new(): WEBGL_debug_renderer_info; + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; +} + +interface WEBGL_depth_texture { + readonly UNSIGNED_INT_24_8_WEBGL: number; +} + +declare var WEBGL_depth_texture: { + prototype: WEBGL_depth_texture; + new(): WEBGL_depth_texture; + readonly UNSIGNED_INT_24_8_WEBGL: number; +} + +interface WaveShaperNode extends AudioNode { + curve: Float32Array | null; + oversample: OverSampleType; +} + +declare var WaveShaperNode: { + prototype: WaveShaperNode; + new(): WaveShaperNode; +} + +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + +interface WebGLActiveInfo { + readonly name: string; + readonly size: number; + readonly type: number; +} + +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WebGLBuffer extends WebGLObject { +} + +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLContextEvent extends Event { + readonly statusMessage: string; +} + +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): 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 { + readonly canvas: HTMLCanvasElement; + readonly drawingBufferHeight: number; + readonly drawingBufferWidth: number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram | null, shader: WebGLShader | null): void; + bindAttribLocation(program: WebGLProgram | null, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer | null): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer | null): void; + bindTexture(target: number, texture: WebGLTexture | null): 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 | null): 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 | null; + createFramebuffer(): WebGLFramebuffer | null; + createProgram(): WebGLProgram | null; + createRenderbuffer(): WebGLRenderbuffer | null; + createShader(type: number): WebGLShader | null; + createTexture(): WebGLTexture | null; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer | null): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer | null): void; + deleteProgram(program: WebGLProgram | null): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer | null): void; + deleteShader(shader: WebGLShader | null): void; + deleteTexture(texture: WebGLTexture | null): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram | null, shader: WebGLShader | null): 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 | null): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture | null, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getActiveUniform(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getAttachedShaders(program: WebGLProgram | null): WebGLShader[] | null; + getAttribLocation(program: WebGLProgram | null, 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 | null): string | null; + getProgramParameter(program: WebGLProgram | null, pname: number): any; + getRenderbufferParameter(target: number, pname: number): any; + getShaderInfoLog(shader: WebGLShader | null): string | null; + getShaderParameter(shader: WebGLShader | null, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat | null; + getShaderSource(shader: WebGLShader | null): string | null; + getSupportedExtensions(): string[] | null; + getTexParameter(target: number, pname: number): any; + getUniform(program: WebGLProgram | null, location: WebGLUniformLocation | null): any; + getUniformLocation(program: WebGLProgram | null, name: string): WebGLUniformLocation | null; + getVertexAttrib(index: number, pname: number): any; + getVertexAttribOffset(index: number, pname: number): number; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer | null): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer | null): boolean; + isProgram(program: WebGLProgram | null): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer | null): boolean; + isShader(shader: WebGLShader | null): boolean; + isTexture(texture: WebGLTexture | null): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram | null): void; + pixelStorei(pname: number, param: number | boolean): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): 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 | null, 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 | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): 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 | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + uniform1f(location: WebGLUniformLocation | null, x: number): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform1i(location: WebGLUniformLocation | null, x: number): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform2f(location: WebGLUniformLocation | null, x: number, y: number): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform2i(location: WebGLUniformLocation | null, x: number, y: number): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform3f(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform3i(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform4f(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform4i(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + useProgram(program: WebGLProgram | null): void; + validateProgram(program: WebGLProgram | null): void; + vertexAttrib1f(indx: number, x: number): void; + vertexAttrib1fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib2f(indx: number, x: number, y: number): void; + vertexAttrib2fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + vertexAttrib3fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + vertexAttrib4fv(indx: number, values: Float32Array | number[]): 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; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; +} + +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; +} + +interface WebGLShader extends WebGLObject { +} + +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface WebGLShaderPrecisionFormat { + readonly precision: number; + readonly rangeMax: number; + readonly 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 WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + +interface WebKitPoint { + x: number; + y: number; +} + +declare var WebKitPoint: { + prototype: WebKitPoint; + new(x?: number, y?: number): WebKitPoint; +} + +interface WebSocketEventMap { + "close": CloseEvent; + "error": Event; + "message": MessageEvent; + "open": Event; +} + +interface WebSocket extends EventTarget { + binaryType: string; + readonly bufferedAmount: number; + readonly extensions: string; + onclose: (this: WebSocket, ev: CloseEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; + onmessage: (this: WebSocket, ev: MessageEvent) => any; + onopen: (this: WebSocket, ev: Event) => any; + readonly protocol: string; + readonly readyState: number; + readonly url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; + addEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; +} + +interface WheelEvent extends MouseEvent { + readonly deltaMode: number; + readonly deltaX: number; + readonly deltaY: number; + readonly deltaZ: number; + readonly wheelDelta: number; + readonly wheelDeltaX: number; + readonly wheelDeltaY: 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; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; +} + +declare var WheelEvent: { + prototype: WheelEvent; + new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; +} + +interface WindowEventMap extends GlobalEventHandlersEventMap { + "abort": UIEvent; + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "compassneedscalibration": Event; + "contextmenu": PointerEvent; + "dblclick": MouseEvent; + "devicelight": DeviceLightEvent; + "devicemotion": DeviceMotionEvent; + "deviceorientation": DeviceOrientationEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "message": MessageEvent; + "mousedown": MouseEvent; + "mouseenter": MouseEvent; + "mouseleave": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSInertiaStart": MSGestureEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "pause": Event; + "play": Event; + "playing": Event; + "popstate": PopStateEvent; + "progress": ProgressEvent; + "ratechange": Event; + "readystatechange": ProgressEvent; + "reset": Event; + "resize": UIEvent; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "stalled": Event; + "storage": StorageEvent; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "unload": Event; + "volumechange": Event; + "waiting": Event; +} + +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { + readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; + readonly clientInformation: Navigator; + readonly closed: boolean; + readonly crypto: Crypto; + defaultStatus: string; + readonly devicePixelRatio: number; + readonly doNotTrack: string; + readonly document: Document; + event: Event | undefined; + readonly external: External; + readonly frameElement: Element; + readonly frames: Window; + readonly history: History; + readonly innerHeight: number; + readonly innerWidth: number; + readonly isSecureContext: boolean; + readonly length: number; + readonly location: Location; + readonly locationbar: BarProp; + readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; + readonly msCredentials: MSCredentials; + name: string; + readonly navigator: Navigator; + offscreenBuffering: string | boolean; + onabort: (this: Window, ev: UIEvent) => any; + onafterprint: (this: Window, ev: Event) => any; + onbeforeprint: (this: Window, ev: Event) => any; + onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; + onblur: (this: Window, ev: FocusEvent) => any; + oncanplay: (this: Window, ev: Event) => any; + oncanplaythrough: (this: Window, ev: Event) => any; + onchange: (this: Window, ev: Event) => any; + onclick: (this: Window, ev: MouseEvent) => any; + oncompassneedscalibration: (this: Window, ev: Event) => any; + oncontextmenu: (this: Window, ev: PointerEvent) => any; + ondblclick: (this: Window, ev: MouseEvent) => any; + ondevicelight: (this: Window, ev: DeviceLightEvent) => any; + ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; + ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; + ondrag: (this: Window, ev: DragEvent) => any; + ondragend: (this: Window, ev: DragEvent) => any; + ondragenter: (this: Window, ev: DragEvent) => any; + ondragleave: (this: Window, ev: DragEvent) => any; + ondragover: (this: Window, ev: DragEvent) => any; + ondragstart: (this: Window, ev: DragEvent) => any; + ondrop: (this: Window, ev: DragEvent) => any; + ondurationchange: (this: Window, ev: Event) => any; + onemptied: (this: Window, ev: Event) => any; + onended: (this: Window, ev: MediaStreamErrorEvent) => any; + onerror: ErrorEventHandler; + onfocus: (this: Window, ev: FocusEvent) => any; + onhashchange: (this: Window, ev: HashChangeEvent) => any; + oninput: (this: Window, ev: Event) => any; + oninvalid: (this: Window, ev: Event) => any; + onkeydown: (this: Window, ev: KeyboardEvent) => any; + onkeypress: (this: Window, ev: KeyboardEvent) => any; + onkeyup: (this: Window, ev: KeyboardEvent) => any; + onload: (this: Window, ev: Event) => any; + onloadeddata: (this: Window, ev: Event) => any; + onloadedmetadata: (this: Window, ev: Event) => any; + onloadstart: (this: Window, ev: Event) => any; + onmessage: (this: Window, ev: MessageEvent) => any; + onmousedown: (this: Window, ev: MouseEvent) => any; + onmouseenter: (this: Window, ev: MouseEvent) => any; + onmouseleave: (this: Window, ev: MouseEvent) => any; + onmousemove: (this: Window, ev: MouseEvent) => any; + onmouseout: (this: Window, ev: MouseEvent) => any; + onmouseover: (this: Window, ev: MouseEvent) => any; + onmouseup: (this: Window, ev: MouseEvent) => any; + onmousewheel: (this: Window, ev: WheelEvent) => any; + onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; + onmsgestureend: (this: Window, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; + onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; + onmspointercancel: (this: Window, ev: MSPointerEvent) => any; + onmspointerdown: (this: Window, ev: MSPointerEvent) => any; + onmspointerenter: (this: Window, ev: MSPointerEvent) => any; + onmspointerleave: (this: Window, ev: MSPointerEvent) => any; + onmspointermove: (this: Window, ev: MSPointerEvent) => any; + onmspointerout: (this: Window, ev: MSPointerEvent) => any; + onmspointerover: (this: Window, ev: MSPointerEvent) => any; + onmspointerup: (this: Window, ev: MSPointerEvent) => any; + onoffline: (this: Window, ev: Event) => any; + ononline: (this: Window, ev: Event) => any; + onorientationchange: (this: Window, ev: Event) => any; + onpagehide: (this: Window, ev: PageTransitionEvent) => any; + onpageshow: (this: Window, ev: PageTransitionEvent) => any; + onpause: (this: Window, ev: Event) => any; + onplay: (this: Window, ev: Event) => any; + onplaying: (this: Window, ev: Event) => any; + onpopstate: (this: Window, ev: PopStateEvent) => any; + onprogress: (this: Window, ev: ProgressEvent) => any; + onratechange: (this: Window, ev: Event) => any; + onreadystatechange: (this: Window, ev: ProgressEvent) => any; + onreset: (this: Window, ev: Event) => any; + onresize: (this: Window, ev: UIEvent) => any; + onscroll: (this: Window, ev: UIEvent) => any; + onseeked: (this: Window, ev: Event) => any; + onseeking: (this: Window, ev: Event) => any; + onselect: (this: Window, ev: UIEvent) => any; + onstalled: (this: Window, ev: Event) => any; + onstorage: (this: Window, ev: StorageEvent) => any; + onsubmit: (this: Window, ev: Event) => any; + onsuspend: (this: Window, ev: Event) => any; + ontimeupdate: (this: Window, ev: Event) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onunload: (this: Window, ev: Event) => any; + onvolumechange: (this: Window, ev: Event) => any; + onwaiting: (this: Window, ev: Event) => any; + opener: any; + orientation: string | number; + readonly outerHeight: number; + readonly outerWidth: number; + readonly pageXOffset: number; + readonly pageYOffset: number; + readonly parent: Window; + readonly performance: Performance; + readonly personalbar: BarProp; + readonly screen: Screen; + readonly screenLeft: number; + readonly screenTop: number; + readonly screenX: number; + readonly screenY: number; + readonly scrollX: number; + readonly scrollY: number; + readonly scrollbars: BarProp; + readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; + status: string; + readonly statusbar: BarProp; + readonly styleMedia: StyleMedia; + readonly toolbar: BarProp; + readonly top: Window; + readonly window: Window; + URL: typeof URL; + URLSearchParams: typeof URLSearchParams; + Blob: typeof Blob; + customElements: CustomElementRegistry; + alert(message?: any): void; + blur(): void; + cancelAnimationFrame(handle: number): void; + captureEvents(): void; + close(): void; + confirm(message?: string): boolean; + departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; + 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; + msWriteProfilerMark(profilerMarkName: string): void; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + postMessage(message: any, targetOrigin: string, transfer?: any[]): void; + print(): void; + prompt(message?: string, _default?: string): string | null; + 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; + stop(): void; + webkitCancelAnimationFrame(handle: number): void; + webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; + webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; + webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; + scroll(options?: ScrollToOptions): void; + scrollTo(options?: ScrollToOptions): void; + scrollBy(options?: ScrollToOptions): void; + addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Window: { + prototype: Window; + new(): Window; +} + +interface WorkerEventMap extends AbstractWorkerEventMap { + "message": MessageEvent; +} + +interface Worker extends EventTarget, AbstractWorker { + onmessage: (this: Worker, ev: MessageEvent) => any; + postMessage(message: any, transfer?: any[]): void; + terminate(): void; + addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => 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 { + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap { + "readystatechange": Event; +} + +interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { + onreadystatechange: (this: XMLHttpRequest, ev: Event) => any; + readonly readyState: number; + readonly response: any; + readonly responseText: string; + responseType: XMLHttpRequestResponseType; + readonly responseURL: string; + readonly responseXML: Document | null; + readonly status: number; + readonly statusText: string; + timeout: number; + readonly upload: XMLHttpRequestUpload; + withCredentials: boolean; + msCaching?: string; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string | null; + 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; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; + addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; +} + +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + 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 | null, type: number, result: XPathResult | null): XPathResult; +} + +declare var XPathEvaluator: { + prototype: XPathEvaluator; + new(): XPathEvaluator; +} + +interface XPathExpression { + evaluate(contextNode: Node, type: number, result: XPathResult | null): XPathResult; +} + +declare var XPathExpression: { + prototype: XPathExpression; + new(): XPathExpression; +} + +interface XPathNSResolver { + lookupNamespaceURI(prefix: string): string; +} + +declare var XPathNSResolver: { + prototype: XPathNSResolver; + new(): XPathNSResolver; +} + +interface XPathResult { + readonly booleanValue: boolean; + readonly invalidIteratorState: boolean; + readonly numberValue: number; + readonly resultType: number; + readonly singleNodeValue: Node; + readonly snapshotLength: number; + readonly stringValue: string; + iterateNext(): Node; + snapshotItem(index: number): Node; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +declare var XPathResult: { + prototype: XPathResult; + new(): XPathResult; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly 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 webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + +interface AbstractWorkerEventMap { + "error": ErrorEvent; +} + +interface AbstractWorker { + onerror: (this: AbstractWorker, ev: ErrorEvent) => any; + addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; + formData(): Promise; +} + +interface CanvasPathMethods { + 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; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + closePath(): void; + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, w: number, h: number): void; +} + +interface ChildNode { + remove(): void; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface DocumentEvent { + createEvent(eventInterface:"AnimationEvent"): AnimationEvent; + createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; + createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; + createEvent(eventInterface:"CloseEvent"): CloseEvent; + createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; + createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; + 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:"FocusNavigationEvent"): FocusNavigationEvent; + createEvent(eventInterface:"GamepadEvent"): GamepadEvent; + createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; + createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface:"KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface:"ListeningStateChangedEvent"): ListeningStateChangedEvent; + 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:"MediaEncryptedEvent"): MediaEncryptedEvent; + createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; + createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; + createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; + createEvent(eventInterface:"MessageEvent"): MessageEvent; + createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; + 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:"OverflowEvent"): OverflowEvent; + createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; + createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; + createEvent(eventInterface:"PointerEvent"): PointerEvent; + createEvent(eventInterface:"PopStateEvent"): PopStateEvent; + createEvent(eventInterface:"ProgressEvent"): ProgressEvent; + createEvent(eventInterface:"RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent; + createEvent(eventInterface:"RTCDtlsTransportStateChangedEvent"): RTCDtlsTransportStateChangedEvent; + createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; + createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; + createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; + createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; + createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; + 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 { + readonly childElementCount: number; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface GlobalEventHandlersEventMap { + "pointercancel": PointerEvent; + "pointerdown": PointerEvent; + "pointerenter": PointerEvent; + "pointerleave": PointerEvent; + "pointermove": PointerEvent; + "pointerout": PointerEvent; + "pointerover": PointerEvent; + "pointerup": PointerEvent; + "wheel": WheelEvent; +} + +interface GlobalEventHandlers { + onpointercancel: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerdown: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerenter: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerleave: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointermove: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerout: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerover: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerup: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onwheel: (this: GlobalEventHandlers, ev: WheelEvent) => any; + addEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + +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 { + readonly indexedDB: IDBFactory; +} + +interface LinkStyle { + readonly sheet: StyleSheet; +} + +interface MSBaseReaderEventMap { + "abort": Event; + "error": ErrorEvent; + "load": Event; + "loadend": ProgressEvent; + "loadstart": Event; + "progress": ProgressEvent; +} + +interface MSBaseReader { + onabort: (this: MSBaseReader, ev: Event) => any; + onerror: (this: MSBaseReader, ev: ErrorEvent) => any; + onload: (this: MSBaseReader, ev: Event) => any; + onloadend: (this: MSBaseReader, ev: ProgressEvent) => any; + onloadstart: (this: MSBaseReader, ev: Event) => any; + onprogress: (this: MSBaseReader, ev: ProgressEvent) => any; + readonly readyState: number; + readonly result: any; + abort(): void; + readonly DONE: number; + readonly EMPTY: number; + readonly LOADING: number; + addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => 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 NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + +interface NavigatorContentUtils { +} + +interface NavigatorGeolocation { + readonly geolocation: Geolocation; +} + +interface NavigatorID { + readonly appCodeName: string; + readonly appName: string; + readonly appVersion: string; + readonly platform: string; + readonly product: string; + readonly productSub: string; + readonly userAgent: string; + readonly vendor: string; + readonly vendorSub: string; +} + +interface NavigatorOnLine { + readonly onLine: boolean; +} + +interface NavigatorStorageUtils { +} + +interface NavigatorUserMedia { + readonly mediaDevices: MediaDevices; + getUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; +} + +interface NodeSelector { + querySelector(selectors: K): ElementTagNameMap[K] | null; + querySelector(selectors: string): Element | null; + querySelectorAll(selectors: K): ElementListTagNameMap[K]; + querySelectorAll(selectors: string): NodeListOf; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface SVGAnimatedPoints { + readonly animatedPoints: SVGPointList; + readonly points: SVGPointList; +} + +interface SVGFilterPrimitiveStandardAttributes { + readonly height: SVGAnimatedLength; + readonly result: SVGAnimatedString; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; +} + +interface SVGFitToViewBox { + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly viewBox: SVGAnimatedRect; +} + +interface SVGTests { + readonly requiredExtensions: SVGStringList; + readonly requiredFeatures: SVGStringList; + readonly systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface SVGURIReference { + readonly href: SVGAnimatedString; +} + +interface WindowBase64 { + atob(encodedString: string): string; + btoa(rawString: string): string; +} + +interface WindowConsole { + readonly console: Console; +} + +interface WindowLocalStorage { + readonly localStorage: Storage; +} + +interface WindowSessionStorage { + readonly sessionStorage: Storage; +} + +interface WindowTimers extends Object, WindowTimersExtension { + clearInterval(handle: number): void; + clearTimeout(handle: number): void; + setInterval(handler: (...args: any[]) => void, timeout: number): number; + setInterval(handler: any, timeout?: any, ...args: any[]): number; + setTimeout(handler: (...args: any[]) => void, timeout: number): number; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; +} + +interface WindowTimersExtension { + clearImmediate(handle: number): void; + setImmediate(handler: (...args: any[]) => void): number; + setImmediate(handler: any, ...args: any[]): number; +} + +interface XMLHttpRequestEventTargetEventMap { + "abort": Event; + "error": ErrorEvent; + "load": Event; + "loadend": ProgressEvent; + "loadstart": Event; + "progress": ProgressEvent; + "timeout": ProgressEvent; +} + +interface XMLHttpRequestEventTarget { + onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + +interface Canvas2DContextAttributes { + alpha?: boolean; + willReadFrequently?: boolean; + storage?: boolean; + [attribute: string]: boolean | string | undefined; +} + +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface HTMLCollectionOf extends HTMLCollection { + item(index: number): T; + namedItem(name: string): T; + [index: number]: T; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + +interface EventListenerObject { + handleEvent(evt: Event): void; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface ScrollOptions { + behavior?: ScrollBehavior; +} + +interface ScrollToOptions extends ScrollOptions { + left?: number; + top?: number; +} + +interface ScrollIntoViewOptions extends ScrollOptions { + block?: ScrollLogicalPosition; + inline?: ScrollLogicalPosition; +} + +interface ClipboardEventInit extends EventInit { + data?: string; + dataType?: string; +} + +interface IDBArrayKey extends Array { +} + +interface RsaKeyGenParams extends Algorithm { + modulusLength: number; + publicExponent: Uint8Array; +} + +interface RsaHashedKeyGenParams extends RsaKeyGenParams { + hash: AlgorithmIdentifier; +} + +interface RsaKeyAlgorithm extends KeyAlgorithm { + modulusLength: number; + publicExponent: Uint8Array; +} + +interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm { + hash: AlgorithmIdentifier; +} + +interface RsaHashedImportParams { + hash: AlgorithmIdentifier; +} + +interface RsaPssParams { + saltLength: number; +} + +interface RsaOaepParams extends Algorithm { + label?: BufferSource; +} + +interface EcdsaParams extends Algorithm { + hash: AlgorithmIdentifier; +} + +interface EcKeyGenParams extends Algorithm { + namedCurve: string; +} + +interface EcKeyAlgorithm extends KeyAlgorithm { + typedCurve: string; +} + +interface EcKeyImportParams { + namedCurve: string; +} + +interface EcdhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} + +interface AesCtrParams extends Algorithm { + counter: BufferSource; + length: number; +} + +interface AesKeyAlgorithm extends KeyAlgorithm { + length: number; +} + +interface AesKeyGenParams extends Algorithm { + length: number; +} + +interface AesDerivedKeyParams extends Algorithm { + length: number; +} + +interface AesCbcParams extends Algorithm { + iv: BufferSource; +} + +interface AesCmacParams extends Algorithm { + length: number; +} + +interface AesGcmParams extends Algorithm { + iv: BufferSource; + additionalData?: BufferSource; + tagLength?: number; +} + +interface AesCfbParams extends Algorithm { + iv: BufferSource; +} + +interface HmacImportParams extends Algorithm { + hash?: AlgorithmIdentifier; + length?: number; +} + +interface HmacKeyAlgorithm extends KeyAlgorithm { + hash: AlgorithmIdentifier; + length: number; +} + +interface HmacKeyGenParams extends Algorithm { + hash: AlgorithmIdentifier; + length?: number; +} + +interface DhKeyGenParams extends Algorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface DhKeyAlgorithm extends KeyAlgorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface DhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} + +interface DhImportKeyParams extends Algorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface ConcatParams extends Algorithm { + hash?: AlgorithmIdentifier; + algorithmId: Uint8Array; + partyUInfo: Uint8Array; + partyVInfo: Uint8Array; + publicInfo?: Uint8Array; + privateInfo?: Uint8Array; +} + +interface HkdfCtrParams extends Algorithm { + hash: AlgorithmIdentifier; + label: BufferSource; + context: BufferSource; +} + +interface Pbkdf2Params extends Algorithm { + salt: BufferSource; + iterations: number; + hash: AlgorithmIdentifier; +} + +interface RsaOtherPrimesInfo { + r: string; + d: string; + t: string; +} + +interface JsonWebKey { + kty: string; + use?: string; + key_ops?: string[]; + alg?: string; + kid?: string; + x5u?: string; + x5c?: string; + x5t?: string; + ext?: boolean; + crv?: string; + x?: string; + y?: string; + d?: string; + n?: string; + e?: string; + p?: string; + q?: string; + dp?: string; + dq?: string; + qi?: string; + oth?: RsaOtherPrimesInfo[]; + k?: string; +} + +interface ParentNode { + readonly children: HTMLCollection; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly childElementCount: number; +} + +interface DocumentOrShadowRoot { + readonly activeElement: Element | null; + readonly stylesheets: StyleSheetList; + getSelection(): Selection | null; + elementFromPoint(x: number, y: number): Element | null; + elementsFromPoint(x: number, y: number): Element[]; +} + +interface ShadowRoot extends DocumentOrShadowRoot, DocumentFragment { + readonly host: Element; + innerHTML: string; +} + +interface ShadowRootInit { + mode: 'open'|'closed'; + delegatesFocus?: boolean; +} + +interface HTMLSlotElement extends HTMLElement { + name: string; + assignedNodes(options?: AssignedNodesOptions): Node[]; +} + +interface AssignedNodesOptions { + flatten?: boolean; +} + +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + +interface TouchEventInit extends EventModifierInit { + touches?: Touch[]; + targetTouches?: Touch[]; + changedTouches?: Touch[]; +} + +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 VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} +interface FunctionStringCallback { + (data: string): void; +} +interface NavigatorUserMediaSuccessCallback { + (stream: MediaStream): void; +} +interface NavigatorUserMediaErrorCallback { + (error: MediaStreamError): void; +} +interface ForEachCallback { + (keyId: any, status: MediaKeyStatus): void; +} +interface NotificationPermissionCallback { + (permission: NotificationPermission): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} +interface HTMLElementTagNameMap { + "a": HTMLAnchorElement; + "applet": HTMLAppletElement; + "area": HTMLAreaElement; + "audio": HTMLAudioElement; + "base": HTMLBaseElement; + "basefont": HTMLBaseFontElement; + "blockquote": HTMLQuoteElement; + "body": HTMLBodyElement; + "br": HTMLBRElement; + "button": HTMLButtonElement; + "canvas": HTMLCanvasElement; + "caption": HTMLTableCaptionElement; + "col": HTMLTableColElement; + "colgroup": HTMLTableColElement; + "data": HTMLDataElement; + "datalist": HTMLDataListElement; + "del": HTMLModElement; + "dir": HTMLDirectoryElement; + "div": HTMLDivElement; + "dl": HTMLDListElement; + "embed": HTMLEmbedElement; + "fieldset": HTMLFieldSetElement; + "font": HTMLFontElement; + "form": HTMLFormElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "h1": HTMLHeadingElement; + "h2": HTMLHeadingElement; + "h3": HTMLHeadingElement; + "h4": HTMLHeadingElement; + "h5": HTMLHeadingElement; + "h6": HTMLHeadingElement; + "head": HTMLHeadElement; + "hr": HTMLHRElement; + "html": HTMLHtmlElement; + "iframe": HTMLIFrameElement; + "img": HTMLImageElement; + "input": HTMLInputElement; + "ins": HTMLModElement; + "isindex": HTMLUnknownElement; + "label": HTMLLabelElement; + "legend": HTMLLegendElement; + "li": HTMLLIElement; + "link": HTMLLinkElement; + "listing": HTMLPreElement; + "map": HTMLMapElement; + "marquee": HTMLMarqueeElement; + "menu": HTMLMenuElement; + "meta": HTMLMetaElement; + "meter": HTMLMeterElement; + "nextid": HTMLUnknownElement; + "object": HTMLObjectElement; + "ol": HTMLOListElement; + "optgroup": HTMLOptGroupElement; + "option": HTMLOptionElement; + "output": HTMLOutputElement; + "p": HTMLParagraphElement; + "param": HTMLParamElement; + "picture": HTMLPictureElement; + "pre": HTMLPreElement; + "progress": HTMLProgressElement; + "q": HTMLQuoteElement; + "script": HTMLScriptElement; + "select": HTMLSelectElement; + "source": HTMLSourceElement; + "span": HTMLSpanElement; + "style": HTMLStyleElement; + "table": HTMLTableElement; + "tbody": HTMLTableSectionElement; + "td": HTMLTableDataCellElement; + "template": HTMLTemplateElement; + "textarea": HTMLTextAreaElement; + "tfoot": HTMLTableSectionElement; + "th": HTMLTableHeaderCellElement; + "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; + "title": HTMLTitleElement; + "tr": HTMLTableRowElement; + "track": HTMLTrackElement; + "ul": HTMLUListElement; + "video": HTMLVideoElement; + "x-ms-webview": MSHTMLWebViewElement; + "xmp": HTMLPreElement; +} + +interface ElementTagNameMap { + "a": HTMLAnchorElement; + "abbr": HTMLElement; + "acronym": HTMLElement; + "address": HTMLElement; + "applet": HTMLAppletElement; + "area": HTMLAreaElement; + "article": HTMLElement; + "aside": HTMLElement; + "audio": HTMLAudioElement; + "b": HTMLElement; + "base": HTMLBaseElement; + "basefont": HTMLBaseFontElement; + "bdo": HTMLElement; + "big": HTMLElement; + "blockquote": HTMLQuoteElement; + "body": HTMLBodyElement; + "br": HTMLBRElement; + "button": HTMLButtonElement; + "canvas": HTMLCanvasElement; + "caption": HTMLTableCaptionElement; + "center": HTMLElement; + "circle": SVGCircleElement; + "cite": HTMLElement; + "clippath": SVGClipPathElement; + "code": HTMLElement; + "col": HTMLTableColElement; + "colgroup": HTMLTableColElement; + "data": HTMLDataElement; + "datalist": HTMLDataListElement; + "dd": HTMLElement; + "defs": SVGDefsElement; + "del": HTMLModElement; + "desc": SVGDescElement; + "dfn": HTMLElement; + "dir": HTMLDirectoryElement; + "div": HTMLDivElement; + "dl": HTMLDListElement; + "dt": HTMLElement; + "ellipse": SVGEllipseElement; + "em": HTMLElement; + "embed": HTMLEmbedElement; + "feblend": SVGFEBlendElement; + "fecolormatrix": SVGFEColorMatrixElement; + "fecomponenttransfer": SVGFEComponentTransferElement; + "fecomposite": SVGFECompositeElement; + "feconvolvematrix": SVGFEConvolveMatrixElement; + "fediffuselighting": SVGFEDiffuseLightingElement; + "fedisplacementmap": SVGFEDisplacementMapElement; + "fedistantlight": SVGFEDistantLightElement; + "feflood": SVGFEFloodElement; + "fefunca": SVGFEFuncAElement; + "fefuncb": SVGFEFuncBElement; + "fefuncg": SVGFEFuncGElement; + "fefuncr": SVGFEFuncRElement; + "fegaussianblur": SVGFEGaussianBlurElement; + "feimage": SVGFEImageElement; + "femerge": SVGFEMergeElement; + "femergenode": SVGFEMergeNodeElement; + "femorphology": SVGFEMorphologyElement; + "feoffset": SVGFEOffsetElement; + "fepointlight": SVGFEPointLightElement; + "fespecularlighting": SVGFESpecularLightingElement; + "fespotlight": SVGFESpotLightElement; + "fetile": SVGFETileElement; + "feturbulence": SVGFETurbulenceElement; + "fieldset": HTMLFieldSetElement; + "figcaption": HTMLElement; + "figure": HTMLElement; + "filter": SVGFilterElement; + "font": HTMLFontElement; + "footer": HTMLElement; + "foreignobject": SVGForeignObjectElement; + "form": HTMLFormElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "g": SVGGElement; + "h1": HTMLHeadingElement; + "h2": HTMLHeadingElement; + "h3": HTMLHeadingElement; + "h4": HTMLHeadingElement; + "h5": HTMLHeadingElement; + "h6": HTMLHeadingElement; + "head": HTMLHeadElement; + "header": HTMLElement; + "hgroup": HTMLElement; + "hr": HTMLHRElement; + "html": HTMLHtmlElement; + "i": HTMLElement; + "iframe": HTMLIFrameElement; + "image": SVGImageElement; + "img": HTMLImageElement; + "input": HTMLInputElement; + "ins": HTMLModElement; + "isindex": HTMLUnknownElement; + "kbd": HTMLElement; + "keygen": HTMLElement; + "label": HTMLLabelElement; + "legend": HTMLLegendElement; + "li": HTMLLIElement; + "line": SVGLineElement; + "lineargradient": SVGLinearGradientElement; + "link": HTMLLinkElement; + "listing": HTMLPreElement; + "map": HTMLMapElement; + "mark": HTMLElement; + "marker": SVGMarkerElement; + "marquee": HTMLMarqueeElement; + "mask": SVGMaskElement; + "menu": HTMLMenuElement; + "meta": HTMLMetaElement; + "metadata": SVGMetadataElement; + "meter": HTMLMeterElement; + "nav": HTMLElement; + "nextid": HTMLUnknownElement; + "nobr": HTMLElement; + "noframes": HTMLElement; + "noscript": HTMLElement; + "object": HTMLObjectElement; + "ol": HTMLOListElement; + "optgroup": HTMLOptGroupElement; + "option": HTMLOptionElement; + "output": HTMLOutputElement; + "p": HTMLParagraphElement; + "param": HTMLParamElement; + "path": SVGPathElement; + "pattern": SVGPatternElement; + "picture": HTMLPictureElement; + "plaintext": HTMLElement; + "polygon": SVGPolygonElement; + "polyline": SVGPolylineElement; + "pre": HTMLPreElement; + "progress": HTMLProgressElement; + "q": HTMLQuoteElement; + "radialgradient": SVGRadialGradientElement; + "rect": SVGRectElement; + "rt": HTMLElement; + "ruby": HTMLElement; + "s": HTMLElement; + "samp": HTMLElement; + "script": HTMLScriptElement; + "section": HTMLElement; + "select": HTMLSelectElement; + "small": HTMLElement; + "source": HTMLSourceElement; + "span": HTMLSpanElement; + "stop": SVGStopElement; + "strike": HTMLElement; + "strong": HTMLElement; + "style": HTMLStyleElement; + "sub": HTMLElement; + "sup": HTMLElement; + "svg": SVGSVGElement; + "switch": SVGSwitchElement; + "symbol": SVGSymbolElement; + "table": HTMLTableElement; + "tbody": HTMLTableSectionElement; + "td": HTMLTableDataCellElement; + "template": HTMLTemplateElement; + "text": SVGTextElement; + "textpath": SVGTextPathElement; + "textarea": HTMLTextAreaElement; + "tfoot": HTMLTableSectionElement; + "th": HTMLTableHeaderCellElement; + "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; + "title": HTMLTitleElement; + "tr": HTMLTableRowElement; + "track": HTMLTrackElement; + "tspan": SVGTSpanElement; + "tt": HTMLElement; + "u": HTMLElement; + "ul": HTMLUListElement; + "use": SVGUseElement; + "var": HTMLElement; + "video": HTMLVideoElement; + "view": SVGViewElement; + "wbr": HTMLElement; + "x-ms-webview": MSHTMLWebViewElement; + "xmp": HTMLPreElement; +} + +interface ElementListTagNameMap { + "a": NodeListOf; + "abbr": NodeListOf; + "acronym": NodeListOf; + "address": NodeListOf; + "applet": NodeListOf; + "area": NodeListOf; + "article": NodeListOf; + "aside": NodeListOf; + "audio": NodeListOf; + "b": NodeListOf; + "base": NodeListOf; + "basefont": NodeListOf; + "bdo": NodeListOf; + "big": NodeListOf; + "blockquote": NodeListOf; + "body": NodeListOf; + "br": NodeListOf; + "button": NodeListOf; + "canvas": NodeListOf; + "caption": NodeListOf; + "center": NodeListOf; + "circle": NodeListOf; + "cite": NodeListOf; + "clippath": NodeListOf; + "code": NodeListOf; + "col": NodeListOf; + "colgroup": NodeListOf; + "data": NodeListOf; + "datalist": NodeListOf; + "dd": NodeListOf; + "defs": NodeListOf; + "del": NodeListOf; + "desc": NodeListOf; + "dfn": NodeListOf; + "dir": NodeListOf; + "div": NodeListOf; + "dl": NodeListOf; + "dt": NodeListOf; + "ellipse": NodeListOf; + "em": NodeListOf; + "embed": NodeListOf; + "feblend": NodeListOf; + "fecolormatrix": NodeListOf; + "fecomponenttransfer": NodeListOf; + "fecomposite": NodeListOf; + "feconvolvematrix": NodeListOf; + "fediffuselighting": NodeListOf; + "fedisplacementmap": NodeListOf; + "fedistantlight": NodeListOf; + "feflood": NodeListOf; + "fefunca": NodeListOf; + "fefuncb": NodeListOf; + "fefuncg": NodeListOf; + "fefuncr": NodeListOf; + "fegaussianblur": NodeListOf; + "feimage": NodeListOf; + "femerge": NodeListOf; + "femergenode": NodeListOf; + "femorphology": NodeListOf; + "feoffset": NodeListOf; + "fepointlight": NodeListOf; + "fespecularlighting": NodeListOf; + "fespotlight": NodeListOf; + "fetile": NodeListOf; + "feturbulence": NodeListOf; + "fieldset": NodeListOf; + "figcaption": NodeListOf; + "figure": NodeListOf; + "filter": NodeListOf; + "font": NodeListOf; + "footer": NodeListOf; + "foreignobject": NodeListOf; + "form": NodeListOf; + "frame": NodeListOf; + "frameset": NodeListOf; + "g": NodeListOf; + "h1": NodeListOf; + "h2": NodeListOf; + "h3": NodeListOf; + "h4": NodeListOf; + "h5": NodeListOf; + "h6": NodeListOf; + "head": NodeListOf; + "header": NodeListOf; + "hgroup": NodeListOf; + "hr": NodeListOf; + "html": NodeListOf; + "i": NodeListOf; + "iframe": NodeListOf; + "image": NodeListOf; + "img": NodeListOf; + "input": NodeListOf; + "ins": NodeListOf; + "isindex": NodeListOf; + "kbd": NodeListOf; + "keygen": NodeListOf; + "label": NodeListOf; + "legend": NodeListOf; + "li": NodeListOf; + "line": NodeListOf; + "lineargradient": NodeListOf; + "link": NodeListOf; + "listing": NodeListOf; + "map": NodeListOf; + "mark": NodeListOf; + "marker": NodeListOf; + "marquee": NodeListOf; + "mask": NodeListOf; + "menu": NodeListOf; + "meta": NodeListOf; + "metadata": NodeListOf; + "meter": NodeListOf; + "nav": NodeListOf; + "nextid": NodeListOf; + "nobr": NodeListOf; + "noframes": NodeListOf; + "noscript": NodeListOf; + "object": NodeListOf; + "ol": NodeListOf; + "optgroup": NodeListOf; + "option": NodeListOf; + "output": NodeListOf; + "p": NodeListOf; + "param": NodeListOf; + "path": NodeListOf; + "pattern": NodeListOf; + "picture": NodeListOf; + "plaintext": NodeListOf; + "polygon": NodeListOf; + "polyline": NodeListOf; + "pre": NodeListOf; + "progress": NodeListOf; + "q": NodeListOf; + "radialgradient": NodeListOf; + "rect": NodeListOf; + "rt": NodeListOf; + "ruby": NodeListOf; + "s": NodeListOf; + "samp": NodeListOf; + "script": NodeListOf; + "section": NodeListOf; + "select": NodeListOf; + "small": NodeListOf; + "source": NodeListOf; + "span": NodeListOf; + "stop": NodeListOf; + "strike": NodeListOf; + "strong": NodeListOf; + "style": NodeListOf; + "sub": NodeListOf; + "sup": NodeListOf; + "svg": NodeListOf; + "switch": NodeListOf; + "symbol": NodeListOf; + "table": NodeListOf; + "tbody": NodeListOf; + "td": NodeListOf; + "template": NodeListOf; + "text": NodeListOf; + "textpath": NodeListOf; + "textarea": NodeListOf; + "tfoot": NodeListOf; + "th": NodeListOf; + "thead": NodeListOf; + "time": NodeListOf; + "title": NodeListOf; + "tr": NodeListOf; + "track": NodeListOf; + "tspan": NodeListOf; + "tt": NodeListOf; + "u": NodeListOf; + "ul": NodeListOf; + "use": NodeListOf; + "var": NodeListOf; + "video": NodeListOf; + "view": NodeListOf; + "wbr": NodeListOf; + "x-ms-webview": NodeListOf; + "xmp": NodeListOf; +} + +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 applicationCache: ApplicationCache; +declare var caches: CacheStorage; +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 | undefined; +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 isSecureContext: boolean; +declare var length: number; +declare var location: Location; +declare var locationbar: BarProp; +declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; +declare var msCredentials: MSCredentials; +declare const name: never; +declare var navigator: Navigator; +declare var offscreenBuffering: string | boolean; +declare var onabort: (this: Window, ev: UIEvent) => any; +declare var onafterprint: (this: Window, ev: Event) => any; +declare var onbeforeprint: (this: Window, ev: Event) => any; +declare var onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; +declare var onblur: (this: Window, ev: FocusEvent) => any; +declare var oncanplay: (this: Window, ev: Event) => any; +declare var oncanplaythrough: (this: Window, ev: Event) => any; +declare var onchange: (this: Window, ev: Event) => any; +declare var onclick: (this: Window, ev: MouseEvent) => any; +declare var oncompassneedscalibration: (this: Window, ev: Event) => any; +declare var oncontextmenu: (this: Window, ev: PointerEvent) => any; +declare var ondblclick: (this: Window, ev: MouseEvent) => any; +declare var ondevicelight: (this: Window, ev: DeviceLightEvent) => any; +declare var ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; +declare var ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; +declare var ondrag: (this: Window, ev: DragEvent) => any; +declare var ondragend: (this: Window, ev: DragEvent) => any; +declare var ondragenter: (this: Window, ev: DragEvent) => any; +declare var ondragleave: (this: Window, ev: DragEvent) => any; +declare var ondragover: (this: Window, ev: DragEvent) => any; +declare var ondragstart: (this: Window, ev: DragEvent) => any; +declare var ondrop: (this: Window, ev: DragEvent) => any; +declare var ondurationchange: (this: Window, ev: Event) => any; +declare var onemptied: (this: Window, ev: Event) => any; +declare var onended: (this: Window, ev: MediaStreamErrorEvent) => any; +declare var onerror: ErrorEventHandler; +declare var onfocus: (this: Window, ev: FocusEvent) => any; +declare var onhashchange: (this: Window, ev: HashChangeEvent) => any; +declare var oninput: (this: Window, ev: Event) => any; +declare var oninvalid: (this: Window, ev: Event) => any; +declare var onkeydown: (this: Window, ev: KeyboardEvent) => any; +declare var onkeypress: (this: Window, ev: KeyboardEvent) => any; +declare var onkeyup: (this: Window, ev: KeyboardEvent) => any; +declare var onload: (this: Window, ev: Event) => any; +declare var onloadeddata: (this: Window, ev: Event) => any; +declare var onloadedmetadata: (this: Window, ev: Event) => any; +declare var onloadstart: (this: Window, ev: Event) => any; +declare var onmessage: (this: Window, ev: MessageEvent) => any; +declare var onmousedown: (this: Window, ev: MouseEvent) => any; +declare var onmouseenter: (this: Window, ev: MouseEvent) => any; +declare var onmouseleave: (this: Window, ev: MouseEvent) => any; +declare var onmousemove: (this: Window, ev: MouseEvent) => any; +declare var onmouseout: (this: Window, ev: MouseEvent) => any; +declare var onmouseover: (this: Window, ev: MouseEvent) => any; +declare var onmouseup: (this: Window, ev: MouseEvent) => any; +declare var onmousewheel: (this: Window, ev: WheelEvent) => any; +declare var onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgestureend: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; +declare var onmspointercancel: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerdown: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerenter: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerleave: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointermove: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerout: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerover: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerup: (this: Window, ev: MSPointerEvent) => any; +declare var onoffline: (this: Window, ev: Event) => any; +declare var ononline: (this: Window, ev: Event) => any; +declare var onorientationchange: (this: Window, ev: Event) => any; +declare var onpagehide: (this: Window, ev: PageTransitionEvent) => any; +declare var onpageshow: (this: Window, ev: PageTransitionEvent) => any; +declare var onpause: (this: Window, ev: Event) => any; +declare var onplay: (this: Window, ev: Event) => any; +declare var onplaying: (this: Window, ev: Event) => any; +declare var onpopstate: (this: Window, ev: PopStateEvent) => any; +declare var onprogress: (this: Window, ev: ProgressEvent) => any; +declare var onratechange: (this: Window, ev: Event) => any; +declare var onreadystatechange: (this: Window, ev: ProgressEvent) => any; +declare var onreset: (this: Window, ev: Event) => any; +declare var onresize: (this: Window, ev: UIEvent) => any; +declare var onscroll: (this: Window, ev: UIEvent) => any; +declare var onseeked: (this: Window, ev: Event) => any; +declare var onseeking: (this: Window, ev: Event) => any; +declare var onselect: (this: Window, ev: UIEvent) => any; +declare var onstalled: (this: Window, ev: Event) => any; +declare var onstorage: (this: Window, ev: StorageEvent) => any; +declare var onsubmit: (this: Window, ev: Event) => any; +declare var onsuspend: (this: Window, ev: Event) => any; +declare var ontimeupdate: (this: Window, ev: Event) => any; +declare var ontouchcancel: (ev: TouchEvent) => any; +declare var ontouchend: (ev: TouchEvent) => any; +declare var ontouchmove: (ev: TouchEvent) => any; +declare var ontouchstart: (ev: TouchEvent) => any; +declare var onunload: (this: Window, ev: Event) => any; +declare var onvolumechange: (this: Window, ev: Event) => any; +declare var onwaiting: (this: Window, ev: Event) => any; +declare var opener: any; +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 speechSynthesis: SpeechSynthesis; +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 customElements: CustomElementRegistry; +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 departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; +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 msWriteProfilerMark(profilerMarkName: string): void; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function postMessage(message: any, targetOrigin: string, transfer?: any[]): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string | null; +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 stop(): void; +declare function webkitCancelAnimationFrame(handle: number): void; +declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; +declare function scroll(options?: ScrollToOptions): void; +declare function scrollTo(options?: ScrollToOptions): void; +declare function scrollBy(options?: ScrollToOptions): void; +declare function toString(): string; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare function clearInterval(handle: number): void; +declare function clearTimeout(handle: number): void; +declare function setInterval(handler: (...args: any[]) => void, timeout: number): number; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function setImmediate(handler: (...args: any[]) => void): number; +declare function setImmediate(handler: any, ...args: any[]): number; +declare var sessionStorage: Storage; +declare var localStorage: Storage; +declare var console: Console; +declare var onpointercancel: (this: Window, ev: PointerEvent) => any; +declare var onpointerdown: (this: Window, ev: PointerEvent) => any; +declare var onpointerenter: (this: Window, ev: PointerEvent) => any; +declare var onpointerleave: (this: Window, ev: PointerEvent) => any; +declare var onpointermove: (this: Window, ev: PointerEvent) => any; +declare var onpointerout: (this: Window, ev: PointerEvent) => any; +declare var onpointerover: (this: Window, ev: PointerEvent) => any; +declare var onpointerup: (this: Window, ev: PointerEvent) => any; +declare var onwheel: (this: Window, ev: WheelEvent) => any; +declare var indexedDB: IDBFactory; +declare function atob(encodedString: string): string; +declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +type AAGUID = string; +type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; +type ConstrainBoolean = boolean | ConstrainBooleanParameters; +type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; +type ConstrainDouble = number | ConstrainDoubleRange; +type ConstrainLong = number | ConstrainLongRange; +type CryptoOperationData = ArrayBufferView; +type GLbitfield = number; +type GLboolean = boolean; +type GLbyte = number; +type GLclampf = number; +type GLenum = number; +type GLfloat = number; +type GLint = number; +type GLintptr = number; +type GLshort = number; +type GLsizei = number; +type GLsizeiptr = number; +type GLubyte = number; +type GLuint = number; +type GLushort = number; +type HeadersInit = any; +type IDBKeyPath = string; +type KeyFormat = string; +type KeyType = string; +type KeyUsage = string; +type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; +type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; +type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; +type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; +type payloadtype = number; +type ScrollBehavior = "auto" | "instant" | "smooth"; +type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; +type IDBValidKey = number | string | Date | IDBArrayKey; +type BufferSource = ArrayBuffer | ArrayBufferView; +type MouseWheelEvent = WheelEvent; +type ScrollRestoration = "auto" | "manual"; +type FormDataEntryValue = string | File; +type AppendMode = "segments" | "sequence"; +type AudioContextState = "suspended" | "running" | "closed"; +type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; +type CanvasFillRule = "nonzero" | "evenodd"; +type ChannelCountMode = "max" | "clamped-max" | "explicit"; +type ChannelInterpretation = "speakers" | "discrete"; +type DistanceModelType = "linear" | "inverse" | "exponential"; +type ExpandGranularity = "character" | "word" | "sentence" | "textedit"; +type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad"; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type ListeningState = "inactive" | "active" | "disambiguation"; +type MSCredentialType = "FIDO_2_0"; +type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived"; +type MSIceType = "failed" | "direct" | "relay"; +type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics"; +type MSTransportType = "Embedded" | "USB" | "NFC" | "BT"; +type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny"; +type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications"; +type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; +type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request"; +type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type MediaKeysRequirement = "required" | "optional" | "not-allowed"; +type MediaStreamTrackState = "live" | "ended"; +type NavigationReason = "up" | "down" | "left" | "right"; +type NavigationType = "navigate" | "reload" | "back_forward" | "prerender"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom"; +type OverSampleType = "none" | "2x" | "4x"; +type PanningModelType = "equalpower"; +type PaymentComplete = "success" | "fail" | ""; +type PaymentShippingType = "shipping" | "delivery" | "pickup"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle"; +type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced"; +type RTCDtlsRole = "auto" | "client" | "server"; +type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed"; +type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay"; +type RTCIceComponent = "RTP" | "RTCP"; +type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"; +type RTCIceGatherPolicy = "all" | "nohost" | "relay"; +type RTCIceGathererState = "new" | "gathering" | "complete"; +type RTCIceGatheringState = "new" | "gathering" | "complete"; +type RTCIceProtocol = "udp" | "tcp"; +type RTCIceRole = "controlling" | "controlled"; +type RTCIceTcpCandidateType = "active" | "passive" | "so"; +type RTCIceTransportPolicy = "none" | "relay" | "all"; +type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed"; +type RTCSdpType = "offer" | "pranswer" | "answer"; +type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"; +type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled"; +type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed"; +type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ScopedCredentialType = "ScopedCred"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type Transport = "usb" | "nfc" | "ble"; +type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; + + +///////////////////////////// +/// 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; + +/** + * Automation date (VT_DATE) + */ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; +} + +interface Date { + getVarDate: () => VarDate; +} + + +/// + +interface DOMTokenList { + [Symbol.iterator](): IterableIterator; +} + +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, string | File]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface Headers { + [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value pairs contained in this object. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all keys f the key/value pairs contained in this object. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values of the key/value pairs contained in this object. + */ + values(): IterableIterator; +} + +interface NodeList { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; +} + +interface NodeListOf { + + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; + + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface URLSearchParams { + /** + * Returns an array of key, value pairs for every entry in the search params + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns a list of keys in the search params + */ + keys(): IterableIterator; + /** + * Returns a list of values in the search params + */ + values(): IterableIterator; + /** + * iterate over key/value pairs + */ + [Symbol.iterator](): IterableIterator<[string, string]>; +} diff --git a/lib/lib.es2017.d.ts b/lib/lib.es2017.d.ts index 91d11bcf301..a0d3a0aff28 100644 --- a/lib/lib.es2017.d.ts +++ b/lib/lib.es2017.d.ts @@ -21,4 +21,4 @@ and limitations under the License. /// /// /// -/// +/// \ No newline at end of file diff --git a/lib/lib.es2017.full.d.ts b/lib/lib.es2017.full.d.ts new file mode 100644 index 00000000000..dae59bc9ae3 --- /dev/null +++ b/lib/lib.es2017.full.d.ts @@ -0,0 +1,15470 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + + +/// + + +/// +/// +/// +/// + + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + +interface Algorithm { + name: string; +} + +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; +} + +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; +} + +interface CompositionEventInit extends UIEventInit { + data?: string; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface ConstrainBooleanParameters { + exact?: boolean; + ideal?: boolean; +} + +interface ConstrainDOMStringParameters { + exact?: string | string[]; + ideal?: string | string[]; +} + +interface ConstrainDoubleRange extends DoubleRange { + exact?: number; + ideal?: number; +} + +interface ConstrainLongRange extends LongRange { + exact?: number; + ideal?: number; +} + +interface ConstrainVideoFacingModeParameters { + exact?: VideoFacingModeEnum | VideoFacingModeEnum[]; + ideal?: VideoFacingModeEnum | VideoFacingModeEnum[]; +} + +interface CustomEventInit extends EventInit { + detail?: any; +} + +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceLightEventInit extends EventInit { + value?: number; +} + +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface DoubleRange { + max?: number; + min?: number; +} + +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + +interface EventInit { + scoped?: boolean; + bubbles?: boolean; + cancelable?: boolean; +} + +interface EventModifierInit extends UIEventInit { + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + modifierAltGraph?: boolean; + modifierCapsLock?: boolean; + modifierFn?: boolean; + modifierFnLock?: boolean; + modifierHyper?: boolean; + modifierNumLock?: boolean; + modifierOS?: boolean; + modifierScrollLock?: boolean; + modifierSuper?: boolean; + modifierSymbol?: boolean; + modifierSymbolLock?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface FocusEventInit extends UIEventInit { + relatedTarget?: EventTarget; +} + +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + +interface HashChangeEventInit extends EventInit { + newURL?: string; + oldURL?: string; +} + +interface IDBIndexParameters { + multiEntry?: boolean; + unique?: boolean; +} + +interface IDBObjectStoreParameters { + autoIncrement?: boolean; + keyPath?: IDBKeyPath; +} + +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + +interface KeyAlgorithm { + name?: string; +} + +interface KeyboardEventInit extends EventModifierInit { + code?: string; + key?: string; + location?: number; + repeat?: boolean; +} + +interface LongRange { + max?: number; + min?: number; +} + +interface MSAccountInfo { + rpDisplayName?: string; + userDisplayName?: string; + accountName?: string; + userId?: string; + accountImageUri?: string; +} + +interface MSAudioLocalClientEvent extends MSLocalClientEventBase { + networkSendQualityEventRatio?: number; + networkDelayEventRatio?: number; + cpuInsufficientEventRatio?: number; + deviceHalfDuplexAECEventRatio?: number; + deviceRenderNotFunctioningEventRatio?: number; + deviceCaptureNotFunctioningEventRatio?: number; + deviceGlitchesEventRatio?: number; + deviceLowSNREventRatio?: number; + deviceLowSpeechLevelEventRatio?: number; + deviceClippingEventRatio?: number; + deviceEchoEventRatio?: number; + deviceNearEndToEchoRatioEventRatio?: number; + deviceRenderZeroVolumeEventRatio?: number; + deviceRenderMuteEventRatio?: number; + deviceMultipleEndpointsEventCount?: number; + deviceHowlingEventCount?: number; +} + +interface MSAudioRecvPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioRecvSignal; + packetReorderRatio?: number; + packetReorderDepthAvg?: number; + packetReorderDepthMax?: number; + burstLossLength1?: number; + burstLossLength2?: number; + burstLossLength3?: number; + burstLossLength4?: number; + burstLossLength5?: number; + burstLossLength6?: number; + burstLossLength7?: number; + burstLossLength8OrHigher?: number; + fecRecvDistance1?: number; + fecRecvDistance2?: number; + fecRecvDistance3?: number; + ratioConcealedSamplesAvg?: number; + ratioStretchedSamplesAvg?: number; + ratioCompressedSamplesAvg?: number; +} + +interface MSAudioRecvSignal { + initialSignalLevelRMS?: number; + recvSignalLevelCh1?: number; + recvNoiseLevelCh1?: number; + renderSignalLevel?: number; + renderNoiseLevel?: number; + renderLoopbackSignalLevel?: number; +} + +interface MSAudioSendPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioSendSignal; + audioFECUsed?: boolean; + sendMutePercent?: number; +} + +interface MSAudioSendSignal { + noiseLevel?: number; + sendSignalLevelCh1?: number; + sendNoiseLevelCh1?: number; +} + +interface MSConnectivity { + iceType?: MSIceType; + iceWarningFlags?: MSIceWarningFlags; + relayAddress?: MSRelayAddress; +} + +interface MSCredentialFilter { + accept?: MSCredentialSpec[]; +} + +interface MSCredentialParameters { + type?: MSCredentialType; +} + +interface MSCredentialSpec { + type?: MSCredentialType; + id?: string; +} + +interface MSDelay { + roundTrip?: number; + roundTripMax?: number; +} + +interface MSDescription extends RTCStats { + connectivity?: MSConnectivity; + transport?: RTCIceProtocol; + networkconnectivity?: MSNetworkConnectivityInfo; + localAddr?: MSIPAddressInfo; + remoteAddr?: MSIPAddressInfo; + deviceDevName?: string; + reflexiveLocalIPAddr?: MSIPAddressInfo; +} + +interface MSFIDOCredentialParameters extends MSCredentialParameters { + algorithm?: string | Algorithm; + authenticators?: AAGUID[]; +} + +interface MSIPAddressInfo { + ipAddr?: string; + port?: number; + manufacturerMacAddrMask?: string; +} + +interface MSIceWarningFlags { + turnTcpTimedOut?: boolean; + turnUdpAllocateFailed?: boolean; + turnUdpSendFailed?: boolean; + turnTcpAllocateFailed?: boolean; + turnTcpSendFailed?: boolean; + udpLocalConnectivityFailed?: boolean; + udpNatConnectivityFailed?: boolean; + udpRelayConnectivityFailed?: boolean; + tcpNatConnectivityFailed?: boolean; + tcpRelayConnectivityFailed?: boolean; + connCheckMessageIntegrityFailed?: boolean; + allocationMessageIntegrityFailed?: boolean; + connCheckOtherError?: boolean; + turnAuthUnknownUsernameError?: boolean; + noRelayServersConfigured?: boolean; + multipleRelayServersAttempted?: boolean; + portRangeExhausted?: boolean; + alternateServerReceived?: boolean; + pseudoTLSFailure?: boolean; + turnTurnTcpConnectivityFailed?: boolean; + useCandidateChecksFailed?: boolean; + fipsAllocationFailure?: boolean; +} + +interface MSJitter { + interArrival?: number; + interArrivalMax?: number; + interArrivalSD?: number; +} + +interface MSLocalClientEventBase extends RTCStats { + networkReceiveQualityEventRatio?: number; + networkBandwidthLowEventRatio?: number; +} + +interface MSNetwork extends RTCStats { + jitter?: MSJitter; + delay?: MSDelay; + packetLoss?: MSPacketLoss; + utilization?: MSUtilization; +} + +interface MSNetworkConnectivityInfo { + vpn?: boolean; + linkspeed?: number; + networkConnectionDetails?: string; +} + +interface MSNetworkInterfaceType { + interfaceTypeEthernet?: boolean; + interfaceTypeWireless?: boolean; + interfaceTypePPP?: boolean; + interfaceTypeTunnel?: boolean; + interfaceTypeWWAN?: boolean; +} + +interface MSOutboundNetwork extends MSNetwork { + appliedBandwidthLimit?: number; +} + +interface MSPacketLoss { + lossRate?: number; + lossRateMax?: number; +} + +interface MSPayloadBase extends RTCStats { + payloadDescription?: string; +} + +interface MSPortRange { + min?: number; + max?: number; +} + +interface MSRelayAddress { + relayAddress?: string; + port?: number; +} + +interface MSSignatureParameters { + userPrompt?: string; +} + +interface MSTransportDiagnosticsStats extends RTCStats { + baseAddress?: string; + localAddress?: string; + localSite?: string; + networkName?: string; + remoteAddress?: string; + remoteSite?: string; + localMR?: string; + remoteMR?: string; + iceWarningFlags?: MSIceWarningFlags; + portRangeMin?: number; + portRangeMax?: number; + localMRTCPPort?: number; + remoteMRTCPPort?: number; + stunVer?: number; + numConsentReqSent?: number; + numConsentReqReceived?: number; + numConsentRespSent?: number; + numConsentRespReceived?: number; + interfaces?: MSNetworkInterfaceType; + baseInterface?: MSNetworkInterfaceType; + protocol?: RTCIceProtocol; + localInterface?: MSNetworkInterfaceType; + localAddrType?: MSIceAddrType; + remoteAddrType?: MSIceAddrType; + iceRole?: RTCIceRole; + rtpRtcpMux?: boolean; + allocationTimeInMs?: number; + msRtcEngineVersion?: string; +} + +interface MSUtilization { + packets?: number; + bandwidthEstimation?: number; + bandwidthEstimationMin?: number; + bandwidthEstimationMax?: number; + bandwidthEstimationStdDev?: number; + bandwidthEstimationAvg?: number; +} + +interface MSVideoPayload extends MSPayloadBase { + resolution?: string; + videoBitRateAvg?: number; + videoBitRateMax?: number; + videoFrameRateAvg?: number; + videoPacketLossRate?: number; + durationSeconds?: number; +} + +interface MSVideoRecvPayload extends MSVideoPayload { + videoFrameLossRate?: number; + recvCodecType?: string; + recvResolutionWidth?: number; + recvResolutionHeight?: number; + videoResolutions?: MSVideoResolutionDistribution; + recvFrameRateAverage?: number; + recvBitRateMaximum?: number; + recvBitRateAverage?: number; + recvVideoStreamsMax?: number; + recvVideoStreamsMin?: number; + recvVideoStreamsMode?: number; + videoPostFECPLR?: number; + lowBitRateCallPercent?: number; + lowFrameRateCallPercent?: number; + reorderBufferTotalPackets?: number; + recvReorderBufferReorderedPackets?: number; + recvReorderBufferPacketsDroppedDueToBufferExhaustion?: number; + recvReorderBufferMaxSuccessfullyOrderedExtent?: number; + recvReorderBufferMaxSuccessfullyOrderedLateTime?: number; + recvReorderBufferPacketsDroppedDueToTimeout?: number; + recvFpsHarmonicAverage?: number; + recvNumResSwitches?: number; +} + +interface MSVideoResolutionDistribution { + cifQuality?: number; + vgaQuality?: number; + h720Quality?: number; + h1080Quality?: number; + h1440Quality?: number; + h2160Quality?: number; +} + +interface MSVideoSendPayload extends MSVideoPayload { + sendFrameRateAverage?: number; + sendBitRateMaximum?: number; + sendBitRateAverage?: number; + sendVideoStreamsMax?: number; + sendResolutionWidth?: number; + sendResolutionHeight?: number; +} + +interface MediaEncryptedEventInit extends EventInit { + initDataType?: string; + initData?: ArrayBuffer; +} + +interface MediaKeyMessageEventInit extends EventInit { + messageType?: MediaKeyMessageType; + message?: ArrayBuffer; +} + +interface MediaKeySystemConfiguration { + initDataTypes?: string[]; + audioCapabilities?: MediaKeySystemMediaCapability[]; + videoCapabilities?: MediaKeySystemMediaCapability[]; + distinctiveIdentifier?: MediaKeysRequirement; + persistentState?: MediaKeysRequirement; +} + +interface MediaKeySystemMediaCapability { + contentType?: string; + robustness?: string; +} + +interface MediaStreamConstraints { + video?: boolean | MediaTrackConstraints; + audio?: boolean | MediaTrackConstraints; +} + +interface MediaStreamErrorEventInit extends EventInit { + error?: MediaStreamError; +} + +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + +interface MediaStreamTrackEventInit extends EventInit { + track?: MediaStreamTrack; +} + +interface MediaTrackCapabilities { + width?: number | LongRange; + height?: number | LongRange; + aspectRatio?: number | DoubleRange; + frameRate?: number | DoubleRange; + facingMode?: string; + volume?: number | DoubleRange; + sampleRate?: number | LongRange; + sampleSize?: number | LongRange; + echoCancellation?: boolean[]; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackConstraintSet { + width?: number | ConstrainLongRange; + height?: number | ConstrainLongRange; + aspectRatio?: number | ConstrainDoubleRange; + frameRate?: number | ConstrainDoubleRange; + facingMode?: string | string[] | ConstrainDOMStringParameters; + volume?: number | ConstrainDoubleRange; + sampleRate?: number | ConstrainLongRange; + sampleSize?: number | ConstrainLongRange; + echoCancelation?: boolean | ConstrainBooleanParameters; + deviceId?: string | string[] | ConstrainDOMStringParameters; + groupId?: string | string[] | ConstrainDOMStringParameters; +} + +interface MediaTrackConstraints extends MediaTrackConstraintSet { + advanced?: MediaTrackConstraintSet[]; +} + +interface MediaTrackSettings { + width?: number; + height?: number; + aspectRatio?: number; + frameRate?: number; + facingMode?: string; + volume?: number; + sampleRate?: number; + sampleSize?: number; + echoCancellation?: boolean; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackSupportedConstraints { + width?: boolean; + height?: boolean; + aspectRatio?: boolean; + frameRate?: boolean; + facingMode?: boolean; + volume?: boolean; + sampleRate?: boolean; + sampleSize?: boolean; + echoCancellation?: boolean; + deviceId?: boolean; + groupId?: boolean; +} + +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + +interface MouseEventInit extends EventModifierInit { + 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 NotificationOptions { + dir?: NotificationDirection; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + +interface PeriodicWaveConstraints { + disableNormalization?: boolean; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface PopStateEventInit extends EventInit { + state?: any; +} + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: RTCIceTransportPolicy; + bundlePolicy?: RTCBundlePolicy; + peerIdentity?: string; +} + +interface RTCDTMFToneChangeEventInit extends EventInit { + tone?: string; +} + +interface RTCDtlsFingerprint { + algorithm?: string; + value?: string; +} + +interface RTCDtlsParameters { + role?: RTCDtlsRole; + fingerprints?: RTCDtlsFingerprint[]; +} + +interface RTCIceCandidateAttributes extends RTCStats { + ipAddress?: string; + portNumber?: number; + transport?: string; + candidateType?: RTCStatsIceCandidateType; + priority?: number; + addressSourceUrl?: string; +} + +interface RTCIceCandidateComplete { +} + +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: RTCIceProtocol; + port?: number; + type?: RTCIceCandidateType; + tcpType?: RTCIceTcpCandidateType; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + +interface RTCIceCandidatePair { + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; +} + +interface RTCIceCandidatePairStats extends RTCStats { + transportId?: string; + localCandidateId?: string; + remoteCandidateId?: string; + state?: RTCStatsIceCandidatePairState; + priority?: number; + nominated?: boolean; + writable?: boolean; + readable?: boolean; + bytesSent?: number; + bytesReceived?: number; + roundTripTime?: number; + availableOutgoingBitrate?: number; + availableIncomingBitrate?: number; +} + +interface RTCIceGatherOptions { + gatherPolicy?: RTCIceGatherPolicy; + iceservers?: RTCIceServer[]; + portRange?: MSPortRange; +} + +interface RTCIceParameters { + usernameFragment?: string; + password?: string; + iceLite?: boolean; +} + +interface RTCIceServer { + urls?: any; + username?: string; + credential?: string; +} + +interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { + packetsReceived?: number; + bytesReceived?: number; + packetsLost?: number; + jitter?: number; + fractionLost?: number; +} + +interface RTCMediaStreamTrackStats extends RTCStats { + trackIdentifier?: string; + remoteSource?: boolean; + ssrcIds?: string[]; + frameWidth?: number; + frameHeight?: number; + framesPerSecond?: number; + framesSent?: number; + framesReceived?: number; + framesDecoded?: number; + framesDropped?: number; + framesCorrupted?: number; + audioLevel?: number; + echoReturnLoss?: number; + echoReturnLossEnhancement?: number; +} + +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + +interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { + packetsSent?: number; + bytesSent?: number; + targetBitrate?: number; + roundTripTime?: number; +} + +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + +interface RTCRTPStreamStats extends RTCStats { + ssrc?: string; + associateStatsId?: string; + isRemote?: boolean; + mediaTrackId?: string; + transportId?: string; + codecId?: string; + firCount?: number; + pliCount?: number; + nackCount?: number; + sliCount?: number; +} + +interface RTCRtcpFeedback { + type?: string; + parameter?: string; +} + +interface RTCRtcpParameters { + ssrc?: number; + cname?: string; + reducedSize?: boolean; + mux?: boolean; +} + +interface RTCRtpCapabilities { + codecs?: RTCRtpCodecCapability[]; + headerExtensions?: RTCRtpHeaderExtension[]; + fecMechanisms?: string[]; +} + +interface RTCRtpCodecCapability { + name?: string; + kind?: string; + clockRate?: number; + preferredPayloadType?: number; + maxptime?: number; + ptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; + options?: any; + maxTemporalLayers?: number; + maxSpatialLayers?: number; + svcMultiStreamSupport?: boolean; +} + +interface RTCRtpCodecParameters { + name?: string; + payloadType?: any; + clockRate?: number; + maxptime?: number; + ptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; +} + +interface RTCRtpContributingSource { + timestamp?: number; + csrc?: number; + audioLevel?: number; +} + +interface RTCRtpEncodingParameters { + ssrc?: number; + codecPayloadType?: number; + fec?: RTCRtpFecParameters; + rtx?: RTCRtpRtxParameters; + priority?: number; + maxBitrate?: number; + minQuality?: number; + resolutionScale?: number; + framerateScale?: number; + maxFramerate?: number; + active?: boolean; + encodingId?: string; + dependencyEncodingIds?: string[]; + ssrcRange?: RTCSsrcRange; +} + +interface RTCRtpFecParameters { + ssrc?: number; + mechanism?: string; +} + +interface RTCRtpHeaderExtension { + kind?: string; + uri?: string; + preferredId?: number; + preferredEncrypt?: boolean; +} + +interface RTCRtpHeaderExtensionParameters { + uri?: string; + id?: number; + encrypt?: boolean; +} + +interface RTCRtpParameters { + muxId?: string; + codecs?: RTCRtpCodecParameters[]; + headerExtensions?: RTCRtpHeaderExtensionParameters[]; + encodings?: RTCRtpEncodingParameters[]; + rtcp?: RTCRtcpParameters; + degradationPreference?: RTCDegradationPreference; +} + +interface RTCRtpRtxParameters { + ssrc?: number; +} + +interface RTCRtpUnhandled { + ssrc?: number; + payloadType?: number; + muxId?: string; +} + +interface RTCSessionDescriptionInit { + type?: RTCSdpType; + sdp?: string; +} + +interface RTCSrtpKeyParam { + keyMethod?: string; + keySalt?: string; + lifetime?: string; + mkiValue?: number; + mkiLength?: number; +} + +interface RTCSrtpSdesParameters { + tag?: number; + cryptoSuite?: string; + keyParams?: RTCSrtpKeyParam[]; + sessionParams?: string[]; +} + +interface RTCSsrcRange { + min?: number; + max?: number; +} + +interface RTCStats { + timestamp?: number; + type?: RTCStatsType; + id?: string; + msType?: MSStatsType; +} + +interface RTCStatsReport { +} + +interface RTCTransportStats extends RTCStats { + bytesSent?: number; + bytesReceived?: number; + rtcpTransportStatsId?: string; + activeConnection?: boolean; + selectedCandidatePairId?: string; + localCertificateId?: string; + remoteCertificateId?: string; +} + +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: ScopedCredentialType; + id?: any; + transports?: Transport[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: ScopedCredentialType; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + +interface UIEventInit extends EventInit { + view?: Window; + detail?: number; +} + +interface WebAuthnExtensions { +} + +interface WebGLContextAttributes { + failIfMajorPerformanceCaveat?: boolean; + 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 WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (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; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +declare var ANGLE_instanced_arrays: { + prototype: ANGLE_instanced_arrays; + new(): ANGLE_instanced_arrays; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +interface AnalyserNode extends AudioNode { + fftSize: number; + readonly 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 { + readonly animationName: string; + readonly elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +declare var AnimationEvent: { + prototype: AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; +} + +interface ApplicationCacheEventMap { + "cached": Event; + "checking": Event; + "downloading": Event; + "error": Event; + "noupdate": Event; + "obsolete": Event; + "progress": ProgressEvent; + "updateready": Event; +} + +interface ApplicationCache extends EventTarget { + oncached: (this: ApplicationCache, ev: Event) => any; + onchecking: (this: ApplicationCache, ev: Event) => any; + ondownloading: (this: ApplicationCache, ev: Event) => any; + onerror: (this: ApplicationCache, ev: Event) => any; + onnoupdate: (this: ApplicationCache, ev: Event) => any; + onobsolete: (this: ApplicationCache, ev: Event) => any; + onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; + onupdateready: (this: ApplicationCache, ev: Event) => any; + readonly status: number; + abort(): void; + swapCache(): void; + update(): void; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; + addEventListener(type: K, listener: (this: ApplicationCache, ev: ApplicationCacheEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; +} + +interface Attr extends Node { + readonly name: string; + readonly ownerElement: Element; + readonly prefix: string | null; + readonly specified: boolean; + value: string; +} + +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface AudioBuffer { + readonly duration: number; + readonly length: number; + readonly numberOfChannels: number; + readonly sampleRate: number; + copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; + copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; + getChannelData(channel: number): Float32Array; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + +interface AudioBufferSourceNodeEventMap { + "ended": MediaStreamErrorEvent; +} + +interface AudioBufferSourceNode extends AudioNode { + buffer: AudioBuffer | null; + readonly detune: AudioParam; + loop: boolean; + loopEnd: number; + loopStart: number; + onended: (this: AudioBufferSourceNode, ev: MediaStreamErrorEvent) => any; + readonly playbackRate: AudioParam; + start(when?: number, offset?: number, duration?: number): void; + stop(when?: number): void; + addEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioBufferSourceNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var AudioBufferSourceNode: { + prototype: AudioBufferSourceNode; + new(): AudioBufferSourceNode; +} + +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { + readonly currentTime: number; + readonly destination: AudioDestinationNode; + readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; + readonly sampleRate: number; + readonly state: AudioContextState; + close(): Promise; + 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; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; + createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; + createOscillator(): OscillatorNode; + createPanner(): PannerNode; + createPeriodicWave(real: Float32Array, imag: Float32Array, constraints?: PeriodicWaveConstraints): PeriodicWave; + createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; + createStereoPanner(): StereoPannerNode; + createWaveShaper(): WaveShaperNode; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; +} + +declare var AudioContext: { + prototype: AudioContext; + new(): AudioContext; +} + +interface AudioDestinationNode extends AudioNode { + readonly 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: ChannelCountMode; + channelInterpretation: ChannelInterpretation; + readonly context: AudioContext; + readonly numberOfInputs: number; + readonly numberOfOutputs: number; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: 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 { + readonly defaultValue: number; + value: number; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; +} + +declare var AudioParam: { + prototype: AudioParam; + new(): AudioParam; +} + +interface AudioProcessingEvent extends Event { + readonly inputBuffer: AudioBuffer; + readonly outputBuffer: AudioBuffer; + readonly playbackTime: number; +} + +declare var AudioProcessingEvent: { + prototype: AudioProcessingEvent; + new(): AudioProcessingEvent; +} + +interface AudioTrack { + enabled: boolean; + readonly id: string; + kind: string; + readonly label: string; + language: string; + readonly sourceBuffer: SourceBuffer; +} + +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface AudioTrackListEventMap { + "addtrack": TrackEvent; + "change": Event; + "removetrack": TrackEvent; +} + +interface AudioTrackList extends EventTarget { + readonly length: number; + onaddtrack: (this: AudioTrackList, ev: TrackEvent) => any; + onchange: (this: AudioTrackList, ev: Event) => any; + onremovetrack: (this: AudioTrackList, ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack | null; + item(index: number): AudioTrack; + addEventListener(type: K, listener: (this: AudioTrackList, ev: AudioTrackListEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: AudioTrack; +} + +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface BarProp { + readonly 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 { + readonly Q: AudioParam; + readonly detune: AudioParam; + readonly frequency: AudioParam; + readonly gain: AudioParam; + type: BiquadFilterType; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var BiquadFilterNode: { + prototype: BiquadFilterNode; + new(): BiquadFilterNode; +} + +interface Blob { + readonly size: number; + readonly 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 { + readonly style: CSSStyleDeclaration; +} + +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface CSSGroupingRule extends CSSRule { + readonly cssRules: CSSRuleList; + deleteRule(index: number): void; + insertRule(rule: string, index: number): number; +} + +declare var CSSGroupingRule: { + prototype: CSSGroupingRule; + new(): CSSGroupingRule; +} + +interface CSSImportRule extends CSSRule { + readonly href: string; + readonly media: MediaList; + readonly styleSheet: CSSStyleSheet; +} + +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface CSSKeyframesRule extends CSSRule { + readonly 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 { + readonly media: MediaList; +} + +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface CSSNamespaceRule extends CSSRule { + readonly namespaceURI: string; + readonly prefix: string; +} + +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface CSSPageRule extends CSSRule { + readonly pseudoClass: string; + readonly selector: string; + selectorText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface CSSRule { + cssText: string; + readonly parentRule: CSSRule; + readonly parentStyleSheet: CSSStyleSheet; + readonly type: number; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; +} + +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; +} + +interface CSSRuleList { + readonly length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} + +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface CSSStyleDeclaration { + alignContent: string | null; + alignItems: string | null; + alignSelf: string | null; + alignmentBaseline: string | null; + animation: string | null; + animationDelay: string | null; + animationDirection: string | null; + animationDuration: string | null; + animationFillMode: string | null; + animationIterationCount: string | null; + animationName: string | null; + animationPlayState: string | null; + animationTimingFunction: string | null; + backfaceVisibility: string | null; + background: string | null; + backgroundAttachment: string | null; + backgroundClip: string | null; + backgroundColor: string | null; + backgroundImage: string | null; + backgroundOrigin: string | null; + backgroundPosition: string | null; + backgroundPositionX: string | null; + backgroundPositionY: string | null; + backgroundRepeat: string | null; + backgroundSize: string | null; + baselineShift: string | null; + border: string | null; + borderBottom: string | null; + borderBottomColor: string | null; + borderBottomLeftRadius: string | null; + borderBottomRightRadius: string | null; + borderBottomStyle: string | null; + borderBottomWidth: string | null; + borderCollapse: string | null; + borderColor: string | null; + borderImage: string | null; + borderImageOutset: string | null; + borderImageRepeat: string | null; + borderImageSlice: string | null; + borderImageSource: string | null; + borderImageWidth: string | null; + borderLeft: string | null; + borderLeftColor: string | null; + borderLeftStyle: string | null; + borderLeftWidth: string | null; + borderRadius: string | null; + borderRight: string | null; + borderRightColor: string | null; + borderRightStyle: string | null; + borderRightWidth: string | null; + borderSpacing: string | null; + borderStyle: string | null; + borderTop: string | null; + borderTopColor: string | null; + borderTopLeftRadius: string | null; + borderTopRightRadius: string | null; + borderTopStyle: string | null; + borderTopWidth: string | null; + borderWidth: string | null; + bottom: string | null; + boxShadow: string | null; + boxSizing: string | null; + breakAfter: string | null; + breakBefore: string | null; + breakInside: string | null; + captionSide: string | null; + clear: string | null; + clip: string | null; + clipPath: string | null; + clipRule: string | null; + color: string | null; + colorInterpolationFilters: string | null; + columnCount: any; + columnFill: string | null; + columnGap: any; + columnRule: string | null; + columnRuleColor: any; + columnRuleStyle: string | null; + columnRuleWidth: any; + columnSpan: string | null; + columnWidth: any; + columns: string | null; + content: string | null; + counterIncrement: string | null; + counterReset: string | null; + cssFloat: string | null; + cssText: string; + cursor: string | null; + direction: string | null; + display: string | null; + dominantBaseline: string | null; + emptyCells: string | null; + enableBackground: string | null; + fill: string | null; + fillOpacity: string | null; + fillRule: string | null; + filter: string | null; + flex: string | null; + flexBasis: string | null; + flexDirection: string | null; + flexFlow: string | null; + flexGrow: string | null; + flexShrink: string | null; + flexWrap: string | null; + floodColor: string | null; + floodOpacity: string | null; + font: string | null; + fontFamily: string | null; + fontFeatureSettings: string | null; + fontSize: string | null; + fontSizeAdjust: string | null; + fontStretch: string | null; + fontStyle: string | null; + fontVariant: string | null; + fontWeight: string | null; + glyphOrientationHorizontal: string | null; + glyphOrientationVertical: string | null; + height: string | null; + imeMode: string | null; + justifyContent: string | null; + kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; + left: string | null; + readonly length: number; + letterSpacing: string | null; + lightingColor: string | null; + lineBreak: string | null; + lineHeight: string | null; + listStyle: string | null; + listStyleImage: string | null; + listStylePosition: string | null; + listStyleType: string | null; + margin: string | null; + marginBottom: string | null; + marginLeft: string | null; + marginRight: string | null; + marginTop: string | null; + marker: string | null; + markerEnd: string | null; + markerMid: string | null; + markerStart: string | null; + mask: string | null; + maxHeight: string | null; + maxWidth: string | null; + minHeight: string | null; + minWidth: string | null; + msContentZoomChaining: string | null; + msContentZoomLimit: string | null; + msContentZoomLimitMax: any; + msContentZoomLimitMin: any; + msContentZoomSnap: string | null; + msContentZoomSnapPoints: string | null; + msContentZoomSnapType: string | null; + msContentZooming: string | null; + msFlowFrom: string | null; + msFlowInto: string | null; + msFontFeatureSettings: string | null; + msGridColumn: any; + msGridColumnAlign: string | null; + msGridColumnSpan: any; + msGridColumns: string | null; + msGridRow: any; + msGridRowAlign: string | null; + msGridRowSpan: any; + msGridRows: string | null; + msHighContrastAdjust: string | null; + msHyphenateLimitChars: string | null; + msHyphenateLimitLines: any; + msHyphenateLimitZone: any; + msHyphens: string | null; + msImeAlign: string | null; + msOverflowStyle: string | null; + msScrollChaining: string | null; + msScrollLimit: string | null; + msScrollLimitXMax: any; + msScrollLimitXMin: any; + msScrollLimitYMax: any; + msScrollLimitYMin: any; + msScrollRails: string | null; + msScrollSnapPointsX: string | null; + msScrollSnapPointsY: string | null; + msScrollSnapType: string | null; + msScrollSnapX: string | null; + msScrollSnapY: string | null; + msScrollTranslation: string | null; + msTextCombineHorizontal: string | null; + msTextSizeAdjust: any; + msTouchAction: string | null; + msTouchSelect: string | null; + msUserSelect: string | null; + msWrapFlow: string; + msWrapMargin: any; + msWrapThrough: string; + opacity: string | null; + order: string | null; + orphans: string | null; + outline: string | null; + outlineColor: string | null; + outlineOffset: string | null; + outlineStyle: string | null; + outlineWidth: string | null; + overflow: string | null; + overflowX: string | null; + overflowY: string | null; + padding: string | null; + paddingBottom: string | null; + paddingLeft: string | null; + paddingRight: string | null; + paddingTop: string | null; + pageBreakAfter: string | null; + pageBreakBefore: string | null; + pageBreakInside: string | null; + readonly parentRule: CSSRule; + perspective: string | null; + perspectiveOrigin: string | null; + pointerEvents: string | null; + position: string | null; + quotes: string | null; + right: string | null; + rotate: string | null; + rubyAlign: string | null; + rubyOverhang: string | null; + rubyPosition: string | null; + scale: string | null; + stopColor: string | null; + stopOpacity: string | null; + stroke: string | null; + strokeDasharray: string | null; + strokeDashoffset: string | null; + strokeLinecap: string | null; + strokeLinejoin: string | null; + strokeMiterlimit: string | null; + strokeOpacity: string | null; + strokeWidth: string | null; + tableLayout: string | null; + textAlign: string | null; + textAlignLast: string | null; + textAnchor: string | null; + textDecoration: string | null; + textIndent: string | null; + textJustify: string | null; + textKashida: string | null; + textKashidaSpace: string | null; + textOverflow: string | null; + textShadow: string | null; + textTransform: string | null; + textUnderlinePosition: string | null; + top: string | null; + touchAction: string | null; + transform: string | null; + transformOrigin: string | null; + transformStyle: string | null; + transition: string | null; + transitionDelay: string | null; + transitionDuration: string | null; + transitionProperty: string | null; + transitionTimingFunction: string | null; + translate: string | null; + unicodeBidi: string | null; + verticalAlign: string | null; + visibility: string | null; + webkitAlignContent: string | null; + webkitAlignItems: string | null; + webkitAlignSelf: string | null; + webkitAnimation: string | null; + webkitAnimationDelay: string | null; + webkitAnimationDirection: string | null; + webkitAnimationDuration: string | null; + webkitAnimationFillMode: string | null; + webkitAnimationIterationCount: string | null; + webkitAnimationName: string | null; + webkitAnimationPlayState: string | null; + webkitAnimationTimingFunction: string | null; + webkitAppearance: string | null; + webkitBackfaceVisibility: string | null; + webkitBackgroundClip: string | null; + webkitBackgroundOrigin: string | null; + webkitBackgroundSize: string | null; + webkitBorderBottomLeftRadius: string | null; + webkitBorderBottomRightRadius: string | null; + webkitBorderImage: string | null; + webkitBorderRadius: string | null; + webkitBorderTopLeftRadius: string | null; + webkitBorderTopRightRadius: string | null; + webkitBoxAlign: string | null; + webkitBoxDirection: string | null; + webkitBoxFlex: string | null; + webkitBoxOrdinalGroup: string | null; + webkitBoxOrient: string | null; + webkitBoxPack: string | null; + webkitBoxSizing: string | null; + webkitColumnBreakAfter: string | null; + webkitColumnBreakBefore: string | null; + webkitColumnBreakInside: string | null; + webkitColumnCount: any; + webkitColumnGap: any; + webkitColumnRule: string | null; + webkitColumnRuleColor: any; + webkitColumnRuleStyle: string | null; + webkitColumnRuleWidth: any; + webkitColumnSpan: string | null; + webkitColumnWidth: any; + webkitColumns: string | null; + webkitFilter: string | null; + webkitFlex: string | null; + webkitFlexBasis: string | null; + webkitFlexDirection: string | null; + webkitFlexFlow: string | null; + webkitFlexGrow: string | null; + webkitFlexShrink: string | null; + webkitFlexWrap: string | null; + webkitJustifyContent: string | null; + webkitOrder: string | null; + webkitPerspective: string | null; + webkitPerspectiveOrigin: string | null; + webkitTapHighlightColor: string | null; + webkitTextFillColor: string | null; + webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; + webkitTransform: string | null; + webkitTransformOrigin: string | null; + webkitTransformStyle: string | null; + webkitTransition: string | null; + webkitTransitionDelay: string | null; + webkitTransitionDuration: string | null; + webkitTransitionProperty: string | null; + webkitTransitionTimingFunction: string | null; + webkitUserModify: string | null; + webkitUserSelect: string | null; + webkitWritingMode: string | null; + whiteSpace: string | null; + widows: string | null; + width: string | null; + wordBreak: string | null; + wordSpacing: string | null; + wordWrap: string | null; + writingMode: string | null; + zIndex: string | null; + zoom: string | null; + resize: string | null; + userSelect: string | null; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + item(index: number): string; + removeProperty(propertyName: string): string; + setProperty(propertyName: string, value: string | null, priority?: string): void; + [index: number]: string; +} + +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface CSSStyleRule extends CSSRule { + readonly readOnly: boolean; + selectorText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface CSSStyleSheet extends StyleSheet { + readonly cssRules: CSSRuleList; + cssText: string; + readonly id: string; + readonly imports: StyleSheetList; + readonly isAlternate: boolean; + readonly isPrefAlternate: boolean; + readonly ownerRule: CSSRule; + readonly owningElement: Element; + readonly pages: StyleSheetPageList; + readonly readOnly: boolean; + readonly 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 Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} + +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; +} + +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface CanvasRenderingContext2D extends Object, CanvasPathMethods { + readonly canvas: HTMLCanvasElement; + fillStyle: string | CanvasGradient | CanvasPattern; + font: string; + globalAlpha: number; + globalCompositeOperation: string; + imageSmoothingEnabled: boolean; + lineCap: string; + lineDashOffset: number; + lineJoin: string; + lineWidth: number; + miterLimit: number; + msFillRule: CanvasFillRule; + shadowBlur: number; + shadowColor: string; + shadowOffsetX: number; + shadowOffsetY: number; + strokeStyle: string | CanvasGradient | CanvasPattern; + textAlign: string; + textBaseline: string; + mozImageSmoothingEnabled: boolean; + webkitImageSmoothingEnabled: boolean; + oImageSmoothingEnabled: boolean; + beginPath(): void; + clearRect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: CanvasFillRule): 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; + drawFocusIfNeeded(element: Element): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; + fill(fillRule?: CanvasFillRule): 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?: CanvasFillRule): boolean; + measureText(text: string): TextMetrics; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: 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(path?: Path2D): 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; + readonly 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; +} + +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface ClientRect { + bottom: number; + readonly height: number; + left: number; + right: number; + top: number; + readonly width: number; +} + +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface ClientRectList { + readonly length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} + +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface ClipboardEvent extends Event { + readonly clipboardData: DataTransfer; +} + +declare var ClipboardEvent: { + prototype: ClipboardEvent; + new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; +} + +interface CloseEvent extends Event { + readonly code: number; + readonly reason: string; + readonly wasClean: boolean; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +declare var CloseEvent: { + prototype: CloseEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; +} + +interface Comment extends CharacterData { + text: string; +} + +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface CompositionEvent extends UIEvent { + readonly data: string; + readonly 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?: any, ...optionalParams: any[]): void; + dir(value?: any, ...optionalParams: any[]): void; + dirxml(value: any): void; + error(message?: any, ...optionalParams: any[]): void; + exception(message?: string, ...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; + table(...data: any[]): 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 | null; + normalize: boolean; +} + +declare var ConvolverNode: { + prototype: ConvolverNode; + new(): ConvolverNode; +} + +interface Coordinates { + readonly accuracy: number; + readonly altitude: number | null; + readonly altitudeAccuracy: number | null; + readonly heading: number | null; + readonly latitude: number; + readonly longitude: number; + readonly speed: number | null; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface Crypto extends Object, RandomSource { + readonly subtle: SubtleCrypto; +} + +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface CryptoKey { + readonly algorithm: KeyAlgorithm; + readonly extractable: boolean; + readonly type: string; + readonly 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 { + readonly 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 { + readonly name: string; + toString(): string; +} + +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface DOMException { + readonly code: number; + readonly message: string; + readonly name: string; + toString(): string; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; +} + +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; +} + +interface DOMImplementation { + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createHTMLDocument(title: string): Document; + hasFeature(feature: string | null, version: string | null): 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 { + readonly length: number; + contains(str: string): boolean; + item(index: number): string | null; + [index: number]: string; +} + +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface DOMStringMap { + [name: string]: string | undefined; +} + +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DOMTokenList { + readonly 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; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DataCue: { + prototype: DataCue; + new(): DataCue; +} + +interface DataTransfer { + dropEffect: string; + effectAllowed: string; + readonly files: FileList; + readonly items: DataTransferItemList; + readonly types: string[]; + clearData(format?: string): boolean; + getData(format: string): string; + setData(format: string, data: string): boolean; + setDragImage(image: Element, x: number, y: number): void; +} + +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface DataTransferItem { + readonly kind: string; + readonly type: string; + getAsFile(): File | null; + getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; +} + +declare var DataTransferItem: { + prototype: DataTransferItem; + new(): DataTransferItem; +} + +interface DataTransferItemList { + readonly length: number; + add(data: File): DataTransferItem | null; + clear(): void; + item(index: number): DataTransferItem; + remove(index: number): void; + [index: number]: DataTransferItem; +} + +declare var DataTransferItemList: { + prototype: DataTransferItemList; + new(): DataTransferItemList; +} + +interface DeferredPermissionRequest { + readonly id: number; + readonly type: MSWebViewPermissionType; + readonly uri: string; + allow(): void; + deny(): void; +} + +declare var DeferredPermissionRequest: { + prototype: DeferredPermissionRequest; + new(): DeferredPermissionRequest; +} + +interface DelayNode extends AudioNode { + readonly delayTime: AudioParam; +} + +declare var DelayNode: { + prototype: DelayNode; + new(): DelayNode; +} + +interface DeviceAcceleration { + readonly x: number | null; + readonly y: number | null; + readonly z: number | null; +} + +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface DeviceLightEvent extends Event { + readonly value: number; +} + +declare var DeviceLightEvent: { + prototype: DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; +} + +interface DeviceMotionEvent extends Event { + readonly acceleration: DeviceAcceleration | null; + readonly accelerationIncludingGravity: DeviceAcceleration | null; + readonly interval: number | null; + readonly rotationRate: DeviceRotationRate | null; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict | null, accelerationIncludingGravity: DeviceAccelerationDict | null, rotationRate: DeviceRotationRateDict | null, interval: number | null): void; +} + +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; +} + +interface DeviceOrientationEvent extends Event { + readonly absolute: boolean; + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number | null, beta: number | null, gamma: number | null, absolute: boolean): void; +} + +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; +} + +interface DeviceRotationRate { + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; +} + +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface DocumentEventMap extends GlobalEventHandlersEventMap { + "abort": UIEvent; + "activate": UIEvent; + "beforeactivate": UIEvent; + "beforedeactivate": UIEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "contextmenu": PointerEvent; + "dblclick": MouseEvent; + "deactivate": UIEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "fullscreenchange": Event; + "fullscreenerror": Event; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "mousedown": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSContentZoom": UIEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSInertiaStart": MSGestureEvent; + "MSManipulationStateChanged": MSManipulationEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "mssitemodejumplistitemremoved": MSSiteModeEvent; + "msthumbnailclick": MSSiteModeEvent; + "pause": Event; + "play": Event; + "playing": Event; + "pointerlockchange": Event; + "pointerlockerror": Event; + "progress": ProgressEvent; + "ratechange": Event; + "readystatechange": Event; + "reset": Event; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "selectionchange": Event; + "selectstart": Event; + "stalled": Event; + "stop": Event; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "touchcancel": TouchEvent; + "touchend": TouchEvent; + "touchmove": TouchEvent; + "touchstart": TouchEvent; + "volumechange": Event; + "waiting": Event; + "webkitfullscreenchange": Event; + "webkitfullscreenerror": Event; +} + +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { + /** + * Sets or gets the URL for the current document. + */ + readonly URL: string; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + readonly URLUnencoded: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + readonly 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. + */ + readonly all: HTMLAllCollection; + /** + * 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: HTMLCollectionOf; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollectionOf; + /** + * 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; + readonly 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. + */ + readonly compatMode: string; + cookie: string; + readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly 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. + */ + readonly 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: HTMLCollectionOf; + /** + * 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: HTMLCollectionOf; + readonly fullscreenElement: Element | null; + readonly fullscreenEnabled: boolean; + readonly head: HTMLHeadElement; + readonly hidden: boolean; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollectionOf; + /** + * Gets the implementation object of the current document. + */ + readonly implementation: DOMImplementation; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + readonly inputEncoding: string | null; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + readonly 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: HTMLCollectionOf; + /** + * Contains information about the current URL. + */ + readonly location: Location; + msCSSOMElementFloatMetrics: boolean; + msCapsLockWarningOff: boolean; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (this: Document, ev: UIEvent) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (this: Document, ev: UIEvent) => any; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (this: Document, 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: (this: Document, ev: UIEvent) => any; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (this: Document, ev: FocusEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (this: Document, ev: Event) => any; + oncanplaythrough: (this: Document, ev: Event) => any; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (this: Document, 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: (this: Document, ev: PointerEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (this: Document, 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: (this: Document, ev: UIEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, ev: DragEvent) => any; + ondrop: (this: Document, ev: DragEvent) => any; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (this: Document, ev: Event) => any; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (this: Document, ev: Event) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (this: Document, ev: MediaStreamErrorEvent) => any; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (this: Document, ev: ErrorEvent) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (this: Document, ev: FocusEvent) => any; + onfullscreenchange: (this: Document, ev: Event) => any; + onfullscreenerror: (this: Document, ev: Event) => any; + oninput: (this: Document, ev: Event) => any; + oninvalid: (this: Document, ev: Event) => any; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (this: Document, ev: Event) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (this: Document, ev: Event) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (this: Document, ev: Event) => any; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (this: Document, ev: WheelEvent) => any; + onmscontentzoom: (this: Document, ev: UIEvent) => any; + onmsgesturechange: (this: Document, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Document, ev: MSGestureEvent) => any; + onmsgestureend: (this: Document, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Document, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Document, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Document, ev: MSGestureEvent) => any; + onmsinertiastart: (this: Document, ev: MSGestureEvent) => any; + onmsmanipulationstatechanged: (this: Document, ev: MSManipulationEvent) => any; + onmspointercancel: (this: Document, ev: MSPointerEvent) => any; + onmspointerdown: (this: Document, ev: MSPointerEvent) => any; + onmspointerenter: (this: Document, ev: MSPointerEvent) => any; + onmspointerleave: (this: Document, ev: MSPointerEvent) => any; + onmspointermove: (this: Document, ev: MSPointerEvent) => any; + onmspointerout: (this: Document, ev: MSPointerEvent) => any; + onmspointerover: (this: Document, ev: MSPointerEvent) => any; + onmspointerup: (this: Document, 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: (this: Document, 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: (this: Document, ev: MSSiteModeEvent) => any; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (this: Document, ev: Event) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (this: Document, ev: Event) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (this: Document, ev: Event) => any; + onpointerlockchange: (this: Document, ev: Event) => any; + onpointerlockerror: (this: Document, ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (this: Document, ev: ProgressEvent) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (this: Document, ev: Event) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (this: Document, ev: Event) => any; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (this: Document, ev: Event) => any; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (this: Document, ev: UIEvent) => any; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (this: Document, ev: Event) => any; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (this: Document, ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (this: Document, ev: UIEvent) => any; + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (this: Document, ev: Event) => any; + onselectstart: (this: Document, ev: Event) => any; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (this: Document, ev: Event) => any; + onsubmit: (this: Document, ev: Event) => any; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (this: Document, ev: Event) => any; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (this: Document, 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: (this: Document, ev: Event) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (this: Document, ev: Event) => any; + onwebkitfullscreenchange: (this: Document, ev: Event) => any; + onwebkitfullscreenerror: (this: Document, ev: Event) => any; + plugins: HTMLCollectionOf; + readonly pointerLockElement: Element; + /** + * Retrieves a value that indicates the current state of the object. + */ + readonly readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + readonly referrer: string; + /** + * Gets the root svg element in the document hierarchy. + */ + readonly rootElement: SVGSVGElement; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollectionOf; + readonly scrollingElement: Element | null; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + readonly styleSheets: StyleSheetList; + /** + * Contains the title of the document. + */ + title: string; + readonly visibilityState: VisibilityState; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + readonly webkitCurrentFullScreenElement: Element | null; + readonly webkitFullscreenElement: Element | null; + readonly webkitFullscreenEnabled: boolean; + readonly webkitIsFullScreen: boolean; + readonly xmlEncoding: string | null; + xmlStandalone: boolean; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string | null; + adoptNode(source: T): T; + captureEvents(): void; + caretRangeFromPoint(x: number, y: number): Range; + 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 | null, 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: K): HTMLElementTagNameMap[K]; + createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: 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 | null, 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: Window, 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 | null, type: number, result: XPathResult | null): 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 | null; + getElementsByClassName(classNames: string): HTMLCollectionOf; + /** + * 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: K): ElementListTagNameMap[K]; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + /** + * 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: T, deep: boolean): T; + msElementsFromPoint(x: number, y: number): NodeListOf; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; + /** + * 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; + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Document: { + prototype: Document; + new(): Document; +} + +interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; +} + +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface DocumentType extends Node, ChildNode { + readonly entities: NamedNodeMap; + readonly internalSubset: string | null; + readonly name: string; + readonly notations: NamedNodeMap; + readonly publicId: string; + readonly systemId: string; +} + +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface DragEvent extends MouseEvent { + readonly 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 { + readonly attack: AudioParam; + readonly knee: AudioParam; + readonly ratio: AudioParam; + readonly reduction: number; + readonly release: AudioParam; + readonly threshold: AudioParam; +} + +declare var DynamicsCompressorNode: { + prototype: DynamicsCompressorNode; + new(): DynamicsCompressorNode; +} + +interface EXT_frag_depth { +} + +declare var EXT_frag_depth: { + prototype: EXT_frag_depth; + new(): EXT_frag_depth; +} + +interface EXT_texture_filter_anisotropic { + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +interface ElementEventMap extends GlobalEventHandlersEventMap { + "ariarequest": Event; + "command": Event; + "gotpointercapture": PointerEvent; + "lostpointercapture": PointerEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSGotPointerCapture": MSPointerEvent; + "MSInertiaStart": MSGestureEvent; + "MSLostPointerCapture": MSPointerEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "touchcancel": TouchEvent; + "touchend": TouchEvent; + "touchmove": TouchEvent; + "touchstart": TouchEvent; + "webkitfullscreenchange": Event; + "webkitfullscreenerror": Event; +} + +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { + readonly classList: DOMTokenList; + className: string; + readonly clientHeight: number; + readonly clientLeft: number; + readonly clientTop: number; + readonly clientWidth: number; + id: string; + innerHTML: string; + msContentZoomFactor: number; + readonly msRegionOverflow: string; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; + ongotpointercapture: (this: Element, ev: PointerEvent) => any; + onlostpointercapture: (this: Element, ev: PointerEvent) => any; + onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Element, ev: MSGestureEvent) => any; + onmsgestureend: (this: Element, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Element, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Element, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Element, ev: MSGestureEvent) => any; + onmsgotpointercapture: (this: Element, ev: MSPointerEvent) => any; + onmsinertiastart: (this: Element, ev: MSGestureEvent) => any; + onmslostpointercapture: (this: Element, ev: MSPointerEvent) => any; + onmspointercancel: (this: Element, ev: MSPointerEvent) => any; + onmspointerdown: (this: Element, ev: MSPointerEvent) => any; + onmspointerenter: (this: Element, ev: MSPointerEvent) => any; + onmspointerleave: (this: Element, ev: MSPointerEvent) => any; + onmspointermove: (this: Element, ev: MSPointerEvent) => any; + onmspointerout: (this: Element, ev: MSPointerEvent) => any; + onmspointerover: (this: Element, ev: MSPointerEvent) => any; + onmspointerup: (this: Element, ev: MSPointerEvent) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onwebkitfullscreenchange: (this: Element, ev: Event) => any; + onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; + readonly prefix: string | null; + readonly scrollHeight: number; + scrollLeft: number; + scrollTop: number; + readonly scrollWidth: number; + readonly tagName: string; + readonly assignedSlot: HTMLSlotElement | null; + slot: string; + readonly shadowRoot: ShadowRoot | null; + getAttribute(name: string): string | null; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNode(name: string): Attr; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + getElementsByTagName(name: K): ElementListTagNameMap[K]; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + 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(qualifiedName: 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; + closest(selector: string): Element | null; + scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; + scroll(options?: ScrollToOptions): void; + scroll(x: number, y: number): void; + scrollTo(options?: ScrollToOptions): void; + scrollTo(x: number, y: number): void; + scrollBy(options?: ScrollToOptions): void; + scrollBy(x: number, y: number): void; + insertAdjacentElement(position: string, insertedElement: Element): Element | null; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; + attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot; + addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Element: { + prototype: Element; + new(): Element; +} + +interface ErrorEvent extends Event { + readonly colno: number; + readonly error: any; + readonly filename: string; + readonly lineno: number; + readonly message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} + +declare var ErrorEvent: { + prototype: ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; +} + +interface Event { + readonly bubbles: boolean; + cancelBubble: boolean; + readonly cancelable: boolean; + readonly currentTarget: EventTarget; + readonly defaultPrevented: boolean; + readonly eventPhase: number; + readonly isTrusted: boolean; + returnValue: boolean; + readonly srcElement: Element | null; + readonly target: EventTarget; + readonly timeStamp: number; + readonly type: string; + readonly scoped: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + preventDefault(): void; + stopImmediatePropagation(): void; + stopPropagation(): void; + deepPath(): EventTarget[]; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; +} + +declare var Event: { + prototype: Event; + new(typeArg: string, eventInitDict?: EventInit): Event; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; +} + +interface EventTarget { + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + dispatchEvent(evt: Event): boolean; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var EventTarget: { + prototype: EventTarget; + new(): EventTarget; +} + +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + +interface External { +} + +declare var External: { + prototype: External; + new(): External; +} + +interface File extends Blob { + readonly lastModifiedDate: any; + readonly name: string; + readonly webkitRelativePath: string; +} + +declare var File: { + prototype: File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; +} + +interface FileList { + readonly length: number; + item(index: number): File; + [index: number]: File; +} + +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface FileReader extends EventTarget, MSBaseReader { + readonly error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface FocusEvent extends UIEvent { + readonly 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 FocusNavigationEvent extends Event { + readonly navigationReason: NavigationReason; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + +interface FormData { + append(name: string, value: string | Blob, fileName?: string): void; + delete(name: string): void; + get(name: string): FormDataEntryValue | null; + getAll(name: string): FormDataEntryValue[]; + has(name: string): boolean; + set(name: string, value: string | Blob, fileName?: string): void; +} + +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface GainNode extends AudioNode { + readonly gain: AudioParam; +} + +declare var GainNode: { + prototype: GainNode; + new(): GainNode; +} + +interface Gamepad { + readonly axes: number[]; + readonly buttons: GamepadButton[]; + readonly connected: boolean; + readonly id: string; + readonly index: number; + readonly mapping: string; + readonly timestamp: number; +} + +declare var Gamepad: { + prototype: Gamepad; + new(): Gamepad; +} + +interface GamepadButton { + readonly pressed: boolean; + readonly value: number; +} + +declare var GamepadButton: { + prototype: GamepadButton; + new(): GamepadButton; +} + +interface GamepadEvent extends Event { + readonly gamepad: Gamepad; +} + +declare var GamepadEvent: { + prototype: GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): 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 { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: 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; + download: 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; + readonly mimeType: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + readonly 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; + readonly 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; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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. + */ + readonly 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; + readonly 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 | null; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + download: 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; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface HTMLAreasCollection extends HTMLCollectionBase { +} + +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface HTMLAudioElement extends HTMLMediaElement { + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLBodyElementEventMap extends HTMLElementEventMap { + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "load": Event; + "message": MessageEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; + "resize": UIEvent; + "scroll": UIEvent; + "storage": StorageEvent; + "unload": Event; +} + +interface HTMLBodyElement extends HTMLElement { + aLink: any; + background: string; + bgColor: any; + bgProperties: string; + link: any; + noWrap: boolean; + onafterprint: (this: HTMLBodyElement, ev: Event) => any; + onbeforeprint: (this: HTMLBodyElement, ev: Event) => any; + onbeforeunload: (this: HTMLBodyElement, ev: BeforeUnloadEvent) => any; + onblur: (this: HTMLBodyElement, ev: FocusEvent) => any; + onerror: (this: HTMLBodyElement, ev: ErrorEvent) => any; + onfocus: (this: HTMLBodyElement, ev: FocusEvent) => any; + onhashchange: (this: HTMLBodyElement, ev: HashChangeEvent) => any; + onload: (this: HTMLBodyElement, ev: Event) => any; + onmessage: (this: HTMLBodyElement, ev: MessageEvent) => any; + onoffline: (this: HTMLBodyElement, ev: Event) => any; + ononline: (this: HTMLBodyElement, ev: Event) => any; + onorientationchange: (this: HTMLBodyElement, ev: Event) => any; + onpagehide: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; + onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; + onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; + onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; + onunload: (this: HTMLBodyElement, ev: Event) => any; + text: any; + vLink: any; + addEventListener(type: K, listener: (this: HTMLBodyElement, ev: HTMLBodyElementEventMap[K]) => 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly 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: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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", contextAttributes?: Canvas2DContextAttributes): CanvasRenderingContext2D | null; + getContext(contextId: "webgl" | "experimental-webgl", contextAttributes?: WebGLContextAttributes): WebGLRenderingContext | null; + getContext(contextId: string, contextAttributes?: {}): CanvasRenderingContext2D | WebGLRenderingContext | null; + /** + * 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(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface HTMLCollectionBase { + /** + * Sets or retrieves the number of objects in a collection. + */ + readonly length: number; + /** + * Retrieves an object from various collections. + */ + item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element | null; +} + +declare var HTMLCollection: { + prototype: HTMLCollection; + new(): HTMLCollection; +} + +interface HTMLDListElement extends HTMLElement { + compact: boolean; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollectionOf; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface HTMLDirectoryElement extends HTMLElement { + compact: boolean; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface HTMLDocument extends Document { + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface HTMLElementEventMap extends ElementEventMap { + "abort": UIEvent; + "activate": UIEvent; + "beforeactivate": UIEvent; + "beforecopy": ClipboardEvent; + "beforecut": ClipboardEvent; + "beforedeactivate": UIEvent; + "beforepaste": ClipboardEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "contextmenu": PointerEvent; + "copy": ClipboardEvent; + "cuechange": Event; + "cut": ClipboardEvent; + "dblclick": MouseEvent; + "deactivate": UIEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "mousedown": MouseEvent; + "mouseenter": MouseEvent; + "mouseleave": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSContentZoom": UIEvent; + "MSManipulationStateChanged": MSManipulationEvent; + "paste": ClipboardEvent; + "pause": Event; + "play": Event; + "playing": Event; + "progress": ProgressEvent; + "ratechange": Event; + "reset": Event; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "selectstart": Event; + "stalled": Event; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "volumechange": Event; + "waiting": Event; +} + +interface HTMLElement extends Element { + accessKey: string; + readonly children: HTMLCollection; + contentEditable: string; + readonly dataset: DOMStringMap; + dir: string; + draggable: boolean; + hidden: boolean; + hideFocus: boolean; + innerText: string; + readonly isContentEditable: boolean; + lang: string; + readonly offsetHeight: number; + readonly offsetLeft: number; + readonly offsetParent: Element; + readonly offsetTop: number; + readonly offsetWidth: number; + onabort: (this: HTMLElement, ev: UIEvent) => any; + onactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforeactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforecopy: (this: HTMLElement, ev: ClipboardEvent) => any; + onbeforecut: (this: HTMLElement, ev: ClipboardEvent) => any; + onbeforedeactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforepaste: (this: HTMLElement, ev: ClipboardEvent) => any; + onblur: (this: HTMLElement, ev: FocusEvent) => any; + oncanplay: (this: HTMLElement, ev: Event) => any; + oncanplaythrough: (this: HTMLElement, ev: Event) => any; + onchange: (this: HTMLElement, ev: Event) => any; + onclick: (this: HTMLElement, ev: MouseEvent) => any; + oncontextmenu: (this: HTMLElement, ev: PointerEvent) => any; + oncopy: (this: HTMLElement, ev: ClipboardEvent) => any; + oncuechange: (this: HTMLElement, ev: Event) => any; + oncut: (this: HTMLElement, ev: ClipboardEvent) => any; + ondblclick: (this: HTMLElement, ev: MouseEvent) => any; + ondeactivate: (this: HTMLElement, ev: UIEvent) => any; + ondrag: (this: HTMLElement, ev: DragEvent) => any; + ondragend: (this: HTMLElement, ev: DragEvent) => any; + ondragenter: (this: HTMLElement, ev: DragEvent) => any; + ondragleave: (this: HTMLElement, ev: DragEvent) => any; + ondragover: (this: HTMLElement, ev: DragEvent) => any; + ondragstart: (this: HTMLElement, ev: DragEvent) => any; + ondrop: (this: HTMLElement, ev: DragEvent) => any; + ondurationchange: (this: HTMLElement, ev: Event) => any; + onemptied: (this: HTMLElement, ev: Event) => any; + onended: (this: HTMLElement, ev: MediaStreamErrorEvent) => any; + onerror: (this: HTMLElement, ev: ErrorEvent) => any; + onfocus: (this: HTMLElement, ev: FocusEvent) => any; + oninput: (this: HTMLElement, ev: Event) => any; + oninvalid: (this: HTMLElement, ev: Event) => any; + onkeydown: (this: HTMLElement, ev: KeyboardEvent) => any; + onkeypress: (this: HTMLElement, ev: KeyboardEvent) => any; + onkeyup: (this: HTMLElement, ev: KeyboardEvent) => any; + onload: (this: HTMLElement, ev: Event) => any; + onloadeddata: (this: HTMLElement, ev: Event) => any; + onloadedmetadata: (this: HTMLElement, ev: Event) => any; + onloadstart: (this: HTMLElement, ev: Event) => any; + onmousedown: (this: HTMLElement, ev: MouseEvent) => any; + onmouseenter: (this: HTMLElement, ev: MouseEvent) => any; + onmouseleave: (this: HTMLElement, ev: MouseEvent) => any; + onmousemove: (this: HTMLElement, ev: MouseEvent) => any; + onmouseout: (this: HTMLElement, ev: MouseEvent) => any; + onmouseover: (this: HTMLElement, ev: MouseEvent) => any; + onmouseup: (this: HTMLElement, ev: MouseEvent) => any; + onmousewheel: (this: HTMLElement, ev: WheelEvent) => any; + onmscontentzoom: (this: HTMLElement, ev: UIEvent) => any; + onmsmanipulationstatechanged: (this: HTMLElement, ev: MSManipulationEvent) => any; + onpaste: (this: HTMLElement, ev: ClipboardEvent) => any; + onpause: (this: HTMLElement, ev: Event) => any; + onplay: (this: HTMLElement, ev: Event) => any; + onplaying: (this: HTMLElement, ev: Event) => any; + onprogress: (this: HTMLElement, ev: ProgressEvent) => any; + onratechange: (this: HTMLElement, ev: Event) => any; + onreset: (this: HTMLElement, ev: Event) => any; + onscroll: (this: HTMLElement, ev: UIEvent) => any; + onseeked: (this: HTMLElement, ev: Event) => any; + onseeking: (this: HTMLElement, ev: Event) => any; + onselect: (this: HTMLElement, ev: UIEvent) => any; + onselectstart: (this: HTMLElement, ev: Event) => any; + onstalled: (this: HTMLElement, ev: Event) => any; + onsubmit: (this: HTMLElement, ev: Event) => any; + onsuspend: (this: HTMLElement, ev: Event) => any; + ontimeupdate: (this: HTMLElement, ev: Event) => any; + onvolumechange: (this: HTMLElement, ev: Event) => any; + onwaiting: (this: HTMLElement, ev: Event) => any; + outerText: string; + spellcheck: boolean; + readonly style: CSSStyleDeclaration; + tabIndex: number; + title: string; + blur(): void; + click(): void; + dragDrop(): boolean; + focus(): void; + msGetInputContext(): MSInputMethodContext; + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the palette used for the embedded document. + */ + readonly palette: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + readonly pluginspage: string; + readonly 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: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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. + */ + readonly form: HTMLFormElement; + name: 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + readonly 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: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + +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. + */ + readonly elements: HTMLFormControlsCollection; + /** + * 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. + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [name: string]: any; +} + +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface HTMLFrameElementEventMap extends HTMLElementEventMap { + "load": Event; +} + +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. + */ + readonly contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + readonly 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: (this: HTMLFrameElement, ev: Event) => any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * 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: K, listener: (this: HTMLFrameElement, ev: HTMLFrameElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "load": Event; + "message": MessageEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; + "resize": UIEvent; + "scroll": UIEvent; + "storage": StorageEvent; + "unload": Event; +} + +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: (this: HTMLFrameSetElement, ev: Event) => any; + onbeforeprint: (this: HTMLFrameSetElement, ev: Event) => any; + onbeforeunload: (this: HTMLFrameSetElement, ev: BeforeUnloadEvent) => any; + /** + * Fires when the object loses the input focus. + */ + onblur: (this: HTMLFrameSetElement, ev: FocusEvent) => any; + onerror: (this: HTMLFrameSetElement, ev: ErrorEvent) => any; + /** + * Fires when the object receives focus. + */ + onfocus: (this: HTMLFrameSetElement, ev: FocusEvent) => any; + onhashchange: (this: HTMLFrameSetElement, ev: HashChangeEvent) => any; + onload: (this: HTMLFrameSetElement, ev: Event) => any; + onmessage: (this: HTMLFrameSetElement, ev: MessageEvent) => any; + onoffline: (this: HTMLFrameSetElement, ev: Event) => any; + ononline: (this: HTMLFrameSetElement, ev: Event) => any; + onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; + onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; + onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; + onunload: (this: HTMLFrameSetElement, ev: Event) => any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => 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: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface HTMLIFrameElementEventMap extends HTMLElementEventMap { + "load": Event; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + allowFullscreen: boolean; + allowPaymentRequest: boolean; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + readonly contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + readonly 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: (this: HTMLIFrameElement, ev: Event) => any; + readonly sandbox: DOMSettableTokenList; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * 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: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => 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. + */ + readonly complete: boolean; + crossOrigin: string | null; + readonly 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; + lowsrc: 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * The original height of the image resource before sizing. + */ + readonly naturalHeight: number; + /** + * The original width of the image resource before sizing. + */ + readonly naturalWidth: number; + sizes: string; + /** + * 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; + readonly x: number; + readonly y: number; + msGetAsCastingSource(): any; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): 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. + */ + readonly 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. + */ + readonly files: FileList | null; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly 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. + */ + readonly 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; + selectionDirection: string; + /** + * 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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; + webkitdirectory: boolean; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + readonly willValidate: boolean; + minLength: number; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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, direction?: string): 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; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLLIElement extends HTMLElement { + type: string; + /** + * Sets or retrieves the value of a list item. + */ + value: number; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface HTMLLabelElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly form: HTMLFormElement; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + import?: Document; + integrity: string; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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. + */ + readonly areas: HTMLAreasCollection; + /** + * Sets or retrieves the name of the object. + */ + name: string; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMarqueeElementEventMap extends HTMLElementEventMap { + "bounce": Event; + "finish": Event; + "start": Event; +} + +interface HTMLMarqueeElement extends HTMLElement { + behavior: string; + bgColor: any; + direction: string; + height: string; + hspace: number; + loop: number; + onbounce: (this: HTMLMarqueeElement, ev: Event) => any; + onfinish: (this: HTMLMarqueeElement, ev: Event) => any; + onstart: (this: HTMLMarqueeElement, ev: Event) => any; + scrollAmount: number; + scrollDelay: number; + trueSpeed: boolean; + vspace: number; + width: string; + start(): void; + stop(): void; + addEventListener(type: K, listener: (this: HTMLMarqueeElement, ev: HTMLMarqueeElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface HTMLMediaElementEventMap extends HTMLElementEventMap { + "encrypted": MediaEncryptedEvent; + "msneedkey": MSMediaKeyNeededEvent; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + readonly 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. + */ + readonly 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; + crossOrigin: string | null; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + readonly 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. + */ + readonly duration: number; + /** + * Gets information about whether the playback has ended or not. + */ + readonly ended: boolean; + /** + * Returns an object representing the current error state of the audio or video element. + */ + readonly error: MediaError; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + readonly mediaKeys: MediaKeys | null; + /** + * 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; + readonly msGraphicsTrustStatus: MSGraphicsTrust; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + readonly 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. + */ + readonly 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. + */ + readonly networkState: number; + onencrypted: (this: HTMLMediaElement, ev: MediaEncryptedEvent) => any; + onmsneedkey: (this: HTMLMediaElement, ev: MSMediaKeyNeededEvent) => any; + /** + * Gets a flag that specifies whether playback is paused. + */ + readonly 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. + */ + readonly 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. + */ + readonly seekable: TimeRanges; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + readonly seeking: boolean; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcObject: MediaStream | null; + readonly textTracks: TextTrackList; + readonly 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; + /** + * Resets the audio or video object and loads a new media resource. + */ + 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; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; + addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; +} + +interface HTMLMenuElement extends HTMLElement { + compact: boolean; + type: string; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface HTMLMeterElement extends HTMLElement { + high: number; + low: number; + max: number; + min: number; + optimum: number; + value: number; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMeterElement: { + prototype: HTMLMeterElement; + new(): HTMLMeterElement; +} + +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; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface HTMLOListElement extends HTMLElement { + compact: boolean; + /** + * The starting number. + */ + start: number; + type: string; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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. + */ + readonly 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. + */ + readonly 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly 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: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): 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. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + readonly 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. + */ + readonly text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; +} + +interface HTMLOptionsCollection extends HTMLCollectionOf { + length: number; + selectedIndex: number; + add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void; + remove(index: number): void; +} + +declare var HTMLOptionsCollection: { + prototype: HTMLOptionsCollection; + new(): HTMLOptionsCollection; +} + +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + +interface HTMLParagraphElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + clear: string; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface HTMLPictureElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + +interface HTMLPreElement extends HTMLElement { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly 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). + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + crossOrigin: string | null; + /** + * 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; + integrity: string; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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; + readonly options: HTMLOptionsCollection; + /** + * 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; + selectedOptions: HTMLCollectionOf; + /** + * 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly willValidate: boolean; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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; + sizes: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcset: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface HTMLSpanElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + disabled: boolean; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: HTMLCollectionOf; + /** + * 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: HTMLCollectionOf; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: HTMLCollectionOf; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the position of the object in the rows collection for the table. + */ + readonly rowIndex: number; + /** + * Retrieves the position of the object in the collection. + */ + readonly 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): HTMLTableDataCellElement; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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: HTMLCollectionOf; + /** + * 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: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface HTMLTemplateElement extends HTMLElement { + readonly content: DocumentFragment; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + +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. + */ + readonly 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly willValidate: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + minLength: number; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLTrackElement extends HTMLElement { + default: boolean; + kind: string; + label: string; + readonly readyState: number; + src: string; + srclang: string; + readonly track: TextTrack; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; +} + +interface HTMLUListElement extends HTMLElement { + compact: boolean; + type: string; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface HTMLUnknownElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLVideoElementEventMap extends HTMLMediaElementEventMap { + "MSVideoFormatChanged": Event; + "MSVideoFrameStepCompleted": Event; + "MSVideoOptimalLayoutChanged": Event; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the height of the video element. + */ + height: number; + msHorizontalMirror: boolean; + readonly msIsLayoutOptimalForPlayback: boolean; + readonly msIsStereo3D: boolean; + msStereo3DPackingMode: string; + msStereo3DRenderMode: string; + msZoom: boolean; + onMSVideoFormatChanged: (this: HTMLVideoElement, ev: Event) => any; + onMSVideoFrameStepCompleted: (this: HTMLVideoElement, ev: Event) => any; + onMSVideoOptimalLayoutChanged: (this: HTMLVideoElement, 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. + */ + readonly videoHeight: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + readonly videoWidth: number; + readonly webkitDisplayingFullscreen: boolean; + readonly 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: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface HashChangeEvent extends Event { + readonly newURL: string | null; + readonly oldURL: string | null; +} + +declare var HashChangeEvent: { + prototype: HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; +} + +interface History { + readonly length: number; + readonly state: any; + scrollRestoration: ScrollRestoration; + back(): void; + forward(): void; + go(delta?: number): void; + pushState(data: any, title: string, url?: string | null): void; + replaceState(data: any, title: string, url?: string | null): void; +} + +declare var History: { + prototype: History; + new(): History; +} + +interface IDBCursor { + readonly direction: IDBCursorDirection; + key: IDBKeyRange | IDBValidKey; + readonly primaryKey: any; + source: IDBObjectStore | IDBIndex; + advance(count: number): void; + continue(key?: IDBKeyRange | IDBValidKey): void; + delete(): IDBRequest; + update(value: any): IDBRequest; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; +} + +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; +} + +interface IDBCursorWithValue extends IDBCursor { + readonly value: any; +} + +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface IDBDatabaseEventMap { + "abort": Event; + "error": Event; +} + +interface IDBDatabase extends EventTarget { + readonly name: string; + readonly objectStoreNames: DOMStringList; + onabort: (this: IDBDatabase, ev: Event) => any; + onerror: (this: IDBDatabase, ev: Event) => any; + version: number; + onversionchange: (ev: IDBVersionChangeEvent) => any; + close(): void; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; + deleteObjectStore(name: string): void; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; + addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => 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[]; + readonly name: string; + readonly objectStore: IDBObjectStore; + readonly unique: boolean; + multiEntry: boolean; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + get(key: IDBKeyRange | IDBValidKey): IDBRequest; + getKey(key: IDBKeyRange | IDBValidKey): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; +} + +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface IDBKeyRange { + readonly lower: any; + readonly lowerOpen: boolean; + readonly upper: any; + readonly upperOpen: boolean; +} + +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + lowerBound(lower: any, open?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + upperBound(upper: any, open?: boolean): IDBKeyRange; +} + +interface IDBObjectStore { + readonly indexNames: DOMStringList; + keyPath: string | string[]; + readonly name: string; + readonly transaction: IDBTransaction; + autoIncrement: boolean; + add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; + clear(): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; + delete(key: IDBKeyRange | IDBValidKey): IDBRequest; + deleteIndex(indexName: string): void; + get(key: any): IDBRequest; + index(name: string): IDBIndex; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; +} + +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface IDBOpenDBRequestEventMap extends IDBRequestEventMap { + "blocked": Event; + "upgradeneeded": IDBVersionChangeEvent; +} + +interface IDBOpenDBRequest extends IDBRequest { + onblocked: (this: IDBOpenDBRequest, ev: Event) => any; + onupgradeneeded: (this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any; + addEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface IDBRequestEventMap { + "error": Event; + "success": Event; +} + +interface IDBRequest extends EventTarget { + readonly error: DOMError; + onerror: (this: IDBRequest, ev: Event) => any; + onsuccess: (this: IDBRequest, ev: Event) => any; + readonly readyState: IDBRequestReadyState; + readonly result: any; + source: IDBObjectStore | IDBIndex | IDBCursor; + readonly transaction: IDBTransaction; + addEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface IDBTransactionEventMap { + "abort": Event; + "complete": Event; + "error": Event; +} + +interface IDBTransaction extends EventTarget { + readonly db: IDBDatabase; + readonly error: DOMError; + readonly mode: IDBTransactionMode; + onabort: (this: IDBTransaction, ev: Event) => any; + oncomplete: (this: IDBTransaction, ev: Event) => any; + onerror: (this: IDBTransaction, ev: Event) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; + addEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; +} + +interface IDBVersionChangeEvent extends Event { + readonly newVersion: number | null; + readonly oldVersion: number; +} + +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + +interface ImageData { + data: Uint8ClampedArray; + readonly height: number; + readonly width: number; +} + +declare var ImageData: { + prototype: ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; +} + +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + +interface KeyboardEvent extends UIEvent { + readonly altKey: boolean; + readonly char: string | null; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly key: string; + readonly keyCode: number; + readonly locale: string; + readonly location: number; + readonly metaKey: boolean; + readonly repeat: boolean; + readonly shiftKey: boolean; + readonly which: number; + readonly code: string; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; +} + +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; +} + +interface ListeningStateChangedEvent extends Event { + readonly label: string; + readonly state: ListeningState; +} + +declare var ListeningStateChangedEvent: { + prototype: ListeningStateChangedEvent; + new(): ListeningStateChangedEvent; +} + +interface Location { + hash: string; + host: string; + hostname: string; + href: string; + readonly 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 { + readonly 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): Promise; + getViewId(view: any): any; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + pageHandlesAllApplicationActivations(enabled: boolean): void; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + terminateApp(exceptionObject: any): void; + readonly CURRENT: string; + readonly HIGH: string; + readonly IDLE: string; + readonly NORMAL: string; +} +declare var MSApp: MSApp; + +interface MSAppAsyncOperationEventMap { + "complete": Event; + "error": Event; +} + +interface MSAppAsyncOperation extends EventTarget { + readonly error: DOMError; + oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; + readonly readyState: number; + readonly result: any; + start(): void; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; +} + +interface MSAssertion { + readonly id: string; + readonly type: MSCredentialType; +} + +declare var MSAssertion: { + prototype: MSAssertion; + new(): MSAssertion; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} + +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface MSCredentials { + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; +} + +declare var MSCredentials: { + prototype: MSCredentials; + new(): MSCredentials; +} + +interface MSFIDOCredentialAssertion extends MSAssertion { + readonly algorithm: string | Algorithm; + readonly attestation: any; + readonly publicKey: string; + readonly transportHints: MSTransportType[]; +} + +declare var MSFIDOCredentialAssertion: { + prototype: MSFIDOCredentialAssertion; + new(): MSFIDOCredentialAssertion; +} + +interface MSFIDOSignature { + readonly authnrData: string; + readonly clientData: string; + readonly signature: string; +} + +declare var MSFIDOSignature: { + prototype: MSFIDOSignature; + new(): MSFIDOSignature; +} + +interface MSFIDOSignatureAssertion extends MSAssertion { + readonly signature: MSFIDOSignature; +} + +declare var MSFIDOSignatureAssertion: { + prototype: MSFIDOSignatureAssertion; + new(): MSFIDOSignatureAssertion; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} + +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface MSGestureEvent extends UIEvent { + readonly clientX: number; + readonly clientY: number; + readonly expansion: number; + readonly gestureObject: any; + readonly hwTimestamp: number; + readonly offsetX: number; + readonly offsetY: number; + readonly rotation: number; + readonly scale: number; + readonly screenX: number; + readonly screenY: number; + readonly translationX: number; + readonly translationY: number; + readonly velocityAngular: number; + readonly velocityExpansion: number; + readonly velocityX: number; + readonly 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; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; +} + +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; +} + +interface MSGraphicsTrust { + readonly constrictionActive: boolean; + readonly status: string; +} + +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface MSHTMLWebViewElement extends HTMLElement { + readonly canGoBack: boolean; + readonly canGoForward: boolean; + readonly containsFullScreenElement: boolean; + readonly documentTitle: string; + height: number; + readonly 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; + navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + navigateToString(contents: string): void; + navigateWithHttpRequestMessage(requestMessage: any): void; + refresh(): void; + stop(): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface MSInputMethodContextEventMap { + "MSCandidateWindowHide": Event; + "MSCandidateWindowShow": Event; + "MSCandidateWindowUpdate": Event; +} + +interface MSInputMethodContext extends EventTarget { + readonly compositionEndOffset: number; + readonly compositionStartOffset: number; + oncandidatewindowhide: (this: MSInputMethodContext, ev: Event) => any; + oncandidatewindowshow: (this: MSInputMethodContext, ev: Event) => any; + oncandidatewindowupdate: (this: MSInputMethodContext, ev: Event) => any; + readonly target: HTMLElement; + getCandidateWindowClientRect(): ClientRect; + getCompositionAlternatives(): string[]; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: K, listener: (this: MSInputMethodContext, ev: MSInputMethodContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface MSManipulationEvent extends UIEvent { + readonly currentState: number; + readonly inertiaDestinationX: number; + readonly inertiaDestinationY: number; + readonly lastState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; +} + +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; +} + +interface MSMediaKeyError { + readonly code: number; + readonly systemCode: number; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; +} + +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; +} + +interface MSMediaKeyMessageEvent extends Event { + readonly destinationURL: string | null; + readonly message: Uint8Array; +} + +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSMediaKeyNeededEvent extends Event { + readonly initData: Uint8Array | null; +} + +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface MSMediaKeySession extends EventTarget { + readonly error: MSMediaKeyError | null; + readonly keySystem: string; + readonly sessionId: string; + close(): void; + update(key: Uint8Array): void; +} + +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface MSMediaKeys { + readonly 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; + isTypeSupportedWithFeatures(keySystem: string, type?: string): string; +} + +interface MSPointerEvent extends MouseEvent { + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly 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 { + readonly length: number; + item(index: number): Range; + [index: number]: Range; +} + +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface MSSiteModeEvent extends Event { + readonly actionURL: string; + readonly buttonID: number; +} + +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface MSStream { + readonly type: string; + msClose(): void; + msDetachStream(): any; +} + +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSStreamReader extends EventTarget, MSBaseReader { + readonly 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: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface MSWebViewAsyncOperationEventMap { + "complete": Event; + "error": Event; +} + +interface MSWebViewAsyncOperation extends EventTarget { + readonly error: DOMError; + oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; + readonly readyState: number; + readonly result: any; + readonly target: MSHTMLWebViewElement; + readonly type: number; + start(): void; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; + addEventListener(type: K, listener: (this: MSWebViewAsyncOperation, ev: MSWebViewAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; +} + +interface MSWebViewSettings { + isIndexedDBEnabled: boolean; + isJavaScriptEnabled: boolean; +} + +declare var MSWebViewSettings: { + prototype: MSWebViewSettings; + new(): MSWebViewSettings; +} + +interface MediaDeviceInfo { + readonly deviceId: string; + readonly groupId: string; + readonly kind: MediaDeviceKind; + readonly label: string; +} + +declare var MediaDeviceInfo: { + prototype: MediaDeviceInfo; + new(): MediaDeviceInfo; +} + +interface MediaDevicesEventMap { + "devicechange": Event; +} + +interface MediaDevices extends EventTarget { + ondevicechange: (this: MediaDevices, ev: Event) => any; + enumerateDevices(): any; + getSupportedConstraints(): MediaTrackSupportedConstraints; + getUserMedia(constraints: MediaStreamConstraints): Promise; + addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaDevices: { + prototype: MediaDevices; + new(): MediaDevices; +} + +interface MediaElementAudioSourceNode extends AudioNode { +} + +declare var MediaElementAudioSourceNode: { + prototype: MediaElementAudioSourceNode; + new(): MediaElementAudioSourceNode; +} + +interface MediaEncryptedEvent extends Event { + readonly initData: ArrayBuffer | null; + readonly initDataType: string; +} + +declare var MediaEncryptedEvent: { + prototype: MediaEncryptedEvent; + new(type: string, eventInitDict?: MediaEncryptedEventInit): MediaEncryptedEvent; +} + +interface MediaError { + readonly code: number; + readonly msExtendedCode: number; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; +} + +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface MediaKeyMessageEvent extends Event { + readonly message: ArrayBuffer; + readonly messageType: MediaKeyMessageType; +} + +declare var MediaKeyMessageEvent: { + prototype: MediaKeyMessageEvent; + new(type: string, eventInitDict?: MediaKeyMessageEventInit): MediaKeyMessageEvent; +} + +interface MediaKeySession extends EventTarget { + readonly closed: Promise; + readonly expiration: number; + readonly keyStatuses: MediaKeyStatusMap; + readonly sessionId: string; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; +} + +declare var MediaKeySession: { + prototype: MediaKeySession; + new(): MediaKeySession; +} + +interface MediaKeyStatusMap { + readonly size: number; + forEach(callback: ForEachCallback): void; + get(keyId: any): MediaKeyStatus; + has(keyId: any): boolean; +} + +declare var MediaKeyStatusMap: { + prototype: MediaKeyStatusMap; + new(): MediaKeyStatusMap; +} + +interface MediaKeySystemAccess { + readonly keySystem: string; + createMediaKeys(): Promise; + getConfiguration(): MediaKeySystemConfiguration; +} + +declare var MediaKeySystemAccess: { + prototype: MediaKeySystemAccess; + new(): MediaKeySystemAccess; +} + +interface MediaKeys { + createSession(sessionType?: MediaKeySessionType): MediaKeySession; + setServerCertificate(serverCertificate: any): Promise; +} + +declare var MediaKeys: { + prototype: MediaKeys; + new(): MediaKeys; +} + +interface MediaList { + readonly 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 { + readonly matches: boolean; + readonly media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface MediaSource extends EventTarget { + readonly activeSourceBuffers: SourceBufferList; + duration: number; + readonly readyState: string; + readonly 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 MediaStreamEventMap { + "active": Event; + "addtrack": MediaStreamTrackEvent; + "inactive": Event; + "removetrack": MediaStreamTrackEvent; +} + +interface MediaStream extends EventTarget { + readonly active: boolean; + readonly id: string; + onactive: (this: MediaStream, ev: Event) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; + oninactive: (this: MediaStream, ev: Event) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; + addTrack(track: MediaStreamTrack): void; + clone(): MediaStream; + getAudioTracks(): MediaStreamTrack[]; + getTrackById(trackId: string): MediaStreamTrack | null; + getTracks(): MediaStreamTrack[]; + getVideoTracks(): MediaStreamTrack[]; + removeTrack(track: MediaStreamTrack): void; + stop(): void; + addEventListener(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStream: { + prototype: MediaStream; + new(streamOrTracks?: MediaStream | MediaStreamTrack[]): MediaStream; +} + +interface MediaStreamAudioSourceNode extends AudioNode { +} + +declare var MediaStreamAudioSourceNode: { + prototype: MediaStreamAudioSourceNode; + new(): MediaStreamAudioSourceNode; +} + +interface MediaStreamError { + readonly constraintName: string | null; + readonly message: string | null; + readonly name: string; +} + +declare var MediaStreamError: { + prototype: MediaStreamError; + new(): MediaStreamError; +} + +interface MediaStreamErrorEvent extends Event { + readonly error: MediaStreamError | null; +} + +declare var MediaStreamErrorEvent: { + prototype: MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; +} + +interface MediaStreamTrackEventMap { + "ended": MediaStreamErrorEvent; + "mute": Event; + "overconstrained": MediaStreamErrorEvent; + "unmute": Event; +} + +interface MediaStreamTrack extends EventTarget { + enabled: boolean; + readonly id: string; + readonly kind: string; + readonly label: string; + readonly muted: boolean; + onended: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; + onmute: (this: MediaStreamTrack, ev: Event) => any; + onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; + onunmute: (this: MediaStreamTrack, ev: Event) => any; + readonly readonly: boolean; + readonly readyState: MediaStreamTrackState; + readonly remote: boolean; + applyConstraints(constraints: MediaTrackConstraints): Promise; + clone(): MediaStreamTrack; + getCapabilities(): MediaTrackCapabilities; + getConstraints(): MediaTrackConstraints; + getSettings(): MediaTrackSettings; + stop(): void; + addEventListener(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStreamTrack: { + prototype: MediaStreamTrack; + new(): MediaStreamTrack; +} + +interface MediaStreamTrackEvent extends Event { + readonly track: MediaStreamTrack; +} + +declare var MediaStreamTrackEvent: { + prototype: MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; +} + +interface MessageChannel { + readonly port1: MessagePort; + readonly port2: MessagePort; +} + +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface MessageEvent extends Event { + readonly data: any; + readonly origin: string; + readonly ports: any; + readonly 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 MessagePortEventMap { + "message": MessageEvent; +} + +interface MessagePort extends EventTarget { + onmessage: (this: MessagePort, ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, transfer?: any[]): void; + start(): void; + addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface MimeType { + readonly description: string; + readonly enabledPlugin: Plugin; + readonly suffixes: string; + readonly type: string; +} + +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface MimeTypeArray { + readonly length: number; + item(index: number): Plugin; + namedItem(type: string): Plugin; + [index: number]: Plugin; +} + +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface MouseEvent extends UIEvent { + readonly altKey: boolean; + readonly button: number; + readonly buttons: number; + readonly clientX: number; + readonly clientY: number; + readonly ctrlKey: boolean; + readonly fromElement: Element; + readonly layerX: number; + readonly layerY: number; + readonly metaKey: boolean; + readonly movementX: number; + readonly movementY: number; + readonly offsetX: number; + readonly offsetY: number; + readonly pageX: number; + readonly pageY: number; + readonly relatedTarget: EventTarget; + readonly screenX: number; + readonly screenY: number; + readonly shiftKey: boolean; + readonly toElement: Element; + readonly which: number; + readonly x: number; + readonly 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 | null): void; +} + +declare var MouseEvent: { + prototype: MouseEvent; + new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; +} + +interface MutationEvent extends Event { + readonly attrChange: number; + readonly attrName: string; + readonly newValue: string; + readonly prevValue: string; + readonly relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly REMOVAL: number; +} + +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly 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 { + readonly addedNodes: NodeList; + readonly attributeName: string | null; + readonly attributeNamespace: string | null; + readonly nextSibling: Node | null; + readonly oldValue: string | null; + readonly previousSibling: Node | null; + readonly removedNodes: NodeList; + readonly target: Node; + readonly type: string; +} + +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface NamedNodeMap { + readonly length: number; + getNamedItem(name: string): Attr; + getNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; + item(index: number): Attr; + removeNamedItem(name: string): Attr; + removeNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; + setNamedItem(arg: Attr): Attr; + setNamedItemNS(arg: Attr): Attr; + [index: number]: Attr; +} + +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface NavigationCompletedEvent extends NavigationEvent { + readonly isSuccess: boolean; + readonly webErrorStatus: number; +} + +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface NavigationEvent extends Event { + readonly uri: string; +} + +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +interface NavigationEventWithReferrer extends NavigationEvent { + readonly referer: string; +} + +declare var NavigationEventWithReferrer: { + prototype: NavigationEventWithReferrer; + new(): NavigationEventWithReferrer; +} + +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; + readonly cookieEnabled: boolean; + gamepadInputEmulation: GamepadInputEmulationType; + readonly language: string; + readonly maxTouchPoints: number; + readonly mimeTypes: MimeTypeArray; + readonly msManipulationViewsEnabled: boolean; + readonly msMaxTouchPoints: number; + readonly msPointerEnabled: boolean; + readonly plugins: PluginArray; + readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; + readonly webdriver: boolean; + readonly hardwareConcurrency: number; + getGamepads(): Gamepad[]; + javaEnabled(): boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; + vibrate(pattern: number | number[]): boolean; +} + +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface Node extends EventTarget { + readonly attributes: NamedNodeMap; + readonly baseURI: string | null; + readonly childNodes: NodeList; + readonly firstChild: Node | null; + readonly lastChild: Node | null; + readonly localName: string | null; + readonly namespaceURI: string | null; + readonly nextSibling: Node | null; + readonly nodeName: string; + readonly nodeType: number; + nodeValue: string | null; + readonly ownerDocument: Document; + readonly parentElement: HTMLElement | null; + readonly parentNode: Node | null; + readonly previousSibling: Node | null; + textContent: string | null; + appendChild(newChild: T): T; + cloneNode(deep?: boolean): Node; + compareDocumentPosition(other: Node): number; + contains(child: Node): boolean; + hasAttributes(): boolean; + hasChildNodes(): boolean; + insertBefore(newChild: T, refChild: Node | null): T; + isDefaultNamespace(namespaceURI: string | null): boolean; + isEqualNode(arg: Node): boolean; + isSameNode(other: Node): boolean; + lookupNamespaceURI(prefix: string | null): string | null; + lookupPrefix(namespaceURI: string | null): string | null; + normalize(): void; + removeChild(oldChild: T): T; + replaceChild(newChild: Node, oldChild: T): T; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; +} + +declare var Node: { + prototype: Node; + new(): Node; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { + readonly FILTER_ACCEPT: number; + readonly FILTER_REJECT: number; + readonly FILTER_SKIP: number; + readonly SHOW_ALL: number; + readonly SHOW_ATTRIBUTE: number; + readonly SHOW_CDATA_SECTION: number; + readonly SHOW_COMMENT: number; + readonly SHOW_DOCUMENT: number; + readonly SHOW_DOCUMENT_FRAGMENT: number; + readonly SHOW_DOCUMENT_TYPE: number; + readonly SHOW_ELEMENT: number; + readonly SHOW_ENTITY: number; + readonly SHOW_ENTITY_REFERENCE: number; + readonly SHOW_NOTATION: number; + readonly SHOW_PROCESSING_INSTRUCTION: number; + readonly SHOW_TEXT: number; +} + +interface NodeIterator { + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly whatToShow: number; + detach(): void; + nextNode(): Node; + previousNode(): Node; +} + +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface NodeList { + readonly length: number; + item(index: number): Node; + [index: number]: Node; +} + +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: NotificationDirection; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: NotificationPermission; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + +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 { + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + readonly 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 OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + +interface OfflineAudioCompletionEvent extends Event { + readonly renderedBuffer: AudioBuffer; +} + +declare var OfflineAudioCompletionEvent: { + prototype: OfflineAudioCompletionEvent; + new(): OfflineAudioCompletionEvent; +} + +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; +} + +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; + addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => 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 OscillatorNodeEventMap { + "ended": MediaStreamErrorEvent; +} + +interface OscillatorNode extends AudioNode { + readonly detune: AudioParam; + readonly frequency: AudioParam; + onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any; + type: OscillatorType; + setPeriodicWave(periodicWave: PeriodicWave): void; + start(when?: number): void; + stop(when?: number): void; + addEventListener(type: K, listener: (this: OscillatorNode, ev: OscillatorNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OscillatorNode: { + prototype: OscillatorNode; + new(): OscillatorNode; +} + +interface OverflowEvent extends UIEvent { + readonly horizontalOverflow: boolean; + readonly orient: number; + readonly verticalOverflow: boolean; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; +} + +declare var OverflowEvent: { + prototype: OverflowEvent; + new(): OverflowEvent; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; +} + +interface PageTransitionEvent extends Event { + readonly persisted: boolean; +} + +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface PannerNode extends AudioNode { + coneInnerAngle: number; + coneOuterAngle: number; + coneOuterGain: number; + distanceModel: DistanceModelType; + maxDistance: number; + panningModel: PanningModelType; + 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 Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: PaymentShippingType | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: PaymentComplete): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + +interface PerfWidgetExternal { + readonly activeNetworkRequestCount: number; + readonly averageFrameTime: number; + readonly averagePaintTime: number; + readonly extraInformationEnabled: boolean; + readonly independentRenderingEnabled: boolean; + readonly irDisablingContentString: string; + readonly irStatusAvailable: boolean; + readonly maxCpuSpeed: number; + readonly paintRequestsPerSecond: number; + readonly performanceCounter: number; + readonly performanceCounterFrequency: number; + addEventListener(eventType: string, callback: Function): void; + getMemoryUsage(): number; + getProcessCpuUsage(): number; + getRecentCpuUsage(last: number | null): any; + getRecentFrames(last: number | null): any; + getRecentMemoryUsage(last: number | null): any; + getRecentPaintRequests(last: number | null): 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 { + readonly navigation: PerformanceNavigation; + readonly 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 { + readonly duration: number; + readonly entryType: string; + readonly name: string; + readonly 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 { + readonly redirectCount: number; + readonly type: number; + toJSON(): any; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly navigationStart: number; + readonly redirectCount: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly type: NavigationType; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; +} + +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + readonly connectEnd: number; + readonly connectStart: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly initiatorType: string; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; +} + +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface PerformanceTiming { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; + readonly secureConnectionStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface PeriodicWave { +} + +declare var PeriodicWave: { + prototype: PeriodicWave; + new(): PeriodicWave; +} + +interface PermissionRequest extends DeferredPermissionRequest { + readonly state: MSWebViewPermissionState; + defer(): void; +} + +declare var PermissionRequest: { + prototype: PermissionRequest; + new(): PermissionRequest; +} + +interface PermissionRequestedEvent extends Event { + readonly permissionRequest: PermissionRequest; +} + +declare var PermissionRequestedEvent: { + prototype: PermissionRequestedEvent; + new(): PermissionRequestedEvent; +} + +interface Plugin { + readonly description: string; + readonly filename: string; + readonly length: number; + readonly name: string; + readonly version: string; + item(index: number): MimeType; + namedItem(type: string): MimeType; + [index: number]: MimeType; +} + +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface PluginArray { + readonly 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 { + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly 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 { + readonly state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +declare var PopStateEvent: { + prototype: PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; +} + +interface Position { + readonly coords: Coordinates; + readonly timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + readonly code: number; + readonly message: string; + toString(): string; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; +} + +interface ProcessingInstruction extends CharacterData { + readonly target: string; +} + +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface ProgressEvent extends Event { + readonly lengthComputable: boolean; + readonly loaded: number; + readonly 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 PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + +interface RTCDTMFToneChangeEvent extends Event { + readonly tone: string; +} + +declare var RTCDTMFToneChangeEvent: { + prototype: RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; +} + +interface RTCDtlsTransportEventMap { + "dtlsstatechange": RTCDtlsTransportStateChangedEvent; + "error": Event; +} + +interface RTCDtlsTransport extends RTCStatsProvider { + ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; + readonly state: RTCDtlsTransportState; + readonly transport: RTCIceTransport; + getLocalParameters(): RTCDtlsParameters; + getRemoteCertificates(): ArrayBuffer[]; + getRemoteParameters(): RTCDtlsParameters | null; + start(remoteParameters: RTCDtlsParameters): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtlsTransport: { + prototype: RTCDtlsTransport; + new(transport: RTCIceTransport): RTCDtlsTransport; +} + +interface RTCDtlsTransportStateChangedEvent extends Event { + readonly state: RTCDtlsTransportState; +} + +declare var RTCDtlsTransportStateChangedEvent: { + prototype: RTCDtlsTransportStateChangedEvent; + new(): RTCDtlsTransportStateChangedEvent; +} + +interface RTCDtmfSenderEventMap { + "tonechange": RTCDTMFToneChangeEvent; +} + +interface RTCDtmfSender extends EventTarget { + readonly canInsertDTMF: boolean; + readonly duration: number; + readonly interToneGap: number; + ontonechange: (this: RTCDtmfSender, ev: RTCDTMFToneChangeEvent) => any; + readonly sender: RTCRtpSender; + readonly toneBuffer: string; + insertDTMF(tones: string, duration?: number, interToneGap?: number): void; + addEventListener(type: K, listener: (this: RTCDtmfSender, ev: RTCDtmfSenderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtmfSender: { + prototype: RTCDtmfSender; + new(sender: RTCRtpSender): RTCDtmfSender; +} + +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + +interface RTCIceCandidatePairChangedEvent extends Event { + readonly pair: RTCIceCandidatePair; +} + +declare var RTCIceCandidatePairChangedEvent: { + prototype: RTCIceCandidatePairChangedEvent; + new(): RTCIceCandidatePairChangedEvent; +} + +interface RTCIceGathererEventMap { + "error": Event; + "localcandidate": RTCIceGathererEvent; +} + +interface RTCIceGatherer extends RTCStatsProvider { + readonly component: RTCIceComponent; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; + onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; + createAssociatedGatherer(): RTCIceGatherer; + getLocalCandidates(): RTCIceCandidateDictionary[]; + getLocalParameters(): RTCIceParameters; + addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceGatherer: { + prototype: RTCIceGatherer; + new(options: RTCIceGatherOptions): RTCIceGatherer; +} + +interface RTCIceGathererEvent extends Event { + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; +} + +declare var RTCIceGathererEvent: { + prototype: RTCIceGathererEvent; + new(): RTCIceGathererEvent; +} + +interface RTCIceTransportEventMap { + "candidatepairchange": RTCIceCandidatePairChangedEvent; + "icestatechange": RTCIceTransportStateChangedEvent; +} + +interface RTCIceTransport extends RTCStatsProvider { + readonly component: RTCIceComponent; + readonly iceGatherer: RTCIceGatherer | null; + oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null; + onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; + readonly role: RTCIceRole; + readonly state: RTCIceTransportState; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; + createAssociatedTransport(): RTCIceTransport; + getNominatedCandidatePair(): RTCIceCandidatePair | null; + getRemoteCandidates(): RTCIceCandidateDictionary[]; + getRemoteParameters(): RTCIceParameters | null; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceTransport: { + prototype: RTCIceTransport; + new(): RTCIceTransport; +} + +interface RTCIceTransportStateChangedEvent extends Event { + readonly state: RTCIceTransportState; +} + +declare var RTCIceTransportStateChangedEvent: { + prototype: RTCIceTransportStateChangedEvent; + new(): RTCIceTransportStateChangedEvent; +} + +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: RTCIceConnectionState; + readonly iceGatheringState: RTCIceGatheringState; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: RTCSignalingState; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + +interface RTCRtpReceiverEventMap { + "error": Event; +} + +interface RTCRtpReceiver extends RTCStatsProvider { + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack | null; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; + getContributingSources(): RTCRtpContributingSource[]; + receive(parameters: RTCRtpParameters): void; + requestSendCSRC(csrc: number): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCRtpReceiver, ev: RTCRtpReceiverEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpReceiver: { + prototype: RTCRtpReceiver; + new(transport: RTCDtlsTransport | RTCSrtpSdesTransport, kind: string, rtcpTransport?: RTCDtlsTransport): RTCRtpReceiver; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCRtpSenderEventMap { + "error": Event; + "ssrcconflict": RTCSsrcConflictEvent; +} + +interface RTCRtpSender extends RTCStatsProvider { + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; + onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; + send(parameters: RTCRtpParameters): void; + setTrack(track: MediaStreamTrack): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCRtpSender, ev: RTCRtpSenderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpSender: { + prototype: RTCRtpSender; + new(track: MediaStreamTrack, transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): RTCRtpSender; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCSessionDescription { + sdp: string | null; + type: RTCSdpType | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + +interface RTCSrtpSdesTransportEventMap { + "error": Event; +} + +interface RTCSrtpSdesTransport extends EventTarget { + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; + readonly transport: RTCIceTransport; + addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCSrtpSdesTransport: { + prototype: RTCSrtpSdesTransport; + new(transport: RTCIceTransport, encryptParameters: RTCSrtpSdesParameters, decryptParameters: RTCSrtpSdesParameters): RTCSrtpSdesTransport; + getLocalParameters(): RTCSrtpSdesParameters[]; +} + +interface RTCSsrcConflictEvent extends Event { + readonly ssrc: number; +} + +declare var RTCSsrcConflictEvent: { + prototype: RTCSsrcConflictEvent; + new(): RTCSsrcConflictEvent; +} + +interface RTCStatsProvider extends EventTarget { + getStats(): Promise; + msGetStats(): Promise; +} + +declare var RTCStatsProvider: { + prototype: RTCStatsProvider; + new(): RTCStatsProvider; +} + +interface Range { + readonly collapsed: boolean; + readonly commonAncestorContainer: Node; + readonly endContainer: Node; + readonly endOffset: number; + readonly startContainer: Node; + readonly 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: ExpandGranularity): 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; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; +} + +declare var Range: { + prototype: Range; + new(): Range; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; +} + +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; + readonly referrer: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: ResponseType; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { + readonly target: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGAngle { + readonly unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; +} + +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; +} + +interface SVGAnimatedAngle { + readonly animVal: SVGAngle; + readonly baseVal: SVGAngle; +} + +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface SVGAnimatedBoolean { + readonly animVal: boolean; + baseVal: boolean; +} + +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface SVGAnimatedEnumeration { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface SVGAnimatedInteger { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGAnimatedLength { + readonly animVal: SVGLength; + readonly baseVal: SVGLength; +} + +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedLengthList { + readonly animVal: SVGLengthList; + readonly baseVal: SVGLengthList; +} + +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedNumber { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface SVGAnimatedNumberList { + readonly animVal: SVGNumberList; + readonly baseVal: SVGNumberList; +} + +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGAnimatedPreserveAspectRatio { + readonly animVal: SVGPreserveAspectRatio; + readonly baseVal: SVGPreserveAspectRatio; +} + +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface SVGAnimatedRect { + readonly animVal: SVGRect; + readonly baseVal: SVGRect; +} + +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface SVGAnimatedString { + readonly animVal: string; + baseVal: string; +} + +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface SVGAnimatedTransformList { + readonly animVal: SVGTransformList; + readonly baseVal: SVGTransformList; +} + +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface SVGCircleElement extends SVGGraphicsElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { + readonly clipPathUnits: SVGAnimatedEnumeration; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + readonly amplitude: SVGAnimatedNumber; + readonly exponent: SVGAnimatedNumber; + readonly intercept: SVGAnimatedNumber; + readonly offset: SVGAnimatedNumber; + readonly slope: SVGAnimatedNumber; + readonly tableValues: SVGAnimatedNumberList; + readonly type: SVGAnimatedEnumeration; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface SVGElementEventMap extends ElementEventMap { + "click": MouseEvent; + "dblclick": MouseEvent; + "focusin": FocusEvent; + "focusout": FocusEvent; + "load": Event; + "mousedown": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; +} + +interface SVGElement extends Element { + className: any; + onclick: (this: SVGElement, ev: MouseEvent) => any; + ondblclick: (this: SVGElement, ev: MouseEvent) => any; + onfocusin: (this: SVGElement, ev: FocusEvent) => any; + onfocusout: (this: SVGElement, ev: FocusEvent) => any; + onload: (this: SVGElement, ev: Event) => any; + onmousedown: (this: SVGElement, ev: MouseEvent) => any; + onmousemove: (this: SVGElement, ev: MouseEvent) => any; + onmouseout: (this: SVGElement, ev: MouseEvent) => any; + onmouseover: (this: SVGElement, ev: MouseEvent) => any; + onmouseup: (this: SVGElement, ev: MouseEvent) => any; + readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; + readonly viewportElement: SVGElement; + xmlbase: string; + addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface SVGElementInstance extends EventTarget { + readonly childNodes: SVGElementInstanceList; + readonly correspondingElement: SVGElement; + readonly correspondingUseElement: SVGUseElement; + readonly firstChild: SVGElementInstance; + readonly lastChild: SVGElementInstance; + readonly nextSibling: SVGElementInstance; + readonly parentNode: SVGElementInstance; + readonly previousSibling: SVGElementInstance; +} + +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface SVGElementInstanceList { + readonly length: number; + item(index: number): SVGElementInstance; +} + +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface SVGEllipseElement extends SVGGraphicsElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly mode: SVGAnimatedEnumeration; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly type: SVGAnimatedEnumeration; + readonly values: SVGAnimatedNumberList; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly k1: SVGAnimatedNumber; + readonly k2: SVGAnimatedNumber; + readonly k3: SVGAnimatedNumber; + readonly k4: SVGAnimatedNumber; + readonly operator: SVGAnimatedEnumeration; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly bias: SVGAnimatedNumber; + readonly divisor: SVGAnimatedNumber; + readonly edgeMode: SVGAnimatedEnumeration; + readonly in1: SVGAnimatedString; + readonly kernelMatrix: SVGAnimatedNumberList; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly orderX: SVGAnimatedInteger; + readonly orderY: SVGAnimatedInteger; + readonly preserveAlpha: SVGAnimatedBoolean; + readonly targetX: SVGAnimatedInteger; + readonly targetY: SVGAnimatedInteger; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly diffuseConstant: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly scale: SVGAnimatedNumber; + readonly xChannelSelector: SVGAnimatedEnumeration; + readonly yChannelSelector: SVGAnimatedEnumeration; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; +} + +interface SVGFEDistantLightElement extends SVGElement { + readonly azimuth: SVGAnimatedNumber; + readonly elevation: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly stdDeviationX: SVGAnimatedNumber; + readonly stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface SVGFEMergeNodeElement extends SVGElement { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly operator: SVGAnimatedEnumeration; + readonly radiusX: SVGAnimatedNumber; + readonly radiusY: SVGAnimatedNumber; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly dx: SVGAnimatedNumber; + readonly dy: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface SVGFEPointLightElement extends SVGElement { + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly specularConstant: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface SVGFESpotLightElement extends SVGElement { + readonly limitingConeAngle: SVGAnimatedNumber; + readonly pointsAtX: SVGAnimatedNumber; + readonly pointsAtY: SVGAnimatedNumber; + readonly pointsAtZ: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly baseFrequencyX: SVGAnimatedNumber; + readonly baseFrequencyY: SVGAnimatedNumber; + readonly numOctaves: SVGAnimatedInteger; + readonly seed: SVGAnimatedNumber; + readonly stitchTiles: SVGAnimatedEnumeration; + readonly type: SVGAnimatedEnumeration; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { + readonly filterResX: SVGAnimatedInteger; + readonly filterResY: SVGAnimatedInteger; + readonly filterUnits: SVGAnimatedEnumeration; + readonly height: SVGAnimatedLength; + readonly primitiveUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + setFilterRes(filterResX: number, filterResY: number): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface SVGForeignObjectElement extends SVGGraphicsElement { + readonly height: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGForeignObjectElement: { + prototype: SVGForeignObjectElement; + new(): SVGForeignObjectElement; +} + +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { + readonly gradientTransform: SVGAnimatedTransformList; + readonly gradientUnits: SVGAnimatedEnumeration; + readonly spreadMethod: SVGAnimatedEnumeration; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; +} + +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { + readonly height: SVGAnimatedLength; + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGLength { + readonly unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; +} + +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; +} + +interface SVGLengthList { + readonly 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 SVGGraphicsElement { + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { + readonly markerHeight: SVGAnimatedLength; + readonly markerUnits: SVGAnimatedEnumeration; + readonly markerWidth: SVGAnimatedLength; + readonly orientAngle: SVGAnimatedAngle; + readonly orientType: SVGAnimatedEnumeration; + readonly refX: SVGAnimatedLength; + readonly refY: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; +} + +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { + readonly height: SVGAnimatedLength; + readonly maskContentUnits: SVGAnimatedEnumeration; + readonly maskUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + 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 { + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGNumber { + value: number; +} + +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGNumberList { + readonly 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 SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; + 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: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface SVGPathSeg { + readonly pathSegType: number; + readonly pathSegTypeAsLetter: string; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly PATHSEG_UNKNOWN: number; +} + +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly 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 { + readonly 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, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { + readonly height: SVGAnimatedLength; + readonly patternContentUnits: SVGAnimatedEnumeration; + readonly patternTransform: SVGAnimatedTransformList; + readonly patternUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + 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 { + readonly 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 SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly fx: SVGAnimatedLength; + readonly fy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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 SVGGraphicsElement { + readonly height: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface SVGSVGElementEventMap extends SVGElementEventMap { + "SVGAbort": Event; + "SVGError": Event; + "resize": UIEvent; + "scroll": UIEvent; + "SVGUnload": Event; + "SVGZoom": SVGZoomEvent; +} + +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { + contentScriptType: string; + contentStyleType: string; + currentScale: number; + readonly currentTranslate: SVGPoint; + readonly height: SVGAnimatedLength; + onabort: (this: SVGSVGElement, ev: Event) => any; + onerror: (this: SVGSVGElement, ev: Event) => any; + onresize: (this: SVGSVGElement, ev: UIEvent) => any; + onscroll: (this: SVGSVGElement, ev: UIEvent) => any; + onunload: (this: SVGSVGElement, ev: Event) => any; + onzoom: (this: SVGSVGElement, ev: SVGZoomEvent) => any; + readonly pixelUnitToMillimeterX: number; + readonly pixelUnitToMillimeterY: number; + readonly screenPixelToMillimeterX: number; + readonly screenPixelToMillimeterY: number; + readonly viewport: SVGRect; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly 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): NodeListOf; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeListOf; + pauseAnimations(): void; + setCurrentTime(seconds: number): void; + suspendRedraw(maxWaitMilliseconds: number): number; + unpauseAnimations(): void; + unsuspendRedraw(suspendHandleID: number): void; + unsuspendRedrawAll(): void; + addEventListener(type: K, listener: (this: SVGSVGElement, ev: SVGSVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface SVGScriptElement extends SVGElement, SVGURIReference { + type: string; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface SVGStopElement extends SVGElement { + readonly offset: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface SVGStringList { + readonly 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 { + disabled: boolean; + media: string; + title: string; + type: string; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface SVGTextContentElement extends SVGGraphicsElement { + readonly lengthAdjust: SVGAnimatedEnumeration; + readonly 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; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; +} + +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + readonly method: SVGAnimatedEnumeration; + readonly spacing: SVGAnimatedEnumeration; + readonly startOffset: SVGAnimatedLength; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + readonly dx: SVGAnimatedLengthList; + readonly dy: SVGAnimatedLengthList; + readonly rotate: SVGAnimatedNumberList; + readonly x: SVGAnimatedLengthList; + readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface SVGTransform { + readonly angle: number; + readonly matrix: SVGMatrix; + readonly 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; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; +} + +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; +} + +interface SVGTransformList { + readonly 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 { + readonly SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + readonly SVG_UNIT_TYPE_UNKNOWN: number; + readonly SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { + readonly animatedInstanceRoot: SVGElementInstance; + readonly height: SVGAnimatedLength; + readonly instanceRoot: SVGElementInstance; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { + readonly viewTarget: SVGStringList; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface SVGZoomAndPan { + readonly zoomAndPan: number; +} + +declare var SVGZoomAndPan: { + readonly SVG_ZOOMANDPAN_DISABLE: number; + readonly SVG_ZOOMANDPAN_MAGNIFY: number; + readonly SVG_ZOOMANDPAN_UNKNOWN: number; +} + +interface SVGZoomEvent extends UIEvent { + readonly newScale: number; + readonly newTranslate: SVGPoint; + readonly previousScale: number; + readonly previousTranslate: SVGPoint; + readonly zoomRectScreen: SVGRect; +} + +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: ScopedCredentialType; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + +interface ScreenEventMap { + "MSOrientationChange": Event; +} + +interface Screen extends EventTarget { + readonly availHeight: number; + readonly availWidth: number; + bufferDepth: number; + readonly colorDepth: number; + readonly deviceXDPI: number; + readonly deviceYDPI: number; + readonly fontSmoothingEnabled: boolean; + readonly height: number; + readonly logicalXDPI: number; + readonly logicalYDPI: number; + readonly msOrientation: string; + onmsorientationchange: (this: Screen, ev: Event) => any; + readonly pixelDepth: number; + readonly systemXDPI: number; + readonly systemYDPI: number; + readonly width: number; + msLockOrientation(orientations: string | string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface ScriptNotifyEvent extends Event { + readonly callingUri: string; + readonly value: string; +} + +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface ScriptProcessorNodeEventMap { + "audioprocess": AudioProcessingEvent; +} + +interface ScriptProcessorNode extends AudioNode { + readonly bufferSize: number; + onaudioprocess: (this: ScriptProcessorNode, ev: AudioProcessingEvent) => any; + addEventListener(type: K, listener: (this: ScriptProcessorNode, ev: ScriptProcessorNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ScriptProcessorNode: { + prototype: ScriptProcessorNode; + new(): ScriptProcessorNode; +} + +interface Selection { + readonly anchorNode: Node; + readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; + readonly focusNode: Node; + readonly focusOffset: number; + readonly isCollapsed: boolean; + readonly rangeCount: number; + readonly 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; + setPosition(parentNode: Node, offset: number): void; + toString(): string; +} + +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: ServiceWorkerState; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + +interface SourceBuffer extends EventTarget { + appendWindowEnd: number; + appendWindowStart: number; + readonly audioTracks: AudioTrackList; + readonly buffered: TimeRanges; + mode: AppendMode; + timestampOffset: number; + readonly updating: boolean; + readonly 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 { + readonly length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + +interface StereoPannerNode extends AudioNode { + readonly pan: AudioParam; +} + +declare var StereoPannerNode: { + prototype: StereoPannerNode; + new(): StereoPannerNode; +} + +interface Storage { + readonly length: number; + clear(): void; + getItem(key: string): string | null; + key(index: number): string | null; + 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 { + readonly url: string; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; +} + +declare var StorageEvent: { + prototype: StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; +} + +interface StyleMedia { + readonly type: string; + matchMedium(mediaquery: string): boolean; +} + +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface StyleSheet { + disabled: boolean; + readonly href: string; + readonly media: MediaList; + readonly ownerNode: Node; + readonly parentStyleSheet: StyleSheet; + readonly title: string; + readonly type: string; +} + +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface StyleSheetList { + readonly length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} + +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface StyleSheetPageList { + readonly length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} + +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface SubtleCrypto { + decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike; + deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike; + deriveKey(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike; + digest(algorithm: AlgorithmIdentifier, data: BufferSource): PromiseLike; + encrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike; + exportKey(format: "jwk", key: CryptoKey): PromiseLike; + exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): PromiseLike; + exportKey(format: string, key: CryptoKey): PromiseLike; + generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): PromiseLike; + generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams | DhKeyGenParams, extractable: boolean, keyUsages: string[]): PromiseLike; + generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike; + importKey(format: "jwk", keyData: JsonWebKey, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + importKey(format: string, keyData: JsonWebKey | BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: BufferSource): PromiseLike; + unwrapKey(format: string, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier, unwrappedKeyAlgorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike; + verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: BufferSource, data: BufferSource): PromiseLike; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier): PromiseLike; +} + +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + +interface Text extends CharacterData { + readonly wholeText: string; + readonly assignedSlot: HTMLSlotElement | null; + splitText(offset: number): Text; +} + +declare var Text: { + prototype: Text; + new(data?: string): Text; +} + +interface TextEvent extends UIEvent { + readonly data: string; + readonly inputMethod: number; + readonly locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; +} + +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; +} + +interface TextMetrics { + readonly width: number; +} + +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface TextTrackEventMap { + "cuechange": Event; + "error": Event; + "load": Event; +} + +interface TextTrack extends EventTarget { + readonly activeCues: TextTrackCueList; + readonly cues: TextTrackCueList; + readonly inBandMetadataTrackDispatchType: string; + readonly kind: string; + readonly label: string; + readonly language: string; + mode: any; + oncuechange: (this: TextTrack, ev: Event) => any; + onerror: (this: TextTrack, ev: Event) => any; + onload: (this: TextTrack, ev: Event) => any; + readonly readyState: number; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; + addEventListener(type: K, listener: (this: TextTrack, ev: TextTrackEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; +} + +interface TextTrackCueEventMap { + "enter": Event; + "exit": Event; +} + +interface TextTrackCue extends EventTarget { + endTime: number; + id: string; + onenter: (this: TextTrackCue, ev: Event) => any; + onexit: (this: TextTrackCue, ev: Event) => any; + pauseOnExit: boolean; + startTime: number; + text: string; + readonly track: TextTrack; + getCueAsHTML(): DocumentFragment; + addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => 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 { + readonly length: number; + getCueById(id: string): TextTrackCue; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; +} + +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface TextTrackListEventMap { + "addtrack": TrackEvent; +} + +interface TextTrackList extends EventTarget { + readonly length: number; + onaddtrack: ((this: TextTrackList, ev: TrackEvent) => any) | null; + item(index: number): TextTrack; + addEventListener(type: K, listener: (this: TextTrackList, ev: TextTrackListEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: TextTrack; +} + +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface TimeRanges { + readonly length: number; + end(index: number): number; + start(index: number): number; +} + +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface Touch { + readonly clientX: number; + readonly clientY: number; + readonly identifier: number; + readonly pageX: number; + readonly pageY: number; + readonly screenX: number; + readonly screenY: number; + readonly target: EventTarget; +} + +declare var Touch: { + prototype: Touch; + new(): Touch; +} + +interface TouchEvent extends UIEvent { + readonly altKey: boolean; + readonly changedTouches: TouchList; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly keyCode: number; + readonly metaKey: boolean; + readonly shiftKey: boolean; + readonly targetTouches: TouchList; + readonly touches: TouchList; + readonly which: number; +} + +declare var TouchEvent: { + prototype: TouchEvent; + new(type: string, touchEventInit?: TouchEventInit): TouchEvent; +} + +interface TouchList { + readonly length: number; + item(index: number): Touch | null; + [index: number]: Touch; +} + +declare var TouchList: { + prototype: TouchList; + new(): TouchList; +} + +interface TrackEvent extends Event { + readonly track: VideoTrack | AudioTrack | TextTrack | null; +} + +declare var TrackEvent: { + prototype: TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; +} + +interface TransitionEvent extends Event { + readonly elapsedTime: number; + readonly propertyName: string; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +declare var TransitionEvent: { + prototype: TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; +} + +interface TreeWalker { + currentNode: Node; + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly 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 { + readonly detail: number; + readonly view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} + +declare var UIEvent: { + prototype: UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; +} + +interface URL { + hash: string; + host: string; + hostname: string; + href: string; + readonly origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + username: string; + readonly searchParams: URLSearchParams; + toString(): string; +} + +declare var URL: { + prototype: URL; + new(url: string, base?: string): URL; + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { + readonly mediaType: string; +} + +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface ValidityState { + readonly badInput: boolean; + readonly customError: boolean; + readonly patternMismatch: boolean; + readonly rangeOverflow: boolean; + readonly rangeUnderflow: boolean; + readonly stepMismatch: boolean; + readonly tooLong: boolean; + readonly typeMismatch: boolean; + readonly valid: boolean; + readonly valueMissing: boolean; +} + +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface VideoPlaybackQuality { + readonly corruptedVideoFrames: number; + readonly creationTime: number; + readonly droppedVideoFrames: number; + readonly totalFrameDelay: number; + readonly totalVideoFrames: number; +} + +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface VideoTrack { + readonly id: string; + kind: string; + readonly label: string; + language: string; + selected: boolean; + readonly sourceBuffer: SourceBuffer; +} + +declare var VideoTrack: { + prototype: VideoTrack; + new(): VideoTrack; +} + +interface VideoTrackListEventMap { + "addtrack": TrackEvent; + "change": Event; + "removetrack": TrackEvent; +} + +interface VideoTrackList extends EventTarget { + readonly length: number; + onaddtrack: (this: VideoTrackList, ev: TrackEvent) => any; + onchange: (this: VideoTrackList, ev: Event) => any; + onremovetrack: (this: VideoTrackList, ev: TrackEvent) => any; + readonly selectedIndex: number; + getTrackById(id: string): VideoTrack | null; + item(index: number): VideoTrack; + addEventListener(type: K, listener: (this: VideoTrackList, ev: VideoTrackListEventMap[K]) => 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 { + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WEBGL_debug_renderer_info { + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; +} + +declare var WEBGL_debug_renderer_info: { + prototype: WEBGL_debug_renderer_info; + new(): WEBGL_debug_renderer_info; + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; +} + +interface WEBGL_depth_texture { + readonly UNSIGNED_INT_24_8_WEBGL: number; +} + +declare var WEBGL_depth_texture: { + prototype: WEBGL_depth_texture; + new(): WEBGL_depth_texture; + readonly UNSIGNED_INT_24_8_WEBGL: number; +} + +interface WaveShaperNode extends AudioNode { + curve: Float32Array | null; + oversample: OverSampleType; +} + +declare var WaveShaperNode: { + prototype: WaveShaperNode; + new(): WaveShaperNode; +} + +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + +interface WebGLActiveInfo { + readonly name: string; + readonly size: number; + readonly type: number; +} + +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WebGLBuffer extends WebGLObject { +} + +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLContextEvent extends Event { + readonly statusMessage: string; +} + +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): 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 { + readonly canvas: HTMLCanvasElement; + readonly drawingBufferHeight: number; + readonly drawingBufferWidth: number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram | null, shader: WebGLShader | null): void; + bindAttribLocation(program: WebGLProgram | null, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer | null): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer | null): void; + bindTexture(target: number, texture: WebGLTexture | null): 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 | null): 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 | null; + createFramebuffer(): WebGLFramebuffer | null; + createProgram(): WebGLProgram | null; + createRenderbuffer(): WebGLRenderbuffer | null; + createShader(type: number): WebGLShader | null; + createTexture(): WebGLTexture | null; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer | null): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer | null): void; + deleteProgram(program: WebGLProgram | null): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer | null): void; + deleteShader(shader: WebGLShader | null): void; + deleteTexture(texture: WebGLTexture | null): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram | null, shader: WebGLShader | null): 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 | null): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture | null, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getActiveUniform(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getAttachedShaders(program: WebGLProgram | null): WebGLShader[] | null; + getAttribLocation(program: WebGLProgram | null, 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 | null): string | null; + getProgramParameter(program: WebGLProgram | null, pname: number): any; + getRenderbufferParameter(target: number, pname: number): any; + getShaderInfoLog(shader: WebGLShader | null): string | null; + getShaderParameter(shader: WebGLShader | null, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat | null; + getShaderSource(shader: WebGLShader | null): string | null; + getSupportedExtensions(): string[] | null; + getTexParameter(target: number, pname: number): any; + getUniform(program: WebGLProgram | null, location: WebGLUniformLocation | null): any; + getUniformLocation(program: WebGLProgram | null, name: string): WebGLUniformLocation | null; + getVertexAttrib(index: number, pname: number): any; + getVertexAttribOffset(index: number, pname: number): number; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer | null): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer | null): boolean; + isProgram(program: WebGLProgram | null): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer | null): boolean; + isShader(shader: WebGLShader | null): boolean; + isTexture(texture: WebGLTexture | null): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram | null): void; + pixelStorei(pname: number, param: number | boolean): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): 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 | null, 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 | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): 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 | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + uniform1f(location: WebGLUniformLocation | null, x: number): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform1i(location: WebGLUniformLocation | null, x: number): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform2f(location: WebGLUniformLocation | null, x: number, y: number): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform2i(location: WebGLUniformLocation | null, x: number, y: number): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform3f(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform3i(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform4f(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform4i(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + useProgram(program: WebGLProgram | null): void; + validateProgram(program: WebGLProgram | null): void; + vertexAttrib1f(indx: number, x: number): void; + vertexAttrib1fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib2f(indx: number, x: number, y: number): void; + vertexAttrib2fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + vertexAttrib3fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + vertexAttrib4fv(indx: number, values: Float32Array | number[]): 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; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; +} + +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; +} + +interface WebGLShader extends WebGLObject { +} + +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface WebGLShaderPrecisionFormat { + readonly precision: number; + readonly rangeMax: number; + readonly 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 WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + +interface WebKitPoint { + x: number; + y: number; +} + +declare var WebKitPoint: { + prototype: WebKitPoint; + new(x?: number, y?: number): WebKitPoint; +} + +interface WebSocketEventMap { + "close": CloseEvent; + "error": Event; + "message": MessageEvent; + "open": Event; +} + +interface WebSocket extends EventTarget { + binaryType: string; + readonly bufferedAmount: number; + readonly extensions: string; + onclose: (this: WebSocket, ev: CloseEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; + onmessage: (this: WebSocket, ev: MessageEvent) => any; + onopen: (this: WebSocket, ev: Event) => any; + readonly protocol: string; + readonly readyState: number; + readonly url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; + addEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; +} + +interface WheelEvent extends MouseEvent { + readonly deltaMode: number; + readonly deltaX: number; + readonly deltaY: number; + readonly deltaZ: number; + readonly wheelDelta: number; + readonly wheelDeltaX: number; + readonly wheelDeltaY: 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; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; +} + +declare var WheelEvent: { + prototype: WheelEvent; + new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; +} + +interface WindowEventMap extends GlobalEventHandlersEventMap { + "abort": UIEvent; + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "compassneedscalibration": Event; + "contextmenu": PointerEvent; + "dblclick": MouseEvent; + "devicelight": DeviceLightEvent; + "devicemotion": DeviceMotionEvent; + "deviceorientation": DeviceOrientationEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "message": MessageEvent; + "mousedown": MouseEvent; + "mouseenter": MouseEvent; + "mouseleave": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSInertiaStart": MSGestureEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "pause": Event; + "play": Event; + "playing": Event; + "popstate": PopStateEvent; + "progress": ProgressEvent; + "ratechange": Event; + "readystatechange": ProgressEvent; + "reset": Event; + "resize": UIEvent; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "stalled": Event; + "storage": StorageEvent; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "unload": Event; + "volumechange": Event; + "waiting": Event; +} + +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { + readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; + readonly clientInformation: Navigator; + readonly closed: boolean; + readonly crypto: Crypto; + defaultStatus: string; + readonly devicePixelRatio: number; + readonly doNotTrack: string; + readonly document: Document; + event: Event | undefined; + readonly external: External; + readonly frameElement: Element; + readonly frames: Window; + readonly history: History; + readonly innerHeight: number; + readonly innerWidth: number; + readonly isSecureContext: boolean; + readonly length: number; + readonly location: Location; + readonly locationbar: BarProp; + readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; + readonly msCredentials: MSCredentials; + name: string; + readonly navigator: Navigator; + offscreenBuffering: string | boolean; + onabort: (this: Window, ev: UIEvent) => any; + onafterprint: (this: Window, ev: Event) => any; + onbeforeprint: (this: Window, ev: Event) => any; + onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; + onblur: (this: Window, ev: FocusEvent) => any; + oncanplay: (this: Window, ev: Event) => any; + oncanplaythrough: (this: Window, ev: Event) => any; + onchange: (this: Window, ev: Event) => any; + onclick: (this: Window, ev: MouseEvent) => any; + oncompassneedscalibration: (this: Window, ev: Event) => any; + oncontextmenu: (this: Window, ev: PointerEvent) => any; + ondblclick: (this: Window, ev: MouseEvent) => any; + ondevicelight: (this: Window, ev: DeviceLightEvent) => any; + ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; + ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; + ondrag: (this: Window, ev: DragEvent) => any; + ondragend: (this: Window, ev: DragEvent) => any; + ondragenter: (this: Window, ev: DragEvent) => any; + ondragleave: (this: Window, ev: DragEvent) => any; + ondragover: (this: Window, ev: DragEvent) => any; + ondragstart: (this: Window, ev: DragEvent) => any; + ondrop: (this: Window, ev: DragEvent) => any; + ondurationchange: (this: Window, ev: Event) => any; + onemptied: (this: Window, ev: Event) => any; + onended: (this: Window, ev: MediaStreamErrorEvent) => any; + onerror: ErrorEventHandler; + onfocus: (this: Window, ev: FocusEvent) => any; + onhashchange: (this: Window, ev: HashChangeEvent) => any; + oninput: (this: Window, ev: Event) => any; + oninvalid: (this: Window, ev: Event) => any; + onkeydown: (this: Window, ev: KeyboardEvent) => any; + onkeypress: (this: Window, ev: KeyboardEvent) => any; + onkeyup: (this: Window, ev: KeyboardEvent) => any; + onload: (this: Window, ev: Event) => any; + onloadeddata: (this: Window, ev: Event) => any; + onloadedmetadata: (this: Window, ev: Event) => any; + onloadstart: (this: Window, ev: Event) => any; + onmessage: (this: Window, ev: MessageEvent) => any; + onmousedown: (this: Window, ev: MouseEvent) => any; + onmouseenter: (this: Window, ev: MouseEvent) => any; + onmouseleave: (this: Window, ev: MouseEvent) => any; + onmousemove: (this: Window, ev: MouseEvent) => any; + onmouseout: (this: Window, ev: MouseEvent) => any; + onmouseover: (this: Window, ev: MouseEvent) => any; + onmouseup: (this: Window, ev: MouseEvent) => any; + onmousewheel: (this: Window, ev: WheelEvent) => any; + onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; + onmsgestureend: (this: Window, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; + onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; + onmspointercancel: (this: Window, ev: MSPointerEvent) => any; + onmspointerdown: (this: Window, ev: MSPointerEvent) => any; + onmspointerenter: (this: Window, ev: MSPointerEvent) => any; + onmspointerleave: (this: Window, ev: MSPointerEvent) => any; + onmspointermove: (this: Window, ev: MSPointerEvent) => any; + onmspointerout: (this: Window, ev: MSPointerEvent) => any; + onmspointerover: (this: Window, ev: MSPointerEvent) => any; + onmspointerup: (this: Window, ev: MSPointerEvent) => any; + onoffline: (this: Window, ev: Event) => any; + ononline: (this: Window, ev: Event) => any; + onorientationchange: (this: Window, ev: Event) => any; + onpagehide: (this: Window, ev: PageTransitionEvent) => any; + onpageshow: (this: Window, ev: PageTransitionEvent) => any; + onpause: (this: Window, ev: Event) => any; + onplay: (this: Window, ev: Event) => any; + onplaying: (this: Window, ev: Event) => any; + onpopstate: (this: Window, ev: PopStateEvent) => any; + onprogress: (this: Window, ev: ProgressEvent) => any; + onratechange: (this: Window, ev: Event) => any; + onreadystatechange: (this: Window, ev: ProgressEvent) => any; + onreset: (this: Window, ev: Event) => any; + onresize: (this: Window, ev: UIEvent) => any; + onscroll: (this: Window, ev: UIEvent) => any; + onseeked: (this: Window, ev: Event) => any; + onseeking: (this: Window, ev: Event) => any; + onselect: (this: Window, ev: UIEvent) => any; + onstalled: (this: Window, ev: Event) => any; + onstorage: (this: Window, ev: StorageEvent) => any; + onsubmit: (this: Window, ev: Event) => any; + onsuspend: (this: Window, ev: Event) => any; + ontimeupdate: (this: Window, ev: Event) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onunload: (this: Window, ev: Event) => any; + onvolumechange: (this: Window, ev: Event) => any; + onwaiting: (this: Window, ev: Event) => any; + opener: any; + orientation: string | number; + readonly outerHeight: number; + readonly outerWidth: number; + readonly pageXOffset: number; + readonly pageYOffset: number; + readonly parent: Window; + readonly performance: Performance; + readonly personalbar: BarProp; + readonly screen: Screen; + readonly screenLeft: number; + readonly screenTop: number; + readonly screenX: number; + readonly screenY: number; + readonly scrollX: number; + readonly scrollY: number; + readonly scrollbars: BarProp; + readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; + status: string; + readonly statusbar: BarProp; + readonly styleMedia: StyleMedia; + readonly toolbar: BarProp; + readonly top: Window; + readonly window: Window; + URL: typeof URL; + URLSearchParams: typeof URLSearchParams; + Blob: typeof Blob; + customElements: CustomElementRegistry; + alert(message?: any): void; + blur(): void; + cancelAnimationFrame(handle: number): void; + captureEvents(): void; + close(): void; + confirm(message?: string): boolean; + departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; + 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; + msWriteProfilerMark(profilerMarkName: string): void; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + postMessage(message: any, targetOrigin: string, transfer?: any[]): void; + print(): void; + prompt(message?: string, _default?: string): string | null; + 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; + stop(): void; + webkitCancelAnimationFrame(handle: number): void; + webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; + webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; + webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; + scroll(options?: ScrollToOptions): void; + scrollTo(options?: ScrollToOptions): void; + scrollBy(options?: ScrollToOptions): void; + addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Window: { + prototype: Window; + new(): Window; +} + +interface WorkerEventMap extends AbstractWorkerEventMap { + "message": MessageEvent; +} + +interface Worker extends EventTarget, AbstractWorker { + onmessage: (this: Worker, ev: MessageEvent) => any; + postMessage(message: any, transfer?: any[]): void; + terminate(): void; + addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => 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 { + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap { + "readystatechange": Event; +} + +interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { + onreadystatechange: (this: XMLHttpRequest, ev: Event) => any; + readonly readyState: number; + readonly response: any; + readonly responseText: string; + responseType: XMLHttpRequestResponseType; + readonly responseURL: string; + readonly responseXML: Document | null; + readonly status: number; + readonly statusText: string; + timeout: number; + readonly upload: XMLHttpRequestUpload; + withCredentials: boolean; + msCaching?: string; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string | null; + 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; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; + addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; +} + +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + 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 | null, type: number, result: XPathResult | null): XPathResult; +} + +declare var XPathEvaluator: { + prototype: XPathEvaluator; + new(): XPathEvaluator; +} + +interface XPathExpression { + evaluate(contextNode: Node, type: number, result: XPathResult | null): XPathResult; +} + +declare var XPathExpression: { + prototype: XPathExpression; + new(): XPathExpression; +} + +interface XPathNSResolver { + lookupNamespaceURI(prefix: string): string; +} + +declare var XPathNSResolver: { + prototype: XPathNSResolver; + new(): XPathNSResolver; +} + +interface XPathResult { + readonly booleanValue: boolean; + readonly invalidIteratorState: boolean; + readonly numberValue: number; + readonly resultType: number; + readonly singleNodeValue: Node; + readonly snapshotLength: number; + readonly stringValue: string; + iterateNext(): Node; + snapshotItem(index: number): Node; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +declare var XPathResult: { + prototype: XPathResult; + new(): XPathResult; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly 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 webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + +interface AbstractWorkerEventMap { + "error": ErrorEvent; +} + +interface AbstractWorker { + onerror: (this: AbstractWorker, ev: ErrorEvent) => any; + addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; + formData(): Promise; +} + +interface CanvasPathMethods { + 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; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + closePath(): void; + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, w: number, h: number): void; +} + +interface ChildNode { + remove(): void; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface DocumentEvent { + createEvent(eventInterface:"AnimationEvent"): AnimationEvent; + createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; + createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; + createEvent(eventInterface:"CloseEvent"): CloseEvent; + createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; + createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; + 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:"FocusNavigationEvent"): FocusNavigationEvent; + createEvent(eventInterface:"GamepadEvent"): GamepadEvent; + createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; + createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface:"KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface:"ListeningStateChangedEvent"): ListeningStateChangedEvent; + 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:"MediaEncryptedEvent"): MediaEncryptedEvent; + createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; + createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; + createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; + createEvent(eventInterface:"MessageEvent"): MessageEvent; + createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; + 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:"OverflowEvent"): OverflowEvent; + createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; + createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; + createEvent(eventInterface:"PointerEvent"): PointerEvent; + createEvent(eventInterface:"PopStateEvent"): PopStateEvent; + createEvent(eventInterface:"ProgressEvent"): ProgressEvent; + createEvent(eventInterface:"RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent; + createEvent(eventInterface:"RTCDtlsTransportStateChangedEvent"): RTCDtlsTransportStateChangedEvent; + createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; + createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; + createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; + createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; + createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; + 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 { + readonly childElementCount: number; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface GlobalEventHandlersEventMap { + "pointercancel": PointerEvent; + "pointerdown": PointerEvent; + "pointerenter": PointerEvent; + "pointerleave": PointerEvent; + "pointermove": PointerEvent; + "pointerout": PointerEvent; + "pointerover": PointerEvent; + "pointerup": PointerEvent; + "wheel": WheelEvent; +} + +interface GlobalEventHandlers { + onpointercancel: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerdown: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerenter: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerleave: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointermove: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerout: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerover: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerup: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onwheel: (this: GlobalEventHandlers, ev: WheelEvent) => any; + addEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + +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 { + readonly indexedDB: IDBFactory; +} + +interface LinkStyle { + readonly sheet: StyleSheet; +} + +interface MSBaseReaderEventMap { + "abort": Event; + "error": ErrorEvent; + "load": Event; + "loadend": ProgressEvent; + "loadstart": Event; + "progress": ProgressEvent; +} + +interface MSBaseReader { + onabort: (this: MSBaseReader, ev: Event) => any; + onerror: (this: MSBaseReader, ev: ErrorEvent) => any; + onload: (this: MSBaseReader, ev: Event) => any; + onloadend: (this: MSBaseReader, ev: ProgressEvent) => any; + onloadstart: (this: MSBaseReader, ev: Event) => any; + onprogress: (this: MSBaseReader, ev: ProgressEvent) => any; + readonly readyState: number; + readonly result: any; + abort(): void; + readonly DONE: number; + readonly EMPTY: number; + readonly LOADING: number; + addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => 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 NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + +interface NavigatorContentUtils { +} + +interface NavigatorGeolocation { + readonly geolocation: Geolocation; +} + +interface NavigatorID { + readonly appCodeName: string; + readonly appName: string; + readonly appVersion: string; + readonly platform: string; + readonly product: string; + readonly productSub: string; + readonly userAgent: string; + readonly vendor: string; + readonly vendorSub: string; +} + +interface NavigatorOnLine { + readonly onLine: boolean; +} + +interface NavigatorStorageUtils { +} + +interface NavigatorUserMedia { + readonly mediaDevices: MediaDevices; + getUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; +} + +interface NodeSelector { + querySelector(selectors: K): ElementTagNameMap[K] | null; + querySelector(selectors: string): Element | null; + querySelectorAll(selectors: K): ElementListTagNameMap[K]; + querySelectorAll(selectors: string): NodeListOf; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface SVGAnimatedPoints { + readonly animatedPoints: SVGPointList; + readonly points: SVGPointList; +} + +interface SVGFilterPrimitiveStandardAttributes { + readonly height: SVGAnimatedLength; + readonly result: SVGAnimatedString; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; +} + +interface SVGFitToViewBox { + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly viewBox: SVGAnimatedRect; +} + +interface SVGTests { + readonly requiredExtensions: SVGStringList; + readonly requiredFeatures: SVGStringList; + readonly systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface SVGURIReference { + readonly href: SVGAnimatedString; +} + +interface WindowBase64 { + atob(encodedString: string): string; + btoa(rawString: string): string; +} + +interface WindowConsole { + readonly console: Console; +} + +interface WindowLocalStorage { + readonly localStorage: Storage; +} + +interface WindowSessionStorage { + readonly sessionStorage: Storage; +} + +interface WindowTimers extends Object, WindowTimersExtension { + clearInterval(handle: number): void; + clearTimeout(handle: number): void; + setInterval(handler: (...args: any[]) => void, timeout: number): number; + setInterval(handler: any, timeout?: any, ...args: any[]): number; + setTimeout(handler: (...args: any[]) => void, timeout: number): number; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; +} + +interface WindowTimersExtension { + clearImmediate(handle: number): void; + setImmediate(handler: (...args: any[]) => void): number; + setImmediate(handler: any, ...args: any[]): number; +} + +interface XMLHttpRequestEventTargetEventMap { + "abort": Event; + "error": ErrorEvent; + "load": Event; + "loadend": ProgressEvent; + "loadstart": Event; + "progress": ProgressEvent; + "timeout": ProgressEvent; +} + +interface XMLHttpRequestEventTarget { + onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + +interface Canvas2DContextAttributes { + alpha?: boolean; + willReadFrequently?: boolean; + storage?: boolean; + [attribute: string]: boolean | string | undefined; +} + +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface HTMLCollectionOf extends HTMLCollection { + item(index: number): T; + namedItem(name: string): T; + [index: number]: T; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + +interface EventListenerObject { + handleEvent(evt: Event): void; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface ScrollOptions { + behavior?: ScrollBehavior; +} + +interface ScrollToOptions extends ScrollOptions { + left?: number; + top?: number; +} + +interface ScrollIntoViewOptions extends ScrollOptions { + block?: ScrollLogicalPosition; + inline?: ScrollLogicalPosition; +} + +interface ClipboardEventInit extends EventInit { + data?: string; + dataType?: string; +} + +interface IDBArrayKey extends Array { +} + +interface RsaKeyGenParams extends Algorithm { + modulusLength: number; + publicExponent: Uint8Array; +} + +interface RsaHashedKeyGenParams extends RsaKeyGenParams { + hash: AlgorithmIdentifier; +} + +interface RsaKeyAlgorithm extends KeyAlgorithm { + modulusLength: number; + publicExponent: Uint8Array; +} + +interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm { + hash: AlgorithmIdentifier; +} + +interface RsaHashedImportParams { + hash: AlgorithmIdentifier; +} + +interface RsaPssParams { + saltLength: number; +} + +interface RsaOaepParams extends Algorithm { + label?: BufferSource; +} + +interface EcdsaParams extends Algorithm { + hash: AlgorithmIdentifier; +} + +interface EcKeyGenParams extends Algorithm { + namedCurve: string; +} + +interface EcKeyAlgorithm extends KeyAlgorithm { + typedCurve: string; +} + +interface EcKeyImportParams { + namedCurve: string; +} + +interface EcdhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} + +interface AesCtrParams extends Algorithm { + counter: BufferSource; + length: number; +} + +interface AesKeyAlgorithm extends KeyAlgorithm { + length: number; +} + +interface AesKeyGenParams extends Algorithm { + length: number; +} + +interface AesDerivedKeyParams extends Algorithm { + length: number; +} + +interface AesCbcParams extends Algorithm { + iv: BufferSource; +} + +interface AesCmacParams extends Algorithm { + length: number; +} + +interface AesGcmParams extends Algorithm { + iv: BufferSource; + additionalData?: BufferSource; + tagLength?: number; +} + +interface AesCfbParams extends Algorithm { + iv: BufferSource; +} + +interface HmacImportParams extends Algorithm { + hash?: AlgorithmIdentifier; + length?: number; +} + +interface HmacKeyAlgorithm extends KeyAlgorithm { + hash: AlgorithmIdentifier; + length: number; +} + +interface HmacKeyGenParams extends Algorithm { + hash: AlgorithmIdentifier; + length?: number; +} + +interface DhKeyGenParams extends Algorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface DhKeyAlgorithm extends KeyAlgorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface DhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} + +interface DhImportKeyParams extends Algorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface ConcatParams extends Algorithm { + hash?: AlgorithmIdentifier; + algorithmId: Uint8Array; + partyUInfo: Uint8Array; + partyVInfo: Uint8Array; + publicInfo?: Uint8Array; + privateInfo?: Uint8Array; +} + +interface HkdfCtrParams extends Algorithm { + hash: AlgorithmIdentifier; + label: BufferSource; + context: BufferSource; +} + +interface Pbkdf2Params extends Algorithm { + salt: BufferSource; + iterations: number; + hash: AlgorithmIdentifier; +} + +interface RsaOtherPrimesInfo { + r: string; + d: string; + t: string; +} + +interface JsonWebKey { + kty: string; + use?: string; + key_ops?: string[]; + alg?: string; + kid?: string; + x5u?: string; + x5c?: string; + x5t?: string; + ext?: boolean; + crv?: string; + x?: string; + y?: string; + d?: string; + n?: string; + e?: string; + p?: string; + q?: string; + dp?: string; + dq?: string; + qi?: string; + oth?: RsaOtherPrimesInfo[]; + k?: string; +} + +interface ParentNode { + readonly children: HTMLCollection; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly childElementCount: number; +} + +interface DocumentOrShadowRoot { + readonly activeElement: Element | null; + readonly stylesheets: StyleSheetList; + getSelection(): Selection | null; + elementFromPoint(x: number, y: number): Element | null; + elementsFromPoint(x: number, y: number): Element[]; +} + +interface ShadowRoot extends DocumentOrShadowRoot, DocumentFragment { + readonly host: Element; + innerHTML: string; +} + +interface ShadowRootInit { + mode: 'open'|'closed'; + delegatesFocus?: boolean; +} + +interface HTMLSlotElement extends HTMLElement { + name: string; + assignedNodes(options?: AssignedNodesOptions): Node[]; +} + +interface AssignedNodesOptions { + flatten?: boolean; +} + +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + +interface TouchEventInit extends EventModifierInit { + touches?: Touch[]; + targetTouches?: Touch[]; + changedTouches?: Touch[]; +} + +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 VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} +interface FunctionStringCallback { + (data: string): void; +} +interface NavigatorUserMediaSuccessCallback { + (stream: MediaStream): void; +} +interface NavigatorUserMediaErrorCallback { + (error: MediaStreamError): void; +} +interface ForEachCallback { + (keyId: any, status: MediaKeyStatus): void; +} +interface NotificationPermissionCallback { + (permission: NotificationPermission): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} +interface HTMLElementTagNameMap { + "a": HTMLAnchorElement; + "applet": HTMLAppletElement; + "area": HTMLAreaElement; + "audio": HTMLAudioElement; + "base": HTMLBaseElement; + "basefont": HTMLBaseFontElement; + "blockquote": HTMLQuoteElement; + "body": HTMLBodyElement; + "br": HTMLBRElement; + "button": HTMLButtonElement; + "canvas": HTMLCanvasElement; + "caption": HTMLTableCaptionElement; + "col": HTMLTableColElement; + "colgroup": HTMLTableColElement; + "data": HTMLDataElement; + "datalist": HTMLDataListElement; + "del": HTMLModElement; + "dir": HTMLDirectoryElement; + "div": HTMLDivElement; + "dl": HTMLDListElement; + "embed": HTMLEmbedElement; + "fieldset": HTMLFieldSetElement; + "font": HTMLFontElement; + "form": HTMLFormElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "h1": HTMLHeadingElement; + "h2": HTMLHeadingElement; + "h3": HTMLHeadingElement; + "h4": HTMLHeadingElement; + "h5": HTMLHeadingElement; + "h6": HTMLHeadingElement; + "head": HTMLHeadElement; + "hr": HTMLHRElement; + "html": HTMLHtmlElement; + "iframe": HTMLIFrameElement; + "img": HTMLImageElement; + "input": HTMLInputElement; + "ins": HTMLModElement; + "isindex": HTMLUnknownElement; + "label": HTMLLabelElement; + "legend": HTMLLegendElement; + "li": HTMLLIElement; + "link": HTMLLinkElement; + "listing": HTMLPreElement; + "map": HTMLMapElement; + "marquee": HTMLMarqueeElement; + "menu": HTMLMenuElement; + "meta": HTMLMetaElement; + "meter": HTMLMeterElement; + "nextid": HTMLUnknownElement; + "object": HTMLObjectElement; + "ol": HTMLOListElement; + "optgroup": HTMLOptGroupElement; + "option": HTMLOptionElement; + "output": HTMLOutputElement; + "p": HTMLParagraphElement; + "param": HTMLParamElement; + "picture": HTMLPictureElement; + "pre": HTMLPreElement; + "progress": HTMLProgressElement; + "q": HTMLQuoteElement; + "script": HTMLScriptElement; + "select": HTMLSelectElement; + "source": HTMLSourceElement; + "span": HTMLSpanElement; + "style": HTMLStyleElement; + "table": HTMLTableElement; + "tbody": HTMLTableSectionElement; + "td": HTMLTableDataCellElement; + "template": HTMLTemplateElement; + "textarea": HTMLTextAreaElement; + "tfoot": HTMLTableSectionElement; + "th": HTMLTableHeaderCellElement; + "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; + "title": HTMLTitleElement; + "tr": HTMLTableRowElement; + "track": HTMLTrackElement; + "ul": HTMLUListElement; + "video": HTMLVideoElement; + "x-ms-webview": MSHTMLWebViewElement; + "xmp": HTMLPreElement; +} + +interface ElementTagNameMap { + "a": HTMLAnchorElement; + "abbr": HTMLElement; + "acronym": HTMLElement; + "address": HTMLElement; + "applet": HTMLAppletElement; + "area": HTMLAreaElement; + "article": HTMLElement; + "aside": HTMLElement; + "audio": HTMLAudioElement; + "b": HTMLElement; + "base": HTMLBaseElement; + "basefont": HTMLBaseFontElement; + "bdo": HTMLElement; + "big": HTMLElement; + "blockquote": HTMLQuoteElement; + "body": HTMLBodyElement; + "br": HTMLBRElement; + "button": HTMLButtonElement; + "canvas": HTMLCanvasElement; + "caption": HTMLTableCaptionElement; + "center": HTMLElement; + "circle": SVGCircleElement; + "cite": HTMLElement; + "clippath": SVGClipPathElement; + "code": HTMLElement; + "col": HTMLTableColElement; + "colgroup": HTMLTableColElement; + "data": HTMLDataElement; + "datalist": HTMLDataListElement; + "dd": HTMLElement; + "defs": SVGDefsElement; + "del": HTMLModElement; + "desc": SVGDescElement; + "dfn": HTMLElement; + "dir": HTMLDirectoryElement; + "div": HTMLDivElement; + "dl": HTMLDListElement; + "dt": HTMLElement; + "ellipse": SVGEllipseElement; + "em": HTMLElement; + "embed": HTMLEmbedElement; + "feblend": SVGFEBlendElement; + "fecolormatrix": SVGFEColorMatrixElement; + "fecomponenttransfer": SVGFEComponentTransferElement; + "fecomposite": SVGFECompositeElement; + "feconvolvematrix": SVGFEConvolveMatrixElement; + "fediffuselighting": SVGFEDiffuseLightingElement; + "fedisplacementmap": SVGFEDisplacementMapElement; + "fedistantlight": SVGFEDistantLightElement; + "feflood": SVGFEFloodElement; + "fefunca": SVGFEFuncAElement; + "fefuncb": SVGFEFuncBElement; + "fefuncg": SVGFEFuncGElement; + "fefuncr": SVGFEFuncRElement; + "fegaussianblur": SVGFEGaussianBlurElement; + "feimage": SVGFEImageElement; + "femerge": SVGFEMergeElement; + "femergenode": SVGFEMergeNodeElement; + "femorphology": SVGFEMorphologyElement; + "feoffset": SVGFEOffsetElement; + "fepointlight": SVGFEPointLightElement; + "fespecularlighting": SVGFESpecularLightingElement; + "fespotlight": SVGFESpotLightElement; + "fetile": SVGFETileElement; + "feturbulence": SVGFETurbulenceElement; + "fieldset": HTMLFieldSetElement; + "figcaption": HTMLElement; + "figure": HTMLElement; + "filter": SVGFilterElement; + "font": HTMLFontElement; + "footer": HTMLElement; + "foreignobject": SVGForeignObjectElement; + "form": HTMLFormElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "g": SVGGElement; + "h1": HTMLHeadingElement; + "h2": HTMLHeadingElement; + "h3": HTMLHeadingElement; + "h4": HTMLHeadingElement; + "h5": HTMLHeadingElement; + "h6": HTMLHeadingElement; + "head": HTMLHeadElement; + "header": HTMLElement; + "hgroup": HTMLElement; + "hr": HTMLHRElement; + "html": HTMLHtmlElement; + "i": HTMLElement; + "iframe": HTMLIFrameElement; + "image": SVGImageElement; + "img": HTMLImageElement; + "input": HTMLInputElement; + "ins": HTMLModElement; + "isindex": HTMLUnknownElement; + "kbd": HTMLElement; + "keygen": HTMLElement; + "label": HTMLLabelElement; + "legend": HTMLLegendElement; + "li": HTMLLIElement; + "line": SVGLineElement; + "lineargradient": SVGLinearGradientElement; + "link": HTMLLinkElement; + "listing": HTMLPreElement; + "map": HTMLMapElement; + "mark": HTMLElement; + "marker": SVGMarkerElement; + "marquee": HTMLMarqueeElement; + "mask": SVGMaskElement; + "menu": HTMLMenuElement; + "meta": HTMLMetaElement; + "metadata": SVGMetadataElement; + "meter": HTMLMeterElement; + "nav": HTMLElement; + "nextid": HTMLUnknownElement; + "nobr": HTMLElement; + "noframes": HTMLElement; + "noscript": HTMLElement; + "object": HTMLObjectElement; + "ol": HTMLOListElement; + "optgroup": HTMLOptGroupElement; + "option": HTMLOptionElement; + "output": HTMLOutputElement; + "p": HTMLParagraphElement; + "param": HTMLParamElement; + "path": SVGPathElement; + "pattern": SVGPatternElement; + "picture": HTMLPictureElement; + "plaintext": HTMLElement; + "polygon": SVGPolygonElement; + "polyline": SVGPolylineElement; + "pre": HTMLPreElement; + "progress": HTMLProgressElement; + "q": HTMLQuoteElement; + "radialgradient": SVGRadialGradientElement; + "rect": SVGRectElement; + "rt": HTMLElement; + "ruby": HTMLElement; + "s": HTMLElement; + "samp": HTMLElement; + "script": HTMLScriptElement; + "section": HTMLElement; + "select": HTMLSelectElement; + "small": HTMLElement; + "source": HTMLSourceElement; + "span": HTMLSpanElement; + "stop": SVGStopElement; + "strike": HTMLElement; + "strong": HTMLElement; + "style": HTMLStyleElement; + "sub": HTMLElement; + "sup": HTMLElement; + "svg": SVGSVGElement; + "switch": SVGSwitchElement; + "symbol": SVGSymbolElement; + "table": HTMLTableElement; + "tbody": HTMLTableSectionElement; + "td": HTMLTableDataCellElement; + "template": HTMLTemplateElement; + "text": SVGTextElement; + "textpath": SVGTextPathElement; + "textarea": HTMLTextAreaElement; + "tfoot": HTMLTableSectionElement; + "th": HTMLTableHeaderCellElement; + "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; + "title": HTMLTitleElement; + "tr": HTMLTableRowElement; + "track": HTMLTrackElement; + "tspan": SVGTSpanElement; + "tt": HTMLElement; + "u": HTMLElement; + "ul": HTMLUListElement; + "use": SVGUseElement; + "var": HTMLElement; + "video": HTMLVideoElement; + "view": SVGViewElement; + "wbr": HTMLElement; + "x-ms-webview": MSHTMLWebViewElement; + "xmp": HTMLPreElement; +} + +interface ElementListTagNameMap { + "a": NodeListOf; + "abbr": NodeListOf; + "acronym": NodeListOf; + "address": NodeListOf; + "applet": NodeListOf; + "area": NodeListOf; + "article": NodeListOf; + "aside": NodeListOf; + "audio": NodeListOf; + "b": NodeListOf; + "base": NodeListOf; + "basefont": NodeListOf; + "bdo": NodeListOf; + "big": NodeListOf; + "blockquote": NodeListOf; + "body": NodeListOf; + "br": NodeListOf; + "button": NodeListOf; + "canvas": NodeListOf; + "caption": NodeListOf; + "center": NodeListOf; + "circle": NodeListOf; + "cite": NodeListOf; + "clippath": NodeListOf; + "code": NodeListOf; + "col": NodeListOf; + "colgroup": NodeListOf; + "data": NodeListOf; + "datalist": NodeListOf; + "dd": NodeListOf; + "defs": NodeListOf; + "del": NodeListOf; + "desc": NodeListOf; + "dfn": NodeListOf; + "dir": NodeListOf; + "div": NodeListOf; + "dl": NodeListOf; + "dt": NodeListOf; + "ellipse": NodeListOf; + "em": NodeListOf; + "embed": NodeListOf; + "feblend": NodeListOf; + "fecolormatrix": NodeListOf; + "fecomponenttransfer": NodeListOf; + "fecomposite": NodeListOf; + "feconvolvematrix": NodeListOf; + "fediffuselighting": NodeListOf; + "fedisplacementmap": NodeListOf; + "fedistantlight": NodeListOf; + "feflood": NodeListOf; + "fefunca": NodeListOf; + "fefuncb": NodeListOf; + "fefuncg": NodeListOf; + "fefuncr": NodeListOf; + "fegaussianblur": NodeListOf; + "feimage": NodeListOf; + "femerge": NodeListOf; + "femergenode": NodeListOf; + "femorphology": NodeListOf; + "feoffset": NodeListOf; + "fepointlight": NodeListOf; + "fespecularlighting": NodeListOf; + "fespotlight": NodeListOf; + "fetile": NodeListOf; + "feturbulence": NodeListOf; + "fieldset": NodeListOf; + "figcaption": NodeListOf; + "figure": NodeListOf; + "filter": NodeListOf; + "font": NodeListOf; + "footer": NodeListOf; + "foreignobject": NodeListOf; + "form": NodeListOf; + "frame": NodeListOf; + "frameset": NodeListOf; + "g": NodeListOf; + "h1": NodeListOf; + "h2": NodeListOf; + "h3": NodeListOf; + "h4": NodeListOf; + "h5": NodeListOf; + "h6": NodeListOf; + "head": NodeListOf; + "header": NodeListOf; + "hgroup": NodeListOf; + "hr": NodeListOf; + "html": NodeListOf; + "i": NodeListOf; + "iframe": NodeListOf; + "image": NodeListOf; + "img": NodeListOf; + "input": NodeListOf; + "ins": NodeListOf; + "isindex": NodeListOf; + "kbd": NodeListOf; + "keygen": NodeListOf; + "label": NodeListOf; + "legend": NodeListOf; + "li": NodeListOf; + "line": NodeListOf; + "lineargradient": NodeListOf; + "link": NodeListOf; + "listing": NodeListOf; + "map": NodeListOf; + "mark": NodeListOf; + "marker": NodeListOf; + "marquee": NodeListOf; + "mask": NodeListOf; + "menu": NodeListOf; + "meta": NodeListOf; + "metadata": NodeListOf; + "meter": NodeListOf; + "nav": NodeListOf; + "nextid": NodeListOf; + "nobr": NodeListOf; + "noframes": NodeListOf; + "noscript": NodeListOf; + "object": NodeListOf; + "ol": NodeListOf; + "optgroup": NodeListOf; + "option": NodeListOf; + "output": NodeListOf; + "p": NodeListOf; + "param": NodeListOf; + "path": NodeListOf; + "pattern": NodeListOf; + "picture": NodeListOf; + "plaintext": NodeListOf; + "polygon": NodeListOf; + "polyline": NodeListOf; + "pre": NodeListOf; + "progress": NodeListOf; + "q": NodeListOf; + "radialgradient": NodeListOf; + "rect": NodeListOf; + "rt": NodeListOf; + "ruby": NodeListOf; + "s": NodeListOf; + "samp": NodeListOf; + "script": NodeListOf; + "section": NodeListOf; + "select": NodeListOf; + "small": NodeListOf; + "source": NodeListOf; + "span": NodeListOf; + "stop": NodeListOf; + "strike": NodeListOf; + "strong": NodeListOf; + "style": NodeListOf; + "sub": NodeListOf; + "sup": NodeListOf; + "svg": NodeListOf; + "switch": NodeListOf; + "symbol": NodeListOf; + "table": NodeListOf; + "tbody": NodeListOf; + "td": NodeListOf; + "template": NodeListOf; + "text": NodeListOf; + "textpath": NodeListOf; + "textarea": NodeListOf; + "tfoot": NodeListOf; + "th": NodeListOf; + "thead": NodeListOf; + "time": NodeListOf; + "title": NodeListOf; + "tr": NodeListOf; + "track": NodeListOf; + "tspan": NodeListOf; + "tt": NodeListOf; + "u": NodeListOf; + "ul": NodeListOf; + "use": NodeListOf; + "var": NodeListOf; + "video": NodeListOf; + "view": NodeListOf; + "wbr": NodeListOf; + "x-ms-webview": NodeListOf; + "xmp": NodeListOf; +} + +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 applicationCache: ApplicationCache; +declare var caches: CacheStorage; +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 | undefined; +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 isSecureContext: boolean; +declare var length: number; +declare var location: Location; +declare var locationbar: BarProp; +declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; +declare var msCredentials: MSCredentials; +declare const name: never; +declare var navigator: Navigator; +declare var offscreenBuffering: string | boolean; +declare var onabort: (this: Window, ev: UIEvent) => any; +declare var onafterprint: (this: Window, ev: Event) => any; +declare var onbeforeprint: (this: Window, ev: Event) => any; +declare var onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; +declare var onblur: (this: Window, ev: FocusEvent) => any; +declare var oncanplay: (this: Window, ev: Event) => any; +declare var oncanplaythrough: (this: Window, ev: Event) => any; +declare var onchange: (this: Window, ev: Event) => any; +declare var onclick: (this: Window, ev: MouseEvent) => any; +declare var oncompassneedscalibration: (this: Window, ev: Event) => any; +declare var oncontextmenu: (this: Window, ev: PointerEvent) => any; +declare var ondblclick: (this: Window, ev: MouseEvent) => any; +declare var ondevicelight: (this: Window, ev: DeviceLightEvent) => any; +declare var ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; +declare var ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; +declare var ondrag: (this: Window, ev: DragEvent) => any; +declare var ondragend: (this: Window, ev: DragEvent) => any; +declare var ondragenter: (this: Window, ev: DragEvent) => any; +declare var ondragleave: (this: Window, ev: DragEvent) => any; +declare var ondragover: (this: Window, ev: DragEvent) => any; +declare var ondragstart: (this: Window, ev: DragEvent) => any; +declare var ondrop: (this: Window, ev: DragEvent) => any; +declare var ondurationchange: (this: Window, ev: Event) => any; +declare var onemptied: (this: Window, ev: Event) => any; +declare var onended: (this: Window, ev: MediaStreamErrorEvent) => any; +declare var onerror: ErrorEventHandler; +declare var onfocus: (this: Window, ev: FocusEvent) => any; +declare var onhashchange: (this: Window, ev: HashChangeEvent) => any; +declare var oninput: (this: Window, ev: Event) => any; +declare var oninvalid: (this: Window, ev: Event) => any; +declare var onkeydown: (this: Window, ev: KeyboardEvent) => any; +declare var onkeypress: (this: Window, ev: KeyboardEvent) => any; +declare var onkeyup: (this: Window, ev: KeyboardEvent) => any; +declare var onload: (this: Window, ev: Event) => any; +declare var onloadeddata: (this: Window, ev: Event) => any; +declare var onloadedmetadata: (this: Window, ev: Event) => any; +declare var onloadstart: (this: Window, ev: Event) => any; +declare var onmessage: (this: Window, ev: MessageEvent) => any; +declare var onmousedown: (this: Window, ev: MouseEvent) => any; +declare var onmouseenter: (this: Window, ev: MouseEvent) => any; +declare var onmouseleave: (this: Window, ev: MouseEvent) => any; +declare var onmousemove: (this: Window, ev: MouseEvent) => any; +declare var onmouseout: (this: Window, ev: MouseEvent) => any; +declare var onmouseover: (this: Window, ev: MouseEvent) => any; +declare var onmouseup: (this: Window, ev: MouseEvent) => any; +declare var onmousewheel: (this: Window, ev: WheelEvent) => any; +declare var onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgestureend: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; +declare var onmspointercancel: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerdown: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerenter: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerleave: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointermove: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerout: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerover: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerup: (this: Window, ev: MSPointerEvent) => any; +declare var onoffline: (this: Window, ev: Event) => any; +declare var ononline: (this: Window, ev: Event) => any; +declare var onorientationchange: (this: Window, ev: Event) => any; +declare var onpagehide: (this: Window, ev: PageTransitionEvent) => any; +declare var onpageshow: (this: Window, ev: PageTransitionEvent) => any; +declare var onpause: (this: Window, ev: Event) => any; +declare var onplay: (this: Window, ev: Event) => any; +declare var onplaying: (this: Window, ev: Event) => any; +declare var onpopstate: (this: Window, ev: PopStateEvent) => any; +declare var onprogress: (this: Window, ev: ProgressEvent) => any; +declare var onratechange: (this: Window, ev: Event) => any; +declare var onreadystatechange: (this: Window, ev: ProgressEvent) => any; +declare var onreset: (this: Window, ev: Event) => any; +declare var onresize: (this: Window, ev: UIEvent) => any; +declare var onscroll: (this: Window, ev: UIEvent) => any; +declare var onseeked: (this: Window, ev: Event) => any; +declare var onseeking: (this: Window, ev: Event) => any; +declare var onselect: (this: Window, ev: UIEvent) => any; +declare var onstalled: (this: Window, ev: Event) => any; +declare var onstorage: (this: Window, ev: StorageEvent) => any; +declare var onsubmit: (this: Window, ev: Event) => any; +declare var onsuspend: (this: Window, ev: Event) => any; +declare var ontimeupdate: (this: Window, ev: Event) => any; +declare var ontouchcancel: (ev: TouchEvent) => any; +declare var ontouchend: (ev: TouchEvent) => any; +declare var ontouchmove: (ev: TouchEvent) => any; +declare var ontouchstart: (ev: TouchEvent) => any; +declare var onunload: (this: Window, ev: Event) => any; +declare var onvolumechange: (this: Window, ev: Event) => any; +declare var onwaiting: (this: Window, ev: Event) => any; +declare var opener: any; +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 speechSynthesis: SpeechSynthesis; +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 customElements: CustomElementRegistry; +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 departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; +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 msWriteProfilerMark(profilerMarkName: string): void; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function postMessage(message: any, targetOrigin: string, transfer?: any[]): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string | null; +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 stop(): void; +declare function webkitCancelAnimationFrame(handle: number): void; +declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; +declare function scroll(options?: ScrollToOptions): void; +declare function scrollTo(options?: ScrollToOptions): void; +declare function scrollBy(options?: ScrollToOptions): void; +declare function toString(): string; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare function clearInterval(handle: number): void; +declare function clearTimeout(handle: number): void; +declare function setInterval(handler: (...args: any[]) => void, timeout: number): number; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function setImmediate(handler: (...args: any[]) => void): number; +declare function setImmediate(handler: any, ...args: any[]): number; +declare var sessionStorage: Storage; +declare var localStorage: Storage; +declare var console: Console; +declare var onpointercancel: (this: Window, ev: PointerEvent) => any; +declare var onpointerdown: (this: Window, ev: PointerEvent) => any; +declare var onpointerenter: (this: Window, ev: PointerEvent) => any; +declare var onpointerleave: (this: Window, ev: PointerEvent) => any; +declare var onpointermove: (this: Window, ev: PointerEvent) => any; +declare var onpointerout: (this: Window, ev: PointerEvent) => any; +declare var onpointerover: (this: Window, ev: PointerEvent) => any; +declare var onpointerup: (this: Window, ev: PointerEvent) => any; +declare var onwheel: (this: Window, ev: WheelEvent) => any; +declare var indexedDB: IDBFactory; +declare function atob(encodedString: string): string; +declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +type AAGUID = string; +type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; +type ConstrainBoolean = boolean | ConstrainBooleanParameters; +type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; +type ConstrainDouble = number | ConstrainDoubleRange; +type ConstrainLong = number | ConstrainLongRange; +type CryptoOperationData = ArrayBufferView; +type GLbitfield = number; +type GLboolean = boolean; +type GLbyte = number; +type GLclampf = number; +type GLenum = number; +type GLfloat = number; +type GLint = number; +type GLintptr = number; +type GLshort = number; +type GLsizei = number; +type GLsizeiptr = number; +type GLubyte = number; +type GLuint = number; +type GLushort = number; +type HeadersInit = any; +type IDBKeyPath = string; +type KeyFormat = string; +type KeyType = string; +type KeyUsage = string; +type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; +type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; +type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; +type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; +type payloadtype = number; +type ScrollBehavior = "auto" | "instant" | "smooth"; +type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; +type IDBValidKey = number | string | Date | IDBArrayKey; +type BufferSource = ArrayBuffer | ArrayBufferView; +type MouseWheelEvent = WheelEvent; +type ScrollRestoration = "auto" | "manual"; +type FormDataEntryValue = string | File; +type AppendMode = "segments" | "sequence"; +type AudioContextState = "suspended" | "running" | "closed"; +type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; +type CanvasFillRule = "nonzero" | "evenodd"; +type ChannelCountMode = "max" | "clamped-max" | "explicit"; +type ChannelInterpretation = "speakers" | "discrete"; +type DistanceModelType = "linear" | "inverse" | "exponential"; +type ExpandGranularity = "character" | "word" | "sentence" | "textedit"; +type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad"; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type ListeningState = "inactive" | "active" | "disambiguation"; +type MSCredentialType = "FIDO_2_0"; +type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived"; +type MSIceType = "failed" | "direct" | "relay"; +type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics"; +type MSTransportType = "Embedded" | "USB" | "NFC" | "BT"; +type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny"; +type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications"; +type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; +type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request"; +type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type MediaKeysRequirement = "required" | "optional" | "not-allowed"; +type MediaStreamTrackState = "live" | "ended"; +type NavigationReason = "up" | "down" | "left" | "right"; +type NavigationType = "navigate" | "reload" | "back_forward" | "prerender"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom"; +type OverSampleType = "none" | "2x" | "4x"; +type PanningModelType = "equalpower"; +type PaymentComplete = "success" | "fail" | ""; +type PaymentShippingType = "shipping" | "delivery" | "pickup"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle"; +type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced"; +type RTCDtlsRole = "auto" | "client" | "server"; +type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed"; +type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay"; +type RTCIceComponent = "RTP" | "RTCP"; +type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"; +type RTCIceGatherPolicy = "all" | "nohost" | "relay"; +type RTCIceGathererState = "new" | "gathering" | "complete"; +type RTCIceGatheringState = "new" | "gathering" | "complete"; +type RTCIceProtocol = "udp" | "tcp"; +type RTCIceRole = "controlling" | "controlled"; +type RTCIceTcpCandidateType = "active" | "passive" | "so"; +type RTCIceTransportPolicy = "none" | "relay" | "all"; +type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed"; +type RTCSdpType = "offer" | "pranswer" | "answer"; +type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"; +type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled"; +type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed"; +type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ScopedCredentialType = "ScopedCred"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type Transport = "usb" | "nfc" | "ble"; +type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; + + +///////////////////////////// +/// 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; + +/** + * Automation date (VT_DATE) + */ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; +} + +interface Date { + getVarDate: () => VarDate; +} + + +/// + +interface DOMTokenList { + [Symbol.iterator](): IterableIterator; +} + +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, string | File]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface Headers { + [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value pairs contained in this object. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all keys f the key/value pairs contained in this object. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values of the key/value pairs contained in this object. + */ + values(): IterableIterator; +} + +interface NodeList { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; +} + +interface NodeListOf { + + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; + + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface URLSearchParams { + /** + * Returns an array of key, value pairs for every entry in the search params + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns a list of keys in the search params + */ + keys(): IterableIterator; + /** + * Returns a list of values in the search params + */ + values(): IterableIterator; + /** + * iterate over key/value pairs + */ + [Symbol.iterator](): IterableIterator<[string, string]>; +} diff --git a/lib/lib.es2017.object.d.ts b/lib/lib.es2017.object.d.ts index 2e4e673d060..00c11be275d 100644 --- a/lib/lib.es2017.object.d.ts +++ b/lib/lib.es2017.object.d.ts @@ -20,26 +20,26 @@ and limitations under the License. interface ObjectConstructor { /** - * Returns an array of values of the enumerable properties 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. - */ + * Returns an array of values of the enumerable properties 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. + */ values(o: { [s: string]: T }): T[]; /** - * Returns an array of values of the enumerable properties 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. - */ + * Returns an array of values of the enumerable properties 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. + */ values(o: any): any[]; /** - * Returns an array of key/values of the enumerable properties 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. - */ + * Returns an array of key/values of the enumerable properties 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. + */ entries(o: { [s: string]: T }): [string, T][]; /** - * Returns an array of key/values of the enumerable properties 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. - */ + * Returns an array of key/values of the enumerable properties 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. + */ entries(o: any): [string, any][]; } diff --git a/lib/lib.es2017.sharedmemory.d.ts b/lib/lib.es2017.sharedmemory.d.ts index 656caaefee7..c0254f1dc2c 100644 --- a/lib/lib.es2017.sharedmemory.d.ts +++ b/lib/lib.es2017.sharedmemory.d.ts @@ -23,8 +23,8 @@ and limitations under the License. interface SharedArrayBuffer { /** - * Read-only. The length of the ArrayBuffer (in bytes). - */ + * Read-only. The length of the ArrayBuffer (in bytes). + */ readonly byteLength: number; /* @@ -32,9 +32,9 @@ interface SharedArrayBuffer { */ length: number; /** - * Returns a section of an SharedArrayBuffer. - */ - slice(begin:number, end?:number): SharedArrayBuffer; + * Returns a section of an SharedArrayBuffer. + */ + slice(begin: number, end?: number): SharedArrayBuffer; readonly [Symbol.species]: SharedArrayBuffer; readonly [Symbol.toStringTag]: "SharedArrayBuffer"; } diff --git a/lib/lib.es2017.string.d.ts b/lib/lib.es2017.string.d.ts index 303c4644b96..dad64f0d864 100644 --- a/lib/lib.es2017.string.d.ts +++ b/lib/lib.es2017.string.d.ts @@ -20,28 +20,28 @@ and limitations under the License. interface String { /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the start (left) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the start (left) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ padStart(maxLength: number, fillString?: string): string; /** - * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. - * The padding is applied from the end (right) of the current string. - * - * @param maxLength The length of the resulting string once the current string has been padded. - * If this parameter is smaller than the current string's length, the current string will be returned as it is. - * - * @param fillString The string to pad the current string with. - * If this string is too long, it will be truncated and the left-most part will be applied. - * The default value for this parameter is " " (U+0020). - */ + * Pads the current string with a given string (possibly repeated) so that the resulting string reaches a given length. + * The padding is applied from the end (right) of the current string. + * + * @param maxLength The length of the resulting string once the current string has been padded. + * If this parameter is smaller than the current string's length, the current string will be returned as it is. + * + * @param fillString The string to pad the current string with. + * If this string is too long, it will be truncated and the left-most part will be applied. + * The default value for this parameter is " " (U+0020). + */ padEnd(maxLength: number, fillString?: string): string; } diff --git a/lib/lib.es5.d.ts b/lib/lib.es5.d.ts index f0c6e9fb861..1d19198d1d1 100644 --- a/lib/lib.es5.d.ts +++ b/lib/lib.es5.d.ts @@ -160,14 +160,14 @@ interface ObjectConstructor { * Creates an object that has the specified prototype or that has null prototype. * @param o Object to use as a prototype. May be null. */ - create(o: T | null): T | object; + create(o: object | null): any; /** * 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: object | null, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -175,14 +175,14 @@ interface ObjectConstructor { * @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; + defineProperty(o: any, p: string, attributes: PropertyDescriptor & ThisType): 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; + defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. @@ -345,53 +345,27 @@ interface String { * 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 | null; - - /** - * 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 | null; + match(regexp: string | RegExp): RegExpMatchArray | null; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ - replace(searchValue: string, replaceValue: string): string; + replace(searchValue: string | RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @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; + replace(searchValue: string | 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; + search(regexp: string | RegExp): number; /** * Returns a section of a string. @@ -406,14 +380,7 @@ interface String { * @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[]; + split(separator: string | RegExp, limit?: number): string[]; /** * Returns the substring at the specified location within a String object. @@ -543,7 +510,7 @@ interface NumberConstructor { declare const Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray + readonly raw: ReadonlyArray; } interface Math { @@ -881,9 +848,9 @@ interface RegExp { } interface RegExpConstructor { - new (pattern: RegExp): RegExp; + new (pattern: RegExp | string): RegExp; new (pattern: string, flags?: string): RegExp; - (pattern: RegExp): RegExp; + (pattern: RegExp | string): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; @@ -1070,37 +1037,49 @@ interface ReadonlyArray { * @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; + every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): 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; + some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): 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; + forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void): void; + forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => void, thisArg: Z): 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[]; + map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U): U[]; + map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => U, thisArg: Z): 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) => value is S, thisArg?: any): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: undefined): S[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: Z): S[]; /** * 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) => any, thisArg?: any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => any, thisArg: Z): 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. @@ -1217,55 +1196,73 @@ interface Array { * @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; + every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; + every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): 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; + some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; + some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): 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; + forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void): void; + forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: T[]) => void, thisArg: Z): 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(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; /** * 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(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; /** * 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(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; /** * 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(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; + map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U]; + map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; + map(this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; /** * 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[]; + map(callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; + map(callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): 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[]) => any, thisArg?: any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => any, thisArg: Z): 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. @@ -1377,14 +1374,19 @@ type Readonly = { */ type Pick = { [P in K]: T[P]; -} +}; /** * Construct a type with a set of properties K of type T */ type Record = { [P in K]: T; -} +}; + +/** + * Marker for contextual 'this' type + */ +interface ThisType { } /** * Represents a raw buffer of binary data, which is used to store data for the @@ -1401,7 +1403,7 @@ interface ArrayBuffer { /** * Returns a section of an ArrayBuffer. */ - slice(begin:number, end?:number): ArrayBuffer; + slice(begin: number, end?: number): ArrayBuffer; } interface ArrayBufferConstructor { @@ -1605,7 +1607,9 @@ interface Int8Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1624,7 +1628,9 @@ interface Int8Array { * @param thisArg 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) => any, thisArg?: any): Int8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any): Int8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any, thisArg: undefined): Int8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => any, thisArg: Z): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1635,7 +1641,9 @@ interface Int8Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1646,7 +1654,9 @@ interface Int8Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1655,7 +1665,9 @@ interface Int8Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1693,7 +1705,9 @@ interface Int8Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number): Int8Array; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg: undefined): Int8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => number, thisArg: Z): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1748,13 +1762,6 @@ interface Int8Array { */ 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. @@ -1777,7 +1784,9 @@ interface Int8Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -1829,7 +1838,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: ArrayLike): Int8Array; } declare const Int8Array: Int8ArrayConstructor; @@ -1878,7 +1891,9 @@ interface Uint8Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1897,7 +1912,9 @@ interface Uint8Array { * @param thisArg 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) => any, thisArg?: any): Uint8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any): Uint8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any, thisArg: undefined): Uint8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => any, thisArg: Z): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1908,7 +1925,9 @@ interface Uint8Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1919,7 +1938,9 @@ interface Uint8Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1928,7 +1949,9 @@ interface Uint8Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1966,7 +1989,9 @@ interface Uint8Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number): Uint8Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg: undefined): Uint8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => number, thisArg: Z): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2021,13 +2046,6 @@ interface Uint8Array { */ 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. @@ -2050,7 +2068,9 @@ interface Uint8Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2103,7 +2123,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: ArrayLike): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2152,7 +2176,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2171,7 +2197,9 @@ interface Uint8ClampedArray { * @param thisArg 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) => any, thisArg?: any): Uint8ClampedArray; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any): Uint8ClampedArray; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: undefined): Uint8ClampedArray; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: Z): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2182,7 +2210,9 @@ interface Uint8ClampedArray { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2193,7 +2223,9 @@ interface Uint8ClampedArray { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2202,7 +2234,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2240,7 +2274,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number): Uint8ClampedArray; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: undefined): Uint8ClampedArray; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: Z): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2295,19 +2331,12 @@ interface Uint8ClampedArray { */ 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; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2324,7 +2353,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2377,7 +2408,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: ArrayLike): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2425,7 +2460,9 @@ interface Int16Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2444,7 +2481,9 @@ interface Int16Array { * @param thisArg 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) => any, thisArg?: any): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg: undefined): Int16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => any, thisArg: Z): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2455,7 +2494,9 @@ interface Int16Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2466,7 +2507,9 @@ interface Int16Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2475,7 +2518,9 @@ interface Int16Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2513,7 +2558,9 @@ interface Int16Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number): Int16Array; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg: undefined): Int16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => number, thisArg: Z): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2568,13 +2615,6 @@ interface Int16Array { */ 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. @@ -2597,7 +2637,9 @@ interface Int16Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2650,7 +2692,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: ArrayLike): Int16Array; } declare const Int16Array: Int16ArrayConstructor; @@ -2699,7 +2745,9 @@ interface Uint16Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2718,7 +2766,9 @@ interface Uint16Array { * @param thisArg 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) => any, thisArg?: any): Uint16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any): Uint16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any, thisArg: undefined): Uint16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => any, thisArg: Z): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2729,7 +2779,9 @@ interface Uint16Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2740,7 +2792,9 @@ interface Uint16Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2749,7 +2803,9 @@ interface Uint16Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2787,7 +2843,9 @@ interface Uint16Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number): Uint16Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg: undefined): Uint16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => number, thisArg: Z): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2842,13 +2900,6 @@ interface Uint16Array { */ 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. @@ -2871,7 +2922,9 @@ interface Uint16Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2924,7 +2977,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: ArrayLike): Uint16Array; } declare const Uint16Array: Uint16ArrayConstructor; @@ -2972,7 +3029,9 @@ interface Int32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2991,7 +3050,9 @@ interface Int32Array { * @param thisArg 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) => any, thisArg?: any): Int32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any): Int32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any, thisArg: undefined): Int32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => any, thisArg: Z): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3002,7 +3063,9 @@ interface Int32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3013,7 +3076,9 @@ interface Int32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3022,7 +3087,9 @@ interface Int32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3060,7 +3127,9 @@ interface Int32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number): Int32Array; + map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number, thisArg: undefined): Int32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => number, thisArg: Z): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3115,13 +3184,6 @@ interface Int32Array { */ 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. @@ -3144,7 +3206,9 @@ interface Int32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3197,7 +3261,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: ArrayLike): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3245,7 +3313,9 @@ interface Uint32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3264,7 +3334,9 @@ interface Uint32Array { * @param thisArg 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) => any, thisArg?: any): Uint32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any): Uint32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any, thisArg: undefined): Uint32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => any, thisArg: Z): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3275,7 +3347,9 @@ interface Uint32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3286,7 +3360,9 @@ interface Uint32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3295,7 +3371,9 @@ interface Uint32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3333,7 +3411,9 @@ interface Uint32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number): Uint32Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg: undefined): Uint32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => number, thisArg: Z): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3388,13 +3468,6 @@ interface Uint32Array { */ 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. @@ -3417,7 +3490,9 @@ interface Uint32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3470,7 +3545,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: ArrayLike): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3518,7 +3597,9 @@ interface Float32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3537,7 +3618,9 @@ interface Float32Array { * @param thisArg 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) => any, thisArg?: any): Float32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any): Float32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any, thisArg: undefined): Float32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => any, thisArg: Z): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3548,7 +3631,9 @@ interface Float32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3559,7 +3644,9 @@ interface Float32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3568,7 +3655,9 @@ interface Float32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3606,7 +3695,9 @@ interface Float32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number): Float32Array; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg: undefined): Float32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => number, thisArg: Z): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3661,13 +3752,6 @@ interface Float32Array { */ 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. @@ -3690,7 +3774,9 @@ interface Float32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3743,7 +3829,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: ArrayLike): Float32Array; } declare const Float32Array: Float32ArrayConstructor; @@ -3792,7 +3882,9 @@ interface Float64Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3811,7 +3903,9 @@ interface Float64Array { * @param thisArg 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) => any, thisArg?: any): Float64Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any): Float64Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any, thisArg: undefined): Float64Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => any, thisArg: Z): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3822,7 +3916,9 @@ interface Float64Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3833,7 +3929,9 @@ interface Float64Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3842,7 +3940,9 @@ interface Float64Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3880,7 +3980,9 @@ interface Float64Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number): Float64Array; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg: undefined): Float64Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => number, thisArg: Z): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3935,13 +4037,6 @@ interface Float64Array { */ 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. @@ -3964,7 +4059,9 @@ interface Float64Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -4017,7 +4114,11 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: ArrayLike): Float64Array; } declare const Float64Array: Float64ArrayConstructor; @@ -4025,7 +4126,7 @@ declare const Float64Array: Float64ArrayConstructor; /// ECMAScript Internationalization API ///////////////////////////// -declare module Intl { +declare namespace Intl { interface CollatorOptions { usage?: string; localeMatcher?: string; @@ -4053,7 +4154,7 @@ declare module Intl { new (locales?: string | string[], options?: CollatorOptions): Collator; (locales?: string | string[], options?: CollatorOptions): Collator; supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[]; - } + }; interface NumberFormatOptions { localeMatcher?: string; @@ -4090,7 +4191,7 @@ declare module Intl { new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; - } + }; interface DateTimeFormatOptions { localeMatcher?: string; @@ -4133,7 +4234,7 @@ declare module Intl { new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[]; - } + }; } interface String { diff --git a/lib/lib.es6.d.ts b/lib/lib.es6.d.ts index 777141c0dba..76dc84306ed 100644 --- a/lib/lib.es6.d.ts +++ b/lib/lib.es6.d.ts @@ -160,14 +160,14 @@ interface ObjectConstructor { * Creates an object that has the specified prototype or that has null prototype. * @param o Object to use as a prototype. May be null. */ - create(o: T | null): T | object; + create(o: object | null): any; /** * 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: object | null, properties: PropertyDescriptorMap): any; + create(o: object | null, properties: PropertyDescriptorMap & ThisType): any; /** * Adds a property to an object, or modifies attributes of an existing property. @@ -175,14 +175,14 @@ interface ObjectConstructor { * @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; + defineProperty(o: any, p: string, attributes: PropertyDescriptor & ThisType): 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; + defineProperties(o: any, properties: PropertyDescriptorMap & ThisType): any; /** * Prevents the modification of attributes of existing properties, and prevents the addition of new properties. @@ -345,53 +345,27 @@ interface String { * 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 | null; - - /** - * 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 | null; + match(regexp: string | RegExp): RegExpMatchArray | null; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @param replaceValue A string containing the text to replace for every successful match of searchValue in this string. */ - replace(searchValue: string, replaceValue: string): string; + replace(searchValue: string | RegExp, replaceValue: string): string; /** * Replaces text in a string, using a regular expression or search string. * @param searchValue A string to search for. * @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; + replace(searchValue: string | 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; + search(regexp: string | RegExp): number; /** * Returns a section of a string. @@ -406,14 +380,7 @@ interface String { * @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[]; + split(separator: string | RegExp, limit?: number): string[]; /** * Returns the substring at the specified location within a String object. @@ -543,7 +510,7 @@ interface NumberConstructor { declare const Number: NumberConstructor; interface TemplateStringsArray extends ReadonlyArray { - readonly raw: ReadonlyArray + readonly raw: ReadonlyArray; } interface Math { @@ -881,9 +848,9 @@ interface RegExp { } interface RegExpConstructor { - new (pattern: RegExp): RegExp; + new (pattern: RegExp | string): RegExp; new (pattern: string, flags?: string): RegExp; - (pattern: RegExp): RegExp; + (pattern: RegExp | string): RegExp; (pattern: string, flags?: string): RegExp; readonly prototype: RegExp; @@ -1070,37 +1037,49 @@ interface ReadonlyArray { * @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; + every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + every(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): 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; + some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean): boolean; + some(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => boolean, thisArg: Z): 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; + forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void): void; + forEach(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => void, thisArg: Z): 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[]; + map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U): U[]; + map(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => U, thisArg: Z): 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) => value is S, thisArg?: any): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S): S[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: undefined): S[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => value is S, thisArg: Z): S[]; /** * 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) => any, thisArg?: any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: ReadonlyArray) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: ReadonlyArray) => any, thisArg: Z): 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. @@ -1217,55 +1196,73 @@ interface Array { * @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; + every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; + every(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): 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; + some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean): boolean; + some(callbackfn: (this: void, value: T, index: number, array: T[]) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: T, index: number, array: T[]) => boolean, thisArg: Z): 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; + forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void): void; + forEach(callbackfn: (this: void, value: T, index: number, array: T[]) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: T, index: number, array: T[]) => void, thisArg: Z): 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(this: [T, T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U, U]; + map(this: [T, T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U, U]; /** * 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(this: [T, T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U, U]; + map(this: [T, T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U, U]; /** * 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(this: [T, T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U, U]; + map(this: [T, T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U, U]; /** * 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(this: [T, T], callbackfn: (value: T, index: number, array: T[]) => U, thisArg?: any): [U, U]; + map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U): [U, U]; + map(this: [T, T], callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): [U, U]; + map(this: [T, T], callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): [U, U]; /** * 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[]; + map(callbackfn: (this: void, value: T, index: number, array: T[]) => U): U[]; + map(callbackfn: (this: void, value: T, index: number, array: T[]) => U, thisArg: undefined): U[]; + map(callbackfn: (this: Z, value: T, index: number, array: T[]) => U, thisArg: Z): 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[]) => any, thisArg?: any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any): T[]; + filter(callbackfn: (this: void, value: T, index: number, array: T[]) => any, thisArg: undefined): T[]; + filter(callbackfn: (this: Z, value: T, index: number, array: T[]) => any, thisArg: Z): 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. @@ -1377,14 +1374,19 @@ type Readonly = { */ type Pick = { [P in K]: T[P]; -} +}; /** * Construct a type with a set of properties K of type T */ type Record = { [P in K]: T; -} +}; + +/** + * Marker for contextual 'this' type + */ +interface ThisType { } /** * Represents a raw buffer of binary data, which is used to store data for the @@ -1401,7 +1403,7 @@ interface ArrayBuffer { /** * Returns a section of an ArrayBuffer. */ - slice(begin:number, end?:number): ArrayBuffer; + slice(begin: number, end?: number): ArrayBuffer; } interface ArrayBufferConstructor { @@ -1605,7 +1607,9 @@ interface Int8Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1624,7 +1628,9 @@ interface Int8Array { * @param thisArg 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) => any, thisArg?: any): Int8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any): Int8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int8Array) => any, thisArg: undefined): Int8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => any, thisArg: Z): Int8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1635,7 +1641,9 @@ interface Int8Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1646,7 +1654,9 @@ interface Int8Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1655,7 +1665,9 @@ interface Int8Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1693,7 +1705,9 @@ interface Int8Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number): Int8Array; + map(callbackfn: (this: void, value: number, index: number, array: Int8Array) => number, thisArg: undefined): Int8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => number, thisArg: Z): Int8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -1748,13 +1762,6 @@ interface Int8Array { */ 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. @@ -1777,7 +1784,9 @@ interface Int8Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -1829,7 +1838,11 @@ interface Int8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: ArrayLike): Int8Array; } declare const Int8Array: Int8ArrayConstructor; @@ -1878,7 +1891,9 @@ interface Uint8Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -1897,7 +1912,9 @@ interface Uint8Array { * @param thisArg 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) => any, thisArg?: any): Uint8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any): Uint8Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => any, thisArg: undefined): Uint8Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => any, thisArg: Z): Uint8Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -1908,7 +1925,9 @@ interface Uint8Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -1919,7 +1938,9 @@ interface Uint8Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -1928,7 +1949,9 @@ interface Uint8Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -1966,7 +1989,9 @@ interface Uint8Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number): Uint8Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => number, thisArg: undefined): Uint8Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => number, thisArg: Z): Uint8Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2021,13 +2046,6 @@ interface Uint8Array { */ 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. @@ -2050,7 +2068,9 @@ interface Uint8Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint8Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2103,7 +2123,11 @@ interface Uint8ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: ArrayLike): Uint8Array; } declare const Uint8Array: Uint8ArrayConstructor; @@ -2152,7 +2176,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2171,7 +2197,9 @@ interface Uint8ClampedArray { * @param thisArg 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) => any, thisArg?: any): Uint8ClampedArray; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any): Uint8ClampedArray; + filter(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: undefined): Uint8ClampedArray; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => any, thisArg: Z): Uint8ClampedArray; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2182,7 +2210,9 @@ interface Uint8ClampedArray { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2193,7 +2223,9 @@ interface Uint8ClampedArray { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2202,7 +2234,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2240,7 +2274,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number): Uint8ClampedArray; + map(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: undefined): Uint8ClampedArray; + map(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => number, thisArg: Z): Uint8ClampedArray; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2295,19 +2331,12 @@ interface Uint8ClampedArray { */ 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; + set(array: ArrayLike, offset?: number): void; /** * Returns a section of an array. @@ -2324,7 +2353,9 @@ interface Uint8ClampedArray { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint8ClampedArray) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2377,7 +2408,11 @@ interface Uint8ClampedArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: ArrayLike): Uint8ClampedArray; } declare const Uint8ClampedArray: Uint8ClampedArrayConstructor; @@ -2425,7 +2460,9 @@ interface Int16Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2444,7 +2481,9 @@ interface Int16Array { * @param thisArg 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) => any, thisArg?: any): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any): Int16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int16Array) => any, thisArg: undefined): Int16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => any, thisArg: Z): Int16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2455,7 +2494,9 @@ interface Int16Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2466,7 +2507,9 @@ interface Int16Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2475,7 +2518,9 @@ interface Int16Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2513,7 +2558,9 @@ interface Int16Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number): Int16Array; + map(callbackfn: (this: void, value: number, index: number, array: Int16Array) => number, thisArg: undefined): Int16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => number, thisArg: Z): Int16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2568,13 +2615,6 @@ interface Int16Array { */ 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. @@ -2597,7 +2637,9 @@ interface Int16Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2650,7 +2692,11 @@ interface Int16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: ArrayLike): Int16Array; } declare const Int16Array: Int16ArrayConstructor; @@ -2699,7 +2745,9 @@ interface Uint16Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2718,7 +2766,9 @@ interface Uint16Array { * @param thisArg 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) => any, thisArg?: any): Uint16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any): Uint16Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => any, thisArg: undefined): Uint16Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => any, thisArg: Z): Uint16Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -2729,7 +2779,9 @@ interface Uint16Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -2740,7 +2792,9 @@ interface Uint16Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -2749,7 +2803,9 @@ interface Uint16Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -2787,7 +2843,9 @@ interface Uint16Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number): Uint16Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => number, thisArg: undefined): Uint16Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => number, thisArg: Z): Uint16Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -2842,13 +2900,6 @@ interface Uint16Array { */ 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. @@ -2871,7 +2922,9 @@ interface Uint16Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint16Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint16Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -2924,7 +2977,11 @@ interface Uint16ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: ArrayLike): Uint16Array; } declare const Uint16Array: Uint16ArrayConstructor; @@ -2972,7 +3029,9 @@ interface Int32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -2991,7 +3050,9 @@ interface Int32Array { * @param thisArg 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) => any, thisArg?: any): Int32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any): Int32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Int32Array) => any, thisArg: undefined): Int32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => any, thisArg: Z): Int32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3002,7 +3063,9 @@ interface Int32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3013,7 +3076,9 @@ interface Int32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3022,7 +3087,9 @@ interface Int32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Int32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3060,7 +3127,9 @@ interface Int32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number): Int32Array; + map(callbackfn: (this: void, value: number, index: number, array: Int32Array) => number, thisArg: undefined): Int32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => number, thisArg: Z): Int32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3115,13 +3184,6 @@ interface Int32Array { */ 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. @@ -3144,7 +3206,9 @@ interface Int32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Int32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Int32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3197,7 +3261,11 @@ interface Int32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: ArrayLike): Int32Array; } declare const Int32Array: Int32ArrayConstructor; @@ -3245,7 +3313,9 @@ interface Uint32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3264,7 +3334,9 @@ interface Uint32Array { * @param thisArg 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) => any, thisArg?: any): Uint32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any): Uint32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => any, thisArg: undefined): Uint32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => any, thisArg: Z): Uint32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3275,7 +3347,9 @@ interface Uint32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3286,7 +3360,9 @@ interface Uint32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3295,7 +3371,9 @@ interface Uint32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3333,7 +3411,9 @@ interface Uint32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number): Uint32Array; + map(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => number, thisArg: undefined): Uint32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => number, thisArg: Z): Uint32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3388,13 +3468,6 @@ interface Uint32Array { */ 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. @@ -3417,7 +3490,9 @@ interface Uint32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Uint32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Uint32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3470,7 +3545,11 @@ interface Uint32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: ArrayLike): Uint32Array; } declare const Uint32Array: Uint32ArrayConstructor; @@ -3518,7 +3597,9 @@ interface Float32Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3537,7 +3618,9 @@ interface Float32Array { * @param thisArg 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) => any, thisArg?: any): Float32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any): Float32Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float32Array) => any, thisArg: undefined): Float32Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => any, thisArg: Z): Float32Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3548,7 +3631,9 @@ interface Float32Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3559,7 +3644,9 @@ interface Float32Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3568,7 +3655,9 @@ interface Float32Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Float32Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3606,7 +3695,9 @@ interface Float32Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number): Float32Array; + map(callbackfn: (this: void, value: number, index: number, array: Float32Array) => number, thisArg: undefined): Float32Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => number, thisArg: Z): Float32Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3661,13 +3752,6 @@ interface Float32Array { */ 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. @@ -3690,7 +3774,9 @@ interface Float32Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Float32Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float32Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -3743,7 +3829,11 @@ interface Float32ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: ArrayLike): Float32Array; } declare const Float32Array: Float32ArrayConstructor; @@ -3792,7 +3882,9 @@ interface Float64Array { * @param thisArg 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; + every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; + every(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + every(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Returns the this object after filling the section identified by start and end with value @@ -3811,7 +3903,9 @@ interface Float64Array { * @param thisArg 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) => any, thisArg?: any): Float64Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any): Float64Array; + filter(callbackfn: (this: void, value: number, index: number, array: Float64Array) => any, thisArg: undefined): Float64Array; + filter(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => any, thisArg: Z): Float64Array; /** * Returns the value of the first element in the array where predicate is true, and undefined @@ -3822,7 +3916,9 @@ interface Float64Array { * @param thisArg 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 | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number | undefined; + find(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number | undefined; + find(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number | undefined; /** * Returns the index of the first element in the array where predicate is true, and -1 @@ -3833,7 +3929,9 @@ interface Float64Array { * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: number, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: number, index: number, obj: Array) => boolean, thisArg: Z): number; /** * Performs the specified action for each element in an array. @@ -3842,7 +3940,9 @@ interface Float64Array { * @param thisArg 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; + forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void): void; + forEach(callbackfn: (this: void, value: number, index: number, array: Float64Array) => void, thisArg: undefined): void; + forEach(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => void, thisArg: Z): void; /** * Returns the index of the first occurrence of a value in an array. @@ -3880,7 +3980,9 @@ interface Float64Array { * @param thisArg 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; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number): Float64Array; + map(callbackfn: (this: void, value: number, index: number, array: Float64Array) => number, thisArg: undefined): Float64Array; + map(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => number, thisArg: Z): Float64Array; /** * Calls the specified callback function for all the elements in an array. The return value of @@ -3935,13 +4037,6 @@ interface Float64Array { */ 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. @@ -3964,7 +4059,9 @@ interface Float64Array { * @param thisArg 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; + some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean): boolean; + some(callbackfn: (this: void, value: number, index: number, array: Float64Array) => boolean, thisArg: undefined): boolean; + some(callbackfn: (this: Z, value: number, index: number, array: Float64Array) => boolean, thisArg: Z): boolean; /** * Sorts an array. @@ -4017,7 +4114,11 @@ interface Float64ArrayConstructor { * @param mapfn A mapping function to call on every element of the array. * @param thisArg Value of 'this' used to invoke the mapfn. */ - from(arrayLike: ArrayLike, mapfn?: (v: number, k: number) => number, thisArg?: any): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: ArrayLike): Float64Array; } declare const Float64Array: Float64ArrayConstructor; @@ -4025,7 +4126,7 @@ declare const Float64Array: Float64ArrayConstructor; /// ECMAScript Internationalization API ///////////////////////////// -declare module Intl { +declare namespace Intl { interface CollatorOptions { usage?: string; localeMatcher?: string; @@ -4053,7 +4154,7 @@ declare module Intl { new (locales?: string | string[], options?: CollatorOptions): Collator; (locales?: string | string[], options?: CollatorOptions): Collator; supportedLocalesOf(locales: string | string[], options?: CollatorOptions): string[]; - } + }; interface NumberFormatOptions { localeMatcher?: string; @@ -4090,7 +4191,7 @@ declare module Intl { new (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; (locales?: string | string[], options?: NumberFormatOptions): NumberFormat; supportedLocalesOf(locales: string | string[], options?: NumberFormatOptions): string[]; - } + }; interface DateTimeFormatOptions { localeMatcher?: string; @@ -4133,7 +4234,7 @@ declare module Intl { new (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; (locales?: string | string[], options?: DateTimeFormatOptions): DateTimeFormat; supportedLocalesOf(locales: string | string[], options?: DateTimeFormatOptions): string[]; - } + }; } interface String { @@ -4182,69 +4283,75 @@ declare type PropertyKey = string | number | symbol; interface Array { /** - * 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 | undefined; + * 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: (this: void, value: T, index: number, obj: Array) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): T | undefined; /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg 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: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): 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. - */ + * 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): this; /** - * 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. - */ + * 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): this; } 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 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: (this: void, v: T, k: number) => U): Array; + from(arrayLike: ArrayLike, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(arrayLike: ArrayLike, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; /** - * Creates an array from an array-like object. - * @param arrayLike An array-like object to convert to an array. - */ + * Creates an array from an array-like object. + * @param arrayLike An array-like object to convert to an array. + */ from(arrayLike: ArrayLike): Array; /** - * Returns a new array from a set of elements. - * @param items A set of elements to include in the new array object. - */ + * 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; } @@ -4254,328 +4361,332 @@ interface DateConstructor { interface Function { /** - * Returns the name of the function. Function names are read-only and can not be changed. - */ + * Returns the name of the function. Function names are read-only and can not be changed. + */ readonly name: string; } interface Math { /** - * Returns the number of leading zero bits in the 32-bit binary representation of a number. - * @param x A numeric expression. - */ + * 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 - */ + * 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 - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * Returns an implementation-dependent approximation to the cube root of number. + * @param x A numeric expression. + */ cbrt(x: number): number; } 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. - */ + * 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 isFinite, 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. - */ + * Returns true if passed value is finite. + * Unlike the global isFinite, 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. - */ + * 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. - */ + * 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. - */ + * 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.MAX_SAFE_INTEGER is 9007199254740991 2^53 − 1. - */ + * 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.MAX_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)). - */ + * 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. - */ + * 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. - */ + * 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 Object { /** - * Determines whether an object has a property with the specified name. - * @param v A property name. - */ - hasOwnProperty(v: PropertyKey): boolean + * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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; + * 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: object, ...sources: any[]): any; /** - * Returns an array of all symbol properties found directly on object o. - * @param o Object to retrieve the symbols from. - */ + * 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. - */ + * 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. - */ + * 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: object | null): 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. - */ + * 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. - */ + * 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 ReadonlyArray { - /** - * 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: ReadonlyArray) => boolean, thisArg?: any): T | undefined; + /** + * 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: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean): T | undefined; + find(predicate: (this: void, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: undefined): T | undefined; + find(predicate: (this: Z, value: T, index: number, obj: ReadonlyArray) => boolean, thisArg: Z): T | undefined; - /** - * Returns the index of the first element in the array where predicate is true, and -1 - * otherwise. - * @param predicate find calls predicate once for each element of the array, in ascending - * order, until it finds one where predicate returns true. If such an element is found, - * findIndex immediately returns that element index. Otherwise, findIndex returns -1. - * @param thisArg 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, index: number, obj: Array) => boolean, thisArg?: any): number; + /** + * Returns the index of the first element in the array where predicate is true, and -1 + * otherwise. + * @param predicate find calls predicate once for each element of the array, in ascending + * order, until it finds one where predicate returns true. If such an element is found, + * findIndex immediately returns that element index. Otherwise, findIndex returns -1. + * @param thisArg 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: (this: void, value: T, index: number, obj: Array) => boolean): number; + findIndex(predicate: (this: void, value: T, index: number, obj: Array) => boolean, thisArg: undefined): number; + findIndex(predicate: (this: Z, value: T, index: number, obj: Array) => boolean, thisArg: Z): number; } interface RegExp { /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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; } @@ -4586,64 +4697,64 @@ interface RegExpConstructor { interface String { /** - * 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. - */ + * 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 | undefined; /** - * 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. - */ + * 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. - */ + * 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" - */ + * 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: "NFC" | "NFD" | "NFKC" | "NFKD"): string; /** - * 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" - */ + * 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 - */ + * 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. - */ + * 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; /** - * Returns an HTML anchor element and sets the name attribute to the text value - * @param name - */ + * Returns an HTML anchor element and sets the name attribute to the text value + * @param name + */ anchor(name: string): string; /** Returns a HTML element */ @@ -4656,10 +4767,10 @@ interface String { bold(): string; /** Returns a HTML element */ - fixed(): string + fixed(): string; /** Returns a HTML element and sets the color attribute value */ - fontcolor(color: string): string + fontcolor(color: string): string; /** Returns a HTML element and sets the size attribute value */ fontsize(size: number): string; @@ -4688,18 +4799,18 @@ interface 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. - */ + * 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. - */ + * 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; } @@ -4723,7 +4834,7 @@ declare var Map: MapConstructor; interface ReadonlyMap { forEach(callbackfn: (value: V, key: K, map: ReadonlyMap) => void, thisArg?: any): void; - get(key: K): V|undefined; + get(key: K): V | undefined; has(key: K): boolean; readonly size: number; } @@ -4736,9 +4847,9 @@ interface WeakMap { } interface WeakMapConstructor { - new (): WeakMap; + new (): WeakMap; new (entries?: [K, V][]): WeakMap; - readonly prototype: WeakMap; + readonly prototype: WeakMap; } declare var WeakMap: WeakMapConstructor; @@ -4771,22 +4882,62 @@ interface WeakSet { } interface WeakSetConstructor { - new (): WeakSet; - new (values?: T[]): WeakSet; - readonly prototype: WeakSet; + new (): WeakSet; + new (values?: T[]): WeakSet; + readonly prototype: WeakSet; } declare var WeakSet: WeakSetConstructor; -interface GeneratorFunction extends Function { } +interface Generator extends Iterator { } + +interface GeneratorFunction { + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + new (...args: any[]): Generator; + /** + * Creates a new Generator object. + * @param args A list of arguments the function accepts. + */ + (...args: any[]): Generator; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ + readonly prototype: Generator; +} interface GeneratorFunctionConstructor { /** - * Creates a new Generator function. - * @param args A list of arguments the function accepts. - */ + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ new (...args: string[]): GeneratorFunction; + /** + * Creates a new Generator function. + * @param args A list of arguments the function accepts. + */ (...args: string[]): GeneratorFunction; + /** + * The length of the arguments. + */ + readonly length: number; + /** + * Returns the name of the function. + */ + readonly name: string; + /** + * A reference to the prototype. + */ readonly prototype: GeneratorFunction; } declare var GeneratorFunction: GeneratorFunctionConstructor; @@ -4795,10 +4946,10 @@ declare var GeneratorFunction: GeneratorFunctionConstructor; /// interface SymbolConstructor { - /** - * A method that returns the default iterator for an object. Called by the semantics of the - * for-of statement. - */ + /** + * A method that returns the default iterator for an object. Called by the semantics of the + * for-of statement. + */ readonly iterator: symbol; } @@ -4825,35 +4976,37 @@ interface Array { /** Iterator */ [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } interface ArrayConstructor { /** - * 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 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: (this: void, v: T, k: number) => U): Array; + from(iterable: Iterable, mapfn: (this: void, v: T, k: number) => U, thisArg: undefined): Array; + from(iterable: Iterable, mapfn: (this: Z, v: T, k: number) => U, thisArg: Z): Array; + /** - * Creates an array from an iterable object. - * @param iterable An iterable object to convert to an array. - */ + * Creates an array from an iterable object. + * @param iterable An iterable object to convert to an array. + */ from(iterable: Iterable): Array; } @@ -4861,19 +5014,19 @@ interface ReadonlyArray { /** Iterator */ [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -4883,7 +5036,7 @@ interface IArguments { } interface Map { - [Symbol.iterator](): IterableIterator<[K,V]>; + [Symbol.iterator](): IterableIterator<[K, V]>; entries(): IterableIterator<[K, V]>; keys(): IterableIterator; values(): IterableIterator; @@ -4913,22 +5066,22 @@ interface SetConstructor { interface WeakSet { } interface WeakSetConstructor { - new (iterable: Iterable): WeakSet; + new (iterable: Iterable): WeakSet; } interface Promise { } interface PromiseConstructor { /** - * Creates a Promise that is resolved with an array of results when all of the provided Promises + * 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: Iterable>): Promise; - + /** - * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved + * 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. @@ -4937,7 +5090,7 @@ interface PromiseConstructor { } declare namespace Reflect { - function enumerate(target: any): IterableIterator; + function enumerate(target: object): IterableIterator; } interface String { @@ -4946,22 +5099,22 @@ interface String { } /** - * 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -4969,31 +5122,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Int8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int8Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5001,33 +5158,37 @@ 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; + * 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: (this: void, v: number, k: number) => number): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5036,33 +5197,37 @@ interface Uint8ClampedArrayConstructor { /** - * 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; + * 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: (this: void, v: number, k: number) => number): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint8ClampedArray; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint8ClampedArray; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5070,31 +5235,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Int16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int16Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5102,31 +5271,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint16Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint16Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5134,31 +5307,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Int32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Int32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Int32Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5166,31 +5343,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Uint32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Uint32Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5198,31 +5379,35 @@ 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; + * 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: (this: void, v: number, k: number) => number): Float32Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float32Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float32Array; + + from(arrayLike: Iterable): 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. - */ + * 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 { [Symbol.iterator](): IterableIterator; - /** - * Returns an array of key, value pairs for every entry in the array - */ + /** + * 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 - */ + /** + * Returns an list of keys in the array + */ keys(): IterableIterator; - /** - * Returns an list of values in the array - */ + /** + * Returns an list of values in the array + */ values(): IterableIterator; } @@ -5230,19 +5415,23 @@ 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; + * 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: (this: void, v: number, k: number) => number): Float64Array; + from(arrayLike: Iterable, mapfn: (this: void, v: number, k: number) => number, thisArg: undefined): Float64Array; + from(arrayLike: Iterable, mapfn: (this: Z, v: number, k: number) => number, thisArg: Z): Float64Array; + + from(arrayLike: Iterable): Float64Array; } interface PromiseConstructor { /** - * A reference to the prototype. - */ + * A reference to the prototype. + */ readonly prototype: Promise; /** @@ -5428,10 +5617,10 @@ interface PromiseConstructor { 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. - */ + * 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; /** @@ -5443,7 +5632,7 @@ interface PromiseConstructor { declare var Promise: PromiseConstructor; -interface ProxyHandler { +interface ProxyHandler { getPrototypeOf? (target: T): object | null; setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; @@ -5457,12 +5646,12 @@ interface ProxyHandler { enumerate? (target: T): PropertyKey[]; ownKeys? (target: T): PropertyKey[]; apply? (target: T, thisArg: any, argArray?: any): any; - construct? (target: T, argArray: any, newTarget?: any): object + construct? (target: T, argArray: any, newTarget?: any): object; } interface ProxyConstructor { - revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; - new (target: T, handler: ProxyHandler): T + revocable(target: T, handler: ProxyHandler): { proxy: T; revoke: () => void; }; + new (target: T, handler: ProxyHandler): T; } declare var Proxy: ProxyConstructor; @@ -5470,19 +5659,20 @@ 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 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: PropertyKey): 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; + function defineProperty(target: object, propertyKey: PropertyKey, attributes: PropertyDescriptor): boolean; + function deleteProperty(target: object, propertyKey: PropertyKey): boolean; + function get(target: object, propertyKey: PropertyKey, receiver?: any): any; + function getOwnPropertyDescriptor(target: object, propertyKey: PropertyKey): PropertyDescriptor; + function getPrototypeOf(target: object): object; + function has(target: object, propertyKey: PropertyKey): boolean; + function isExtensible(target: object): boolean; + function ownKeys(target: object): Array; + function preventExtensions(target: object): boolean; + function set(target: object, propertyKey: PropertyKey, value: any, receiver?: any): boolean; + function setPrototypeOf(target: object, proto: any): boolean; } + interface Symbol { /** Returns a string representation of an object. */ toString(): string; @@ -5492,29 +5682,29 @@ interface Symbol { } interface SymbolConstructor { - /** - * A reference to the prototype. - */ + /** + * 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 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. - */ + * 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. - */ + * 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 | undefined; } @@ -5523,64 +5713,64 @@ declare var Symbol: SymbolConstructor; /// 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. - */ + /** + * 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. - */ + /** + * A Boolean value that if true indicates that an object should flatten to its array elements + * by Array.prototype.concat. + */ readonly isConcatSpreadable: symbol; /** - * A regular expression method that matches the regular expression against a string. Called - * by the String.prototype.match method. - */ + * 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. - */ + /** + * 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. - */ + * 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. - */ + /** + * 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. - */ + * 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. - */ + /** + * 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. - */ + /** + * 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. - */ + * An Object whose own property names are property names that are excluded from the 'with' + * environment bindings of the associated objects. + */ readonly unscopables: symbol; } @@ -5659,7 +5849,7 @@ interface Function { [Symbol.hasInstance](value: any): boolean; } -interface GeneratorFunction extends Function { +interface GeneratorFunction { readonly [Symbol.toStringTag]: "GeneratorFunction"; } @@ -5676,50 +5866,50 @@ interface PromiseConstructor { } 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. - */ + /** + * 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 | null; /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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. - */ + * 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[]; } @@ -5729,45 +5919,45 @@ interface RegExpConstructor { interface String { /** - * 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. - */ + * 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 | null; }): RegExpMatchArray | null; /** - * 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. - */ + * 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. - */ + * 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. - */ + * 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 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[]; } /** - * 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. - */ + * 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"; } @@ -5777,73 +5967,73 @@ interface 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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "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. - */ + * 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 { readonly [Symbol.toStringTag]: "Float64Array"; } @@ -5929,8 +6119,8 @@ interface ConstrainLongRange extends LongRange { } interface ConstrainVideoFacingModeParameters { - exact?: string | string[]; - ideal?: string | string[]; + exact?: VideoFacingModeEnum | VideoFacingModeEnum[]; + ideal?: VideoFacingModeEnum | VideoFacingModeEnum[]; } interface CustomEventInit extends EventInit { @@ -6159,7 +6349,7 @@ interface MSAudioSendSignal { } interface MSConnectivity { - iceType?: string; + iceType?: MSIceType; iceWarningFlags?: MSIceWarningFlags; relayAddress?: MSRelayAddress; } @@ -6169,11 +6359,11 @@ interface MSCredentialFilter { } interface MSCredentialParameters { - type?: string; + type?: MSCredentialType; } interface MSCredentialSpec { - type?: string; + type?: MSCredentialType; id?: string; } @@ -6184,7 +6374,7 @@ interface MSDelay { interface MSDescription extends RTCStats { connectivity?: MSConnectivity; - transport?: string; + transport?: RTCIceProtocol; networkconnectivity?: MSNetworkConnectivityInfo; localAddr?: MSIPAddressInfo; remoteAddr?: MSIPAddressInfo; @@ -6308,11 +6498,11 @@ interface MSTransportDiagnosticsStats extends RTCStats { numConsentRespReceived?: number; interfaces?: MSNetworkInterfaceType; baseInterface?: MSNetworkInterfaceType; - protocol?: string; + protocol?: RTCIceProtocol; localInterface?: MSNetworkInterfaceType; - localAddrType?: string; - remoteAddrType?: string; - iceRole?: string; + localAddrType?: MSIceAddrType; + remoteAddrType?: MSIceAddrType; + iceRole?: RTCIceRole; rtpRtcpMux?: boolean; allocationTimeInMs?: number; msRtcEngineVersion?: string; @@ -6385,7 +6575,7 @@ interface MediaEncryptedEventInit extends EventInit { } interface MediaKeyMessageEventInit extends EventInit { - messageType?: string; + messageType?: MediaKeyMessageType; message?: ArrayBuffer; } @@ -6393,8 +6583,8 @@ interface MediaKeySystemConfiguration { initDataTypes?: string[]; audioCapabilities?: MediaKeySystemMediaCapability[]; videoCapabilities?: MediaKeySystemMediaCapability[]; - distinctiveIdentifier?: string; - persistentState?: string; + distinctiveIdentifier?: MediaKeysRequirement; + persistentState?: MediaKeysRequirement; } interface MediaKeySystemMediaCapability { @@ -6518,7 +6708,7 @@ interface MutationObserverInit { } interface NotificationOptions { - dir?: string; + dir?: NotificationDirection; lang?: string; body?: string; tag?: string; @@ -6617,8 +6807,8 @@ interface PushSubscriptionOptionsInit { interface RTCConfiguration { iceServers?: RTCIceServer[]; - iceTransportPolicy?: string; - bundlePolicy?: string; + iceTransportPolicy?: RTCIceTransportPolicy; + bundlePolicy?: RTCBundlePolicy; peerIdentity?: string; } @@ -6632,7 +6822,7 @@ interface RTCDtlsFingerprint { } interface RTCDtlsParameters { - role?: string; + role?: RTCDtlsRole; fingerprints?: RTCDtlsFingerprint[]; } @@ -6640,7 +6830,7 @@ interface RTCIceCandidateAttributes extends RTCStats { ipAddress?: string; portNumber?: number; transport?: string; - candidateType?: string; + candidateType?: RTCStatsIceCandidateType; priority?: number; addressSourceUrl?: string; } @@ -6652,10 +6842,10 @@ interface RTCIceCandidateDictionary { foundation?: string; priority?: number; ip?: string; - protocol?: string; + protocol?: RTCIceProtocol; port?: number; - type?: string; - tcpType?: string; + type?: RTCIceCandidateType; + tcpType?: RTCIceTcpCandidateType; relatedAddress?: string; relatedPort?: number; msMTurnSessionId?: string; @@ -6676,7 +6866,7 @@ interface RTCIceCandidatePairStats extends RTCStats { transportId?: string; localCandidateId?: string; remoteCandidateId?: string; - state?: string; + state?: RTCStatsIceCandidatePairState; priority?: number; nominated?: boolean; writable?: boolean; @@ -6689,7 +6879,7 @@ interface RTCIceCandidatePairStats extends RTCStats { } interface RTCIceGatherOptions { - gatherPolicy?: string; + gatherPolicy?: RTCIceGatherPolicy; iceservers?: RTCIceServer[]; portRange?: MSPortRange; } @@ -6854,7 +7044,7 @@ interface RTCRtpParameters { headerExtensions?: RTCRtpHeaderExtensionParameters[]; encodings?: RTCRtpEncodingParameters[]; rtcp?: RTCRtcpParameters; - degradationPreference?: string; + degradationPreference?: RTCDegradationPreference; } interface RTCRtpRtxParameters { @@ -6868,7 +7058,7 @@ interface RTCRtpUnhandled { } interface RTCSessionDescriptionInit { - type?: string; + type?: RTCSdpType; sdp?: string; } @@ -6894,9 +7084,9 @@ interface RTCSsrcRange { interface RTCStats { timestamp?: number; - type?: string; + type?: RTCStatsType; id?: string; - msType?: string; + msType?: MSStatsType; } interface RTCStatsReport { @@ -6921,11 +7111,11 @@ interface RequestInit { headers?: any; body?: any; referrer?: string; - referrerPolicy?: string; - mode?: string; - credentials?: string; - cache?: string; - redirect?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; integrity?: string; keepalive?: boolean; window?: any; @@ -6938,9 +7128,9 @@ interface ResponseInit { } interface ScopedCredentialDescriptor { - type?: string; + type?: ScopedCredentialType; id?: any; - transports?: string[]; + transports?: Transport[]; } interface ScopedCredentialOptions { @@ -6951,7 +7141,7 @@ interface ScopedCredentialOptions { } interface ScopedCredentialParameters { - type?: string; + type?: ScopedCredentialType; algorithm?: string | Algorithm; } @@ -7181,7 +7371,7 @@ interface AudioContextBase extends EventTarget { readonly listener: AudioListener; onstatechange: (this: AudioContext, ev: Event) => any; readonly sampleRate: number; - readonly state: string; + readonly state: AudioContextState; close(): Promise; createAnalyser(): AnalyserNode; createBiquadFilter(): BiquadFilterNode; @@ -7241,12 +7431,13 @@ declare var AudioListener: { interface AudioNode extends EventTarget { channelCount: number; - channelCountMode: string; - channelInterpretation: string; + channelCountMode: ChannelCountMode; + channelInterpretation: ChannelInterpretation; readonly context: AudioContext; readonly numberOfInputs: number; readonly numberOfOutputs: number; connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: number): void; disconnect(output?: number): void; disconnect(destination: AudioNode, output?: number, input?: number): void; disconnect(destination: AudioParam, output?: number): void; @@ -7344,7 +7535,7 @@ interface BiquadFilterNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; readonly gain: AudioParam; - type: string; + type: BiquadFilterType; getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; } @@ -7984,7 +8175,7 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { lineJoin: string; lineWidth: number; miterLimit: number; - msFillRule: string; + msFillRule: CanvasFillRule; shadowBlur: number; shadowColor: string; shadowOffsetX: number; @@ -7997,19 +8188,21 @@ interface CanvasRenderingContext2D extends Object, CanvasPathMethods { oImageSmoothingEnabled: boolean; beginPath(): void; clearRect(x: number, y: number, w: number, h: number): void; - clip(fillRule?: string): void; + clip(fillRule?: CanvasFillRule): 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; drawFocusIfNeeded(element: Element): void; - 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; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; + fill(fillRule?: CanvasFillRule): 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; + isPointInPath(x: number, y: number, fillRule?: CanvasFillRule): boolean; measureText(text: string): TextMetrics; putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: number): void; restore(): void; @@ -8300,10 +8493,10 @@ declare var DOMException: { } interface DOMImplementation { - createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType): Document; + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; createHTMLDocument(title: string): Document; - hasFeature(): boolean; + hasFeature(feature: string | null, version: string | null): boolean; } declare var DOMImplementation: { @@ -8386,6 +8579,7 @@ interface DataTransfer { clearData(format?: string): boolean; getData(format: string): string; setData(format: string, data: string): boolean; + setDragImage(image: Element, x: number, y: number): void; } declare var DataTransfer: { @@ -8422,7 +8616,7 @@ declare var DataTransferItemList: { interface DeferredPermissionRequest { readonly id: number; - readonly type: string; + readonly type: MSWebViewPermissionType; readonly uri: string; allow(): void; deny(): void; @@ -9040,7 +9234,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Contains the title of the document. */ title: string; - readonly visibilityState: string; + readonly visibilityState: VisibilityState; /** * Sets or gets the color of the links that the user has visited. */ @@ -9055,7 +9249,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets or sets the version attribute specified in the declaration of an XML document. */ xmlVersion: string | null; - adoptNode(source: Node): Node; + adoptNode(source: T): T; captureEvents(): void; caretRangeFromPoint(x: number, y: number): Range; clear(): void; @@ -9232,7 +9426,7 @@ interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEven * Gets a value indicating whether the object currently has focus. */ hasFocus(): boolean; - importNode(importedNode: Node, deep: boolean): Node; + importNode(importedNode: T, deep: boolean): T; msElementsFromPoint(x: number, y: number): NodeListOf; msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; /** @@ -9300,6 +9494,7 @@ declare var Document: { } interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; } declare var DocumentFragment: { @@ -9547,9 +9742,9 @@ declare var Event: { } interface EventTarget { - addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare var EventTarget: { @@ -9628,7 +9823,7 @@ declare var FocusEvent: { } interface FocusNavigationEvent extends Event { - readonly navigationReason: string; + readonly navigationReason: NavigationReason; readonly originHeight: number; readonly originLeft: number; readonly originTop: number; @@ -9642,7 +9837,12 @@ declare var FocusNavigationEvent: { } interface FormData { - append(name: any, value: any, blobName?: string): void; + append(name: string, value: string | Blob, fileName?: string): void; + delete(name: string): void; + get(name: string): FormDataEntryValue | null; + getAll(name: string): FormDataEntryValue[]; + has(name: string): boolean; + set(name: string, value: string | Blob, fileName?: string): void; } declare var FormData: { @@ -12804,7 +13004,7 @@ declare var History: { } interface IDBCursor { - readonly direction: string; + readonly direction: IDBCursorDirection; key: IDBKeyRange | IDBValidKey; readonly primaryKey: any; source: IDBObjectStore | IDBIndex; @@ -12956,7 +13156,7 @@ interface IDBRequest extends EventTarget { readonly error: DOMError; onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; - readonly readyState: string; + readonly readyState: IDBRequestReadyState; readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; @@ -12978,7 +13178,7 @@ interface IDBTransactionEventMap { interface IDBTransaction extends EventTarget { readonly db: IDBDatabase; readonly error: DOMError; - readonly mode: string; + readonly mode: IDBTransactionMode; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; onerror: (this: IDBTransaction, ev: Event) => any; @@ -13096,7 +13296,7 @@ declare var KeyboardEvent: { interface ListeningStateChangedEvent extends Event { readonly label: string; - readonly state: string; + readonly state: ListeningState; } declare var ListeningStateChangedEvent: { @@ -13187,7 +13387,7 @@ declare var MSAppAsyncOperation: { interface MSAssertion { readonly id: string; - readonly type: string; + readonly type: MSCredentialType; } declare var MSAssertion: { @@ -13219,7 +13419,7 @@ interface MSFIDOCredentialAssertion extends MSAssertion { readonly algorithm: string | Algorithm; readonly attestation: any; readonly publicKey: string; - readonly transportHints: string[]; + readonly transportHints: MSTransportType[]; } declare var MSFIDOCredentialAssertion: { @@ -13323,7 +13523,7 @@ interface MSHTMLWebViewElement extends HTMLElement { goForward(): void; invokeScriptAsync(scriptName: string, ...args: any[]): MSWebViewAsyncOperation; navigate(uri: string): void; - navigateFocus(navigationReason: string, origin: FocusNavigationOrigin): void; + navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; navigateToLocalStreamUri(source: string, streamResolver: any): void; navigateToString(contents: string): void; navigateWithHttpRequestMessage(requestMessage: any): void; @@ -13578,7 +13778,7 @@ declare var MSWebViewSettings: { interface MediaDeviceInfo { readonly deviceId: string; readonly groupId: string; - readonly kind: string; + readonly kind: MediaDeviceKind; readonly label: string; } @@ -13645,7 +13845,7 @@ declare var MediaError: { interface MediaKeyMessageEvent extends Event { readonly message: ArrayBuffer; - readonly messageType: string; + readonly messageType: MediaKeyMessageType; } declare var MediaKeyMessageEvent: { @@ -13673,7 +13873,7 @@ declare var MediaKeySession: { interface MediaKeyStatusMap { readonly size: number; forEach(callback: ForEachCallback): void; - get(keyId: any): string; + get(keyId: any): MediaKeyStatus; has(keyId: any): boolean; } @@ -13694,7 +13894,7 @@ declare var MediaKeySystemAccess: { } interface MediaKeys { - createSession(sessionType?: string): MediaKeySession; + createSession(sessionType?: MediaKeySessionType): MediaKeySession; setServerCertificate(serverCertificate: any): Promise; } @@ -13832,7 +14032,7 @@ interface MediaStreamTrack extends EventTarget { onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; onunmute: (this: MediaStreamTrack, ev: Event) => any; readonly readonly: boolean; - readonly readyState: string; + readonly readyState: MediaStreamTrackState; readonly remote: boolean; applyConstraints(constraints: MediaTrackConstraints): Promise; clone(): MediaStreamTrack; @@ -14053,7 +14253,7 @@ declare var NavigationEventWithReferrer: { interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { readonly authentication: WebAuthentication; readonly cookieEnabled: boolean; - gamepadInputEmulation: string; + gamepadInputEmulation: GamepadInputEmulationType; readonly language: string; readonly maxTouchPoints: number; readonly mimeTypes: MimeTypeArray; @@ -14100,15 +14300,15 @@ interface Node extends EventTarget { contains(child: Node): boolean; hasAttributes(): boolean; hasChildNodes(): boolean; - insertBefore(newChild: Node, refChild: Node | null): Node; + insertBefore(newChild: T, refChild: Node | null): T; isDefaultNamespace(namespaceURI: string | null): boolean; isEqualNode(arg: Node): boolean; isSameNode(other: Node): boolean; lookupNamespaceURI(prefix: string | null): string | null; lookupPrefix(namespaceURI: string | null): string | null; normalize(): void; - removeChild(oldChild: Node): Node; - replaceChild(newChild: Node, oldChild: Node): Node; + removeChild(oldChild: T): T; + replaceChild(newChild: Node, oldChild: T): T; readonly ATTRIBUTE_NODE: number; readonly CDATA_SECTION_NODE: number; readonly COMMENT_NODE: number; @@ -14210,14 +14410,14 @@ interface NotificationEventMap { interface Notification extends EventTarget { readonly body: string; - readonly dir: string; + readonly dir: NotificationDirection; readonly icon: string; readonly lang: string; onclick: (this: Notification, ev: Event) => any; onclose: (this: Notification, ev: Event) => any; onerror: (this: Notification, ev: Event) => any; onshow: (this: Notification, ev: Event) => any; - readonly permission: string; + readonly permission: NotificationPermission; readonly tag: string; readonly title: string; close(): void; @@ -14228,7 +14428,7 @@ interface Notification extends EventTarget { declare var Notification: { prototype: Notification; new(title: string, options?: NotificationOptions): Notification; - requestPermission(callback?: NotificationPermissionCallback): Promise; + requestPermission(callback?: NotificationPermissionCallback): Promise; } interface OES_element_index_uint { @@ -14318,7 +14518,7 @@ interface OscillatorNode extends AudioNode { readonly detune: AudioParam; readonly frequency: AudioParam; onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any; - type: string; + type: OscillatorType; setPeriodicWave(periodicWave: PeriodicWave): void; start(when?: number): void; stop(when?: number): void; @@ -14361,9 +14561,9 @@ interface PannerNode extends AudioNode { coneInnerAngle: number; coneOuterAngle: number; coneOuterGain: number; - distanceModel: string; + distanceModel: DistanceModelType; maxDistance: number; - panningModel: string; + panningModel: PanningModelType; refDistance: number; rolloffFactor: number; setOrientation(x: number, y: number, z: number): void; @@ -14414,7 +14614,7 @@ interface PaymentRequest extends EventTarget { onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; - readonly shippingType: string | null; + readonly shippingType: PaymentShippingType | null; abort(): Promise; show(): Promise; addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; @@ -14443,7 +14643,7 @@ interface PaymentResponse { readonly payerPhone: string | null; readonly shippingAddress: PaymentAddress | null; readonly shippingOption: string | null; - complete(result?: string): Promise; + complete(result?: PaymentComplete): Promise; toJSON(): any; } @@ -14571,7 +14771,7 @@ interface PerformanceNavigationTiming extends PerformanceEntry { readonly requestStart: number; readonly responseEnd: number; readonly responseStart: number; - readonly type: string; + readonly type: NavigationType; readonly unloadEventEnd: number; readonly unloadEventStart: number; } @@ -14640,7 +14840,7 @@ declare var PeriodicWave: { } interface PermissionRequest extends DeferredPermissionRequest { - readonly state: string; + readonly state: MSWebViewPermissionState; defer(): void; } @@ -14770,7 +14970,7 @@ declare var ProgressEvent: { interface PushManager { getSubscription(): Promise; - permissionState(options?: PushSubscriptionOptionsInit): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; subscribe(options?: PushSubscriptionOptionsInit): Promise; } @@ -14782,7 +14982,7 @@ declare var PushManager: { interface PushSubscription { readonly endpoint: USVString; readonly options: PushSubscriptionOptions; - getKey(name: string): ArrayBuffer | null; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; toJSON(): any; unsubscribe(): Promise; } @@ -14819,7 +15019,7 @@ interface RTCDtlsTransportEventMap { interface RTCDtlsTransport extends RTCStatsProvider { ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; - readonly state: string; + readonly state: RTCDtlsTransportState; readonly transport: RTCIceTransport; getLocalParameters(): RTCDtlsParameters; getRemoteCertificates(): ArrayBuffer[]; @@ -14836,7 +15036,7 @@ declare var RTCDtlsTransport: { } interface RTCDtlsTransportStateChangedEvent extends Event { - readonly state: string; + readonly state: RTCDtlsTransportState; } declare var RTCDtlsTransportStateChangedEvent: { @@ -14892,7 +15092,7 @@ interface RTCIceGathererEventMap { } interface RTCIceGatherer extends RTCStatsProvider { - readonly component: string; + readonly component: RTCIceComponent; onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; createAssociatedGatherer(): RTCIceGatherer; @@ -14922,19 +15122,19 @@ interface RTCIceTransportEventMap { } interface RTCIceTransport extends RTCStatsProvider { - readonly component: string; + readonly component: RTCIceComponent; readonly iceGatherer: RTCIceGatherer | null; oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null; onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; - readonly role: string; - readonly state: string; + readonly role: RTCIceRole; + readonly state: RTCIceTransportState; addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; createAssociatedTransport(): RTCIceTransport; getNominatedCandidatePair(): RTCIceCandidatePair | null; getRemoteCandidates(): RTCIceCandidateDictionary[]; getRemoteParameters(): RTCIceParameters | null; setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; - start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: string): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; stop(): void; addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -14946,7 +15146,7 @@ declare var RTCIceTransport: { } interface RTCIceTransportStateChangedEvent extends Event { - readonly state: string; + readonly state: RTCIceTransportState; } declare var RTCIceTransportStateChangedEvent: { @@ -14966,8 +15166,8 @@ interface RTCPeerConnectionEventMap { interface RTCPeerConnection extends EventTarget { readonly canTrickleIceCandidates: boolean | null; - readonly iceConnectionState: string; - readonly iceGatheringState: string; + readonly iceConnectionState: RTCIceConnectionState; + readonly iceGatheringState: RTCIceGatheringState; readonly localDescription: RTCSessionDescription | null; onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; @@ -14977,7 +15177,7 @@ interface RTCPeerConnection extends EventTarget { onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; readonly remoteDescription: RTCSessionDescription | null; - readonly signalingState: string; + readonly signalingState: RTCSignalingState; addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; addStream(stream: MediaStream): void; close(): void; @@ -15060,7 +15260,7 @@ declare var RTCRtpSender: { interface RTCSessionDescription { sdp: string | null; - type: string | null; + type: RTCSdpType | null; toJSON(): any; } @@ -15119,7 +15319,7 @@ interface Range { createContextualFragment(fragment: string): DocumentFragment; deleteContents(): void; detach(): void; - expand(Unit: string): boolean; + expand(Unit: ExpandGranularity): boolean; extractContents(): DocumentFragment; getBoundingClientRect(): ClientRect; getClientRects(): ClientRectList; @@ -15172,18 +15372,18 @@ declare var ReadableStreamReader: { } interface Request extends Object, Body { - readonly cache: string; - readonly credentials: string; - readonly destination: string; + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; readonly headers: Headers; readonly integrity: string; readonly keepalive: boolean; readonly method: string; - readonly mode: string; - readonly redirect: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; readonly referrer: string; - readonly referrerPolicy: string; - readonly type: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; readonly url: string; clone(): Request; } @@ -15199,7 +15399,7 @@ interface Response extends Object, Body { readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly type: string; + readonly type: ResponseType; readonly url: string; clone(): Response; } @@ -16999,7 +17199,7 @@ declare var SVGZoomEvent: { interface ScopedCredential { readonly id: ArrayBuffer; - readonly type: string; + readonly type: ScopedCredentialType; } declare var ScopedCredential: { @@ -17116,7 +17316,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap { interface ServiceWorker extends EventTarget, AbstractWorker { onstatechange: (this: ServiceWorker, ev: Event) => any; readonly scriptURL: USVString; - readonly state: string; + readonly state: ServiceWorkerState; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -17192,7 +17392,7 @@ interface SourceBuffer extends EventTarget { appendWindowStart: number; readonly audioTracks: AudioTrackList; readonly buffered: TimeRanges; - mode: string; + mode: AppendMode; timestampOffset: number; readonly updating: boolean; readonly videoTracks: VideoTrackList; @@ -17428,7 +17628,7 @@ interface Text extends CharacterData { declare var Text: { prototype: Text; - new(): Text; + new(data?: string): Text; } interface TextEvent extends UIEvent { @@ -17611,7 +17811,7 @@ interface TouchEvent extends UIEvent { declare var TouchEvent: { prototype: TouchEvent; - new(): TouchEvent; + new(type: string, touchEventInit?: TouchEventInit): TouchEvent; } interface TouchList { @@ -17688,7 +17888,7 @@ interface URL { protocol: string; search: string; username: string; - readonly searchparams: URLSearchParams; + readonly searchParams: URLSearchParams; toString(): string; } @@ -17817,7 +18017,7 @@ declare var WEBGL_depth_texture: { interface WaveShaperNode extends AudioNode { curve: Float32Array | null; - oversample: string; + oversample: OverSampleType; } declare var WaveShaperNode: { @@ -18012,12 +18212,12 @@ interface WebGLRenderingContext { 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, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texImage2D(target: number, level: number, internalformat: number, width: number, height: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): 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, pixels?: ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; uniform1f(location: WebGLUniformLocation | null, x: number): void; uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; uniform1i(location: WebGLUniformLocation | null, x: number): void; @@ -19078,6 +19278,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window readonly top: Window; readonly window: Window; URL: typeof URL; + URLSearchParams: typeof URLSearchParams; Blob: typeof Blob; customElements: CustomElementRegistry; alert(message?: any): void; @@ -19086,7 +19287,7 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window captureEvents(): void; close(): void; confirm(message?: string): boolean; - departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; + departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; focus(): void; getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -19111,6 +19312,8 @@ interface Window extends EventTarget, WindowTimers, WindowSessionStorage, Window webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; scroll(options?: ScrollToOptions): void; scrollTo(options?: ScrollToOptions): void; scrollBy(options?: ScrollToOptions): void; @@ -19159,7 +19362,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly readyState: number; readonly response: any; readonly responseText: string; - responseType: string; + responseType: XMLHttpRequestResponseType; readonly responseURL: string; readonly responseXML: Document | null; readonly status: number; @@ -19324,6 +19527,7 @@ interface Body { blob(): Promise; json(): Promise; text(): Promise; + formData(): Promise; } interface CanvasPathMethods { @@ -19686,6 +19890,21 @@ interface Canvas2DContextAttributes { [attribute: string]: boolean | string | undefined; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + interface URLSearchParams { /** * Appends a specified key/value pair as a new search parameter. @@ -19730,6 +19949,7 @@ interface NodeListOf extends NodeList { interface HTMLCollectionOf extends HTMLCollection { item(index: number): T; namedItem(name: string): T; + [index: number]: T; } interface BlobPropertyBag { @@ -19999,6 +20219,21 @@ interface PromiseRejectionEventInit extends EventInit { reason?: any; } +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + +interface TouchEventInit extends EventModifierInit { + touches?: Touch[]; + targetTouches?: Touch[]; + changedTouches?: Touch[]; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -20056,10 +20291,10 @@ interface NavigatorUserMediaErrorCallback { (error: MediaStreamError): void; } interface ForEachCallback { - (keyId: any, status: string): void; + (keyId: any, status: MediaKeyStatus): void; } interface NotificationPermissionCallback { - (permission: string): void; + (permission: NotificationPermission): void; } interface IntersectionObserverCallback { (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; @@ -20666,7 +20901,7 @@ declare function cancelAnimationFrame(handle: number): void; declare function captureEvents(): void; declare function close(): void; declare function confirm(message?: string): boolean; -declare function departFocus(navigationReason: string, origin: FocusNavigationOrigin): void; +declare function departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; declare function focus(): void; declare function getComputedStyle(elt: Element, pseudoElt?: string): CSSStyleDeclaration; declare function getMatchedCSSRules(elt: Element, pseudoElt?: string): CSSRuleList; @@ -20691,12 +20926,14 @@ declare function webkitCancelAnimationFrame(handle: number): void; declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function scroll(options?: ScrollToOptions): void; declare function scrollTo(options?: ScrollToOptions): void; declare function scrollBy(options?: ScrollToOptions): void; declare function toString(): string; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; declare function clearInterval(handle: number): void; declare function clearTimeout(handle: number): void; declare function setInterval(handler: (...args: any[]) => void, timeout: number): number; @@ -20766,12 +21003,84 @@ type IDBValidKey = number | string | Date | IDBArrayKey; type BufferSource = ArrayBuffer | ArrayBufferView; type MouseWheelEvent = WheelEvent; type ScrollRestoration = "auto" | "manual"; +type FormDataEntryValue = string | File; +type AppendMode = "segments" | "sequence"; +type AudioContextState = "suspended" | "running" | "closed"; +type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; +type CanvasFillRule = "nonzero" | "evenodd"; +type ChannelCountMode = "max" | "clamped-max" | "explicit"; +type ChannelInterpretation = "speakers" | "discrete"; +type DistanceModelType = "linear" | "inverse" | "exponential"; +type ExpandGranularity = "character" | "word" | "sentence" | "textedit"; +type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad"; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type ListeningState = "inactive" | "active" | "disambiguation"; +type MSCredentialType = "FIDO_2_0"; +type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived"; +type MSIceType = "failed" | "direct" | "relay"; +type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics"; +type MSTransportType = "Embedded" | "USB" | "NFC" | "BT"; +type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny"; +type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications"; +type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; +type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request"; +type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type MediaKeysRequirement = "required" | "optional" | "not-allowed"; +type MediaStreamTrackState = "live" | "ended"; +type NavigationReason = "up" | "down" | "left" | "right"; +type NavigationType = "navigate" | "reload" | "back_forward" | "prerender"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom"; +type OverSampleType = "none" | "2x" | "4x"; +type PanningModelType = "equalpower"; +type PaymentComplete = "success" | "fail" | ""; +type PaymentShippingType = "shipping" | "delivery" | "pickup"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle"; +type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced"; +type RTCDtlsRole = "auto" | "client" | "server"; +type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed"; +type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay"; +type RTCIceComponent = "RTP" | "RTCP"; +type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"; +type RTCIceGatherPolicy = "all" | "nohost" | "relay"; +type RTCIceGathererState = "new" | "gathering" | "complete"; +type RTCIceGatheringState = "new" | "gathering" | "complete"; +type RTCIceProtocol = "udp" | "tcp"; +type RTCIceRole = "controlling" | "controlled"; +type RTCIceTcpCandidateType = "active" | "passive" | "so"; +type RTCIceTransportPolicy = "none" | "relay" | "all"; +type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed"; +type RTCSdpType = "offer" | "pranswer" | "answer"; +type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"; +type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled"; +type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed"; +type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ScopedCredentialType = "ScopedCred"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type Transport = "usb" | "nfc" | "ble"; +type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; ///////////////////////////// -/// WorkerGlobalScope APIs +/// WorkerGlobalScope APIs ///////////////////////////// -// These are only available in a Web Worker +// These are only available in a Web Worker declare function importScripts(...urls: string[]): void; @@ -20806,7 +21115,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * 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; @@ -20876,9 +21185,9 @@ interface TextStreamReader extends TextStreamBase { 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). - */ + * 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; /** @@ -21074,10 +21383,104 @@ interface DOMTokenList { [Symbol.iterator](): IterableIterator; } +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, string | File]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface Headers { + [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value pairs contained in this object. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all keys f the key/value pairs contained in this object. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values of the key/value pairs contained in this object. + */ + values(): IterableIterator; +} + interface NodeList { - [Symbol.iterator](): IterableIterator + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; } interface NodeListOf { - [Symbol.iterator](): IterableIterator + + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; + + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface URLSearchParams { + /** + * Returns an array of key, value pairs for every entry in the search params + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns a list of keys in the search params + */ + keys(): IterableIterator; + /** + * Returns a list of values in the search params + */ + values(): IterableIterator; + /** + * iterate over key/value pairs + */ + [Symbol.iterator](): IterableIterator<[string, string]>; } diff --git a/lib/lib.esnext.asynciterable.d.ts b/lib/lib.esnext.asynciterable.d.ts new file mode 100644 index 00000000000..d9e17e6d94e --- /dev/null +++ b/lib/lib.esnext.asynciterable.d.ts @@ -0,0 +1,44 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + + +/// + + +/// +/// + +interface SymbolConstructor { + /** + * A method that returns the default async iterator for an object. Called by the semantics of + * the for-await-of statement. + */ + readonly asyncIterator: symbol; +} + +interface AsyncIterator { + next(value?: any): Promise>; + return?(value?: any): Promise>; + throw?(e?: any): Promise>; +} + +interface AsyncIterable { + [Symbol.asyncIterator](): AsyncIterator; +} + +interface AsyncIterableIterator extends AsyncIterator { + [Symbol.asyncIterator](): AsyncIterableIterator; +} \ No newline at end of file diff --git a/lib/lib.esnext.d.ts b/lib/lib.esnext.d.ts new file mode 100644 index 00000000000..ebc1e9d5299 --- /dev/null +++ b/lib/lib.esnext.d.ts @@ -0,0 +1,22 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + + +/// + + +/// +/// diff --git a/lib/lib.esnext.full.d.ts b/lib/lib.esnext.full.d.ts new file mode 100644 index 00000000000..d285df3f4db --- /dev/null +++ b/lib/lib.esnext.full.d.ts @@ -0,0 +1,15469 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + + + +/// + + +/// +/// + + + +///////////////////////////// +/// IE DOM APIs +///////////////////////////// + +interface Account { + rpDisplayName?: string; + displayName?: string; + id?: string; + name?: string; + imageURL?: string; +} + +interface Algorithm { + name: string; +} + +interface AnimationEventInit extends EventInit { + animationName?: string; + elapsedTime?: number; +} + +interface AssertionOptions { + timeoutSeconds?: number; + rpId?: USVString; + allowList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface CacheQueryOptions { + ignoreSearch?: boolean; + ignoreMethod?: boolean; + ignoreVary?: boolean; + cacheName?: string; +} + +interface ClientData { + challenge?: string; + origin?: string; + rpId?: string; + hashAlg?: string | Algorithm; + tokenBinding?: string; + extensions?: WebAuthnExtensions; +} + +interface CloseEventInit extends EventInit { + wasClean?: boolean; + code?: number; + reason?: string; +} + +interface CompositionEventInit extends UIEventInit { + data?: string; +} + +interface ConfirmSiteSpecificExceptionsInformation extends ExceptionInformation { + arrayOfDomainStrings?: string[]; +} + +interface ConstrainBooleanParameters { + exact?: boolean; + ideal?: boolean; +} + +interface ConstrainDOMStringParameters { + exact?: string | string[]; + ideal?: string | string[]; +} + +interface ConstrainDoubleRange extends DoubleRange { + exact?: number; + ideal?: number; +} + +interface ConstrainLongRange extends LongRange { + exact?: number; + ideal?: number; +} + +interface ConstrainVideoFacingModeParameters { + exact?: VideoFacingModeEnum | VideoFacingModeEnum[]; + ideal?: VideoFacingModeEnum | VideoFacingModeEnum[]; +} + +interface CustomEventInit extends EventInit { + detail?: any; +} + +interface DOMRectInit { + x?: any; + y?: any; + width?: any; + height?: any; +} + +interface DeviceAccelerationDict { + x?: number; + y?: number; + z?: number; +} + +interface DeviceLightEventInit extends EventInit { + value?: number; +} + +interface DeviceMotionEventInit extends EventInit { + acceleration?: DeviceAccelerationDict; + accelerationIncludingGravity?: DeviceAccelerationDict; + rotationRate?: DeviceRotationRateDict; + interval?: number; +} + +interface DeviceOrientationEventInit extends EventInit { + alpha?: number; + beta?: number; + gamma?: number; + absolute?: boolean; +} + +interface DeviceRotationRateDict { + alpha?: number; + beta?: number; + gamma?: number; +} + +interface DoubleRange { + max?: number; + min?: number; +} + +interface ErrorEventInit extends EventInit { + message?: string; + filename?: string; + lineno?: number; + colno?: number; + error?: any; +} + +interface EventInit { + scoped?: boolean; + bubbles?: boolean; + cancelable?: boolean; +} + +interface EventModifierInit extends UIEventInit { + ctrlKey?: boolean; + shiftKey?: boolean; + altKey?: boolean; + metaKey?: boolean; + modifierAltGraph?: boolean; + modifierCapsLock?: boolean; + modifierFn?: boolean; + modifierFnLock?: boolean; + modifierHyper?: boolean; + modifierNumLock?: boolean; + modifierOS?: boolean; + modifierScrollLock?: boolean; + modifierSuper?: boolean; + modifierSymbol?: boolean; + modifierSymbolLock?: boolean; +} + +interface ExceptionInformation { + domain?: string; +} + +interface FocusEventInit extends UIEventInit { + relatedTarget?: EventTarget; +} + +interface FocusNavigationEventInit extends EventInit { + navigationReason?: string; + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface FocusNavigationOrigin { + originLeft?: number; + originTop?: number; + originWidth?: number; + originHeight?: number; +} + +interface GamepadEventInit extends EventInit { + gamepad?: Gamepad; +} + +interface GetNotificationOptions { + tag?: string; +} + +interface HashChangeEventInit extends EventInit { + newURL?: string; + oldURL?: string; +} + +interface IDBIndexParameters { + multiEntry?: boolean; + unique?: boolean; +} + +interface IDBObjectStoreParameters { + autoIncrement?: boolean; + keyPath?: IDBKeyPath; +} + +interface IntersectionObserverEntryInit { + time?: number; + rootBounds?: DOMRectInit; + boundingClientRect?: DOMRectInit; + intersectionRect?: DOMRectInit; + target?: Element; +} + +interface IntersectionObserverInit { + root?: Element; + rootMargin?: string; + threshold?: number | number[]; +} + +interface KeyAlgorithm { + name?: string; +} + +interface KeyboardEventInit extends EventModifierInit { + code?: string; + key?: string; + location?: number; + repeat?: boolean; +} + +interface LongRange { + max?: number; + min?: number; +} + +interface MSAccountInfo { + rpDisplayName?: string; + userDisplayName?: string; + accountName?: string; + userId?: string; + accountImageUri?: string; +} + +interface MSAudioLocalClientEvent extends MSLocalClientEventBase { + networkSendQualityEventRatio?: number; + networkDelayEventRatio?: number; + cpuInsufficientEventRatio?: number; + deviceHalfDuplexAECEventRatio?: number; + deviceRenderNotFunctioningEventRatio?: number; + deviceCaptureNotFunctioningEventRatio?: number; + deviceGlitchesEventRatio?: number; + deviceLowSNREventRatio?: number; + deviceLowSpeechLevelEventRatio?: number; + deviceClippingEventRatio?: number; + deviceEchoEventRatio?: number; + deviceNearEndToEchoRatioEventRatio?: number; + deviceRenderZeroVolumeEventRatio?: number; + deviceRenderMuteEventRatio?: number; + deviceMultipleEndpointsEventCount?: number; + deviceHowlingEventCount?: number; +} + +interface MSAudioRecvPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioRecvSignal; + packetReorderRatio?: number; + packetReorderDepthAvg?: number; + packetReorderDepthMax?: number; + burstLossLength1?: number; + burstLossLength2?: number; + burstLossLength3?: number; + burstLossLength4?: number; + burstLossLength5?: number; + burstLossLength6?: number; + burstLossLength7?: number; + burstLossLength8OrHigher?: number; + fecRecvDistance1?: number; + fecRecvDistance2?: number; + fecRecvDistance3?: number; + ratioConcealedSamplesAvg?: number; + ratioStretchedSamplesAvg?: number; + ratioCompressedSamplesAvg?: number; +} + +interface MSAudioRecvSignal { + initialSignalLevelRMS?: number; + recvSignalLevelCh1?: number; + recvNoiseLevelCh1?: number; + renderSignalLevel?: number; + renderNoiseLevel?: number; + renderLoopbackSignalLevel?: number; +} + +interface MSAudioSendPayload extends MSPayloadBase { + samplingRate?: number; + signal?: MSAudioSendSignal; + audioFECUsed?: boolean; + sendMutePercent?: number; +} + +interface MSAudioSendSignal { + noiseLevel?: number; + sendSignalLevelCh1?: number; + sendNoiseLevelCh1?: number; +} + +interface MSConnectivity { + iceType?: MSIceType; + iceWarningFlags?: MSIceWarningFlags; + relayAddress?: MSRelayAddress; +} + +interface MSCredentialFilter { + accept?: MSCredentialSpec[]; +} + +interface MSCredentialParameters { + type?: MSCredentialType; +} + +interface MSCredentialSpec { + type?: MSCredentialType; + id?: string; +} + +interface MSDelay { + roundTrip?: number; + roundTripMax?: number; +} + +interface MSDescription extends RTCStats { + connectivity?: MSConnectivity; + transport?: RTCIceProtocol; + networkconnectivity?: MSNetworkConnectivityInfo; + localAddr?: MSIPAddressInfo; + remoteAddr?: MSIPAddressInfo; + deviceDevName?: string; + reflexiveLocalIPAddr?: MSIPAddressInfo; +} + +interface MSFIDOCredentialParameters extends MSCredentialParameters { + algorithm?: string | Algorithm; + authenticators?: AAGUID[]; +} + +interface MSIPAddressInfo { + ipAddr?: string; + port?: number; + manufacturerMacAddrMask?: string; +} + +interface MSIceWarningFlags { + turnTcpTimedOut?: boolean; + turnUdpAllocateFailed?: boolean; + turnUdpSendFailed?: boolean; + turnTcpAllocateFailed?: boolean; + turnTcpSendFailed?: boolean; + udpLocalConnectivityFailed?: boolean; + udpNatConnectivityFailed?: boolean; + udpRelayConnectivityFailed?: boolean; + tcpNatConnectivityFailed?: boolean; + tcpRelayConnectivityFailed?: boolean; + connCheckMessageIntegrityFailed?: boolean; + allocationMessageIntegrityFailed?: boolean; + connCheckOtherError?: boolean; + turnAuthUnknownUsernameError?: boolean; + noRelayServersConfigured?: boolean; + multipleRelayServersAttempted?: boolean; + portRangeExhausted?: boolean; + alternateServerReceived?: boolean; + pseudoTLSFailure?: boolean; + turnTurnTcpConnectivityFailed?: boolean; + useCandidateChecksFailed?: boolean; + fipsAllocationFailure?: boolean; +} + +interface MSJitter { + interArrival?: number; + interArrivalMax?: number; + interArrivalSD?: number; +} + +interface MSLocalClientEventBase extends RTCStats { + networkReceiveQualityEventRatio?: number; + networkBandwidthLowEventRatio?: number; +} + +interface MSNetwork extends RTCStats { + jitter?: MSJitter; + delay?: MSDelay; + packetLoss?: MSPacketLoss; + utilization?: MSUtilization; +} + +interface MSNetworkConnectivityInfo { + vpn?: boolean; + linkspeed?: number; + networkConnectionDetails?: string; +} + +interface MSNetworkInterfaceType { + interfaceTypeEthernet?: boolean; + interfaceTypeWireless?: boolean; + interfaceTypePPP?: boolean; + interfaceTypeTunnel?: boolean; + interfaceTypeWWAN?: boolean; +} + +interface MSOutboundNetwork extends MSNetwork { + appliedBandwidthLimit?: number; +} + +interface MSPacketLoss { + lossRate?: number; + lossRateMax?: number; +} + +interface MSPayloadBase extends RTCStats { + payloadDescription?: string; +} + +interface MSPortRange { + min?: number; + max?: number; +} + +interface MSRelayAddress { + relayAddress?: string; + port?: number; +} + +interface MSSignatureParameters { + userPrompt?: string; +} + +interface MSTransportDiagnosticsStats extends RTCStats { + baseAddress?: string; + localAddress?: string; + localSite?: string; + networkName?: string; + remoteAddress?: string; + remoteSite?: string; + localMR?: string; + remoteMR?: string; + iceWarningFlags?: MSIceWarningFlags; + portRangeMin?: number; + portRangeMax?: number; + localMRTCPPort?: number; + remoteMRTCPPort?: number; + stunVer?: number; + numConsentReqSent?: number; + numConsentReqReceived?: number; + numConsentRespSent?: number; + numConsentRespReceived?: number; + interfaces?: MSNetworkInterfaceType; + baseInterface?: MSNetworkInterfaceType; + protocol?: RTCIceProtocol; + localInterface?: MSNetworkInterfaceType; + localAddrType?: MSIceAddrType; + remoteAddrType?: MSIceAddrType; + iceRole?: RTCIceRole; + rtpRtcpMux?: boolean; + allocationTimeInMs?: number; + msRtcEngineVersion?: string; +} + +interface MSUtilization { + packets?: number; + bandwidthEstimation?: number; + bandwidthEstimationMin?: number; + bandwidthEstimationMax?: number; + bandwidthEstimationStdDev?: number; + bandwidthEstimationAvg?: number; +} + +interface MSVideoPayload extends MSPayloadBase { + resolution?: string; + videoBitRateAvg?: number; + videoBitRateMax?: number; + videoFrameRateAvg?: number; + videoPacketLossRate?: number; + durationSeconds?: number; +} + +interface MSVideoRecvPayload extends MSVideoPayload { + videoFrameLossRate?: number; + recvCodecType?: string; + recvResolutionWidth?: number; + recvResolutionHeight?: number; + videoResolutions?: MSVideoResolutionDistribution; + recvFrameRateAverage?: number; + recvBitRateMaximum?: number; + recvBitRateAverage?: number; + recvVideoStreamsMax?: number; + recvVideoStreamsMin?: number; + recvVideoStreamsMode?: number; + videoPostFECPLR?: number; + lowBitRateCallPercent?: number; + lowFrameRateCallPercent?: number; + reorderBufferTotalPackets?: number; + recvReorderBufferReorderedPackets?: number; + recvReorderBufferPacketsDroppedDueToBufferExhaustion?: number; + recvReorderBufferMaxSuccessfullyOrderedExtent?: number; + recvReorderBufferMaxSuccessfullyOrderedLateTime?: number; + recvReorderBufferPacketsDroppedDueToTimeout?: number; + recvFpsHarmonicAverage?: number; + recvNumResSwitches?: number; +} + +interface MSVideoResolutionDistribution { + cifQuality?: number; + vgaQuality?: number; + h720Quality?: number; + h1080Quality?: number; + h1440Quality?: number; + h2160Quality?: number; +} + +interface MSVideoSendPayload extends MSVideoPayload { + sendFrameRateAverage?: number; + sendBitRateMaximum?: number; + sendBitRateAverage?: number; + sendVideoStreamsMax?: number; + sendResolutionWidth?: number; + sendResolutionHeight?: number; +} + +interface MediaEncryptedEventInit extends EventInit { + initDataType?: string; + initData?: ArrayBuffer; +} + +interface MediaKeyMessageEventInit extends EventInit { + messageType?: MediaKeyMessageType; + message?: ArrayBuffer; +} + +interface MediaKeySystemConfiguration { + initDataTypes?: string[]; + audioCapabilities?: MediaKeySystemMediaCapability[]; + videoCapabilities?: MediaKeySystemMediaCapability[]; + distinctiveIdentifier?: MediaKeysRequirement; + persistentState?: MediaKeysRequirement; +} + +interface MediaKeySystemMediaCapability { + contentType?: string; + robustness?: string; +} + +interface MediaStreamConstraints { + video?: boolean | MediaTrackConstraints; + audio?: boolean | MediaTrackConstraints; +} + +interface MediaStreamErrorEventInit extends EventInit { + error?: MediaStreamError; +} + +interface MediaStreamEventInit extends EventInit { + stream?: MediaStream; +} + +interface MediaStreamTrackEventInit extends EventInit { + track?: MediaStreamTrack; +} + +interface MediaTrackCapabilities { + width?: number | LongRange; + height?: number | LongRange; + aspectRatio?: number | DoubleRange; + frameRate?: number | DoubleRange; + facingMode?: string; + volume?: number | DoubleRange; + sampleRate?: number | LongRange; + sampleSize?: number | LongRange; + echoCancellation?: boolean[]; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackConstraintSet { + width?: number | ConstrainLongRange; + height?: number | ConstrainLongRange; + aspectRatio?: number | ConstrainDoubleRange; + frameRate?: number | ConstrainDoubleRange; + facingMode?: string | string[] | ConstrainDOMStringParameters; + volume?: number | ConstrainDoubleRange; + sampleRate?: number | ConstrainLongRange; + sampleSize?: number | ConstrainLongRange; + echoCancelation?: boolean | ConstrainBooleanParameters; + deviceId?: string | string[] | ConstrainDOMStringParameters; + groupId?: string | string[] | ConstrainDOMStringParameters; +} + +interface MediaTrackConstraints extends MediaTrackConstraintSet { + advanced?: MediaTrackConstraintSet[]; +} + +interface MediaTrackSettings { + width?: number; + height?: number; + aspectRatio?: number; + frameRate?: number; + facingMode?: string; + volume?: number; + sampleRate?: number; + sampleSize?: number; + echoCancellation?: boolean; + deviceId?: string; + groupId?: string; +} + +interface MediaTrackSupportedConstraints { + width?: boolean; + height?: boolean; + aspectRatio?: boolean; + frameRate?: boolean; + facingMode?: boolean; + volume?: boolean; + sampleRate?: boolean; + sampleSize?: boolean; + echoCancellation?: boolean; + deviceId?: boolean; + groupId?: boolean; +} + +interface MessageEventInit extends EventInit { + lastEventId?: string; + channel?: string; + data?: any; + origin?: string; + source?: Window; + ports?: MessagePort[]; +} + +interface MouseEventInit extends EventModifierInit { + 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 NotificationOptions { + dir?: NotificationDirection; + lang?: string; + body?: string; + tag?: string; + icon?: string; +} + +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + +interface PaymentCurrencyAmount { + currency?: string; + value?: string; + currencySystem?: string; +} + +interface PaymentDetails { + total?: PaymentItem; + displayItems?: PaymentItem[]; + shippingOptions?: PaymentShippingOption[]; + modifiers?: PaymentDetailsModifier[]; + error?: string; +} + +interface PaymentDetailsModifier { + supportedMethods?: string[]; + total?: PaymentItem; + additionalDisplayItems?: PaymentItem[]; + data?: any; +} + +interface PaymentItem { + label?: string; + amount?: PaymentCurrencyAmount; + pending?: boolean; +} + +interface PaymentMethodData { + supportedMethods?: string[]; + data?: any; +} + +interface PaymentOptions { + requestPayerName?: boolean; + requestPayerEmail?: boolean; + requestPayerPhone?: boolean; + requestShipping?: boolean; + shippingType?: string; +} + +interface PaymentRequestUpdateEventInit extends EventInit { +} + +interface PaymentShippingOption { + id?: string; + label?: string; + amount?: PaymentCurrencyAmount; + selected?: boolean; +} + +interface PeriodicWaveConstraints { + disableNormalization?: boolean; +} + +interface PointerEventInit extends MouseEventInit { + pointerId?: number; + width?: number; + height?: number; + pressure?: number; + tiltX?: number; + tiltY?: number; + pointerType?: string; + isPrimary?: boolean; +} + +interface PopStateEventInit extends EventInit { + state?: any; +} + +interface PositionOptions { + enableHighAccuracy?: boolean; + timeout?: number; + maximumAge?: number; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface PushSubscriptionOptionsInit { + userVisibleOnly?: boolean; + applicationServerKey?: any; +} + +interface RTCConfiguration { + iceServers?: RTCIceServer[]; + iceTransportPolicy?: RTCIceTransportPolicy; + bundlePolicy?: RTCBundlePolicy; + peerIdentity?: string; +} + +interface RTCDTMFToneChangeEventInit extends EventInit { + tone?: string; +} + +interface RTCDtlsFingerprint { + algorithm?: string; + value?: string; +} + +interface RTCDtlsParameters { + role?: RTCDtlsRole; + fingerprints?: RTCDtlsFingerprint[]; +} + +interface RTCIceCandidateAttributes extends RTCStats { + ipAddress?: string; + portNumber?: number; + transport?: string; + candidateType?: RTCStatsIceCandidateType; + priority?: number; + addressSourceUrl?: string; +} + +interface RTCIceCandidateComplete { +} + +interface RTCIceCandidateDictionary { + foundation?: string; + priority?: number; + ip?: string; + protocol?: RTCIceProtocol; + port?: number; + type?: RTCIceCandidateType; + tcpType?: RTCIceTcpCandidateType; + relatedAddress?: string; + relatedPort?: number; + msMTurnSessionId?: string; +} + +interface RTCIceCandidateInit { + candidate?: string; + sdpMid?: string; + sdpMLineIndex?: number; +} + +interface RTCIceCandidatePair { + local?: RTCIceCandidateDictionary; + remote?: RTCIceCandidateDictionary; +} + +interface RTCIceCandidatePairStats extends RTCStats { + transportId?: string; + localCandidateId?: string; + remoteCandidateId?: string; + state?: RTCStatsIceCandidatePairState; + priority?: number; + nominated?: boolean; + writable?: boolean; + readable?: boolean; + bytesSent?: number; + bytesReceived?: number; + roundTripTime?: number; + availableOutgoingBitrate?: number; + availableIncomingBitrate?: number; +} + +interface RTCIceGatherOptions { + gatherPolicy?: RTCIceGatherPolicy; + iceservers?: RTCIceServer[]; + portRange?: MSPortRange; +} + +interface RTCIceParameters { + usernameFragment?: string; + password?: string; + iceLite?: boolean; +} + +interface RTCIceServer { + urls?: any; + username?: string; + credential?: string; +} + +interface RTCInboundRTPStreamStats extends RTCRTPStreamStats { + packetsReceived?: number; + bytesReceived?: number; + packetsLost?: number; + jitter?: number; + fractionLost?: number; +} + +interface RTCMediaStreamTrackStats extends RTCStats { + trackIdentifier?: string; + remoteSource?: boolean; + ssrcIds?: string[]; + frameWidth?: number; + frameHeight?: number; + framesPerSecond?: number; + framesSent?: number; + framesReceived?: number; + framesDecoded?: number; + framesDropped?: number; + framesCorrupted?: number; + audioLevel?: number; + echoReturnLoss?: number; + echoReturnLossEnhancement?: number; +} + +interface RTCOfferOptions { + offerToReceiveVideo?: number; + offerToReceiveAudio?: number; + voiceActivityDetection?: boolean; + iceRestart?: boolean; +} + +interface RTCOutboundRTPStreamStats extends RTCRTPStreamStats { + packetsSent?: number; + bytesSent?: number; + targetBitrate?: number; + roundTripTime?: number; +} + +interface RTCPeerConnectionIceEventInit extends EventInit { + candidate?: RTCIceCandidate; +} + +interface RTCRTPStreamStats extends RTCStats { + ssrc?: string; + associateStatsId?: string; + isRemote?: boolean; + mediaTrackId?: string; + transportId?: string; + codecId?: string; + firCount?: number; + pliCount?: number; + nackCount?: number; + sliCount?: number; +} + +interface RTCRtcpFeedback { + type?: string; + parameter?: string; +} + +interface RTCRtcpParameters { + ssrc?: number; + cname?: string; + reducedSize?: boolean; + mux?: boolean; +} + +interface RTCRtpCapabilities { + codecs?: RTCRtpCodecCapability[]; + headerExtensions?: RTCRtpHeaderExtension[]; + fecMechanisms?: string[]; +} + +interface RTCRtpCodecCapability { + name?: string; + kind?: string; + clockRate?: number; + preferredPayloadType?: number; + maxptime?: number; + ptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; + options?: any; + maxTemporalLayers?: number; + maxSpatialLayers?: number; + svcMultiStreamSupport?: boolean; +} + +interface RTCRtpCodecParameters { + name?: string; + payloadType?: any; + clockRate?: number; + maxptime?: number; + ptime?: number; + numChannels?: number; + rtcpFeedback?: RTCRtcpFeedback[]; + parameters?: any; +} + +interface RTCRtpContributingSource { + timestamp?: number; + csrc?: number; + audioLevel?: number; +} + +interface RTCRtpEncodingParameters { + ssrc?: number; + codecPayloadType?: number; + fec?: RTCRtpFecParameters; + rtx?: RTCRtpRtxParameters; + priority?: number; + maxBitrate?: number; + minQuality?: number; + resolutionScale?: number; + framerateScale?: number; + maxFramerate?: number; + active?: boolean; + encodingId?: string; + dependencyEncodingIds?: string[]; + ssrcRange?: RTCSsrcRange; +} + +interface RTCRtpFecParameters { + ssrc?: number; + mechanism?: string; +} + +interface RTCRtpHeaderExtension { + kind?: string; + uri?: string; + preferredId?: number; + preferredEncrypt?: boolean; +} + +interface RTCRtpHeaderExtensionParameters { + uri?: string; + id?: number; + encrypt?: boolean; +} + +interface RTCRtpParameters { + muxId?: string; + codecs?: RTCRtpCodecParameters[]; + headerExtensions?: RTCRtpHeaderExtensionParameters[]; + encodings?: RTCRtpEncodingParameters[]; + rtcp?: RTCRtcpParameters; + degradationPreference?: RTCDegradationPreference; +} + +interface RTCRtpRtxParameters { + ssrc?: number; +} + +interface RTCRtpUnhandled { + ssrc?: number; + payloadType?: number; + muxId?: string; +} + +interface RTCSessionDescriptionInit { + type?: RTCSdpType; + sdp?: string; +} + +interface RTCSrtpKeyParam { + keyMethod?: string; + keySalt?: string; + lifetime?: string; + mkiValue?: number; + mkiLength?: number; +} + +interface RTCSrtpSdesParameters { + tag?: number; + cryptoSuite?: string; + keyParams?: RTCSrtpKeyParam[]; + sessionParams?: string[]; +} + +interface RTCSsrcRange { + min?: number; + max?: number; +} + +interface RTCStats { + timestamp?: number; + type?: RTCStatsType; + id?: string; + msType?: MSStatsType; +} + +interface RTCStatsReport { +} + +interface RTCTransportStats extends RTCStats { + bytesSent?: number; + bytesReceived?: number; + rtcpTransportStatsId?: string; + activeConnection?: boolean; + selectedCandidatePairId?: string; + localCertificateId?: string; + remoteCertificateId?: string; +} + +interface RegistrationOptions { + scope?: string; +} + +interface RequestInit { + method?: string; + headers?: any; + body?: any; + referrer?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; + integrity?: string; + keepalive?: boolean; + window?: any; +} + +interface ResponseInit { + status?: number; + statusText?: string; + headers?: any; +} + +interface ScopedCredentialDescriptor { + type?: ScopedCredentialType; + id?: any; + transports?: Transport[]; +} + +interface ScopedCredentialOptions { + timeoutSeconds?: number; + rpId?: USVString; + excludeList?: ScopedCredentialDescriptor[]; + extensions?: WebAuthnExtensions; +} + +interface ScopedCredentialParameters { + type?: ScopedCredentialType; + algorithm?: string | Algorithm; +} + +interface ServiceWorkerMessageEventInit extends EventInit { + data?: any; + origin?: string; + lastEventId?: string; + source?: ServiceWorker | MessagePort; + ports?: MessagePort[]; +} + +interface SpeechSynthesisEventInit extends EventInit { + utterance?: SpeechSynthesisUtterance; + charIndex?: number; + elapsedTime?: number; + name?: string; +} + +interface StoreExceptionsInformation extends ExceptionInformation { + siteName?: string; + explanationString?: string; + detailURI?: string; +} + +interface StoreSiteSpecificExceptionsInformation extends StoreExceptionsInformation { + arrayOfDomainStrings?: string[]; +} + +interface TrackEventInit extends EventInit { + track?: VideoTrack | AudioTrack | TextTrack; +} + +interface TransitionEventInit extends EventInit { + propertyName?: string; + elapsedTime?: number; +} + +interface UIEventInit extends EventInit { + view?: Window; + detail?: number; +} + +interface WebAuthnExtensions { +} + +interface WebGLContextAttributes { + failIfMajorPerformanceCaveat?: boolean; + 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 WebKitEntriesCallback { + (evt: Event): void; +} + +interface WebKitErrorCallback { + (evt: Event): void; +} + +interface WebKitFileCallback { + (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; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +declare var ANGLE_instanced_arrays: { + prototype: ANGLE_instanced_arrays; + new(): ANGLE_instanced_arrays; + readonly VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE: number; +} + +interface AnalyserNode extends AudioNode { + fftSize: number; + readonly 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 { + readonly animationName: string; + readonly elapsedTime: number; + initAnimationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, animationNameArg: string, elapsedTimeArg: number): void; +} + +declare var AnimationEvent: { + prototype: AnimationEvent; + new(typeArg: string, eventInitDict?: AnimationEventInit): AnimationEvent; +} + +interface ApplicationCacheEventMap { + "cached": Event; + "checking": Event; + "downloading": Event; + "error": Event; + "noupdate": Event; + "obsolete": Event; + "progress": ProgressEvent; + "updateready": Event; +} + +interface ApplicationCache extends EventTarget { + oncached: (this: ApplicationCache, ev: Event) => any; + onchecking: (this: ApplicationCache, ev: Event) => any; + ondownloading: (this: ApplicationCache, ev: Event) => any; + onerror: (this: ApplicationCache, ev: Event) => any; + onnoupdate: (this: ApplicationCache, ev: Event) => any; + onobsolete: (this: ApplicationCache, ev: Event) => any; + onprogress: (this: ApplicationCache, ev: ProgressEvent) => any; + onupdateready: (this: ApplicationCache, ev: Event) => any; + readonly status: number; + abort(): void; + swapCache(): void; + update(): void; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; + addEventListener(type: K, listener: (this: ApplicationCache, ev: ApplicationCacheEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ApplicationCache: { + prototype: ApplicationCache; + new(): ApplicationCache; + readonly CHECKING: number; + readonly DOWNLOADING: number; + readonly IDLE: number; + readonly OBSOLETE: number; + readonly UNCACHED: number; + readonly UPDATEREADY: number; +} + +interface Attr extends Node { + readonly name: string; + readonly ownerElement: Element; + readonly prefix: string | null; + readonly specified: boolean; + value: string; +} + +declare var Attr: { + prototype: Attr; + new(): Attr; +} + +interface AudioBuffer { + readonly duration: number; + readonly length: number; + readonly numberOfChannels: number; + readonly sampleRate: number; + copyFromChannel(destination: Float32Array, channelNumber: number, startInChannel?: number): void; + copyToChannel(source: Float32Array, channelNumber: number, startInChannel?: number): void; + getChannelData(channel: number): Float32Array; +} + +declare var AudioBuffer: { + prototype: AudioBuffer; + new(): AudioBuffer; +} + +interface AudioBufferSourceNodeEventMap { + "ended": MediaStreamErrorEvent; +} + +interface AudioBufferSourceNode extends AudioNode { + buffer: AudioBuffer | null; + readonly detune: AudioParam; + loop: boolean; + loopEnd: number; + loopStart: number; + onended: (this: AudioBufferSourceNode, ev: MediaStreamErrorEvent) => any; + readonly playbackRate: AudioParam; + start(when?: number, offset?: number, duration?: number): void; + stop(when?: number): void; + addEventListener(type: K, listener: (this: AudioBufferSourceNode, ev: AudioBufferSourceNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var AudioBufferSourceNode: { + prototype: AudioBufferSourceNode; + new(): AudioBufferSourceNode; +} + +interface AudioContextEventMap { + "statechange": Event; +} + +interface AudioContextBase extends EventTarget { + readonly currentTime: number; + readonly destination: AudioDestinationNode; + readonly listener: AudioListener; + onstatechange: (this: AudioContext, ev: Event) => any; + readonly sampleRate: number; + readonly state: AudioContextState; + close(): Promise; + 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; + createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode; + createMediaElementSource(mediaElement: HTMLMediaElement): MediaElementAudioSourceNode; + createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode; + createOscillator(): OscillatorNode; + createPanner(): PannerNode; + createPeriodicWave(real: Float32Array, imag: Float32Array, constraints?: PeriodicWaveConstraints): PeriodicWave; + createScriptProcessor(bufferSize?: number, numberOfInputChannels?: number, numberOfOutputChannels?: number): ScriptProcessorNode; + createStereoPanner(): StereoPannerNode; + createWaveShaper(): WaveShaperNode; + decodeAudioData(audioData: ArrayBuffer, successCallback?: DecodeSuccessCallback, errorCallback?: DecodeErrorCallback): Promise; + resume(): Promise; + addEventListener(type: K, listener: (this: AudioContext, ev: AudioContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface AudioContext extends AudioContextBase { + suspend(): Promise; +} + +declare var AudioContext: { + prototype: AudioContext; + new(): AudioContext; +} + +interface AudioDestinationNode extends AudioNode { + readonly 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: ChannelCountMode; + channelInterpretation: ChannelInterpretation; + readonly context: AudioContext; + readonly numberOfInputs: number; + readonly numberOfOutputs: number; + connect(destination: AudioNode, output?: number, input?: number): AudioNode; + connect(destination: AudioParam, output?: 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 { + readonly defaultValue: number; + value: number; + cancelScheduledValues(startTime: number): AudioParam; + exponentialRampToValueAtTime(value: number, endTime: number): AudioParam; + linearRampToValueAtTime(value: number, endTime: number): AudioParam; + setTargetAtTime(target: number, startTime: number, timeConstant: number): AudioParam; + setValueAtTime(value: number, startTime: number): AudioParam; + setValueCurveAtTime(values: Float32Array, startTime: number, duration: number): AudioParam; +} + +declare var AudioParam: { + prototype: AudioParam; + new(): AudioParam; +} + +interface AudioProcessingEvent extends Event { + readonly inputBuffer: AudioBuffer; + readonly outputBuffer: AudioBuffer; + readonly playbackTime: number; +} + +declare var AudioProcessingEvent: { + prototype: AudioProcessingEvent; + new(): AudioProcessingEvent; +} + +interface AudioTrack { + enabled: boolean; + readonly id: string; + kind: string; + readonly label: string; + language: string; + readonly sourceBuffer: SourceBuffer; +} + +declare var AudioTrack: { + prototype: AudioTrack; + new(): AudioTrack; +} + +interface AudioTrackListEventMap { + "addtrack": TrackEvent; + "change": Event; + "removetrack": TrackEvent; +} + +interface AudioTrackList extends EventTarget { + readonly length: number; + onaddtrack: (this: AudioTrackList, ev: TrackEvent) => any; + onchange: (this: AudioTrackList, ev: Event) => any; + onremovetrack: (this: AudioTrackList, ev: TrackEvent) => any; + getTrackById(id: string): AudioTrack | null; + item(index: number): AudioTrack; + addEventListener(type: K, listener: (this: AudioTrackList, ev: AudioTrackListEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: AudioTrack; +} + +declare var AudioTrackList: { + prototype: AudioTrackList; + new(): AudioTrackList; +} + +interface BarProp { + readonly 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 { + readonly Q: AudioParam; + readonly detune: AudioParam; + readonly frequency: AudioParam; + readonly gain: AudioParam; + type: BiquadFilterType; + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var BiquadFilterNode: { + prototype: BiquadFilterNode; + new(): BiquadFilterNode; +} + +interface Blob { + readonly size: number; + readonly 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 { + readonly style: CSSStyleDeclaration; +} + +declare var CSSFontFaceRule: { + prototype: CSSFontFaceRule; + new(): CSSFontFaceRule; +} + +interface CSSGroupingRule extends CSSRule { + readonly cssRules: CSSRuleList; + deleteRule(index: number): void; + insertRule(rule: string, index: number): number; +} + +declare var CSSGroupingRule: { + prototype: CSSGroupingRule; + new(): CSSGroupingRule; +} + +interface CSSImportRule extends CSSRule { + readonly href: string; + readonly media: MediaList; + readonly styleSheet: CSSStyleSheet; +} + +declare var CSSImportRule: { + prototype: CSSImportRule; + new(): CSSImportRule; +} + +interface CSSKeyframeRule extends CSSRule { + keyText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSKeyframeRule: { + prototype: CSSKeyframeRule; + new(): CSSKeyframeRule; +} + +interface CSSKeyframesRule extends CSSRule { + readonly 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 { + readonly media: MediaList; +} + +declare var CSSMediaRule: { + prototype: CSSMediaRule; + new(): CSSMediaRule; +} + +interface CSSNamespaceRule extends CSSRule { + readonly namespaceURI: string; + readonly prefix: string; +} + +declare var CSSNamespaceRule: { + prototype: CSSNamespaceRule; + new(): CSSNamespaceRule; +} + +interface CSSPageRule extends CSSRule { + readonly pseudoClass: string; + readonly selector: string; + selectorText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSPageRule: { + prototype: CSSPageRule; + new(): CSSPageRule; +} + +interface CSSRule { + cssText: string; + readonly parentRule: CSSRule; + readonly parentStyleSheet: CSSStyleSheet; + readonly type: number; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; +} + +declare var CSSRule: { + prototype: CSSRule; + new(): CSSRule; + readonly CHARSET_RULE: number; + readonly FONT_FACE_RULE: number; + readonly IMPORT_RULE: number; + readonly KEYFRAMES_RULE: number; + readonly KEYFRAME_RULE: number; + readonly MEDIA_RULE: number; + readonly NAMESPACE_RULE: number; + readonly PAGE_RULE: number; + readonly STYLE_RULE: number; + readonly SUPPORTS_RULE: number; + readonly UNKNOWN_RULE: number; + readonly VIEWPORT_RULE: number; +} + +interface CSSRuleList { + readonly length: number; + item(index: number): CSSRule; + [index: number]: CSSRule; +} + +declare var CSSRuleList: { + prototype: CSSRuleList; + new(): CSSRuleList; +} + +interface CSSStyleDeclaration { + alignContent: string | null; + alignItems: string | null; + alignSelf: string | null; + alignmentBaseline: string | null; + animation: string | null; + animationDelay: string | null; + animationDirection: string | null; + animationDuration: string | null; + animationFillMode: string | null; + animationIterationCount: string | null; + animationName: string | null; + animationPlayState: string | null; + animationTimingFunction: string | null; + backfaceVisibility: string | null; + background: string | null; + backgroundAttachment: string | null; + backgroundClip: string | null; + backgroundColor: string | null; + backgroundImage: string | null; + backgroundOrigin: string | null; + backgroundPosition: string | null; + backgroundPositionX: string | null; + backgroundPositionY: string | null; + backgroundRepeat: string | null; + backgroundSize: string | null; + baselineShift: string | null; + border: string | null; + borderBottom: string | null; + borderBottomColor: string | null; + borderBottomLeftRadius: string | null; + borderBottomRightRadius: string | null; + borderBottomStyle: string | null; + borderBottomWidth: string | null; + borderCollapse: string | null; + borderColor: string | null; + borderImage: string | null; + borderImageOutset: string | null; + borderImageRepeat: string | null; + borderImageSlice: string | null; + borderImageSource: string | null; + borderImageWidth: string | null; + borderLeft: string | null; + borderLeftColor: string | null; + borderLeftStyle: string | null; + borderLeftWidth: string | null; + borderRadius: string | null; + borderRight: string | null; + borderRightColor: string | null; + borderRightStyle: string | null; + borderRightWidth: string | null; + borderSpacing: string | null; + borderStyle: string | null; + borderTop: string | null; + borderTopColor: string | null; + borderTopLeftRadius: string | null; + borderTopRightRadius: string | null; + borderTopStyle: string | null; + borderTopWidth: string | null; + borderWidth: string | null; + bottom: string | null; + boxShadow: string | null; + boxSizing: string | null; + breakAfter: string | null; + breakBefore: string | null; + breakInside: string | null; + captionSide: string | null; + clear: string | null; + clip: string | null; + clipPath: string | null; + clipRule: string | null; + color: string | null; + colorInterpolationFilters: string | null; + columnCount: any; + columnFill: string | null; + columnGap: any; + columnRule: string | null; + columnRuleColor: any; + columnRuleStyle: string | null; + columnRuleWidth: any; + columnSpan: string | null; + columnWidth: any; + columns: string | null; + content: string | null; + counterIncrement: string | null; + counterReset: string | null; + cssFloat: string | null; + cssText: string; + cursor: string | null; + direction: string | null; + display: string | null; + dominantBaseline: string | null; + emptyCells: string | null; + enableBackground: string | null; + fill: string | null; + fillOpacity: string | null; + fillRule: string | null; + filter: string | null; + flex: string | null; + flexBasis: string | null; + flexDirection: string | null; + flexFlow: string | null; + flexGrow: string | null; + flexShrink: string | null; + flexWrap: string | null; + floodColor: string | null; + floodOpacity: string | null; + font: string | null; + fontFamily: string | null; + fontFeatureSettings: string | null; + fontSize: string | null; + fontSizeAdjust: string | null; + fontStretch: string | null; + fontStyle: string | null; + fontVariant: string | null; + fontWeight: string | null; + glyphOrientationHorizontal: string | null; + glyphOrientationVertical: string | null; + height: string | null; + imeMode: string | null; + justifyContent: string | null; + kerning: string | null; + layoutGrid: string | null; + layoutGridChar: string | null; + layoutGridLine: string | null; + layoutGridMode: string | null; + layoutGridType: string | null; + left: string | null; + readonly length: number; + letterSpacing: string | null; + lightingColor: string | null; + lineBreak: string | null; + lineHeight: string | null; + listStyle: string | null; + listStyleImage: string | null; + listStylePosition: string | null; + listStyleType: string | null; + margin: string | null; + marginBottom: string | null; + marginLeft: string | null; + marginRight: string | null; + marginTop: string | null; + marker: string | null; + markerEnd: string | null; + markerMid: string | null; + markerStart: string | null; + mask: string | null; + maxHeight: string | null; + maxWidth: string | null; + minHeight: string | null; + minWidth: string | null; + msContentZoomChaining: string | null; + msContentZoomLimit: string | null; + msContentZoomLimitMax: any; + msContentZoomLimitMin: any; + msContentZoomSnap: string | null; + msContentZoomSnapPoints: string | null; + msContentZoomSnapType: string | null; + msContentZooming: string | null; + msFlowFrom: string | null; + msFlowInto: string | null; + msFontFeatureSettings: string | null; + msGridColumn: any; + msGridColumnAlign: string | null; + msGridColumnSpan: any; + msGridColumns: string | null; + msGridRow: any; + msGridRowAlign: string | null; + msGridRowSpan: any; + msGridRows: string | null; + msHighContrastAdjust: string | null; + msHyphenateLimitChars: string | null; + msHyphenateLimitLines: any; + msHyphenateLimitZone: any; + msHyphens: string | null; + msImeAlign: string | null; + msOverflowStyle: string | null; + msScrollChaining: string | null; + msScrollLimit: string | null; + msScrollLimitXMax: any; + msScrollLimitXMin: any; + msScrollLimitYMax: any; + msScrollLimitYMin: any; + msScrollRails: string | null; + msScrollSnapPointsX: string | null; + msScrollSnapPointsY: string | null; + msScrollSnapType: string | null; + msScrollSnapX: string | null; + msScrollSnapY: string | null; + msScrollTranslation: string | null; + msTextCombineHorizontal: string | null; + msTextSizeAdjust: any; + msTouchAction: string | null; + msTouchSelect: string | null; + msUserSelect: string | null; + msWrapFlow: string; + msWrapMargin: any; + msWrapThrough: string; + opacity: string | null; + order: string | null; + orphans: string | null; + outline: string | null; + outlineColor: string | null; + outlineOffset: string | null; + outlineStyle: string | null; + outlineWidth: string | null; + overflow: string | null; + overflowX: string | null; + overflowY: string | null; + padding: string | null; + paddingBottom: string | null; + paddingLeft: string | null; + paddingRight: string | null; + paddingTop: string | null; + pageBreakAfter: string | null; + pageBreakBefore: string | null; + pageBreakInside: string | null; + readonly parentRule: CSSRule; + perspective: string | null; + perspectiveOrigin: string | null; + pointerEvents: string | null; + position: string | null; + quotes: string | null; + right: string | null; + rotate: string | null; + rubyAlign: string | null; + rubyOverhang: string | null; + rubyPosition: string | null; + scale: string | null; + stopColor: string | null; + stopOpacity: string | null; + stroke: string | null; + strokeDasharray: string | null; + strokeDashoffset: string | null; + strokeLinecap: string | null; + strokeLinejoin: string | null; + strokeMiterlimit: string | null; + strokeOpacity: string | null; + strokeWidth: string | null; + tableLayout: string | null; + textAlign: string | null; + textAlignLast: string | null; + textAnchor: string | null; + textDecoration: string | null; + textIndent: string | null; + textJustify: string | null; + textKashida: string | null; + textKashidaSpace: string | null; + textOverflow: string | null; + textShadow: string | null; + textTransform: string | null; + textUnderlinePosition: string | null; + top: string | null; + touchAction: string | null; + transform: string | null; + transformOrigin: string | null; + transformStyle: string | null; + transition: string | null; + transitionDelay: string | null; + transitionDuration: string | null; + transitionProperty: string | null; + transitionTimingFunction: string | null; + translate: string | null; + unicodeBidi: string | null; + verticalAlign: string | null; + visibility: string | null; + webkitAlignContent: string | null; + webkitAlignItems: string | null; + webkitAlignSelf: string | null; + webkitAnimation: string | null; + webkitAnimationDelay: string | null; + webkitAnimationDirection: string | null; + webkitAnimationDuration: string | null; + webkitAnimationFillMode: string | null; + webkitAnimationIterationCount: string | null; + webkitAnimationName: string | null; + webkitAnimationPlayState: string | null; + webkitAnimationTimingFunction: string | null; + webkitAppearance: string | null; + webkitBackfaceVisibility: string | null; + webkitBackgroundClip: string | null; + webkitBackgroundOrigin: string | null; + webkitBackgroundSize: string | null; + webkitBorderBottomLeftRadius: string | null; + webkitBorderBottomRightRadius: string | null; + webkitBorderImage: string | null; + webkitBorderRadius: string | null; + webkitBorderTopLeftRadius: string | null; + webkitBorderTopRightRadius: string | null; + webkitBoxAlign: string | null; + webkitBoxDirection: string | null; + webkitBoxFlex: string | null; + webkitBoxOrdinalGroup: string | null; + webkitBoxOrient: string | null; + webkitBoxPack: string | null; + webkitBoxSizing: string | null; + webkitColumnBreakAfter: string | null; + webkitColumnBreakBefore: string | null; + webkitColumnBreakInside: string | null; + webkitColumnCount: any; + webkitColumnGap: any; + webkitColumnRule: string | null; + webkitColumnRuleColor: any; + webkitColumnRuleStyle: string | null; + webkitColumnRuleWidth: any; + webkitColumnSpan: string | null; + webkitColumnWidth: any; + webkitColumns: string | null; + webkitFilter: string | null; + webkitFlex: string | null; + webkitFlexBasis: string | null; + webkitFlexDirection: string | null; + webkitFlexFlow: string | null; + webkitFlexGrow: string | null; + webkitFlexShrink: string | null; + webkitFlexWrap: string | null; + webkitJustifyContent: string | null; + webkitOrder: string | null; + webkitPerspective: string | null; + webkitPerspectiveOrigin: string | null; + webkitTapHighlightColor: string | null; + webkitTextFillColor: string | null; + webkitTextSizeAdjust: any; + webkitTextStroke: string | null; + webkitTextStrokeColor: string | null; + webkitTextStrokeWidth: string | null; + webkitTransform: string | null; + webkitTransformOrigin: string | null; + webkitTransformStyle: string | null; + webkitTransition: string | null; + webkitTransitionDelay: string | null; + webkitTransitionDuration: string | null; + webkitTransitionProperty: string | null; + webkitTransitionTimingFunction: string | null; + webkitUserModify: string | null; + webkitUserSelect: string | null; + webkitWritingMode: string | null; + whiteSpace: string | null; + widows: string | null; + width: string | null; + wordBreak: string | null; + wordSpacing: string | null; + wordWrap: string | null; + writingMode: string | null; + zIndex: string | null; + zoom: string | null; + resize: string | null; + userSelect: string | null; + getPropertyPriority(propertyName: string): string; + getPropertyValue(propertyName: string): string; + item(index: number): string; + removeProperty(propertyName: string): string; + setProperty(propertyName: string, value: string | null, priority?: string): void; + [index: number]: string; +} + +declare var CSSStyleDeclaration: { + prototype: CSSStyleDeclaration; + new(): CSSStyleDeclaration; +} + +interface CSSStyleRule extends CSSRule { + readonly readOnly: boolean; + selectorText: string; + readonly style: CSSStyleDeclaration; +} + +declare var CSSStyleRule: { + prototype: CSSStyleRule; + new(): CSSStyleRule; +} + +interface CSSStyleSheet extends StyleSheet { + readonly cssRules: CSSRuleList; + cssText: string; + readonly id: string; + readonly imports: StyleSheetList; + readonly isAlternate: boolean; + readonly isPrefAlternate: boolean; + readonly ownerRule: CSSRule; + readonly owningElement: Element; + readonly pages: StyleSheetPageList; + readonly readOnly: boolean; + readonly 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 Cache { + add(request: RequestInfo): Promise; + addAll(requests: RequestInfo[]): Promise; + delete(request: RequestInfo, options?: CacheQueryOptions): Promise; + keys(request?: RequestInfo, options?: CacheQueryOptions): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + matchAll(request?: RequestInfo, options?: CacheQueryOptions): any; + put(request: RequestInfo, response: Response): Promise; +} + +declare var Cache: { + prototype: Cache; + new(): Cache; +} + +interface CacheStorage { + delete(cacheName: string): Promise; + has(cacheName: string): Promise; + keys(): any; + match(request: RequestInfo, options?: CacheQueryOptions): Promise; + open(cacheName: string): Promise; +} + +declare var CacheStorage: { + prototype: CacheStorage; + new(): CacheStorage; +} + +interface CanvasGradient { + addColorStop(offset: number, color: string): void; +} + +declare var CanvasGradient: { + prototype: CanvasGradient; + new(): CanvasGradient; +} + +interface CanvasPattern { + setTransform(matrix: SVGMatrix): void; +} + +declare var CanvasPattern: { + prototype: CanvasPattern; + new(): CanvasPattern; +} + +interface CanvasRenderingContext2D extends Object, CanvasPathMethods { + readonly canvas: HTMLCanvasElement; + fillStyle: string | CanvasGradient | CanvasPattern; + font: string; + globalAlpha: number; + globalCompositeOperation: string; + imageSmoothingEnabled: boolean; + lineCap: string; + lineDashOffset: number; + lineJoin: string; + lineWidth: number; + miterLimit: number; + msFillRule: CanvasFillRule; + shadowBlur: number; + shadowColor: string; + shadowOffsetX: number; + shadowOffsetY: number; + strokeStyle: string | CanvasGradient | CanvasPattern; + textAlign: string; + textBaseline: string; + mozImageSmoothingEnabled: boolean; + webkitImageSmoothingEnabled: boolean; + oImageSmoothingEnabled: boolean; + beginPath(): void; + clearRect(x: number, y: number, w: number, h: number): void; + clip(fillRule?: CanvasFillRule): 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; + drawFocusIfNeeded(element: Element): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, dstX: number, dstY: number, dstW: number, dstH: number): void; + drawImage(image: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | ImageBitmap, srcX: number, srcY: number, srcW: number, srcH: number, dstX: number, dstY: number, dstW: number, dstH: number): void; + fill(fillRule?: CanvasFillRule): 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?: CanvasFillRule): boolean; + measureText(text: string): TextMetrics; + putImageData(imagedata: ImageData, dx: number, dy: number, dirtyX?: number, dirtyY?: number, dirtyWidth?: number, dirtyHeight?: 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(path?: Path2D): 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; + readonly 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; +} + +declare var CharacterData: { + prototype: CharacterData; + new(): CharacterData; +} + +interface ClientRect { + bottom: number; + readonly height: number; + left: number; + right: number; + top: number; + readonly width: number; +} + +declare var ClientRect: { + prototype: ClientRect; + new(): ClientRect; +} + +interface ClientRectList { + readonly length: number; + item(index: number): ClientRect; + [index: number]: ClientRect; +} + +declare var ClientRectList: { + prototype: ClientRectList; + new(): ClientRectList; +} + +interface ClipboardEvent extends Event { + readonly clipboardData: DataTransfer; +} + +declare var ClipboardEvent: { + prototype: ClipboardEvent; + new(type: string, eventInitDict?: ClipboardEventInit): ClipboardEvent; +} + +interface CloseEvent extends Event { + readonly code: number; + readonly reason: string; + readonly wasClean: boolean; + initCloseEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, wasCleanArg: boolean, codeArg: number, reasonArg: string): void; +} + +declare var CloseEvent: { + prototype: CloseEvent; + new(typeArg: string, eventInitDict?: CloseEventInit): CloseEvent; +} + +interface Comment extends CharacterData { + text: string; +} + +declare var Comment: { + prototype: Comment; + new(): Comment; +} + +interface CompositionEvent extends UIEvent { + readonly data: string; + readonly 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?: any, ...optionalParams: any[]): void; + dir(value?: any, ...optionalParams: any[]): void; + dirxml(value: any): void; + error(message?: any, ...optionalParams: any[]): void; + exception(message?: string, ...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; + table(...data: any[]): 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 | null; + normalize: boolean; +} + +declare var ConvolverNode: { + prototype: ConvolverNode; + new(): ConvolverNode; +} + +interface Coordinates { + readonly accuracy: number; + readonly altitude: number | null; + readonly altitudeAccuracy: number | null; + readonly heading: number | null; + readonly latitude: number; + readonly longitude: number; + readonly speed: number | null; +} + +declare var Coordinates: { + prototype: Coordinates; + new(): Coordinates; +} + +interface Crypto extends Object, RandomSource { + readonly subtle: SubtleCrypto; +} + +declare var Crypto: { + prototype: Crypto; + new(): Crypto; +} + +interface CryptoKey { + readonly algorithm: KeyAlgorithm; + readonly extractable: boolean; + readonly type: string; + readonly 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 { + readonly 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 { + readonly name: string; + toString(): string; +} + +declare var DOMError: { + prototype: DOMError; + new(): DOMError; +} + +interface DOMException { + readonly code: number; + readonly message: string; + readonly name: string; + toString(): string; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; +} + +declare var DOMException: { + prototype: DOMException; + new(): DOMException; + readonly ABORT_ERR: number; + readonly DATA_CLONE_ERR: number; + readonly DOMSTRING_SIZE_ERR: number; + readonly HIERARCHY_REQUEST_ERR: number; + readonly INDEX_SIZE_ERR: number; + readonly INUSE_ATTRIBUTE_ERR: number; + readonly INVALID_ACCESS_ERR: number; + readonly INVALID_CHARACTER_ERR: number; + readonly INVALID_MODIFICATION_ERR: number; + readonly INVALID_NODE_TYPE_ERR: number; + readonly INVALID_STATE_ERR: number; + readonly NAMESPACE_ERR: number; + readonly NETWORK_ERR: number; + readonly NOT_FOUND_ERR: number; + readonly NOT_SUPPORTED_ERR: number; + readonly NO_DATA_ALLOWED_ERR: number; + readonly NO_MODIFICATION_ALLOWED_ERR: number; + readonly PARSE_ERR: number; + readonly QUOTA_EXCEEDED_ERR: number; + readonly SECURITY_ERR: number; + readonly SERIALIZE_ERR: number; + readonly SYNTAX_ERR: number; + readonly TIMEOUT_ERR: number; + readonly TYPE_MISMATCH_ERR: number; + readonly URL_MISMATCH_ERR: number; + readonly VALIDATION_ERR: number; + readonly WRONG_DOCUMENT_ERR: number; +} + +interface DOMImplementation { + createDocument(namespaceURI: string | null, qualifiedName: string | null, doctype: DocumentType | null): Document; + createDocumentType(qualifiedName: string, publicId: string, systemId: string): DocumentType; + createHTMLDocument(title: string): Document; + hasFeature(feature: string | null, version: string | null): 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 { + readonly length: number; + contains(str: string): boolean; + item(index: number): string | null; + [index: number]: string; +} + +declare var DOMStringList: { + prototype: DOMStringList; + new(): DOMStringList; +} + +interface DOMStringMap { + [name: string]: string | undefined; +} + +declare var DOMStringMap: { + prototype: DOMStringMap; + new(): DOMStringMap; +} + +interface DOMTokenList { + readonly 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; + addEventListener(type: K, listener: (this: DataCue, ev: TextTrackCueEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var DataCue: { + prototype: DataCue; + new(): DataCue; +} + +interface DataTransfer { + dropEffect: string; + effectAllowed: string; + readonly files: FileList; + readonly items: DataTransferItemList; + readonly types: string[]; + clearData(format?: string): boolean; + getData(format: string): string; + setData(format: string, data: string): boolean; + setDragImage(image: Element, x: number, y: number): void; +} + +declare var DataTransfer: { + prototype: DataTransfer; + new(): DataTransfer; +} + +interface DataTransferItem { + readonly kind: string; + readonly type: string; + getAsFile(): File | null; + getAsString(_callback: FunctionStringCallback | null): void; + webkitGetAsEntry(): any; +} + +declare var DataTransferItem: { + prototype: DataTransferItem; + new(): DataTransferItem; +} + +interface DataTransferItemList { + readonly length: number; + add(data: File): DataTransferItem | null; + clear(): void; + item(index: number): DataTransferItem; + remove(index: number): void; + [index: number]: DataTransferItem; +} + +declare var DataTransferItemList: { + prototype: DataTransferItemList; + new(): DataTransferItemList; +} + +interface DeferredPermissionRequest { + readonly id: number; + readonly type: MSWebViewPermissionType; + readonly uri: string; + allow(): void; + deny(): void; +} + +declare var DeferredPermissionRequest: { + prototype: DeferredPermissionRequest; + new(): DeferredPermissionRequest; +} + +interface DelayNode extends AudioNode { + readonly delayTime: AudioParam; +} + +declare var DelayNode: { + prototype: DelayNode; + new(): DelayNode; +} + +interface DeviceAcceleration { + readonly x: number | null; + readonly y: number | null; + readonly z: number | null; +} + +declare var DeviceAcceleration: { + prototype: DeviceAcceleration; + new(): DeviceAcceleration; +} + +interface DeviceLightEvent extends Event { + readonly value: number; +} + +declare var DeviceLightEvent: { + prototype: DeviceLightEvent; + new(typeArg: string, eventInitDict?: DeviceLightEventInit): DeviceLightEvent; +} + +interface DeviceMotionEvent extends Event { + readonly acceleration: DeviceAcceleration | null; + readonly accelerationIncludingGravity: DeviceAcceleration | null; + readonly interval: number | null; + readonly rotationRate: DeviceRotationRate | null; + initDeviceMotionEvent(type: string, bubbles: boolean, cancelable: boolean, acceleration: DeviceAccelerationDict | null, accelerationIncludingGravity: DeviceAccelerationDict | null, rotationRate: DeviceRotationRateDict | null, interval: number | null): void; +} + +declare var DeviceMotionEvent: { + prototype: DeviceMotionEvent; + new(typeArg: string, eventInitDict?: DeviceMotionEventInit): DeviceMotionEvent; +} + +interface DeviceOrientationEvent extends Event { + readonly absolute: boolean; + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; + initDeviceOrientationEvent(type: string, bubbles: boolean, cancelable: boolean, alpha: number | null, beta: number | null, gamma: number | null, absolute: boolean): void; +} + +declare var DeviceOrientationEvent: { + prototype: DeviceOrientationEvent; + new(typeArg: string, eventInitDict?: DeviceOrientationEventInit): DeviceOrientationEvent; +} + +interface DeviceRotationRate { + readonly alpha: number | null; + readonly beta: number | null; + readonly gamma: number | null; +} + +declare var DeviceRotationRate: { + prototype: DeviceRotationRate; + new(): DeviceRotationRate; +} + +interface DocumentEventMap extends GlobalEventHandlersEventMap { + "abort": UIEvent; + "activate": UIEvent; + "beforeactivate": UIEvent; + "beforedeactivate": UIEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "contextmenu": PointerEvent; + "dblclick": MouseEvent; + "deactivate": UIEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "fullscreenchange": Event; + "fullscreenerror": Event; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "mousedown": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSContentZoom": UIEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSInertiaStart": MSGestureEvent; + "MSManipulationStateChanged": MSManipulationEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "mssitemodejumplistitemremoved": MSSiteModeEvent; + "msthumbnailclick": MSSiteModeEvent; + "pause": Event; + "play": Event; + "playing": Event; + "pointerlockchange": Event; + "pointerlockerror": Event; + "progress": ProgressEvent; + "ratechange": Event; + "readystatechange": Event; + "reset": Event; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "selectionchange": Event; + "selectstart": Event; + "stalled": Event; + "stop": Event; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "touchcancel": TouchEvent; + "touchend": TouchEvent; + "touchmove": TouchEvent; + "touchstart": TouchEvent; + "volumechange": Event; + "waiting": Event; + "webkitfullscreenchange": Event; + "webkitfullscreenerror": Event; +} + +interface Document extends Node, GlobalEventHandlers, NodeSelector, DocumentEvent, ParentNode, DocumentOrShadowRoot { + /** + * Sets or gets the URL for the current document. + */ + readonly URL: string; + /** + * Gets the URL for the document, stripped of any character encoding. + */ + readonly URLUnencoded: string; + /** + * Gets the object that has the focus when the parent document has focus. + */ + readonly 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. + */ + readonly all: HTMLAllCollection; + /** + * 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: HTMLCollectionOf; + /** + * Retrieves a collection of all applet objects in the document. + */ + applets: HTMLCollectionOf; + /** + * 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; + readonly 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. + */ + readonly compatMode: string; + cookie: string; + readonly currentScript: HTMLScriptElement | SVGScriptElement; + readonly 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. + */ + readonly 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: HTMLCollectionOf; + /** + * 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: HTMLCollectionOf; + readonly fullscreenElement: Element | null; + readonly fullscreenEnabled: boolean; + readonly head: HTMLHeadElement; + readonly hidden: boolean; + /** + * Retrieves a collection, in source order, of img objects in the document. + */ + images: HTMLCollectionOf; + /** + * Gets the implementation object of the current document. + */ + readonly implementation: DOMImplementation; + /** + * Returns the character encoding used to create the webpage that is loaded into the document object. + */ + readonly inputEncoding: string | null; + /** + * Gets the date that the page was last modified, if the page supplies one. + */ + readonly 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: HTMLCollectionOf; + /** + * Contains information about the current URL. + */ + readonly location: Location; + msCSSOMElementFloatMetrics: boolean; + msCapsLockWarningOff: boolean; + /** + * Fires when the user aborts the download. + * @param ev The event. + */ + onabort: (this: Document, ev: UIEvent) => any; + /** + * Fires when the object is set as the active element. + * @param ev The event. + */ + onactivate: (this: Document, ev: UIEvent) => any; + /** + * Fires immediately before the object is set as the active element. + * @param ev The event. + */ + onbeforeactivate: (this: Document, 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: (this: Document, ev: UIEvent) => any; + /** + * Fires when the object loses the input focus. + * @param ev The focus event. + */ + onblur: (this: Document, ev: FocusEvent) => any; + /** + * Occurs when playback is possible, but would require further buffering. + * @param ev The event. + */ + oncanplay: (this: Document, ev: Event) => any; + oncanplaythrough: (this: Document, ev: Event) => any; + /** + * Fires when the contents of the object or selection have changed. + * @param ev The event. + */ + onchange: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the left mouse button on the object + * @param ev The mouse event. + */ + onclick: (this: Document, 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: (this: Document, ev: PointerEvent) => any; + /** + * Fires when the user double-clicks the object. + * @param ev The mouse event. + */ + ondblclick: (this: Document, 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: (this: Document, ev: UIEvent) => any; + /** + * Fires on the source object continuously during a drag operation. + * @param ev The event. + */ + ondrag: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, 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: (this: Document, ev: DragEvent) => any; + ondrop: (this: Document, ev: DragEvent) => any; + /** + * Occurs when the duration attribute is updated. + * @param ev The event. + */ + ondurationchange: (this: Document, ev: Event) => any; + /** + * Occurs when the media element is reset to its initial state. + * @param ev The event. + */ + onemptied: (this: Document, ev: Event) => any; + /** + * Occurs when the end of playback is reached. + * @param ev The event + */ + onended: (this: Document, ev: MediaStreamErrorEvent) => any; + /** + * Fires when an error occurs during object loading. + * @param ev The event. + */ + onerror: (this: Document, ev: ErrorEvent) => any; + /** + * Fires when the object receives focus. + * @param ev The event. + */ + onfocus: (this: Document, ev: FocusEvent) => any; + onfullscreenchange: (this: Document, ev: Event) => any; + onfullscreenerror: (this: Document, ev: Event) => any; + oninput: (this: Document, ev: Event) => any; + oninvalid: (this: Document, ev: Event) => any; + /** + * Fires when the user presses a key. + * @param ev The keyboard event + */ + onkeydown: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires when the user presses an alphanumeric key. + * @param ev The event. + */ + onkeypress: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires when the user releases a key. + * @param ev The keyboard event + */ + onkeyup: (this: Document, ev: KeyboardEvent) => any; + /** + * Fires immediately after the browser loads the object. + * @param ev The event. + */ + onload: (this: Document, ev: Event) => any; + /** + * Occurs when media data is loaded at the current playback position. + * @param ev The event. + */ + onloadeddata: (this: Document, ev: Event) => any; + /** + * Occurs when the duration and dimensions of the media have been determined. + * @param ev The event. + */ + onloadedmetadata: (this: Document, ev: Event) => any; + /** + * Occurs when Internet Explorer begins looking for media data. + * @param ev The event. + */ + onloadstart: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the object with either mouse button. + * @param ev The mouse event. + */ + onmousedown: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse over the object. + * @param ev The mouse event. + */ + onmousemove: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer outside the boundaries of the object. + * @param ev The mouse event. + */ + onmouseout: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user moves the mouse pointer into the object. + * @param ev The mouse event. + */ + onmouseover: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the user releases a mouse button while the mouse is over the object. + * @param ev The mouse event. + */ + onmouseup: (this: Document, ev: MouseEvent) => any; + /** + * Fires when the wheel button is rotated. + * @param ev The mouse event + */ + onmousewheel: (this: Document, ev: WheelEvent) => any; + onmscontentzoom: (this: Document, ev: UIEvent) => any; + onmsgesturechange: (this: Document, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Document, ev: MSGestureEvent) => any; + onmsgestureend: (this: Document, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Document, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Document, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Document, ev: MSGestureEvent) => any; + onmsinertiastart: (this: Document, ev: MSGestureEvent) => any; + onmsmanipulationstatechanged: (this: Document, ev: MSManipulationEvent) => any; + onmspointercancel: (this: Document, ev: MSPointerEvent) => any; + onmspointerdown: (this: Document, ev: MSPointerEvent) => any; + onmspointerenter: (this: Document, ev: MSPointerEvent) => any; + onmspointerleave: (this: Document, ev: MSPointerEvent) => any; + onmspointermove: (this: Document, ev: MSPointerEvent) => any; + onmspointerout: (this: Document, ev: MSPointerEvent) => any; + onmspointerover: (this: Document, ev: MSPointerEvent) => any; + onmspointerup: (this: Document, 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: (this: Document, 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: (this: Document, ev: MSSiteModeEvent) => any; + /** + * Occurs when playback is paused. + * @param ev The event. + */ + onpause: (this: Document, ev: Event) => any; + /** + * Occurs when the play method is requested. + * @param ev The event. + */ + onplay: (this: Document, ev: Event) => any; + /** + * Occurs when the audio or video has started playing. + * @param ev The event. + */ + onplaying: (this: Document, ev: Event) => any; + onpointerlockchange: (this: Document, ev: Event) => any; + onpointerlockerror: (this: Document, ev: Event) => any; + /** + * Occurs to indicate progress while downloading media data. + * @param ev The event. + */ + onprogress: (this: Document, ev: ProgressEvent) => any; + /** + * Occurs when the playback rate is increased or decreased. + * @param ev The event. + */ + onratechange: (this: Document, ev: Event) => any; + /** + * Fires when the state of the object has changed. + * @param ev The event + */ + onreadystatechange: (this: Document, ev: Event) => any; + /** + * Fires when the user resets a form. + * @param ev The event. + */ + onreset: (this: Document, ev: Event) => any; + /** + * Fires when the user repositions the scroll box in the scroll bar on the object. + * @param ev The event. + */ + onscroll: (this: Document, ev: UIEvent) => any; + /** + * Occurs when the seek operation ends. + * @param ev The event. + */ + onseeked: (this: Document, ev: Event) => any; + /** + * Occurs when the current playback position is moved. + * @param ev The event. + */ + onseeking: (this: Document, ev: Event) => any; + /** + * Fires when the current selection changes. + * @param ev The event. + */ + onselect: (this: Document, ev: UIEvent) => any; + /** + * Fires when the selection state of a document changes. + * @param ev The event. + */ + onselectionchange: (this: Document, ev: Event) => any; + onselectstart: (this: Document, ev: Event) => any; + /** + * Occurs when the download has stopped. + * @param ev The event. + */ + onstalled: (this: Document, ev: Event) => any; + /** + * Fires when the user clicks the Stop button or leaves the Web page. + * @param ev The event. + */ + onstop: (this: Document, ev: Event) => any; + onsubmit: (this: Document, ev: Event) => any; + /** + * Occurs if the load operation has been intentionally halted. + * @param ev The event. + */ + onsuspend: (this: Document, ev: Event) => any; + /** + * Occurs to indicate the current playback position. + * @param ev The event. + */ + ontimeupdate: (this: Document, 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: (this: Document, ev: Event) => any; + /** + * Occurs when playback stops because the next frame of a video resource is not available. + * @param ev The event. + */ + onwaiting: (this: Document, ev: Event) => any; + onwebkitfullscreenchange: (this: Document, ev: Event) => any; + onwebkitfullscreenerror: (this: Document, ev: Event) => any; + plugins: HTMLCollectionOf; + readonly pointerLockElement: Element; + /** + * Retrieves a value that indicates the current state of the object. + */ + readonly readyState: string; + /** + * Gets the URL of the location that referred the user to the current page. + */ + readonly referrer: string; + /** + * Gets the root svg element in the document hierarchy. + */ + readonly rootElement: SVGSVGElement; + /** + * Retrieves a collection of all script objects in the document. + */ + scripts: HTMLCollectionOf; + readonly scrollingElement: Element | null; + /** + * Retrieves a collection of styleSheet objects representing the style sheets that correspond to each instance of a link or style object in the document. + */ + readonly styleSheets: StyleSheetList; + /** + * Contains the title of the document. + */ + title: string; + readonly visibilityState: VisibilityState; + /** + * Sets or gets the color of the links that the user has visited. + */ + vlinkColor: string; + readonly webkitCurrentFullScreenElement: Element | null; + readonly webkitFullscreenElement: Element | null; + readonly webkitFullscreenEnabled: boolean; + readonly webkitIsFullScreen: boolean; + readonly xmlEncoding: string | null; + xmlStandalone: boolean; + /** + * Gets or sets the version attribute specified in the declaration of an XML document. + */ + xmlVersion: string | null; + adoptNode(source: T): T; + captureEvents(): void; + caretRangeFromPoint(x: number, y: number): Range; + 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 | null, 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: K): HTMLElementTagNameMap[K]; + createElement(tagName: string): HTMLElement; + createElementNS(namespaceURI: "http://www.w3.org/1999/xhtml", qualifiedName: 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 | null, 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: Window, 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 | null, type: number, result: XPathResult | null): 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 | null; + getElementsByClassName(classNames: string): HTMLCollectionOf; + /** + * 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: K): ElementListTagNameMap[K]; + getElementsByTagName(tagname: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + /** + * 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: T, deep: boolean): T; + msElementsFromPoint(x: number, y: number): NodeListOf; + msElementsFromRect(left: number, top: number, width: number, height: number): NodeListOf; + /** + * 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; + addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Document: { + prototype: Document; + new(): Document; +} + +interface DocumentFragment extends Node, NodeSelector, ParentNode { + getElementById(elementId: string): HTMLElement | null; +} + +declare var DocumentFragment: { + prototype: DocumentFragment; + new(): DocumentFragment; +} + +interface DocumentType extends Node, ChildNode { + readonly entities: NamedNodeMap; + readonly internalSubset: string | null; + readonly name: string; + readonly notations: NamedNodeMap; + readonly publicId: string; + readonly systemId: string; +} + +declare var DocumentType: { + prototype: DocumentType; + new(): DocumentType; +} + +interface DragEvent extends MouseEvent { + readonly 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 { + readonly attack: AudioParam; + readonly knee: AudioParam; + readonly ratio: AudioParam; + readonly reduction: number; + readonly release: AudioParam; + readonly threshold: AudioParam; +} + +declare var DynamicsCompressorNode: { + prototype: DynamicsCompressorNode; + new(): DynamicsCompressorNode; +} + +interface EXT_frag_depth { +} + +declare var EXT_frag_depth: { + prototype: EXT_frag_depth; + new(): EXT_frag_depth; +} + +interface EXT_texture_filter_anisotropic { + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +declare var EXT_texture_filter_anisotropic: { + prototype: EXT_texture_filter_anisotropic; + new(): EXT_texture_filter_anisotropic; + readonly MAX_TEXTURE_MAX_ANISOTROPY_EXT: number; + readonly TEXTURE_MAX_ANISOTROPY_EXT: number; +} + +interface ElementEventMap extends GlobalEventHandlersEventMap { + "ariarequest": Event; + "command": Event; + "gotpointercapture": PointerEvent; + "lostpointercapture": PointerEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSGotPointerCapture": MSPointerEvent; + "MSInertiaStart": MSGestureEvent; + "MSLostPointerCapture": MSPointerEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "touchcancel": TouchEvent; + "touchend": TouchEvent; + "touchmove": TouchEvent; + "touchstart": TouchEvent; + "webkitfullscreenchange": Event; + "webkitfullscreenerror": Event; +} + +interface Element extends Node, GlobalEventHandlers, ElementTraversal, NodeSelector, ChildNode, ParentNode { + readonly classList: DOMTokenList; + className: string; + readonly clientHeight: number; + readonly clientLeft: number; + readonly clientTop: number; + readonly clientWidth: number; + id: string; + innerHTML: string; + msContentZoomFactor: number; + readonly msRegionOverflow: string; + onariarequest: (this: Element, ev: Event) => any; + oncommand: (this: Element, ev: Event) => any; + ongotpointercapture: (this: Element, ev: PointerEvent) => any; + onlostpointercapture: (this: Element, ev: PointerEvent) => any; + onmsgesturechange: (this: Element, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Element, ev: MSGestureEvent) => any; + onmsgestureend: (this: Element, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Element, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Element, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Element, ev: MSGestureEvent) => any; + onmsgotpointercapture: (this: Element, ev: MSPointerEvent) => any; + onmsinertiastart: (this: Element, ev: MSGestureEvent) => any; + onmslostpointercapture: (this: Element, ev: MSPointerEvent) => any; + onmspointercancel: (this: Element, ev: MSPointerEvent) => any; + onmspointerdown: (this: Element, ev: MSPointerEvent) => any; + onmspointerenter: (this: Element, ev: MSPointerEvent) => any; + onmspointerleave: (this: Element, ev: MSPointerEvent) => any; + onmspointermove: (this: Element, ev: MSPointerEvent) => any; + onmspointerout: (this: Element, ev: MSPointerEvent) => any; + onmspointerover: (this: Element, ev: MSPointerEvent) => any; + onmspointerup: (this: Element, ev: MSPointerEvent) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onwebkitfullscreenchange: (this: Element, ev: Event) => any; + onwebkitfullscreenerror: (this: Element, ev: Event) => any; + outerHTML: string; + readonly prefix: string | null; + readonly scrollHeight: number; + scrollLeft: number; + scrollTop: number; + readonly scrollWidth: number; + readonly tagName: string; + readonly assignedSlot: HTMLSlotElement | null; + slot: string; + readonly shadowRoot: ShadowRoot | null; + getAttribute(name: string): string | null; + getAttributeNS(namespaceURI: string, localName: string): string; + getAttributeNode(name: string): Attr; + getAttributeNodeNS(namespaceURI: string, localName: string): Attr; + getBoundingClientRect(): ClientRect; + getClientRects(): ClientRectList; + getElementsByTagName(name: K): ElementListTagNameMap[K]; + getElementsByTagName(name: string): NodeListOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/1999/xhtml", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: "http://www.w3.org/2000/svg", localName: string): HTMLCollectionOf; + getElementsByTagNameNS(namespaceURI: string, localName: string): HTMLCollectionOf; + 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(qualifiedName: 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; + closest(selector: string): Element | null; + scrollIntoView(arg?: boolean | ScrollIntoViewOptions): void; + scroll(options?: ScrollToOptions): void; + scroll(x: number, y: number): void; + scrollTo(options?: ScrollToOptions): void; + scrollTo(x: number, y: number): void; + scrollBy(options?: ScrollToOptions): void; + scrollBy(x: number, y: number): void; + insertAdjacentElement(position: string, insertedElement: Element): Element | null; + insertAdjacentHTML(where: string, html: string): void; + insertAdjacentText(where: string, text: string): void; + attachShadow(shadowRootInitDict: ShadowRootInit): ShadowRoot; + addEventListener(type: K, listener: (this: Element, ev: ElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Element: { + prototype: Element; + new(): Element; +} + +interface ErrorEvent extends Event { + readonly colno: number; + readonly error: any; + readonly filename: string; + readonly lineno: number; + readonly message: string; + initErrorEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, messageArg: string, filenameArg: string, linenoArg: number): void; +} + +declare var ErrorEvent: { + prototype: ErrorEvent; + new(type: string, errorEventInitDict?: ErrorEventInit): ErrorEvent; +} + +interface Event { + readonly bubbles: boolean; + cancelBubble: boolean; + readonly cancelable: boolean; + readonly currentTarget: EventTarget; + readonly defaultPrevented: boolean; + readonly eventPhase: number; + readonly isTrusted: boolean; + returnValue: boolean; + readonly srcElement: Element | null; + readonly target: EventTarget; + readonly timeStamp: number; + readonly type: string; + readonly scoped: boolean; + initEvent(eventTypeArg: string, canBubbleArg: boolean, cancelableArg: boolean): void; + preventDefault(): void; + stopImmediatePropagation(): void; + stopPropagation(): void; + deepPath(): EventTarget[]; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; +} + +declare var Event: { + prototype: Event; + new(typeArg: string, eventInitDict?: EventInit): Event; + readonly AT_TARGET: number; + readonly BUBBLING_PHASE: number; + readonly CAPTURING_PHASE: number; +} + +interface EventTarget { + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; + dispatchEvent(evt: Event): boolean; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +} + +declare var EventTarget: { + prototype: EventTarget; + new(): EventTarget; +} + +interface ExtensionScriptApis { + extensionIdToShortId(extensionId: string): number; + fireExtensionApiTelemetry(functionName: string, isSucceeded: boolean, isSupported: boolean): void; + genericFunction(routerAddress: any, parameters?: string, callbackId?: number): void; + genericSynchronousFunction(functionId: number, parameters?: string): string; + getExtensionId(): string; + registerGenericFunctionCallbackHandler(callbackHandler: any): void; + registerGenericPersistentCallbackHandler(callbackHandler: any): void; +} + +declare var ExtensionScriptApis: { + prototype: ExtensionScriptApis; + new(): ExtensionScriptApis; +} + +interface External { +} + +declare var External: { + prototype: External; + new(): External; +} + +interface File extends Blob { + readonly lastModifiedDate: any; + readonly name: string; + readonly webkitRelativePath: string; +} + +declare var File: { + prototype: File; + new (parts: (ArrayBuffer | ArrayBufferView | Blob | string)[], filename: string, properties?: FilePropertyBag): File; +} + +interface FileList { + readonly length: number; + item(index: number): File; + [index: number]: File; +} + +declare var FileList: { + prototype: FileList; + new(): FileList; +} + +interface FileReader extends EventTarget, MSBaseReader { + readonly error: DOMError; + readAsArrayBuffer(blob: Blob): void; + readAsBinaryString(blob: Blob): void; + readAsDataURL(blob: Blob): void; + readAsText(blob: Blob, encoding?: string): void; + addEventListener(type: K, listener: (this: FileReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var FileReader: { + prototype: FileReader; + new(): FileReader; +} + +interface FocusEvent extends UIEvent { + readonly 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 FocusNavigationEvent extends Event { + readonly navigationReason: NavigationReason; + readonly originHeight: number; + readonly originLeft: number; + readonly originTop: number; + readonly originWidth: number; + requestFocus(): void; +} + +declare var FocusNavigationEvent: { + prototype: FocusNavigationEvent; + new(type: string, eventInitDict?: FocusNavigationEventInit): FocusNavigationEvent; +} + +interface FormData { + append(name: string, value: string | Blob, fileName?: string): void; + delete(name: string): void; + get(name: string): FormDataEntryValue | null; + getAll(name: string): FormDataEntryValue[]; + has(name: string): boolean; + set(name: string, value: string | Blob, fileName?: string): void; +} + +declare var FormData: { + prototype: FormData; + new (form?: HTMLFormElement): FormData; +} + +interface GainNode extends AudioNode { + readonly gain: AudioParam; +} + +declare var GainNode: { + prototype: GainNode; + new(): GainNode; +} + +interface Gamepad { + readonly axes: number[]; + readonly buttons: GamepadButton[]; + readonly connected: boolean; + readonly id: string; + readonly index: number; + readonly mapping: string; + readonly timestamp: number; +} + +declare var Gamepad: { + prototype: Gamepad; + new(): Gamepad; +} + +interface GamepadButton { + readonly pressed: boolean; + readonly value: number; +} + +declare var GamepadButton: { + prototype: GamepadButton; + new(): GamepadButton; +} + +interface GamepadEvent extends Event { + readonly gamepad: Gamepad; +} + +declare var GamepadEvent: { + prototype: GamepadEvent; + new(typeArg: string, eventInitDict?: GamepadEventInit): 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 { + readonly length: number; + item(nameOrIndex?: string): HTMLCollection | Element | null; + namedItem(name: string): HTMLCollection | Element | null; + [index: number]: 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; + download: 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; + readonly mimeType: string; + /** + * Sets or retrieves the shape of the object. + */ + name: string; + readonly 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; + readonly 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; + addEventListener(type: K, listener: (this: HTMLAnchorElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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. + */ + readonly 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; + readonly 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 | null; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLAppletElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + download: 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; + addEventListener(type: K, listener: (this: HTMLAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLAreaElement: { + prototype: HTMLAreaElement; + new(): HTMLAreaElement; +} + +interface HTMLAreasCollection extends HTMLCollectionBase { +} + +declare var HTMLAreasCollection: { + prototype: HTMLAreasCollection; + new(): HTMLAreasCollection; +} + +interface HTMLAudioElement extends HTMLMediaElement { + addEventListener(type: K, listener: (this: HTMLAudioElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLBRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLBaseElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: K, listener: (this: HTMLBaseFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLBaseFontElement: { + prototype: HTMLBaseFontElement; + new(): HTMLBaseFontElement; +} + +interface HTMLBodyElementEventMap extends HTMLElementEventMap { + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "load": Event; + "message": MessageEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; + "resize": UIEvent; + "scroll": UIEvent; + "storage": StorageEvent; + "unload": Event; +} + +interface HTMLBodyElement extends HTMLElement { + aLink: any; + background: string; + bgColor: any; + bgProperties: string; + link: any; + noWrap: boolean; + onafterprint: (this: HTMLBodyElement, ev: Event) => any; + onbeforeprint: (this: HTMLBodyElement, ev: Event) => any; + onbeforeunload: (this: HTMLBodyElement, ev: BeforeUnloadEvent) => any; + onblur: (this: HTMLBodyElement, ev: FocusEvent) => any; + onerror: (this: HTMLBodyElement, ev: ErrorEvent) => any; + onfocus: (this: HTMLBodyElement, ev: FocusEvent) => any; + onhashchange: (this: HTMLBodyElement, ev: HashChangeEvent) => any; + onload: (this: HTMLBodyElement, ev: Event) => any; + onmessage: (this: HTMLBodyElement, ev: MessageEvent) => any; + onoffline: (this: HTMLBodyElement, ev: Event) => any; + ononline: (this: HTMLBodyElement, ev: Event) => any; + onorientationchange: (this: HTMLBodyElement, ev: Event) => any; + onpagehide: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; + onpageshow: (this: HTMLBodyElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLBodyElement, ev: PopStateEvent) => any; + onresize: (this: HTMLBodyElement, ev: UIEvent) => any; + onscroll: (this: HTMLBodyElement, ev: UIEvent) => any; + onstorage: (this: HTMLBodyElement, ev: StorageEvent) => any; + onunload: (this: HTMLBodyElement, ev: Event) => any; + text: any; + vLink: any; + addEventListener(type: K, listener: (this: HTMLBodyElement, ev: HTMLBodyElementEventMap[K]) => 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly 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: K, listener: (this: HTMLButtonElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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", contextAttributes?: Canvas2DContextAttributes): CanvasRenderingContext2D | null; + getContext(contextId: "webgl" | "experimental-webgl", contextAttributes?: WebGLContextAttributes): WebGLRenderingContext | null; + getContext(contextId: string, contextAttributes?: {}): CanvasRenderingContext2D | WebGLRenderingContext | null; + /** + * 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(callback: (result: Blob | null) => void, type?: string, ...arguments: any[]): void; + addEventListener(type: K, listener: (this: HTMLCanvasElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLCanvasElement: { + prototype: HTMLCanvasElement; + new(): HTMLCanvasElement; +} + +interface HTMLCollectionBase { + /** + * Sets or retrieves the number of objects in a collection. + */ + readonly length: number; + /** + * Retrieves an object from various collections. + */ + item(index: number): Element; + [index: number]: Element; +} + +interface HTMLCollection extends HTMLCollectionBase { + /** + * Retrieves a select object or an object from an options collection. + */ + namedItem(name: string): Element | null; +} + +declare var HTMLCollection: { + prototype: HTMLCollection; + new(): HTMLCollection; +} + +interface HTMLDListElement extends HTMLElement { + compact: boolean; + addEventListener(type: K, listener: (this: HTMLDListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDListElement: { + prototype: HTMLDListElement; + new(): HTMLDListElement; +} + +interface HTMLDataElement extends HTMLElement { + value: string; + addEventListener(type: K, listener: (this: HTMLDataElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataElement: { + prototype: HTMLDataElement; + new(): HTMLDataElement; +} + +interface HTMLDataListElement extends HTMLElement { + options: HTMLCollectionOf; + addEventListener(type: K, listener: (this: HTMLDataListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDataListElement: { + prototype: HTMLDataListElement; + new(): HTMLDataListElement; +} + +interface HTMLDirectoryElement extends HTMLElement { + compact: boolean; + addEventListener(type: K, listener: (this: HTMLDirectoryElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLDivElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDivElement: { + prototype: HTMLDivElement; + new(): HTMLDivElement; +} + +interface HTMLDocument extends Document { + addEventListener(type: K, listener: (this: HTMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLDocument: { + prototype: HTMLDocument; + new(): HTMLDocument; +} + +interface HTMLElementEventMap extends ElementEventMap { + "abort": UIEvent; + "activate": UIEvent; + "beforeactivate": UIEvent; + "beforecopy": ClipboardEvent; + "beforecut": ClipboardEvent; + "beforedeactivate": UIEvent; + "beforepaste": ClipboardEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "contextmenu": PointerEvent; + "copy": ClipboardEvent; + "cuechange": Event; + "cut": ClipboardEvent; + "dblclick": MouseEvent; + "deactivate": UIEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "mousedown": MouseEvent; + "mouseenter": MouseEvent; + "mouseleave": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSContentZoom": UIEvent; + "MSManipulationStateChanged": MSManipulationEvent; + "paste": ClipboardEvent; + "pause": Event; + "play": Event; + "playing": Event; + "progress": ProgressEvent; + "ratechange": Event; + "reset": Event; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "selectstart": Event; + "stalled": Event; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "volumechange": Event; + "waiting": Event; +} + +interface HTMLElement extends Element { + accessKey: string; + readonly children: HTMLCollection; + contentEditable: string; + readonly dataset: DOMStringMap; + dir: string; + draggable: boolean; + hidden: boolean; + hideFocus: boolean; + innerText: string; + readonly isContentEditable: boolean; + lang: string; + readonly offsetHeight: number; + readonly offsetLeft: number; + readonly offsetParent: Element; + readonly offsetTop: number; + readonly offsetWidth: number; + onabort: (this: HTMLElement, ev: UIEvent) => any; + onactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforeactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforecopy: (this: HTMLElement, ev: ClipboardEvent) => any; + onbeforecut: (this: HTMLElement, ev: ClipboardEvent) => any; + onbeforedeactivate: (this: HTMLElement, ev: UIEvent) => any; + onbeforepaste: (this: HTMLElement, ev: ClipboardEvent) => any; + onblur: (this: HTMLElement, ev: FocusEvent) => any; + oncanplay: (this: HTMLElement, ev: Event) => any; + oncanplaythrough: (this: HTMLElement, ev: Event) => any; + onchange: (this: HTMLElement, ev: Event) => any; + onclick: (this: HTMLElement, ev: MouseEvent) => any; + oncontextmenu: (this: HTMLElement, ev: PointerEvent) => any; + oncopy: (this: HTMLElement, ev: ClipboardEvent) => any; + oncuechange: (this: HTMLElement, ev: Event) => any; + oncut: (this: HTMLElement, ev: ClipboardEvent) => any; + ondblclick: (this: HTMLElement, ev: MouseEvent) => any; + ondeactivate: (this: HTMLElement, ev: UIEvent) => any; + ondrag: (this: HTMLElement, ev: DragEvent) => any; + ondragend: (this: HTMLElement, ev: DragEvent) => any; + ondragenter: (this: HTMLElement, ev: DragEvent) => any; + ondragleave: (this: HTMLElement, ev: DragEvent) => any; + ondragover: (this: HTMLElement, ev: DragEvent) => any; + ondragstart: (this: HTMLElement, ev: DragEvent) => any; + ondrop: (this: HTMLElement, ev: DragEvent) => any; + ondurationchange: (this: HTMLElement, ev: Event) => any; + onemptied: (this: HTMLElement, ev: Event) => any; + onended: (this: HTMLElement, ev: MediaStreamErrorEvent) => any; + onerror: (this: HTMLElement, ev: ErrorEvent) => any; + onfocus: (this: HTMLElement, ev: FocusEvent) => any; + oninput: (this: HTMLElement, ev: Event) => any; + oninvalid: (this: HTMLElement, ev: Event) => any; + onkeydown: (this: HTMLElement, ev: KeyboardEvent) => any; + onkeypress: (this: HTMLElement, ev: KeyboardEvent) => any; + onkeyup: (this: HTMLElement, ev: KeyboardEvent) => any; + onload: (this: HTMLElement, ev: Event) => any; + onloadeddata: (this: HTMLElement, ev: Event) => any; + onloadedmetadata: (this: HTMLElement, ev: Event) => any; + onloadstart: (this: HTMLElement, ev: Event) => any; + onmousedown: (this: HTMLElement, ev: MouseEvent) => any; + onmouseenter: (this: HTMLElement, ev: MouseEvent) => any; + onmouseleave: (this: HTMLElement, ev: MouseEvent) => any; + onmousemove: (this: HTMLElement, ev: MouseEvent) => any; + onmouseout: (this: HTMLElement, ev: MouseEvent) => any; + onmouseover: (this: HTMLElement, ev: MouseEvent) => any; + onmouseup: (this: HTMLElement, ev: MouseEvent) => any; + onmousewheel: (this: HTMLElement, ev: WheelEvent) => any; + onmscontentzoom: (this: HTMLElement, ev: UIEvent) => any; + onmsmanipulationstatechanged: (this: HTMLElement, ev: MSManipulationEvent) => any; + onpaste: (this: HTMLElement, ev: ClipboardEvent) => any; + onpause: (this: HTMLElement, ev: Event) => any; + onplay: (this: HTMLElement, ev: Event) => any; + onplaying: (this: HTMLElement, ev: Event) => any; + onprogress: (this: HTMLElement, ev: ProgressEvent) => any; + onratechange: (this: HTMLElement, ev: Event) => any; + onreset: (this: HTMLElement, ev: Event) => any; + onscroll: (this: HTMLElement, ev: UIEvent) => any; + onseeked: (this: HTMLElement, ev: Event) => any; + onseeking: (this: HTMLElement, ev: Event) => any; + onselect: (this: HTMLElement, ev: UIEvent) => any; + onselectstart: (this: HTMLElement, ev: Event) => any; + onstalled: (this: HTMLElement, ev: Event) => any; + onsubmit: (this: HTMLElement, ev: Event) => any; + onsuspend: (this: HTMLElement, ev: Event) => any; + ontimeupdate: (this: HTMLElement, ev: Event) => any; + onvolumechange: (this: HTMLElement, ev: Event) => any; + onwaiting: (this: HTMLElement, ev: Event) => any; + outerText: string; + spellcheck: boolean; + readonly style: CSSStyleDeclaration; + tabIndex: number; + title: string; + blur(): void; + click(): void; + dragDrop(): boolean; + focus(): void; + msGetInputContext(): MSInputMethodContext; + addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * Retrieves the palette used for the embedded document. + */ + readonly palette: string; + /** + * Retrieves the URL of the plug-in used to view an embedded document. + */ + readonly pluginspage: string; + readonly 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: K, listener: (this: HTMLEmbedElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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. + */ + readonly form: HTMLFormElement; + name: 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly validity: ValidityState; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + readonly 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: K, listener: (this: HTMLFieldSetElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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: K, listener: (this: HTMLFontElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFontElement: { + prototype: HTMLFontElement; + new(): HTMLFontElement; +} + +interface HTMLFormControlsCollection extends HTMLCollectionBase { + namedItem(name: string): HTMLCollection | Element | null; +} + +declare var HTMLFormControlsCollection: { + prototype: HTMLFormControlsCollection; + new(): HTMLFormControlsCollection; +} + +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. + */ + readonly elements: HTMLFormControlsCollection; + /** + * 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. + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLFormElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [name: string]: any; +} + +declare var HTMLFormElement: { + prototype: HTMLFormElement; + new(): HTMLFormElement; +} + +interface HTMLFrameElementEventMap extends HTMLElementEventMap { + "load": Event; +} + +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. + */ + readonly contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + readonly 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: (this: HTMLFrameElement, ev: Event) => any; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * 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: K, listener: (this: HTMLFrameElement, ev: HTMLFrameElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLFrameElement: { + prototype: HTMLFrameElement; + new(): HTMLFrameElement; +} + +interface HTMLFrameSetElementEventMap extends HTMLElementEventMap { + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "error": ErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "load": Event; + "message": MessageEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "popstate": PopStateEvent; + "resize": UIEvent; + "scroll": UIEvent; + "storage": StorageEvent; + "unload": Event; +} + +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: (this: HTMLFrameSetElement, ev: Event) => any; + onbeforeprint: (this: HTMLFrameSetElement, ev: Event) => any; + onbeforeunload: (this: HTMLFrameSetElement, ev: BeforeUnloadEvent) => any; + /** + * Fires when the object loses the input focus. + */ + onblur: (this: HTMLFrameSetElement, ev: FocusEvent) => any; + onerror: (this: HTMLFrameSetElement, ev: ErrorEvent) => any; + /** + * Fires when the object receives focus. + */ + onfocus: (this: HTMLFrameSetElement, ev: FocusEvent) => any; + onhashchange: (this: HTMLFrameSetElement, ev: HashChangeEvent) => any; + onload: (this: HTMLFrameSetElement, ev: Event) => any; + onmessage: (this: HTMLFrameSetElement, ev: MessageEvent) => any; + onoffline: (this: HTMLFrameSetElement, ev: Event) => any; + ononline: (this: HTMLFrameSetElement, ev: Event) => any; + onorientationchange: (this: HTMLFrameSetElement, ev: Event) => any; + onpagehide: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpageshow: (this: HTMLFrameSetElement, ev: PageTransitionEvent) => any; + onpopstate: (this: HTMLFrameSetElement, ev: PopStateEvent) => any; + onresize: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onscroll: (this: HTMLFrameSetElement, ev: UIEvent) => any; + onstorage: (this: HTMLFrameSetElement, ev: StorageEvent) => any; + onunload: (this: HTMLFrameSetElement, ev: Event) => any; + /** + * Sets or retrieves the frame heights of the object. + */ + rows: string; + addEventListener(type: K, listener: (this: HTMLFrameSetElement, ev: HTMLFrameSetElementEventMap[K]) => 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: K, listener: (this: HTMLHRElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHRElement: { + prototype: HTMLHRElement; + new(): HTMLHRElement; +} + +interface HTMLHeadElement extends HTMLElement { + profile: string; + addEventListener(type: K, listener: (this: HTMLHeadElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHeadElement: { + prototype: HTMLHeadElement; + new(): HTMLHeadElement; +} + +interface HTMLHeadingElement extends HTMLElement { + /** + * Sets or retrieves a value that indicates the table alignment. + */ + align: string; + addEventListener(type: K, listener: (this: HTMLHeadingElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHeadingElement: { + prototype: HTMLHeadingElement; + new(): HTMLHeadingElement; +} + +interface HTMLHtmlElement extends HTMLElement { + /** + * Sets or retrieves the DTD version that governs the current document. + */ + version: string; + addEventListener(type: K, listener: (this: HTMLHtmlElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLHtmlElement: { + prototype: HTMLHtmlElement; + new(): HTMLHtmlElement; +} + +interface HTMLIFrameElementEventMap extends HTMLElementEventMap { + "load": Event; +} + +interface HTMLIFrameElement extends HTMLElement, GetSVGDocument { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + allowFullscreen: boolean; + allowPaymentRequest: boolean; + /** + * Specifies the properties of a border drawn around an object. + */ + border: string; + /** + * Retrieves the document object of the page or frame. + */ + readonly contentDocument: Document; + /** + * Retrieves the object of the specified. + */ + readonly 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: (this: HTMLIFrameElement, ev: Event) => any; + readonly sandbox: DOMSettableTokenList; + /** + * Sets or retrieves whether the frame can be scrolled. + */ + scrolling: string; + /** + * 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: K, listener: (this: HTMLIFrameElement, ev: HTMLIFrameElementEventMap[K]) => 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. + */ + readonly complete: boolean; + crossOrigin: string | null; + readonly 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; + lowsrc: 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + /** + * The original height of the image resource before sizing. + */ + readonly naturalHeight: number; + /** + * The original width of the image resource before sizing. + */ + readonly naturalWidth: number; + sizes: string; + /** + * 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; + readonly x: number; + readonly y: number; + msGetAsCastingSource(): any; + addEventListener(type: K, listener: (this: HTMLImageElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLImageElement: { + prototype: HTMLImageElement; + new(): 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. + */ + readonly 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. + */ + readonly files: FileList | null; + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly 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. + */ + readonly 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; + selectionDirection: string; + /** + * 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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; + webkitdirectory: boolean; + /** + * Sets or retrieves the width of the object. + */ + width: string; + /** + * Returns whether an element will successfully validate based on forms validation rules and constraints. + */ + readonly willValidate: boolean; + minLength: number; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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, direction?: string): 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; + addEventListener(type: K, listener: (this: HTMLInputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLInputElement: { + prototype: HTMLInputElement; + new(): HTMLInputElement; +} + +interface HTMLLIElement extends HTMLElement { + type: string; + /** + * Sets or retrieves the value of a list item. + */ + value: number; + addEventListener(type: K, listener: (this: HTMLLIElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLLIElement: { + prototype: HTMLLIElement; + new(): HTMLLIElement; +} + +interface HTMLLabelElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the object to which the given label object is assigned. + */ + htmlFor: string; + addEventListener(type: K, listener: (this: HTMLLabelElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly form: HTMLFormElement; + addEventListener(type: K, listener: (this: HTMLLegendElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + import?: Document; + integrity: string; + addEventListener(type: K, listener: (this: HTMLLinkElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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. + */ + readonly areas: HTMLAreasCollection; + /** + * Sets or retrieves the name of the object. + */ + name: string; + addEventListener(type: K, listener: (this: HTMLMapElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMapElement: { + prototype: HTMLMapElement; + new(): HTMLMapElement; +} + +interface HTMLMarqueeElementEventMap extends HTMLElementEventMap { + "bounce": Event; + "finish": Event; + "start": Event; +} + +interface HTMLMarqueeElement extends HTMLElement { + behavior: string; + bgColor: any; + direction: string; + height: string; + hspace: number; + loop: number; + onbounce: (this: HTMLMarqueeElement, ev: Event) => any; + onfinish: (this: HTMLMarqueeElement, ev: Event) => any; + onstart: (this: HTMLMarqueeElement, ev: Event) => any; + scrollAmount: number; + scrollDelay: number; + trueSpeed: boolean; + vspace: number; + width: string; + start(): void; + stop(): void; + addEventListener(type: K, listener: (this: HTMLMarqueeElement, ev: HTMLMarqueeElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMarqueeElement: { + prototype: HTMLMarqueeElement; + new(): HTMLMarqueeElement; +} + +interface HTMLMediaElementEventMap extends HTMLElementEventMap { + "encrypted": MediaEncryptedEvent; + "msneedkey": MSMediaKeyNeededEvent; +} + +interface HTMLMediaElement extends HTMLElement { + /** + * Returns an AudioTrackList object with the audio tracks for a given video element. + */ + readonly 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. + */ + readonly 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; + crossOrigin: string | null; + /** + * Gets the address or URL of the current media resource that is selected by IHTMLMediaElement. + */ + readonly 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. + */ + readonly duration: number; + /** + * Gets information about whether the playback has ended or not. + */ + readonly ended: boolean; + /** + * Returns an object representing the current error state of the audio or video element. + */ + readonly error: MediaError; + /** + * Gets or sets a flag to specify whether playback should restart after it completes. + */ + loop: boolean; + readonly mediaKeys: MediaKeys | null; + /** + * 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; + readonly msGraphicsTrustStatus: MSGraphicsTrust; + /** + * Gets the MSMediaKeys object, which is used for decrypting media data, that is associated with this media element. + */ + readonly 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. + */ + readonly 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. + */ + readonly networkState: number; + onencrypted: (this: HTMLMediaElement, ev: MediaEncryptedEvent) => any; + onmsneedkey: (this: HTMLMediaElement, ev: MSMediaKeyNeededEvent) => any; + /** + * Gets a flag that specifies whether playback is paused. + */ + readonly 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. + */ + readonly 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. + */ + readonly seekable: TimeRanges; + /** + * Gets a flag that indicates whether the the client is currently moving to a new playback position in the media resource. + */ + readonly seeking: boolean; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcObject: MediaStream | null; + readonly textTracks: TextTrackList; + readonly 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; + /** + * Resets the audio or video object and loads a new media resource. + */ + 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; + setMediaKeys(mediaKeys: MediaKeys | null): Promise; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; + addEventListener(type: K, listener: (this: HTMLMediaElement, ev: HTMLMediaElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMediaElement: { + prototype: HTMLMediaElement; + new(): HTMLMediaElement; + readonly HAVE_CURRENT_DATA: number; + readonly HAVE_ENOUGH_DATA: number; + readonly HAVE_FUTURE_DATA: number; + readonly HAVE_METADATA: number; + readonly HAVE_NOTHING: number; + readonly NETWORK_EMPTY: number; + readonly NETWORK_IDLE: number; + readonly NETWORK_LOADING: number; + readonly NETWORK_NO_SOURCE: number; +} + +interface HTMLMenuElement extends HTMLElement { + compact: boolean; + type: string; + addEventListener(type: K, listener: (this: HTMLMenuElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLMetaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMetaElement: { + prototype: HTMLMetaElement; + new(): HTMLMetaElement; +} + +interface HTMLMeterElement extends HTMLElement { + high: number; + low: number; + max: number; + min: number; + optimum: number; + value: number; + addEventListener(type: K, listener: (this: HTMLMeterElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLMeterElement: { + prototype: HTMLMeterElement; + new(): HTMLMeterElement; +} + +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; + addEventListener(type: K, listener: (this: HTMLModElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLModElement: { + prototype: HTMLModElement; + new(): HTMLModElement; +} + +interface HTMLOListElement extends HTMLElement { + compact: boolean; + /** + * The starting number. + */ + start: number; + type: string; + addEventListener(type: K, listener: (this: HTMLOListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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. + */ + readonly 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. + */ + readonly 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. + */ + readonly msPlayToSource: any; + /** + * Sets or retrieves the name of the object. + */ + name: string; + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly 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: K, listener: (this: HTMLObjectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): 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. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + readonly 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. + */ + readonly text: string; + /** + * Sets or retrieves the value which is returned to the server when the form control is submitted. + */ + value: string; + addEventListener(type: K, listener: (this: HTMLOptGroupElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly form: HTMLFormElement; + /** + * Sets or retrieves the ordinal position of an option in a list box. + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLOptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOptionElement: { + prototype: HTMLOptionElement; + new(): HTMLOptionElement; +} + +interface HTMLOptionsCollection extends HTMLCollectionOf { + length: number; + selectedIndex: number; + add(element: HTMLOptionElement | HTMLOptGroupElement, before?: HTMLElement | number): void; + remove(index: number): void; +} + +declare var HTMLOptionsCollection: { + prototype: HTMLOptionsCollection; + new(): HTMLOptionsCollection; +} + +interface HTMLOutputElement extends HTMLElement { + defaultValue: string; + readonly form: HTMLFormElement; + readonly htmlFor: DOMSettableTokenList; + name: string; + readonly type: string; + readonly validationMessage: string; + readonly validity: ValidityState; + value: string; + readonly willValidate: boolean; + checkValidity(): boolean; + reportValidity(): boolean; + setCustomValidity(error: string): void; + addEventListener(type: K, listener: (this: HTMLOutputElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLOutputElement: { + prototype: HTMLOutputElement; + new(): HTMLOutputElement; +} + +interface HTMLParagraphElement extends HTMLElement { + /** + * Sets or retrieves how the object is aligned with adjacent text. + */ + align: string; + clear: string; + addEventListener(type: K, listener: (this: HTMLParagraphElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLParamElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLParamElement: { + prototype: HTMLParamElement; + new(): HTMLParamElement; +} + +interface HTMLPictureElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLPictureElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLPictureElement: { + prototype: HTMLPictureElement; + new(): HTMLPictureElement; +} + +interface HTMLPreElement extends HTMLElement { + /** + * Sets or gets a value that you can use to implement your own width functionality for the object. + */ + width: number; + addEventListener(type: K, listener: (this: HTMLPreElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLPreElement: { + prototype: HTMLPreElement; + new(): HTMLPreElement; +} + +interface HTMLProgressElement extends HTMLElement { + /** + * Retrieves a reference to the form that the object is embedded in. + */ + readonly 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). + */ + readonly 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; + addEventListener(type: K, listener: (this: HTMLProgressElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLProgressElement: { + prototype: HTMLProgressElement; + new(): HTMLProgressElement; +} + +interface HTMLQuoteElement extends HTMLElement { + /** + * Sets or retrieves reference information about the object. + */ + cite: string; + addEventListener(type: K, listener: (this: HTMLQuoteElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + crossOrigin: string | null; + /** + * 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; + integrity: string; + addEventListener(type: K, listener: (this: HTMLScriptElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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; + readonly options: HTMLOptionsCollection; + /** + * 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; + selectedOptions: HTMLCollectionOf; + /** + * 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly willValidate: boolean; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLSelectElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): 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; + sizes: string; + /** + * The address or URL of the a media resource that is to be considered. + */ + src: string; + srcset: string; + /** + * Gets or sets the MIME type of a media resource. + */ + type: string; + addEventListener(type: K, listener: (this: HTMLSourceElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLSourceElement: { + prototype: HTMLSourceElement; + new(): HTMLSourceElement; +} + +interface HTMLSpanElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLSpanElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLSpanElement: { + prototype: HTMLSpanElement; + new(): HTMLSpanElement; +} + +interface HTMLStyleElement extends HTMLElement, LinkStyle { + disabled: boolean; + /** + * Sets or retrieves the media type. + */ + media: string; + /** + * Retrieves the CSS language in which the style sheet is written. + */ + type: string; + addEventListener(type: K, listener: (this: HTMLStyleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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; + addEventListener(type: K, listener: (this: HTMLTableCaptionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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. + */ + readonly 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: K, listener: (this: HTMLTableCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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: K, listener: (this: HTMLTableColElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableColElement: { + prototype: HTMLTableColElement; + new(): HTMLTableColElement; +} + +interface HTMLTableDataCellElement extends HTMLTableCellElement { + addEventListener(type: K, listener: (this: HTMLTableDataCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: HTMLCollectionOf; + /** + * 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: HTMLCollectionOf; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLTableElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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; + addEventListener(type: K, listener: (this: HTMLTableHeaderCellElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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: HTMLCollectionOf; + /** + * Sets or retrieves the height of the object. + */ + height: any; + /** + * Retrieves the position of the object in the rows collection for the table. + */ + readonly rowIndex: number; + /** + * Retrieves the position of the object in the collection. + */ + readonly 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): HTMLTableDataCellElement; + addEventListener(type: K, listener: (this: HTMLTableRowElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + 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: HTMLCollectionOf; + /** + * 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: K, listener: (this: HTMLTableSectionElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTableSectionElement: { + prototype: HTMLTableSectionElement; + new(): HTMLTableSectionElement; +} + +interface HTMLTemplateElement extends HTMLElement { + readonly content: DocumentFragment; + addEventListener(type: K, listener: (this: HTMLTemplateElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTemplateElement: { + prototype: HTMLTemplateElement; + new(): HTMLTemplateElement; +} + +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. + */ + readonly 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. + */ + readonly 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. + */ + readonly validationMessage: string; + /** + * Returns a ValidityState object that represents the validity states of an element. + */ + readonly 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. + */ + readonly willValidate: boolean; + /** + * Sets or retrieves how to handle wordwrapping in the object. + */ + wrap: string; + minLength: number; + /** + * Returns whether a form will validate when it is submitted, without having to submit it. + */ + checkValidity(): boolean; + /** + * 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; + addEventListener(type: K, listener: (this: HTMLTextAreaElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTextAreaElement: { + prototype: HTMLTextAreaElement; + new(): HTMLTextAreaElement; +} + +interface HTMLTimeElement extends HTMLElement { + dateTime: string; + addEventListener(type: K, listener: (this: HTMLTimeElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTimeElement: { + prototype: HTMLTimeElement; + new(): HTMLTimeElement; +} + +interface HTMLTitleElement extends HTMLElement { + /** + * Retrieves or sets the text of the object as a string. + */ + text: string; + addEventListener(type: K, listener: (this: HTMLTitleElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTitleElement: { + prototype: HTMLTitleElement; + new(): HTMLTitleElement; +} + +interface HTMLTrackElement extends HTMLElement { + default: boolean; + kind: string; + label: string; + readonly readyState: number; + src: string; + srclang: string; + readonly track: TextTrack; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + addEventListener(type: K, listener: (this: HTMLTrackElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLTrackElement: { + prototype: HTMLTrackElement; + new(): HTMLTrackElement; + readonly ERROR: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; +} + +interface HTMLUListElement extends HTMLElement { + compact: boolean; + type: string; + addEventListener(type: K, listener: (this: HTMLUListElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLUListElement: { + prototype: HTMLUListElement; + new(): HTMLUListElement; +} + +interface HTMLUnknownElement extends HTMLElement { + addEventListener(type: K, listener: (this: HTMLUnknownElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLUnknownElement: { + prototype: HTMLUnknownElement; + new(): HTMLUnknownElement; +} + +interface HTMLVideoElementEventMap extends HTMLMediaElementEventMap { + "MSVideoFormatChanged": Event; + "MSVideoFrameStepCompleted": Event; + "MSVideoOptimalLayoutChanged": Event; +} + +interface HTMLVideoElement extends HTMLMediaElement { + /** + * Gets or sets the height of the video element. + */ + height: number; + msHorizontalMirror: boolean; + readonly msIsLayoutOptimalForPlayback: boolean; + readonly msIsStereo3D: boolean; + msStereo3DPackingMode: string; + msStereo3DRenderMode: string; + msZoom: boolean; + onMSVideoFormatChanged: (this: HTMLVideoElement, ev: Event) => any; + onMSVideoFrameStepCompleted: (this: HTMLVideoElement, ev: Event) => any; + onMSVideoOptimalLayoutChanged: (this: HTMLVideoElement, 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. + */ + readonly videoHeight: number; + /** + * Gets the intrinsic width of a video in CSS pixels, or zero if the dimensions are not known. + */ + readonly videoWidth: number; + readonly webkitDisplayingFullscreen: boolean; + readonly 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: K, listener: (this: HTMLVideoElement, ev: HTMLVideoElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var HTMLVideoElement: { + prototype: HTMLVideoElement; + new(): HTMLVideoElement; +} + +interface HashChangeEvent extends Event { + readonly newURL: string | null; + readonly oldURL: string | null; +} + +declare var HashChangeEvent: { + prototype: HashChangeEvent; + new(typeArg: string, eventInitDict?: HashChangeEventInit): HashChangeEvent; +} + +interface Headers { + append(name: string, value: string): void; + delete(name: string): void; + forEach(callback: ForEachCallback): void; + get(name: string): string | null; + has(name: string): boolean; + set(name: string, value: string): void; +} + +declare var Headers: { + prototype: Headers; + new(init?: any): Headers; +} + +interface History { + readonly length: number; + readonly state: any; + scrollRestoration: ScrollRestoration; + back(): void; + forward(): void; + go(delta?: number): void; + pushState(data: any, title: string, url?: string | null): void; + replaceState(data: any, title: string, url?: string | null): void; +} + +declare var History: { + prototype: History; + new(): History; +} + +interface IDBCursor { + readonly direction: IDBCursorDirection; + key: IDBKeyRange | IDBValidKey; + readonly primaryKey: any; + source: IDBObjectStore | IDBIndex; + advance(count: number): void; + continue(key?: IDBKeyRange | IDBValidKey): void; + delete(): IDBRequest; + update(value: any): IDBRequest; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; +} + +declare var IDBCursor: { + prototype: IDBCursor; + new(): IDBCursor; + readonly NEXT: string; + readonly NEXT_NO_DUPLICATE: string; + readonly PREV: string; + readonly PREV_NO_DUPLICATE: string; +} + +interface IDBCursorWithValue extends IDBCursor { + readonly value: any; +} + +declare var IDBCursorWithValue: { + prototype: IDBCursorWithValue; + new(): IDBCursorWithValue; +} + +interface IDBDatabaseEventMap { + "abort": Event; + "error": Event; +} + +interface IDBDatabase extends EventTarget { + readonly name: string; + readonly objectStoreNames: DOMStringList; + onabort: (this: IDBDatabase, ev: Event) => any; + onerror: (this: IDBDatabase, ev: Event) => any; + version: number; + onversionchange: (ev: IDBVersionChangeEvent) => any; + close(): void; + createObjectStore(name: string, optionalParameters?: IDBObjectStoreParameters): IDBObjectStore; + deleteObjectStore(name: string): void; + transaction(storeNames: string | string[], mode?: string): IDBTransaction; + addEventListener(type: "versionchange", listener: (ev: IDBVersionChangeEvent) => any, useCapture?: boolean): void; + addEventListener(type: K, listener: (this: IDBDatabase, ev: IDBDatabaseEventMap[K]) => 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[]; + readonly name: string; + readonly objectStore: IDBObjectStore; + readonly unique: boolean; + multiEntry: boolean; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + get(key: IDBKeyRange | IDBValidKey): IDBRequest; + getKey(key: IDBKeyRange | IDBValidKey): IDBRequest; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + openKeyCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; +} + +declare var IDBIndex: { + prototype: IDBIndex; + new(): IDBIndex; +} + +interface IDBKeyRange { + readonly lower: any; + readonly lowerOpen: boolean; + readonly upper: any; + readonly upperOpen: boolean; +} + +declare var IDBKeyRange: { + prototype: IDBKeyRange; + new(): IDBKeyRange; + bound(lower: any, upper: any, lowerOpen?: boolean, upperOpen?: boolean): IDBKeyRange; + lowerBound(lower: any, open?: boolean): IDBKeyRange; + only(value: any): IDBKeyRange; + upperBound(upper: any, open?: boolean): IDBKeyRange; +} + +interface IDBObjectStore { + readonly indexNames: DOMStringList; + keyPath: string | string[]; + readonly name: string; + readonly transaction: IDBTransaction; + autoIncrement: boolean; + add(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; + clear(): IDBRequest; + count(key?: IDBKeyRange | IDBValidKey): IDBRequest; + createIndex(name: string, keyPath: string | string[], optionalParameters?: IDBIndexParameters): IDBIndex; + delete(key: IDBKeyRange | IDBValidKey): IDBRequest; + deleteIndex(indexName: string): void; + get(key: any): IDBRequest; + index(name: string): IDBIndex; + openCursor(range?: IDBKeyRange | IDBValidKey, direction?: string): IDBRequest; + put(value: any, key?: IDBKeyRange | IDBValidKey): IDBRequest; +} + +declare var IDBObjectStore: { + prototype: IDBObjectStore; + new(): IDBObjectStore; +} + +interface IDBOpenDBRequestEventMap extends IDBRequestEventMap { + "blocked": Event; + "upgradeneeded": IDBVersionChangeEvent; +} + +interface IDBOpenDBRequest extends IDBRequest { + onblocked: (this: IDBOpenDBRequest, ev: Event) => any; + onupgradeneeded: (this: IDBOpenDBRequest, ev: IDBVersionChangeEvent) => any; + addEventListener(type: K, listener: (this: IDBOpenDBRequest, ev: IDBOpenDBRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBOpenDBRequest: { + prototype: IDBOpenDBRequest; + new(): IDBOpenDBRequest; +} + +interface IDBRequestEventMap { + "error": Event; + "success": Event; +} + +interface IDBRequest extends EventTarget { + readonly error: DOMError; + onerror: (this: IDBRequest, ev: Event) => any; + onsuccess: (this: IDBRequest, ev: Event) => any; + readonly readyState: IDBRequestReadyState; + readonly result: any; + source: IDBObjectStore | IDBIndex | IDBCursor; + readonly transaction: IDBTransaction; + addEventListener(type: K, listener: (this: IDBRequest, ev: IDBRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBRequest: { + prototype: IDBRequest; + new(): IDBRequest; +} + +interface IDBTransactionEventMap { + "abort": Event; + "complete": Event; + "error": Event; +} + +interface IDBTransaction extends EventTarget { + readonly db: IDBDatabase; + readonly error: DOMError; + readonly mode: IDBTransactionMode; + onabort: (this: IDBTransaction, ev: Event) => any; + oncomplete: (this: IDBTransaction, ev: Event) => any; + onerror: (this: IDBTransaction, ev: Event) => any; + abort(): void; + objectStore(name: string): IDBObjectStore; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; + addEventListener(type: K, listener: (this: IDBTransaction, ev: IDBTransactionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var IDBTransaction: { + prototype: IDBTransaction; + new(): IDBTransaction; + readonly READ_ONLY: string; + readonly READ_WRITE: string; + readonly VERSION_CHANGE: string; +} + +interface IDBVersionChangeEvent extends Event { + readonly newVersion: number | null; + readonly oldVersion: number; +} + +declare var IDBVersionChangeEvent: { + prototype: IDBVersionChangeEvent; + new(): IDBVersionChangeEvent; +} + +interface IIRFilterNode extends AudioNode { + getFrequencyResponse(frequencyHz: Float32Array, magResponse: Float32Array, phaseResponse: Float32Array): void; +} + +declare var IIRFilterNode: { + prototype: IIRFilterNode; + new(): IIRFilterNode; +} + +interface ImageData { + data: Uint8ClampedArray; + readonly height: number; + readonly width: number; +} + +declare var ImageData: { + prototype: ImageData; + new(width: number, height: number): ImageData; + new(array: Uint8ClampedArray, width: number, height: number): ImageData; +} + +interface IntersectionObserver { + readonly root: Element | null; + readonly rootMargin: string; + readonly thresholds: number[]; + disconnect(): void; + observe(target: Element): void; + takeRecords(): IntersectionObserverEntry[]; + unobserve(target: Element): void; +} + +declare var IntersectionObserver: { + prototype: IntersectionObserver; + new(callback: IntersectionObserverCallback, options?: IntersectionObserverInit): IntersectionObserver; +} + +interface IntersectionObserverEntry { + readonly boundingClientRect: ClientRect; + readonly intersectionRatio: number; + readonly intersectionRect: ClientRect; + readonly rootBounds: ClientRect; + readonly target: Element; + readonly time: number; +} + +declare var IntersectionObserverEntry: { + prototype: IntersectionObserverEntry; + new(intersectionObserverEntryInit: IntersectionObserverEntryInit): IntersectionObserverEntry; +} + +interface KeyboardEvent extends UIEvent { + readonly altKey: boolean; + readonly char: string | null; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly key: string; + readonly keyCode: number; + readonly locale: string; + readonly location: number; + readonly metaKey: boolean; + readonly repeat: boolean; + readonly shiftKey: boolean; + readonly which: number; + readonly code: string; + getModifierState(keyArg: string): boolean; + initKeyboardEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, keyArg: string, locationArg: number, modifiersListArg: string, repeat: boolean, locale: string): void; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; +} + +declare var KeyboardEvent: { + prototype: KeyboardEvent; + new(typeArg: string, eventInitDict?: KeyboardEventInit): KeyboardEvent; + readonly DOM_KEY_LOCATION_JOYSTICK: number; + readonly DOM_KEY_LOCATION_LEFT: number; + readonly DOM_KEY_LOCATION_MOBILE: number; + readonly DOM_KEY_LOCATION_NUMPAD: number; + readonly DOM_KEY_LOCATION_RIGHT: number; + readonly DOM_KEY_LOCATION_STANDARD: number; +} + +interface ListeningStateChangedEvent extends Event { + readonly label: string; + readonly state: ListeningState; +} + +declare var ListeningStateChangedEvent: { + prototype: ListeningStateChangedEvent; + new(): ListeningStateChangedEvent; +} + +interface Location { + hash: string; + host: string; + hostname: string; + href: string; + readonly 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 { + readonly 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): Promise; + getViewId(view: any): any; + isTaskScheduledAtPriorityOrHigher(priority: string): boolean; + pageHandlesAllApplicationActivations(enabled: boolean): void; + suppressSubdownloadCredentialPrompts(suppress: boolean): void; + terminateApp(exceptionObject: any): void; + readonly CURRENT: string; + readonly HIGH: string; + readonly IDLE: string; + readonly NORMAL: string; +} +declare var MSApp: MSApp; + +interface MSAppAsyncOperationEventMap { + "complete": Event; + "error": Event; +} + +interface MSAppAsyncOperation extends EventTarget { + readonly error: DOMError; + oncomplete: (this: MSAppAsyncOperation, ev: Event) => any; + onerror: (this: MSAppAsyncOperation, ev: Event) => any; + readonly readyState: number; + readonly result: any; + start(): void; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + addEventListener(type: K, listener: (this: MSAppAsyncOperation, ev: MSAppAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSAppAsyncOperation: { + prototype: MSAppAsyncOperation; + new(): MSAppAsyncOperation; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; +} + +interface MSAssertion { + readonly id: string; + readonly type: MSCredentialType; +} + +declare var MSAssertion: { + prototype: MSAssertion; + new(): MSAssertion; +} + +interface MSBlobBuilder { + append(data: any, endings?: string): void; + getBlob(contentType?: string): Blob; +} + +declare var MSBlobBuilder: { + prototype: MSBlobBuilder; + new(): MSBlobBuilder; +} + +interface MSCredentials { + getAssertion(challenge: string, filter?: MSCredentialFilter, params?: MSSignatureParameters): Promise; + makeCredential(accountInfo: MSAccountInfo, params: MSCredentialParameters[], challenge?: string): Promise; +} + +declare var MSCredentials: { + prototype: MSCredentials; + new(): MSCredentials; +} + +interface MSFIDOCredentialAssertion extends MSAssertion { + readonly algorithm: string | Algorithm; + readonly attestation: any; + readonly publicKey: string; + readonly transportHints: MSTransportType[]; +} + +declare var MSFIDOCredentialAssertion: { + prototype: MSFIDOCredentialAssertion; + new(): MSFIDOCredentialAssertion; +} + +interface MSFIDOSignature { + readonly authnrData: string; + readonly clientData: string; + readonly signature: string; +} + +declare var MSFIDOSignature: { + prototype: MSFIDOSignature; + new(): MSFIDOSignature; +} + +interface MSFIDOSignatureAssertion extends MSAssertion { + readonly signature: MSFIDOSignature; +} + +declare var MSFIDOSignatureAssertion: { + prototype: MSFIDOSignatureAssertion; + new(): MSFIDOSignatureAssertion; +} + +interface MSGesture { + target: Element; + addPointer(pointerId: number): void; + stop(): void; +} + +declare var MSGesture: { + prototype: MSGesture; + new(): MSGesture; +} + +interface MSGestureEvent extends UIEvent { + readonly clientX: number; + readonly clientY: number; + readonly expansion: number; + readonly gestureObject: any; + readonly hwTimestamp: number; + readonly offsetX: number; + readonly offsetY: number; + readonly rotation: number; + readonly scale: number; + readonly screenX: number; + readonly screenY: number; + readonly translationX: number; + readonly translationY: number; + readonly velocityAngular: number; + readonly velocityExpansion: number; + readonly velocityX: number; + readonly 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; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; +} + +declare var MSGestureEvent: { + prototype: MSGestureEvent; + new(): MSGestureEvent; + readonly MSGESTURE_FLAG_BEGIN: number; + readonly MSGESTURE_FLAG_CANCEL: number; + readonly MSGESTURE_FLAG_END: number; + readonly MSGESTURE_FLAG_INERTIA: number; + readonly MSGESTURE_FLAG_NONE: number; +} + +interface MSGraphicsTrust { + readonly constrictionActive: boolean; + readonly status: string; +} + +declare var MSGraphicsTrust: { + prototype: MSGraphicsTrust; + new(): MSGraphicsTrust; +} + +interface MSHTMLWebViewElement extends HTMLElement { + readonly canGoBack: boolean; + readonly canGoForward: boolean; + readonly containsFullScreenElement: boolean; + readonly documentTitle: string; + height: number; + readonly 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; + navigateFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; + navigateToLocalStreamUri(source: string, streamResolver: any): void; + navigateToString(contents: string): void; + navigateWithHttpRequestMessage(requestMessage: any): void; + refresh(): void; + stop(): void; + addEventListener(type: K, listener: (this: MSHTMLWebViewElement, ev: HTMLElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSHTMLWebViewElement: { + prototype: MSHTMLWebViewElement; + new(): MSHTMLWebViewElement; +} + +interface MSInputMethodContextEventMap { + "MSCandidateWindowHide": Event; + "MSCandidateWindowShow": Event; + "MSCandidateWindowUpdate": Event; +} + +interface MSInputMethodContext extends EventTarget { + readonly compositionEndOffset: number; + readonly compositionStartOffset: number; + oncandidatewindowhide: (this: MSInputMethodContext, ev: Event) => any; + oncandidatewindowshow: (this: MSInputMethodContext, ev: Event) => any; + oncandidatewindowupdate: (this: MSInputMethodContext, ev: Event) => any; + readonly target: HTMLElement; + getCandidateWindowClientRect(): ClientRect; + getCompositionAlternatives(): string[]; + hasComposition(): boolean; + isCandidateWindowVisible(): boolean; + addEventListener(type: K, listener: (this: MSInputMethodContext, ev: MSInputMethodContextEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSInputMethodContext: { + prototype: MSInputMethodContext; + new(): MSInputMethodContext; +} + +interface MSManipulationEvent extends UIEvent { + readonly currentState: number; + readonly inertiaDestinationX: number; + readonly inertiaDestinationY: number; + readonly lastState: number; + initMSManipulationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number, lastState: number, currentState: number): void; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; +} + +declare var MSManipulationEvent: { + prototype: MSManipulationEvent; + new(): MSManipulationEvent; + readonly MS_MANIPULATION_STATE_ACTIVE: number; + readonly MS_MANIPULATION_STATE_CANCELLED: number; + readonly MS_MANIPULATION_STATE_COMMITTED: number; + readonly MS_MANIPULATION_STATE_DRAGGING: number; + readonly MS_MANIPULATION_STATE_INERTIA: number; + readonly MS_MANIPULATION_STATE_PRESELECT: number; + readonly MS_MANIPULATION_STATE_SELECTING: number; + readonly MS_MANIPULATION_STATE_STOPPED: number; +} + +interface MSMediaKeyError { + readonly code: number; + readonly systemCode: number; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; +} + +declare var MSMediaKeyError: { + prototype: MSMediaKeyError; + new(): MSMediaKeyError; + readonly MS_MEDIA_KEYERR_CLIENT: number; + readonly MS_MEDIA_KEYERR_DOMAIN: number; + readonly MS_MEDIA_KEYERR_HARDWARECHANGE: number; + readonly MS_MEDIA_KEYERR_OUTPUT: number; + readonly MS_MEDIA_KEYERR_SERVICE: number; + readonly MS_MEDIA_KEYERR_UNKNOWN: number; +} + +interface MSMediaKeyMessageEvent extends Event { + readonly destinationURL: string | null; + readonly message: Uint8Array; +} + +declare var MSMediaKeyMessageEvent: { + prototype: MSMediaKeyMessageEvent; + new(): MSMediaKeyMessageEvent; +} + +interface MSMediaKeyNeededEvent extends Event { + readonly initData: Uint8Array | null; +} + +declare var MSMediaKeyNeededEvent: { + prototype: MSMediaKeyNeededEvent; + new(): MSMediaKeyNeededEvent; +} + +interface MSMediaKeySession extends EventTarget { + readonly error: MSMediaKeyError | null; + readonly keySystem: string; + readonly sessionId: string; + close(): void; + update(key: Uint8Array): void; +} + +declare var MSMediaKeySession: { + prototype: MSMediaKeySession; + new(): MSMediaKeySession; +} + +interface MSMediaKeys { + readonly 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; + isTypeSupportedWithFeatures(keySystem: string, type?: string): string; +} + +interface MSPointerEvent extends MouseEvent { + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly 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 { + readonly length: number; + item(index: number): Range; + [index: number]: Range; +} + +declare var MSRangeCollection: { + prototype: MSRangeCollection; + new(): MSRangeCollection; +} + +interface MSSiteModeEvent extends Event { + readonly actionURL: string; + readonly buttonID: number; +} + +declare var MSSiteModeEvent: { + prototype: MSSiteModeEvent; + new(): MSSiteModeEvent; +} + +interface MSStream { + readonly type: string; + msClose(): void; + msDetachStream(): any; +} + +declare var MSStream: { + prototype: MSStream; + new(): MSStream; +} + +interface MSStreamReader extends EventTarget, MSBaseReader { + readonly 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: K, listener: (this: MSStreamReader, ev: MSBaseReaderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSStreamReader: { + prototype: MSStreamReader; + new(): MSStreamReader; +} + +interface MSWebViewAsyncOperationEventMap { + "complete": Event; + "error": Event; +} + +interface MSWebViewAsyncOperation extends EventTarget { + readonly error: DOMError; + oncomplete: (this: MSWebViewAsyncOperation, ev: Event) => any; + onerror: (this: MSWebViewAsyncOperation, ev: Event) => any; + readonly readyState: number; + readonly result: any; + readonly target: MSHTMLWebViewElement; + readonly type: number; + start(): void; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; + addEventListener(type: K, listener: (this: MSWebViewAsyncOperation, ev: MSWebViewAsyncOperationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MSWebViewAsyncOperation: { + prototype: MSWebViewAsyncOperation; + new(): MSWebViewAsyncOperation; + readonly COMPLETED: number; + readonly ERROR: number; + readonly STARTED: number; + readonly TYPE_CAPTURE_PREVIEW_TO_RANDOM_ACCESS_STREAM: number; + readonly TYPE_CREATE_DATA_PACKAGE_FROM_SELECTION: number; + readonly TYPE_INVOKE_SCRIPT: number; +} + +interface MSWebViewSettings { + isIndexedDBEnabled: boolean; + isJavaScriptEnabled: boolean; +} + +declare var MSWebViewSettings: { + prototype: MSWebViewSettings; + new(): MSWebViewSettings; +} + +interface MediaDeviceInfo { + readonly deviceId: string; + readonly groupId: string; + readonly kind: MediaDeviceKind; + readonly label: string; +} + +declare var MediaDeviceInfo: { + prototype: MediaDeviceInfo; + new(): MediaDeviceInfo; +} + +interface MediaDevicesEventMap { + "devicechange": Event; +} + +interface MediaDevices extends EventTarget { + ondevicechange: (this: MediaDevices, ev: Event) => any; + enumerateDevices(): any; + getSupportedConstraints(): MediaTrackSupportedConstraints; + getUserMedia(constraints: MediaStreamConstraints): Promise; + addEventListener(type: K, listener: (this: MediaDevices, ev: MediaDevicesEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaDevices: { + prototype: MediaDevices; + new(): MediaDevices; +} + +interface MediaElementAudioSourceNode extends AudioNode { +} + +declare var MediaElementAudioSourceNode: { + prototype: MediaElementAudioSourceNode; + new(): MediaElementAudioSourceNode; +} + +interface MediaEncryptedEvent extends Event { + readonly initData: ArrayBuffer | null; + readonly initDataType: string; +} + +declare var MediaEncryptedEvent: { + prototype: MediaEncryptedEvent; + new(type: string, eventInitDict?: MediaEncryptedEventInit): MediaEncryptedEvent; +} + +interface MediaError { + readonly code: number; + readonly msExtendedCode: number; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; +} + +declare var MediaError: { + prototype: MediaError; + new(): MediaError; + readonly MEDIA_ERR_ABORTED: number; + readonly MEDIA_ERR_DECODE: number; + readonly MEDIA_ERR_NETWORK: number; + readonly MEDIA_ERR_SRC_NOT_SUPPORTED: number; + readonly MS_MEDIA_ERR_ENCRYPTED: number; +} + +interface MediaKeyMessageEvent extends Event { + readonly message: ArrayBuffer; + readonly messageType: MediaKeyMessageType; +} + +declare var MediaKeyMessageEvent: { + prototype: MediaKeyMessageEvent; + new(type: string, eventInitDict?: MediaKeyMessageEventInit): MediaKeyMessageEvent; +} + +interface MediaKeySession extends EventTarget { + readonly closed: Promise; + readonly expiration: number; + readonly keyStatuses: MediaKeyStatusMap; + readonly sessionId: string; + close(): Promise; + generateRequest(initDataType: string, initData: any): Promise; + load(sessionId: string): Promise; + remove(): Promise; + update(response: any): Promise; +} + +declare var MediaKeySession: { + prototype: MediaKeySession; + new(): MediaKeySession; +} + +interface MediaKeyStatusMap { + readonly size: number; + forEach(callback: ForEachCallback): void; + get(keyId: any): MediaKeyStatus; + has(keyId: any): boolean; +} + +declare var MediaKeyStatusMap: { + prototype: MediaKeyStatusMap; + new(): MediaKeyStatusMap; +} + +interface MediaKeySystemAccess { + readonly keySystem: string; + createMediaKeys(): Promise; + getConfiguration(): MediaKeySystemConfiguration; +} + +declare var MediaKeySystemAccess: { + prototype: MediaKeySystemAccess; + new(): MediaKeySystemAccess; +} + +interface MediaKeys { + createSession(sessionType?: MediaKeySessionType): MediaKeySession; + setServerCertificate(serverCertificate: any): Promise; +} + +declare var MediaKeys: { + prototype: MediaKeys; + new(): MediaKeys; +} + +interface MediaList { + readonly 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 { + readonly matches: boolean; + readonly media: string; + addListener(listener: MediaQueryListListener): void; + removeListener(listener: MediaQueryListListener): void; +} + +declare var MediaQueryList: { + prototype: MediaQueryList; + new(): MediaQueryList; +} + +interface MediaSource extends EventTarget { + readonly activeSourceBuffers: SourceBufferList; + duration: number; + readonly readyState: string; + readonly 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 MediaStreamEventMap { + "active": Event; + "addtrack": MediaStreamTrackEvent; + "inactive": Event; + "removetrack": MediaStreamTrackEvent; +} + +interface MediaStream extends EventTarget { + readonly active: boolean; + readonly id: string; + onactive: (this: MediaStream, ev: Event) => any; + onaddtrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; + oninactive: (this: MediaStream, ev: Event) => any; + onremovetrack: (this: MediaStream, ev: MediaStreamTrackEvent) => any; + addTrack(track: MediaStreamTrack): void; + clone(): MediaStream; + getAudioTracks(): MediaStreamTrack[]; + getTrackById(trackId: string): MediaStreamTrack | null; + getTracks(): MediaStreamTrack[]; + getVideoTracks(): MediaStreamTrack[]; + removeTrack(track: MediaStreamTrack): void; + stop(): void; + addEventListener(type: K, listener: (this: MediaStream, ev: MediaStreamEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStream: { + prototype: MediaStream; + new(streamOrTracks?: MediaStream | MediaStreamTrack[]): MediaStream; +} + +interface MediaStreamAudioSourceNode extends AudioNode { +} + +declare var MediaStreamAudioSourceNode: { + prototype: MediaStreamAudioSourceNode; + new(): MediaStreamAudioSourceNode; +} + +interface MediaStreamError { + readonly constraintName: string | null; + readonly message: string | null; + readonly name: string; +} + +declare var MediaStreamError: { + prototype: MediaStreamError; + new(): MediaStreamError; +} + +interface MediaStreamErrorEvent extends Event { + readonly error: MediaStreamError | null; +} + +declare var MediaStreamErrorEvent: { + prototype: MediaStreamErrorEvent; + new(typeArg: string, eventInitDict?: MediaStreamErrorEventInit): MediaStreamErrorEvent; +} + +interface MediaStreamEvent extends Event { + readonly stream: MediaStream | null; +} + +declare var MediaStreamEvent: { + prototype: MediaStreamEvent; + new(type: string, eventInitDict: MediaStreamEventInit): MediaStreamEvent; +} + +interface MediaStreamTrackEventMap { + "ended": MediaStreamErrorEvent; + "mute": Event; + "overconstrained": MediaStreamErrorEvent; + "unmute": Event; +} + +interface MediaStreamTrack extends EventTarget { + enabled: boolean; + readonly id: string; + readonly kind: string; + readonly label: string; + readonly muted: boolean; + onended: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; + onmute: (this: MediaStreamTrack, ev: Event) => any; + onoverconstrained: (this: MediaStreamTrack, ev: MediaStreamErrorEvent) => any; + onunmute: (this: MediaStreamTrack, ev: Event) => any; + readonly readonly: boolean; + readonly readyState: MediaStreamTrackState; + readonly remote: boolean; + applyConstraints(constraints: MediaTrackConstraints): Promise; + clone(): MediaStreamTrack; + getCapabilities(): MediaTrackCapabilities; + getConstraints(): MediaTrackConstraints; + getSettings(): MediaTrackSettings; + stop(): void; + addEventListener(type: K, listener: (this: MediaStreamTrack, ev: MediaStreamTrackEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MediaStreamTrack: { + prototype: MediaStreamTrack; + new(): MediaStreamTrack; +} + +interface MediaStreamTrackEvent extends Event { + readonly track: MediaStreamTrack; +} + +declare var MediaStreamTrackEvent: { + prototype: MediaStreamTrackEvent; + new(typeArg: string, eventInitDict?: MediaStreamTrackEventInit): MediaStreamTrackEvent; +} + +interface MessageChannel { + readonly port1: MessagePort; + readonly port2: MessagePort; +} + +declare var MessageChannel: { + prototype: MessageChannel; + new(): MessageChannel; +} + +interface MessageEvent extends Event { + readonly data: any; + readonly origin: string; + readonly ports: any; + readonly 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 MessagePortEventMap { + "message": MessageEvent; +} + +interface MessagePort extends EventTarget { + onmessage: (this: MessagePort, ev: MessageEvent) => any; + close(): void; + postMessage(message?: any, transfer?: any[]): void; + start(): void; + addEventListener(type: K, listener: (this: MessagePort, ev: MessagePortEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var MessagePort: { + prototype: MessagePort; + new(): MessagePort; +} + +interface MimeType { + readonly description: string; + readonly enabledPlugin: Plugin; + readonly suffixes: string; + readonly type: string; +} + +declare var MimeType: { + prototype: MimeType; + new(): MimeType; +} + +interface MimeTypeArray { + readonly length: number; + item(index: number): Plugin; + namedItem(type: string): Plugin; + [index: number]: Plugin; +} + +declare var MimeTypeArray: { + prototype: MimeTypeArray; + new(): MimeTypeArray; +} + +interface MouseEvent extends UIEvent { + readonly altKey: boolean; + readonly button: number; + readonly buttons: number; + readonly clientX: number; + readonly clientY: number; + readonly ctrlKey: boolean; + readonly fromElement: Element; + readonly layerX: number; + readonly layerY: number; + readonly metaKey: boolean; + readonly movementX: number; + readonly movementY: number; + readonly offsetX: number; + readonly offsetY: number; + readonly pageX: number; + readonly pageY: number; + readonly relatedTarget: EventTarget; + readonly screenX: number; + readonly screenY: number; + readonly shiftKey: boolean; + readonly toElement: Element; + readonly which: number; + readonly x: number; + readonly 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 | null): void; +} + +declare var MouseEvent: { + prototype: MouseEvent; + new(typeArg: string, eventInitDict?: MouseEventInit): MouseEvent; +} + +interface MutationEvent extends Event { + readonly attrChange: number; + readonly attrName: string; + readonly newValue: string; + readonly prevValue: string; + readonly relatedNode: Node; + initMutationEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, relatedNodeArg: Node, prevValueArg: string, newValueArg: string, attrNameArg: string, attrChangeArg: number): void; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly REMOVAL: number; +} + +declare var MutationEvent: { + prototype: MutationEvent; + new(): MutationEvent; + readonly ADDITION: number; + readonly MODIFICATION: number; + readonly 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 { + readonly addedNodes: NodeList; + readonly attributeName: string | null; + readonly attributeNamespace: string | null; + readonly nextSibling: Node | null; + readonly oldValue: string | null; + readonly previousSibling: Node | null; + readonly removedNodes: NodeList; + readonly target: Node; + readonly type: string; +} + +declare var MutationRecord: { + prototype: MutationRecord; + new(): MutationRecord; +} + +interface NamedNodeMap { + readonly length: number; + getNamedItem(name: string): Attr; + getNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; + item(index: number): Attr; + removeNamedItem(name: string): Attr; + removeNamedItemNS(namespaceURI: string | null, localName: string | null): Attr; + setNamedItem(arg: Attr): Attr; + setNamedItemNS(arg: Attr): Attr; + [index: number]: Attr; +} + +declare var NamedNodeMap: { + prototype: NamedNodeMap; + new(): NamedNodeMap; +} + +interface NavigationCompletedEvent extends NavigationEvent { + readonly isSuccess: boolean; + readonly webErrorStatus: number; +} + +declare var NavigationCompletedEvent: { + prototype: NavigationCompletedEvent; + new(): NavigationCompletedEvent; +} + +interface NavigationEvent extends Event { + readonly uri: string; +} + +declare var NavigationEvent: { + prototype: NavigationEvent; + new(): NavigationEvent; +} + +interface NavigationEventWithReferrer extends NavigationEvent { + readonly referer: string; +} + +declare var NavigationEventWithReferrer: { + prototype: NavigationEventWithReferrer; + new(): NavigationEventWithReferrer; +} + +interface Navigator extends Object, NavigatorID, NavigatorOnLine, NavigatorContentUtils, NavigatorStorageUtils, NavigatorGeolocation, MSNavigatorDoNotTrack, MSFileSaver, NavigatorBeacon, NavigatorConcurrentHardware, NavigatorUserMedia { + readonly authentication: WebAuthentication; + readonly cookieEnabled: boolean; + gamepadInputEmulation: GamepadInputEmulationType; + readonly language: string; + readonly maxTouchPoints: number; + readonly mimeTypes: MimeTypeArray; + readonly msManipulationViewsEnabled: boolean; + readonly msMaxTouchPoints: number; + readonly msPointerEnabled: boolean; + readonly plugins: PluginArray; + readonly pointerEnabled: boolean; + readonly serviceWorker: ServiceWorkerContainer; + readonly webdriver: boolean; + readonly hardwareConcurrency: number; + getGamepads(): Gamepad[]; + javaEnabled(): boolean; + msLaunchUri(uri: string, successCallback?: MSLaunchUriCallback, noHandlerCallback?: MSLaunchUriCallback): void; + requestMediaKeySystemAccess(keySystem: string, supportedConfigurations: MediaKeySystemConfiguration[]): Promise; + vibrate(pattern: number | number[]): boolean; +} + +declare var Navigator: { + prototype: Navigator; + new(): Navigator; +} + +interface Node extends EventTarget { + readonly attributes: NamedNodeMap; + readonly baseURI: string | null; + readonly childNodes: NodeList; + readonly firstChild: Node | null; + readonly lastChild: Node | null; + readonly localName: string | null; + readonly namespaceURI: string | null; + readonly nextSibling: Node | null; + readonly nodeName: string; + readonly nodeType: number; + nodeValue: string | null; + readonly ownerDocument: Document; + readonly parentElement: HTMLElement | null; + readonly parentNode: Node | null; + readonly previousSibling: Node | null; + textContent: string | null; + appendChild(newChild: T): T; + cloneNode(deep?: boolean): Node; + compareDocumentPosition(other: Node): number; + contains(child: Node): boolean; + hasAttributes(): boolean; + hasChildNodes(): boolean; + insertBefore(newChild: T, refChild: Node | null): T; + isDefaultNamespace(namespaceURI: string | null): boolean; + isEqualNode(arg: Node): boolean; + isSameNode(other: Node): boolean; + lookupNamespaceURI(prefix: string | null): string | null; + lookupPrefix(namespaceURI: string | null): string | null; + normalize(): void; + removeChild(oldChild: T): T; + replaceChild(newChild: Node, oldChild: T): T; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; +} + +declare var Node: { + prototype: Node; + new(): Node; + readonly ATTRIBUTE_NODE: number; + readonly CDATA_SECTION_NODE: number; + readonly COMMENT_NODE: number; + readonly DOCUMENT_FRAGMENT_NODE: number; + readonly DOCUMENT_NODE: number; + readonly DOCUMENT_POSITION_CONTAINED_BY: number; + readonly DOCUMENT_POSITION_CONTAINS: number; + readonly DOCUMENT_POSITION_DISCONNECTED: number; + readonly DOCUMENT_POSITION_FOLLOWING: number; + readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: number; + readonly DOCUMENT_POSITION_PRECEDING: number; + readonly DOCUMENT_TYPE_NODE: number; + readonly ELEMENT_NODE: number; + readonly ENTITY_NODE: number; + readonly ENTITY_REFERENCE_NODE: number; + readonly NOTATION_NODE: number; + readonly PROCESSING_INSTRUCTION_NODE: number; + readonly TEXT_NODE: number; +} + +interface NodeFilter { + acceptNode(n: Node): number; +} + +declare var NodeFilter: { + readonly FILTER_ACCEPT: number; + readonly FILTER_REJECT: number; + readonly FILTER_SKIP: number; + readonly SHOW_ALL: number; + readonly SHOW_ATTRIBUTE: number; + readonly SHOW_CDATA_SECTION: number; + readonly SHOW_COMMENT: number; + readonly SHOW_DOCUMENT: number; + readonly SHOW_DOCUMENT_FRAGMENT: number; + readonly SHOW_DOCUMENT_TYPE: number; + readonly SHOW_ELEMENT: number; + readonly SHOW_ENTITY: number; + readonly SHOW_ENTITY_REFERENCE: number; + readonly SHOW_NOTATION: number; + readonly SHOW_PROCESSING_INSTRUCTION: number; + readonly SHOW_TEXT: number; +} + +interface NodeIterator { + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly whatToShow: number; + detach(): void; + nextNode(): Node; + previousNode(): Node; +} + +declare var NodeIterator: { + prototype: NodeIterator; + new(): NodeIterator; +} + +interface NodeList { + readonly length: number; + item(index: number): Node; + [index: number]: Node; +} + +declare var NodeList: { + prototype: NodeList; + new(): NodeList; +} + +interface NotificationEventMap { + "click": Event; + "close": Event; + "error": Event; + "show": Event; +} + +interface Notification extends EventTarget { + readonly body: string; + readonly dir: NotificationDirection; + readonly icon: string; + readonly lang: string; + onclick: (this: Notification, ev: Event) => any; + onclose: (this: Notification, ev: Event) => any; + onerror: (this: Notification, ev: Event) => any; + onshow: (this: Notification, ev: Event) => any; + readonly permission: NotificationPermission; + readonly tag: string; + readonly title: string; + close(): void; + addEventListener(type: K, listener: (this: Notification, ev: NotificationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Notification: { + prototype: Notification; + new(title: string, options?: NotificationOptions): Notification; + requestPermission(callback?: NotificationPermissionCallback): Promise; +} + +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 { + readonly FRAGMENT_SHADER_DERIVATIVE_HINT_OES: number; +} + +declare var OES_standard_derivatives: { + prototype: OES_standard_derivatives; + new(): OES_standard_derivatives; + readonly 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 OES_texture_half_float { + readonly HALF_FLOAT_OES: number; +} + +declare var OES_texture_half_float: { + prototype: OES_texture_half_float; + new(): OES_texture_half_float; + readonly HALF_FLOAT_OES: number; +} + +interface OES_texture_half_float_linear { +} + +declare var OES_texture_half_float_linear: { + prototype: OES_texture_half_float_linear; + new(): OES_texture_half_float_linear; +} + +interface OfflineAudioCompletionEvent extends Event { + readonly renderedBuffer: AudioBuffer; +} + +declare var OfflineAudioCompletionEvent: { + prototype: OfflineAudioCompletionEvent; + new(): OfflineAudioCompletionEvent; +} + +interface OfflineAudioContextEventMap extends AudioContextEventMap { + "complete": OfflineAudioCompletionEvent; +} + +interface OfflineAudioContext extends AudioContextBase { + readonly length: number; + oncomplete: (this: OfflineAudioContext, ev: OfflineAudioCompletionEvent) => any; + startRendering(): Promise; + suspend(suspendTime: number): Promise; + addEventListener(type: K, listener: (this: OfflineAudioContext, ev: OfflineAudioContextEventMap[K]) => 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 OscillatorNodeEventMap { + "ended": MediaStreamErrorEvent; +} + +interface OscillatorNode extends AudioNode { + readonly detune: AudioParam; + readonly frequency: AudioParam; + onended: (this: OscillatorNode, ev: MediaStreamErrorEvent) => any; + type: OscillatorType; + setPeriodicWave(periodicWave: PeriodicWave): void; + start(when?: number): void; + stop(when?: number): void; + addEventListener(type: K, listener: (this: OscillatorNode, ev: OscillatorNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var OscillatorNode: { + prototype: OscillatorNode; + new(): OscillatorNode; +} + +interface OverflowEvent extends UIEvent { + readonly horizontalOverflow: boolean; + readonly orient: number; + readonly verticalOverflow: boolean; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; +} + +declare var OverflowEvent: { + prototype: OverflowEvent; + new(): OverflowEvent; + readonly BOTH: number; + readonly HORIZONTAL: number; + readonly VERTICAL: number; +} + +interface PageTransitionEvent extends Event { + readonly persisted: boolean; +} + +declare var PageTransitionEvent: { + prototype: PageTransitionEvent; + new(): PageTransitionEvent; +} + +interface PannerNode extends AudioNode { + coneInnerAngle: number; + coneOuterAngle: number; + coneOuterGain: number; + distanceModel: DistanceModelType; + maxDistance: number; + panningModel: PanningModelType; + 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 Path2D extends Object, CanvasPathMethods { +} + +declare var Path2D: { + prototype: Path2D; + new(path?: Path2D): Path2D; +} + +interface PaymentAddress { + readonly addressLine: string[]; + readonly city: string; + readonly country: string; + readonly dependentLocality: string; + readonly languageCode: string; + readonly organization: string; + readonly phone: string; + readonly postalCode: string; + readonly recipient: string; + readonly region: string; + readonly sortingCode: string; + toJSON(): any; +} + +declare var PaymentAddress: { + prototype: PaymentAddress; + new(): PaymentAddress; +} + +interface PaymentRequestEventMap { + "shippingaddresschange": Event; + "shippingoptionchange": Event; +} + +interface PaymentRequest extends EventTarget { + onshippingaddresschange: (this: PaymentRequest, ev: Event) => any; + onshippingoptionchange: (this: PaymentRequest, ev: Event) => any; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + readonly shippingType: PaymentShippingType | null; + abort(): Promise; + show(): Promise; + addEventListener(type: K, listener: (this: PaymentRequest, ev: PaymentRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var PaymentRequest: { + prototype: PaymentRequest; + new(methodData: PaymentMethodData[], details: PaymentDetails, options?: PaymentOptions): PaymentRequest; +} + +interface PaymentRequestUpdateEvent extends Event { + updateWith(d: Promise): void; +} + +declare var PaymentRequestUpdateEvent: { + prototype: PaymentRequestUpdateEvent; + new(type: string, eventInitDict?: PaymentRequestUpdateEventInit): PaymentRequestUpdateEvent; +} + +interface PaymentResponse { + readonly details: any; + readonly methodName: string; + readonly payerEmail: string | null; + readonly payerName: string | null; + readonly payerPhone: string | null; + readonly shippingAddress: PaymentAddress | null; + readonly shippingOption: string | null; + complete(result?: PaymentComplete): Promise; + toJSON(): any; +} + +declare var PaymentResponse: { + prototype: PaymentResponse; + new(): PaymentResponse; +} + +interface PerfWidgetExternal { + readonly activeNetworkRequestCount: number; + readonly averageFrameTime: number; + readonly averagePaintTime: number; + readonly extraInformationEnabled: boolean; + readonly independentRenderingEnabled: boolean; + readonly irDisablingContentString: string; + readonly irStatusAvailable: boolean; + readonly maxCpuSpeed: number; + readonly paintRequestsPerSecond: number; + readonly performanceCounter: number; + readonly performanceCounterFrequency: number; + addEventListener(eventType: string, callback: Function): void; + getMemoryUsage(): number; + getProcessCpuUsage(): number; + getRecentCpuUsage(last: number | null): any; + getRecentFrames(last: number | null): any; + getRecentMemoryUsage(last: number | null): any; + getRecentPaintRequests(last: number | null): 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 { + readonly navigation: PerformanceNavigation; + readonly 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 { + readonly duration: number; + readonly entryType: string; + readonly name: string; + readonly 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 { + readonly redirectCount: number; + readonly type: number; + toJSON(): any; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +declare var PerformanceNavigation: { + prototype: PerformanceNavigation; + new(): PerformanceNavigation; + readonly TYPE_BACK_FORWARD: number; + readonly TYPE_NAVIGATE: number; + readonly TYPE_RELOAD: number; + readonly TYPE_RESERVED: number; +} + +interface PerformanceNavigationTiming extends PerformanceEntry { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly navigationStart: number; + readonly redirectCount: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly type: NavigationType; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; +} + +declare var PerformanceNavigationTiming: { + prototype: PerformanceNavigationTiming; + new(): PerformanceNavigationTiming; +} + +interface PerformanceResourceTiming extends PerformanceEntry { + readonly connectEnd: number; + readonly connectStart: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly initiatorType: string; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; +} + +declare var PerformanceResourceTiming: { + prototype: PerformanceResourceTiming; + new(): PerformanceResourceTiming; +} + +interface PerformanceTiming { + readonly connectEnd: number; + readonly connectStart: number; + readonly domComplete: number; + readonly domContentLoadedEventEnd: number; + readonly domContentLoadedEventStart: number; + readonly domInteractive: number; + readonly domLoading: number; + readonly domainLookupEnd: number; + readonly domainLookupStart: number; + readonly fetchStart: number; + readonly loadEventEnd: number; + readonly loadEventStart: number; + readonly msFirstPaint: number; + readonly navigationStart: number; + readonly redirectEnd: number; + readonly redirectStart: number; + readonly requestStart: number; + readonly responseEnd: number; + readonly responseStart: number; + readonly unloadEventEnd: number; + readonly unloadEventStart: number; + readonly secureConnectionStart: number; + toJSON(): any; +} + +declare var PerformanceTiming: { + prototype: PerformanceTiming; + new(): PerformanceTiming; +} + +interface PeriodicWave { +} + +declare var PeriodicWave: { + prototype: PeriodicWave; + new(): PeriodicWave; +} + +interface PermissionRequest extends DeferredPermissionRequest { + readonly state: MSWebViewPermissionState; + defer(): void; +} + +declare var PermissionRequest: { + prototype: PermissionRequest; + new(): PermissionRequest; +} + +interface PermissionRequestedEvent extends Event { + readonly permissionRequest: PermissionRequest; +} + +declare var PermissionRequestedEvent: { + prototype: PermissionRequestedEvent; + new(): PermissionRequestedEvent; +} + +interface Plugin { + readonly description: string; + readonly filename: string; + readonly length: number; + readonly name: string; + readonly version: string; + item(index: number): MimeType; + namedItem(type: string): MimeType; + [index: number]: MimeType; +} + +declare var Plugin: { + prototype: Plugin; + new(): Plugin; +} + +interface PluginArray { + readonly 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 { + readonly currentPoint: any; + readonly height: number; + readonly hwTimestamp: number; + readonly intermediatePoints: any; + readonly isPrimary: boolean; + readonly pointerId: number; + readonly pointerType: any; + readonly pressure: number; + readonly rotation: number; + readonly tiltX: number; + readonly tiltY: number; + readonly 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 { + readonly state: any; + initPopStateEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, stateArg: any): void; +} + +declare var PopStateEvent: { + prototype: PopStateEvent; + new(typeArg: string, eventInitDict?: PopStateEventInit): PopStateEvent; +} + +interface Position { + readonly coords: Coordinates; + readonly timestamp: number; +} + +declare var Position: { + prototype: Position; + new(): Position; +} + +interface PositionError { + readonly code: number; + readonly message: string; + toString(): string; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; +} + +declare var PositionError: { + prototype: PositionError; + new(): PositionError; + readonly PERMISSION_DENIED: number; + readonly POSITION_UNAVAILABLE: number; + readonly TIMEOUT: number; +} + +interface ProcessingInstruction extends CharacterData { + readonly target: string; +} + +declare var ProcessingInstruction: { + prototype: ProcessingInstruction; + new(): ProcessingInstruction; +} + +interface ProgressEvent extends Event { + readonly lengthComputable: boolean; + readonly loaded: number; + readonly 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 PushManager { + getSubscription(): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; + subscribe(options?: PushSubscriptionOptionsInit): Promise; +} + +declare var PushManager: { + prototype: PushManager; + new(): PushManager; +} + +interface PushSubscription { + readonly endpoint: USVString; + readonly options: PushSubscriptionOptions; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; + toJSON(): any; + unsubscribe(): Promise; +} + +declare var PushSubscription: { + prototype: PushSubscription; + new(): PushSubscription; +} + +interface PushSubscriptionOptions { + readonly applicationServerKey: ArrayBuffer | null; + readonly userVisibleOnly: boolean; +} + +declare var PushSubscriptionOptions: { + prototype: PushSubscriptionOptions; + new(): PushSubscriptionOptions; +} + +interface RTCDTMFToneChangeEvent extends Event { + readonly tone: string; +} + +declare var RTCDTMFToneChangeEvent: { + prototype: RTCDTMFToneChangeEvent; + new(typeArg: string, eventInitDict: RTCDTMFToneChangeEventInit): RTCDTMFToneChangeEvent; +} + +interface RTCDtlsTransportEventMap { + "dtlsstatechange": RTCDtlsTransportStateChangedEvent; + "error": Event; +} + +interface RTCDtlsTransport extends RTCStatsProvider { + ondtlsstatechange: ((this: RTCDtlsTransport, ev: RTCDtlsTransportStateChangedEvent) => any) | null; + onerror: ((this: RTCDtlsTransport, ev: Event) => any) | null; + readonly state: RTCDtlsTransportState; + readonly transport: RTCIceTransport; + getLocalParameters(): RTCDtlsParameters; + getRemoteCertificates(): ArrayBuffer[]; + getRemoteParameters(): RTCDtlsParameters | null; + start(remoteParameters: RTCDtlsParameters): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCDtlsTransport, ev: RTCDtlsTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtlsTransport: { + prototype: RTCDtlsTransport; + new(transport: RTCIceTransport): RTCDtlsTransport; +} + +interface RTCDtlsTransportStateChangedEvent extends Event { + readonly state: RTCDtlsTransportState; +} + +declare var RTCDtlsTransportStateChangedEvent: { + prototype: RTCDtlsTransportStateChangedEvent; + new(): RTCDtlsTransportStateChangedEvent; +} + +interface RTCDtmfSenderEventMap { + "tonechange": RTCDTMFToneChangeEvent; +} + +interface RTCDtmfSender extends EventTarget { + readonly canInsertDTMF: boolean; + readonly duration: number; + readonly interToneGap: number; + ontonechange: (this: RTCDtmfSender, ev: RTCDTMFToneChangeEvent) => any; + readonly sender: RTCRtpSender; + readonly toneBuffer: string; + insertDTMF(tones: string, duration?: number, interToneGap?: number): void; + addEventListener(type: K, listener: (this: RTCDtmfSender, ev: RTCDtmfSenderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCDtmfSender: { + prototype: RTCDtmfSender; + new(sender: RTCRtpSender): RTCDtmfSender; +} + +interface RTCIceCandidate { + candidate: string | null; + sdpMLineIndex: number | null; + sdpMid: string | null; + toJSON(): any; +} + +declare var RTCIceCandidate: { + prototype: RTCIceCandidate; + new(candidateInitDict?: RTCIceCandidateInit): RTCIceCandidate; +} + +interface RTCIceCandidatePairChangedEvent extends Event { + readonly pair: RTCIceCandidatePair; +} + +declare var RTCIceCandidatePairChangedEvent: { + prototype: RTCIceCandidatePairChangedEvent; + new(): RTCIceCandidatePairChangedEvent; +} + +interface RTCIceGathererEventMap { + "error": Event; + "localcandidate": RTCIceGathererEvent; +} + +interface RTCIceGatherer extends RTCStatsProvider { + readonly component: RTCIceComponent; + onerror: ((this: RTCIceGatherer, ev: Event) => any) | null; + onlocalcandidate: ((this: RTCIceGatherer, ev: RTCIceGathererEvent) => any) | null; + createAssociatedGatherer(): RTCIceGatherer; + getLocalCandidates(): RTCIceCandidateDictionary[]; + getLocalParameters(): RTCIceParameters; + addEventListener(type: K, listener: (this: RTCIceGatherer, ev: RTCIceGathererEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceGatherer: { + prototype: RTCIceGatherer; + new(options: RTCIceGatherOptions): RTCIceGatherer; +} + +interface RTCIceGathererEvent extends Event { + readonly candidate: RTCIceCandidateDictionary | RTCIceCandidateComplete; +} + +declare var RTCIceGathererEvent: { + prototype: RTCIceGathererEvent; + new(): RTCIceGathererEvent; +} + +interface RTCIceTransportEventMap { + "candidatepairchange": RTCIceCandidatePairChangedEvent; + "icestatechange": RTCIceTransportStateChangedEvent; +} + +interface RTCIceTransport extends RTCStatsProvider { + readonly component: RTCIceComponent; + readonly iceGatherer: RTCIceGatherer | null; + oncandidatepairchange: ((this: RTCIceTransport, ev: RTCIceCandidatePairChangedEvent) => any) | null; + onicestatechange: ((this: RTCIceTransport, ev: RTCIceTransportStateChangedEvent) => any) | null; + readonly role: RTCIceRole; + readonly state: RTCIceTransportState; + addRemoteCandidate(remoteCandidate: RTCIceCandidateDictionary | RTCIceCandidateComplete): void; + createAssociatedTransport(): RTCIceTransport; + getNominatedCandidatePair(): RTCIceCandidatePair | null; + getRemoteCandidates(): RTCIceCandidateDictionary[]; + getRemoteParameters(): RTCIceParameters | null; + setRemoteCandidates(remoteCandidates: RTCIceCandidateDictionary[]): void; + start(gatherer: RTCIceGatherer, remoteParameters: RTCIceParameters, role?: RTCIceRole): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCIceTransport, ev: RTCIceTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCIceTransport: { + prototype: RTCIceTransport; + new(): RTCIceTransport; +} + +interface RTCIceTransportStateChangedEvent extends Event { + readonly state: RTCIceTransportState; +} + +declare var RTCIceTransportStateChangedEvent: { + prototype: RTCIceTransportStateChangedEvent; + new(): RTCIceTransportStateChangedEvent; +} + +interface RTCPeerConnectionEventMap { + "addstream": MediaStreamEvent; + "icecandidate": RTCPeerConnectionIceEvent; + "iceconnectionstatechange": Event; + "icegatheringstatechange": Event; + "negotiationneeded": Event; + "removestream": MediaStreamEvent; + "signalingstatechange": Event; +} + +interface RTCPeerConnection extends EventTarget { + readonly canTrickleIceCandidates: boolean | null; + readonly iceConnectionState: RTCIceConnectionState; + readonly iceGatheringState: RTCIceGatheringState; + readonly localDescription: RTCSessionDescription | null; + onaddstream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onicecandidate: (this: RTCPeerConnection, ev: RTCPeerConnectionIceEvent) => any; + oniceconnectionstatechange: (this: RTCPeerConnection, ev: Event) => any; + onicegatheringstatechange: (this: RTCPeerConnection, ev: Event) => any; + onnegotiationneeded: (this: RTCPeerConnection, ev: Event) => any; + onremovestream: (this: RTCPeerConnection, ev: MediaStreamEvent) => any; + onsignalingstatechange: (this: RTCPeerConnection, ev: Event) => any; + readonly remoteDescription: RTCSessionDescription | null; + readonly signalingState: RTCSignalingState; + addIceCandidate(candidate: RTCIceCandidate, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addStream(stream: MediaStream): void; + close(): void; + createAnswer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + createOffer(successCallback?: RTCSessionDescriptionCallback, failureCallback?: RTCPeerConnectionErrorCallback, options?: RTCOfferOptions): Promise; + getConfiguration(): RTCConfiguration; + getLocalStreams(): MediaStream[]; + getRemoteStreams(): MediaStream[]; + getStats(selector: MediaStreamTrack | null, successCallback?: RTCStatsCallback, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + getStreamById(streamId: string): MediaStream | null; + removeStream(stream: MediaStream): void; + setLocalDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + setRemoteDescription(description: RTCSessionDescription, successCallback?: VoidFunction, failureCallback?: RTCPeerConnectionErrorCallback): Promise; + addEventListener(type: K, listener: (this: RTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCPeerConnection: { + prototype: RTCPeerConnection; + new(configuration: RTCConfiguration): RTCPeerConnection; +} + +interface RTCPeerConnectionIceEvent extends Event { + readonly candidate: RTCIceCandidate; +} + +declare var RTCPeerConnectionIceEvent: { + prototype: RTCPeerConnectionIceEvent; + new(type: string, eventInitDict: RTCPeerConnectionIceEventInit): RTCPeerConnectionIceEvent; +} + +interface RTCRtpReceiverEventMap { + "error": Event; +} + +interface RTCRtpReceiver extends RTCStatsProvider { + onerror: ((this: RTCRtpReceiver, ev: Event) => any) | null; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack | null; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; + getContributingSources(): RTCRtpContributingSource[]; + receive(parameters: RTCRtpParameters): void; + requestSendCSRC(csrc: number): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCRtpReceiver, ev: RTCRtpReceiverEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpReceiver: { + prototype: RTCRtpReceiver; + new(transport: RTCDtlsTransport | RTCSrtpSdesTransport, kind: string, rtcpTransport?: RTCDtlsTransport): RTCRtpReceiver; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCRtpSenderEventMap { + "error": Event; + "ssrcconflict": RTCSsrcConflictEvent; +} + +interface RTCRtpSender extends RTCStatsProvider { + onerror: ((this: RTCRtpSender, ev: Event) => any) | null; + onssrcconflict: ((this: RTCRtpSender, ev: RTCSsrcConflictEvent) => any) | null; + readonly rtcpTransport: RTCDtlsTransport; + readonly track: MediaStreamTrack; + readonly transport: RTCDtlsTransport | RTCSrtpSdesTransport; + send(parameters: RTCRtpParameters): void; + setTrack(track: MediaStreamTrack): void; + setTransport(transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): void; + stop(): void; + addEventListener(type: K, listener: (this: RTCRtpSender, ev: RTCRtpSenderEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCRtpSender: { + prototype: RTCRtpSender; + new(track: MediaStreamTrack, transport: RTCDtlsTransport | RTCSrtpSdesTransport, rtcpTransport?: RTCDtlsTransport): RTCRtpSender; + getCapabilities(kind?: string): RTCRtpCapabilities; +} + +interface RTCSessionDescription { + sdp: string | null; + type: RTCSdpType | null; + toJSON(): any; +} + +declare var RTCSessionDescription: { + prototype: RTCSessionDescription; + new(descriptionInitDict?: RTCSessionDescriptionInit): RTCSessionDescription; +} + +interface RTCSrtpSdesTransportEventMap { + "error": Event; +} + +interface RTCSrtpSdesTransport extends EventTarget { + onerror: ((this: RTCSrtpSdesTransport, ev: Event) => any) | null; + readonly transport: RTCIceTransport; + addEventListener(type: K, listener: (this: RTCSrtpSdesTransport, ev: RTCSrtpSdesTransportEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var RTCSrtpSdesTransport: { + prototype: RTCSrtpSdesTransport; + new(transport: RTCIceTransport, encryptParameters: RTCSrtpSdesParameters, decryptParameters: RTCSrtpSdesParameters): RTCSrtpSdesTransport; + getLocalParameters(): RTCSrtpSdesParameters[]; +} + +interface RTCSsrcConflictEvent extends Event { + readonly ssrc: number; +} + +declare var RTCSsrcConflictEvent: { + prototype: RTCSsrcConflictEvent; + new(): RTCSsrcConflictEvent; +} + +interface RTCStatsProvider extends EventTarget { + getStats(): Promise; + msGetStats(): Promise; +} + +declare var RTCStatsProvider: { + prototype: RTCStatsProvider; + new(): RTCStatsProvider; +} + +interface Range { + readonly collapsed: boolean; + readonly commonAncestorContainer: Node; + readonly endContainer: Node; + readonly endOffset: number; + readonly startContainer: Node; + readonly 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: ExpandGranularity): 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; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; +} + +declare var Range: { + prototype: Range; + new(): Range; + readonly END_TO_END: number; + readonly END_TO_START: number; + readonly START_TO_END: number; + readonly START_TO_START: number; +} + +interface ReadableStream { + readonly locked: boolean; + cancel(): Promise; + getReader(): ReadableStreamReader; +} + +declare var ReadableStream: { + prototype: ReadableStream; + new(): ReadableStream; +} + +interface ReadableStreamReader { + cancel(): Promise; + read(): Promise; + releaseLock(): void; +} + +declare var ReadableStreamReader: { + prototype: ReadableStreamReader; + new(): ReadableStreamReader; +} + +interface Request extends Object, Body { + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; + readonly headers: Headers; + readonly integrity: string; + readonly keepalive: boolean; + readonly method: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; + readonly referrer: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; + readonly url: string; + clone(): Request; +} + +declare var Request: { + prototype: Request; + new(input: Request | string, init?: RequestInit): Request; +} + +interface Response extends Object, Body { + readonly body: ReadableStream | null; + readonly headers: Headers; + readonly ok: boolean; + readonly status: number; + readonly statusText: string; + readonly type: ResponseType; + readonly url: string; + clone(): Response; +} + +declare var Response: { + prototype: Response; + new(body?: any, init?: ResponseInit): Response; +} + +interface SVGAElement extends SVGGraphicsElement, SVGURIReference { + readonly target: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGAElement: { + prototype: SVGAElement; + new(): SVGAElement; +} + +interface SVGAngle { + readonly unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; +} + +declare var SVGAngle: { + prototype: SVGAngle; + new(): SVGAngle; + readonly SVG_ANGLETYPE_DEG: number; + readonly SVG_ANGLETYPE_GRAD: number; + readonly SVG_ANGLETYPE_RAD: number; + readonly SVG_ANGLETYPE_UNKNOWN: number; + readonly SVG_ANGLETYPE_UNSPECIFIED: number; +} + +interface SVGAnimatedAngle { + readonly animVal: SVGAngle; + readonly baseVal: SVGAngle; +} + +declare var SVGAnimatedAngle: { + prototype: SVGAnimatedAngle; + new(): SVGAnimatedAngle; +} + +interface SVGAnimatedBoolean { + readonly animVal: boolean; + baseVal: boolean; +} + +declare var SVGAnimatedBoolean: { + prototype: SVGAnimatedBoolean; + new(): SVGAnimatedBoolean; +} + +interface SVGAnimatedEnumeration { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedEnumeration: { + prototype: SVGAnimatedEnumeration; + new(): SVGAnimatedEnumeration; +} + +interface SVGAnimatedInteger { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedInteger: { + prototype: SVGAnimatedInteger; + new(): SVGAnimatedInteger; +} + +interface SVGAnimatedLength { + readonly animVal: SVGLength; + readonly baseVal: SVGLength; +} + +declare var SVGAnimatedLength: { + prototype: SVGAnimatedLength; + new(): SVGAnimatedLength; +} + +interface SVGAnimatedLengthList { + readonly animVal: SVGLengthList; + readonly baseVal: SVGLengthList; +} + +declare var SVGAnimatedLengthList: { + prototype: SVGAnimatedLengthList; + new(): SVGAnimatedLengthList; +} + +interface SVGAnimatedNumber { + readonly animVal: number; + baseVal: number; +} + +declare var SVGAnimatedNumber: { + prototype: SVGAnimatedNumber; + new(): SVGAnimatedNumber; +} + +interface SVGAnimatedNumberList { + readonly animVal: SVGNumberList; + readonly baseVal: SVGNumberList; +} + +declare var SVGAnimatedNumberList: { + prototype: SVGAnimatedNumberList; + new(): SVGAnimatedNumberList; +} + +interface SVGAnimatedPreserveAspectRatio { + readonly animVal: SVGPreserveAspectRatio; + readonly baseVal: SVGPreserveAspectRatio; +} + +declare var SVGAnimatedPreserveAspectRatio: { + prototype: SVGAnimatedPreserveAspectRatio; + new(): SVGAnimatedPreserveAspectRatio; +} + +interface SVGAnimatedRect { + readonly animVal: SVGRect; + readonly baseVal: SVGRect; +} + +declare var SVGAnimatedRect: { + prototype: SVGAnimatedRect; + new(): SVGAnimatedRect; +} + +interface SVGAnimatedString { + readonly animVal: string; + baseVal: string; +} + +declare var SVGAnimatedString: { + prototype: SVGAnimatedString; + new(): SVGAnimatedString; +} + +interface SVGAnimatedTransformList { + readonly animVal: SVGTransformList; + readonly baseVal: SVGTransformList; +} + +declare var SVGAnimatedTransformList: { + prototype: SVGAnimatedTransformList; + new(): SVGAnimatedTransformList; +} + +interface SVGCircleElement extends SVGGraphicsElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGCircleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGCircleElement: { + prototype: SVGCircleElement; + new(): SVGCircleElement; +} + +interface SVGClipPathElement extends SVGGraphicsElement, SVGUnitTypes { + readonly clipPathUnits: SVGAnimatedEnumeration; + addEventListener(type: K, listener: (this: SVGClipPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGClipPathElement: { + prototype: SVGClipPathElement; + new(): SVGClipPathElement; +} + +interface SVGComponentTransferFunctionElement extends SVGElement { + readonly amplitude: SVGAnimatedNumber; + readonly exponent: SVGAnimatedNumber; + readonly intercept: SVGAnimatedNumber; + readonly offset: SVGAnimatedNumber; + readonly slope: SVGAnimatedNumber; + readonly tableValues: SVGAnimatedNumberList; + readonly type: SVGAnimatedEnumeration; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGComponentTransferFunctionElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGComponentTransferFunctionElement: { + prototype: SVGComponentTransferFunctionElement; + new(): SVGComponentTransferFunctionElement; + readonly SVG_FECOMPONENTTRANSFER_TYPE_DISCRETE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_GAMMA: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_IDENTITY: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_LINEAR: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_TABLE: number; + readonly SVG_FECOMPONENTTRANSFER_TYPE_UNKNOWN: number; +} + +interface SVGDefsElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGDefsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDefsElement: { + prototype: SVGDefsElement; + new(): SVGDefsElement; +} + +interface SVGDescElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGDescElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGDescElement: { + prototype: SVGDescElement; + new(): SVGDescElement; +} + +interface SVGElementEventMap extends ElementEventMap { + "click": MouseEvent; + "dblclick": MouseEvent; + "focusin": FocusEvent; + "focusout": FocusEvent; + "load": Event; + "mousedown": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; +} + +interface SVGElement extends Element { + className: any; + onclick: (this: SVGElement, ev: MouseEvent) => any; + ondblclick: (this: SVGElement, ev: MouseEvent) => any; + onfocusin: (this: SVGElement, ev: FocusEvent) => any; + onfocusout: (this: SVGElement, ev: FocusEvent) => any; + onload: (this: SVGElement, ev: Event) => any; + onmousedown: (this: SVGElement, ev: MouseEvent) => any; + onmousemove: (this: SVGElement, ev: MouseEvent) => any; + onmouseout: (this: SVGElement, ev: MouseEvent) => any; + onmouseover: (this: SVGElement, ev: MouseEvent) => any; + onmouseup: (this: SVGElement, ev: MouseEvent) => any; + readonly ownerSVGElement: SVGSVGElement; + readonly style: CSSStyleDeclaration; + readonly viewportElement: SVGElement; + xmlbase: string; + addEventListener(type: K, listener: (this: SVGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGElement: { + prototype: SVGElement; + new(): SVGElement; +} + +interface SVGElementInstance extends EventTarget { + readonly childNodes: SVGElementInstanceList; + readonly correspondingElement: SVGElement; + readonly correspondingUseElement: SVGUseElement; + readonly firstChild: SVGElementInstance; + readonly lastChild: SVGElementInstance; + readonly nextSibling: SVGElementInstance; + readonly parentNode: SVGElementInstance; + readonly previousSibling: SVGElementInstance; +} + +declare var SVGElementInstance: { + prototype: SVGElementInstance; + new(): SVGElementInstance; +} + +interface SVGElementInstanceList { + readonly length: number; + item(index: number): SVGElementInstance; +} + +declare var SVGElementInstanceList: { + prototype: SVGElementInstanceList; + new(): SVGElementInstanceList; +} + +interface SVGEllipseElement extends SVGGraphicsElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGEllipseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGEllipseElement: { + prototype: SVGEllipseElement; + new(): SVGEllipseElement; +} + +interface SVGFEBlendElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly mode: SVGAnimatedEnumeration; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEBlendElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEBlendElement: { + prototype: SVGFEBlendElement; + new(): SVGFEBlendElement; + readonly SVG_FEBLEND_MODE_COLOR: number; + readonly SVG_FEBLEND_MODE_COLOR_BURN: number; + readonly SVG_FEBLEND_MODE_COLOR_DODGE: number; + readonly SVG_FEBLEND_MODE_DARKEN: number; + readonly SVG_FEBLEND_MODE_DIFFERENCE: number; + readonly SVG_FEBLEND_MODE_EXCLUSION: number; + readonly SVG_FEBLEND_MODE_HARD_LIGHT: number; + readonly SVG_FEBLEND_MODE_HUE: number; + readonly SVG_FEBLEND_MODE_LIGHTEN: number; + readonly SVG_FEBLEND_MODE_LUMINOSITY: number; + readonly SVG_FEBLEND_MODE_MULTIPLY: number; + readonly SVG_FEBLEND_MODE_NORMAL: number; + readonly SVG_FEBLEND_MODE_OVERLAY: number; + readonly SVG_FEBLEND_MODE_SATURATION: number; + readonly SVG_FEBLEND_MODE_SCREEN: number; + readonly SVG_FEBLEND_MODE_SOFT_LIGHT: number; + readonly SVG_FEBLEND_MODE_UNKNOWN: number; +} + +interface SVGFEColorMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly type: SVGAnimatedEnumeration; + readonly values: SVGAnimatedNumberList; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEColorMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEColorMatrixElement: { + prototype: SVGFEColorMatrixElement; + new(): SVGFEColorMatrixElement; + readonly SVG_FECOLORMATRIX_TYPE_HUEROTATE: number; + readonly SVG_FECOLORMATRIX_TYPE_LUMINANCETOALPHA: number; + readonly SVG_FECOLORMATRIX_TYPE_MATRIX: number; + readonly SVG_FECOLORMATRIX_TYPE_SATURATE: number; + readonly SVG_FECOLORMATRIX_TYPE_UNKNOWN: number; +} + +interface SVGFEComponentTransferElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEComponentTransferElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEComponentTransferElement: { + prototype: SVGFEComponentTransferElement; + new(): SVGFEComponentTransferElement; +} + +interface SVGFECompositeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly k1: SVGAnimatedNumber; + readonly k2: SVGAnimatedNumber; + readonly k3: SVGAnimatedNumber; + readonly k4: SVGAnimatedNumber; + readonly operator: SVGAnimatedEnumeration; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; + addEventListener(type: K, listener: (this: SVGFECompositeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFECompositeElement: { + prototype: SVGFECompositeElement; + new(): SVGFECompositeElement; + readonly SVG_FECOMPOSITE_OPERATOR_ARITHMETIC: number; + readonly SVG_FECOMPOSITE_OPERATOR_ATOP: number; + readonly SVG_FECOMPOSITE_OPERATOR_IN: number; + readonly SVG_FECOMPOSITE_OPERATOR_OUT: number; + readonly SVG_FECOMPOSITE_OPERATOR_OVER: number; + readonly SVG_FECOMPOSITE_OPERATOR_UNKNOWN: number; + readonly SVG_FECOMPOSITE_OPERATOR_XOR: number; +} + +interface SVGFEConvolveMatrixElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly bias: SVGAnimatedNumber; + readonly divisor: SVGAnimatedNumber; + readonly edgeMode: SVGAnimatedEnumeration; + readonly in1: SVGAnimatedString; + readonly kernelMatrix: SVGAnimatedNumberList; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly orderX: SVGAnimatedInteger; + readonly orderY: SVGAnimatedInteger; + readonly preserveAlpha: SVGAnimatedBoolean; + readonly targetX: SVGAnimatedInteger; + readonly targetY: SVGAnimatedInteger; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; + addEventListener(type: K, listener: (this: SVGFEConvolveMatrixElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEConvolveMatrixElement: { + prototype: SVGFEConvolveMatrixElement; + new(): SVGFEConvolveMatrixElement; + readonly SVG_EDGEMODE_DUPLICATE: number; + readonly SVG_EDGEMODE_NONE: number; + readonly SVG_EDGEMODE_UNKNOWN: number; + readonly SVG_EDGEMODE_WRAP: number; +} + +interface SVGFEDiffuseLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly diffuseConstant: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEDiffuseLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDiffuseLightingElement: { + prototype: SVGFEDiffuseLightingElement; + new(): SVGFEDiffuseLightingElement; +} + +interface SVGFEDisplacementMapElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly in2: SVGAnimatedString; + readonly scale: SVGAnimatedNumber; + readonly xChannelSelector: SVGAnimatedEnumeration; + readonly yChannelSelector: SVGAnimatedEnumeration; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEDisplacementMapElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDisplacementMapElement: { + prototype: SVGFEDisplacementMapElement; + new(): SVGFEDisplacementMapElement; + readonly SVG_CHANNEL_A: number; + readonly SVG_CHANNEL_B: number; + readonly SVG_CHANNEL_G: number; + readonly SVG_CHANNEL_R: number; + readonly SVG_CHANNEL_UNKNOWN: number; +} + +interface SVGFEDistantLightElement extends SVGElement { + readonly azimuth: SVGAnimatedNumber; + readonly elevation: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEDistantLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEDistantLightElement: { + prototype: SVGFEDistantLightElement; + new(): SVGFEDistantLightElement; +} + +interface SVGFEFloodElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: K, listener: (this: SVGFEFloodElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFloodElement: { + prototype: SVGFEFloodElement; + new(): SVGFEFloodElement; +} + +interface SVGFEFuncAElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncAElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncAElement: { + prototype: SVGFEFuncAElement; + new(): SVGFEFuncAElement; +} + +interface SVGFEFuncBElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncBElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncBElement: { + prototype: SVGFEFuncBElement; + new(): SVGFEFuncBElement; +} + +interface SVGFEFuncGElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncGElement: { + prototype: SVGFEFuncGElement; + new(): SVGFEFuncGElement; +} + +interface SVGFEFuncRElement extends SVGComponentTransferFunctionElement { + addEventListener(type: K, listener: (this: SVGFEFuncRElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEFuncRElement: { + prototype: SVGFEFuncRElement; + new(): SVGFEFuncRElement; +} + +interface SVGFEGaussianBlurElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly stdDeviationX: SVGAnimatedNumber; + readonly stdDeviationY: SVGAnimatedNumber; + setStdDeviation(stdDeviationX: number, stdDeviationY: number): void; + addEventListener(type: K, listener: (this: SVGFEGaussianBlurElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEGaussianBlurElement: { + prototype: SVGFEGaussianBlurElement; + new(): SVGFEGaussianBlurElement; +} + +interface SVGFEImageElement extends SVGElement, SVGFilterPrimitiveStandardAttributes, SVGURIReference { + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + addEventListener(type: K, listener: (this: SVGFEImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEImageElement: { + prototype: SVGFEImageElement; + new(): SVGFEImageElement; +} + +interface SVGFEMergeElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + addEventListener(type: K, listener: (this: SVGFEMergeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeElement: { + prototype: SVGFEMergeElement; + new(): SVGFEMergeElement; +} + +interface SVGFEMergeNodeElement extends SVGElement { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEMergeNodeElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMergeNodeElement: { + prototype: SVGFEMergeNodeElement; + new(): SVGFEMergeNodeElement; +} + +interface SVGFEMorphologyElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly operator: SVGAnimatedEnumeration; + readonly radiusX: SVGAnimatedNumber; + readonly radiusY: SVGAnimatedNumber; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFEMorphologyElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEMorphologyElement: { + prototype: SVGFEMorphologyElement; + new(): SVGFEMorphologyElement; + readonly SVG_MORPHOLOGY_OPERATOR_DILATE: number; + readonly SVG_MORPHOLOGY_OPERATOR_ERODE: number; + readonly SVG_MORPHOLOGY_OPERATOR_UNKNOWN: number; +} + +interface SVGFEOffsetElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly dx: SVGAnimatedNumber; + readonly dy: SVGAnimatedNumber; + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFEOffsetElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEOffsetElement: { + prototype: SVGFEOffsetElement; + new(): SVGFEOffsetElement; +} + +interface SVGFEPointLightElement extends SVGElement { + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFEPointLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFEPointLightElement: { + prototype: SVGFEPointLightElement; + new(): SVGFEPointLightElement; +} + +interface SVGFESpecularLightingElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + readonly kernelUnitLengthX: SVGAnimatedNumber; + readonly kernelUnitLengthY: SVGAnimatedNumber; + readonly specularConstant: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly surfaceScale: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFESpecularLightingElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpecularLightingElement: { + prototype: SVGFESpecularLightingElement; + new(): SVGFESpecularLightingElement; +} + +interface SVGFESpotLightElement extends SVGElement { + readonly limitingConeAngle: SVGAnimatedNumber; + readonly pointsAtX: SVGAnimatedNumber; + readonly pointsAtY: SVGAnimatedNumber; + readonly pointsAtZ: SVGAnimatedNumber; + readonly specularExponent: SVGAnimatedNumber; + readonly x: SVGAnimatedNumber; + readonly y: SVGAnimatedNumber; + readonly z: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGFESpotLightElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFESpotLightElement: { + prototype: SVGFESpotLightElement; + new(): SVGFESpotLightElement; +} + +interface SVGFETileElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly in1: SVGAnimatedString; + addEventListener(type: K, listener: (this: SVGFETileElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETileElement: { + prototype: SVGFETileElement; + new(): SVGFETileElement; +} + +interface SVGFETurbulenceElement extends SVGElement, SVGFilterPrimitiveStandardAttributes { + readonly baseFrequencyX: SVGAnimatedNumber; + readonly baseFrequencyY: SVGAnimatedNumber; + readonly numOctaves: SVGAnimatedInteger; + readonly seed: SVGAnimatedNumber; + readonly stitchTiles: SVGAnimatedEnumeration; + readonly type: SVGAnimatedEnumeration; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGFETurbulenceElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFETurbulenceElement: { + prototype: SVGFETurbulenceElement; + new(): SVGFETurbulenceElement; + readonly SVG_STITCHTYPE_NOSTITCH: number; + readonly SVG_STITCHTYPE_STITCH: number; + readonly SVG_STITCHTYPE_UNKNOWN: number; + readonly SVG_TURBULENCE_TYPE_FRACTALNOISE: number; + readonly SVG_TURBULENCE_TYPE_TURBULENCE: number; + readonly SVG_TURBULENCE_TYPE_UNKNOWN: number; +} + +interface SVGFilterElement extends SVGElement, SVGUnitTypes, SVGURIReference { + readonly filterResX: SVGAnimatedInteger; + readonly filterResY: SVGAnimatedInteger; + readonly filterUnits: SVGAnimatedEnumeration; + readonly height: SVGAnimatedLength; + readonly primitiveUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + setFilterRes(filterResX: number, filterResY: number): void; + addEventListener(type: K, listener: (this: SVGFilterElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGFilterElement: { + prototype: SVGFilterElement; + new(): SVGFilterElement; +} + +interface SVGForeignObjectElement extends SVGGraphicsElement { + readonly height: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGForeignObjectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGForeignObjectElement: { + prototype: SVGForeignObjectElement; + new(): SVGForeignObjectElement; +} + +interface SVGGElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGGElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGElement: { + prototype: SVGGElement; + new(): SVGGElement; +} + +interface SVGGradientElement extends SVGElement, SVGUnitTypes, SVGURIReference { + readonly gradientTransform: SVGAnimatedTransformList; + readonly gradientUnits: SVGAnimatedEnumeration; + readonly spreadMethod: SVGAnimatedEnumeration; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGradientElement: { + prototype: SVGGradientElement; + new(): SVGGradientElement; + readonly SVG_SPREADMETHOD_PAD: number; + readonly SVG_SPREADMETHOD_REFLECT: number; + readonly SVG_SPREADMETHOD_REPEAT: number; + readonly SVG_SPREADMETHOD_UNKNOWN: number; +} + +interface SVGGraphicsElement extends SVGElement, SVGTests { + readonly farthestViewportElement: SVGElement; + readonly nearestViewportElement: SVGElement; + readonly transform: SVGAnimatedTransformList; + getBBox(): SVGRect; + getCTM(): SVGMatrix; + getScreenCTM(): SVGMatrix; + getTransformToElement(element: SVGElement): SVGMatrix; + addEventListener(type: K, listener: (this: SVGGraphicsElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGGraphicsElement: { + prototype: SVGGraphicsElement; + new(): SVGGraphicsElement; +} + +interface SVGImageElement extends SVGGraphicsElement, SVGURIReference { + readonly height: SVGAnimatedLength; + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGImageElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGImageElement: { + prototype: SVGImageElement; + new(): SVGImageElement; +} + +interface SVGLength { + readonly unitType: number; + value: number; + valueAsString: string; + valueInSpecifiedUnits: number; + convertToSpecifiedUnits(unitType: number): void; + newValueSpecifiedUnits(unitType: number, valueInSpecifiedUnits: number): void; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; +} + +declare var SVGLength: { + prototype: SVGLength; + new(): SVGLength; + readonly SVG_LENGTHTYPE_CM: number; + readonly SVG_LENGTHTYPE_EMS: number; + readonly SVG_LENGTHTYPE_EXS: number; + readonly SVG_LENGTHTYPE_IN: number; + readonly SVG_LENGTHTYPE_MM: number; + readonly SVG_LENGTHTYPE_NUMBER: number; + readonly SVG_LENGTHTYPE_PC: number; + readonly SVG_LENGTHTYPE_PERCENTAGE: number; + readonly SVG_LENGTHTYPE_PT: number; + readonly SVG_LENGTHTYPE_PX: number; + readonly SVG_LENGTHTYPE_UNKNOWN: number; +} + +interface SVGLengthList { + readonly 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 SVGGraphicsElement { + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLineElement: { + prototype: SVGLineElement; + new(): SVGLineElement; +} + +interface SVGLinearGradientElement extends SVGGradientElement { + readonly x1: SVGAnimatedLength; + readonly x2: SVGAnimatedLength; + readonly y1: SVGAnimatedLength; + readonly y2: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGLinearGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGLinearGradientElement: { + prototype: SVGLinearGradientElement; + new(): SVGLinearGradientElement; +} + +interface SVGMarkerElement extends SVGElement, SVGFitToViewBox { + readonly markerHeight: SVGAnimatedLength; + readonly markerUnits: SVGAnimatedEnumeration; + readonly markerWidth: SVGAnimatedLength; + readonly orientAngle: SVGAnimatedAngle; + readonly orientType: SVGAnimatedEnumeration; + readonly refX: SVGAnimatedLength; + readonly refY: SVGAnimatedLength; + setOrientToAngle(angle: SVGAngle): void; + setOrientToAuto(): void; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGMarkerElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMarkerElement: { + prototype: SVGMarkerElement; + new(): SVGMarkerElement; + readonly SVG_MARKERUNITS_STROKEWIDTH: number; + readonly SVG_MARKERUNITS_UNKNOWN: number; + readonly SVG_MARKERUNITS_USERSPACEONUSE: number; + readonly SVG_MARKER_ORIENT_ANGLE: number; + readonly SVG_MARKER_ORIENT_AUTO: number; + readonly SVG_MARKER_ORIENT_UNKNOWN: number; +} + +interface SVGMaskElement extends SVGElement, SVGTests, SVGUnitTypes { + readonly height: SVGAnimatedLength; + readonly maskContentUnits: SVGAnimatedEnumeration; + readonly maskUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGMaskElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + 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 { + addEventListener(type: K, listener: (this: SVGMetadataElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGMetadataElement: { + prototype: SVGMetadataElement; + new(): SVGMetadataElement; +} + +interface SVGNumber { + value: number; +} + +declare var SVGNumber: { + prototype: SVGNumber; + new(): SVGNumber; +} + +interface SVGNumberList { + readonly 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 SVGGraphicsElement { + readonly pathSegList: SVGPathSegList; + 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: K, listener: (this: SVGPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPathElement: { + prototype: SVGPathElement; + new(): SVGPathElement; +} + +interface SVGPathSeg { + readonly pathSegType: number; + readonly pathSegTypeAsLetter: string; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly PATHSEG_UNKNOWN: number; +} + +declare var SVGPathSeg: { + prototype: SVGPathSeg; + new(): SVGPathSeg; + readonly PATHSEG_ARC_ABS: number; + readonly PATHSEG_ARC_REL: number; + readonly PATHSEG_CLOSEPATH: number; + readonly PATHSEG_CURVETO_CUBIC_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_REL: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_CUBIC_SMOOTH_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_REL: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS: number; + readonly PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL: number; + readonly PATHSEG_LINETO_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_ABS: number; + readonly PATHSEG_LINETO_HORIZONTAL_REL: number; + readonly PATHSEG_LINETO_REL: number; + readonly PATHSEG_LINETO_VERTICAL_ABS: number; + readonly PATHSEG_LINETO_VERTICAL_REL: number; + readonly PATHSEG_MOVETO_ABS: number; + readonly PATHSEG_MOVETO_REL: number; + readonly 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 { + readonly 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, SVGTests, SVGUnitTypes, SVGFitToViewBox, SVGURIReference { + readonly height: SVGAnimatedLength; + readonly patternContentUnits: SVGAnimatedEnumeration; + readonly patternTransform: SVGAnimatedTransformList; + readonly patternUnits: SVGAnimatedEnumeration; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGPatternElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + 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 { + readonly 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 SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolygonElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolygonElement: { + prototype: SVGPolygonElement; + new(): SVGPolygonElement; +} + +interface SVGPolylineElement extends SVGGraphicsElement, SVGAnimatedPoints { + addEventListener(type: K, listener: (this: SVGPolylineElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGPolylineElement: { + prototype: SVGPolylineElement; + new(): SVGPolylineElement; +} + +interface SVGPreserveAspectRatio { + align: number; + meetOrSlice: number; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +declare var SVGPreserveAspectRatio: { + prototype: SVGPreserveAspectRatio; + new(): SVGPreserveAspectRatio; + readonly SVG_MEETORSLICE_MEET: number; + readonly SVG_MEETORSLICE_SLICE: number; + readonly SVG_MEETORSLICE_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_NONE: number; + readonly SVG_PRESERVEASPECTRATIO_UNKNOWN: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMAXYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMIDYMIN: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMAX: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMID: number; + readonly SVG_PRESERVEASPECTRATIO_XMINYMIN: number; +} + +interface SVGRadialGradientElement extends SVGGradientElement { + readonly cx: SVGAnimatedLength; + readonly cy: SVGAnimatedLength; + readonly fx: SVGAnimatedLength; + readonly fy: SVGAnimatedLength; + readonly r: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRadialGradientElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +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 SVGGraphicsElement { + readonly height: SVGAnimatedLength; + readonly rx: SVGAnimatedLength; + readonly ry: SVGAnimatedLength; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGRectElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGRectElement: { + prototype: SVGRectElement; + new(): SVGRectElement; +} + +interface SVGSVGElementEventMap extends SVGElementEventMap { + "SVGAbort": Event; + "SVGError": Event; + "resize": UIEvent; + "scroll": UIEvent; + "SVGUnload": Event; + "SVGZoom": SVGZoomEvent; +} + +interface SVGSVGElement extends SVGGraphicsElement, DocumentEvent, SVGFitToViewBox, SVGZoomAndPan { + contentScriptType: string; + contentStyleType: string; + currentScale: number; + readonly currentTranslate: SVGPoint; + readonly height: SVGAnimatedLength; + onabort: (this: SVGSVGElement, ev: Event) => any; + onerror: (this: SVGSVGElement, ev: Event) => any; + onresize: (this: SVGSVGElement, ev: UIEvent) => any; + onscroll: (this: SVGSVGElement, ev: UIEvent) => any; + onunload: (this: SVGSVGElement, ev: Event) => any; + onzoom: (this: SVGSVGElement, ev: SVGZoomEvent) => any; + readonly pixelUnitToMillimeterX: number; + readonly pixelUnitToMillimeterY: number; + readonly screenPixelToMillimeterX: number; + readonly screenPixelToMillimeterY: number; + readonly viewport: SVGRect; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly 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): NodeListOf; + getIntersectionList(rect: SVGRect, referenceElement: SVGElement): NodeListOf; + pauseAnimations(): void; + setCurrentTime(seconds: number): void; + suspendRedraw(maxWaitMilliseconds: number): number; + unpauseAnimations(): void; + unsuspendRedraw(suspendHandleID: number): void; + unsuspendRedrawAll(): void; + addEventListener(type: K, listener: (this: SVGSVGElement, ev: SVGSVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSVGElement: { + prototype: SVGSVGElement; + new(): SVGSVGElement; +} + +interface SVGScriptElement extends SVGElement, SVGURIReference { + type: string; + addEventListener(type: K, listener: (this: SVGScriptElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGScriptElement: { + prototype: SVGScriptElement; + new(): SVGScriptElement; +} + +interface SVGStopElement extends SVGElement { + readonly offset: SVGAnimatedNumber; + addEventListener(type: K, listener: (this: SVGStopElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStopElement: { + prototype: SVGStopElement; + new(): SVGStopElement; +} + +interface SVGStringList { + readonly 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 { + disabled: boolean; + media: string; + title: string; + type: string; + addEventListener(type: K, listener: (this: SVGStyleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGStyleElement: { + prototype: SVGStyleElement; + new(): SVGStyleElement; +} + +interface SVGSwitchElement extends SVGGraphicsElement { + addEventListener(type: K, listener: (this: SVGSwitchElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSwitchElement: { + prototype: SVGSwitchElement; + new(): SVGSwitchElement; +} + +interface SVGSymbolElement extends SVGElement, SVGFitToViewBox { + addEventListener(type: K, listener: (this: SVGSymbolElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGSymbolElement: { + prototype: SVGSymbolElement; + new(): SVGSymbolElement; +} + +interface SVGTSpanElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTSpanElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTSpanElement: { + prototype: SVGTSpanElement; + new(): SVGTSpanElement; +} + +interface SVGTextContentElement extends SVGGraphicsElement { + readonly lengthAdjust: SVGAnimatedEnumeration; + readonly 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; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextContentElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextContentElement: { + prototype: SVGTextContentElement; + new(): SVGTextContentElement; + readonly LENGTHADJUST_SPACING: number; + readonly LENGTHADJUST_SPACINGANDGLYPHS: number; + readonly LENGTHADJUST_UNKNOWN: number; +} + +interface SVGTextElement extends SVGTextPositioningElement { + addEventListener(type: K, listener: (this: SVGTextElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextElement: { + prototype: SVGTextElement; + new(): SVGTextElement; +} + +interface SVGTextPathElement extends SVGTextContentElement, SVGURIReference { + readonly method: SVGAnimatedEnumeration; + readonly spacing: SVGAnimatedEnumeration; + readonly startOffset: SVGAnimatedLength; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; + addEventListener(type: K, listener: (this: SVGTextPathElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPathElement: { + prototype: SVGTextPathElement; + new(): SVGTextPathElement; + readonly TEXTPATH_METHODTYPE_ALIGN: number; + readonly TEXTPATH_METHODTYPE_STRETCH: number; + readonly TEXTPATH_METHODTYPE_UNKNOWN: number; + readonly TEXTPATH_SPACINGTYPE_AUTO: number; + readonly TEXTPATH_SPACINGTYPE_EXACT: number; + readonly TEXTPATH_SPACINGTYPE_UNKNOWN: number; +} + +interface SVGTextPositioningElement extends SVGTextContentElement { + readonly dx: SVGAnimatedLengthList; + readonly dy: SVGAnimatedLengthList; + readonly rotate: SVGAnimatedNumberList; + readonly x: SVGAnimatedLengthList; + readonly y: SVGAnimatedLengthList; + addEventListener(type: K, listener: (this: SVGTextPositioningElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTextPositioningElement: { + prototype: SVGTextPositioningElement; + new(): SVGTextPositioningElement; +} + +interface SVGTitleElement extends SVGElement { + addEventListener(type: K, listener: (this: SVGTitleElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGTitleElement: { + prototype: SVGTitleElement; + new(): SVGTitleElement; +} + +interface SVGTransform { + readonly angle: number; + readonly matrix: SVGMatrix; + readonly 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; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; +} + +declare var SVGTransform: { + prototype: SVGTransform; + new(): SVGTransform; + readonly SVG_TRANSFORM_MATRIX: number; + readonly SVG_TRANSFORM_ROTATE: number; + readonly SVG_TRANSFORM_SCALE: number; + readonly SVG_TRANSFORM_SKEWX: number; + readonly SVG_TRANSFORM_SKEWY: number; + readonly SVG_TRANSFORM_TRANSLATE: number; + readonly SVG_TRANSFORM_UNKNOWN: number; +} + +interface SVGTransformList { + readonly 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 { + readonly SVG_UNIT_TYPE_OBJECTBOUNDINGBOX: number; + readonly SVG_UNIT_TYPE_UNKNOWN: number; + readonly SVG_UNIT_TYPE_USERSPACEONUSE: number; +} +declare var SVGUnitTypes: SVGUnitTypes; + +interface SVGUseElement extends SVGGraphicsElement, SVGURIReference { + readonly animatedInstanceRoot: SVGElementInstance; + readonly height: SVGAnimatedLength; + readonly instanceRoot: SVGElementInstance; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; + addEventListener(type: K, listener: (this: SVGUseElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGUseElement: { + prototype: SVGUseElement; + new(): SVGUseElement; +} + +interface SVGViewElement extends SVGElement, SVGZoomAndPan, SVGFitToViewBox { + readonly viewTarget: SVGStringList; + addEventListener(type: K, listener: (this: SVGViewElement, ev: SVGElementEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SVGViewElement: { + prototype: SVGViewElement; + new(): SVGViewElement; +} + +interface SVGZoomAndPan { + readonly zoomAndPan: number; +} + +declare var SVGZoomAndPan: { + readonly SVG_ZOOMANDPAN_DISABLE: number; + readonly SVG_ZOOMANDPAN_MAGNIFY: number; + readonly SVG_ZOOMANDPAN_UNKNOWN: number; +} + +interface SVGZoomEvent extends UIEvent { + readonly newScale: number; + readonly newTranslate: SVGPoint; + readonly previousScale: number; + readonly previousTranslate: SVGPoint; + readonly zoomRectScreen: SVGRect; +} + +declare var SVGZoomEvent: { + prototype: SVGZoomEvent; + new(): SVGZoomEvent; +} + +interface ScopedCredential { + readonly id: ArrayBuffer; + readonly type: ScopedCredentialType; +} + +declare var ScopedCredential: { + prototype: ScopedCredential; + new(): ScopedCredential; +} + +interface ScopedCredentialInfo { + readonly credential: ScopedCredential; + readonly publicKey: CryptoKey; +} + +declare var ScopedCredentialInfo: { + prototype: ScopedCredentialInfo; + new(): ScopedCredentialInfo; +} + +interface ScreenEventMap { + "MSOrientationChange": Event; +} + +interface Screen extends EventTarget { + readonly availHeight: number; + readonly availWidth: number; + bufferDepth: number; + readonly colorDepth: number; + readonly deviceXDPI: number; + readonly deviceYDPI: number; + readonly fontSmoothingEnabled: boolean; + readonly height: number; + readonly logicalXDPI: number; + readonly logicalYDPI: number; + readonly msOrientation: string; + onmsorientationchange: (this: Screen, ev: Event) => any; + readonly pixelDepth: number; + readonly systemXDPI: number; + readonly systemYDPI: number; + readonly width: number; + msLockOrientation(orientations: string | string[]): boolean; + msUnlockOrientation(): void; + addEventListener(type: K, listener: (this: Screen, ev: ScreenEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Screen: { + prototype: Screen; + new(): Screen; +} + +interface ScriptNotifyEvent extends Event { + readonly callingUri: string; + readonly value: string; +} + +declare var ScriptNotifyEvent: { + prototype: ScriptNotifyEvent; + new(): ScriptNotifyEvent; +} + +interface ScriptProcessorNodeEventMap { + "audioprocess": AudioProcessingEvent; +} + +interface ScriptProcessorNode extends AudioNode { + readonly bufferSize: number; + onaudioprocess: (this: ScriptProcessorNode, ev: AudioProcessingEvent) => any; + addEventListener(type: K, listener: (this: ScriptProcessorNode, ev: ScriptProcessorNodeEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ScriptProcessorNode: { + prototype: ScriptProcessorNode; + new(): ScriptProcessorNode; +} + +interface Selection { + readonly anchorNode: Node; + readonly anchorOffset: number; + readonly baseNode: Node; + readonly baseOffset: number; + readonly extentNode: Node; + readonly extentOffset: number; + readonly focusNode: Node; + readonly focusOffset: number; + readonly isCollapsed: boolean; + readonly rangeCount: number; + readonly 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; + setPosition(parentNode: Node, offset: number): void; + toString(): string; +} + +declare var Selection: { + prototype: Selection; + new(): Selection; +} + +interface ServiceWorkerEventMap extends AbstractWorkerEventMap { + "statechange": Event; +} + +interface ServiceWorker extends EventTarget, AbstractWorker { + onstatechange: (this: ServiceWorker, ev: Event) => any; + readonly scriptURL: USVString; + readonly state: ServiceWorkerState; + postMessage(message: any, transfer?: any[]): void; + addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorker: { + prototype: ServiceWorker; + new(): ServiceWorker; +} + +interface ServiceWorkerContainerEventMap { + "controllerchange": Event; + "message": ServiceWorkerMessageEvent; +} + +interface ServiceWorkerContainer extends EventTarget { + readonly controller: ServiceWorker | null; + oncontrollerchange: (this: ServiceWorkerContainer, ev: Event) => any; + onmessage: (this: ServiceWorkerContainer, ev: ServiceWorkerMessageEvent) => any; + readonly ready: Promise; + getRegistration(clientURL?: USVString): Promise; + getRegistrations(): any; + register(scriptURL: USVString, options?: RegistrationOptions): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerContainer, ev: ServiceWorkerContainerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerContainer: { + prototype: ServiceWorkerContainer; + new(): ServiceWorkerContainer; +} + +interface ServiceWorkerMessageEvent extends Event { + readonly data: any; + readonly lastEventId: string; + readonly origin: string; + readonly ports: MessagePort[] | null; + readonly source: ServiceWorker | MessagePort | null; +} + +declare var ServiceWorkerMessageEvent: { + prototype: ServiceWorkerMessageEvent; + new(type: string, eventInitDict?: ServiceWorkerMessageEventInit): ServiceWorkerMessageEvent; +} + +interface ServiceWorkerRegistrationEventMap { + "updatefound": Event; +} + +interface ServiceWorkerRegistration extends EventTarget { + readonly active: ServiceWorker | null; + readonly installing: ServiceWorker | null; + onupdatefound: (this: ServiceWorkerRegistration, ev: Event) => any; + readonly pushManager: PushManager; + readonly scope: USVString; + readonly sync: SyncManager; + readonly waiting: ServiceWorker | null; + getNotifications(filter?: GetNotificationOptions): any; + showNotification(title: string, options?: NotificationOptions): Promise; + unregister(): Promise; + update(): Promise; + addEventListener(type: K, listener: (this: ServiceWorkerRegistration, ev: ServiceWorkerRegistrationEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var ServiceWorkerRegistration: { + prototype: ServiceWorkerRegistration; + new(): ServiceWorkerRegistration; +} + +interface SourceBuffer extends EventTarget { + appendWindowEnd: number; + appendWindowStart: number; + readonly audioTracks: AudioTrackList; + readonly buffered: TimeRanges; + mode: AppendMode; + timestampOffset: number; + readonly updating: boolean; + readonly 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 { + readonly length: number; + item(index: number): SourceBuffer; + [index: number]: SourceBuffer; +} + +declare var SourceBufferList: { + prototype: SourceBufferList; + new(): SourceBufferList; +} + +interface SpeechSynthesisEventMap { + "voiceschanged": Event; +} + +interface SpeechSynthesis extends EventTarget { + onvoiceschanged: (this: SpeechSynthesis, ev: Event) => any; + readonly paused: boolean; + readonly pending: boolean; + readonly speaking: boolean; + cancel(): void; + getVoices(): SpeechSynthesisVoice[]; + pause(): void; + resume(): void; + speak(utterance: SpeechSynthesisUtterance): void; + addEventListener(type: K, listener: (this: SpeechSynthesis, ev: SpeechSynthesisEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesis: { + prototype: SpeechSynthesis; + new(): SpeechSynthesis; +} + +interface SpeechSynthesisEvent extends Event { + readonly charIndex: number; + readonly elapsedTime: number; + readonly name: string; + readonly utterance: SpeechSynthesisUtterance | null; +} + +declare var SpeechSynthesisEvent: { + prototype: SpeechSynthesisEvent; + new(type: string, eventInitDict?: SpeechSynthesisEventInit): SpeechSynthesisEvent; +} + +interface SpeechSynthesisUtteranceEventMap { + "boundary": Event; + "end": Event; + "error": Event; + "mark": Event; + "pause": Event; + "resume": Event; + "start": Event; +} + +interface SpeechSynthesisUtterance extends EventTarget { + lang: string; + onboundary: (this: SpeechSynthesisUtterance, ev: Event) => any; + onend: (this: SpeechSynthesisUtterance, ev: Event) => any; + onerror: (this: SpeechSynthesisUtterance, ev: Event) => any; + onmark: (this: SpeechSynthesisUtterance, ev: Event) => any; + onpause: (this: SpeechSynthesisUtterance, ev: Event) => any; + onresume: (this: SpeechSynthesisUtterance, ev: Event) => any; + onstart: (this: SpeechSynthesisUtterance, ev: Event) => any; + pitch: number; + rate: number; + text: string; + voice: SpeechSynthesisVoice; + volume: number; + addEventListener(type: K, listener: (this: SpeechSynthesisUtterance, ev: SpeechSynthesisUtteranceEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var SpeechSynthesisUtterance: { + prototype: SpeechSynthesisUtterance; + new(text?: string): SpeechSynthesisUtterance; +} + +interface SpeechSynthesisVoice { + readonly default: boolean; + readonly lang: string; + readonly localService: boolean; + readonly name: string; + readonly voiceURI: string; +} + +declare var SpeechSynthesisVoice: { + prototype: SpeechSynthesisVoice; + new(): SpeechSynthesisVoice; +} + +interface StereoPannerNode extends AudioNode { + readonly pan: AudioParam; +} + +declare var StereoPannerNode: { + prototype: StereoPannerNode; + new(): StereoPannerNode; +} + +interface Storage { + readonly length: number; + clear(): void; + getItem(key: string): string | null; + key(index: number): string | null; + 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 { + readonly url: string; + key?: string; + oldValue?: string; + newValue?: string; + storageArea?: Storage; +} + +declare var StorageEvent: { + prototype: StorageEvent; + new (type: string, eventInitDict?: StorageEventInit): StorageEvent; +} + +interface StyleMedia { + readonly type: string; + matchMedium(mediaquery: string): boolean; +} + +declare var StyleMedia: { + prototype: StyleMedia; + new(): StyleMedia; +} + +interface StyleSheet { + disabled: boolean; + readonly href: string; + readonly media: MediaList; + readonly ownerNode: Node; + readonly parentStyleSheet: StyleSheet; + readonly title: string; + readonly type: string; +} + +declare var StyleSheet: { + prototype: StyleSheet; + new(): StyleSheet; +} + +interface StyleSheetList { + readonly length: number; + item(index?: number): StyleSheet; + [index: number]: StyleSheet; +} + +declare var StyleSheetList: { + prototype: StyleSheetList; + new(): StyleSheetList; +} + +interface StyleSheetPageList { + readonly length: number; + item(index: number): CSSPageRule; + [index: number]: CSSPageRule; +} + +declare var StyleSheetPageList: { + prototype: StyleSheetPageList; + new(): StyleSheetPageList; +} + +interface SubtleCrypto { + decrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike; + deriveBits(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, length: number): PromiseLike; + deriveKey(algorithm: string | EcdhKeyDeriveParams | DhKeyDeriveParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, baseKey: CryptoKey, derivedKeyType: string | AesDerivedKeyParams | HmacImportParams | ConcatParams | HkdfCtrParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike; + digest(algorithm: AlgorithmIdentifier, data: BufferSource): PromiseLike; + encrypt(algorithm: string | RsaOaepParams | AesCtrParams | AesCbcParams | AesCmacParams | AesGcmParams | AesCfbParams, key: CryptoKey, data: BufferSource): PromiseLike; + exportKey(format: "jwk", key: CryptoKey): PromiseLike; + exportKey(format: "raw" | "pkcs8" | "spki", key: CryptoKey): PromiseLike; + exportKey(format: string, key: CryptoKey): PromiseLike; + generateKey(algorithm: string, extractable: boolean, keyUsages: string[]): PromiseLike; + generateKey(algorithm: RsaHashedKeyGenParams | EcKeyGenParams | DhKeyGenParams, extractable: boolean, keyUsages: string[]): PromiseLike; + generateKey(algorithm: AesKeyGenParams | HmacKeyGenParams | Pbkdf2Params, extractable: boolean, keyUsages: string[]): PromiseLike; + importKey(format: "jwk", keyData: JsonWebKey, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + importKey(format: "raw" | "pkcs8" | "spki", keyData: BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + importKey(format: string, keyData: JsonWebKey | BufferSource, algorithm: string | RsaHashedImportParams | EcKeyImportParams | HmacImportParams | DhImportKeyParams, extractable:boolean, keyUsages: string[]): PromiseLike; + sign(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, data: BufferSource): PromiseLike; + unwrapKey(format: string, wrappedKey: BufferSource, unwrappingKey: CryptoKey, unwrapAlgorithm: AlgorithmIdentifier, unwrappedKeyAlgorithm: AlgorithmIdentifier, extractable: boolean, keyUsages: string[]): PromiseLike; + verify(algorithm: string | RsaPssParams | EcdsaParams | AesCmacParams, key: CryptoKey, signature: BufferSource, data: BufferSource): PromiseLike; + wrapKey(format: string, key: CryptoKey, wrappingKey: CryptoKey, wrapAlgorithm: AlgorithmIdentifier): PromiseLike; +} + +declare var SubtleCrypto: { + prototype: SubtleCrypto; + new(): SubtleCrypto; +} + +interface SyncManager { + getTags(): any; + register(tag: string): Promise; +} + +declare var SyncManager: { + prototype: SyncManager; + new(): SyncManager; +} + +interface Text extends CharacterData { + readonly wholeText: string; + readonly assignedSlot: HTMLSlotElement | null; + splitText(offset: number): Text; +} + +declare var Text: { + prototype: Text; + new(data?: string): Text; +} + +interface TextEvent extends UIEvent { + readonly data: string; + readonly inputMethod: number; + readonly locale: string; + initTextEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, dataArg: string, inputMethod: number, locale: string): void; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; +} + +declare var TextEvent: { + prototype: TextEvent; + new(): TextEvent; + readonly DOM_INPUT_METHOD_DROP: number; + readonly DOM_INPUT_METHOD_HANDWRITING: number; + readonly DOM_INPUT_METHOD_IME: number; + readonly DOM_INPUT_METHOD_KEYBOARD: number; + readonly DOM_INPUT_METHOD_MULTIMODAL: number; + readonly DOM_INPUT_METHOD_OPTION: number; + readonly DOM_INPUT_METHOD_PASTE: number; + readonly DOM_INPUT_METHOD_SCRIPT: number; + readonly DOM_INPUT_METHOD_UNKNOWN: number; + readonly DOM_INPUT_METHOD_VOICE: number; +} + +interface TextMetrics { + readonly width: number; +} + +declare var TextMetrics: { + prototype: TextMetrics; + new(): TextMetrics; +} + +interface TextTrackEventMap { + "cuechange": Event; + "error": Event; + "load": Event; +} + +interface TextTrack extends EventTarget { + readonly activeCues: TextTrackCueList; + readonly cues: TextTrackCueList; + readonly inBandMetadataTrackDispatchType: string; + readonly kind: string; + readonly label: string; + readonly language: string; + mode: any; + oncuechange: (this: TextTrack, ev: Event) => any; + onerror: (this: TextTrack, ev: Event) => any; + onload: (this: TextTrack, ev: Event) => any; + readonly readyState: number; + addCue(cue: TextTrackCue): void; + removeCue(cue: TextTrackCue): void; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; + addEventListener(type: K, listener: (this: TextTrack, ev: TextTrackEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var TextTrack: { + prototype: TextTrack; + new(): TextTrack; + readonly DISABLED: number; + readonly ERROR: number; + readonly HIDDEN: number; + readonly LOADED: number; + readonly LOADING: number; + readonly NONE: number; + readonly SHOWING: number; +} + +interface TextTrackCueEventMap { + "enter": Event; + "exit": Event; +} + +interface TextTrackCue extends EventTarget { + endTime: number; + id: string; + onenter: (this: TextTrackCue, ev: Event) => any; + onexit: (this: TextTrackCue, ev: Event) => any; + pauseOnExit: boolean; + startTime: number; + text: string; + readonly track: TextTrack; + getCueAsHTML(): DocumentFragment; + addEventListener(type: K, listener: (this: TextTrackCue, ev: TextTrackCueEventMap[K]) => 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 { + readonly length: number; + getCueById(id: string): TextTrackCue; + item(index: number): TextTrackCue; + [index: number]: TextTrackCue; +} + +declare var TextTrackCueList: { + prototype: TextTrackCueList; + new(): TextTrackCueList; +} + +interface TextTrackListEventMap { + "addtrack": TrackEvent; +} + +interface TextTrackList extends EventTarget { + readonly length: number; + onaddtrack: ((this: TextTrackList, ev: TrackEvent) => any) | null; + item(index: number): TextTrack; + addEventListener(type: K, listener: (this: TextTrackList, ev: TextTrackListEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; + [index: number]: TextTrack; +} + +declare var TextTrackList: { + prototype: TextTrackList; + new(): TextTrackList; +} + +interface TimeRanges { + readonly length: number; + end(index: number): number; + start(index: number): number; +} + +declare var TimeRanges: { + prototype: TimeRanges; + new(): TimeRanges; +} + +interface Touch { + readonly clientX: number; + readonly clientY: number; + readonly identifier: number; + readonly pageX: number; + readonly pageY: number; + readonly screenX: number; + readonly screenY: number; + readonly target: EventTarget; +} + +declare var Touch: { + prototype: Touch; + new(): Touch; +} + +interface TouchEvent extends UIEvent { + readonly altKey: boolean; + readonly changedTouches: TouchList; + readonly charCode: number; + readonly ctrlKey: boolean; + readonly keyCode: number; + readonly metaKey: boolean; + readonly shiftKey: boolean; + readonly targetTouches: TouchList; + readonly touches: TouchList; + readonly which: number; +} + +declare var TouchEvent: { + prototype: TouchEvent; + new(type: string, touchEventInit?: TouchEventInit): TouchEvent; +} + +interface TouchList { + readonly length: number; + item(index: number): Touch | null; + [index: number]: Touch; +} + +declare var TouchList: { + prototype: TouchList; + new(): TouchList; +} + +interface TrackEvent extends Event { + readonly track: VideoTrack | AudioTrack | TextTrack | null; +} + +declare var TrackEvent: { + prototype: TrackEvent; + new(typeArg: string, eventInitDict?: TrackEventInit): TrackEvent; +} + +interface TransitionEvent extends Event { + readonly elapsedTime: number; + readonly propertyName: string; + initTransitionEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, propertyNameArg: string, elapsedTimeArg: number): void; +} + +declare var TransitionEvent: { + prototype: TransitionEvent; + new(typeArg: string, eventInitDict?: TransitionEventInit): TransitionEvent; +} + +interface TreeWalker { + currentNode: Node; + readonly expandEntityReferences: boolean; + readonly filter: NodeFilter; + readonly root: Node; + readonly 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 { + readonly detail: number; + readonly view: Window; + initUIEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, viewArg: Window, detailArg: number): void; +} + +declare var UIEvent: { + prototype: UIEvent; + new(typeArg: string, eventInitDict?: UIEventInit): UIEvent; +} + +interface URL { + hash: string; + host: string; + hostname: string; + href: string; + readonly origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + username: string; + readonly searchParams: URLSearchParams; + toString(): string; +} + +declare var URL: { + prototype: URL; + new(url: string, base?: string): URL; + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} + +interface UnviewableContentIdentifiedEvent extends NavigationEventWithReferrer { + readonly mediaType: string; +} + +declare var UnviewableContentIdentifiedEvent: { + prototype: UnviewableContentIdentifiedEvent; + new(): UnviewableContentIdentifiedEvent; +} + +interface ValidityState { + readonly badInput: boolean; + readonly customError: boolean; + readonly patternMismatch: boolean; + readonly rangeOverflow: boolean; + readonly rangeUnderflow: boolean; + readonly stepMismatch: boolean; + readonly tooLong: boolean; + readonly typeMismatch: boolean; + readonly valid: boolean; + readonly valueMissing: boolean; +} + +declare var ValidityState: { + prototype: ValidityState; + new(): ValidityState; +} + +interface VideoPlaybackQuality { + readonly corruptedVideoFrames: number; + readonly creationTime: number; + readonly droppedVideoFrames: number; + readonly totalFrameDelay: number; + readonly totalVideoFrames: number; +} + +declare var VideoPlaybackQuality: { + prototype: VideoPlaybackQuality; + new(): VideoPlaybackQuality; +} + +interface VideoTrack { + readonly id: string; + kind: string; + readonly label: string; + language: string; + selected: boolean; + readonly sourceBuffer: SourceBuffer; +} + +declare var VideoTrack: { + prototype: VideoTrack; + new(): VideoTrack; +} + +interface VideoTrackListEventMap { + "addtrack": TrackEvent; + "change": Event; + "removetrack": TrackEvent; +} + +interface VideoTrackList extends EventTarget { + readonly length: number; + onaddtrack: (this: VideoTrackList, ev: TrackEvent) => any; + onchange: (this: VideoTrackList, ev: Event) => any; + onremovetrack: (this: VideoTrackList, ev: TrackEvent) => any; + readonly selectedIndex: number; + getTrackById(id: string): VideoTrack | null; + item(index: number): VideoTrack; + addEventListener(type: K, listener: (this: VideoTrackList, ev: VideoTrackListEventMap[K]) => 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 { + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +declare var WEBGL_compressed_texture_s3tc: { + prototype: WEBGL_compressed_texture_s3tc; + new(): WEBGL_compressed_texture_s3tc; + readonly COMPRESSED_RGBA_S3TC_DXT1_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT3_EXT: number; + readonly COMPRESSED_RGBA_S3TC_DXT5_EXT: number; + readonly COMPRESSED_RGB_S3TC_DXT1_EXT: number; +} + +interface WEBGL_debug_renderer_info { + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; +} + +declare var WEBGL_debug_renderer_info: { + prototype: WEBGL_debug_renderer_info; + new(): WEBGL_debug_renderer_info; + readonly UNMASKED_RENDERER_WEBGL: number; + readonly UNMASKED_VENDOR_WEBGL: number; +} + +interface WEBGL_depth_texture { + readonly UNSIGNED_INT_24_8_WEBGL: number; +} + +declare var WEBGL_depth_texture: { + prototype: WEBGL_depth_texture; + new(): WEBGL_depth_texture; + readonly UNSIGNED_INT_24_8_WEBGL: number; +} + +interface WaveShaperNode extends AudioNode { + curve: Float32Array | null; + oversample: OverSampleType; +} + +declare var WaveShaperNode: { + prototype: WaveShaperNode; + new(): WaveShaperNode; +} + +interface WebAuthentication { + getAssertion(assertionChallenge: any, options?: AssertionOptions): Promise; + makeCredential(accountInformation: Account, cryptoParameters: ScopedCredentialParameters[], attestationChallenge: any, options?: ScopedCredentialOptions): Promise; +} + +declare var WebAuthentication: { + prototype: WebAuthentication; + new(): WebAuthentication; +} + +interface WebAuthnAssertion { + readonly authenticatorData: ArrayBuffer; + readonly clientData: ArrayBuffer; + readonly credential: ScopedCredential; + readonly signature: ArrayBuffer; +} + +declare var WebAuthnAssertion: { + prototype: WebAuthnAssertion; + new(): WebAuthnAssertion; +} + +interface WebGLActiveInfo { + readonly name: string; + readonly size: number; + readonly type: number; +} + +declare var WebGLActiveInfo: { + prototype: WebGLActiveInfo; + new(): WebGLActiveInfo; +} + +interface WebGLBuffer extends WebGLObject { +} + +declare var WebGLBuffer: { + prototype: WebGLBuffer; + new(): WebGLBuffer; +} + +interface WebGLContextEvent extends Event { + readonly statusMessage: string; +} + +declare var WebGLContextEvent: { + prototype: WebGLContextEvent; + new(typeArg: string, eventInitDict?: WebGLContextEventInit): 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 { + readonly canvas: HTMLCanvasElement; + readonly drawingBufferHeight: number; + readonly drawingBufferWidth: number; + activeTexture(texture: number): void; + attachShader(program: WebGLProgram | null, shader: WebGLShader | null): void; + bindAttribLocation(program: WebGLProgram | null, index: number, name: string): void; + bindBuffer(target: number, buffer: WebGLBuffer | null): void; + bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void; + bindRenderbuffer(target: number, renderbuffer: WebGLRenderbuffer | null): void; + bindTexture(target: number, texture: WebGLTexture | null): 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 | null): 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 | null; + createFramebuffer(): WebGLFramebuffer | null; + createProgram(): WebGLProgram | null; + createRenderbuffer(): WebGLRenderbuffer | null; + createShader(type: number): WebGLShader | null; + createTexture(): WebGLTexture | null; + cullFace(mode: number): void; + deleteBuffer(buffer: WebGLBuffer | null): void; + deleteFramebuffer(framebuffer: WebGLFramebuffer | null): void; + deleteProgram(program: WebGLProgram | null): void; + deleteRenderbuffer(renderbuffer: WebGLRenderbuffer | null): void; + deleteShader(shader: WebGLShader | null): void; + deleteTexture(texture: WebGLTexture | null): void; + depthFunc(func: number): void; + depthMask(flag: boolean): void; + depthRange(zNear: number, zFar: number): void; + detachShader(program: WebGLProgram | null, shader: WebGLShader | null): 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 | null): void; + framebufferTexture2D(target: number, attachment: number, textarget: number, texture: WebGLTexture | null, level: number): void; + frontFace(mode: number): void; + generateMipmap(target: number): void; + getActiveAttrib(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getActiveUniform(program: WebGLProgram | null, index: number): WebGLActiveInfo | null; + getAttachedShaders(program: WebGLProgram | null): WebGLShader[] | null; + getAttribLocation(program: WebGLProgram | null, 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 | null): string | null; + getProgramParameter(program: WebGLProgram | null, pname: number): any; + getRenderbufferParameter(target: number, pname: number): any; + getShaderInfoLog(shader: WebGLShader | null): string | null; + getShaderParameter(shader: WebGLShader | null, pname: number): any; + getShaderPrecisionFormat(shadertype: number, precisiontype: number): WebGLShaderPrecisionFormat | null; + getShaderSource(shader: WebGLShader | null): string | null; + getSupportedExtensions(): string[] | null; + getTexParameter(target: number, pname: number): any; + getUniform(program: WebGLProgram | null, location: WebGLUniformLocation | null): any; + getUniformLocation(program: WebGLProgram | null, name: string): WebGLUniformLocation | null; + getVertexAttrib(index: number, pname: number): any; + getVertexAttribOffset(index: number, pname: number): number; + hint(target: number, mode: number): void; + isBuffer(buffer: WebGLBuffer | null): boolean; + isContextLost(): boolean; + isEnabled(cap: number): boolean; + isFramebuffer(framebuffer: WebGLFramebuffer | null): boolean; + isProgram(program: WebGLProgram | null): boolean; + isRenderbuffer(renderbuffer: WebGLRenderbuffer | null): boolean; + isShader(shader: WebGLShader | null): boolean; + isTexture(texture: WebGLTexture | null): boolean; + lineWidth(width: number): void; + linkProgram(program: WebGLProgram | null): void; + pixelStorei(pname: number, param: number | boolean): void; + polygonOffset(factor: number, units: number): void; + readPixels(x: number, y: number, width: number, height: number, format: number, type: number, pixels: ArrayBufferView | null): 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 | null, 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 | null): void; + texImage2D(target: number, level: number, internalformat: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): 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 | null): void; + texSubImage2D(target: number, level: number, xoffset: number, yoffset: number, format: number, type: number, pixels: ImageBitmap | ImageData | HTMLVideoElement | HTMLImageElement | HTMLCanvasElement): void; + uniform1f(location: WebGLUniformLocation | null, x: number): void; + uniform1fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform1i(location: WebGLUniformLocation | null, x: number): void; + uniform1iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform2f(location: WebGLUniformLocation | null, x: number, y: number): void; + uniform2fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform2i(location: WebGLUniformLocation | null, x: number, y: number): void; + uniform2iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform3f(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; + uniform3fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform3i(location: WebGLUniformLocation | null, x: number, y: number, z: number): void; + uniform3iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniform4f(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; + uniform4fv(location: WebGLUniformLocation, v: Float32Array | number[]): void; + uniform4i(location: WebGLUniformLocation | null, x: number, y: number, z: number, w: number): void; + uniform4iv(location: WebGLUniformLocation, v: Int32Array | number[]): void; + uniformMatrix2fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniformMatrix3fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + uniformMatrix4fv(location: WebGLUniformLocation, transpose: boolean, value: Float32Array | number[]): void; + useProgram(program: WebGLProgram | null): void; + validateProgram(program: WebGLProgram | null): void; + vertexAttrib1f(indx: number, x: number): void; + vertexAttrib1fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib2f(indx: number, x: number, y: number): void; + vertexAttrib2fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib3f(indx: number, x: number, y: number, z: number): void; + vertexAttrib3fv(indx: number, values: Float32Array | number[]): void; + vertexAttrib4f(indx: number, x: number, y: number, z: number, w: number): void; + vertexAttrib4fv(indx: number, values: Float32Array | number[]): 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; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; +} + +declare var WebGLRenderingContext: { + prototype: WebGLRenderingContext; + new(): WebGLRenderingContext; + readonly ACTIVE_ATTRIBUTES: number; + readonly ACTIVE_TEXTURE: number; + readonly ACTIVE_UNIFORMS: number; + readonly ALIASED_LINE_WIDTH_RANGE: number; + readonly ALIASED_POINT_SIZE_RANGE: number; + readonly ALPHA: number; + readonly ALPHA_BITS: number; + readonly ALWAYS: number; + readonly ARRAY_BUFFER: number; + readonly ARRAY_BUFFER_BINDING: number; + readonly ATTACHED_SHADERS: number; + readonly BACK: number; + readonly BLEND: number; + readonly BLEND_COLOR: number; + readonly BLEND_DST_ALPHA: number; + readonly BLEND_DST_RGB: number; + readonly BLEND_EQUATION: number; + readonly BLEND_EQUATION_ALPHA: number; + readonly BLEND_EQUATION_RGB: number; + readonly BLEND_SRC_ALPHA: number; + readonly BLEND_SRC_RGB: number; + readonly BLUE_BITS: number; + readonly BOOL: number; + readonly BOOL_VEC2: number; + readonly BOOL_VEC3: number; + readonly BOOL_VEC4: number; + readonly BROWSER_DEFAULT_WEBGL: number; + readonly BUFFER_SIZE: number; + readonly BUFFER_USAGE: number; + readonly BYTE: number; + readonly CCW: number; + readonly CLAMP_TO_EDGE: number; + readonly COLOR_ATTACHMENT0: number; + readonly COLOR_BUFFER_BIT: number; + readonly COLOR_CLEAR_VALUE: number; + readonly COLOR_WRITEMASK: number; + readonly COMPILE_STATUS: number; + readonly COMPRESSED_TEXTURE_FORMATS: number; + readonly CONSTANT_ALPHA: number; + readonly CONSTANT_COLOR: number; + readonly CONTEXT_LOST_WEBGL: number; + readonly CULL_FACE: number; + readonly CULL_FACE_MODE: number; + readonly CURRENT_PROGRAM: number; + readonly CURRENT_VERTEX_ATTRIB: number; + readonly CW: number; + readonly DECR: number; + readonly DECR_WRAP: number; + readonly DELETE_STATUS: number; + readonly DEPTH_ATTACHMENT: number; + readonly DEPTH_BITS: number; + readonly DEPTH_BUFFER_BIT: number; + readonly DEPTH_CLEAR_VALUE: number; + readonly DEPTH_COMPONENT: number; + readonly DEPTH_COMPONENT16: number; + readonly DEPTH_FUNC: number; + readonly DEPTH_RANGE: number; + readonly DEPTH_STENCIL: number; + readonly DEPTH_STENCIL_ATTACHMENT: number; + readonly DEPTH_TEST: number; + readonly DEPTH_WRITEMASK: number; + readonly DITHER: number; + readonly DONT_CARE: number; + readonly DST_ALPHA: number; + readonly DST_COLOR: number; + readonly DYNAMIC_DRAW: number; + readonly ELEMENT_ARRAY_BUFFER: number; + readonly ELEMENT_ARRAY_BUFFER_BINDING: number; + readonly EQUAL: number; + readonly FASTEST: number; + readonly FLOAT: number; + readonly FLOAT_MAT2: number; + readonly FLOAT_MAT3: number; + readonly FLOAT_MAT4: number; + readonly FLOAT_VEC2: number; + readonly FLOAT_VEC3: number; + readonly FLOAT_VEC4: number; + readonly FRAGMENT_SHADER: number; + readonly FRAMEBUFFER: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: number; + readonly FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: number; + readonly FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: number; + readonly FRAMEBUFFER_BINDING: number; + readonly FRAMEBUFFER_COMPLETE: number; + readonly FRAMEBUFFER_INCOMPLETE_ATTACHMENT: number; + readonly FRAMEBUFFER_INCOMPLETE_DIMENSIONS: number; + readonly FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: number; + readonly FRAMEBUFFER_UNSUPPORTED: number; + readonly FRONT: number; + readonly FRONT_AND_BACK: number; + readonly FRONT_FACE: number; + readonly FUNC_ADD: number; + readonly FUNC_REVERSE_SUBTRACT: number; + readonly FUNC_SUBTRACT: number; + readonly GENERATE_MIPMAP_HINT: number; + readonly GEQUAL: number; + readonly GREATER: number; + readonly GREEN_BITS: number; + readonly HIGH_FLOAT: number; + readonly HIGH_INT: number; + readonly IMPLEMENTATION_COLOR_READ_FORMAT: number; + readonly IMPLEMENTATION_COLOR_READ_TYPE: number; + readonly INCR: number; + readonly INCR_WRAP: number; + readonly INT: number; + readonly INT_VEC2: number; + readonly INT_VEC3: number; + readonly INT_VEC4: number; + readonly INVALID_ENUM: number; + readonly INVALID_FRAMEBUFFER_OPERATION: number; + readonly INVALID_OPERATION: number; + readonly INVALID_VALUE: number; + readonly INVERT: number; + readonly KEEP: number; + readonly LEQUAL: number; + readonly LESS: number; + readonly LINEAR: number; + readonly LINEAR_MIPMAP_LINEAR: number; + readonly LINEAR_MIPMAP_NEAREST: number; + readonly LINES: number; + readonly LINE_LOOP: number; + readonly LINE_STRIP: number; + readonly LINE_WIDTH: number; + readonly LINK_STATUS: number; + readonly LOW_FLOAT: number; + readonly LOW_INT: number; + readonly LUMINANCE: number; + readonly LUMINANCE_ALPHA: number; + readonly MAX_COMBINED_TEXTURE_IMAGE_UNITS: number; + readonly MAX_CUBE_MAP_TEXTURE_SIZE: number; + readonly MAX_FRAGMENT_UNIFORM_VECTORS: number; + readonly MAX_RENDERBUFFER_SIZE: number; + readonly MAX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_TEXTURE_SIZE: number; + readonly MAX_VARYING_VECTORS: number; + readonly MAX_VERTEX_ATTRIBS: number; + readonly MAX_VERTEX_TEXTURE_IMAGE_UNITS: number; + readonly MAX_VERTEX_UNIFORM_VECTORS: number; + readonly MAX_VIEWPORT_DIMS: number; + readonly MEDIUM_FLOAT: number; + readonly MEDIUM_INT: number; + readonly MIRRORED_REPEAT: number; + readonly NEAREST: number; + readonly NEAREST_MIPMAP_LINEAR: number; + readonly NEAREST_MIPMAP_NEAREST: number; + readonly NEVER: number; + readonly NICEST: number; + readonly NONE: number; + readonly NOTEQUAL: number; + readonly NO_ERROR: number; + readonly ONE: number; + readonly ONE_MINUS_CONSTANT_ALPHA: number; + readonly ONE_MINUS_CONSTANT_COLOR: number; + readonly ONE_MINUS_DST_ALPHA: number; + readonly ONE_MINUS_DST_COLOR: number; + readonly ONE_MINUS_SRC_ALPHA: number; + readonly ONE_MINUS_SRC_COLOR: number; + readonly OUT_OF_MEMORY: number; + readonly PACK_ALIGNMENT: number; + readonly POINTS: number; + readonly POLYGON_OFFSET_FACTOR: number; + readonly POLYGON_OFFSET_FILL: number; + readonly POLYGON_OFFSET_UNITS: number; + readonly RED_BITS: number; + readonly RENDERBUFFER: number; + readonly RENDERBUFFER_ALPHA_SIZE: number; + readonly RENDERBUFFER_BINDING: number; + readonly RENDERBUFFER_BLUE_SIZE: number; + readonly RENDERBUFFER_DEPTH_SIZE: number; + readonly RENDERBUFFER_GREEN_SIZE: number; + readonly RENDERBUFFER_HEIGHT: number; + readonly RENDERBUFFER_INTERNAL_FORMAT: number; + readonly RENDERBUFFER_RED_SIZE: number; + readonly RENDERBUFFER_STENCIL_SIZE: number; + readonly RENDERBUFFER_WIDTH: number; + readonly RENDERER: number; + readonly REPEAT: number; + readonly REPLACE: number; + readonly RGB: number; + readonly RGB565: number; + readonly RGB5_A1: number; + readonly RGBA: number; + readonly RGBA4: number; + readonly SAMPLER_2D: number; + readonly SAMPLER_CUBE: number; + readonly SAMPLES: number; + readonly SAMPLE_ALPHA_TO_COVERAGE: number; + readonly SAMPLE_BUFFERS: number; + readonly SAMPLE_COVERAGE: number; + readonly SAMPLE_COVERAGE_INVERT: number; + readonly SAMPLE_COVERAGE_VALUE: number; + readonly SCISSOR_BOX: number; + readonly SCISSOR_TEST: number; + readonly SHADER_TYPE: number; + readonly SHADING_LANGUAGE_VERSION: number; + readonly SHORT: number; + readonly SRC_ALPHA: number; + readonly SRC_ALPHA_SATURATE: number; + readonly SRC_COLOR: number; + readonly STATIC_DRAW: number; + readonly STENCIL_ATTACHMENT: number; + readonly STENCIL_BACK_FAIL: number; + readonly STENCIL_BACK_FUNC: number; + readonly STENCIL_BACK_PASS_DEPTH_FAIL: number; + readonly STENCIL_BACK_PASS_DEPTH_PASS: number; + readonly STENCIL_BACK_REF: number; + readonly STENCIL_BACK_VALUE_MASK: number; + readonly STENCIL_BACK_WRITEMASK: number; + readonly STENCIL_BITS: number; + readonly STENCIL_BUFFER_BIT: number; + readonly STENCIL_CLEAR_VALUE: number; + readonly STENCIL_FAIL: number; + readonly STENCIL_FUNC: number; + readonly STENCIL_INDEX: number; + readonly STENCIL_INDEX8: number; + readonly STENCIL_PASS_DEPTH_FAIL: number; + readonly STENCIL_PASS_DEPTH_PASS: number; + readonly STENCIL_REF: number; + readonly STENCIL_TEST: number; + readonly STENCIL_VALUE_MASK: number; + readonly STENCIL_WRITEMASK: number; + readonly STREAM_DRAW: number; + readonly SUBPIXEL_BITS: number; + readonly TEXTURE: number; + readonly TEXTURE0: number; + readonly TEXTURE1: number; + readonly TEXTURE10: number; + readonly TEXTURE11: number; + readonly TEXTURE12: number; + readonly TEXTURE13: number; + readonly TEXTURE14: number; + readonly TEXTURE15: number; + readonly TEXTURE16: number; + readonly TEXTURE17: number; + readonly TEXTURE18: number; + readonly TEXTURE19: number; + readonly TEXTURE2: number; + readonly TEXTURE20: number; + readonly TEXTURE21: number; + readonly TEXTURE22: number; + readonly TEXTURE23: number; + readonly TEXTURE24: number; + readonly TEXTURE25: number; + readonly TEXTURE26: number; + readonly TEXTURE27: number; + readonly TEXTURE28: number; + readonly TEXTURE29: number; + readonly TEXTURE3: number; + readonly TEXTURE30: number; + readonly TEXTURE31: number; + readonly TEXTURE4: number; + readonly TEXTURE5: number; + readonly TEXTURE6: number; + readonly TEXTURE7: number; + readonly TEXTURE8: number; + readonly TEXTURE9: number; + readonly TEXTURE_2D: number; + readonly TEXTURE_BINDING_2D: number; + readonly TEXTURE_BINDING_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_X: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Y: number; + readonly TEXTURE_CUBE_MAP_NEGATIVE_Z: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_X: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Y: number; + readonly TEXTURE_CUBE_MAP_POSITIVE_Z: number; + readonly TEXTURE_MAG_FILTER: number; + readonly TEXTURE_MIN_FILTER: number; + readonly TEXTURE_WRAP_S: number; + readonly TEXTURE_WRAP_T: number; + readonly TRIANGLES: number; + readonly TRIANGLE_FAN: number; + readonly TRIANGLE_STRIP: number; + readonly UNPACK_ALIGNMENT: number; + readonly UNPACK_COLORSPACE_CONVERSION_WEBGL: number; + readonly UNPACK_FLIP_Y_WEBGL: number; + readonly UNPACK_PREMULTIPLY_ALPHA_WEBGL: number; + readonly UNSIGNED_BYTE: number; + readonly UNSIGNED_INT: number; + readonly UNSIGNED_SHORT: number; + readonly UNSIGNED_SHORT_4_4_4_4: number; + readonly UNSIGNED_SHORT_5_5_5_1: number; + readonly UNSIGNED_SHORT_5_6_5: number; + readonly VALIDATE_STATUS: number; + readonly VENDOR: number; + readonly VERSION: number; + readonly VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: number; + readonly VERTEX_ATTRIB_ARRAY_ENABLED: number; + readonly VERTEX_ATTRIB_ARRAY_NORMALIZED: number; + readonly VERTEX_ATTRIB_ARRAY_POINTER: number; + readonly VERTEX_ATTRIB_ARRAY_SIZE: number; + readonly VERTEX_ATTRIB_ARRAY_STRIDE: number; + readonly VERTEX_ATTRIB_ARRAY_TYPE: number; + readonly VERTEX_SHADER: number; + readonly VIEWPORT: number; + readonly ZERO: number; +} + +interface WebGLShader extends WebGLObject { +} + +declare var WebGLShader: { + prototype: WebGLShader; + new(): WebGLShader; +} + +interface WebGLShaderPrecisionFormat { + readonly precision: number; + readonly rangeMax: number; + readonly 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 WebKitDirectoryEntry extends WebKitEntry { + createReader(): WebKitDirectoryReader; +} + +declare var WebKitDirectoryEntry: { + prototype: WebKitDirectoryEntry; + new(): WebKitDirectoryEntry; +} + +interface WebKitDirectoryReader { + readEntries(successCallback: WebKitEntriesCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitDirectoryReader: { + prototype: WebKitDirectoryReader; + new(): WebKitDirectoryReader; +} + +interface WebKitEntry { + readonly filesystem: WebKitFileSystem; + readonly fullPath: string; + readonly isDirectory: boolean; + readonly isFile: boolean; + readonly name: string; +} + +declare var WebKitEntry: { + prototype: WebKitEntry; + new(): WebKitEntry; +} + +interface WebKitFileEntry extends WebKitEntry { + file(successCallback: WebKitFileCallback, errorCallback?: WebKitErrorCallback): void; +} + +declare var WebKitFileEntry: { + prototype: WebKitFileEntry; + new(): WebKitFileEntry; +} + +interface WebKitFileSystem { + readonly name: string; + readonly root: WebKitDirectoryEntry; +} + +declare var WebKitFileSystem: { + prototype: WebKitFileSystem; + new(): WebKitFileSystem; +} + +interface WebKitPoint { + x: number; + y: number; +} + +declare var WebKitPoint: { + prototype: WebKitPoint; + new(x?: number, y?: number): WebKitPoint; +} + +interface WebSocketEventMap { + "close": CloseEvent; + "error": Event; + "message": MessageEvent; + "open": Event; +} + +interface WebSocket extends EventTarget { + binaryType: string; + readonly bufferedAmount: number; + readonly extensions: string; + onclose: (this: WebSocket, ev: CloseEvent) => any; + onerror: (this: WebSocket, ev: Event) => any; + onmessage: (this: WebSocket, ev: MessageEvent) => any; + onopen: (this: WebSocket, ev: Event) => any; + readonly protocol: string; + readonly readyState: number; + readonly url: string; + close(code?: number, reason?: string): void; + send(data: any): void; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; + addEventListener(type: K, listener: (this: WebSocket, ev: WebSocketEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var WebSocket: { + prototype: WebSocket; + new(url: string, protocols?: string | string[]): WebSocket; + readonly CLOSED: number; + readonly CLOSING: number; + readonly CONNECTING: number; + readonly OPEN: number; +} + +interface WheelEvent extends MouseEvent { + readonly deltaMode: number; + readonly deltaX: number; + readonly deltaY: number; + readonly deltaZ: number; + readonly wheelDelta: number; + readonly wheelDeltaX: number; + readonly wheelDeltaY: 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; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; +} + +declare var WheelEvent: { + prototype: WheelEvent; + new(typeArg: string, eventInitDict?: WheelEventInit): WheelEvent; + readonly DOM_DELTA_LINE: number; + readonly DOM_DELTA_PAGE: number; + readonly DOM_DELTA_PIXEL: number; +} + +interface WindowEventMap extends GlobalEventHandlersEventMap { + "abort": UIEvent; + "afterprint": Event; + "beforeprint": Event; + "beforeunload": BeforeUnloadEvent; + "blur": FocusEvent; + "canplay": Event; + "canplaythrough": Event; + "change": Event; + "click": MouseEvent; + "compassneedscalibration": Event; + "contextmenu": PointerEvent; + "dblclick": MouseEvent; + "devicelight": DeviceLightEvent; + "devicemotion": DeviceMotionEvent; + "deviceorientation": DeviceOrientationEvent; + "drag": DragEvent; + "dragend": DragEvent; + "dragenter": DragEvent; + "dragleave": DragEvent; + "dragover": DragEvent; + "dragstart": DragEvent; + "drop": DragEvent; + "durationchange": Event; + "emptied": Event; + "ended": MediaStreamErrorEvent; + "focus": FocusEvent; + "hashchange": HashChangeEvent; + "input": Event; + "invalid": Event; + "keydown": KeyboardEvent; + "keypress": KeyboardEvent; + "keyup": KeyboardEvent; + "load": Event; + "loadeddata": Event; + "loadedmetadata": Event; + "loadstart": Event; + "message": MessageEvent; + "mousedown": MouseEvent; + "mouseenter": MouseEvent; + "mouseleave": MouseEvent; + "mousemove": MouseEvent; + "mouseout": MouseEvent; + "mouseover": MouseEvent; + "mouseup": MouseEvent; + "mousewheel": WheelEvent; + "MSGestureChange": MSGestureEvent; + "MSGestureDoubleTap": MSGestureEvent; + "MSGestureEnd": MSGestureEvent; + "MSGestureHold": MSGestureEvent; + "MSGestureStart": MSGestureEvent; + "MSGestureTap": MSGestureEvent; + "MSInertiaStart": MSGestureEvent; + "MSPointerCancel": MSPointerEvent; + "MSPointerDown": MSPointerEvent; + "MSPointerEnter": MSPointerEvent; + "MSPointerLeave": MSPointerEvent; + "MSPointerMove": MSPointerEvent; + "MSPointerOut": MSPointerEvent; + "MSPointerOver": MSPointerEvent; + "MSPointerUp": MSPointerEvent; + "offline": Event; + "online": Event; + "orientationchange": Event; + "pagehide": PageTransitionEvent; + "pageshow": PageTransitionEvent; + "pause": Event; + "play": Event; + "playing": Event; + "popstate": PopStateEvent; + "progress": ProgressEvent; + "ratechange": Event; + "readystatechange": ProgressEvent; + "reset": Event; + "resize": UIEvent; + "scroll": UIEvent; + "seeked": Event; + "seeking": Event; + "select": UIEvent; + "stalled": Event; + "storage": StorageEvent; + "submit": Event; + "suspend": Event; + "timeupdate": Event; + "unload": Event; + "volumechange": Event; + "waiting": Event; +} + +interface Window extends EventTarget, WindowTimers, WindowSessionStorage, WindowLocalStorage, WindowConsole, GlobalEventHandlers, IDBEnvironment, WindowBase64, GlobalFetch { + readonly applicationCache: ApplicationCache; + readonly caches: CacheStorage; + readonly clientInformation: Navigator; + readonly closed: boolean; + readonly crypto: Crypto; + defaultStatus: string; + readonly devicePixelRatio: number; + readonly doNotTrack: string; + readonly document: Document; + event: Event | undefined; + readonly external: External; + readonly frameElement: Element; + readonly frames: Window; + readonly history: History; + readonly innerHeight: number; + readonly innerWidth: number; + readonly isSecureContext: boolean; + readonly length: number; + readonly location: Location; + readonly locationbar: BarProp; + readonly menubar: BarProp; + readonly msContentScript: ExtensionScriptApis; + readonly msCredentials: MSCredentials; + name: string; + readonly navigator: Navigator; + offscreenBuffering: string | boolean; + onabort: (this: Window, ev: UIEvent) => any; + onafterprint: (this: Window, ev: Event) => any; + onbeforeprint: (this: Window, ev: Event) => any; + onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; + onblur: (this: Window, ev: FocusEvent) => any; + oncanplay: (this: Window, ev: Event) => any; + oncanplaythrough: (this: Window, ev: Event) => any; + onchange: (this: Window, ev: Event) => any; + onclick: (this: Window, ev: MouseEvent) => any; + oncompassneedscalibration: (this: Window, ev: Event) => any; + oncontextmenu: (this: Window, ev: PointerEvent) => any; + ondblclick: (this: Window, ev: MouseEvent) => any; + ondevicelight: (this: Window, ev: DeviceLightEvent) => any; + ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; + ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; + ondrag: (this: Window, ev: DragEvent) => any; + ondragend: (this: Window, ev: DragEvent) => any; + ondragenter: (this: Window, ev: DragEvent) => any; + ondragleave: (this: Window, ev: DragEvent) => any; + ondragover: (this: Window, ev: DragEvent) => any; + ondragstart: (this: Window, ev: DragEvent) => any; + ondrop: (this: Window, ev: DragEvent) => any; + ondurationchange: (this: Window, ev: Event) => any; + onemptied: (this: Window, ev: Event) => any; + onended: (this: Window, ev: MediaStreamErrorEvent) => any; + onerror: ErrorEventHandler; + onfocus: (this: Window, ev: FocusEvent) => any; + onhashchange: (this: Window, ev: HashChangeEvent) => any; + oninput: (this: Window, ev: Event) => any; + oninvalid: (this: Window, ev: Event) => any; + onkeydown: (this: Window, ev: KeyboardEvent) => any; + onkeypress: (this: Window, ev: KeyboardEvent) => any; + onkeyup: (this: Window, ev: KeyboardEvent) => any; + onload: (this: Window, ev: Event) => any; + onloadeddata: (this: Window, ev: Event) => any; + onloadedmetadata: (this: Window, ev: Event) => any; + onloadstart: (this: Window, ev: Event) => any; + onmessage: (this: Window, ev: MessageEvent) => any; + onmousedown: (this: Window, ev: MouseEvent) => any; + onmouseenter: (this: Window, ev: MouseEvent) => any; + onmouseleave: (this: Window, ev: MouseEvent) => any; + onmousemove: (this: Window, ev: MouseEvent) => any; + onmouseout: (this: Window, ev: MouseEvent) => any; + onmouseover: (this: Window, ev: MouseEvent) => any; + onmouseup: (this: Window, ev: MouseEvent) => any; + onmousewheel: (this: Window, ev: WheelEvent) => any; + onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; + onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; + onmsgestureend: (this: Window, ev: MSGestureEvent) => any; + onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; + onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; + onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; + onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; + onmspointercancel: (this: Window, ev: MSPointerEvent) => any; + onmspointerdown: (this: Window, ev: MSPointerEvent) => any; + onmspointerenter: (this: Window, ev: MSPointerEvent) => any; + onmspointerleave: (this: Window, ev: MSPointerEvent) => any; + onmspointermove: (this: Window, ev: MSPointerEvent) => any; + onmspointerout: (this: Window, ev: MSPointerEvent) => any; + onmspointerover: (this: Window, ev: MSPointerEvent) => any; + onmspointerup: (this: Window, ev: MSPointerEvent) => any; + onoffline: (this: Window, ev: Event) => any; + ononline: (this: Window, ev: Event) => any; + onorientationchange: (this: Window, ev: Event) => any; + onpagehide: (this: Window, ev: PageTransitionEvent) => any; + onpageshow: (this: Window, ev: PageTransitionEvent) => any; + onpause: (this: Window, ev: Event) => any; + onplay: (this: Window, ev: Event) => any; + onplaying: (this: Window, ev: Event) => any; + onpopstate: (this: Window, ev: PopStateEvent) => any; + onprogress: (this: Window, ev: ProgressEvent) => any; + onratechange: (this: Window, ev: Event) => any; + onreadystatechange: (this: Window, ev: ProgressEvent) => any; + onreset: (this: Window, ev: Event) => any; + onresize: (this: Window, ev: UIEvent) => any; + onscroll: (this: Window, ev: UIEvent) => any; + onseeked: (this: Window, ev: Event) => any; + onseeking: (this: Window, ev: Event) => any; + onselect: (this: Window, ev: UIEvent) => any; + onstalled: (this: Window, ev: Event) => any; + onstorage: (this: Window, ev: StorageEvent) => any; + onsubmit: (this: Window, ev: Event) => any; + onsuspend: (this: Window, ev: Event) => any; + ontimeupdate: (this: Window, ev: Event) => any; + ontouchcancel: (ev: TouchEvent) => any; + ontouchend: (ev: TouchEvent) => any; + ontouchmove: (ev: TouchEvent) => any; + ontouchstart: (ev: TouchEvent) => any; + onunload: (this: Window, ev: Event) => any; + onvolumechange: (this: Window, ev: Event) => any; + onwaiting: (this: Window, ev: Event) => any; + opener: any; + orientation: string | number; + readonly outerHeight: number; + readonly outerWidth: number; + readonly pageXOffset: number; + readonly pageYOffset: number; + readonly parent: Window; + readonly performance: Performance; + readonly personalbar: BarProp; + readonly screen: Screen; + readonly screenLeft: number; + readonly screenTop: number; + readonly screenX: number; + readonly screenY: number; + readonly scrollX: number; + readonly scrollY: number; + readonly scrollbars: BarProp; + readonly self: Window; + readonly speechSynthesis: SpeechSynthesis; + status: string; + readonly statusbar: BarProp; + readonly styleMedia: StyleMedia; + readonly toolbar: BarProp; + readonly top: Window; + readonly window: Window; + URL: typeof URL; + URLSearchParams: typeof URLSearchParams; + Blob: typeof Blob; + customElements: CustomElementRegistry; + alert(message?: any): void; + blur(): void; + cancelAnimationFrame(handle: number): void; + captureEvents(): void; + close(): void; + confirm(message?: string): boolean; + departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; + 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; + msWriteProfilerMark(profilerMarkName: string): void; + open(url?: string, target?: string, features?: string, replace?: boolean): Window; + postMessage(message: any, targetOrigin: string, transfer?: any[]): void; + print(): void; + prompt(message?: string, _default?: string): string | null; + 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; + stop(): void; + webkitCancelAnimationFrame(handle: number): void; + webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; + webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; + webkitRequestAnimationFrame(callback: FrameRequestCallback): number; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; + scroll(options?: ScrollToOptions): void; + scrollTo(options?: ScrollToOptions): void; + scrollBy(options?: ScrollToOptions): void; + addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var Window: { + prototype: Window; + new(): Window; +} + +interface WorkerEventMap extends AbstractWorkerEventMap { + "message": MessageEvent; +} + +interface Worker extends EventTarget, AbstractWorker { + onmessage: (this: Worker, ev: MessageEvent) => any; + postMessage(message: any, transfer?: any[]): void; + terminate(): void; + addEventListener(type: K, listener: (this: Worker, ev: WorkerEventMap[K]) => 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 { + addEventListener(type: K, listener: (this: XMLDocument, ev: DocumentEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLDocument: { + prototype: XMLDocument; + new(): XMLDocument; +} + +interface XMLHttpRequestEventMap extends XMLHttpRequestEventTargetEventMap { + "readystatechange": Event; +} + +interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { + onreadystatechange: (this: XMLHttpRequest, ev: Event) => any; + readonly readyState: number; + readonly response: any; + readonly responseText: string; + responseType: XMLHttpRequestResponseType; + readonly responseURL: string; + readonly responseXML: Document | null; + readonly status: number; + readonly statusText: string; + timeout: number; + readonly upload: XMLHttpRequestUpload; + withCredentials: boolean; + msCaching?: string; + abort(): void; + getAllResponseHeaders(): string; + getResponseHeader(header: string): string | null; + 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; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; + addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var XMLHttpRequest: { + prototype: XMLHttpRequest; + new(): XMLHttpRequest; + readonly DONE: number; + readonly HEADERS_RECEIVED: number; + readonly LOADING: number; + readonly OPENED: number; + readonly UNSENT: number; +} + +interface XMLHttpRequestUpload extends EventTarget, XMLHttpRequestEventTarget { + addEventListener(type: K, listener: (this: XMLHttpRequestUpload, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + 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 | null, type: number, result: XPathResult | null): XPathResult; +} + +declare var XPathEvaluator: { + prototype: XPathEvaluator; + new(): XPathEvaluator; +} + +interface XPathExpression { + evaluate(contextNode: Node, type: number, result: XPathResult | null): XPathResult; +} + +declare var XPathExpression: { + prototype: XPathExpression; + new(): XPathExpression; +} + +interface XPathNSResolver { + lookupNamespaceURI(prefix: string): string; +} + +declare var XPathNSResolver: { + prototype: XPathNSResolver; + new(): XPathNSResolver; +} + +interface XPathResult { + readonly booleanValue: boolean; + readonly invalidIteratorState: boolean; + readonly numberValue: number; + readonly resultType: number; + readonly singleNodeValue: Node; + readonly snapshotLength: number; + readonly stringValue: string; + iterateNext(): Node; + snapshotItem(index: number): Node; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly UNORDERED_NODE_SNAPSHOT_TYPE: number; +} + +declare var XPathResult: { + prototype: XPathResult; + new(): XPathResult; + readonly ANY_TYPE: number; + readonly ANY_UNORDERED_NODE_TYPE: number; + readonly BOOLEAN_TYPE: number; + readonly FIRST_ORDERED_NODE_TYPE: number; + readonly NUMBER_TYPE: number; + readonly ORDERED_NODE_ITERATOR_TYPE: number; + readonly ORDERED_NODE_SNAPSHOT_TYPE: number; + readonly STRING_TYPE: number; + readonly UNORDERED_NODE_ITERATOR_TYPE: number; + readonly 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 webkitRTCPeerConnection extends RTCPeerConnection { + addEventListener(type: K, listener: (this: webkitRTCPeerConnection, ev: RTCPeerConnectionEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +declare var webkitRTCPeerConnection: { + prototype: webkitRTCPeerConnection; + new(configuration: RTCConfiguration): webkitRTCPeerConnection; +} + +interface AbstractWorkerEventMap { + "error": ErrorEvent; +} + +interface AbstractWorker { + onerror: (this: AbstractWorker, ev: ErrorEvent) => any; + addEventListener(type: K, listener: (this: AbstractWorker, ev: AbstractWorkerEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface Body { + readonly bodyUsed: boolean; + arrayBuffer(): Promise; + blob(): Promise; + json(): Promise; + text(): Promise; + formData(): Promise; +} + +interface CanvasPathMethods { + 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; + bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void; + closePath(): void; + ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise?: boolean): void; + lineTo(x: number, y: number): void; + moveTo(x: number, y: number): void; + quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void; + rect(x: number, y: number, w: number, h: number): void; +} + +interface ChildNode { + remove(): void; +} + +interface DOML2DeprecatedColorProperty { + color: string; +} + +interface DOML2DeprecatedSizeProperty { + size: number; +} + +interface DocumentEvent { + createEvent(eventInterface:"AnimationEvent"): AnimationEvent; + createEvent(eventInterface:"AudioProcessingEvent"): AudioProcessingEvent; + createEvent(eventInterface:"BeforeUnloadEvent"): BeforeUnloadEvent; + createEvent(eventInterface:"ClipboardEvent"): ClipboardEvent; + createEvent(eventInterface:"CloseEvent"): CloseEvent; + createEvent(eventInterface:"CompositionEvent"): CompositionEvent; + createEvent(eventInterface:"CustomEvent"): CustomEvent; + createEvent(eventInterface:"DeviceLightEvent"): DeviceLightEvent; + 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:"FocusNavigationEvent"): FocusNavigationEvent; + createEvent(eventInterface:"GamepadEvent"): GamepadEvent; + createEvent(eventInterface:"HashChangeEvent"): HashChangeEvent; + createEvent(eventInterface:"IDBVersionChangeEvent"): IDBVersionChangeEvent; + createEvent(eventInterface:"KeyboardEvent"): KeyboardEvent; + createEvent(eventInterface:"ListeningStateChangedEvent"): ListeningStateChangedEvent; + 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:"MediaEncryptedEvent"): MediaEncryptedEvent; + createEvent(eventInterface:"MediaKeyMessageEvent"): MediaKeyMessageEvent; + createEvent(eventInterface:"MediaStreamErrorEvent"): MediaStreamErrorEvent; + createEvent(eventInterface:"MediaStreamEvent"): MediaStreamEvent; + createEvent(eventInterface:"MediaStreamTrackEvent"): MediaStreamTrackEvent; + createEvent(eventInterface:"MessageEvent"): MessageEvent; + createEvent(eventInterface:"MouseEvent"): MouseEvent; + createEvent(eventInterface:"MouseEvents"): MouseEvent; + 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:"OverflowEvent"): OverflowEvent; + createEvent(eventInterface:"PageTransitionEvent"): PageTransitionEvent; + createEvent(eventInterface:"PaymentRequestUpdateEvent"): PaymentRequestUpdateEvent; + createEvent(eventInterface:"PermissionRequestedEvent"): PermissionRequestedEvent; + createEvent(eventInterface:"PointerEvent"): PointerEvent; + createEvent(eventInterface:"PopStateEvent"): PopStateEvent; + createEvent(eventInterface:"ProgressEvent"): ProgressEvent; + createEvent(eventInterface:"RTCDTMFToneChangeEvent"): RTCDTMFToneChangeEvent; + createEvent(eventInterface:"RTCDtlsTransportStateChangedEvent"): RTCDtlsTransportStateChangedEvent; + createEvent(eventInterface:"RTCIceCandidatePairChangedEvent"): RTCIceCandidatePairChangedEvent; + createEvent(eventInterface:"RTCIceGathererEvent"): RTCIceGathererEvent; + createEvent(eventInterface:"RTCIceTransportStateChangedEvent"): RTCIceTransportStateChangedEvent; + createEvent(eventInterface:"RTCPeerConnectionIceEvent"): RTCPeerConnectionIceEvent; + createEvent(eventInterface:"RTCSsrcConflictEvent"): RTCSsrcConflictEvent; + createEvent(eventInterface:"SVGZoomEvent"): SVGZoomEvent; + createEvent(eventInterface:"SVGZoomEvents"): SVGZoomEvent; + createEvent(eventInterface:"ScriptNotifyEvent"): ScriptNotifyEvent; + createEvent(eventInterface:"ServiceWorkerMessageEvent"): ServiceWorkerMessageEvent; + createEvent(eventInterface:"SpeechSynthesisEvent"): SpeechSynthesisEvent; + 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 { + readonly childElementCount: number; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly nextElementSibling: Element | null; + readonly previousElementSibling: Element | null; +} + +interface GetSVGDocument { + getSVGDocument(): Document; +} + +interface GlobalEventHandlersEventMap { + "pointercancel": PointerEvent; + "pointerdown": PointerEvent; + "pointerenter": PointerEvent; + "pointerleave": PointerEvent; + "pointermove": PointerEvent; + "pointerout": PointerEvent; + "pointerover": PointerEvent; + "pointerup": PointerEvent; + "wheel": WheelEvent; +} + +interface GlobalEventHandlers { + onpointercancel: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerdown: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerenter: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerleave: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointermove: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerout: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerover: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onpointerup: (this: GlobalEventHandlers, ev: PointerEvent) => any; + onwheel: (this: GlobalEventHandlers, ev: WheelEvent) => any; + addEventListener(type: K, listener: (this: GlobalEventHandlers, ev: GlobalEventHandlersEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface GlobalFetch { + fetch(input: RequestInfo, init?: RequestInit): Promise; +} + +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 { + readonly indexedDB: IDBFactory; +} + +interface LinkStyle { + readonly sheet: StyleSheet; +} + +interface MSBaseReaderEventMap { + "abort": Event; + "error": ErrorEvent; + "load": Event; + "loadend": ProgressEvent; + "loadstart": Event; + "progress": ProgressEvent; +} + +interface MSBaseReader { + onabort: (this: MSBaseReader, ev: Event) => any; + onerror: (this: MSBaseReader, ev: ErrorEvent) => any; + onload: (this: MSBaseReader, ev: Event) => any; + onloadend: (this: MSBaseReader, ev: ProgressEvent) => any; + onloadstart: (this: MSBaseReader, ev: Event) => any; + onprogress: (this: MSBaseReader, ev: ProgressEvent) => any; + readonly readyState: number; + readonly result: any; + abort(): void; + readonly DONE: number; + readonly EMPTY: number; + readonly LOADING: number; + addEventListener(type: K, listener: (this: MSBaseReader, ev: MSBaseReaderEventMap[K]) => 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 NavigatorBeacon { + sendBeacon(url: USVString, data?: BodyInit): boolean; +} + +interface NavigatorConcurrentHardware { + readonly hardwareConcurrency: number; +} + +interface NavigatorContentUtils { +} + +interface NavigatorGeolocation { + readonly geolocation: Geolocation; +} + +interface NavigatorID { + readonly appCodeName: string; + readonly appName: string; + readonly appVersion: string; + readonly platform: string; + readonly product: string; + readonly productSub: string; + readonly userAgent: string; + readonly vendor: string; + readonly vendorSub: string; +} + +interface NavigatorOnLine { + readonly onLine: boolean; +} + +interface NavigatorStorageUtils { +} + +interface NavigatorUserMedia { + readonly mediaDevices: MediaDevices; + getUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void; +} + +interface NodeSelector { + querySelector(selectors: K): ElementTagNameMap[K] | null; + querySelector(selectors: string): Element | null; + querySelectorAll(selectors: K): ElementListTagNameMap[K]; + querySelectorAll(selectors: string): NodeListOf; +} + +interface RandomSource { + getRandomValues(array: ArrayBufferView): ArrayBufferView; +} + +interface SVGAnimatedPoints { + readonly animatedPoints: SVGPointList; + readonly points: SVGPointList; +} + +interface SVGFilterPrimitiveStandardAttributes { + readonly height: SVGAnimatedLength; + readonly result: SVGAnimatedString; + readonly width: SVGAnimatedLength; + readonly x: SVGAnimatedLength; + readonly y: SVGAnimatedLength; +} + +interface SVGFitToViewBox { + readonly preserveAspectRatio: SVGAnimatedPreserveAspectRatio; + readonly viewBox: SVGAnimatedRect; +} + +interface SVGTests { + readonly requiredExtensions: SVGStringList; + readonly requiredFeatures: SVGStringList; + readonly systemLanguage: SVGStringList; + hasExtension(extension: string): boolean; +} + +interface SVGURIReference { + readonly href: SVGAnimatedString; +} + +interface WindowBase64 { + atob(encodedString: string): string; + btoa(rawString: string): string; +} + +interface WindowConsole { + readonly console: Console; +} + +interface WindowLocalStorage { + readonly localStorage: Storage; +} + +interface WindowSessionStorage { + readonly sessionStorage: Storage; +} + +interface WindowTimers extends Object, WindowTimersExtension { + clearInterval(handle: number): void; + clearTimeout(handle: number): void; + setInterval(handler: (...args: any[]) => void, timeout: number): number; + setInterval(handler: any, timeout?: any, ...args: any[]): number; + setTimeout(handler: (...args: any[]) => void, timeout: number): number; + setTimeout(handler: any, timeout?: any, ...args: any[]): number; +} + +interface WindowTimersExtension { + clearImmediate(handle: number): void; + setImmediate(handler: (...args: any[]) => void): number; + setImmediate(handler: any, ...args: any[]): number; +} + +interface XMLHttpRequestEventTargetEventMap { + "abort": Event; + "error": ErrorEvent; + "load": Event; + "loadend": ProgressEvent; + "loadstart": Event; + "progress": ProgressEvent; + "timeout": ProgressEvent; +} + +interface XMLHttpRequestEventTarget { + onabort: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onerror: (this: XMLHttpRequestEventTarget, ev: ErrorEvent) => any; + onload: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onloadend: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + onloadstart: (this: XMLHttpRequestEventTarget, ev: Event) => any; + onprogress: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + ontimeout: (this: XMLHttpRequestEventTarget, ev: ProgressEvent) => any; + addEventListener(type: K, listener: (this: XMLHttpRequestEventTarget, ev: XMLHttpRequestEventTargetEventMap[K]) => any, useCapture?: boolean): void; + addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +} + +interface ErrorEventInit { + message?: string; + filename?: string; + lineno?: number; + conlno?: number; + error?: any; +} + +interface StorageEventInit extends EventInit { + key?: string; + oldValue?: string; + newValue?: string; + url: string; + storageArea?: Storage; +} + +interface Canvas2DContextAttributes { + alpha?: boolean; + willReadFrequently?: boolean; + storage?: boolean; + [attribute: string]: boolean | string | undefined; +} + +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + +interface NodeListOf extends NodeList { + length: number; + item(index: number): TNode; + [index: number]: TNode; +} + +interface HTMLCollectionOf extends HTMLCollection { + item(index: number): T; + namedItem(name: string): T; + [index: number]: T; +} + +interface BlobPropertyBag { + type?: string; + endings?: string; +} + +interface FilePropertyBag { + type?: string; + lastModified?: number; +} + +interface EventListenerObject { + handleEvent(evt: Event): void; +} + +interface ProgressEventInit extends EventInit { + lengthComputable?: boolean; + loaded?: number; + total?: number; +} + +interface ScrollOptions { + behavior?: ScrollBehavior; +} + +interface ScrollToOptions extends ScrollOptions { + left?: number; + top?: number; +} + +interface ScrollIntoViewOptions extends ScrollOptions { + block?: ScrollLogicalPosition; + inline?: ScrollLogicalPosition; +} + +interface ClipboardEventInit extends EventInit { + data?: string; + dataType?: string; +} + +interface IDBArrayKey extends Array { +} + +interface RsaKeyGenParams extends Algorithm { + modulusLength: number; + publicExponent: Uint8Array; +} + +interface RsaHashedKeyGenParams extends RsaKeyGenParams { + hash: AlgorithmIdentifier; +} + +interface RsaKeyAlgorithm extends KeyAlgorithm { + modulusLength: number; + publicExponent: Uint8Array; +} + +interface RsaHashedKeyAlgorithm extends RsaKeyAlgorithm { + hash: AlgorithmIdentifier; +} + +interface RsaHashedImportParams { + hash: AlgorithmIdentifier; +} + +interface RsaPssParams { + saltLength: number; +} + +interface RsaOaepParams extends Algorithm { + label?: BufferSource; +} + +interface EcdsaParams extends Algorithm { + hash: AlgorithmIdentifier; +} + +interface EcKeyGenParams extends Algorithm { + namedCurve: string; +} + +interface EcKeyAlgorithm extends KeyAlgorithm { + typedCurve: string; +} + +interface EcKeyImportParams { + namedCurve: string; +} + +interface EcdhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} + +interface AesCtrParams extends Algorithm { + counter: BufferSource; + length: number; +} + +interface AesKeyAlgorithm extends KeyAlgorithm { + length: number; +} + +interface AesKeyGenParams extends Algorithm { + length: number; +} + +interface AesDerivedKeyParams extends Algorithm { + length: number; +} + +interface AesCbcParams extends Algorithm { + iv: BufferSource; +} + +interface AesCmacParams extends Algorithm { + length: number; +} + +interface AesGcmParams extends Algorithm { + iv: BufferSource; + additionalData?: BufferSource; + tagLength?: number; +} + +interface AesCfbParams extends Algorithm { + iv: BufferSource; +} + +interface HmacImportParams extends Algorithm { + hash?: AlgorithmIdentifier; + length?: number; +} + +interface HmacKeyAlgorithm extends KeyAlgorithm { + hash: AlgorithmIdentifier; + length: number; +} + +interface HmacKeyGenParams extends Algorithm { + hash: AlgorithmIdentifier; + length?: number; +} + +interface DhKeyGenParams extends Algorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface DhKeyAlgorithm extends KeyAlgorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface DhKeyDeriveParams extends Algorithm { + public: CryptoKey; +} + +interface DhImportKeyParams extends Algorithm { + prime: Uint8Array; + generator: Uint8Array; +} + +interface ConcatParams extends Algorithm { + hash?: AlgorithmIdentifier; + algorithmId: Uint8Array; + partyUInfo: Uint8Array; + partyVInfo: Uint8Array; + publicInfo?: Uint8Array; + privateInfo?: Uint8Array; +} + +interface HkdfCtrParams extends Algorithm { + hash: AlgorithmIdentifier; + label: BufferSource; + context: BufferSource; +} + +interface Pbkdf2Params extends Algorithm { + salt: BufferSource; + iterations: number; + hash: AlgorithmIdentifier; +} + +interface RsaOtherPrimesInfo { + r: string; + d: string; + t: string; +} + +interface JsonWebKey { + kty: string; + use?: string; + key_ops?: string[]; + alg?: string; + kid?: string; + x5u?: string; + x5c?: string; + x5t?: string; + ext?: boolean; + crv?: string; + x?: string; + y?: string; + d?: string; + n?: string; + e?: string; + p?: string; + q?: string; + dp?: string; + dq?: string; + qi?: string; + oth?: RsaOtherPrimesInfo[]; + k?: string; +} + +interface ParentNode { + readonly children: HTMLCollection; + readonly firstElementChild: Element | null; + readonly lastElementChild: Element | null; + readonly childElementCount: number; +} + +interface DocumentOrShadowRoot { + readonly activeElement: Element | null; + readonly stylesheets: StyleSheetList; + getSelection(): Selection | null; + elementFromPoint(x: number, y: number): Element | null; + elementsFromPoint(x: number, y: number): Element[]; +} + +interface ShadowRoot extends DocumentOrShadowRoot, DocumentFragment { + readonly host: Element; + innerHTML: string; +} + +interface ShadowRootInit { + mode: 'open'|'closed'; + delegatesFocus?: boolean; +} + +interface HTMLSlotElement extends HTMLElement { + name: string; + assignedNodes(options?: AssignedNodesOptions): Node[]; +} + +interface AssignedNodesOptions { + flatten?: boolean; +} + +interface ElementDefinitionOptions { + extends: string; +} + +interface CustomElementRegistry { + define(name: string, constructor: Function, options?: ElementDefinitionOptions): void; + get(name: string): any; + whenDefined(name: string): PromiseLike; +} + +interface PromiseRejectionEvent extends Event { + readonly promise: PromiseLike; + readonly reason: any; +} + +interface PromiseRejectionEventInit extends EventInit { + promise: PromiseLike; + reason?: any; +} + +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + +interface TouchEventInit extends EventModifierInit { + touches?: Touch[]; + targetTouches?: Touch[]; + changedTouches?: Touch[]; +} + +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 VoidFunction { + (): void; +} +interface RTCSessionDescriptionCallback { + (sdp: RTCSessionDescription): void; +} +interface RTCPeerConnectionErrorCallback { + (error: DOMError): void; +} +interface RTCStatsCallback { + (report: RTCStatsReport): void; +} +interface FunctionStringCallback { + (data: string): void; +} +interface NavigatorUserMediaSuccessCallback { + (stream: MediaStream): void; +} +interface NavigatorUserMediaErrorCallback { + (error: MediaStreamError): void; +} +interface ForEachCallback { + (keyId: any, status: MediaKeyStatus): void; +} +interface NotificationPermissionCallback { + (permission: NotificationPermission): void; +} +interface IntersectionObserverCallback { + (entries: IntersectionObserverEntry[], observer: IntersectionObserver): void; +} +interface HTMLElementTagNameMap { + "a": HTMLAnchorElement; + "applet": HTMLAppletElement; + "area": HTMLAreaElement; + "audio": HTMLAudioElement; + "base": HTMLBaseElement; + "basefont": HTMLBaseFontElement; + "blockquote": HTMLQuoteElement; + "body": HTMLBodyElement; + "br": HTMLBRElement; + "button": HTMLButtonElement; + "canvas": HTMLCanvasElement; + "caption": HTMLTableCaptionElement; + "col": HTMLTableColElement; + "colgroup": HTMLTableColElement; + "data": HTMLDataElement; + "datalist": HTMLDataListElement; + "del": HTMLModElement; + "dir": HTMLDirectoryElement; + "div": HTMLDivElement; + "dl": HTMLDListElement; + "embed": HTMLEmbedElement; + "fieldset": HTMLFieldSetElement; + "font": HTMLFontElement; + "form": HTMLFormElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "h1": HTMLHeadingElement; + "h2": HTMLHeadingElement; + "h3": HTMLHeadingElement; + "h4": HTMLHeadingElement; + "h5": HTMLHeadingElement; + "h6": HTMLHeadingElement; + "head": HTMLHeadElement; + "hr": HTMLHRElement; + "html": HTMLHtmlElement; + "iframe": HTMLIFrameElement; + "img": HTMLImageElement; + "input": HTMLInputElement; + "ins": HTMLModElement; + "isindex": HTMLUnknownElement; + "label": HTMLLabelElement; + "legend": HTMLLegendElement; + "li": HTMLLIElement; + "link": HTMLLinkElement; + "listing": HTMLPreElement; + "map": HTMLMapElement; + "marquee": HTMLMarqueeElement; + "menu": HTMLMenuElement; + "meta": HTMLMetaElement; + "meter": HTMLMeterElement; + "nextid": HTMLUnknownElement; + "object": HTMLObjectElement; + "ol": HTMLOListElement; + "optgroup": HTMLOptGroupElement; + "option": HTMLOptionElement; + "output": HTMLOutputElement; + "p": HTMLParagraphElement; + "param": HTMLParamElement; + "picture": HTMLPictureElement; + "pre": HTMLPreElement; + "progress": HTMLProgressElement; + "q": HTMLQuoteElement; + "script": HTMLScriptElement; + "select": HTMLSelectElement; + "source": HTMLSourceElement; + "span": HTMLSpanElement; + "style": HTMLStyleElement; + "table": HTMLTableElement; + "tbody": HTMLTableSectionElement; + "td": HTMLTableDataCellElement; + "template": HTMLTemplateElement; + "textarea": HTMLTextAreaElement; + "tfoot": HTMLTableSectionElement; + "th": HTMLTableHeaderCellElement; + "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; + "title": HTMLTitleElement; + "tr": HTMLTableRowElement; + "track": HTMLTrackElement; + "ul": HTMLUListElement; + "video": HTMLVideoElement; + "x-ms-webview": MSHTMLWebViewElement; + "xmp": HTMLPreElement; +} + +interface ElementTagNameMap { + "a": HTMLAnchorElement; + "abbr": HTMLElement; + "acronym": HTMLElement; + "address": HTMLElement; + "applet": HTMLAppletElement; + "area": HTMLAreaElement; + "article": HTMLElement; + "aside": HTMLElement; + "audio": HTMLAudioElement; + "b": HTMLElement; + "base": HTMLBaseElement; + "basefont": HTMLBaseFontElement; + "bdo": HTMLElement; + "big": HTMLElement; + "blockquote": HTMLQuoteElement; + "body": HTMLBodyElement; + "br": HTMLBRElement; + "button": HTMLButtonElement; + "canvas": HTMLCanvasElement; + "caption": HTMLTableCaptionElement; + "center": HTMLElement; + "circle": SVGCircleElement; + "cite": HTMLElement; + "clippath": SVGClipPathElement; + "code": HTMLElement; + "col": HTMLTableColElement; + "colgroup": HTMLTableColElement; + "data": HTMLDataElement; + "datalist": HTMLDataListElement; + "dd": HTMLElement; + "defs": SVGDefsElement; + "del": HTMLModElement; + "desc": SVGDescElement; + "dfn": HTMLElement; + "dir": HTMLDirectoryElement; + "div": HTMLDivElement; + "dl": HTMLDListElement; + "dt": HTMLElement; + "ellipse": SVGEllipseElement; + "em": HTMLElement; + "embed": HTMLEmbedElement; + "feblend": SVGFEBlendElement; + "fecolormatrix": SVGFEColorMatrixElement; + "fecomponenttransfer": SVGFEComponentTransferElement; + "fecomposite": SVGFECompositeElement; + "feconvolvematrix": SVGFEConvolveMatrixElement; + "fediffuselighting": SVGFEDiffuseLightingElement; + "fedisplacementmap": SVGFEDisplacementMapElement; + "fedistantlight": SVGFEDistantLightElement; + "feflood": SVGFEFloodElement; + "fefunca": SVGFEFuncAElement; + "fefuncb": SVGFEFuncBElement; + "fefuncg": SVGFEFuncGElement; + "fefuncr": SVGFEFuncRElement; + "fegaussianblur": SVGFEGaussianBlurElement; + "feimage": SVGFEImageElement; + "femerge": SVGFEMergeElement; + "femergenode": SVGFEMergeNodeElement; + "femorphology": SVGFEMorphologyElement; + "feoffset": SVGFEOffsetElement; + "fepointlight": SVGFEPointLightElement; + "fespecularlighting": SVGFESpecularLightingElement; + "fespotlight": SVGFESpotLightElement; + "fetile": SVGFETileElement; + "feturbulence": SVGFETurbulenceElement; + "fieldset": HTMLFieldSetElement; + "figcaption": HTMLElement; + "figure": HTMLElement; + "filter": SVGFilterElement; + "font": HTMLFontElement; + "footer": HTMLElement; + "foreignobject": SVGForeignObjectElement; + "form": HTMLFormElement; + "frame": HTMLFrameElement; + "frameset": HTMLFrameSetElement; + "g": SVGGElement; + "h1": HTMLHeadingElement; + "h2": HTMLHeadingElement; + "h3": HTMLHeadingElement; + "h4": HTMLHeadingElement; + "h5": HTMLHeadingElement; + "h6": HTMLHeadingElement; + "head": HTMLHeadElement; + "header": HTMLElement; + "hgroup": HTMLElement; + "hr": HTMLHRElement; + "html": HTMLHtmlElement; + "i": HTMLElement; + "iframe": HTMLIFrameElement; + "image": SVGImageElement; + "img": HTMLImageElement; + "input": HTMLInputElement; + "ins": HTMLModElement; + "isindex": HTMLUnknownElement; + "kbd": HTMLElement; + "keygen": HTMLElement; + "label": HTMLLabelElement; + "legend": HTMLLegendElement; + "li": HTMLLIElement; + "line": SVGLineElement; + "lineargradient": SVGLinearGradientElement; + "link": HTMLLinkElement; + "listing": HTMLPreElement; + "map": HTMLMapElement; + "mark": HTMLElement; + "marker": SVGMarkerElement; + "marquee": HTMLMarqueeElement; + "mask": SVGMaskElement; + "menu": HTMLMenuElement; + "meta": HTMLMetaElement; + "metadata": SVGMetadataElement; + "meter": HTMLMeterElement; + "nav": HTMLElement; + "nextid": HTMLUnknownElement; + "nobr": HTMLElement; + "noframes": HTMLElement; + "noscript": HTMLElement; + "object": HTMLObjectElement; + "ol": HTMLOListElement; + "optgroup": HTMLOptGroupElement; + "option": HTMLOptionElement; + "output": HTMLOutputElement; + "p": HTMLParagraphElement; + "param": HTMLParamElement; + "path": SVGPathElement; + "pattern": SVGPatternElement; + "picture": HTMLPictureElement; + "plaintext": HTMLElement; + "polygon": SVGPolygonElement; + "polyline": SVGPolylineElement; + "pre": HTMLPreElement; + "progress": HTMLProgressElement; + "q": HTMLQuoteElement; + "radialgradient": SVGRadialGradientElement; + "rect": SVGRectElement; + "rt": HTMLElement; + "ruby": HTMLElement; + "s": HTMLElement; + "samp": HTMLElement; + "script": HTMLScriptElement; + "section": HTMLElement; + "select": HTMLSelectElement; + "small": HTMLElement; + "source": HTMLSourceElement; + "span": HTMLSpanElement; + "stop": SVGStopElement; + "strike": HTMLElement; + "strong": HTMLElement; + "style": HTMLStyleElement; + "sub": HTMLElement; + "sup": HTMLElement; + "svg": SVGSVGElement; + "switch": SVGSwitchElement; + "symbol": SVGSymbolElement; + "table": HTMLTableElement; + "tbody": HTMLTableSectionElement; + "td": HTMLTableDataCellElement; + "template": HTMLTemplateElement; + "text": SVGTextElement; + "textpath": SVGTextPathElement; + "textarea": HTMLTextAreaElement; + "tfoot": HTMLTableSectionElement; + "th": HTMLTableHeaderCellElement; + "thead": HTMLTableSectionElement; + "time": HTMLTimeElement; + "title": HTMLTitleElement; + "tr": HTMLTableRowElement; + "track": HTMLTrackElement; + "tspan": SVGTSpanElement; + "tt": HTMLElement; + "u": HTMLElement; + "ul": HTMLUListElement; + "use": SVGUseElement; + "var": HTMLElement; + "video": HTMLVideoElement; + "view": SVGViewElement; + "wbr": HTMLElement; + "x-ms-webview": MSHTMLWebViewElement; + "xmp": HTMLPreElement; +} + +interface ElementListTagNameMap { + "a": NodeListOf; + "abbr": NodeListOf; + "acronym": NodeListOf; + "address": NodeListOf; + "applet": NodeListOf; + "area": NodeListOf; + "article": NodeListOf; + "aside": NodeListOf; + "audio": NodeListOf; + "b": NodeListOf; + "base": NodeListOf; + "basefont": NodeListOf; + "bdo": NodeListOf; + "big": NodeListOf; + "blockquote": NodeListOf; + "body": NodeListOf; + "br": NodeListOf; + "button": NodeListOf; + "canvas": NodeListOf; + "caption": NodeListOf; + "center": NodeListOf; + "circle": NodeListOf; + "cite": NodeListOf; + "clippath": NodeListOf; + "code": NodeListOf; + "col": NodeListOf; + "colgroup": NodeListOf; + "data": NodeListOf; + "datalist": NodeListOf; + "dd": NodeListOf; + "defs": NodeListOf; + "del": NodeListOf; + "desc": NodeListOf; + "dfn": NodeListOf; + "dir": NodeListOf; + "div": NodeListOf; + "dl": NodeListOf; + "dt": NodeListOf; + "ellipse": NodeListOf; + "em": NodeListOf; + "embed": NodeListOf; + "feblend": NodeListOf; + "fecolormatrix": NodeListOf; + "fecomponenttransfer": NodeListOf; + "fecomposite": NodeListOf; + "feconvolvematrix": NodeListOf; + "fediffuselighting": NodeListOf; + "fedisplacementmap": NodeListOf; + "fedistantlight": NodeListOf; + "feflood": NodeListOf; + "fefunca": NodeListOf; + "fefuncb": NodeListOf; + "fefuncg": NodeListOf; + "fefuncr": NodeListOf; + "fegaussianblur": NodeListOf; + "feimage": NodeListOf; + "femerge": NodeListOf; + "femergenode": NodeListOf; + "femorphology": NodeListOf; + "feoffset": NodeListOf; + "fepointlight": NodeListOf; + "fespecularlighting": NodeListOf; + "fespotlight": NodeListOf; + "fetile": NodeListOf; + "feturbulence": NodeListOf; + "fieldset": NodeListOf; + "figcaption": NodeListOf; + "figure": NodeListOf; + "filter": NodeListOf; + "font": NodeListOf; + "footer": NodeListOf; + "foreignobject": NodeListOf; + "form": NodeListOf; + "frame": NodeListOf; + "frameset": NodeListOf; + "g": NodeListOf; + "h1": NodeListOf; + "h2": NodeListOf; + "h3": NodeListOf; + "h4": NodeListOf; + "h5": NodeListOf; + "h6": NodeListOf; + "head": NodeListOf; + "header": NodeListOf; + "hgroup": NodeListOf; + "hr": NodeListOf; + "html": NodeListOf; + "i": NodeListOf; + "iframe": NodeListOf; + "image": NodeListOf; + "img": NodeListOf; + "input": NodeListOf; + "ins": NodeListOf; + "isindex": NodeListOf; + "kbd": NodeListOf; + "keygen": NodeListOf; + "label": NodeListOf; + "legend": NodeListOf; + "li": NodeListOf; + "line": NodeListOf; + "lineargradient": NodeListOf; + "link": NodeListOf; + "listing": NodeListOf; + "map": NodeListOf; + "mark": NodeListOf; + "marker": NodeListOf; + "marquee": NodeListOf; + "mask": NodeListOf; + "menu": NodeListOf; + "meta": NodeListOf; + "metadata": NodeListOf; + "meter": NodeListOf; + "nav": NodeListOf; + "nextid": NodeListOf; + "nobr": NodeListOf; + "noframes": NodeListOf; + "noscript": NodeListOf; + "object": NodeListOf; + "ol": NodeListOf; + "optgroup": NodeListOf; + "option": NodeListOf; + "output": NodeListOf; + "p": NodeListOf; + "param": NodeListOf; + "path": NodeListOf; + "pattern": NodeListOf; + "picture": NodeListOf; + "plaintext": NodeListOf; + "polygon": NodeListOf; + "polyline": NodeListOf; + "pre": NodeListOf; + "progress": NodeListOf; + "q": NodeListOf; + "radialgradient": NodeListOf; + "rect": NodeListOf; + "rt": NodeListOf; + "ruby": NodeListOf; + "s": NodeListOf; + "samp": NodeListOf; + "script": NodeListOf; + "section": NodeListOf; + "select": NodeListOf; + "small": NodeListOf; + "source": NodeListOf; + "span": NodeListOf; + "stop": NodeListOf; + "strike": NodeListOf; + "strong": NodeListOf; + "style": NodeListOf; + "sub": NodeListOf; + "sup": NodeListOf; + "svg": NodeListOf; + "switch": NodeListOf; + "symbol": NodeListOf; + "table": NodeListOf; + "tbody": NodeListOf; + "td": NodeListOf; + "template": NodeListOf; + "text": NodeListOf; + "textpath": NodeListOf; + "textarea": NodeListOf; + "tfoot": NodeListOf; + "th": NodeListOf; + "thead": NodeListOf; + "time": NodeListOf; + "title": NodeListOf; + "tr": NodeListOf; + "track": NodeListOf; + "tspan": NodeListOf; + "tt": NodeListOf; + "u": NodeListOf; + "ul": NodeListOf; + "use": NodeListOf; + "var": NodeListOf; + "video": NodeListOf; + "view": NodeListOf; + "wbr": NodeListOf; + "x-ms-webview": NodeListOf; + "xmp": NodeListOf; +} + +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 applicationCache: ApplicationCache; +declare var caches: CacheStorage; +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 | undefined; +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 isSecureContext: boolean; +declare var length: number; +declare var location: Location; +declare var locationbar: BarProp; +declare var menubar: BarProp; +declare var msContentScript: ExtensionScriptApis; +declare var msCredentials: MSCredentials; +declare const name: never; +declare var navigator: Navigator; +declare var offscreenBuffering: string | boolean; +declare var onabort: (this: Window, ev: UIEvent) => any; +declare var onafterprint: (this: Window, ev: Event) => any; +declare var onbeforeprint: (this: Window, ev: Event) => any; +declare var onbeforeunload: (this: Window, ev: BeforeUnloadEvent) => any; +declare var onblur: (this: Window, ev: FocusEvent) => any; +declare var oncanplay: (this: Window, ev: Event) => any; +declare var oncanplaythrough: (this: Window, ev: Event) => any; +declare var onchange: (this: Window, ev: Event) => any; +declare var onclick: (this: Window, ev: MouseEvent) => any; +declare var oncompassneedscalibration: (this: Window, ev: Event) => any; +declare var oncontextmenu: (this: Window, ev: PointerEvent) => any; +declare var ondblclick: (this: Window, ev: MouseEvent) => any; +declare var ondevicelight: (this: Window, ev: DeviceLightEvent) => any; +declare var ondevicemotion: (this: Window, ev: DeviceMotionEvent) => any; +declare var ondeviceorientation: (this: Window, ev: DeviceOrientationEvent) => any; +declare var ondrag: (this: Window, ev: DragEvent) => any; +declare var ondragend: (this: Window, ev: DragEvent) => any; +declare var ondragenter: (this: Window, ev: DragEvent) => any; +declare var ondragleave: (this: Window, ev: DragEvent) => any; +declare var ondragover: (this: Window, ev: DragEvent) => any; +declare var ondragstart: (this: Window, ev: DragEvent) => any; +declare var ondrop: (this: Window, ev: DragEvent) => any; +declare var ondurationchange: (this: Window, ev: Event) => any; +declare var onemptied: (this: Window, ev: Event) => any; +declare var onended: (this: Window, ev: MediaStreamErrorEvent) => any; +declare var onerror: ErrorEventHandler; +declare var onfocus: (this: Window, ev: FocusEvent) => any; +declare var onhashchange: (this: Window, ev: HashChangeEvent) => any; +declare var oninput: (this: Window, ev: Event) => any; +declare var oninvalid: (this: Window, ev: Event) => any; +declare var onkeydown: (this: Window, ev: KeyboardEvent) => any; +declare var onkeypress: (this: Window, ev: KeyboardEvent) => any; +declare var onkeyup: (this: Window, ev: KeyboardEvent) => any; +declare var onload: (this: Window, ev: Event) => any; +declare var onloadeddata: (this: Window, ev: Event) => any; +declare var onloadedmetadata: (this: Window, ev: Event) => any; +declare var onloadstart: (this: Window, ev: Event) => any; +declare var onmessage: (this: Window, ev: MessageEvent) => any; +declare var onmousedown: (this: Window, ev: MouseEvent) => any; +declare var onmouseenter: (this: Window, ev: MouseEvent) => any; +declare var onmouseleave: (this: Window, ev: MouseEvent) => any; +declare var onmousemove: (this: Window, ev: MouseEvent) => any; +declare var onmouseout: (this: Window, ev: MouseEvent) => any; +declare var onmouseover: (this: Window, ev: MouseEvent) => any; +declare var onmouseup: (this: Window, ev: MouseEvent) => any; +declare var onmousewheel: (this: Window, ev: WheelEvent) => any; +declare var onmsgesturechange: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturedoubletap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgestureend: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturehold: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturestart: (this: Window, ev: MSGestureEvent) => any; +declare var onmsgesturetap: (this: Window, ev: MSGestureEvent) => any; +declare var onmsinertiastart: (this: Window, ev: MSGestureEvent) => any; +declare var onmspointercancel: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerdown: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerenter: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerleave: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointermove: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerout: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerover: (this: Window, ev: MSPointerEvent) => any; +declare var onmspointerup: (this: Window, ev: MSPointerEvent) => any; +declare var onoffline: (this: Window, ev: Event) => any; +declare var ononline: (this: Window, ev: Event) => any; +declare var onorientationchange: (this: Window, ev: Event) => any; +declare var onpagehide: (this: Window, ev: PageTransitionEvent) => any; +declare var onpageshow: (this: Window, ev: PageTransitionEvent) => any; +declare var onpause: (this: Window, ev: Event) => any; +declare var onplay: (this: Window, ev: Event) => any; +declare var onplaying: (this: Window, ev: Event) => any; +declare var onpopstate: (this: Window, ev: PopStateEvent) => any; +declare var onprogress: (this: Window, ev: ProgressEvent) => any; +declare var onratechange: (this: Window, ev: Event) => any; +declare var onreadystatechange: (this: Window, ev: ProgressEvent) => any; +declare var onreset: (this: Window, ev: Event) => any; +declare var onresize: (this: Window, ev: UIEvent) => any; +declare var onscroll: (this: Window, ev: UIEvent) => any; +declare var onseeked: (this: Window, ev: Event) => any; +declare var onseeking: (this: Window, ev: Event) => any; +declare var onselect: (this: Window, ev: UIEvent) => any; +declare var onstalled: (this: Window, ev: Event) => any; +declare var onstorage: (this: Window, ev: StorageEvent) => any; +declare var onsubmit: (this: Window, ev: Event) => any; +declare var onsuspend: (this: Window, ev: Event) => any; +declare var ontimeupdate: (this: Window, ev: Event) => any; +declare var ontouchcancel: (ev: TouchEvent) => any; +declare var ontouchend: (ev: TouchEvent) => any; +declare var ontouchmove: (ev: TouchEvent) => any; +declare var ontouchstart: (ev: TouchEvent) => any; +declare var onunload: (this: Window, ev: Event) => any; +declare var onvolumechange: (this: Window, ev: Event) => any; +declare var onwaiting: (this: Window, ev: Event) => any; +declare var opener: any; +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 speechSynthesis: SpeechSynthesis; +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 customElements: CustomElementRegistry; +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 departFocus(navigationReason: NavigationReason, origin: FocusNavigationOrigin): void; +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 msWriteProfilerMark(profilerMarkName: string): void; +declare function open(url?: string, target?: string, features?: string, replace?: boolean): Window; +declare function postMessage(message: any, targetOrigin: string, transfer?: any[]): void; +declare function print(): void; +declare function prompt(message?: string, _default?: string): string | null; +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 stop(): void; +declare function webkitCancelAnimationFrame(handle: number): void; +declare function webkitConvertPointFromNodeToPage(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitConvertPointFromPageToNode(node: Node, pt: WebKitPoint): WebKitPoint; +declare function webkitRequestAnimationFrame(callback: FrameRequestCallback): number; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: HTMLImageElement | SVGImageElement | HTMLVideoElement | HTMLCanvasElement | ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; +declare function scroll(options?: ScrollToOptions): void; +declare function scrollTo(options?: ScrollToOptions): void; +declare function scrollBy(options?: ScrollToOptions): void; +declare function toString(): string; +declare function dispatchEvent(evt: Event): boolean; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; +declare function clearInterval(handle: number): void; +declare function clearTimeout(handle: number): void; +declare function setInterval(handler: (...args: any[]) => void, timeout: number): number; +declare function setInterval(handler: any, timeout?: any, ...args: any[]): number; +declare function setTimeout(handler: (...args: any[]) => void, timeout: number): number; +declare function setTimeout(handler: any, timeout?: any, ...args: any[]): number; +declare function clearImmediate(handle: number): void; +declare function setImmediate(handler: (...args: any[]) => void): number; +declare function setImmediate(handler: any, ...args: any[]): number; +declare var sessionStorage: Storage; +declare var localStorage: Storage; +declare var console: Console; +declare var onpointercancel: (this: Window, ev: PointerEvent) => any; +declare var onpointerdown: (this: Window, ev: PointerEvent) => any; +declare var onpointerenter: (this: Window, ev: PointerEvent) => any; +declare var onpointerleave: (this: Window, ev: PointerEvent) => any; +declare var onpointermove: (this: Window, ev: PointerEvent) => any; +declare var onpointerout: (this: Window, ev: PointerEvent) => any; +declare var onpointerover: (this: Window, ev: PointerEvent) => any; +declare var onpointerup: (this: Window, ev: PointerEvent) => any; +declare var onwheel: (this: Window, ev: WheelEvent) => any; +declare var indexedDB: IDBFactory; +declare function atob(encodedString: string): string; +declare function btoa(rawString: string): string; +declare function fetch(input: RequestInfo, init?: RequestInit): Promise; +declare function addEventListener(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, useCapture?: boolean): void; +declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; +type AAGUID = string; +type AlgorithmIdentifier = string | Algorithm; +type BodyInit = any; +type ByteString = string; +type ConstrainBoolean = boolean | ConstrainBooleanParameters; +type ConstrainDOMString = string | string[] | ConstrainDOMStringParameters; +type ConstrainDouble = number | ConstrainDoubleRange; +type ConstrainLong = number | ConstrainLongRange; +type CryptoOperationData = ArrayBufferView; +type GLbitfield = number; +type GLboolean = boolean; +type GLbyte = number; +type GLclampf = number; +type GLenum = number; +type GLfloat = number; +type GLint = number; +type GLintptr = number; +type GLshort = number; +type GLsizei = number; +type GLsizeiptr = number; +type GLubyte = number; +type GLuint = number; +type GLushort = number; +type HeadersInit = any; +type IDBKeyPath = string; +type KeyFormat = string; +type KeyType = string; +type KeyUsage = string; +type MSInboundPayload = MSVideoRecvPayload | MSAudioRecvPayload; +type MSLocalClientEvent = MSLocalClientEventBase | MSAudioLocalClientEvent; +type MSOutboundPayload = MSVideoSendPayload | MSAudioSendPayload; +type RTCIceGatherCandidate = RTCIceCandidateDictionary | RTCIceCandidateComplete; +type RTCTransport = RTCDtlsTransport | RTCSrtpSdesTransport; +type RequestInfo = Request | string; +type USVString = string; +type payloadtype = number; +type ScrollBehavior = "auto" | "instant" | "smooth"; +type ScrollLogicalPosition = "start" | "center" | "end" | "nearest"; +type IDBValidKey = number | string | Date | IDBArrayKey; +type BufferSource = ArrayBuffer | ArrayBufferView; +type MouseWheelEvent = WheelEvent; +type ScrollRestoration = "auto" | "manual"; +type FormDataEntryValue = string | File; +type AppendMode = "segments" | "sequence"; +type AudioContextState = "suspended" | "running" | "closed"; +type BiquadFilterType = "lowpass" | "highpass" | "bandpass" | "lowshelf" | "highshelf" | "peaking" | "notch" | "allpass"; +type CanvasFillRule = "nonzero" | "evenodd"; +type ChannelCountMode = "max" | "clamped-max" | "explicit"; +type ChannelInterpretation = "speakers" | "discrete"; +type DistanceModelType = "linear" | "inverse" | "exponential"; +type ExpandGranularity = "character" | "word" | "sentence" | "textedit"; +type GamepadInputEmulationType = "mouse" | "keyboard" | "gamepad"; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type ListeningState = "inactive" | "active" | "disambiguation"; +type MSCredentialType = "FIDO_2_0"; +type MSIceAddrType = "os" | "stun" | "turn" | "peer-derived"; +type MSIceType = "failed" | "direct" | "relay"; +type MSStatsType = "description" | "localclientevent" | "inbound-network" | "outbound-network" | "inbound-payload" | "outbound-payload" | "transportdiagnostics"; +type MSTransportType = "Embedded" | "USB" | "NFC" | "BT"; +type MSWebViewPermissionState = "unknown" | "defer" | "allow" | "deny"; +type MSWebViewPermissionType = "geolocation" | "unlimitedIndexedDBQuota" | "media" | "pointerlock" | "webnotifications"; +type MediaDeviceKind = "audioinput" | "audiooutput" | "videoinput"; +type MediaKeyMessageType = "license-request" | "license-renewal" | "license-release" | "individualization-request"; +type MediaKeySessionType = "temporary" | "persistent-license" | "persistent-release-message"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type MediaKeysRequirement = "required" | "optional" | "not-allowed"; +type MediaStreamTrackState = "live" | "ended"; +type NavigationReason = "up" | "down" | "left" | "right"; +type NavigationType = "navigate" | "reload" | "back_forward" | "prerender"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type OscillatorType = "sine" | "square" | "sawtooth" | "triangle" | "custom"; +type OverSampleType = "none" | "2x" | "4x"; +type PanningModelType = "equalpower"; +type PaymentComplete = "success" | "fail" | ""; +type PaymentShippingType = "shipping" | "delivery" | "pickup"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type RTCBundlePolicy = "balanced" | "max-compat" | "max-bundle"; +type RTCDegradationPreference = "maintain-framerate" | "maintain-resolution" | "balanced"; +type RTCDtlsRole = "auto" | "client" | "server"; +type RTCDtlsTransportState = "new" | "connecting" | "connected" | "closed"; +type RTCIceCandidateType = "host" | "srflx" | "prflx" | "relay"; +type RTCIceComponent = "RTP" | "RTCP"; +type RTCIceConnectionState = "new" | "checking" | "connected" | "completed" | "failed" | "disconnected" | "closed"; +type RTCIceGatherPolicy = "all" | "nohost" | "relay"; +type RTCIceGathererState = "new" | "gathering" | "complete"; +type RTCIceGatheringState = "new" | "gathering" | "complete"; +type RTCIceProtocol = "udp" | "tcp"; +type RTCIceRole = "controlling" | "controlled"; +type RTCIceTcpCandidateType = "active" | "passive" | "so"; +type RTCIceTransportPolicy = "none" | "relay" | "all"; +type RTCIceTransportState = "new" | "checking" | "connected" | "completed" | "disconnected" | "closed"; +type RTCSdpType = "offer" | "pranswer" | "answer"; +type RTCSignalingState = "stable" | "have-local-offer" | "have-remote-offer" | "have-local-pranswer" | "have-remote-pranswer" | "closed"; +type RTCStatsIceCandidatePairState = "frozen" | "waiting" | "inprogress" | "failed" | "succeeded" | "cancelled"; +type RTCStatsIceCandidateType = "host" | "serverreflexive" | "peerreflexive" | "relayed"; +type RTCStatsType = "inboundrtp" | "outboundrtp" | "session" | "datachannel" | "track" | "transport" | "candidatepair" | "localcandidate" | "remotecandidate"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ScopedCredentialType = "ScopedCred"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type Transport = "usb" | "nfc" | "ble"; +type VideoFacingModeEnum = "user" | "environment" | "left" | "right"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; + + +///////////////////////////// +/// 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; + +/** + * Automation date (VT_DATE) + */ +interface VarDate { } + +interface DateConstructor { + new (vd: VarDate): Date; +} + +interface Date { + getVarDate: () => VarDate; +} + + +/// + +interface DOMTokenList { + [Symbol.iterator](): IterableIterator; +} + +interface FormData { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[string, string | File]>; + /** + * Returns a list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns a list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface Headers { + [Symbol.iterator](): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all key/value pairs contained in this object. + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns an iterator allowing to go through all keys f the key/value pairs contained in this object. + */ + keys(): IterableIterator; + /** + * Returns an iterator allowing to go through all values of the key/value pairs contained in this object. + */ + values(): IterableIterator; +} + +interface NodeList { + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, Node]>; + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: Node, index: number, listObj: NodeList) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + + [Symbol.iterator](): IterableIterator; +} + +interface NodeListOf { + + /** + * Returns an array of key, value pairs for every entry in the list + */ + entries(): IterableIterator<[number, TNode]>; + + /** + * Performs the specified action for each node in an list. + * @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the list. + * @param thisArg 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: TNode, index: number, listObj: NodeListOf) => void, thisArg?: any): void; + /** + * Returns an list of keys in the list + */ + keys(): IterableIterator; + /** + * Returns an list of values in the list + */ + values(): IterableIterator; + + [Symbol.iterator](): IterableIterator; +} + +interface URLSearchParams { + /** + * Returns an array of key, value pairs for every entry in the search params + */ + entries(): IterableIterator<[string, string]>; + /** + * Returns a list of keys in the search params + */ + keys(): IterableIterator; + /** + * Returns a list of values in the search params + */ + values(): IterableIterator; + /** + * iterate over key/value pairs + */ + [Symbol.iterator](): IterableIterator<[string, string]>; +} diff --git a/lib/lib.scripthost.d.ts b/lib/lib.scripthost.d.ts index 2be78dec994..47cfaa7fb8c 100644 --- a/lib/lib.scripthost.d.ts +++ b/lib/lib.scripthost.d.ts @@ -49,7 +49,7 @@ interface TextStreamBase { /** * Closes a text stream. - * It is not necessary to close standard streams; they close automatically when the process ends. If + * 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; @@ -119,9 +119,9 @@ interface TextStreamReader extends TextStreamBase { 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). - */ + * 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; /** diff --git a/lib/lib.webworker.d.ts b/lib/lib.webworker.d.ts index e20455cf59e..4e7672f7973 100644 --- a/lib/lib.webworker.d.ts +++ b/lib/lib.webworker.d.ts @@ -74,13 +74,17 @@ interface MessageEventInit extends EventInit { } interface NotificationOptions { - dir?: string; + dir?: NotificationDirection; lang?: string; body?: string; tag?: string; icon?: string; } +interface ObjectURLOptions { + oneTimeOnly?: boolean; +} + interface PushSubscriptionOptionsInit { userVisibleOnly?: boolean; applicationServerKey?: any; @@ -91,11 +95,11 @@ interface RequestInit { headers?: any; body?: any; referrer?: string; - referrerPolicy?: string; - mode?: string; - credentials?: string; - cache?: string; - redirect?: string; + referrerPolicy?: ReferrerPolicy; + mode?: RequestMode; + credentials?: RequestCredentials; + cache?: RequestCache; + redirect?: RequestRedirect; integrity?: string; keepalive?: boolean; window?: any; @@ -109,7 +113,7 @@ interface ResponseInit { interface ClientQueryOptions { includeUncontrolled?: boolean; - type?: string; + type?: ClientType; } interface ExtendableEventInit extends EventInit { @@ -419,9 +423,9 @@ declare var Event: { } interface EventTarget { - addEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + addEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; dispatchEvent(evt: Event): boolean; - removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; + removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare var EventTarget: { @@ -481,7 +485,7 @@ declare var Headers: { } interface IDBCursor { - readonly direction: string; + readonly direction: IDBCursorDirection; key: IDBKeyRange | IDBValidKey; readonly primaryKey: any; source: IDBObjectStore | IDBIndex; @@ -633,7 +637,7 @@ interface IDBRequest extends EventTarget { readonly error: DOMError; onerror: (this: IDBRequest, ev: Event) => any; onsuccess: (this: IDBRequest, ev: Event) => any; - readonly readyState: string; + readonly readyState: IDBRequestReadyState; readonly result: any; source: IDBObjectStore | IDBIndex | IDBCursor; readonly transaction: IDBTransaction; @@ -655,7 +659,7 @@ interface IDBTransactionEventMap { interface IDBTransaction extends EventTarget { readonly db: IDBDatabase; readonly error: DOMError; - readonly mode: string; + readonly mode: IDBTransactionMode; onabort: (this: IDBTransaction, ev: Event) => any; oncomplete: (this: IDBTransaction, ev: Event) => any; onerror: (this: IDBTransaction, ev: Event) => any; @@ -748,14 +752,14 @@ interface NotificationEventMap { interface Notification extends EventTarget { readonly body: string; - readonly dir: string; + readonly dir: NotificationDirection; readonly icon: string; readonly lang: string; onclick: (this: Notification, ev: Event) => any; onclose: (this: Notification, ev: Event) => any; onerror: (this: Notification, ev: Event) => any; onshow: (this: Notification, ev: Event) => any; - readonly permission: string; + readonly permission: NotificationPermission; readonly tag: string; readonly title: string; close(): void; @@ -766,7 +770,7 @@ interface Notification extends EventTarget { declare var Notification: { prototype: Notification; new(title: string, options?: NotificationOptions): Notification; - requestPermission(callback?: NotificationPermissionCallback): Promise; + requestPermission(callback?: NotificationPermissionCallback): Promise; } interface Performance { @@ -883,7 +887,7 @@ declare var ProgressEvent: { interface PushManager { getSubscription(): Promise; - permissionState(options?: PushSubscriptionOptionsInit): Promise; + permissionState(options?: PushSubscriptionOptionsInit): Promise; subscribe(options?: PushSubscriptionOptionsInit): Promise; } @@ -895,7 +899,7 @@ declare var PushManager: { interface PushSubscription { readonly endpoint: USVString; readonly options: PushSubscriptionOptions; - getKey(name: string): ArrayBuffer | null; + getKey(name: PushEncryptionKeyName): ArrayBuffer | null; toJSON(): any; unsubscribe(): Promise; } @@ -938,18 +942,18 @@ declare var ReadableStreamReader: { } interface Request extends Object, Body { - readonly cache: string; - readonly credentials: string; - readonly destination: string; + readonly cache: RequestCache; + readonly credentials: RequestCredentials; + readonly destination: RequestDestination; readonly headers: Headers; readonly integrity: string; readonly keepalive: boolean; readonly method: string; - readonly mode: string; - readonly redirect: string; + readonly mode: RequestMode; + readonly redirect: RequestRedirect; readonly referrer: string; - readonly referrerPolicy: string; - readonly type: string; + readonly referrerPolicy: ReferrerPolicy; + readonly type: RequestType; readonly url: string; clone(): Request; } @@ -965,7 +969,7 @@ interface Response extends Object, Body { readonly ok: boolean; readonly status: number; readonly statusText: string; - readonly type: string; + readonly type: ResponseType; readonly url: string; clone(): Response; } @@ -982,7 +986,7 @@ interface ServiceWorkerEventMap extends AbstractWorkerEventMap { interface ServiceWorker extends EventTarget, AbstractWorker { onstatechange: (this: ServiceWorker, ev: Event) => any; readonly scriptURL: USVString; - readonly state: string; + readonly state: ServiceWorkerState; postMessage(message: any, transfer?: any[]): void; addEventListener(type: K, listener: (this: ServiceWorker, ev: ServiceWorkerEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; @@ -1028,6 +1032,29 @@ declare var SyncManager: { new(): SyncManager; } +interface URL { + hash: string; + host: string; + hostname: string; + href: string; + readonly origin: string; + password: string; + pathname: string; + port: string; + protocol: string; + search: string; + username: string; + readonly searchParams: URLSearchParams; + toString(): string; +} + +declare var URL: { + prototype: URL; + new(url: string, base?: string): URL; + createObjectURL(object: any, options?: ObjectURLOptions): string; + revokeObjectURL(url: string): void; +} + interface WebSocketEventMap { "close": CloseEvent; "error": Event; @@ -1091,7 +1118,7 @@ interface XMLHttpRequest extends EventTarget, XMLHttpRequestEventTarget { readonly readyState: number; readonly response: any; readonly responseText: string; - responseType: string; + responseType: XMLHttpRequestResponseType; readonly responseURL: string; readonly responseXML: any; readonly status: number; @@ -1242,7 +1269,7 @@ interface XMLHttpRequestEventTarget { } interface Client { - readonly frameType: string; + readonly frameType: FrameType; readonly id: string; readonly url: USVString; postMessage(message: any, transfer?: any[]): void; @@ -1405,7 +1432,7 @@ declare var SyncEvent: { interface WindowClient extends Client { readonly focused: boolean; - readonly visibilityState: string; + readonly visibilityState: VisibilityState; focus(): Promise; navigate(url: USVString): Promise; } @@ -1427,6 +1454,8 @@ interface WorkerGlobalScope extends EventTarget, WorkerUtils, WindowConsole, Glo readonly performance: Performance; readonly self: WorkerGlobalScope; msWriteProfilerMark(profilerMarkName: string): void; + createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; + createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; addEventListener(type: K, listener: (this: WorkerGlobalScope, ev: WorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; } @@ -1487,6 +1516,56 @@ interface ErrorEventInit { error?: any; } +interface ImageBitmapOptions { + imageOrientation?: "none" | "flipY"; + premultiplyAlpha?: "none" | "premultiply" | "default"; + colorSpaceConversion?: "none" | "default"; + resizeWidth?: number; + resizeHeight?: number; + resizeQuality?: "pixelated" | "low" | "medium" | "high"; +} + +interface ImageBitmap { + readonly width: number; + readonly height: number; + close(): void; +} + +interface URLSearchParams { + /** + * Appends a specified key/value pair as a new search parameter. + */ + append(name: string, value: string): void; + /** + * Deletes the given search parameter, and its associated value, from the list of all search parameters. + */ + delete(name: string): void; + /** + * Returns the first value associated to the given search parameter. + */ + get(name: string): string | null; + /** + * Returns all the values association with a given search parameter. + */ + getAll(name: string): string[]; + /** + * Returns a Boolean indicating if such a search parameter exists. + */ + has(name: string): boolean; + /** + * Sets the value associated to a given search parameter to the given value. If there were several values, delete the others. + */ + set(name: string, value: string): void; +} + +declare var URLSearchParams: { + prototype: URLSearchParams; + /** + * Constructor returning a URLSearchParams object. + */ + new (init?: string | URLSearchParams): URLSearchParams; +} + interface BlobPropertyBag { type?: string; endings?: string; @@ -1681,6 +1760,15 @@ interface JsonWebKey { k?: string; } +interface EventListenerOptions { + capture?: boolean; +} + +interface AddEventListenerOptions extends EventListenerOptions { + passive?: boolean; + once?: boolean; +} + declare type EventListenerOrEventListenerObject = EventListener | EventListenerObject; interface ErrorEventHandler { @@ -1702,10 +1790,10 @@ interface FunctionStringCallback { (data: string): void; } interface ForEachCallback { - (keyId: any, status: string): void; + (keyId: any, status: MediaKeyStatus): void; } interface NotificationPermissionCallback { - (permission: string): void; + (permission: NotificationPermission): void; } declare var onmessage: (this: DedicatedWorkerGlobalScope, ev: MessageEvent) => any; declare function close(): void; @@ -1717,8 +1805,10 @@ declare var onerror: (this: DedicatedWorkerGlobalScope, ev: ErrorEvent) => any; declare var performance: Performance; declare var self: WorkerGlobalScope; declare function msWriteProfilerMark(profilerMarkName: string): void; +declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, options?: ImageBitmapOptions): Promise; +declare function createImageBitmap(image: ImageBitmap | ImageData | Blob, sx: number, sy: number, sw: number, sh: number, options?: ImageBitmapOptions): Promise; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; declare var indexedDB: IDBFactory; declare var msIndexedDB: IDBFactory; declare var navigator: WorkerNavigator; @@ -1737,7 +1827,7 @@ declare function btoa(rawString: string): string; declare var console: Console; declare function fetch(input: RequestInfo, init?: RequestInit): Promise; declare function dispatchEvent(evt: Event): boolean; -declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, useCapture?: boolean): void; +declare function removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; declare function addEventListener(type: K, listener: (this: DedicatedWorkerGlobalScope, ev: DedicatedWorkerGlobalScopeEventMap[K]) => any, useCapture?: boolean): void; declare function addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void; type AlgorithmIdentifier = string | Algorithm; @@ -1746,4 +1836,26 @@ type IDBKeyPath = string; type RequestInfo = Request | string; type USVString = string; type IDBValidKey = number | string | Date | IDBArrayKey; -type BufferSource = ArrayBuffer | ArrayBufferView; \ No newline at end of file +type BufferSource = ArrayBuffer | ArrayBufferView; +type FormDataEntryValue = string | File; +type IDBCursorDirection = "next" | "nextunique" | "prev" | "prevunique"; +type IDBRequestReadyState = "pending" | "done"; +type IDBTransactionMode = "readonly" | "readwrite" | "versionchange"; +type MediaKeyStatus = "usable" | "expired" | "output-downscaled" | "output-not-allowed" | "status-pending" | "internal-error"; +type NotificationDirection = "auto" | "ltr" | "rtl"; +type NotificationPermission = "default" | "denied" | "granted"; +type PushEncryptionKeyName = "p256dh" | "auth"; +type PushPermissionState = "granted" | "denied" | "prompt"; +type ReferrerPolicy = "" | "no-referrer" | "no-referrer-when-downgrade" | "origin-only" | "origin-when-cross-origin" | "unsafe-url"; +type RequestCache = "default" | "no-store" | "reload" | "no-cache" | "force-cache"; +type RequestCredentials = "omit" | "same-origin" | "include"; +type RequestDestination = "" | "document" | "sharedworker" | "subresource" | "unknown" | "worker"; +type RequestMode = "navigate" | "same-origin" | "no-cors" | "cors"; +type RequestRedirect = "follow" | "error" | "manual"; +type RequestType = "" | "audio" | "font" | "image" | "script" | "style" | "track" | "video"; +type ResponseType = "basic" | "cors" | "default" | "error" | "opaque" | "opaqueredirect"; +type ServiceWorkerState = "installing" | "installed" | "activating" | "activated" | "redundant"; +type VisibilityState = "hidden" | "visible" | "prerender" | "unloaded"; +type XMLHttpRequestResponseType = "" | "arraybuffer" | "blob" | "document" | "json" | "text"; +type ClientType = "window" | "worker" | "sharedworker" | "all"; +type FrameType = "auxiliary" | "top-level" | "nested" | "none"; \ No newline at end of file diff --git a/lib/protocol.d.ts b/lib/protocol.d.ts index e675ba87417..9e26197e21d 100644 --- a/lib/protocol.d.ts +++ b/lib/protocol.d.ts @@ -1,6 +1,6 @@ /** - * Declaration module describing the TypeScript Server protocol - */ + * Declaration module describing the TypeScript Server protocol + */ declare namespace ts.server.protocol { namespace CommandTypes { type Brace = "brace"; @@ -49,82 +49,82 @@ declare namespace ts.server.protocol { type GetSupportedCodeFixes = "getSupportedCodeFixes"; } /** - * A TypeScript Server message - */ + * A TypeScript Server message + */ interface Message { /** - * Sequence number of the message - */ + * Sequence number of the message + */ seq: number; /** - * One of "request", "response", or "event" - */ + * One of "request", "response", or "event" + */ type: "request" | "response" | "event"; } /** - * Client-initiated request message - */ + * Client-initiated request message + */ interface Request extends Message { /** - * The command to execute - */ + * The command to execute + */ command: string; /** - * Object containing arguments for the command - */ + * Object containing arguments for the command + */ arguments?: any; } /** - * Request to reload the project structure for all the opened files - */ + * Request to reload the project structure for all the opened files + */ interface ReloadProjectsRequest extends Message { command: CommandTypes.ReloadProjects; } /** - * Server-initiated event message - */ + * Server-initiated event message + */ interface Event extends Message { /** - * Name of event - */ + * Name of event + */ event: string; /** - * Event-specific information - */ + * Event-specific information + */ body?: any; } /** - * Response by server to client request message. - */ + * Response by server to client request message. + */ interface Response extends Message { /** - * Sequence number of the request message. - */ + * Sequence number of the request message. + */ request_seq: number; /** - * Outcome of the request. - */ + * Outcome of the request. + */ success: boolean; /** - * The command requested. - */ + * The command requested. + */ command: string; /** - * Contains error message if success === false. - */ + * Contains error message if success === false. + */ message?: string; /** - * Contains message body if success === true. - */ + * Contains message body if success === true. + */ body?: any; } /** - * Arguments for FileRequest messages. - */ + * Arguments for FileRequest messages. + */ interface FileRequestArgs { /** - * The file for the request (absolute pathname required). - */ + * The file for the request (absolute pathname required). + */ file: string; projectFileName?: string; } @@ -199,17 +199,17 @@ declare namespace ts.server.protocol { options?: EditorSettings; } /** - * Arguments for ProjectInfoRequest request. - */ + * Arguments for ProjectInfoRequest request. + */ interface ProjectInfoRequestArgs extends FileRequestArgs { /** - * Indicate if the file name list of the project is needed - */ + * Indicate if the file name list of the project is needed + */ needFileNameList: boolean; } /** - * A request to get the project information of the current file. - */ + * A request to get the project information of the current file. + */ interface ProjectInfoRequest extends Request { command: CommandTypes.ProjectInfo; arguments: ProjectInfoRequestArgs; @@ -230,21 +230,21 @@ declare namespace ts.server.protocol { projectFileName: string; } /** - * Response message body for "projectInfo" request - */ + * Response message body for "projectInfo" request + */ interface ProjectInfo { /** - * For configured project, this is the normalized path of the 'tsconfig.json' file - * For inferred project, this is undefined - */ + * For configured project, this is the normalized path of the 'tsconfig.json' file + * For inferred project, this is undefined + */ configFileName: string; /** - * The list of normalized file name in the project, including 'lib.d.ts' - */ + * The list of normalized file name in the project, including 'lib.d.ts' + */ fileNames?: string[]; /** - * Indicates if the project has a active language service instance - */ + * Indicates if the project has a active language service instance + */ languageServiceDisabled?: boolean; } /** @@ -262,61 +262,61 @@ declare namespace ts.server.protocol { code: number; } /** - * Response message for "projectInfo" request - */ + * Response message for "projectInfo" request + */ interface ProjectInfoResponse extends Response { body?: ProjectInfo; } /** - * Request whose sole parameter is a file name. - */ + * Request whose sole parameter is a file name. + */ interface FileRequest extends Request { arguments: FileRequestArgs; } /** - * Instances of this interface specify a location in a source file: - * (file, line, character offset), where line and character offset are 1-based. - */ + * Instances of this interface specify a location in a source file: + * (file, line, character offset), where line and character offset are 1-based. + */ interface FileLocationRequestArgs extends FileRequestArgs { /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ line: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ offset: number; } /** - * Request for the available codefixes at a specific position. - */ + * Request for the available codefixes at a specific position. + */ interface CodeFixRequest extends Request { command: CommandTypes.GetCodeFixes; arguments: CodeFixRequestArgs; } /** - * Instances of this interface specify errorcodes on a specific location in a sourcefile. - */ + * Instances of this interface specify errorcodes on a specific location in a sourcefile. + */ interface CodeFixRequestArgs extends FileRequestArgs { /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ startLine: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ startOffset: number; /** - * The line number for the request (1-based). - */ + * The line number for the request (1-based). + */ endLine: number; /** - * The character offset (on the line) for the request (1-based). - */ + * The character offset (on the line) for the request (1-based). + */ endOffset: number; /** - * Errorcodes we want to get the fixes for. - */ + * Errorcodes we want to get the fixes for. + */ errorCodes?: number[]; } /** @@ -326,8 +326,8 @@ declare namespace ts.server.protocol { body?: CodeAction[]; } /** - * A request whose arguments specify a file location (file, line, col). - */ + * A request whose arguments specify a file location (file, line, col). + */ interface FileLocationRequest extends FileRequest { arguments: FileLocationRequestArgs; } @@ -360,9 +360,9 @@ declare namespace ts.server.protocol { length: number; } /** - * Arguments in document highlight request; include: filesToSearch, file, - * line, offset. - */ + * Arguments in document highlight request; include: filesToSearch, file, + * line, offset. + */ interface DocumentHighlightsRequestArgs extends FileLocationRequestArgs { /** * List of files to search for document highlights. @@ -370,73 +370,73 @@ declare namespace ts.server.protocol { filesToSearch: string[]; } /** - * Go to definition request; value of command field is - * "definition". Return response giving the file locations that - * define the symbol found in file at location line, col. - */ + * Go to definition request; value of command field is + * "definition". Return response giving the file locations that + * define the symbol found in file at location line, col. + */ interface DefinitionRequest extends FileLocationRequest { command: CommandTypes.Definition; } /** - * Go to type request; value of command field is - * "typeDefinition". Return response giving the file locations that - * define the type for the symbol found in file at location line, col. - */ + * Go to type request; value of command field is + * "typeDefinition". Return response giving the file locations that + * define the type for the symbol found in file at location line, col. + */ interface TypeDefinitionRequest extends FileLocationRequest { command: CommandTypes.TypeDefinition; } /** - * Go to implementation request; value of command field is - * "implementation". Return response giving the file locations that - * implement the symbol found in file at location line, col. - */ + * Go to implementation request; value of command field is + * "implementation". Return response giving the file locations that + * implement the symbol found in file at location line, col. + */ interface ImplementationRequest extends FileLocationRequest { command: CommandTypes.Implementation; } /** - * Location in source code expressed as (one-based) line and character offset. - */ + * Location in source code expressed as (one-based) line and character offset. + */ interface Location { line: number; offset: number; } /** - * Object found in response messages defining a span of text in source code. - */ + * Object found in response messages defining a span of text in source code. + */ interface TextSpan { /** - * First character of the definition. - */ + * First character of the definition. + */ start: Location; /** - * One character past last character of the definition. - */ + * One character past last character of the definition. + */ end: Location; } /** - * Object found in response messages defining a span of text in a specific source file. - */ + * Object found in response messages defining a span of text in a specific source file. + */ interface FileSpan extends TextSpan { /** - * File containing text span. - */ + * File containing text span. + */ file: string; } /** - * Definition response message. Gives text range for definition. - */ + * Definition response message. Gives text range for definition. + */ interface DefinitionResponse extends Response { body?: FileSpan[]; } /** - * Definition response message. Gives text range for definition. - */ + * Definition response message. Gives text range for definition. + */ interface TypeDefinitionResponse extends Response { body?: FileSpan[]; } /** - * Implementation response message. Gives text range for implementations. - */ + * Implementation response message. Gives text range for implementations. + */ interface ImplementationResponse extends Response { body?: FileSpan[]; } @@ -457,27 +457,31 @@ declare namespace ts.server.protocol { openingBrace: string; } /** - * Get occurrences request; value of command field is - * "occurrences". Return response giving spans that are relevant - * in the file at a given line and column. - */ + * Get occurrences request; value of command field is + * "occurrences". Return response giving spans that are relevant + * in the file at a given line and column. + */ interface OccurrencesRequest extends FileLocationRequest { command: CommandTypes.Occurrences; } interface OccurrencesResponseItem extends FileSpan { /** - * True if the occurrence is a write location, false otherwise. - */ + * True if the occurrence is a write location, false otherwise. + */ isWriteAccess: boolean; + /** + * True if the occurrence is in a string, undefined otherwise; + */ + isInString?: true; } interface OccurrencesResponse extends Response { body?: OccurrencesResponseItem[]; } /** - * Get document highlights request; value of command field is - * "documentHighlights". Return response giving spans that are relevant - * in the file at a given line and column. - */ + * Get document highlights request; value of command field is + * "documentHighlights". Return response giving spans that are relevant + * in the file at a given line and column. + */ interface DocumentHighlightsRequest extends FileLocationRequest { command: CommandTypes.DocumentHighlights; arguments: DocumentHighlightsRequestArgs; @@ -494,12 +498,12 @@ declare namespace ts.server.protocol { */ interface DocumentHighlightsItem { /** - * File containing highlight spans. - */ + * File containing highlight spans. + */ file: string; /** - * Spans to highlight in file. - */ + * Spans to highlight in file. + */ highlightSpans: HighlightSpan[]; } /** @@ -509,23 +513,23 @@ declare namespace ts.server.protocol { body?: DocumentHighlightsItem[]; } /** - * Find references request; value of command field is - * "references". Return response giving the file locations that - * reference the symbol found in file at location line, col. - */ + * Find references request; value of command field is + * "references". Return response giving the file locations that + * reference the symbol found in file at location line, col. + */ interface ReferencesRequest extends FileLocationRequest { command: CommandTypes.References; } interface ReferencesResponseItem extends FileSpan { /** Text of line containing the reference. Including this - * with the response avoids latency of editor loading files - * to show text of reference line (the server already has - * loaded the referencing files). - */ + * with the response avoids latency of editor loading files + * to show text of reference line (the server already has + * loaded the referencing files). + */ lineText: string; /** - * True if reference is a write location, false otherwise. - */ + * True if reference is a write location, false otherwise. + */ isWriteAccess: boolean; /** * True if reference is a definition, false otherwise. @@ -533,29 +537,29 @@ declare namespace ts.server.protocol { isDefinition: boolean; } /** - * The body of a "references" response message. - */ + * The body of a "references" response message. + */ interface ReferencesResponseBody { /** - * The file locations referencing the symbol. - */ + * The file locations referencing the symbol. + */ refs: ReferencesResponseItem[]; /** - * The name of the symbol. - */ + * The name of the symbol. + */ symbolName: string; /** - * The start character offset of the symbol (on the line provided by the references request). - */ + * The start character offset of the symbol (on the line provided by the references request). + */ symbolStartOffset: number; /** - * The full display name of the symbol. - */ + * The full display name of the symbol. + */ symbolDisplayString: string; } /** - * Response to "references" request. - */ + * Response to "references" request. + */ interface ReferencesResponse extends Response { body?: ReferencesResponseBody; } @@ -573,42 +577,42 @@ declare namespace ts.server.protocol { findInStrings?: boolean; } /** - * Rename request; value of command field is "rename". Return - * response giving the file locations that reference the symbol - * found in file at location line, col. Also return full display - * name of the symbol so that client can print it unambiguously. - */ + * Rename request; value of command field is "rename". Return + * response giving the file locations that reference the symbol + * found in file at location line, col. Also return full display + * name of the symbol so that client can print it unambiguously. + */ interface RenameRequest extends FileLocationRequest { command: CommandTypes.Rename; arguments: RenameRequestArgs; } /** - * Information about the item to be renamed. - */ + * Information about the item to be renamed. + */ interface RenameInfo { /** - * True if item can be renamed. - */ + * True if item can be renamed. + */ canRename: boolean; /** - * Error message if item can not be renamed. - */ + * Error message if item can not be renamed. + */ localizedErrorMessage?: string; /** - * Display name of the item to be renamed. - */ + * Display name of the item to be renamed. + */ displayName: string; /** - * Full display name of item to be renamed. - */ + * Full display name of item to be renamed. + */ fullDisplayName: string; /** - * The items's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The items's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; } /** @@ -631,8 +635,8 @@ declare namespace ts.server.protocol { locs: SpanGroup[]; } /** - * Rename response message. - */ + * Rename response message. + */ interface RenameResponse extends Response { body?: RenameResponseBody; } @@ -640,7 +644,7 @@ declare namespace ts.server.protocol { * Represents a file in external project. * External project is project whose set of files, compilation options and open\close state * is maintained by the client (i.e. if all this data come from .csproj file in Visual Studio). - * External project will exist even if all files in it are closed and should be closed explicity. + * External project will exist even if all files in it are closed and should be closed explicitly. * If external project includes one or more tsconfig.json/jsconfig.json files then tsserver will * create configured project for every config file but will maintain a link that these projects were created * as a result of opening external project so they should be removed once external project is closed. @@ -717,17 +721,17 @@ declare namespace ts.server.protocol { updated: string[]; } /** - * Information found in a configure request. - */ + * Information found in a configure request. + */ interface ConfigureRequestArguments { /** - * Information about the host, for example 'Emacs 24.4' or - * 'Sublime Text version 3075' - */ + * Information about the host, for example 'Emacs 24.4' or + * 'Sublime Text version 3075' + */ hostInfo?: string; /** - * If present, tab settings apply only to this file. - */ + * If present, tab settings apply only to this file. + */ file?: string; /** * The format options to use during formatting and other code editing features. @@ -739,22 +743,22 @@ declare namespace ts.server.protocol { extraFileExtensions?: JsFileExtensionInfo[]; } /** - * Configure request; value of command field is "configure". Specifies - * host information, such as host type, tab size, and indent size. - */ + * Configure request; value of command field is "configure". Specifies + * host information, such as host type, tab size, and indent size. + */ interface ConfigureRequest extends Request { command: CommandTypes.Configure; arguments: ConfigureRequestArguments; } /** - * Response to "configure" request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to "configure" request. This is just an acknowledgement, so + * no body field is required. + */ interface ConfigureResponse extends Response { } /** - * Information found in an "open" request. - */ + * Information found in an "open" request. + */ interface OpenRequestArgs extends FileRequestArgs { /** * Used when a version of the file content is known to be more up to date than the one on disk. @@ -766,16 +770,21 @@ declare namespace ts.server.protocol { * "TS", "JS", "TSX", "JSX" */ scriptKindName?: ScriptKindName; + /** + * Used to limit the searching for project config file. If given the searching will stop at this + * root path; otherwise it will go all the way up to the dist root path. + */ + projectRootPath?: string; } type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; /** - * Open request; value of command field is "open". Notify the - * server that the client has file open. The server will not - * monitor the filesystem for changes in this file and will assume - * that the client is updating the server (using the change and/or - * reload messages) when the file changes. Server does not currently - * send a response to an open request. - */ + * Open request; value of command field is "open". Notify the + * server that the client has file open. The server will not + * monitor the filesystem for changes in this file and will assume + * that the client is updating the server (using the change and/or + * reload messages) when the file changes. Server does not currently + * send a response to an open request. + */ interface OpenRequest extends Request { command: CommandTypes.Open; arguments: OpenRequestArgs; @@ -864,25 +873,25 @@ declare namespace ts.server.protocol { options: ExternalProjectCompilerOptions; } /** - * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to SetCompilerOptionsForInferredProjectsResponse request. This is just an acknowledgement, so + * no body field is required. + */ interface SetCompilerOptionsForInferredProjectsResponse extends Response { } /** - * Exit request; value of command field is "exit". Ask the server process - * to exit. - */ + * Exit request; value of command field is "exit". Ask the server process + * to exit. + */ interface ExitRequest extends Request { command: CommandTypes.Exit; } /** - * Close request; value of command field is "close". Notify the - * server that the client has closed a previously open file. If - * file is still referenced by open files, the server will resume - * monitoring the filesystem for changes to file. Server does not - * currently send a response to a close request. - */ + * Close request; value of command field is "close". Notify the + * server that the client has closed a previously open file. If + * file is still referenced by open files, the server will resume + * monitoring the filesystem for changes to file. Server does not + * currently send a response to a close request. + */ interface CloseRequest extends FileRequest { command: CommandTypes.Close; } @@ -933,60 +942,64 @@ declare namespace ts.server.protocol { forced?: boolean; } /** - * Quickinfo request; value of command field is - * "quickinfo". Return response giving a quick type and - * documentation string for the symbol found in file at location - * line, col. - */ + * Quickinfo request; value of command field is + * "quickinfo". Return response giving a quick type and + * documentation string for the symbol found in file at location + * line, col. + */ interface QuickInfoRequest extends FileLocationRequest { command: CommandTypes.Quickinfo; } /** - * Body of QuickInfoResponse. - */ + * Body of QuickInfoResponse. + */ interface QuickInfoResponseBody { /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * Starting file location of symbol. - */ + * Starting file location of symbol. + */ start: Location; /** - * One past last character of symbol. - */ + * One past last character of symbol. + */ end: Location; /** - * Type and kind of symbol. - */ + * Type and kind of symbol. + */ displayString: string; /** - * Documentation associated with symbol. - */ + * Documentation associated with symbol. + */ documentation: string; + /** + * JSDoc tags associated with symbol. + */ + tags: JSDocTagInfo[]; } /** - * Quickinfo response message. - */ + * Quickinfo response message. + */ interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; } /** - * Arguments for format messages. - */ + * Arguments for format messages. + */ interface FormatRequestArgs extends FileLocationRequestArgs { /** - * Last line of range for which to format text in file. - */ + * Last line of range for which to format text in file. + */ endLine: number; /** - * Character offset on last line of range for which to format text in file. - */ + * Character offset on last line of range for which to format text in file. + */ endOffset: number; /** * Format options to be used. @@ -994,36 +1007,36 @@ declare namespace ts.server.protocol { options?: FormatCodeSettings; } /** - * Format request; value of command field is "format". Return - * response giving zero or more edit instructions. The edit - * instructions will be sorted in file order. Applying the edit - * instructions in reverse to file will result in correctly - * reformatted text. - */ + * Format request; value of command field is "format". Return + * response giving zero or more edit instructions. The edit + * instructions will be sorted in file order. Applying the edit + * instructions in reverse to file will result in correctly + * reformatted text. + */ interface FormatRequest extends FileLocationRequest { command: CommandTypes.Format; arguments: FormatRequestArgs; } /** - * Object found in response messages defining an editing - * instruction for a span of text in source code. The effect of - * this instruction is to replace the text starting at start and - * ending one character before end with newText. For an insertion, - * the text span is empty. For a deletion, newText is empty. - */ + * Object found in response messages defining an editing + * instruction for a span of text in source code. The effect of + * this instruction is to replace the text starting at start and + * ending one character before end with newText. For an insertion, + * the text span is empty. For a deletion, newText is empty. + */ interface CodeEdit { /** - * First character of the text span to edit. - */ + * First character of the text span to edit. + */ start: Location; /** - * One character past last character of the text span to edit. - */ + * One character past last character of the text span to edit. + */ end: Location; /** - * Replace the span defined above with this string (may be - * the empty string). - */ + * Replace the span defined above with this string (may be + * the empty string). + */ newText: string; } interface FileCodeEdits { @@ -1041,99 +1054,99 @@ declare namespace ts.server.protocol { changes: FileCodeEdits[]; } /** - * Format and format on key response message. - */ + * Format and format on key response message. + */ interface FormatResponse extends Response { body?: CodeEdit[]; } /** - * Arguments for format on key messages. - */ + * Arguments for format on key messages. + */ interface FormatOnKeyRequestArgs extends FileLocationRequestArgs { /** - * Key pressed (';', '\n', or '}'). - */ + * Key pressed (';', '\n', or '}'). + */ key: string; options?: FormatCodeSettings; } /** - * Format on key request; value of command field is - * "formatonkey". Given file location and key typed (as string), - * return response giving zero or more edit instructions. The - * edit instructions will be sorted in file order. Applying the - * edit instructions in reverse to file will result in correctly - * reformatted text. - */ + * Format on key request; value of command field is + * "formatonkey". Given file location and key typed (as string), + * return response giving zero or more edit instructions. The + * edit instructions will be sorted in file order. Applying the + * edit instructions in reverse to file will result in correctly + * reformatted text. + */ interface FormatOnKeyRequest extends FileLocationRequest { command: CommandTypes.Formatonkey; arguments: FormatOnKeyRequestArgs; } /** - * Arguments for completions messages. - */ + * Arguments for completions messages. + */ interface CompletionsRequestArgs extends FileLocationRequestArgs { /** - * Optional prefix to apply to possible completions. - */ + * Optional prefix to apply to possible completions. + */ prefix?: string; } /** - * Completions request; value of command field is "completions". - * Given a file location (file, line, col) and a prefix (which may - * be the empty string), return the possible completions that - * begin with prefix. - */ + * Completions request; value of command field is "completions". + * Given a file location (file, line, col) and a prefix (which may + * be the empty string), return the possible completions that + * begin with prefix. + */ interface CompletionsRequest extends FileLocationRequest { command: CommandTypes.Completions; arguments: CompletionsRequestArgs; } /** - * Arguments for completion details request. - */ + * Arguments for completion details request. + */ interface CompletionDetailsRequestArgs extends FileLocationRequestArgs { /** - * Names of one or more entries for which to obtain details. - */ + * Names of one or more entries for which to obtain details. + */ entryNames: string[]; } /** - * Completion entry details request; value of command field is - * "completionEntryDetails". Given a file location (file, line, - * col) and an array of completion entry names return more - * detailed information for each completion entry. - */ + * Completion entry details request; value of command field is + * "completionEntryDetails". Given a file location (file, line, + * col) and an array of completion entry names return more + * detailed information for each completion entry. + */ interface CompletionDetailsRequest extends FileLocationRequest { command: CommandTypes.CompletionDetails; arguments: CompletionDetailsRequestArgs; } /** - * Part of a symbol description. - */ + * Part of a symbol description. + */ interface SymbolDisplayPart { /** - * Text of an item describing the symbol. - */ + * Text of an item describing the symbol. + */ text: string; /** - * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). - */ + * The symbol's kind (such as 'className' or 'parameterName' or plain 'text'). + */ kind: string; } /** - * An item found in a completion response. - */ + * An item found in a completion response. + */ interface CompletionEntry { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** * A string that is used for comparing completion items so that they can be ordered. This @@ -1147,29 +1160,33 @@ declare namespace ts.server.protocol { replacementSpan?: TextSpan; } /** - * Additional completion entry details, available on demand - */ + * Additional completion entry details, available on demand + */ interface CompletionEntryDetails { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers: string; /** - * Display parts of the symbol (similar to quick info). - */ + * Display parts of the symbol (similar to quick info). + */ displayParts: SymbolDisplayPart[]; /** - * Documentation strings for the symbol. - */ + * Documentation strings for the symbol. + */ documentation: SymbolDisplayPart[]; + /** + * JSDoc tags for the symbol. + */ + tags: JSDocTagInfo[]; } interface CompletionsResponse extends Response { body?: CompletionEntry[]; @@ -1186,12 +1203,12 @@ declare namespace ts.server.protocol { */ name: string; /** - * Documentation of the parameter. - */ + * Documentation of the parameter. + */ documentation: SymbolDisplayPart[]; /** - * Display parts of the parameter. - */ + * Display parts of the parameter. + */ displayParts: SymbolDisplayPart[]; /** * Whether the parameter is optional or not. @@ -1226,6 +1243,10 @@ declare namespace ts.server.protocol { * The signature's documentation */ documentation: SymbolDisplayPart[]; + /** + * The signature's JSDoc tags + */ + tags: JSDocTagInfo[]; } /** * Signature help items found in the response of a signature help request. @@ -1258,10 +1279,10 @@ declare namespace ts.server.protocol { interface SignatureHelpRequestArgs extends FileLocationRequestArgs { } /** - * Signature help request; value of command field is "signatureHelp". - * Given a file location (file, line, col), return the signature - * help. - */ + * Signature help request; value of command field is "signatureHelp". + * Given a file location (file, line, col), return the signature + * help. + */ interface SignatureHelpRequest extends FileLocationRequest { command: CommandTypes.SignatureHelp; arguments: SignatureHelpRequestArgs; @@ -1273,8 +1294,8 @@ declare namespace ts.server.protocol { body?: SignatureHelpItems; } /** - * Synchronous request for semantic diagnostics of one file. - */ + * Synchronous request for semantic diagnostics of one file. + */ interface SemanticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SemanticDiagnosticsSync; arguments: SemanticDiagnosticsSyncRequestArgs; @@ -1283,14 +1304,14 @@ declare namespace ts.server.protocol { includeLinePosition?: boolean; } /** - * Response object for synchronous sematic diagnostics request. - */ + * Response object for synchronous sematic diagnostics request. + */ interface SemanticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } /** - * Synchronous request for syntactic diagnostics of one file. - */ + * Synchronous request for syntactic diagnostics of one file. + */ interface SyntacticDiagnosticsSyncRequest extends FileRequest { command: CommandTypes.SyntacticDiagnosticsSync; arguments: SyntacticDiagnosticsSyncRequestArgs; @@ -1299,59 +1320,59 @@ declare namespace ts.server.protocol { includeLinePosition?: boolean; } /** - * Response object for synchronous syntactic diagnostics request. - */ + * Response object for synchronous syntactic diagnostics request. + */ interface SyntacticDiagnosticsSyncResponse extends Response { body?: Diagnostic[] | DiagnosticWithLinePosition[]; } /** - * Arguments for GeterrForProject request. - */ + * Arguments for GeterrForProject request. + */ interface GeterrForProjectRequestArgs { /** - * the file requesting project error list - */ + * the file requesting project error list + */ file: string; /** - * Delay in milliseconds to wait before starting to compute - * errors for the files in the file list - */ + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } /** - * GeterrForProjectRequest request; value of command field is - * "geterrForProject". It works similarly with 'Geterr', only - * it request for every file in this project. - */ + * GeterrForProjectRequest request; value of command field is + * "geterrForProject". It works similarly with 'Geterr', only + * it request for every file in this project. + */ interface GeterrForProjectRequest extends Request { command: CommandTypes.GeterrForProject; arguments: GeterrForProjectRequestArgs; } /** - * Arguments for geterr messages. - */ + * Arguments for geterr messages. + */ interface GeterrRequestArgs { /** - * List of file names for which to compute compiler errors. - * The files will be checked in list order. - */ + * List of file names for which to compute compiler errors. + * The files will be checked in list order. + */ files: string[]; /** - * Delay in milliseconds to wait before starting to compute - * errors for the files in the file list - */ + * Delay in milliseconds to wait before starting to compute + * errors for the files in the file list + */ delay: number; } /** - * Geterr request; value of command field is "geterr". Wait for - * delay milliseconds and then, if during the wait no change or - * reload messages have arrived for the first file in the files - * list, get the syntactic errors for the file, field requests, - * and then get the semantic errors for the file. Repeat with a - * smaller delay for each subsequent file on the files list. Best - * practice for an editor is to send a file list containing each - * file that is currently visible, in most-recently-used order. - */ + * Geterr request; value of command field is "geterr". Wait for + * delay milliseconds and then, if during the wait no change or + * reload messages have arrived for the first file in the files + * list, get the syntactic errors for the file, field requests, + * and then get the semantic errors for the file. Repeat with a + * smaller delay for each subsequent file on the files list. Best + * practice for an editor is to send a file list containing each + * file that is currently visible, in most-recently-used order. + */ interface GeterrRequest extends Request { command: CommandTypes.Geterr; arguments: GeterrRequestArgs; @@ -1368,40 +1389,48 @@ declare namespace ts.server.protocol { request_seq: number; } /** - * Item of diagnostic information found in a DiagnosticEvent message. - */ + * Item of diagnostic information found in a DiagnosticEvent message. + */ interface Diagnostic { /** - * Starting file location at which text applies. - */ + * Starting file location at which text applies. + */ start: Location; /** - * The last file location at which the text applies. - */ + * The last file location at which the text applies. + */ end: Location; /** - * Text of diagnostic message. - */ + * Text of diagnostic message. + */ text: string; /** - * The error code of the diagnostic message. - */ + * The category of the diagnostic message, e.g. "error" vs. "warning" + */ + category: string; + /** + * The error code of the diagnostic message. + */ code?: number; + /** + * The name of the plugin reporting the message. + */ + source?: string; } interface DiagnosticEventBody { /** - * The file for which diagnostic information is reported. - */ + * The file for which diagnostic information is reported. + */ file: string; /** - * An array of diagnostic information items. - */ + * An array of diagnostic information items. + */ diagnostics: Diagnostic[]; } /** - * Event message for "syntaxDiag" and "semanticDiag" event types. - * These events provide syntactic and semantic errors for a file. - */ + * Event message for "syntaxDiag" and "semanticDiag" event types. + * These events provide syntactic and semantic errors for a file. + */ interface DiagnosticEvent extends Event { body?: DiagnosticEventBody; } @@ -1447,172 +1476,172 @@ declare namespace ts.server.protocol { languageServiceEnabled: boolean; } /** - * Arguments for reload request. - */ + * Arguments for reload request. + */ interface ReloadRequestArgs extends FileRequestArgs { /** - * Name of temporary file from which to reload file - * contents. May be same as file. - */ + * Name of temporary file from which to reload file + * contents. May be same as file. + */ tmpfile: string; } /** - * Reload request message; value of command field is "reload". - * Reload contents of file with name given by the 'file' argument - * from temporary file with name given by the 'tmpfile' argument. - * The two names can be identical. - */ + * Reload request message; value of command field is "reload". + * Reload contents of file with name given by the 'file' argument + * from temporary file with name given by the 'tmpfile' argument. + * The two names can be identical. + */ interface ReloadRequest extends FileRequest { command: CommandTypes.Reload; arguments: ReloadRequestArgs; } /** - * Response to "reload" request. This is just an acknowledgement, so - * no body field is required. - */ + * Response to "reload" request. This is just an acknowledgement, so + * no body field is required. + */ interface ReloadResponse extends Response { } /** - * Arguments for saveto request. - */ + * Arguments for saveto request. + */ interface SavetoRequestArgs extends FileRequestArgs { /** - * Name of temporary file into which to save server's view of - * file contents. - */ + * Name of temporary file into which to save server's view of + * file contents. + */ tmpfile: string; } /** - * Saveto request message; value of command field is "saveto". - * For debugging purposes, save to a temporaryfile (named by - * argument 'tmpfile') the contents of file named by argument - * 'file'. The server does not currently send a response to a - * "saveto" request. - */ + * Saveto request message; value of command field is "saveto". + * For debugging purposes, save to a temporaryfile (named by + * argument 'tmpfile') the contents of file named by argument + * 'file'. The server does not currently send a response to a + * "saveto" request. + */ interface SavetoRequest extends FileRequest { command: CommandTypes.Saveto; arguments: SavetoRequestArgs; } /** - * Arguments for navto request message. - */ + * Arguments for navto request message. + */ interface NavtoRequestArgs extends FileRequestArgs { /** - * Search term to navigate to from current location; term can - * be '.*' or an identifier prefix. - */ + * Search term to navigate to from current location; term can + * be '.*' or an identifier prefix. + */ searchValue: string; /** - * Optional limit on the number of items to return. - */ + * Optional limit on the number of items to return. + */ maxResultCount?: number; /** - * Optional flag to indicate we want results for just the current file - * or the entire project. - */ + * Optional flag to indicate we want results for just the current file + * or the entire project. + */ currentFileOnly?: boolean; projectFileName?: string; } /** - * Navto request message; value of command field is "navto". - * Return list of objects giving file locations and symbols that - * match the search term given in argument 'searchTerm'. The - * context for the search is given by the named file. - */ + * Navto request message; value of command field is "navto". + * Return list of objects giving file locations and symbols that + * match the search term given in argument 'searchTerm'. The + * context for the search is given by the named file. + */ interface NavtoRequest extends FileRequest { command: CommandTypes.Navto; arguments: NavtoRequestArgs; } /** - * An item found in a navto response. - */ + * An item found in a navto response. + */ interface NavtoItem { /** - * The symbol's name. - */ + * The symbol's name. + */ name: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * exact, substring, or prefix. - */ + * exact, substring, or prefix. + */ matchKind?: string; /** - * If this was a case sensitive or insensitive match. - */ + * If this was a case sensitive or insensitive match. + */ isCaseSensitive?: boolean; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; /** - * The file in which the symbol is found. - */ + * The file in which the symbol is found. + */ file: string; /** - * The location within file at which the symbol is found. - */ + * The location within file at which the symbol is found. + */ start: Location; /** - * One past the last character of the symbol. - */ + * One past the last character of the symbol. + */ end: Location; /** - * Name of symbol's container symbol (if any); for example, - * the class name if symbol is a class member. - */ + * Name of symbol's container symbol (if any); for example, + * the class name if symbol is a class member. + */ containerName?: string; /** - * Kind of symbol's container symbol (if any). - */ + * Kind of symbol's container symbol (if any). + */ containerKind?: string; } /** - * Navto response message. Body is an array of navto items. Each - * item gives a symbol that matched the search term. - */ + * Navto response message. Body is an array of navto items. Each + * item gives a symbol that matched the search term. + */ interface NavtoResponse extends Response { body?: NavtoItem[]; } /** - * Arguments for change request message. - */ + * Arguments for change request message. + */ interface ChangeRequestArgs extends FormatRequestArgs { /** - * Optional string to insert at location (file, line, offset). - */ + * Optional string to insert at location (file, line, offset). + */ insertString?: string; } /** - * Change request message; value of command field is "change". - * Update the server's view of the file named by argument 'file'. - * Server does not currently send a response to a change request. - */ + * Change request message; value of command field is "change". + * Update the server's view of the file named by argument 'file'. + * Server does not currently send a response to a change request. + */ interface ChangeRequest extends FileLocationRequest { command: CommandTypes.Change; arguments: ChangeRequestArgs; } /** - * Response to "brace" request. - */ + * Response to "brace" request. + */ interface BraceResponse extends Response { body?: TextSpan[]; } /** - * Brace matching request; value of command field is "brace". - * Return response giving the file locations of matching braces - * found in file at location line, offset. - */ + * Brace matching request; value of command field is "brace". + * Return response giving the file locations of matching braces + * found in file at location line, offset. + */ interface BraceRequest extends FileLocationRequest { command: CommandTypes.Brace; } /** - * NavBar items request; value of command field is "navbar". - * Return response giving the list of navigation bar entries - * extracted from the requested file. - */ + * NavBar items request; value of command field is "navbar". + * Return response giving the list of navigation bar entries + * extracted from the requested file. + */ interface NavBarRequest extends FileRequest { command: CommandTypes.NavBar; } @@ -1625,28 +1654,28 @@ declare namespace ts.server.protocol { } interface NavigationBarItem { /** - * The item's display text. - */ + * The item's display text. + */ text: string; /** - * The symbol's kind (such as 'className' or 'parameterName'). - */ + * The symbol's kind (such as 'className' or 'parameterName'). + */ kind: string; /** - * Optional modifiers for the kind (such as 'public'). - */ + * Optional modifiers for the kind (such as 'public'). + */ kindModifiers?: string; /** - * The definition locations of the item. - */ + * The definition locations of the item. + */ spans: TextSpan[]; /** - * Optional children. - */ + * Optional children. + */ childItems?: NavigationBarItem[]; /** - * Number of levels deep this item should appear. - */ + * Number of levels deep this item should appear. + */ indent: number; } /** protocol.NavigationTree is identical to ts.NavigationTree, except using protocol.TextSpan instead of ts.TextSpan */ @@ -1666,6 +1695,14 @@ declare namespace ts.server.protocol { telemetryEventName: string; payload: any; } + type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + interface TypesInstallerInitializationFailedEvent extends Event { + event: TypesInstallerInitializationFailedEventName; + body: TypesInstallerInitializationFailedEventBody; + } + interface TypesInstallerInitializationFailedEventBody { + message: string; + } type TypingsInstalledTelemetryEventName = "typingsInstalled"; interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { telemetryEventName: TypingsInstalledTelemetryEventName; @@ -1754,15 +1791,19 @@ declare namespace ts.server.protocol { allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; + alwaysStrict?: boolean; baseUrl?: string; charset?: string; + checkJs?: boolean; declaration?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; + importHelpers?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; @@ -1802,6 +1843,7 @@ declare namespace ts.server.protocol { skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strict?: boolean; strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; @@ -1879,6 +1921,11 @@ declare namespace ts.server.protocol { isMixedContent: boolean; } + interface JSDocTagInfo { + name: string; + text?: string; + } + /** * Type of objects whose values are all of the same type. * The `in` and `for-in` operators can *not* be safely used, diff --git a/lib/tsc.js b/lib/tsc.js index f7231fcafd8..693a32dc98b 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -27,6 +27,16 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + NodeBuilderFlags[NodeBuilderFlags["allowThisInObjectLiteral"] = 1] = "allowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["allowQualifedNameInPlaceOfIdentifier"] = 2] = "allowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowTypeParameterInQualifiedName"] = 4] = "allowTypeParameterInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["allowAnonymousIdentifier"] = 8] = "allowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyUnionOrIntersection"] = 16] = "allowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyTuple"] = 32] = "allowEmptyTuple"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -132,7 +142,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.3.0"; + ts.version = "2.4.0"; })(ts || (ts = {})); (function (ts) { ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; @@ -284,6 +294,20 @@ var ts; return undefined; } ts.forEach = forEach; + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; function zipWith(arrayA, arrayB, callback) { Debug.assert(arrayA.length === arrayB.length); for (var i = 0; i < arrayA.length; i++) { @@ -837,10 +861,10 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function arrayFrom(iterator) { + function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { - result.push(value); + result.push(map ? map(value) : value); } return result; var _b; @@ -893,10 +917,10 @@ var ts; } for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { var arg = args_1[_a]; - for (var _b = 0, _c = getOwnKeys(arg); _b < _c.length; _b++) { - var p = _c[_b]; - t[p] = arg[p]; - } + for (var p in arg) + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } } return t; } @@ -2022,136 +2046,29 @@ var ts; } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; + function isCheckJsEnabledForFile(sourceFile, compilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; })(ts || (ts = {})); var ts; (function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var shell = new ActiveXObject("WScript.Shell"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function getDirectories(path) { - var folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - function getAccessibleFileSystemEntries(path) { - try { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - var directories = getNames(folder.subfolders); - return { files: files, directories: directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function readDirectory(path, extensions, excludes, includes) { - return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - var wscriptSystem = { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return shell.CurrentDirectory; - }, - getDirectories: getDirectories, - getEnvironmentVariable: function (name) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings("%" + name + "%"); - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; + function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; } + var version = process.version; + if (!version) { + return undefined; + } + var dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + ts.getNodeMajorVersion = getNodeMajorVersion; + ts.sys = (function () { function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); @@ -2215,9 +2132,8 @@ var ts; } } var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } + var nodeVersion = getNodeMajorVersion(); + var isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive() { if (platform === "win32" || platform === "win64") { return false; @@ -2351,10 +2267,10 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + if (!directoryExists(directoryName)) { return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { @@ -2364,11 +2280,7 @@ var ts; if (eventName === "rename") { callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName))); } - ; }); - function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; - } }, resolvePath: function (path) { return _path.resolve(path); @@ -2484,9 +2396,6 @@ var ts; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { sys = getNodeSystem(); } @@ -2555,11 +2464,11 @@ var ts; Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", message: "The return type of an async function must either be a valid promise or must not contain a callable 'then' member." }, + A_promise_must_have_a_then_method: { code: 1059, category: ts.DiagnosticCategory.Error, key: "A_promise_must_have_a_then_method_1059", message: "A promise must have a 'then' method." }, + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: { code: 1060, category: ts.DiagnosticCategory.Error, key: "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", message: "The first parameter of the 'then' method of a promise must be a callback." }, 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." }, + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "Type 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." }, @@ -2584,6 +2493,7 @@ var ts; Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: { code: 1103, category: ts.DiagnosticCategory.Error, key: "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", message: "A 'for-await-of' statement is only allowed within an async function or async generator." }, A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, @@ -2591,7 +2501,7 @@ var ts; Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'." }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, @@ -2623,9 +2533,9 @@ var ts; 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_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." }, - 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" }, + 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" }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized." }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, @@ -2674,8 +2584,8 @@ var ts; Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_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." }, @@ -2727,6 +2637,9 @@ var ts; A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1320, category: ts.DiagnosticCategory.Error, key: "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", message: "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1321, category: ts.DiagnosticCategory.Error, key: "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", message: "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1322, category: ts.DiagnosticCategory.Error, key: "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", message: "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2788,13 +2701,13 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'." }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, @@ -2834,12 +2747,12 @@ var ts; The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class." }, The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - 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_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}'." }, 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}'." }, @@ -2848,19 +2761,19 @@ var ts; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, 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}'" }, + 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_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}'" }, + 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." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged." }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged." }, Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name." }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'." }, Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'." }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, @@ -2869,18 +2782,20 @@ 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." }, + Class_0_used_before_its_declaration: { code: 2449, category: ts.DiagnosticCategory.Error, key: "Class_0_used_before_its_declaration_2449", message: "Class '{0}' used before its declaration." }, + Enum_0_used_before_its_declaration: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Enum_0_used_before_its_declaration_2450", message: "Enum '{0}' used before its declaration." }, 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." }, Variable_0_is_used_before_being_assigned: { code: 2454, category: ts.DiagnosticCategory.Error, key: "Variable_0_is_used_before_being_assigned_2454", message: "Variable '{0}' is used before being assigned." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'." }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern." }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -2901,13 +2816,13 @@ var ts; let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, 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}'" }, + 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_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, 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." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause." }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, @@ -2919,6 +2834,7 @@ var ts; A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: { code: 2504, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", message: "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, @@ -2933,6 +2849,7 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, + An_async_iterator_must_have_a_next_method: { code: 2519, category: ts.DiagnosticCategory.Error, key: "An_async_iterator_must_have_a_next_method_2519", message: "An async iterator must have a 'next()' method." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", message: "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method." }, @@ -2960,25 +2877,29 @@ var ts; Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, + The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: { code: 2547, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", message: "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property." }, + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2548, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", message: "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2549, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", message: "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: { code: 2550, category: ts.DiagnosticCategory.Error, key: "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", message: "Generic type instantiation is excessively deep and possibly infinite." }, 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." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'." }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property." }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property." }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React." }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, - Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element." }, + Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'." }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", message: "Cannot export '{0}'. Only local declarations can be exported from a module." }, @@ -3010,7 +2931,6 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, - A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { code: 2693, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", message: "'{0}' only refers to a type, but is being used as a value here." }, @@ -3023,11 +2943,14 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, - The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference." }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property." }, An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, + Cannot_use_namespace_0_as_a_value: { code: 2708, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_value_2708", message: "Cannot use namespace '{0}' as a value." }, + Cannot_use_namespace_0_as_a_type: { code: 2709, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_type_2709", message: "Cannot use namespace '{0}' as a type." }, + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: { code: 2710, category: ts.DiagnosticCategory.Error, key: "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", message: "'{0}' are specified twice. The attribute named '{0}' will be overwritten." }, 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}'." }, @@ -3107,12 +3030,11 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { code: 5011, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011", message: "File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}." }, Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", message: "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, @@ -3121,12 +3043,12 @@ var ts; A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, 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}'" }, + 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}'." }, 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" }, + 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." }, Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." }, Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, @@ -3144,11 +3066,11 @@ var ts; Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'." }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -3168,7 +3090,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_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}" }, + Argument_for_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}." }, 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}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, @@ -3190,18 +3112,18 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context (experimental)." }, Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'." }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, 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}." }, 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." }, - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", message: "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit" }, Enable_tracing_of_the_name_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_name_resolution_process_6085", message: "Enable tracing of the name 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}'." }, @@ -3223,12 +3145,12 @@ var ts; 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_0_field_in_package_json_to_be_string_got_1: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", message: "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'." }, - 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" }, + 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." }, Enable_strict_null_checks: { code: 6113, category: ts.DiagnosticCategory.Message, key: "Enable_strict_null_checks_6113", message: "Enable strict null checks." }, Unknown_option_excludes_Did_you_mean_exclude: { code: 6114, category: ts.DiagnosticCategory.Error, key: "Unknown_option_excludes_Did_you_mean_exclude_6114", message: "Unknown option 'excludes'. Did you mean 'exclude'?" }, @@ -3238,26 +3160,26 @@ var ts; Resolving_from_node_modules_folder: { code: 6118, category: ts.DiagnosticCategory.Message, key: "Resolving_from_node_modules_folder_6118", message: "Resolving from node_modules folder..." }, Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { code: 6119, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", message: "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========" }, Type_reference_directive_0_was_not_resolved: { code: 6120, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_not_resolved_6120", message: "======== Type reference directive '{0}' was not resolved. ========" }, - Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'" }, + Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'." }, Root_directory_cannot_be_determined_skipping_primary_search_paths: { code: 6122, category: ts.DiagnosticCategory.Message, key: "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", message: "Root directory cannot be determined, skipping primary search paths." }, Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { code: 6123, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", message: "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========" }, Type_declaration_files_to_be_included_in_compilation: { code: 6124, category: ts.DiagnosticCategory.Message, key: "Type_declaration_files_to_be_included_in_compilation_6124", message: "Type declaration files to be included in compilation." }, - Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'" }, + Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'." }, Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { code: 6126, category: ts.DiagnosticCategory.Message, key: "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", message: "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { code: 6127, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", message: "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========" }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" }, The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." }, - Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, + Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'." }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, - File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it." }, _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files." }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file." }, Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, @@ -3265,6 +3187,40 @@ var ts; Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, + Show_diagnostic_information: { code: 6149, category: ts.DiagnosticCategory.Message, key: "Show_diagnostic_information_6149", message: "Show diagnostic information." }, + Show_verbose_diagnostic_information: { code: 6150, category: ts.DiagnosticCategory.Message, key: "Show_verbose_diagnostic_information_6150", message: "Show verbose diagnostic information." }, + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: { code: 6151, category: ts.DiagnosticCategory.Message, key: "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", message: "Emit a single file with source maps instead of having a separate file." }, + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: { code: 6152, category: ts.DiagnosticCategory.Message, key: "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", message: "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set." }, + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: { code: 6153, category: ts.DiagnosticCategory.Message, key: "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", message: "Transpile each file as a separate module (similar to 'ts.transpileModule')." }, + Print_names_of_generated_files_part_of_the_compilation: { code: 6154, category: ts.DiagnosticCategory.Message, key: "Print_names_of_generated_files_part_of_the_compilation_6154", message: "Print names of generated files part of the compilation." }, + Print_names_of_files_part_of_the_compilation: { code: 6155, category: ts.DiagnosticCategory.Message, key: "Print_names_of_files_part_of_the_compilation_6155", message: "Print names of files part of the compilation." }, + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: { code: 6156, category: ts.DiagnosticCategory.Message, key: "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", message: "The locale used when displaying messages to the user (e.g. 'en-us')" }, + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: { code: 6157, category: ts.DiagnosticCategory.Message, key: "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", message: "Do not generate custom helper functions like '__extends' in compiled output." }, + Do_not_include_the_default_library_file_lib_d_ts: { code: 6158, category: ts.DiagnosticCategory.Message, key: "Do_not_include_the_default_library_file_lib_d_ts_6158", message: "Do not include the default library file (lib.d.ts)." }, + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: { code: 6159, category: ts.DiagnosticCategory.Message, key: "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", message: "Do not add triple-slash references or imported modules to the list of compiled files." }, + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: { code: 6160, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", message: "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files." }, + List_of_folders_to_include_type_definitions_from: { code: 6161, category: ts.DiagnosticCategory.Message, key: "List_of_folders_to_include_type_definitions_from_6161", message: "List of folders to include type definitions from." }, + Disable_size_limitations_on_JavaScript_projects: { code: 6162, category: ts.DiagnosticCategory.Message, key: "Disable_size_limitations_on_JavaScript_projects_6162", message: "Disable size limitations on JavaScript projects." }, + The_character_set_of_the_input_files: { code: 6163, category: ts.DiagnosticCategory.Message, key: "The_character_set_of_the_input_files_6163", message: "The character set of the input files." }, + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: { code: 6164, category: ts.DiagnosticCategory.Message, key: "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", message: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." }, + Do_not_truncate_error_messages: { code: 6165, category: ts.DiagnosticCategory.Message, key: "Do_not_truncate_error_messages_6165", message: "Do not truncate error messages." }, + Output_directory_for_generated_declaration_files: { code: 6166, category: ts.DiagnosticCategory.Message, key: "Output_directory_for_generated_declaration_files_6166", message: "Output directory for generated declaration files." }, + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: { code: 6167, category: ts.DiagnosticCategory.Message, key: "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", message: "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'." }, + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: { code: 6168, category: ts.DiagnosticCategory.Message, key: "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", message: "List of root folders whose combined content represents the structure of the project at runtime." }, + Show_all_compiler_options: { code: 6169, category: ts.DiagnosticCategory.Message, key: "Show_all_compiler_options_6169", message: "Show all compiler options." }, + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: { code: 6170, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", message: "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file" }, + Command_line_Options: { code: 6171, category: ts.DiagnosticCategory.Message, key: "Command_line_Options_6171", message: "Command-line Options" }, + Basic_Options: { code: 6172, category: ts.DiagnosticCategory.Message, key: "Basic_Options_6172", message: "Basic Options" }, + Strict_Type_Checking_Options: { code: 6173, category: ts.DiagnosticCategory.Message, key: "Strict_Type_Checking_Options_6173", message: "Strict Type-Checking Options" }, + Module_Resolution_Options: { code: 6174, category: ts.DiagnosticCategory.Message, key: "Module_Resolution_Options_6174", message: "Module Resolution Options" }, + Source_Map_Options: { code: 6175, category: ts.DiagnosticCategory.Message, key: "Source_Map_Options_6175", message: "Source Map Options" }, + Additional_Checks: { code: 6176, category: ts.DiagnosticCategory.Message, key: "Additional_Checks_6176", message: "Additional Checks" }, + Experimental_Options: { code: 6177, category: ts.DiagnosticCategory.Message, key: "Experimental_Options_6177", message: "Experimental Options" }, + Advanced_Options: { code: 6178, category: ts.DiagnosticCategory.Message, key: "Advanced_Options_6178", message: "Advanced Options" }, + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: { code: 6179, category: ts.DiagnosticCategory.Message, key: "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", message: "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'." }, + Enable_all_strict_type_checking_options: { code: 6180, category: ts.DiagnosticCategory.Message, key: "Enable_all_strict_type_checking_options_6180", message: "Enable all strict type-checking options." }, + List_of_language_service_plugins: { code: 6181, category: ts.DiagnosticCategory.Message, key: "List_of_language_service_plugins_6181", message: "List of language service plugins." }, + Scoped_package_detected_looking_in_0: { code: 6182, category: ts.DiagnosticCategory.Message, key: "Scoped_package_detected_looking_in_0_6182", message: "Scoped package detected, looking in '{0}'" }, 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." }, @@ -3282,7 +3238,7 @@ var ts; _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists." }, Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, @@ -3291,6 +3247,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, + Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: { code: 7035, category: ts.DiagnosticCategory.Error, key: "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", message: "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -3314,14 +3271,14 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + 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." }, 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." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" }, Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, @@ -3330,151 +3287,158 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: '{0}'." }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig." }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, - Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, - Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, - Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}." }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}." }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." }, + Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." }, + Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'." }, + Disable_checking_for_this_file: { code: 90018, category: ts.DiagnosticCategory.Message, key: "Disable_checking_for_this_file_90018", message: "Disable checking for this file." }, + Ignore_this_error_message: { code: 90019, category: ts.DiagnosticCategory.Message, key: "Ignore_this_error_message_90019", message: "Ignore this error message." }, + Initialize_property_0_in_the_constructor: { code: 90020, category: ts.DiagnosticCategory.Message, key: "Initialize_property_0_in_the_constructor_90020", message: "Initialize property '{0}' in the constructor." }, + Initialize_static_property_0: { code: 90021, category: ts.DiagnosticCategory.Message, key: "Initialize_static_property_0_90021", message: "Initialize static property '{0}'." }, Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, + Report_errors_in_js_files: { code: 8019, category: ts.DiagnosticCategory.Message, key: "Report_errors_in_js_files_8019", message: "Report errors in .js files." }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 70; + return token >= 71; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMapFromTemplate({ - "abstract": 116, - "any": 118, - "as": 117, - "boolean": 121, - "break": 71, - "case": 72, - "catch": 73, - "class": 74, - "continue": 76, - "const": 75, - "constructor": 122, - "debugger": 77, - "declare": 123, - "default": 78, - "delete": 79, - "do": 80, - "else": 81, - "enum": 82, - "export": 83, - "extends": 84, - "false": 85, - "finally": 86, - "for": 87, - "from": 139, - "function": 88, - "get": 124, - "if": 89, - "implements": 107, - "import": 90, - "in": 91, - "instanceof": 92, - "interface": 108, - "is": 125, - "keyof": 126, - "let": 109, - "module": 127, - "namespace": 128, - "never": 129, - "new": 93, - "null": 94, - "number": 132, - "object": 133, - "package": 110, - "private": 111, - "protected": 112, - "public": 113, - "readonly": 130, - "require": 131, - "global": 140, - "return": 95, - "set": 134, - "static": 114, - "string": 135, - "super": 96, - "switch": 97, - "symbol": 136, - "this": 98, - "throw": 99, - "true": 100, - "try": 101, - "type": 137, - "typeof": 102, - "undefined": 138, - "var": 103, - "void": 104, - "while": 105, - "with": 106, - "yield": 115, - "async": 119, - "await": 120, - "of": 141, - "{": 16, - "}": 17, - "(": 18, - ")": 19, - "[": 20, - "]": 21, - ".": 22, - "...": 23, - ";": 24, - ",": 25, - "<": 26, - ">": 28, - "<=": 29, - ">=": 30, - "==": 31, - "!=": 32, - "===": 33, - "!==": 34, - "=>": 35, - "+": 36, - "-": 37, - "**": 39, - "*": 38, - "/": 40, - "%": 41, - "++": 42, - "--": 43, - "<<": 44, - ">": 45, - ">>>": 46, - "&": 47, - "|": 48, - "^": 49, - "!": 50, - "~": 51, - "&&": 52, - "||": 53, - "?": 54, - ":": 55, - "=": 57, - "+=": 58, - "-=": 59, - "*=": 60, - "**=": 61, - "/=": 62, - "%=": 63, - "<<=": 64, - ">>=": 65, - ">>>=": 66, - "&=": 67, - "|=": 68, - "^=": 69, - "@": 56, + "abstract": 117, + "any": 119, + "as": 118, + "boolean": 122, + "break": 72, + "case": 73, + "catch": 74, + "class": 75, + "continue": 77, + "const": 76, + "constructor": 123, + "debugger": 78, + "declare": 124, + "default": 79, + "delete": 80, + "do": 81, + "else": 82, + "enum": 83, + "export": 84, + "extends": 85, + "false": 86, + "finally": 87, + "for": 88, + "from": 140, + "function": 89, + "get": 125, + "if": 90, + "implements": 108, + "import": 91, + "in": 92, + "instanceof": 93, + "interface": 109, + "is": 126, + "keyof": 127, + "let": 110, + "module": 128, + "namespace": 129, + "never": 130, + "new": 94, + "null": 95, + "number": 133, + "object": 134, + "package": 111, + "private": 112, + "protected": 113, + "public": 114, + "readonly": 131, + "require": 132, + "global": 141, + "return": 96, + "set": 135, + "static": 115, + "string": 136, + "super": 97, + "switch": 98, + "symbol": 137, + "this": 99, + "throw": 100, + "true": 101, + "try": 102, + "type": 138, + "typeof": 103, + "undefined": 139, + "var": 104, + "void": 105, + "while": 106, + "with": 107, + "yield": 116, + "async": 120, + "await": 121, + "of": 142, + "{": 17, + "}": 18, + "(": 19, + ")": 20, + "[": 21, + "]": 22, + ".": 23, + "...": 24, + ";": 25, + ",": 26, + "<": 27, + ">": 29, + "<=": 30, + ">=": 31, + "==": 32, + "!=": 33, + "===": 34, + "!==": 35, + "=>": 36, + "+": 37, + "-": 38, + "**": 40, + "*": 39, + "/": 41, + "%": 42, + "++": 43, + "--": 44, + "<<": 45, + ">": 46, + ">>>": 47, + "&": 48, + "|": 49, + "^": 50, + "!": 51, + "~": 52, + "&&": 53, + "||": 54, + "?": 55, + ":": 56, + "=": 58, + "+=": 59, + "-=": 60, + "*=": 61, + "**=": 62, + "/=": 63, + "%=": 64, + "<<=": 65, + ">>=": 66, + ">>>=": 67, + "&=": 68, + "|=": 69, + "^=": 70, + "@": 57, }); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -3586,10 +3550,10 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function isWhiteSpace(ch) { + function isWhiteSpaceLike(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - ts.isWhiteSpace = isWhiteSpace; + ts.isWhiteSpaceLike = isWhiteSpaceLike; function isWhiteSpaceSingleLine(ch) { return ch === 32 || ch === 9 || @@ -3705,7 +3669,7 @@ var ts; } break; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -3839,7 +3803,7 @@ var ts; } break scan; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -3874,7 +3838,7 @@ var ts; if (!comments) { comments = []; } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine }); return comments; } function getLeadingCommentRanges(text, pos) { @@ -3926,6 +3890,7 @@ var ts; var precedingLineBreak; var hasExtendedUnicodeEscape; var tokenIsUnterminated; + var numericLiteralFlags; setText(text, start, length); return { getStartPos: function () { return startPos; }, @@ -3936,9 +3901,10 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 70 || token > 106; }, - isReservedWord: function () { return token >= 71 && token <= 106; }, + isIdentifier: function () { return token === 71 || token > 107; }, + isReservedWord: function () { return token >= 72 && token <= 107; }, isUnterminated: function () { return tokenIsUnterminated; }, + getNumericLiteralFlags: function () { return numericLiteralFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, @@ -3975,6 +3941,7 @@ var ts; var end = pos; if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { pos++; + numericLiteralFlags = 2; if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++; if (isDigit(text.charCodeAt(pos))) { @@ -4073,20 +4040,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 13 : 14; + resultingToken = startedWithBacktick ? 14 : 15; break; } if (currChar === 92) { @@ -4251,7 +4218,7 @@ var ts; } } } - return token = 70; + return token = 71; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -4277,6 +4244,7 @@ var ts; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -4326,12 +4294,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 34; + return pos += 3, token = 35; } - return pos += 2, token = 32; + return pos += 2, token = 33; } pos++; - return token = 50; + return token = 51; case 34: case 39: tokenValue = scanString(); @@ -4340,51 +4308,39 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } pos++; - return token = 41; + return token = 42; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 52; + return pos += 2, token = 53; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; - return token = 47; + return token = 48; case 40: pos++; - return token = 18; + return token = 19; case 41: pos++; - return token = 19; + return token = 20; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 61; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 62; } - return pos += 2, token = 39; + return pos += 2, token = 40; } pos++; - return token = 38; + return token = 39; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 44: - pos++; - return token = 25; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { @@ -4392,16 +4348,28 @@ var ts; } pos++; return token = 37; + case 44: + pos++; + return token = 26; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + pos++; + return token = 38; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 23; + return pos += 3, token = 24; } pos++; - return token = 22; + return token = 23; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -4445,10 +4413,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -4458,6 +4426,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 8; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { @@ -4468,6 +4437,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 16; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { @@ -4478,10 +4448,12 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 32; return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = 4; return token = 8; } case 49: @@ -4497,10 +4469,10 @@ var ts; return token = 8; case 58: pos++; - return token = 55; + return token = 56; case 59: pos++; - return token = 24; + return token = 25; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4513,20 +4485,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 64; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 29; + return pos += 2, token = 30; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 27; + return pos += 2, token = 28; } pos++; - return token = 26; + return token = 27; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4539,15 +4511,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 35; + return pos += 2, token = 36; } pos++; - return token = 57; + return token = 58; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4559,43 +4531,43 @@ var ts; } } pos++; - return token = 28; + return token = 29; case 63: pos++; - return token = 54; + return token = 55; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 70; + } + pos++; + return token = 50; + case 123: + pos++; + return token = 17; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 54; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 69; } pos++; return token = 49; - case 123: - pos++; - return token = 16; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 53; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; case 125: pos++; - return token = 17; + return token = 18; case 126: pos++; - return token = 51; + return token = 52; case 64: pos++; - return token = 56; + return token = 57; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -4633,29 +4605,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 28) { + if (token === 29) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 66; + return pos += 3, token = 67; } - return pos += 2, token = 46; + return pos += 2, token = 47; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 66; } pos++; - return token = 45; + return token = 46; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 30; + return token = 31; } } return token; } function reScanSlashToken() { - if (token === 40 || token === 62) { + if (token === 41 || token === 63) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -4694,12 +4666,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 11; + token = 12; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 18, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -4716,23 +4688,37 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 27; + return token = 28; } pos++; - return token = 26; + return token = 27; } if (char === 123) { pos++; - return token = 16; + return token = 17; } + var firstNonWhitespace = 0; while (pos < end) { - pos++; char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { + if (char === 123) { break; } + if (char === 60) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = 7; + } + break; + } + if (isLineBreak(char) && firstNonWhitespace === 0) { + firstNonWhitespace = -1; + } + else if (!isWhiteSpaceLike(char)) { + firstNonWhitespace = pos; + } + pos++; } - return token = 10; + return firstNonWhitespace === -1 ? 11 : 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -4779,42 +4765,42 @@ var ts; return token = 5; case 64: pos++; - return token = 56; + return token = 57; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 38; + return token = 39; case 123: pos++; - return token = 16; + return token = 17; case 125: pos++; - return token = 17; + return token = 18; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 61: pos++; - return token = 57; + return token = 58; case 44: pos++; - return token = 25; + return token = 26; case 46: pos++; - return token = 22; + return token = 23; } if (isIdentifierStart(ch, 5)) { pos++; while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } - return token = 70; + return token = 71; } else { return pos += 1, token = 0; @@ -5028,7 +5014,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 264) { + while (node && node.kind !== 265) { node = node.parent; } return node; @@ -5036,11 +5022,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 206: - case 234: - case 213: + case 207: + case 235: case 214: case 215: + case 216: return true; } return false; @@ -5095,6 +5081,10 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isToken(n) { + return n.kind >= 0 && n.kind <= 142; + } + ts.isToken = isToken; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -5105,18 +5095,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 296 && node._children.length > 0) { + if (node.kind === 294 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 266 && node.kind <= 295; + return node.kind >= 267 && node.kind <= 293; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 282 && node.kind <= 295; + return node.kind >= 283 && node.kind <= 293; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5147,27 +5137,20 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } + function getLiteralText(node, sourceFile) { if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; + return getSourceTextOfNodeFromSourceFile(sourceFile, node); } switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 15: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 16: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -5175,37 +5158,6 @@ var ts; ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - return node.kind === 8 - && (getNumericLiteralFlags(text, 6) & 6) !== 0; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - function getNumericLiteralFlags(text, hint) { - if (text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - return 2; - case 111: - case 79: - return 4; - case 120: - case 88: - return 1; - } - if (hint & 8) { - for (var i = text.length - 1; i >= 0; i--) { - switch (text.charCodeAt(i)) { - case 101: - case 69: - return 8; - } - } - } - } - return 0; - } - ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -5224,11 +5176,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 225 && node.parent.kind === 259; + return node.kind === 226 && node.parent.kind === 260; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 232 && + return node && node.kind === 233 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5237,11 +5189,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 232 && (!node.body); + return node && node.kind === 233 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 264 || - node.kind === 232 || + return node.kind === 265 || + node.kind === 233 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5254,9 +5206,9 @@ var ts; return false; } switch (node.parent.kind) { - case 264: + case 265: return ts.isExternalModule(node.parent); - case 233: + case 234: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5268,22 +5220,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 264: - case 234: - case 259: - case 232: - case 213: + case 265: + case 235: + case 260: + case 233: case 214: case 215: - case 151: - case 150: + case 216: case 152: + case 151: case 153: - case 227: - case 185: + case 154: + case 228: case 186: + case 187: return true; - case 206: + case 207: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5303,14 +5255,18 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getNameFromIndexInfo(info) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } + ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 70: + case 71: return name.text; case 9: case 8: return name.text; - case 143: + case 144: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -5320,11 +5276,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 70: + case 71: return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); - case 142: + case 143: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 178: + case 179: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -5361,7 +5317,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 206) { + if (node.body && node.body.kind === 207) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5373,29 +5329,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 264: + case 265: 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 225: - case 175: - case 228: - case 198: + case 226: + case 176: case 229: - case 232: - case 231: - case 263: - case 227: - case 185: - case 150: - case 152: - case 153: + case 199: case 230: + case 233: + case 232: + case 264: + case 228: + case 186: + case 151: + case 153: + case 154: + case 231: errorNode = node.name; break; - case 186: + case 187: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5416,7 +5372,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 231 && isConst(node); + return node.kind === 232 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5429,11 +5385,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 180 && n.expression.kind === 96; + return n.kind === 181 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 209 + return node.kind === 210 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5446,10 +5402,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 145 || - node.kind === 144 || - node.kind === 185 || - node.kind === 186) ? + var commentRanges = (node.kind === 146 || + node.kind === 145 || + node.kind === 186 || + node.kind === 187) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -5463,69 +5419,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (157 <= node.kind && node.kind <= 172) { + if (158 <= node.kind && node.kind <= 173) { return true; } switch (node.kind) { - case 118: - case 132: - case 135: - case 121: + case 119: + case 133: case 136: - case 138: - case 129: + case 122: + case 137: + case 139: + case 130: return true; - case 104: - return node.parent.kind !== 189; - case 200: + case 105: + return node.parent.kind !== 190; + case 201: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 142 && node.parent.right === node) { + case 71: + if (node.parent.kind === 143 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 178 && node.parent.name === node) { + else if (node.parent.kind === 179 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 142: - case 178: - case 98: + ts.Debug.assert(node.kind === 71 || node.kind === 143 || node.kind === 179, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 143: + case 179: + case 99: var parent = node.parent; - if (parent.kind === 161) { + if (parent.kind === 162) { return false; } - if (157 <= parent.kind && parent.kind <= 172) { + if (158 <= parent.kind && parent.kind <= 173) { return true; } switch (parent.kind) { - case 200: + case 201: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 144: - return node === parent.constraint; - case 148: - case 147: case 145: - case 225: + return node === parent.constraint; + case 149: + case 148: + case 146: + case 226: return node === parent.type; - case 227: - case 185: + case 228: case 186: + case 187: + case 152: case 151: case 150: - case 149: - case 152: case 153: - return node === parent.type; case 154: + return node === parent.type; case 155: case 156: + case 157: return node === parent.type; - case 183: + case 184: return node === parent.type; - case 180: case 181: - return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; case 182: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 183: return false; } } @@ -5543,30 +5499,30 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 218: + case 219: return visitor(node); - case 234: - case 206: - case 210: + case 235: + case 207: case 211: case 212: case 213: case 214: case 215: - case 219: + case 216: case 220: - case 256: - case 257: case 221: - case 223: - case 259: + case 257: + case 258: + case 222: + case 224: + case 260: return ts.forEachChild(node, traverse); } } @@ -5576,23 +5532,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 196: + case 197: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 231: - case 229: + return; case 232: case 230: - case 228: - case 198: + case 233: + case 231: + case 229: + case 199: return; default: if (isFunctionLike(node)) { var name = node.name; - if (name && name.kind === 143) { + if (name && name.kind === 144) { traverse(name.expression); return; } @@ -5605,10 +5562,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 163) { + if (node && node.kind === 164) { return node.elementType; } - else if (node && node.kind === 158) { + else if (node && node.kind === 159) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -5619,14 +5576,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 175: - case 263: - case 145: - case 260: - case 148: - case 147: + case 176: + case 264: + case 146: case 261: - case 225: + case 149: + case 148: + case 262: + case 226: return true; } } @@ -5634,11 +5591,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 152 || node.kind === 153); + return node && (node.kind === 153 || node.kind === 154); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 228 || node.kind === 198); + return node && (node.kind === 229 || node.kind === 199); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5647,19 +5604,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 151: - case 185: - case 227: - case 186: - case 150: - case 149: case 152: + case 186: + case 228: + case 187: + case 151: + case 150: case 153: case 154: case 155: case 156: - case 159: + case 157: case 160: + case 161: return true; } return false; @@ -5667,13 +5624,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 227: - case 185: + case 154: + case 228: + case 186: return true; } return false; @@ -5681,42 +5638,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 213: case 214: case 215: - case 211: + case 216: case 212: + case 213: return true; - case 221: + case 222: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; - function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) { while (true) { if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 221) { + if (node.statement.kind !== 222) { return node.statement; } node = node.statement; } } - ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 206 && isFunctionLike(node.parent); + return node && node.kind === 207 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 150 && node.parent.kind === 177; + return node && node.kind === 151 && node.parent.kind === 178; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 150 && - (node.parent.kind === 177 || - node.parent.kind === 198); + return node.kind === 151 && + (node.parent.kind === 178 || + node.parent.kind === 199); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5752,39 +5709,39 @@ var ts; return undefined; } switch (node.kind) { - case 143: + case 144: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 146: - if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + case 147: + if (node.parent.kind === 146 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 186: + case 187: if (!includeArrowFunctions) { continue; } - case 227: - case 185: - case 232: - case 148: - case 147: - case 150: + case 228: + case 186: + case 233: case 149: + case 148: case 151: + case 150: case 152: case 153: case 154: case 155: case 156: - case 231: - case 264: + case 157: + case 232: + case 265: return node; } } @@ -5794,9 +5751,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 151: - case 227: - case 185: + case 152: + case 228: + case 186: return container; } } @@ -5810,25 +5767,25 @@ var ts; return node; } switch (node.kind) { - case 143: + case 144: node = node.parent; break; - case 227: - case 185: + case 228: case 186: + case 187: if (!stopOnFunctions) { continue; } - case 148: - case 147: - case 150: case 149: + case 148: case 151: + case 150: case 152: case 153: + case 154: return node; - case 146: - if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + case 147: + if (node.parent.kind === 146 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -5840,14 +5797,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 185 || func.kind === 186) { + if (func.kind === 186 || func.kind === 187) { var prev = func; var parent = func.parent; - while (parent.kind === 184) { + while (parent.kind === 185) { prev = parent; parent = parent.parent; } - if (parent.kind === 180 && parent.expression === prev) { + if (parent.kind === 181 && parent.expression === prev) { return parent; } } @@ -5855,21 +5812,21 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 178 || kind === 179) - && node.expression.kind === 96; + return (kind === 179 || kind === 180) + && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 158: - case 276: + case 159: + case 277: return node.typeName; - case 200: + case 201: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 70: - case 142: + case 71: + case 143: return node; } return undefined; @@ -5877,12 +5834,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { + case 251: case 250: - case 249: - case 180: case 181: case 182: - case 146: + case 183: + case 147: return true; default: return false; @@ -5890,7 +5847,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 182) { + if (node.kind === 183) { return node.tag; } else if (isJsxOpeningLikeElement(node)) { @@ -5901,21 +5858,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 228: + case 229: return true; - case 148: - return node.parent.kind === 228; - case 152: + case 149: + return node.parent.kind === 229; case 153: - case 150: + case 154: + case 151: return node.body !== undefined - && node.parent.kind === 228; - case 145: + && node.parent.kind === 229; + case 146: return node.parent.body !== undefined - && (node.parent.kind === 151 - || node.parent.kind === 150 - || node.parent.kind === 153) - && node.parent.parent.kind === 228; + && (node.parent.kind === 152 + || node.parent.kind === 151 + || node.parent.kind === 154) + && node.parent.parent.kind === 229; } return false; } @@ -5931,19 +5888,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 228: + case 229: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 150: - case 153: + case 151: + case 154: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 250 || - parent.kind === 249 || - parent.kind === 251) { + if (parent.kind === 251 || + parent.kind === 250 || + parent.kind === 252) { return parent.tagName === node; } return false; @@ -5951,99 +5908,99 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 98: - case 96: - case 94: - case 100: - case 85: - case 11: - case 176: + case 99: + case 97: + case 95: + case 101: + case 86: + case 12: case 177: case 178: case 179: case 180: case 181: case 182: - case 201: case 183: case 202: case 184: + case 203: case 185: - case 198: case 186: - case 189: + case 199: case 187: + case 190: case 188: - case 191: + case 189: case 192: case 193: case 194: - case 197: case 195: - case 12: - case 199: - case 248: - case 249: + case 198: case 196: - case 190: - case 203: + case 13: + case 200: + case 249: + case 250: + case 197: + case 191: + case 204: return true; - case 142: - while (node.parent.kind === 142) { + case 143: + while (node.parent.kind === 143) { node = node.parent; } - return node.parent.kind === 161 || isJSXTagName(node); - case 70: - if (node.parent.kind === 161 || isJSXTagName(node)) { + return node.parent.kind === 162 || isJSXTagName(node); + case 71: + if (node.parent.kind === 162 || isJSXTagName(node)) { return true; } case 8: case 9: - case 98: + case 99: var parent = node.parent; switch (parent.kind) { - case 225: - case 145: + case 226: + case 146: + case 149: case 148: - case 147: - case 263: - case 260: - case 175: + case 264: + case 261: + case 176: return parent.initializer === node; - case 209: case 210: case 211: case 212: - case 218: + case 213: case 219: case 220: - case 256: - case 222: - case 220: + case 221: + case 257: + case 223: + case 221: return parent.expression === node; - case 213: + case 214: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || forStatement.condition === node || forStatement.incrementor === node; - case 214: case 215: + case 216: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || forInStatement.expression === node; - case 183: - case 201: + case 184: + case 202: return node === parent.expression; - case 204: + case 205: return node === parent.expression; - case 143: + case 144: return node === parent.expression; - case 146: + case 147: + case 256: case 255: - case 254: - case 262: + case 263: return true; - case 200: + case 201: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: if (isPartOfExpression(parent)) { @@ -6061,7 +6018,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 && node.moduleReference.kind === 247; + return node.kind === 237 && node.moduleReference.kind === 248; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -6070,7 +6027,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 && node.moduleReference.kind !== 247; + return node.kind === 237 && node.moduleReference.kind !== 248; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -6081,39 +6038,58 @@ var ts; return node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 180 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + function isRequireCall(callExpression, checkArgumentIsStringLiteral) { + if (callExpression.kind !== 181) { + return false; + } + var _a = callExpression, expression = _a.expression, args = _a.arguments; + if (expression.kind !== 71 || expression.text !== "require") { + return false; + } + if (args.length !== 1) { + return false; + } + var arg = args[0]; + return !checkArgumentIsStringLiteral || arg.kind === 9 || arg.kind === 13; } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { return charCode === 39 || charCode === 34; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 225) { + function isDeclarationOfFunctionOrClassExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 226) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 185; + return declaration.initializer && (declaration.initializer.kind === 186 || declaration.initializer.kind === 199); } return false; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + ts.isDeclarationOfFunctionOrClassExpression = isDeclarationOfFunctionOrClassExpression; + function getRightMostAssignedExpression(node) { + while (isAssignmentExpression(node, true)) { + node = node.right; + } + return node; + } + ts.getRightMostAssignedExpression = getRightMostAssignedExpression; + function isExportsIdentifier(node) { + return isIdentifier(node) && node.text === "exports"; + } + ts.isExportsIdentifier = isExportsIdentifier; + function isModuleExportsPropertyAccessExpression(node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; function getSpecialPropertyAssignmentKind(expression) { if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 193) { - return 0; - } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { + if (expr.operatorToken.kind !== 58 || expr.left.kind !== 179) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 70) { + if (lhs.expression.kind === 71) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -6121,13 +6097,16 @@ var ts; else if (lhsId.text === "module" && lhs.name.text === "exports") { return 2; } + else { + return 5; + } } - else if (lhs.expression.kind === 98) { + else if (lhs.expression.kind === 99) { return 4; } - else if (lhs.expression.kind === 178) { + else if (lhs.expression.kind === 179) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { + if (innerPropertyAccess.expression.kind === 71) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -6141,35 +6120,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 237) { + if (node.kind === 238) { return node.moduleSpecifier; } - if (node.kind === 236) { + if (node.kind === 237) { var reference = node.moduleReference; - if (reference.kind === 247) { + if (reference.kind === 248) { return reference.expression; } } - if (node.kind === 243) { + if (node.kind === 244) { return node.moduleSpecifier; } - if (node.kind === 232 && node.name.kind === 9) { + if (node.kind === 233 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 240) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 237 + return node.kind === 238 && node.importClause && !!node.importClause.name; } @@ -6177,13 +6156,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 145: + case 146: + case 151: case 150: - case 149: + case 262: case 261: - case 260: + case 149: case 148: - case 147: return node.questionToken !== undefined; } } @@ -6191,9 +6170,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 278 && + return node.kind === 279 && node.parameters.length > 0 && - node.parameters[0].type.kind === 280; + node.parameters[0].type.kind === 281; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -6201,7 +6180,7 @@ var ts; } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; function hasJSDocParameterTags(node) { - var parameterTags = getJSDocTags(node, 285); + var parameterTags = getJSDocTags(node, 286); return parameterTags && parameterTags.length > 0; } ts.hasJSDocParameterTags = hasJSDocParameterTags; @@ -6211,13 +6190,16 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 285) { + if (doc.kind === 286) { if (doc.kind === kind) { result.push(doc); } } else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + var tags = doc.tags; + if (tags) { + result.push.apply(result, ts.filter(tags, function (tag) { return tag.kind === kind; })); + } } } return result; @@ -6237,9 +6219,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 207; + parent.parent.parent.kind === 208; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 207; + parent.parent.kind === 208; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -6247,19 +6229,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 193 && - parent.operatorToken.kind === 57 && - parent.parent.kind === 209; + parent.kind === 194 && + parent.operatorToken.kind === 58 && + parent.parent.kind === 210; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 232 && - parent && parent.kind === 232; - var isPropertyAssignmentExpression = parent && parent.kind === 260; + var isModuleDeclaration = node.kind === 233 && + parent && parent.kind === 233; + var isPropertyAssignmentExpression = parent && parent.kind === 261; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 145) { + if (node.kind === 146) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -6268,22 +6250,23 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 285); + var tags = getJSDocTags(func, 286); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 286; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } - else if (param.name.kind === 70) { + else if (param.name.kind === 71) { var name_1 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); + return ts.filter(tags, function (tag) { return tag.kind === 286 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -6291,8 +6274,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 287); - if (!tag && node.kind === 145) { + var tag = getFirstJSDocTag(node, 288); + if (!tag && node.kind === 146) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -6302,15 +6285,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 286); + return getFirstJSDocTag(node, 287); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 288); + return getFirstJSDocTag(node, 289); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -6323,8 +6306,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 279 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { + if (node.type && node.type.kind === 280 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 280; })) { return true; } } @@ -6339,30 +6322,30 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 193: + case 194: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 ? 1 : 2 : + binaryOperator === 58 ? 1 : 2 : 0; - case 191: case 192: + case 193: var unaryOperator = parent.operator; - return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 214: + return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; case 215: + case 216: return parent.initializer === node ? 1 : 0; - case 184: - case 176: - case 197: + case 185: + case 177: + case 198: node = parent; break; - case 261: + case 262: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 260: + case 261: if (parent.name === node) { return 0; } @@ -6380,14 +6363,14 @@ var ts; } ts.isAssignmentTarget = isAssignmentTarget; function isDeleteTarget(node) { - if (node.kind !== 178 && node.kind !== 179) { + if (node.kind !== 179 && node.kind !== 180) { return false; } node = node.parent; - while (node && node.kind === 184) { + while (node && node.kind === 185) { node = node.parent; } - return node && node.kind === 187; + return node && node.kind === 188; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -6401,7 +6384,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 265 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6410,11 +6393,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 71 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 241 || parent.kind === 245) { + if (parent.kind === 242 || parent.kind === 246) { if (parent.propertyName) { return true; } @@ -6427,48 +6410,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 143 && + node.parent.kind === 144 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 148: - case 147: - case 150: case 149: - case 152: + case 148: + case 151: + case 150: case 153: - case 263: - case 260: - case 178: + case 154: + case 264: + case 261: + case 179: return parent.name === node; - case 142: + case 143: if (parent.right === node) { - while (parent.kind === 142) { + while (parent.kind === 143) { parent = parent.parent; } - return parent.kind === 161; + return parent.kind === 162; } return false; - case 175: - case 241: + case 176: + case 242: return parent.propertyName === node; - case 245: + case 246: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 236 || - node.kind === 235 || - node.kind === 238 && !!node.name || - node.kind === 239 || - node.kind === 241 || - node.kind === 245 || - node.kind === 242 && exportAssignmentIsAlias(node); + return node.kind === 237 || + node.kind === 236 || + node.kind === 239 && !!node.name || + node.kind === 240 || + node.kind === 242 || + node.kind === 246 || + node.kind === 243 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6476,17 +6459,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); + var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); + var heritageClause = getHeritageClause(node.heritageClauses, 108); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); + var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6554,17 +6537,51 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 141; + return 72 <= token && token <= 142; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + function getFunctionFlags(node) { + var flags = 0; + switch (node.kind) { + case 228: + case 186: + case 151: + if (node.asteriskToken) { + flags |= 1; + } + case 187: + if (hasModifier(node, 256)) { + flags |= 2; + } + break; + } + if (!node.body) { + flags |= 4; + } + return flags; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; + ts.getFunctionFlags = getFunctionFlags; + function isAsyncFunction(node) { + switch (node.kind) { + case 228: + case 186: + case 187: + case 151: + return node.body !== undefined + && node.asteriskToken === undefined + && hasModifier(node, 256); + } + return false; + } + ts.isAsyncFunction = isAsyncFunction; + function isNumericLiteral(node) { + return node.kind === 8; + } + ts.isNumericLiteral = isNumericLiteral; function isStringOrNumericLiteral(node) { var kind = node.kind; return kind === 9 @@ -6576,7 +6593,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 143 && + return name.kind === 144 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6586,10 +6603,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { + if (name.kind === 71 || name.kind === 9 || name.kind === 8 || name.kind === 146) { return name.text; } - if (name.kind === 143) { + if (name.kind === 144) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6607,7 +6624,7 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; + return node.kind === 71 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -6616,17 +6633,17 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 130: + case 117: + case 120: + case 76: + case 124: + case 79: + case 84: case 114: + case 112: + case 113: + case 131: + case 115: return true; } return false; @@ -6634,11 +6651,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 145; + return root.kind === 146; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 175) { + while (node.kind === 176) { node = node.parent.parent; } return node; @@ -6646,15 +6663,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 151 - || kind === 185 - || kind === 227 + return kind === 152 || kind === 186 - || kind === 150 - || kind === 152 + || kind === 228 + || kind === 187 + || kind === 151 || kind === 153 - || kind === 232 - || kind === 264; + || kind === 154 + || kind === 233 + || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6663,7 +6680,7 @@ var ts; } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFileOrBundle(sourceFileOrBundle) { - if (sourceFileOrBundle.kind === 265) { + if (sourceFileOrBundle.kind === 266) { return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } return getOriginalSourceFile(sourceFileOrBundle); @@ -6683,38 +6700,38 @@ var ts; ts.getOriginalNodeId = getOriginalNodeId; function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 181: + case 182: return hasArguments ? 0 : 1; - case 191: - case 188: + case 192: case 189: - case 187: case 190: - case 194: - case 196: + case 188: + case 191: + case 195: + case 197: return 1; - case 193: + case 194: switch (operator) { - case 39: - case 57: + case 40: case 58: case 59: - case 61: case 60: case 62: + case 61: case 63: case 64: case 65: case 66: case 67: - case 69: case 68: + case 70: + case 69: return 1; } } @@ -6723,15 +6740,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 193) { + if (expression.kind === 194) { return expression.operatorToken.kind; } - else if (expression.kind === 191 || expression.kind === 192) { + else if (expression.kind === 192 || expression.kind === 193) { return expression.operator; } else { @@ -6741,106 +6758,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - case 85: + case 99: + case 97: + case 71: + case 95: + case 101: + case 86: case 8: case 9: - case 176: case 177: - case 185: - case 186: - case 198: - case 248: - case 249: - case 11: - case 12: - case 195: - case 184: - case 199: - return 19; - case 182: case 178: - case 179: - return 18; - case 181: - return hasArguments ? 18 : 17; - case 180: - return 17; - case 192: - return 16; - case 191: - case 188: - case 189: + case 186: case 187: - case 190: - return 15; + case 199: + case 249: + case 250: + case 12: + case 13: + case 196: + case 185: + case 200: + return 19; + case 183: + case 179: + case 180: + return 18; + case 182: + return hasArguments ? 18 : 17; + case 181: + return 17; case 193: + return 16; + case 192: + case 189: + case 190: + case 188: + case 191: + return 15; + case 194: switch (operatorKind) { - case 50: case 51: + case 52: return 15; - case 39: - case 38: case 40: + case 39: case 41: + case 42: return 14; - case 36: case 37: + case 38: return 13; - case 44: case 45: case 46: + case 47: return 12; - case 26: - case 29: - case 28: + case 27: case 30: - case 91: - case 92: - return 11; + case 29: case 31: - case 33: + case 92: + case 93: + return 11; case 32: case 34: + case 33: + case 35: return 10; - case 47: - return 9; - case 49: - return 8; case 48: + return 9; + case 50: + return 8; + case 49: return 7; - case 52: - return 6; case 53: + return 6; + case 54: return 5; - case 57: case 58: case 59: - case 61: case 60: case 62: + case 61: case 63: case 64: case 65: case 66: case 67: - case 69: case 68: + case 70: + case 69: return 3; - case 25: + case 26: return 0; default: return -1; } - case 194: + case 195: return 4; - case 196: - return 2; case 197: + return 2; + case 198: return 1; default: return -1; @@ -7101,7 +7118,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -7156,7 +7173,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 151 && nodeIsPresent(member.body)) { + if (member.kind === 152 && nodeIsPresent(member.body)) { return member; } }); @@ -7183,11 +7200,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); + return node && node.kind === 71 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; + return id.originalKeywordKind === 99; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -7197,10 +7214,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 152) { + if (accessor.kind === 153) { getAccessor = accessor; } - else if (accessor.kind === 153) { + else if (accessor.kind === 154) { setAccessor = accessor; } else { @@ -7209,7 +7226,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 152 || member.kind === 153) + if ((member.kind === 153 || member.kind === 154) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -7220,10 +7237,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 152 && !getAccessor) { + if (member.kind === 153 && !getAccessor) { getAccessor = member; } - if (member.kind === 153 && !setAccessor) { + if (member.kind === 154 && !setAccessor) { setAccessor = member; } } @@ -7406,7 +7423,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 71 && node.isInJSDocNamespace)) { flags |= 1; } node.modifierFlagsCache = flags | 536870912; @@ -7415,34 +7432,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 130: return 64; + case 115: return 32; + case 114: return 4; + case 113: return 16; + case 112: return 8; + case 117: return 128; + case 84: return 1; + case 124: return 2; + case 76: return 2048; + case 79: return 512; + case 120: return 256; + case 131: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; + return token === 54 + || token === 53 + || token === 51; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 57 && token <= 69; + return token >= 58 && token <= 70; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 200 && - node.parent.token === 84 && + if (node.kind === 201 && + node.parent.token === 85 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -7451,7 +7468,7 @@ var ts; function isAssignmentExpression(node, excludeCompoundAssignment) { return isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 + ? node.operatorToken.kind === 58 : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left); } @@ -7459,8 +7476,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 177 - || kind === 176; + return kind === 178 + || kind === 177; } return false; } @@ -7470,7 +7487,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { + if (node.kind === 71) { return true; } else if (isPropertyAccessExpression(node)) { @@ -7484,27 +7501,35 @@ var ts; return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isExpressionWithTypeArgumentsInClassImplementsClause(node) { + return node.kind === 201 + && isEntityNameExpression(node.expression) + && node.parent + && node.parent.token === 108 + && node.parent.parent + && isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassImplementsClause = isExpressionWithTypeArgumentsInClassImplementsClause; function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 178 && isEntityNameExpression(node.expression); + return node.kind === 71 || + node.kind === 179 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 142 && node.parent.right === node) || - (node.parent.kind === 178 && node.parent.name === node); + return (node.parent.kind === 143 && node.parent.right === node) || + (node.parent.kind === 179 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 177) { - return expression.properties.length === 0; - } - if (kind === 176) { - return expression.elements.length === 0; - } - return false; + function isEmptyObjectLiteral(expression) { + return expression.kind === 178 && + expression.properties.length === 0; } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + ts.isEmptyObjectLiteral = isEmptyObjectLiteral; + function isEmptyArrayLiteral(expression) { + return expression.kind === 177 && + expression.elements.length === 0; + } + ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7512,7 +7537,6 @@ var ts; function isExportDefaultSymbol(symbol) { return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); } - ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -7594,49 +7618,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 11 || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { + || kind === 13 + || kind === 71 + || kind === 99 + || kind === 97 + || kind === 101 + || kind === 86 + || kind === 95) { return true; } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 179) { + else if (kind === 180) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 191 - || kind === 192) { + else if (kind === 192 + || kind === 193) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 193) { - return node.operatorToken.kind !== 39 + else if (kind === 194) { + return node.operatorToken.kind !== 40 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 194) { + else if (kind === 195) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 189 - || kind === 188 - || kind === 187) { + else if (kind === 190 + || kind === 189 + || kind === 188) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 176) { + else if (kind === 177) { return node.elements.length === 0; } - else if (kind === 177) { + else if (kind === 178) { return node.properties.length === 0; } - else if (kind === 180) { + else if (kind === 181) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7757,8 +7781,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 231: case 232: + case 233: return parseNode === parseNode.parent.name; } } @@ -7776,7 +7800,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 && declaration !== node) { + if (declaration.kind === 229 && declaration !== node) { return true; } } @@ -7794,15 +7818,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; + return node.kind === 13; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; + return 8 <= kind && kind <= 13; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; + return kind === 9 || kind === 13; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -7810,25 +7834,25 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; + return 13 <= kind && kind <= 16; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 13; + return node.kind === 14; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 14 - || kind === 15; + return kind === 15 + || kind === 16; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 70; + return node.kind === 71; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 189; + return node.kind === 190; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -7840,131 +7864,135 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 143; + return node.kind === 144; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 142 - || kind === 70; + return kind === 143 + || kind === 71; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 70 + return kind === 71 || kind === 9 || kind === 8 - || kind === 143; + || kind === 144; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 70 + return kind === 71 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 70 - || kind === 173 - || kind === 174; + return kind === 71 + || kind === 174 + || kind === 175; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 145; + return node.kind === 146; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 146; + return node.kind === 147; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 150; + return node.kind === 151; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 151 - || kind === 148 - || kind === 150 - || kind === 152 + return kind === 152 + || kind === 149 + || kind === 151 || kind === 153 - || kind === 156 - || kind === 205; + || kind === 154 + || kind === 157 + || kind === 206; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 260 - || kind === 261 + return kind === 261 || kind === 262 - || kind === 150 - || kind === 152 + || kind === 263 + || kind === 151 || kind === 153 - || kind === 246; + || kind === 154 + || kind === 247; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 157 && kind <= 172) - || kind === 118 - || kind === 132 - || kind === 121 - || kind === 135 + return (kind >= 158 && kind <= 173) + || kind === 119 + || kind === 133 + || kind === 134 + || kind === 122 || kind === 136 - || kind === 104 - || kind === 129 - || kind === 200; + || kind === 137 + || kind === 99 + || kind === 105 + || kind === 139 + || kind === 95 + || kind === 130 + || kind === 201; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 174; + return node.kind === 175; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 174 - || kind === 173; + return kind === 175 + || kind === 174; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 176 - || kind === 177; + return kind === 177 + || kind === 178; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 175; + return node.kind === 176; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 175 - || kind === 199; + return kind === 176 + || kind === 200; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 225: - case 145: - case 175: + case 226: + case 146: + case 176: return true; } return false; @@ -7977,8 +8005,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 177: + case 174: + case 178: return true; } return false; @@ -7986,94 +8014,100 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 174: - case 176: + case 175: + case 177: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessOrQualifiedName(node) { + var kind = node.kind; + return kind === 179 + || kind === 143; + } + ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isElementAccessExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 180; + return node.kind === 181; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 195 - || kind === 12; + return kind === 196 + || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 200; + return node.kind === 201; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 178 - || kind === 179 - || kind === 181 + return kind === 179 || kind === 180 - || kind === 248 - || kind === 249 || kind === 182 - || kind === 176 - || kind === 184 + || kind === 181 + || kind === 249 + || kind === 250 + || kind === 183 || kind === 177 - || kind === 198 || kind === 185 - || kind === 70 - || kind === 11 + || kind === 178 + || kind === 199 + || kind === 186 + || kind === 71 + || kind === 12 || kind === 8 || kind === 9 - || kind === 12 - || kind === 195 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 202 - || kind === 203; + || kind === 13 + || kind === 196 + || kind === 86 + || kind === 95 + || kind === 99 + || kind === 101 + || kind === 97 + || kind === 203 + || kind === 204; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 191 - || kind === 192 - || kind === 187 + return kind === 192 + || kind === 193 || kind === 188 || kind === 189 || kind === 190 - || kind === 183 + || kind === 191 + || kind === 184 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -8081,13 +8115,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 194 - || kind === 196 - || kind === 186 - || kind === 193 + return kind === 195 || kind === 197 - || kind === 201 - || kind === 199 + || kind === 187 + || kind === 194 + || kind === 198 + || kind === 202 + || kind === 200 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -8096,16 +8130,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 183 - || kind === 201; + return kind === 184 + || kind === 202; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 298; + return node.kind === 296; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 297; + return node.kind === 295; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -8114,15 +8148,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 204; + return node.kind === 205; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 206; + return node.kind === 207; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8140,135 +8174,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 225; + return node.kind === 226; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 226; + return node.kind === 227; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 234; + return node.kind === 235; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 233 - || kind === 232 - || kind === 70; + return kind === 234 + || kind === 233 + || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 70 - || kind === 232; + return kind === 71 + || kind === 233; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 238; + return node.kind === 239; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 240 - || kind === 239; + return kind === 241 + || kind === 240; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 241; + return node.kind === 242; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 244; + return node.kind === 245; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 245; + return node.kind === 246; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 232 || node.kind === 231; + return node.kind === 233 || node.kind === 232; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 186 - || kind === 175 - || kind === 228 - || kind === 198 - || kind === 151 - || kind === 231 - || kind === 263 - || kind === 245 - || kind === 227 - || kind === 185 - || kind === 152 - || kind === 238 - || kind === 236 - || kind === 241 + return kind === 187 + || kind === 176 || kind === 229 - || kind === 252 - || kind === 150 - || kind === 149 + || kind === 199 + || kind === 152 || kind === 232 - || kind === 235 - || kind === 239 - || kind === 145 - || kind === 260 - || kind === 148 - || kind === 147 - || kind === 153 - || kind === 261 - || kind === 230 - || kind === 144 - || kind === 225 - || kind === 289; - } - function isDeclarationStatementKind(kind) { - return kind === 227 + || kind === 264 || kind === 246 || kind === 228 + || kind === 186 + || kind === 153 + || kind === 239 + || kind === 237 + || kind === 242 + || kind === 230 + || kind === 253 + || kind === 151 + || kind === 150 + || kind === 233 + || kind === 236 + || kind === 240 + || kind === 146 + || kind === 261 + || kind === 149 + || kind === 148 + || kind === 154 + || kind === 262 + || kind === 231 + || kind === 145 + || kind === 226 + || kind === 290; + } + function isDeclarationStatementKind(kind) { + return kind === 228 + || kind === 247 || kind === 229 || kind === 230 || kind === 231 || kind === 232 + || kind === 233 + || kind === 238 || kind === 237 - || kind === 236 + || kind === 244 || kind === 243 - || kind === 242 - || kind === 235; + || kind === 236; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 217 - || kind === 216 - || kind === 224 - || kind === 211 - || kind === 209 - || kind === 208 - || kind === 214 - || kind === 215 - || kind === 213 - || kind === 210 - || kind === 221 - || kind === 218 - || kind === 220 - || kind === 222 - || kind === 223 - || kind === 207 + return kind === 218 + || kind === 217 + || kind === 225 || kind === 212 + || kind === 210 + || kind === 209 + || kind === 215 + || kind === 216 + || kind === 214 + || kind === 211 + || kind === 222 || kind === 219 - || kind === 297 - || kind === 300 - || kind === 299; + || kind === 221 + || kind === 223 + || kind === 224 + || kind === 208 + || kind === 213 + || kind === 220 + || kind === 295 + || kind === 298 + || kind === 297; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8286,96 +8320,98 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 206; + || kind === 207; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 247 - || kind === 142 - || kind === 70; + return kind === 248 + || kind === 143 + || kind === 71; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 178; + return kind === 99 + || kind === 71 + || kind === 179; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 248 - || kind === 255 - || kind === 249 + return kind === 249 + || kind === 256 + || kind === 250 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributes(node) { var kind = node.kind; - return kind === 253; + return kind === 254; } ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 252 - || kind === 254; + return kind === 253 + || kind === 255; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 254; + return node.kind === 255; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 252; + return node.kind === 253; } ts.isJsxAttribute = isJsxAttribute; - function isJsxOpeningLikeElement(node) { - return node.kind === 250 || node.kind === 249; - } - ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 255; + || kind === 256; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isJsxOpeningLikeElement(node) { + var kind = node.kind; + return kind === 251 + || kind === 250; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 256 - || kind === 257; + return kind === 257 + || kind === 258; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 258; + return node.kind === 259; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 259; + return node.kind === 260; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 260; + return node.kind === 261; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 261; + return node.kind === 262; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 263; + return node.kind === 264; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 264; + return node.kind === 265; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8387,10 +8423,11 @@ var ts; function getDefaultLibFileName(options) { switch (options.target) { case 5: + return "lib.esnext.full.d.ts"; case 4: - return "lib.es2017.d.ts"; + return "lib.es2017.full.d.ts"; case 3: - return "lib.es2016.d.ts"; + return "lib.es2016.full.d.ts"; case 2: return "lib.es6.d.ts"; default: @@ -8514,9 +8551,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 144) { + if (d && d.kind === 145) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 230) { return current; } } @@ -8524,11 +8561,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 175 || ts.isBindingPattern(node))) { + while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8536,14 +8573,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 225) { + if (node.kind === 226) { node = node.parent; } - if (node && node.kind === 226) { + if (node && node.kind === 227) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 207) { + if (node && node.kind === 208) { flags |= ts.getModifierFlags(node); } return flags; @@ -8552,14 +8589,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 225) { + if (node.kind === 226) { node = node.parent; } - if (node && node.kind === 226) { + if (node && node.kind === 227) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 207) { + if (node && node.kind === 208) { flags |= node.flags; } return flags; @@ -8626,7 +8663,7 @@ var ts; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { + if (node === undefined || isParseTreeNode(node)) { return node; } node = getOriginalNode(node); @@ -8705,6 +8742,7 @@ var ts; function createNumericLiteral(value) { var node = createSynthesizedNode(8); node.text = value; + node.numericLiteralFlags = 0; return node; } ts.createNumericLiteral = createNumericLiteral; @@ -8719,7 +8757,7 @@ var ts; return node; } function createIdentifier(text) { - var node = createSynthesizedNode(70); + var node = createSynthesizedNode(71); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; @@ -8769,27 +8807,27 @@ var ts; } ts.createToken = createToken; function createSuper() { - return createSynthesizedNode(96); + return createSynthesizedNode(97); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(98); + return createSynthesizedNode(99); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(94); + return createSynthesizedNode(95); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(100); + return createSynthesizedNode(101); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(85); + return createSynthesizedNode(86); } ts.createFalse = createFalse; function createQualifiedName(left, right) { - var node = createSynthesizedNode(142); + var node = createSynthesizedNode(143); node.left = left; node.right = asName(right); return node; @@ -8803,7 +8841,7 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function createComputedPropertyName(expression) { - var node = createSynthesizedNode(143); + var node = createSynthesizedNode(144); node.expression = expression; return node; } @@ -8814,8 +8852,285 @@ var ts; : node; } ts.updateComputedPropertyName = updateComputedPropertyName; + function createSignatureDeclaration(kind, typeParameters, parameters, type) { + var signatureDeclaration = createSynthesizedNode(kind); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + ts.createSignatureDeclaration = createSignatureDeclaration; + function updateSignatureDeclaration(node, typeParameters, parameters, type) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + function createFunctionTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(160, typeParameters, parameters, type); + } + ts.createFunctionTypeNode = createFunctionTypeNode; + function updateFunctionTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateFunctionTypeNode = updateFunctionTypeNode; + function createConstructorTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(161, typeParameters, parameters, type); + } + ts.createConstructorTypeNode = createConstructorTypeNode; + function updateConstructorTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructorTypeNode = updateConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(155, typeParameters, parameters, type); + } + ts.createCallSignatureDeclaration = createCallSignatureDeclaration; + function updateCallSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateCallSignatureDeclaration = updateCallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(156, typeParameters, parameters, type); + } + ts.createConstructSignatureDeclaration = createConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructSignatureDeclaration = updateConstructSignatureDeclaration; + function createMethodSignature(typeParameters, parameters, type, name, questionToken) { + var methodSignature = createSignatureDeclaration(150, typeParameters, parameters, type); + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + ts.createMethodSignature = createMethodSignature; + function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + ts.updateMethodSignature = updateMethodSignature; + function createKeywordTypeNode(kind) { + return createSynthesizedNode(kind); + } + ts.createKeywordTypeNode = createKeywordTypeNode; + function createThisTypeNode() { + return createSynthesizedNode(169); + } + ts.createThisTypeNode = createThisTypeNode; + function createLiteralTypeNode(literal) { + var literalTypeNode = createSynthesizedNode(173); + literalTypeNode.literal = literal; + return literalTypeNode; + } + ts.createLiteralTypeNode = createLiteralTypeNode; + function updateLiteralTypeNode(node, literal) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + ts.updateLiteralTypeNode = updateLiteralTypeNode; + function createTypeReferenceNode(typeName, typeArguments) { + var typeReference = createSynthesizedNode(159); + typeReference.typeName = asName(typeName); + typeReference.typeArguments = asNodeArray(typeArguments); + return typeReference; + } + ts.createTypeReferenceNode = createTypeReferenceNode; + function updateTypeReferenceNode(node, typeName, typeArguments) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + ts.updateTypeReferenceNode = updateTypeReferenceNode; + function createTypePredicateNode(parameterName, type) { + var typePredicateNode = createSynthesizedNode(158); + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + ts.createTypePredicateNode = createTypePredicateNode; + function updateTypePredicateNode(node, parameterName, type) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function createTypeQueryNode(exprName) { + var typeQueryNode = createSynthesizedNode(162); + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + ts.createTypeQueryNode = createTypeQueryNode; + function updateTypeQueryNode(node, exprName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; + } + ts.updateTypeQueryNode = updateTypeQueryNode; + function createArrayTypeNode(elementType) { + var arrayTypeNode = createSynthesizedNode(164); + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + ts.createArrayTypeNode = createArrayTypeNode; + function updateArrayTypeNode(node, elementType) { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + ts.updateArrayTypeNode = updateArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind, types) { + var unionTypeNode = createSynthesizedNode(kind); + unionTypeNode.types = createNodeArray(types); + return unionTypeNode; + } + ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node, types) { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + ts.updateUnionOrIntersectionTypeNode = updateUnionOrIntersectionTypeNode; + function createParenthesizedType(type) { + var node = createSynthesizedNode(168); + node.type = type; + return node; + } + ts.createParenthesizedType = createParenthesizedType; + function updateParenthesizedType(node, type) { + return node.type !== type + ? updateNode(createParenthesizedType(type), node) + : node; + } + ts.updateParenthesizedType = updateParenthesizedType; + function createTypeLiteralNode(members) { + var typeLiteralNode = createSynthesizedNode(163); + typeLiteralNode.members = createNodeArray(members); + return typeLiteralNode; + } + ts.createTypeLiteralNode = createTypeLiteralNode; + function updateTypeLiteralNode(node, members) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + ts.updateTypeLiteralNode = updateTypeLiteralNode; + function createTupleTypeNode(elementTypes) { + var tupleTypeNode = createSynthesizedNode(165); + tupleTypeNode.elementTypes = createNodeArray(elementTypes); + return tupleTypeNode; + } + ts.createTupleTypeNode = createTupleTypeNode; + function updateTypleTypeNode(node, elementTypes) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + ts.updateTypleTypeNode = updateTypleTypeNode; + function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { + var mappedTypeNode = createSynthesizedNode(172); + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + ts.createMappedTypeNode = createMappedTypeNode; + function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + ts.updateMappedTypeNode = updateMappedTypeNode; + function createTypeOperatorNode(type) { + var typeOperatorNode = createSynthesizedNode(170); + typeOperatorNode.operator = 127; + typeOperatorNode.type = type; + return typeOperatorNode; + } + ts.createTypeOperatorNode = createTypeOperatorNode; + function updateTypeOperatorNode(node, type) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + ts.updateTypeOperatorNode = updateTypeOperatorNode; + function createIndexedAccessTypeNode(objectType, indexType) { + var indexedAccessTypeNode = createSynthesizedNode(171); + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node, objectType, indexType) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; + function createTypeParameterDeclaration(name, constraint, defaultType) { + var typeParameter = createSynthesizedNode(145); + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultType; + return typeParameter; + } + ts.createTypeParameterDeclaration = createTypeParameterDeclaration; + function updateTypeParameterDeclaration(node, name, constraint, defaultType) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) + : node; + } + ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; + function createPropertySignature(name, questionToken, type, initializer) { + var propertySignature = createSynthesizedNode(148); + propertySignature.name = asName(name); + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + ts.createPropertySignature = createPropertySignature; + function updatePropertySignature(node, name, questionToken, type, initializer) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + ts.updatePropertySignature = updatePropertySignature; + function createIndexSignatureDeclaration(decorators, modifiers, parameters, type) { + var indexSignature = createSynthesizedNode(157); + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; + return indexSignature; + } + ts.createIndexSignatureDeclaration = createIndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node, decorators, modifiers, parameters, type) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) + : node; + } + ts.updateIndexSignatureDeclaration = updateIndexSignatureDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(145); + var node = createSynthesizedNode(146); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -8826,11 +9141,12 @@ var ts; return node; } ts.createParameter = createParameter; - function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { + function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -8838,7 +9154,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(146); + var node = createSynthesizedNode(147); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -8850,7 +9166,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createProperty(decorators, modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148); + var node = createSynthesizedNode(149); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -8870,33 +9186,35 @@ var ts; : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(150); + function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(151); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - ts.createMethod = createMethod; - function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + ts.createMethodDeclaration = createMethodDeclaration; + function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(152); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -8916,7 +9234,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(153); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -8939,7 +9257,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(154); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -8960,7 +9278,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } @@ -8972,7 +9290,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(174); + var node = createSynthesizedNode(175); node.elements = createNodeArray(elements); return node; } @@ -8983,10 +9301,10 @@ var ts; : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer) { - var node = createSynthesizedNode(175); - node.propertyName = asName(propertyName); + function createBindingElement(dotDotDotToken, propertyName, name, initializer) { + var node = createSynthesizedNode(176); node.dotDotDotToken = dotDotDotToken; + node.propertyName = asName(propertyName); node.name = asName(name); node.initializer = initializer; return node; @@ -8997,12 +9315,12 @@ var ts; || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer - ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) : node; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(177); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -9017,7 +9335,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(178); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -9032,10 +9350,10 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(179); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); - setEmitFlags(node, 65536); + setEmitFlags(node, 131072); return node; } ts.createPropertyAccess = createPropertyAccess; @@ -9047,7 +9365,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(180); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -9061,7 +9379,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(181); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -9077,7 +9395,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(182); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -9093,7 +9411,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(183); node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; @@ -9107,7 +9425,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(184); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -9121,7 +9439,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(185); node.expression = expression; return node; } @@ -9133,7 +9451,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(186); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -9144,24 +9462,25 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.name !== name || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(187); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -9177,7 +9496,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -9189,7 +9508,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(189); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -9201,7 +9520,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(190); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -9213,7 +9532,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(191); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -9225,7 +9544,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(192); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -9238,7 +9557,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(193); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -9251,7 +9570,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(194); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -9268,11 +9587,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(195); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(55); + node.colonToken = whenFalse ? colonToken : createToken(56); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -9286,7 +9605,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(196); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -9300,20 +9619,21 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(196); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(197); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; - function updateYield(node, expression) { + function updateYield(node, asteriskToken, expression) { return node.expression !== expression - ? updateNode(createYield(node.asteriskToken, expression), node) + || node.asteriskToken !== asteriskToken + ? updateNode(createYield(asteriskToken, expression), node) : node; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(198); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -9325,7 +9645,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(199); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -9346,11 +9666,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(199); + return createSynthesizedNode(200); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(201); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -9364,7 +9684,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(202); node.expression = expression; node.type = type; return node; @@ -9378,7 +9698,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(203); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -9390,7 +9710,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(205); node.expression = expression; node.literal = literal; return node; @@ -9404,7 +9724,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(206); + var block = createSynthesizedNode(207); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -9418,7 +9738,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(208); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -9433,7 +9753,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(227); node.flags |= flags; node.declarations = createNodeArray(declarations); return node; @@ -9446,7 +9766,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(226); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -9462,11 +9782,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement() { - return createSynthesizedNode(208); + return createSynthesizedNode(209); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(210); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -9478,7 +9798,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(211); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -9494,7 +9814,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(211); + var node = createSynthesizedNode(212); node.statement = statement; node.expression = expression; return node; @@ -9508,7 +9828,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(213); node.expression = expression; node.statement = statement; return node; @@ -9522,7 +9842,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(214); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -9540,7 +9860,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -9555,24 +9875,26 @@ var ts; : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement) { - var node = createSynthesizedNode(215); + function createForOf(awaitModifier, initializer, expression, statement) { + var node = createSynthesizedNode(216); + node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; node.statement = statement; return node; } ts.createForOf = createForOf; - function updateForOf(node, initializer, expression, statement) { - return node.initializer !== initializer + function updateForOf(node, awaitModifier, initializer, expression, statement) { + return node.awaitModifier !== awaitModifier + || node.initializer !== initializer || node.expression !== expression || node.statement !== statement - ? updateNode(createForOf(initializer, expression, statement), node) + ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node) : node; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(216); + var node = createSynthesizedNode(217); node.label = asName(label); return node; } @@ -9584,7 +9906,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(218); node.label = asName(label); return node; } @@ -9596,7 +9918,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(219); node.expression = expression; return node; } @@ -9608,7 +9930,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(220); node.expression = expression; node.statement = statement; return node; @@ -9622,7 +9944,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(221); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -9636,7 +9958,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(222); node.label = asName(label); node.statement = statement; return node; @@ -9650,7 +9972,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(223); node.expression = expression; return node; } @@ -9662,7 +9984,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(224); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -9678,7 +10000,7 @@ var ts; } ts.updateTry = updateTry; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(228); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -9690,20 +10012,21 @@ var ts; return node; } ts.createFunctionDeclaration = createFunctionDeclaration; - function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(229); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -9725,7 +10048,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(232); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -9743,7 +10066,7 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(233); node.flags |= flags; node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -9774,7 +10097,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(235); node.clauses = createNodeArray(clauses); return node; } @@ -9786,7 +10109,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -9804,7 +10127,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -9821,7 +10144,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(239); node.name = name; node.namedBindings = namedBindings; return node; @@ -9835,7 +10158,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(240); node.name = name; return node; } @@ -9847,7 +10170,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(241); node.elements = createNodeArray(elements); return node; } @@ -9859,7 +10182,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(242); node.propertyName = propertyName; node.name = name; return node; @@ -9873,7 +10196,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -9890,7 +10213,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -9908,7 +10231,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(245); node.elements = createNodeArray(elements); return node; } @@ -9919,21 +10242,22 @@ var ts; : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName) { - var node = createSynthesizedNode(245); - node.name = asName(name); + function createExportSpecifier(propertyName, name) { + var node = createSynthesizedNode(246); node.propertyName = asName(propertyName); + node.name = asName(name); return node; } ts.createExportSpecifier = createExportSpecifier; - function updateExportSpecifier(node, name, propertyName) { - return node.name !== name || node.propertyName !== propertyName - ? updateNode(createExportSpecifier(name, propertyName), node) + function updateExportSpecifier(node, propertyName, name) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createExportSpecifier(propertyName, name), node) : node; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(248); node.expression = expression; return node; } @@ -9945,7 +10269,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(249); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -9961,7 +10285,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(250); node.tagName = tagName; node.attributes = attributes; return node; @@ -9975,7 +10299,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(251); node.tagName = tagName; node.attributes = attributes; return node; @@ -9989,7 +10313,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(252); node.tagName = tagName; return node; } @@ -10001,7 +10325,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttributes(properties) { - var jsxAttributes = createSynthesizedNode(253); + var jsxAttributes = createSynthesizedNode(254); jsxAttributes.properties = createNodeArray(properties); return jsxAttributes; } @@ -10014,7 +10338,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(253); node.name = name; node.initializer = initializer; return node; @@ -10028,7 +10352,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(255); node.expression = expression; return node; } @@ -10039,8 +10363,8 @@ var ts; : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken) { - var node = createSynthesizedNode(255); + function createJsxExpression(dotDotDotToken, expression) { + var node = createSynthesizedNode(256); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -10048,12 +10372,12 @@ var ts; ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { return node.expression !== expression - ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node) : node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(259); node.token = token; node.types = createNodeArray(types); return node; @@ -10067,7 +10391,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(257); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -10081,7 +10405,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(258); node.statements = createNodeArray(statements); return node; } @@ -10094,7 +10418,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(259); + var node = createSynthesizedNode(260); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -10108,7 +10432,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(261); node.name = asName(name); node.questionToken = undefined; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -10123,18 +10447,12 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(262); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression) { - var node = createSynthesizedNode(262); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; - return node; - } - ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); @@ -10142,6 +10460,12 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(263); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { return updateNode(createSpreadAssignment(expression), node); @@ -10150,7 +10474,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(264); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -10165,7 +10489,7 @@ var ts; ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createSynthesizedNode(264); + var updated = createSynthesizedNode(265); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -10234,28 +10558,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(297); + var node = createSynthesizedNode(295); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(300); + var node = createSynthesizedNode(298); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(299); + var node = createSynthesizedNode(297); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(298); + var node = createSynthesizedNode(296); node.expression = expression; node.original = original; setTextRange(node, original); @@ -10270,7 +10594,7 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createBundle(sourceFiles) { - var node = ts.createNode(265); + var node = ts.createNode(266); node.sourceFiles = sourceFiles; return node; } @@ -10283,47 +10607,47 @@ var ts; } ts.updateBundle = updateBundle; function createComma(left, right) { - return createBinary(left, 25, right); + return createBinary(left, 26, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 26, right); + return createBinary(left, 27, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 57, right); + return createBinary(left, 58, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 34, right); + return createBinary(left, 35, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 37, right); + return createBinary(left, 38, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 42); + return createPostfix(operand, 43); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 53, right); + return createBinary(left, 54, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(50, operand); + return createPrefix(51, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -10335,7 +10659,7 @@ var ts; } ts.createExportDefault = createExportDefault; function createExternalModuleExport(exportName) { - return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); + return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; function asName(name) { @@ -10365,7 +10689,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 264) { + if (node.kind === 265) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -10427,6 +10751,34 @@ var ts; return node; } ts.setCommentRange = setCommentRange; + function getSyntheticLeadingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.leadingComments; + } + ts.getSyntheticLeadingComments = getSyntheticLeadingComments; + function setSyntheticLeadingComments(node, comments) { + getOrCreateEmitNode(node).leadingComments = comments; + return node; + } + ts.setSyntheticLeadingComments = setSyntheticLeadingComments; + function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticLeadingComment = addSyntheticLeadingComment; + function getSyntheticTrailingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.trailingComments; + } + ts.getSyntheticTrailingComments = getSyntheticTrailingComments; + function setSyntheticTrailingComments(node, comments) { + getOrCreateEmitNode(node).trailingComments = comments; + return node; + } + ts.setSyntheticTrailingComments = setSyntheticTrailingComments; + function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticTrailingComment = addSyntheticTrailingComment; function getConstantValue(node) { var emitNode = node.emitNode; return emitNode && emitNode.constantValue; @@ -10520,9 +10872,13 @@ var ts; } ts.setOriginalNode = setOriginalNode; function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + var flags = sourceEmitNode.flags, leadingComments = sourceEmitNode.leadingComments, trailingComments = sourceEmitNode.trailingComments, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; if (!destEmitNode) destEmitNode = {}; + if (leadingComments) + destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) + destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; if (commentRange) @@ -10644,11 +11000,65 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + var valuesHelper = { + name: "typescript:values", + scoped: false, + text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };\n " + }; + function createValuesHelper(context, expression, location) { + context.requestEmitHelper(valuesHelper); + return ts.setTextRange(ts.createCall(getHelperName("__values"), undefined, [expression]), location); + } + ts.createValuesHelper = createValuesHelper; + var readHelper = { + name: "typescript:read", + scoped: false, + text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };\n " + }; + function createReadHelper(context, iteratorRecord, count, location) { + context.requestEmitHelper(readHelper); + return ts.setTextRange(ts.createCall(getHelperName("__read"), undefined, count !== undefined + ? [iteratorRecord, ts.createLiteral(count)] + : [iteratorRecord]), location); + } + ts.createReadHelper = createReadHelper; + var spreadHelper = { + name: "typescript:spread", + scoped: false, + text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" + }; + function createSpreadHelper(context, argumentList, location) { + context.requestEmitHelper(readHelper); + context.requestEmitHelper(spreadHelper); + return ts.setTextRange(ts.createCall(getHelperName("__spread"), undefined, argumentList), location); + } + ts.createSpreadHelper = createSpreadHelper; + function createForOfBindingStatement(node, boundValue) { + if (ts.isVariableDeclarationList(node)) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue); + return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node); + } + else { + var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node); + return ts.setTextRange(ts.createStatement(updatedExpression), node); + } + } + ts.createForOfBindingStatement = createForOfBindingStatement; + function insertLeadingStatement(dest, source) { + if (ts.isBlock(dest)) { + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + } + else { + return ts.createBlock(ts.createNodeArray([dest, source]), true); + } + } + ts.insertLeadingStatement = insertLeadingStatement; function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 222 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -10660,19 +11070,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 70: + case 71: return cacheIdentifiers; - case 98: + case 99: case 8: case 9: return false; - case 176: + case 177: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 177: + case 178: return target.properties.length > 0; default: return true; @@ -10686,15 +11096,19 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 96) { + else if (callee.kind === 97) { thisArg = ts.createThis(); target = languageVersion < 2 ? ts.setTextRange(ts.createIdentifier("_super"), callee) : callee; } + else if (ts.getEmitFlags(callee) & 4096) { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(callee); + } else { switch (callee.kind) { - case 178: { + case 179: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -10706,7 +11120,7 @@ var ts; } break; } - case 179: { + case 180: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -10757,14 +11171,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 152: case 153: + case 154: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 260: - return createExpressionForPropertyAssignment(property, receiver); case 261: + return createExpressionForPropertyAssignment(property, receiver); + case 262: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 150: + case 151: return createExpressionForMethodDeclaration(property, receiver); } } @@ -10807,6 +11221,14 @@ var ts; function createExpressionForMethodDeclaration(method, receiver) { return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); } + function getInternalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384 | 32768); + } + ts.getInternalName = getInternalName; + function isInternalName(node) { + return (ts.getEmitFlags(node) & 32768) !== 0; + } + ts.isInternalName = isInternalName; function getLocalName(node, allowComments, allowSourceMaps) { return getName(node, allowComments, allowSourceMaps, 16384); } @@ -10868,7 +11290,12 @@ var ts; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + function addPrologue(target, source, ensureUseStrict, visitor) { + var offset = addStandardPrologue(target, source, ensureUseStrict); + return addCustomPrologue(target, source, offset, visitor); + } + ts.addPrologue = addPrologue; + function addStandardPrologue(target, source, ensureUseStrict) { ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; @@ -10889,9 +11316,14 @@ var ts; if (ensureUseStrict && !foundUseStrict) { target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } + return statementOffset; + } + ts.addStandardPrologue = addStandardPrologue; + function addCustomPrologue(target, source, statementOffset, visitor) { + var numStatements = source.length; while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 524288) { + if (ts.getEmitFlags(statement) & 1048576) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -10901,7 +11333,7 @@ var ts; } return statementOffset; } - ts.addPrologueDirectives = addPrologueDirectives; + ts.addCustomPrologue = addCustomPrologue; function startsWithUseStrict(statements) { var firstStatement = ts.firstOrUndefined(statements); return firstStatement !== undefined @@ -10931,9 +11363,19 @@ var ts; return statements; } ts.ensureUseStrict = ensureUseStrict; + function parenthesizeConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(195, 55); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeConditionalHead = parenthesizeConditionalHead; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 184) { + if (skipped.kind === 185) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -10942,15 +11384,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(194, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(194, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 196) { + && operand.kind === 197) { return false; } return true; @@ -10966,7 +11408,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 36) { + if (binaryOperator === 37) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -10979,17 +11421,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 + return binaryOperator === 39 + || binaryOperator === 49 || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; + || binaryOperator === 50; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.kind === 194 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -11004,7 +11446,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var conditionalPrecedence = ts.getOperatorPrecedence(195, 55); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -11014,7 +11456,7 @@ var ts; } ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 193 && e.operatorToken.kind === 25 + return e.kind === 194 && e.operatorToken.kind === 26 ? ts.createParen(e) : e; } @@ -11022,9 +11464,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 180: - return ts.createParen(expression); case 181: + return ts.createParen(expression); + case 182: return emittedExpression.arguments ? expression : ts.createParen(expression); @@ -11035,8 +11477,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 181 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { + && (emittedExpression.kind !== 182 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -11074,7 +11515,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(193, 25); + var commaPrecedence = ts.getOperatorPrecedence(194, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -11085,7 +11526,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 185 || kind === 186) { + if (kind === 186 || kind === 187) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -11093,7 +11534,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { return ts.setTextRange(ts.createParen(expression), expression); } } @@ -11111,21 +11552,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 192: + case 193: node = node.operand; continue; - case 193: + case 194: node = node.left; continue; - case 194: + case 195: node = node.condition; continue; + case 181: case 180: case 179: - case 178: node = node.expression; continue; - case 298: + case 296: node = node.expression; continue; } @@ -11133,8 +11574,7 @@ var ts; } } function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 177) { + if (!ts.isBlock(body) && getLeftmostExpression(body).kind === 178) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -11159,7 +11599,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 184) { + while (node.kind === 185) { node = node.expression; } return node; @@ -11173,7 +11613,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 298) { + while (node.kind === 296) { node = node.expression; } return node; @@ -11216,10 +11656,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 237 && node.importClause) { + if (node.kind === 238 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 243 && node.moduleSpecifier) { + if (node.kind === 244 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -11281,11 +11721,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 260: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 261: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 262: + return bindingElement.name; + case 263: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -11301,11 +11741,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 145: - case 175: + case 146: + case 176: return bindingElement.dotDotDotToken; - case 197: - case 262: + case 198: + case 263: return bindingElement; } return undefined; @@ -11313,7 +11753,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 175: + case 176: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -11321,7 +11761,7 @@ var ts; : propertyName; } break; - case 260: + case 261: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -11329,7 +11769,7 @@ var ts; : propertyName; } break; - case 262: + case 263: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -11343,11 +11783,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 173: case 174: - case 176: - return name.elements; + case 175: case 177: + return name.elements; + case 178: return name.properties; } } @@ -11386,11 +11826,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 174: - case 176: - return convertToArrayAssignmentPattern(node); - case 173: + case 175: case 177: + return convertToArrayAssignmentPattern(node); + case 174: + case 178: return convertToObjectAssignmentPattern(node); } } @@ -11436,15 +11876,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 237: + case 238: externalImports.push(node); break; - case 236: - if (node.moduleReference.kind === 247) { + case 237: + if (node.moduleReference.kind === 248) { externalImports.push(node); } break; - case 243: + case 244: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -11471,12 +11911,12 @@ var ts; } } break; - case 242: + case 243: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 207: + case 208: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -11484,7 +11924,7 @@ var ts; } } break; - case 227: + case 228: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -11502,7 +11942,7 @@ var ts; } } break; - case 228: + case 229: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -11560,13 +12000,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 264) { + if (kind === 265) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 70) { + else if (kind === 71) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 142) { + else if (kind < 143) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -11602,29 +12042,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 142: + case 143: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 144: + case 145: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 261: + case 262: 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 262: + case 263: return visitNode(cbNode, node.expression); - case 145: + case 146: + case 149: case 148: - case 147: - case 260: - case 225: - case 175: + case 261: + case 226: + case 176: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -11633,24 +12073,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 159: case 160: - case 154: + case 161: case 155: case 156: + case 157: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: + case 228: + case 187: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -11661,174 +12101,168 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 158: + case 159: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 157: + case 158: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 161: - return visitNode(cbNode, node.exprName); case 162: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 163: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 164: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 165: + return visitNodes(cbNodes, node.elementTypes); case 166: - return visitNodes(cbNodes, node.types); case 167: - case 169: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 168: case 170: + return visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 171: + case 172: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 172: - return visitNode(cbNode, node.literal); case 173: + return visitNode(cbNode, node.literal); case 174: - return visitNodes(cbNodes, node.elements); - case 176: + case 175: return visitNodes(cbNodes, node.elements); case 177: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 178: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 179: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 180: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 181: + case 182: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 182: + case 183: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 183: + case 184: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 187: + case 185: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); - case 191: - return visitNode(cbNode, node.operand); - case 196: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 190: return visitNode(cbNode, node.expression); case 192: return visitNode(cbNode, node.operand); + case 197: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 191: + return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.operand); + case 194: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 201: + case 202: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.name); - case 194: + case 195: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 197: + case 198: return visitNode(cbNode, node.expression); - case 206: - case 233: + case 207: + case 234: return visitNodes(cbNodes, node.statements); - case 264: + case 265: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 207: + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 226: + case 227: return visitNodes(cbNodes, node.declarations); - case 209: - return visitNode(cbNode, node.expression); case 210: + return visitNode(cbNode, node.expression); + case 211: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 211: + case 212: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 213: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 215: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 216: - case 217: - return visitNode(cbNode, node.label); - case 218: - return visitNode(cbNode, node.expression); - case 219: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.awaitModifier) || + visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 217: + case 218: + return visitNode(cbNode, node.label); + case 219: + return visitNode(cbNode, node.expression); case 220: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 221: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 234: + case 235: return visitNodes(cbNodes, node.clauses); - case 256: + case 257: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 257: + case 258: return visitNodes(cbNodes, node.statements); - case 221: + case 222: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 222: - return visitNode(cbNode, node.expression); case 223: + return visitNode(cbNode, node.expression); + case 224: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 259: + case 260: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 146: + case 147: return visitNode(cbNode, node.expression); - case 228: - case 198: - 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 229: + case 199: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -11840,146 +12274,153 @@ 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 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 263: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 232: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 264: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 233: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 237: + case 238: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 238: + case 239: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 235: - return visitNode(cbNode, node.name); - case 239: + case 236: return visitNode(cbNode, node.name); case 240: - case 244: + return visitNode(cbNode, node.name); + case 241: + case 245: return visitNodes(cbNodes, node.elements); - case 243: + case 244: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 241: - case 245: + case 242: + case 246: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 242: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 195: + case 196: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 204: + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.types); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 247: - return visitNode(cbNode, node.expression); - case 246: - return visitNodes(cbNodes, node.decorators); case 248: + return visitNode(cbNode, node.expression); + case 247: + return visitNodes(cbNodes, node.decorators); + case 249: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 249: case 250: + case 251: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.attributes); - case 253: + case 254: return visitNodes(cbNodes, node.properties); - case 252: + case 253: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 254: - return visitNode(cbNode, node.expression); case 255: + return visitNode(cbNode, node.expression); + case 256: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 251: + case 252: return visitNode(cbNode, node.tagName); - case 266: + case 267: return visitNode(cbNode, node.type); - case 270: - return visitNodes(cbNodes, node.types); case 271: return visitNodes(cbNodes, node.types); - case 269: + case 272: + return visitNodes(cbNodes, node.types); + case 270: return visitNode(cbNode, node.elementType); + case 274: + return visitNode(cbNode, node.type); case 273: return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.type); - case 274: + case 275: return visitNode(cbNode, node.literal); - case 276: + case 277: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 277: - return visitNode(cbNode, node.type); case 278: + return visitNode(cbNode, node.type); + case 279: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 279: - return visitNode(cbNode, node.type); case 280: return visitNode(cbNode, node.type); case 281: return visitNode(cbNode, node.type); - case 275: + case 282: + return visitNode(cbNode, node.type); + case 276: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 282: + case 283: return visitNodes(cbNodes, node.tags); - case 285: + case 286: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 286: - return visitNode(cbNode, node.typeExpression); case 287: return visitNode(cbNode, node.typeExpression); - case 284: - return visitNode(cbNode, node.typeExpression); case 288: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 285: + return visitNode(cbNode, node.typeExpression); case 289: + return visitNodes(cbNodes, node.typeParameters); + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 291: + case 292: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 290: + case 291: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 298: + case 296: return visitNode(cbNode, node.expression); - case 292: + case 293: return visitNode(cbNode, node.literal); } } @@ -12143,7 +12584,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(265, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -12299,16 +12740,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 70) { + if (token() === 71) { return true; } - if (token() === 115 && inYieldContext()) { + if (token() === 116 && inYieldContext()) { return false; } - if (token() === 120 && inAwaitContext()) { + if (token() === 121 && inAwaitContext()) { return false; } - return token() > 106; + return token() > 107; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -12349,20 +12790,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 24) { + if (token() === 25) { return true; } - return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 18 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 24) { + if (token() === 25) { nextToken(); } return true; } else { - return parseExpected(24); + return parseExpected(25); } } function createNode(kind, pos) { @@ -12370,8 +12811,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 142 ? new NodeConstructor(kind, pos, pos) : - kind === 70 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 143 ? new NodeConstructor(kind, pos, pos) : + kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -12416,15 +12857,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(70); - if (token() !== 70) { + var node = createNode(71); + if (token() !== 71) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -12441,7 +12882,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 20) { + if (allowComputedPropertyNames && token() === 21) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -12456,10 +12897,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(143); - parseExpected(20); - node.expression = allowInAnd(parseExpression); + var node = createNode(144); parseExpected(21); + node.expression = allowInAnd(parseExpression); + parseExpected(22); return finishNode(node); } function parseContextualModifier(t) { @@ -12473,20 +12914,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 75) { - return nextToken() === 82; + if (token() === 76) { + return nextToken() === 83; } - if (token() === 83) { + if (token() === 84) { nextToken(); - if (token() === 78) { + if (token() === 79) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); + return token() !== 39 && token() !== 118 && token() !== 17 && canFollowModifier(); } - if (token() === 78) { + if (token() === 79) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 114) { + if (token() === 115) { nextToken(); return canFollowModifier(); } @@ -12496,16 +12937,17 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 20 - || token() === 16 - || token() === 38 - || token() === 23 + return token() === 21 + || token() === 17 + || token() === 39 + || token() === 24 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 74 || token() === 88 || - (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 75 || token() === 89 || + (token() === 117 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 120 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -12516,23 +12958,23 @@ var ts; case 0: case 1: case 3: - return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 25 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 72 || token() === 78; + return token() === 73 || token() === 79; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 25 && !inErrorRecovery); case 6: - return token() === 20 || isLiteralPropertyName(); + return token() === 21 || isLiteralPropertyName(); case 12: - return token() === 20 || token() === 38 || token() === 23 || isLiteralPropertyName(); + return token() === 21 || token() === 39 || token() === 24 || isLiteralPropertyName(); case 17: return isLiteralPropertyName(); case 9: - return token() === 20 || token() === 23 || isLiteralPropertyName(); + return token() === 21 || token() === 24 || isLiteralPropertyName(); case 7: - if (token() === 16) { + if (token() === 17) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -12544,23 +12986,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 25 || token() === 23 || isIdentifierOrPattern(); + return token() === 26 || token() === 24 || isIdentifierOrPattern(); case 18: return isIdentifier(); case 11: case 15: - return token() === 25 || token() === 23 || isStartOfExpression(); + return token() === 26 || token() === 24 || isStartOfExpression(); case 16: return isStartOfParameter(); case 19: case 20: - return token() === 25 || isStartOfType(); + return token() === 26 || isStartOfType(); case 21: return isHeritageClause(); case 22: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17; case 14: return true; case 23: @@ -12573,10 +13015,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 16); - if (nextToken() === 17) { + ts.Debug.assert(token() === 17); + if (nextToken() === 18) { var next = nextToken(); - return next === 25 || next === 16 || next === 84 || next === 107; + return next === 26 || next === 17 || next === 85 || next === 108; } return true; } @@ -12589,8 +13031,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 107 || - token() === 84) { + if (token() === 108 || + token() === 85) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -12612,40 +13054,40 @@ var ts; case 12: case 9: case 22: - return token() === 17; + return token() === 18; case 3: - return token() === 17 || token() === 72 || token() === 78; + return token() === 18 || token() === 73 || token() === 79; case 7: - return token() === 16 || token() === 84 || token() === 107; + return token() === 17 || token() === 85 || token() === 108; case 8: return isVariableDeclaratorListTerminator(); case 18: - return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; + return token() === 29 || token() === 19 || token() === 17 || token() === 85 || token() === 108; case 11: - return token() === 19 || token() === 24; + return token() === 20 || token() === 25; case 15: case 20: case 10: - return token() === 21; + return token() === 22; case 16: case 17: - return token() === 19 || token() === 21; + return token() === 20 || token() === 22; case 19: - return token() !== 25; + return token() !== 26; case 21: - return token() === 16 || token() === 17; + return token() === 17 || token() === 18; case 13: - return token() === 28 || token() === 40; + return token() === 29 || token() === 41; case 14: - return token() === 26 && lookAhead(nextTokenIsSlash); + return token() === 27 && lookAhead(nextTokenIsSlash); case 23: - return token() === 19 || token() === 55 || token() === 17; + return token() === 20 || token() === 56 || token() === 18; case 24: - return token() === 28 || token() === 17; + return token() === 29 || token() === 18; case 26: - return token() === 21 || token() === 17; + return token() === 22 || token() === 18; case 25: - return token() === 17; + return token() === 18; } } function isVariableDeclaratorListTerminator() { @@ -12655,7 +13097,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 35) { + if (token() === 36) { return true; } return false; @@ -12761,17 +13203,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 151: - case 156: case 152: + case 157: case 153: - case 148: - case 205: + case 154: + case 149: + case 206: return true; - case 150: + case 151: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 70 && - methodDeclaration.name.originalKeywordKind === 122; + var nameIsConstructor = methodDeclaration.name.kind === 71 && + methodDeclaration.name.originalKeywordKind === 123; return !nameIsConstructor; } } @@ -12780,8 +13222,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 256: case 257: + case 258: return true; } } @@ -12790,65 +13232,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 227: + case 228: + case 208: case 207: - case 206: + case 211: case 210: - case 209: - case 222: + case 223: + case 219: + case 221: case 218: - case 220: case 217: + case 215: case 216: case 214: - case 215: case 213: - case 212: - case 219: - case 208: - case 223: - case 221: - case 211: + case 220: + case 209: case 224: + case 222: + case 212: + case 225: + case 238: case 237: - case 236: + case 244: case 243: - case 242: - case 232: - case 228: + case 233: case 229: - case 231: case 230: + case 232: + case 231: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 263; + return node.kind === 264; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 155: - case 149: case 156: - case 147: - case 154: + case 150: + case 157: + case 148: + case 155: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 225) { + if (node.kind !== 226) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 145) { + if (node.kind !== 146) { return false; } var parameter = node; @@ -12893,7 +13335,6 @@ var ts; case 25: return ts.Diagnostics.Property_assignment_expected; } } - ; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -12903,15 +13344,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(25)) { + if (parseOptional(26)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(25); - if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { + parseExpected(26); + if (considerSemicolonAsDelimiter && token() === 25 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -12943,8 +13384,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(22)) { - var node = createNode(142, entity.pos); + while (parseOptional(23)) { + var node = createNode(143, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -12955,33 +13396,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(71, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(195); + var template = createNode(196); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(204); + var span = createNode(205); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 17) { + if (token() === 18) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); + literal = parseExpectedToken(16, false, ts.Diagnostics._0_expected, ts.tokenToString(18)); } span.literal = literal; return finishNode(span); @@ -12991,12 +13432,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 14, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 || fragment.kind === 16, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -13009,47 +13450,43 @@ var ts; if (scanner.isUnterminated()) { node.isUnterminated = true; } - var tokenPos = scanner.getTokenPos(); + if (node.kind === 8) { + node.numericLiteralFlags = scanner.getNumericLiteralFlags(); + } nextToken(); finishNode(node); - if (node.kind === 8 - && sourceText.charCodeAt(tokenPos) === 48 - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.isOctalLiteral = true; - } return node; } function parseTypeReference() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(158, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 26) { - node.typeArguments = parseBracketedList(19, parseType, 26, 28); + var node = createNode(159); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token() === 27) { + node.typeArguments = parseBracketedList(19, parseType, 27, 29); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(157, lhs.pos); + var node = createNode(158, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(168); + var node = createNode(169); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(161); - parseExpected(102); + var node = createNode(162); + parseExpected(103); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(144); + var node = createNode(145); node.name = parseIdentifier(); - if (parseOptional(84)) { + if (parseOptional(85)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -13057,40 +13494,40 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(57)) { + if (parseOptional(58)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 26) { - return parseBracketedList(18, parseTypeParameter, 26, 28); + if (token() === 27) { + return parseBracketedList(18, parseTypeParameter, 27, 29); } } function parseParameterType() { - if (parseOptional(55)) { + if (parseOptional(56)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; + return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 57 || token() === 99; } function parseParameter() { - var node = createNode(145); - if (token() === 98) { - node.name = createIdentifier(true, undefined); + var node = createNode(146); + if (token() === 99) { + node.name = createIdentifier(true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(23); + node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(54); + node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -13102,7 +13539,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 35; + var returnTokenRequired = returnToken === 36; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -13114,7 +13551,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(18)) { + if (parseExpected(19)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -13122,7 +13559,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(19) && requireCompleteParameterList) { + if (!parseExpected(20) && requireCompleteParameterList) { return undefined; } return result; @@ -13130,29 +13567,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(25)) { + if (parseOptional(26)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 155) { - parseExpected(93); + if (kind === 156) { + parseExpected(94); } - fillSignature(55, false, false, false, node); + fillSignature(56, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 20) { + if (token() !== 21) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 23 || token() === 21) { + if (token() === 24 || token() === 22) { return true; } if (ts.isModifierKind(token())) { @@ -13167,43 +13604,43 @@ var ts; else { nextToken(); } - if (token() === 55 || token() === 25) { + if (token() === 56 || token() === 26) { return true; } - if (token() !== 54) { + if (token() !== 55) { return false; } nextToken(); - return token() === 55 || token() === 25 || token() === 21; + return token() === 56 || token() === 26 || token() === 22; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(156, fullStart); + var node = createNode(157, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 20, 21); + node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (token() === 18 || token() === 26) { - var method = createNode(149, fullStart); + var questionToken = parseOptionalToken(55); + if (token() === 19 || token() === 27) { + var method = createNode(150, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(55, false, false, false, method); + fillSignature(56, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 57) { + if (token() === 58) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -13211,38 +13648,38 @@ var ts; } } function isTypeMemberStart() { - var idToken; - if (token() === 18 || token() === 26) { + if (token() === 19 || token() === 27) { return true; } + var idToken; while (ts.isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } - if (token() === 20) { + if (token() === 21) { return true; } if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } if (idToken) { - return token() === 18 || - token() === 26 || - token() === 54 || + return token() === 19 || + token() === 27 || token() === 55 || - token() === 25 || + token() === 56 || + token() === 26 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 18 || token() === 26) { - return parseSignatureMember(154); - } - if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + if (token() === 19 || token() === 27) { return parseSignatureMember(155); } + if (token() === 94 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(156); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -13252,18 +13689,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 18 || token() === 26; + return token() === 19 || token() === 27; } function parseTypeLiteral() { - var node = createNode(162); + var node = createNode(163); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(16)) { + if (parseExpected(17)) { members = parseList(4, parseTypeMember); - parseExpected(17); + parseExpected(18); } else { members = createMissingList(); @@ -13272,57 +13709,57 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 130) { + if (token() === 131) { nextToken(); } - return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; + return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; } function parseMappedTypeParameter() { - var node = createNode(144); + var node = createNode(145); node.name = parseIdentifier(); - parseExpected(91); + parseExpected(92); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(171); - parseExpected(16); - node.readonlyToken = parseOptionalToken(130); - parseExpected(20); - node.typeParameter = parseMappedTypeParameter(); + var node = createNode(172); + parseExpected(17); + node.readonlyToken = parseOptionalToken(131); parseExpected(21); - node.questionToken = parseOptionalToken(54); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(22); + node.questionToken = parseOptionalToken(55); node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(17); + parseExpected(18); return finishNode(node); } function parseTupleType() { - var node = createNode(164); - node.elementTypes = parseBracketedList(20, parseType, 20, 21); + var node = createNode(165); + node.elementTypes = parseBracketedList(20, parseType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(167); - parseExpected(18); - node.type = parseType(); + var node = createNode(168); parseExpected(19); + node.type = parseType(); + parseExpected(20); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 160) { - parseExpected(93); + if (kind === 161) { + parseExpected(94); } - fillSignature(35, false, false, false, node); + fillSignature(36, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 22 ? undefined : node; + return token() === 23 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(172); + var node = createNode(173); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -13332,42 +13769,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: - case 138: - case 129: case 133: + case 122: + case 137: + case 139: + case 130: + case 134: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 100: - case 85: + case 101: + case 86: return parseLiteralTypeNode(); - case 37: + case 38: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 104: - case 94: + case 105: + case 95: return parseTokenNode(); - case 98: { + case 99: { var thisKeyword = parseThisTypeNode(); - if (token() === 125 && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 102: + case 103: return parseTypeQuery(); - case 16: + case 17: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 20: + case 21: return parseTupleType(); - case 18: + case 19: return parseParenthesizedType(); default: return parseTypeReference(); @@ -13375,32 +13812,32 @@ var ts; } function isStartOfType() { switch (token()) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: - case 104: - case 138: - case 94: - case 98: - case 102: - case 129: - case 16: - case 20: - case 26: + case 133: + case 122: + case 137: + case 105: + case 139: + case 95: + case 99: + case 103: + case 130: + case 17: + case 21: + case 27: + case 49: case 48: - case 47: - case 93: + case 94: case 9: case 8: - case 100: - case 85: - case 133: + case 101: + case 86: + case 134: return true; - case 37: + case 38: return lookAhead(nextTokenIsNumericLiteral); - case 18: + case 19: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -13408,29 +13845,29 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 19 || isStartOfParameter() || isStartOfType(); + return token() === 20 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + while (!scanner.hasPrecedingLineBreak() && parseOptional(21)) { if (isStartOfType()) { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(21); + parseExpected(22); type = finishNode(node); } else { - var node = createNode(163, type.pos); + var node = createNode(164, type.pos); node.elementType = type; - parseExpected(21); + parseExpected(22); type = finishNode(node); } } return type; } function parseTypeOperator(operator) { - var node = createNode(169); + var node = createNode(170); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -13438,8 +13875,8 @@ var ts; } function parseTypeOperatorOrHigher() { switch (token()) { - case 126: - return parseTypeOperator(126); + case 127: + return parseTypeOperator(127); } return parseArrayTypeOrHigher(); } @@ -13459,26 +13896,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(167, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(166, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { - if (token() === 26) { + if (token() === 27) { return true; } - return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 19 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 98) { + if (isIdentifier() || token() === 99) { nextToken(); return true; } - if (token() === 20 || token() === 16) { + if (token() === 21 || token() === 17) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -13487,17 +13924,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 19 || token() === 23) { + if (token() === 20 || token() === 24) { return true; } if (skipParameterStart()) { - if (token() === 55 || token() === 25 || - token() === 54 || token() === 57) { + if (token() === 56 || token() === 26 || + token() === 55 || token() === 58) { return true; } - if (token() === 19) { + if (token() === 20) { nextToken(); - if (token() === 35) { + if (token() === 36) { return true; } } @@ -13508,7 +13945,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(157, typePredicateVariable.pos); + var node = createNode(158, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -13519,7 +13956,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 125 && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -13529,36 +13966,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(159); - } - if (token() === 93) { return parseFunctionOrConstructorType(160); } + if (token() === 94) { + return parseFunctionOrConstructorType(161); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(55) ? parseType() : undefined; + return parseOptional(56) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 98: - case 96: - case 94: - case 100: - case 85: + case 99: + case 97: + case 95: + case 101: + case 86: case 8: case 9: - case 12: case 13: - case 18: - case 20: - case 16: - case 88: - case 74: - case 93: - case 40: - case 62: - case 70: + case 14: + case 19: + case 21: + case 17: + case 89: + case 75: + case 94: + case 41: + case 63: + case 71: return true; default: return isIdentifier(); @@ -13569,18 +14006,18 @@ var ts; return true; } switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 79: - case 102: - case 104: - case 42: + case 80: + case 103: + case 105: case 43: - case 26: - case 120: - case 115: + case 44: + case 27: + case 121: + case 116: return true; default: if (isBinaryOperator()) { @@ -13590,10 +14027,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 16 && - token() !== 88 && - token() !== 74 && - token() !== 56 && + return token() !== 17 && + token() !== 89 && + token() !== 75 && + token() !== 57 && isStartOfExpression(); } function parseExpression() { @@ -13603,7 +14040,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(25))) { + while ((operatorToken = parseOptionalToken(26))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -13612,12 +14049,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 57) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { + if (token() !== 58) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } } - parseExpected(57); + parseExpected(58); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -13629,7 +14066,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 70 && token() === 35) { + if (expr.kind === 71 && token() === 36) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -13638,7 +14075,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 115) { + if (token() === 116) { if (inYieldContext()) { return true; } @@ -13651,11 +14088,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(196); + var node = createNode(197); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 38 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(38); + (token() === 39 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(39); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -13664,21 +14101,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(186, asyncModifier.pos); + node = createNode(187, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(186, identifier.pos); + node = createNode(187, identifier.pos); } - var parameter = createNode(145, identifier.pos); + var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -13695,78 +14132,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 35 || lastToken === 16) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 36 || lastToken === 17) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 18 || token() === 26 || token() === 119) { + if (token() === 19 || token() === 27 || token() === 120) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 35) { + if (token() === 36) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 119) { + if (token() === 120) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 18 && token() !== 26) { + if (token() !== 19 && token() !== 27) { return 0; } } var first = token(); var second = nextToken(); - if (first === 18) { - if (second === 19) { + if (first === 19) { + if (second === 20) { var third = nextToken(); switch (third) { - case 35: - case 55: - case 16: + case 36: + case 56: + case 17: return 1; default: return 0; } } - if (second === 20 || second === 16) { + if (second === 21 || second === 17) { return 2; } - if (second === 23) { + if (second === 24) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 55) { + if (nextToken() === 56) { return 1; } return 2; } else { - ts.Debug.assert(first === 26); + ts.Debug.assert(first === 27); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 84) { + if (third === 85) { var fourth = nextToken(); switch (fourth) { - case 57: - case 28: + case 58: + case 29: return false; default: return true; } } - else if (third === 25) { + else if (third === 26) { return true; } return false; @@ -13783,7 +14220,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 119) { + if (token() === 120) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -13794,38 +14231,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 119) { + if (token() === 120) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 35) { + if (scanner.hasPrecedingLineBreak() || token() === 36) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 && token() === 36) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(186); + var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(55, false, isAsync, !allowAmbiguity, node); + fillSignature(56, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 35 && token() !== 16) { + if (!allowAmbiguity && token() !== 36 && token() !== 17) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 16) { + if (token() === 17) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 24 && - token() !== 88 && - token() !== 74 && + if (token() !== 25 && + token() !== 89 && + token() !== 75 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -13835,15 +14272,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(54); + var questionToken = parseOptionalToken(55); if (!questionToken) { return leftOperand; } - var node = createNode(194, leftOperand.pos); + var node = createNode(195, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); + node.colonToken = parseExpectedToken(56, false, ts.Diagnostics._0_expected, ts.tokenToString(56)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -13852,22 +14289,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 141; + return t === 92 || t === 142; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 39 ? + var consumeCurrentOperator = token() === 40 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 91 && inDisallowInContext()) { + if (token() === 92 && inDisallowInContext()) { break; } - if (token() === 117) { + if (token() === 118) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -13883,92 +14320,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 91) { + if (inDisallowInContext() && token() === 92) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 53: + case 54: return 1; - case 52: + case 53: return 2; - case 48: - return 3; case 49: + return 3; + case 50: return 4; - case 47: + case 48: return 5; - case 31: case 32: case 33: case 34: + case 35: return 6; - case 26: - case 28: + case 27: case 29: case 30: + case 31: + case 93: case 92: - case 91: - case 117: + case 118: return 7; - case 44: case 45: case 46: + case 47: return 8; - case 36: case 37: - return 9; case 38: - case 40: - case 41: - return 10; + return 9; case 39: + case 41: + case 42: + return 10; + case 40: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(193, left.pos); + var node = createNode(194, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(201, left.pos); + var node = createNode(202, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(191); + var node = createNode(192); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(187); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(189); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(190); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 120) { + if (token() === 121) { if (inAwaitContext()) { return true; } @@ -13977,7 +14414,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -13985,15 +14422,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 39 ? + return token() === 40 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 39) { + if (token() === 40) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 183) { + if (simpleUnaryExpression.kind === 184) { 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 { @@ -14004,20 +14441,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: return parsePrefixUnaryExpression(); - case 79: + case 80: return parseDeleteExpression(); - case 102: + case 103: return parseTypeOfExpression(); - case 104: + case 105: return parseVoidExpression(); - case 26: + case 27: return parseTypeAssertion(); - case 120: + case 121: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -14027,16 +14464,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 79: - case 102: - case 104: - case 120: + case 80: + case 103: + case 105: + case 121: return false; - case 26: + case 27: if (sourceFile.languageVariant !== 1) { return false; } @@ -14045,20 +14482,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 42 || token() === 43) { - var node = createNode(191); + if (token() === 43 || token() === 44) { + var node = createNode(192); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 27 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(192, expression.pos); + if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(193, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -14067,7 +14504,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 96 + var expression = token() === 97 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -14078,12 +14515,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 18 || token() === 22 || token() === 20) { + if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(178, expression.pos); + var node = createNode(179, expression.pos); node.expression = expression; - parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(23, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -14091,10 +14528,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 70) { + if (lhs.kind === 71) { return lhs.text === rhs.text; } - if (lhs.kind === 98) { + if (lhs.kind === 99) { return true; } return lhs.name.text === rhs.name.text && @@ -14103,8 +14540,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 250) { - var node = createNode(248, opening.pos); + if (opening.kind === 251) { + var node = createNode(249, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -14114,18 +14551,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 249); + ts.Debug.assert(opening.kind === 250); result = opening; } - if (inExpressionContext && token() === 26) { + if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(193, result.pos); + var badNode = createNode(194, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(25, false, undefined); + badNode.operatorToken = createMissingNode(26, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -14134,16 +14571,18 @@ var ts; } function parseJsxText() { var node = createNode(10, scanner.getStartPos()); + node.containsOnlyWhiteSpaces = currentToken === 11; currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { case 10: + case 11: return parseJsxText(); - case 16: + case 17: return parseJsxExpression(false); - case 26: + case 27: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -14154,44 +14593,50 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 27) { + if (token() === 28) { break; } else if (token() === 1) { parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } - result.push(parseJsxChild()); + else if (token() === 7) { + break; + } + var child = parseJsxChild(); + if (child) { + result.push(child); + } } result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; return result; } function parseJsxAttributes() { - var jsxAttributes = createNode(253); + var jsxAttributes = createNode(254); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(26); + parseExpected(27); var tagName = parseJsxElementName(); var attributes = parseJsxAttributes(); var node; - if (token() === 28) { - node = createNode(250, fullStart); + if (token() === 29) { + node = createNode(251, fullStart); scanJsxText(); } else { - parseExpected(40); + parseExpected(41); if (inExpressionContext) { - parseExpected(28); + parseExpected(29); } else { - parseExpected(28, undefined, false); + parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(249, fullStart); + node = createNode(250, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -14199,10 +14644,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 98 ? + var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(22)) { - var propertyAccess = createNode(178, expression.pos); + while (parseOptional(23)) { + var propertyAccess = createNode(179, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -14210,29 +14655,29 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(255); - parseExpected(16); - if (token() !== 17) { - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(256); + parseExpected(17); + if (token() !== 18) { + node.dotDotDotToken = parseOptionalToken(24); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(17); + parseExpected(18); } else { - parseExpected(17, undefined, false); + parseExpected(18, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 16) { + if (token() === 17) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(252); + var node = createNode(253); node.name = parseIdentifierName(); - if (token() === 57) { + if (token() === 58) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -14245,69 +14690,69 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(254); - parseExpected(16); - parseExpected(23); - node.expression = parseExpression(); + var node = createNode(255); parseExpected(17); + parseExpected(24); + node.expression = parseExpression(); + parseExpected(18); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(251); - parseExpected(27); + var node = createNode(252); + parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(28); + parseExpected(29); } else { - parseExpected(28, undefined, false); + parseExpected(29, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(183); - parseExpected(26); + var node = createNode(184); + parseExpected(27); node.type = parseType(); - parseExpected(28); + parseExpected(29); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(22); + var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(178, expression.pos); + var propertyAccess = createNode(179, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 50 && !scanner.hasPrecedingLineBreak()) { + if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(202, expression.pos); + var nonNullExpression = createNode(203, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(179, expression.pos); + if (!inDecoratorContext() && parseOptional(21)) { + var indexedAccess = createNode(180, expression.pos); indexedAccess.expression = expression; - if (token() !== 21) { + if (token() !== 22) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(21); + parseExpected(22); expression = finishNode(indexedAccess); continue; } - if (token() === 12 || token() === 13) { - var tagExpression = createNode(182, expression.pos); + if (token() === 13 || token() === 14) { + var tagExpression = createNode(183, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 12 + tagExpression.template = token() === 13 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -14319,20 +14764,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 26) { + if (token() === 27) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(180, expression.pos); + var callExpr = createNode(181, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 18) { - var callExpr = createNode(180, expression.pos); + else if (token() === 19) { + var callExpr = createNode(181, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -14342,17 +14787,17 @@ var ts; } } function parseArgumentList() { - parseExpected(18); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(19); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(20); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(26)) { + if (!parseOptional(27)) { return undefined; } var typeArguments = parseDelimitedList(19, parseType); - if (!parseExpected(28)) { + if (!parseExpected(29)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -14361,27 +14806,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 18: - case 22: case 19: - case 21: + case 23: + case 20: + case 22: + case 56: + case 25: case 55: - case 24: - case 54: - case 31: - case 33: case 32: case 34: - case 52: + case 33: + case 35: case 53: - case 49: - case 47: + case 54: + case 50: case 48: - case 17: + case 49: + case 18: case 1: return true; - case 25: - case 16: + case 26: + case 17: default: return false; } @@ -14390,87 +14835,87 @@ var ts; switch (token()) { case 8: case 9: - case 12: + case 13: return parseLiteralNode(); - case 98: - case 96: - case 94: - case 100: - case 85: + case 99: + case 97: + case 95: + case 101: + case 86: return parseTokenNode(); - case 18: + case 19: return parseParenthesizedExpression(); - case 20: + case 21: return parseArrayLiteralExpression(); - case 16: + case 17: return parseObjectLiteralExpression(); - case 119: + case 120: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 74: + case 75: return parseClassExpression(); - case 88: + case 89: return parseFunctionExpression(); - case 93: + case 94: return parseNewExpression(); - case 40: - case 62: - if (reScanSlashToken() === 11) { + case 41: + case 63: + if (reScanSlashToken() === 12) { return parseLiteralNode(); } break; - case 13: + case 14: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(184); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(185); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(197); - parseExpected(23); + var node = createNode(198); + parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(199) : + return token() === 24 ? parseSpreadElement() : + token() === 26 ? createNode(200) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(176); - parseExpected(20); + var node = createNode(177); + parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(21); + parseExpected(22); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(124)) { - return parseAccessorDeclaration(152, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(134)) { + if (parseContextualModifier(125)) { return parseAccessorDeclaration(153, fullStart, decorators, modifiers); } + else if (parseContextualModifier(135)) { + return parseAccessorDeclaration(154, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); - var dotDotDotToken = parseOptionalToken(23); + var dotDotDotToken = parseOptionalToken(24); if (dotDotDotToken) { - var spreadElement = createNode(262, fullStart); + var spreadElement = createNode(263, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -14480,19 +14925,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(38); + var asteriskToken = parseOptionalToken(39); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (asteriskToken || token() === 18 || token() === 26) { + var questionToken = parseOptionalToken(55); + if (asteriskToken || token() === 19 || token() === 27) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(261, fullStart); + var shorthandDeclaration = createNode(262, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(57); + var equalsToken = parseOptionalToken(58); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -14500,23 +14945,23 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(260, fullStart); + var propertyAssignment = createNode(261, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(55); + parseExpected(56); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(177); - parseExpected(16); + var node = createNode(178); + parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(17); + parseExpected(18); return finishNode(node); } function parseFunctionExpression() { @@ -14524,10 +14969,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiers(); - parseExpected(88); - node.asteriskToken = parseOptionalToken(38); + parseExpected(89); + node.asteriskToken = parseOptionalToken(39); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -14535,7 +14980,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(55, isGenerator, isAsync, false, node); + fillSignature(56, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -14547,29 +14992,29 @@ var ts; } function parseNewExpression() { var fullStart = scanner.getStartPos(); - parseExpected(93); - if (parseOptional(22)) { - var node_1 = createNode(203, fullStart); - node_1.keywordToken = 93; + parseExpected(94); + if (parseOptional(23)) { + var node_1 = createNode(204, fullStart); + node_1.keywordToken = 94; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(181, fullStart); + var node = createNode(182, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 18) { + if (node.typeArguments || token() === 19) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(206); - if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(207); + if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(17); + parseExpected(18); } else { node.statements = createMissingList(); @@ -14594,47 +15039,48 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(208); - parseExpected(24); + var node = createNode(209); + parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(210); - parseExpected(89); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(211); + parseExpected(90); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(81) ? parseStatement() : undefined; + node.elseStatement = parseOptional(82) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(211); - parseExpected(80); + var node = createNode(212); + parseExpected(81); node.statement = parseStatement(); - parseExpected(105); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + parseExpected(106); parseExpected(19); - parseOptional(24); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + parseOptional(25); return finishNode(node); } function parseWhileStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(87); - parseExpected(18); + parseExpected(88); + var awaitToken = parseOptionalToken(121); + parseExpected(19); var initializer = undefined; - if (token() !== 24) { - if (token() === 103 || token() === 109 || token() === 75) { + if (token() !== 25) { + if (token() === 104 || token() === 110 || token() === 76) { initializer = parseVariableDeclarationList(true); } else { @@ -14642,32 +15088,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(91)) { - var forInStatement = createNode(214, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(19); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(141)) { - var forOfStatement = createNode(215, pos); + if (awaitToken ? parseExpected(142) : parseOptional(142)) { + var forOfStatement = createNode(216, pos); + forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(19); + parseExpected(20); forOrForInOrForOfStatement = forOfStatement; } + else if (parseOptional(92)) { + var forInStatement = createNode(215, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(20); + forOrForInOrForOfStatement = forInStatement; + } else { - var forStatement = createNode(213, pos); + var forStatement = createNode(214, pos); forStatement.initializer = initializer; - parseExpected(24); - if (token() !== 24 && token() !== 19) { + parseExpected(25); + if (token() !== 25 && token() !== 20) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(24); - if (token() !== 19) { + parseExpected(25); + if (token() !== 20) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(19); + parseExpected(20); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -14675,7 +15122,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 217 ? 71 : 76); + parseExpected(kind === 218 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -14683,8 +15130,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(218); - parseExpected(95); + var node = createNode(219); + parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -14692,90 +15139,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(219); - parseExpected(106); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(220); + parseExpected(107); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(256); - parseExpected(72); + var node = createNode(257); + parseExpected(73); node.expression = allowInAnd(parseExpression); - parseExpected(55); + parseExpected(56); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(257); - parseExpected(78); - parseExpected(55); + var node = createNode(258); + parseExpected(79); + parseExpected(56); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 72 ? parseCaseClause() : parseDefaultClause(); + return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(220); - parseExpected(97); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(221); + parseExpected(98); parseExpected(19); - var caseBlock = createNode(234, scanner.getStartPos()); - parseExpected(16); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + var caseBlock = createNode(235, scanner.getStartPos()); parseExpected(17); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(18); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(222); - parseExpected(99); + var node = createNode(223); + parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(223); - parseExpected(101); + var node = createNode(224); + parseExpected(102); node.tryBlock = parseBlock(false); - node.catchClause = token() === 73 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 86) { - parseExpected(86); + node.catchClause = token() === 74 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 87) { + parseExpected(87); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(259); - parseExpected(73); - if (parseExpected(18)) { + var result = createNode(260); + parseExpected(74); + if (parseExpected(19)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(19); + parseExpected(20); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(224); - parseExpected(77); + var node = createNode(225); + parseExpected(78); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(221, fullStart); + if (expression.kind === 71 && parseOptional(56)) { + var labeledStatement = createNode(222, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(209, fullStart); + var expressionStatement = createNode(210, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -14785,9 +15232,13 @@ var ts; nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsClassKeywordOnSameLine() { + nextToken(); + return token() === 75 && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 88 && !scanner.hasPrecedingLineBreak(); + return token() === 89 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -14796,47 +15247,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 103: - case 109: + case 104: + case 110: + case 76: + case 89: case 75: - case 88: - case 74: - case 82: + case 83: return true; - case 108: - case 137: + case 109: + case 138: return nextTokenIsIdentifierOnSameLine(); - case 127: case 128: + case 129: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 119: - case 123: - case 111: + case 117: + case 120: + case 124: case 112: case 113: - case 130: + case 114: + case 131: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 140: + case 141: nextToken(); - return token() === 16 || token() === 70 || token() === 83; - case 90: + return token() === 17 || token() === 71 || token() === 84; + case 91: nextToken(); - return token() === 9 || token() === 38 || - token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); - case 83: + return token() === 9 || token() === 39 || + token() === 17 || ts.tokenIsIdentifierOrKeyword(token()); + case 84: nextToken(); - if (token() === 57 || token() === 38 || - token() === 16 || token() === 78 || - token() === 117) { + if (token() === 58 || token() === 39 || + token() === 17 || token() === 79 || + token() === 118) { return true; } continue; - case 114: + case 115: nextToken(); continue; default: @@ -14849,46 +15300,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 56: - case 24: - case 16: - case 103: - case 109: - case 88: - case 74: - case 82: + case 57: + case 25: + case 17: + case 104: + case 110: case 89: - case 80: - case 105: - case 87: - case 76: - case 71: - case 95: - case 106: - case 97: - case 99: - case 101: - case 77: - case 73: - case 86: - return true; case 75: case 83: case 90: - return isStartOfDeclaration(); - case 119: - case 123: - case 108: - case 127: - case 128: - case 137: - case 140: + case 81: + case 106: + case 88: + case 77: + case 72: + case 96: + case 107: + case 98: + case 100: + case 102: + case 78: + case 74: + case 87: + return true; + case 76: + case 84: + case 91: + return isStartOfDeclaration(); + case 120: + case 124: + case 109: + case 128: + case 129: + case 138: + case 141: return true; - case 113: - case 111: - case 112: case 114: - case 130: + case 112: + case 113: + case 115: + case 131: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -14896,73 +15347,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 16 || token() === 20; + return isIdentifier() || token() === 17 || token() === 21; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 24: + case 25: return parseEmptyStatement(); - case 16: + case 17: return parseBlock(false); - case 103: + case 104: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 109: + case 110: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 88: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 74: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 89: - return parseIfStatement(); - case 80: - return parseDoStatement(); - case 105: - return parseWhileStatement(); - case 87: - return parseForOrForInOrForOfStatement(); - case 76: - return parseBreakOrContinueStatement(216); - case 71: - return parseBreakOrContinueStatement(217); - case 95: - return parseReturnStatement(); - case 106: - return parseWithStatement(); - case 97: - return parseSwitchStatement(); - case 99: - return parseThrowStatement(); - case 101: - case 73: - case 86: - return parseTryStatement(); - case 77: - return parseDebuggerStatement(); - case 56: - return parseDeclaration(); - case 119: - case 108: - case 137: - case 127: - case 128: - case 123: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 75: - case 82: - case 83: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 90: - case 111: + return parseIfStatement(); + case 81: + return parseDoStatement(); + case 106: + return parseWhileStatement(); + case 88: + return parseForOrForInOrForOfStatement(); + case 77: + return parseBreakOrContinueStatement(217); + case 72: + return parseBreakOrContinueStatement(218); + case 96: + return parseReturnStatement(); + case 107: + return parseWithStatement(); + case 98: + return parseSwitchStatement(); + case 100: + return parseThrowStatement(); + case 102: + case 74: + case 87: + return parseTryStatement(); + case 78: + return parseDebuggerStatement(); + case 57: + return parseDeclaration(); + case 120: + case 109: + case 138: + case 128: + case 129: + case 124: + case 76: + case 83: + case 84: + case 91: case 112: case 113: - case 116: case 114: - case 130: - case 140: + case 117: + case 115: + case 131: + case 141: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -14975,40 +15426,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 103: - case 109: - case 75: + case 104: + case 110: + case 76: return parseVariableStatement(fullStart, decorators, modifiers); - case 88: + case 89: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 74: + case 75: return parseClassDeclaration(fullStart, decorators, modifiers); - case 108: + case 109: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 137: + case 138: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 82: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 140: - case 127: - case 128: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 90: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 83: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 141: + case 128: + case 129: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 91: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 84: nextToken(); switch (token()) { - case 78: - case 57: + case 79: + case 58: return parseExportAssignment(fullStart, decorators, modifiers); - case 117: + case 118: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(247, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -15021,32 +15472,32 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 16 && canParseSemicolon()) { + if (token() !== 17 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 25) { - return createNode(199); + if (token() === 26) { + return createNode(200); } - var node = createNode(175); - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(176); + node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(175); - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(176); + node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 55) { + if (tokenIsIdentifier && token() !== 56) { node.name = propertyName; } else { - parseExpected(55); + parseExpected(56); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -15054,33 +15505,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(173); - parseExpected(16); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(174); parseExpected(17); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(174); - parseExpected(20); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(175); parseExpected(21); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(22); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 16 || token() === 20 || isIdentifier(); + return token() === 17 || token() === 21 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 20) { + if (token() === 21) { return parseArrayBindingPattern(); } - if (token() === 16) { + if (token() === 17) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(225); + var node = createNode(226); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -15089,21 +15540,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(226); + var node = createNode(227); switch (token()) { - case 103: + case 104: break; - case 109: + case 110: node.flags |= 1; break; - case 75: + case 76: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 142 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -15115,10 +15566,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 19; + return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(207, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -15126,29 +15577,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(88); - node.asteriskToken = parseOptionalToken(38); + parseExpected(89); + node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(55, isGenerator, isAsync, false, node); + fillSignature(56, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(151, pos); + var node = createNode(152, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(122); - fillSignature(55, false, false, false, node); + parseExpected(123); + fillSignature(56, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(150, fullStart); + var method = createNode(151, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -15156,12 +15607,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(55, isGenerator, isAsync, false, method); + fillSignature(56, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(148, fullStart); + var property = createNode(149, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -15174,10 +15625,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(38); + var asteriskToken = parseOptionalToken(39); var name = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (asteriskToken || token() === 18 || token() === 26) { + var questionToken = parseOptionalToken(55); + if (asteriskToken || token() === 19 || token() === 27) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -15192,17 +15643,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(55, false, false, false, node); + fillSignature(56, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 113: - case 111: - case 112: case 114: - case 130: + case 112: + case 113: + case 115: + case 131: return true; default: return false; @@ -15210,7 +15661,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 56) { + if (token() === 57) { return true; } while (ts.isModifierKind(token())) { @@ -15220,26 +15671,26 @@ var ts; } nextToken(); } - if (token() === 38) { + if (token() === 39) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 20) { + if (token() === 21) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 135 || idToken === 125) { return true; } switch (token()) { - case 18: - case 26: + case 19: + case 27: + case 56: + case 58: case 55: - case 57: - case 54: return true; default: return canParseSemicolon(); @@ -15251,10 +15702,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(56)) { + if (!parseOptional(57)) { break; } - var decorator = createNode(146, decoratorStart); + var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -15274,7 +15725,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 75 && permitInvalidConstAsModifier) { + if (token() === 76 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -15299,7 +15750,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 119) { + if (token() === 120) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -15310,8 +15761,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 24) { - var result = createNode(205); + if (token() === 25) { + var result = createNode(206); nextToken(); return finishNode(result); } @@ -15322,7 +15773,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 122) { + if (token() === 123) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -15331,33 +15782,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 38 || - token() === 20) { + token() === 39 || + token() === 21) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 199); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 229); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(74); + parseExpected(75); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(16)) { + if (parseExpected(17)) { node.members = parseClassMembers(); - parseExpected(17); + parseExpected(18); } else { node.members = createMissingList(); @@ -15370,7 +15821,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 108 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -15379,9 +15830,10 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 84 || token() === 107) { - var node = createNode(258); - node.token = token(); + var tok = token(); + if (tok === 85 || tok === 108) { + var node = createNode(259); + node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); @@ -15389,24 +15841,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(200); + var node = createNode(201); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 26) { - node.typeArguments = parseBracketedList(19, parseType, 26, 28); + if (token() === 27) { + node.typeArguments = parseBracketedList(19, parseType, 27, 29); } return finishNode(node); } function isHeritageClause() { - return token() === 84 || token() === 107; + return token() === 85 || token() === 108; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(108); + parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -15414,32 +15866,32 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(137); + parseExpected(138); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(57); + parseExpected(58); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(263, scanner.getStartPos()); + var node = createNode(264, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(82); + parseExpected(83); node.name = parseIdentifier(); - if (parseExpected(16)) { + if (parseExpected(17)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(17); + parseExpected(18); } else { node.members = createMissingList(); @@ -15447,10 +15899,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(233, scanner.getStartPos()); - if (parseExpected(16)) { + var node = createNode(234, scanner.getStartPos()); + if (parseExpected(17)) { node.statements = parseList(1, parseStatement); - parseExpected(17); + parseExpected(18); } else { node.statements = createMissingList(); @@ -15458,29 +15910,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(232, fullStart); + var node = createNode(233, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(22) + node.body = parseOptional(23) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(232, fullStart); + var node = createNode(233, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 140) { + if (token() === 141) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 16) { + if (token() === 17) { node.body = parseModuleBlock(); } else { @@ -15490,14 +15942,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 140) { + if (token() === 141) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(128)) { + else if (parseOptional(129)) { flags |= 16; } else { - parseExpected(127); + parseExpected(128); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -15505,63 +15957,66 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 131 && + return token() === 132 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 18; + return nextToken() === 19; } function nextTokenIsSlash() { - return nextToken() === 40; + return nextToken() === 41; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(235, fullStart); + var exportDeclaration = createNode(236, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(117); - parseExpected(128); + parseExpected(118); + parseExpected(129); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(90); + parseExpected(91); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 139) { - var importEqualsDeclaration = createNode(236, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(57); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + if (token() !== 26 && token() !== 140) { + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } - var importDeclaration = createNode(237, fullStart); + var importDeclaration = createNode(238, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 38 || - token() === 16) { + token() === 39 || + token() === 17) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(139); + parseExpected(140); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier) { + var importEqualsDeclaration = createNode(237, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(58); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } function parseImportClause(identifier, fullStart) { - var importClause = createNode(238, fullStart); + var importClause = createNode(239, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); + parseOptional(26)) { + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(241); } return finishNode(importClause); } @@ -15571,11 +16026,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(247); - parseExpected(131); - parseExpected(18); - node.expression = parseModuleSpecifier(); + var node = createNode(248); + parseExpected(132); parseExpected(19); + node.expression = parseModuleSpecifier(); + parseExpected(20); return finishNode(node); } function parseModuleSpecifier() { @@ -15589,22 +16044,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(239); - parseExpected(38); - parseExpected(117); + var namespaceImport = createNode(240); + parseExpected(39); + parseExpected(118); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 241 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(245); + return parseImportOrExportSpecifier(246); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(241); + return parseImportOrExportSpecifier(242); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -15612,9 +16067,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 117) { + if (token() === 118) { node.propertyName = identifierName; - parseExpected(117); + parseExpected(118); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -15623,23 +16078,23 @@ var ts; else { node.name = identifierName; } - if (kind === 241 && checkIdentifierIsKeyword) { + if (kind === 242 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(243, fullStart); + var node = createNode(244, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(38)) { - parseExpected(139); + if (parseOptional(39)) { + parseExpected(140); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(244); - if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(139); + node.exportClause = parseNamedImportsOrExports(245); + if (token() === 140 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(140); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -15647,14 +16102,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(242, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(57)) { + if (parseOptional(58)) { node.isExportEquals = true; } else { - parseExpected(78); + parseExpected(79); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -15666,6 +16121,7 @@ var ts; var typeReferenceDirectives = []; var amdDependencies = []; var amdModuleName; + var checkJsDirective = undefined; while (true) { var kind = triviaScanner.scan(); if (kind !== 2) { @@ -15676,7 +16132,11 @@ var ts; break; } } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var range = { + kind: triviaScanner.getToken(), + pos: triviaScanner.getTokenPos(), + end: triviaScanner.getTextPos(), + }; var comment = sourceText.substring(range.pos, range.end); var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { @@ -15716,20 +16176,30 @@ var ts; amdDependencies.push(amdDependency); } } + var checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; + var checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: ts.compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", true) === 0, + end: range.end, + pos: range.pos + }; + } } } sourceFile.referencedFiles = referencedFiles; sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 236 && node.moduleReference.kind === 247 - || node.kind === 237 - || node.kind === 242 + || node.kind === 237 && node.moduleReference.kind === 248 + || node.kind === 238 || node.kind === 243 + || node.kind === 244 ? node : undefined; }); @@ -15738,16 +16208,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 38: - case 54: - case 18: - case 20: - case 50: - case 16: - case 88: - case 23: - case 93: - case 98: + case 39: + case 55: + case 19: + case 21: + case 51: + case 17: + case 89: + case 24: + case 94: + case 99: return true; } return ts.tokenIsIdentifierOrKeyword(token()); @@ -15765,23 +16235,23 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(266, scanner.getTokenPos()); - parseExpected(16); - result.type = parseJSDocTopLevelType(); + var result = createNode(267, scanner.getTokenPos()); parseExpected(17); + result.type = parseJSDocTopLevelType(); + parseExpected(18); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 48) { - var unionType = createNode(270, type.pos); + if (token() === 49) { + var unionType = createNode(271, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 57) { - var optionalType = createNode(277, type.pos); + if (token() === 58) { + var optionalType = createNode(278, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -15791,21 +16261,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 20) { - var arrayType = createNode(269, type.pos); + if (token() === 21) { + var arrayType = createNode(270, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(21); + parseExpected(22); type = finishNode(arrayType); } - else if (token() === 54) { - var nullableType = createNode(272, type.pos); + else if (token() === 55) { + var nullableType = createNode(273, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 50) { - var nonNullableType = createNode(273, type.pos); + else if (token() === 51) { + var nonNullableType = createNode(274, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -15818,95 +16288,95 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 38: + case 39: return parseJSDocAllType(); - case 54: + case 55: return parseJSDocUnknownOrNullableType(); - case 18: + case 19: return parseJSDocUnionType(); - case 20: + case 21: return parseJSDocTupleType(); - case 50: + case 51: return parseJSDocNonNullableType(); - case 16: + case 17: return parseJSDocRecordType(); - case 88: + case 89: return parseJSDocFunctionType(); - case 23: + case 24: return parseJSDocVariadicType(); - case 93: - return parseJSDocConstructorType(); - case 98: - return parseJSDocThisType(); - case 118: - case 135: - case 132: - case 121: - case 136: - case 104: case 94: - case 138: - case 129: + return parseJSDocConstructorType(); + case 99: + return parseJSDocThisType(); + case 119: + case 136: case 133: + case 122: + case 137: + case 105: + case 95: + case 139: + case 130: + case 134: return parseTokenNode(); case 9: case 8: - case 100: - case 85: + case 101: + case 86: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(281); + var result = createNode(282); nextToken(); - parseExpected(55); + parseExpected(56); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(280); + var result = createNode(281); nextToken(); - parseExpected(55); + parseExpected(56); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(279); + var result = createNode(280); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(278); + var result = createNode(279); nextToken(); - parseExpected(18); + parseExpected(19); result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(19); - if (token() === 55) { + parseExpected(20); + if (token() === 56) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(145); + var parameter = createNode(146); parameter.type = parseJSDocType(); - if (parseOptional(57)) { - parameter.questionToken = createNode(57); + if (parseOptional(58)) { + parameter.questionToken = createNode(58); } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(276); + var result = createNode(277); result.name = parseSimplePropertyName(); - if (token() === 26) { + if (token() === 27) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(22)) { - if (token() === 26) { + while (parseOptional(23)) { + if (token() === 27) { result.typeArguments = parseTypeArguments(); break; } @@ -15922,7 +16392,7 @@ var ts; var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(28); + parseExpected(29); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -15933,28 +16403,28 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(142, left.pos); + var result = createNode(143, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(274); + var result = createNode(275); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(273); + var result = createNode(274); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(271); + var result = createNode(272); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(21); + parseExpected(22); return finishNode(result); } function checkForTrailingComma(list) { @@ -15964,45 +16434,45 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(270); + var result = createNode(271); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(19); + parseExpected(20); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(48)) { + while (parseOptional(49)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(267); + var result = createNode(268); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(292); + var result = createNode(293); result.literal = parseLiteralTypeNode(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 25 || - token() === 17 || - token() === 19 || - token() === 28 || - token() === 57 || - token() === 48) { - var result = createNode(268, pos); + if (token() === 26 || + token() === 18 || + token() === 20 || + token() === 29 || + token() === 58 || + token() === 49) { + var result = createNode(269, pos); return finishNode(result); } else { - var result = createNode(272, pos); + var result = createNode(273, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -16067,7 +16537,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 56: + case 57: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -16085,7 +16555,7 @@ var ts; state = 0; indent = 0; break; - case 38: + case 39: var asterisk = scanner.getTokenText(); if (state === 1 || state === 2) { state = 2; @@ -16096,7 +16566,7 @@ var ts; indent += asterisk.length; } break; - case 70: + case 71: pushComment(scanner.getTokenText()); state = 2; break; @@ -16146,7 +16616,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(282, start); + var result = createNode(283, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -16157,8 +16627,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 56); - var atToken = createNode(56, scanner.getTokenPos()); + ts.Debug.assert(token() === 57); + var atToken = createNode(57, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -16203,7 +16673,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1; + var state = 0; var margin; function pushComment(text) { if (!margin) { @@ -16212,7 +16682,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 56 && token() !== 1) { + while (token() !== 57 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -16221,7 +16691,7 @@ var ts; } indent = 0; break; - case 56: + case 57: break; case 5: if (state === 2) { @@ -16235,7 +16705,7 @@ var ts; indent += whitespace.length; } break; - case 38: + case 39: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -16246,7 +16716,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 56) { + if (token() === 57) { break; } nextJSDocToken(); @@ -16256,7 +16726,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -16274,7 +16744,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 16) { + if (token() !== 17) { return undefined; } return parseJSDocTypeExpression(); @@ -16285,14 +16755,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(20)) { + if (parseOptionalToken(21)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(57)) { + if (parseOptionalToken(58)) { parseExpression(); } - parseExpected(21); + parseExpected(22); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -16311,7 +16781,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(285, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -16322,20 +16792,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 286; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 287; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(287, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -16350,7 +16820,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(290, atToken.pos); + var result = createNode(291, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -16359,7 +16829,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -16368,15 +16838,15 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(289, atToken.pos); + var typedefTag = createNode(290, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; while (true) { - if (rightNode.kind === 70 || !rightNode.body) { - typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + if (rightNode.kind === 71 || !rightNode.body) { + typedefTag.name = rightNode.kind === 71 ? rightNode : rightNode.name; break; } rightNode = rightNode.body; @@ -16385,9 +16855,9 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 276) { + if (typeExpression.type.kind === 277) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 70) { + if (jsDocTypeReference.name.kind === 71) { var name = jsDocTypeReference.name; if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -16403,7 +16873,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(292, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -16411,7 +16881,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 56: + case 57: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -16425,14 +16895,15 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 38: + case 39: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 70: + case 71: canParseTag = false; + break; case 1: break; } @@ -16443,8 +16914,8 @@ var ts; function parseJSDocTypeNameWithNamespace(flags) { var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(232, pos); + if (typeNameOrNamespaceName && parseOptional(23)) { + var jsDocNamespaceNode = createNode(233, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -16457,8 +16928,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 56); - var atToken = createNode(56, scanner.getStartPos()); + ts.Debug.assert(token() === 57); + var atToken = createNode(57, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -16488,7 +16959,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 288; })) { + if (ts.forEach(tags, function (t) { return t.kind === 289; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -16499,11 +16970,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(144, name.pos); + var typeParameter = createNode(145, name.pos); typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 25) { + if (token() === 26) { nextJSDocToken(); skipWhitespace(); } @@ -16511,7 +16982,7 @@ var ts; break; } } - var result = createNode(288, atToken.pos); + var result = createNode(289, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -16532,7 +17003,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(70, pos); + var result = createNode(71, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -16613,7 +17084,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 70: + case 71: return true; } return false; @@ -16830,16 +17301,16 @@ var ts; var ts; (function (ts) { function getModuleInstanceState(node) { - if (node.kind === 229 || node.kind === 230) { + if (node.kind === 230 || node.kind === 231) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 238 || node.kind === 237) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 233) { + else if (node.kind === 234) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -16855,11 +17326,11 @@ var ts; }); return state_1; } - else if (node.kind === 232) { + else if (node.kind === 233) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } - else if (node.kind === 70 && node.isInJSDocNamespace) { + else if (node.kind === 71 && node.isInJSDocNamespace) { return 0; } else { @@ -16937,7 +17408,7 @@ var ts; } return bindSourceFile; function bindInStrictMode(file, opts) { - if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !ts.isDeclarationFile(file)) { return true; } else { @@ -16964,7 +17435,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 233)) { symbol.valueDeclaration = node; } } @@ -16974,7 +17445,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 143) { + if (node.name.kind === 144) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -16985,49 +17456,50 @@ var ts; return node.name.text; } switch (node.kind) { - case 151: + case 152: return "__constructor"; - case 159: - case 154: - return "__call"; case 160: case 155: - return "__new"; + return "__call"; + case 161: case 156: + return "__new"; + case 157: return "__index"; - case 243: + case 244: return "__export"; - case 242: + case 243: return node.isExportEquals ? "export=" : "default"; - case 193: + case 194: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; case 1: case 4: + case 5: return node.left.name.text; case 3: return node.left.expression.name.text; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 227: case 228: + case 229: return ts.hasModifier(node, 512) ? "default" : undefined; - case 278: + case 279: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 145: - ts.Debug.assert(node.parent.kind === 278); + case 146: + ts.Debug.assert(node.parent.kind === 279); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 289: + case 290: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 207) { + if (parentNode && parentNode.kind === 208) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70) { + if (nameIdentifier.kind === 71) { nameFromParentNode = nameIdentifier.text; } } @@ -17071,7 +17543,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 243 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -17091,7 +17563,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { + if (node.kind === 246 || (node.kind === 237 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -17099,9 +17571,9 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 289 && + var isJSDocTypedefInJSDocNamespace = node.kind === 290 && node.name && - node.name.kind === 70 && + node.name.kind === 71 && node.name.isInJSDocNamespace; if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | @@ -17160,7 +17632,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 264) { + if (node.kind === 265) { node.flags |= emitFlags; } if (isIIFE) { @@ -17236,66 +17708,72 @@ var ts; return; } switch (node.kind) { - case 212: + case 213: bindWhileStatement(node); break; - case 211: + case 212: bindDoStatement(node); break; - case 213: + case 214: bindForStatement(node); break; - case 214: case 215: + case 216: bindForInOrForOfStatement(node); break; - case 210: + case 211: bindIfStatement(node); break; - case 218: - case 222: + case 219: + case 223: bindReturnOrThrow(node); break; + case 218: case 217: - case 216: bindBreakOrContinueStatement(node); break; - case 223: + case 224: bindTryStatement(node); break; - case 220: + case 221: bindSwitchStatement(node); break; - case 234: + case 235: bindCaseBlock(node); break; - case 256: + case 257: bindCaseClause(node); break; - case 221: + case 222: bindLabeledStatement(node); break; - case 191: + case 192: bindPrefixUnaryExpressionFlow(node); break; - case 192: + case 193: bindPostfixUnaryExpressionFlow(node); break; - case 193: + case 194: bindBinaryExpressionFlow(node); break; - case 187: + case 188: bindDeleteExpressionFlow(node); break; - case 194: + case 195: bindConditionalExpressionFlow(node); break; - case 225: + case 226: bindVariableDeclarationFlow(node); break; - case 180: + case 181: bindCallExpressionFlow(node); break; + case 283: + bindJSDocComment(node); + break; + case 290: + bindJSDocTypedefTag(node); + break; default: bindEachChild(node); break; @@ -17303,25 +17781,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 70: - case 98: - case 178: + case 71: + case 99: + case 179: return isNarrowableReference(expr); - case 180: + case 181: return hasNarrowableArgument(expr); - case 184: + case 185: return isNarrowingExpression(expr.expression); - case 193: + case 194: return isNarrowingBinaryExpression(expr); - case 191: - return expr.operator === 50 && isNarrowingExpression(expr.operand); + case 192: + return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 70 || - expr.kind === 98 || - expr.kind === 178 && isNarrowableReference(expr.expression); + return expr.kind === 71 || + expr.kind === 99 || + expr.kind === 97 || + expr.kind === 179 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -17332,41 +17811,41 @@ var ts; } } } - if (expr.expression.kind === 178 && + if (expr.expression.kind === 179 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 189 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 57: + case 58: return isNarrowableReference(expr.left); - case 31: case 32: case 33: case 34: + case 35: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 92: + case 93: return isNarrowableOperand(expr.left); - case 25: + case 26: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 184: + case 185: return isNarrowableOperand(expr.expression); - case 193: + case 194: switch (expr.operatorToken.kind) { - case 57: + case 58: return isNarrowableOperand(expr.left); - case 25: + case 26: return isNarrowableOperand(expr.right); } } @@ -17400,8 +17879,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 100 && flags & 64 || - expression.kind === 85 && flags & 32) { + if (expression.kind === 101 && flags & 64 || + expression.kind === 86 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -17456,34 +17935,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 210: - case 212: case 211: - return parent.expression === node; case 213: - case 194: + case 212: + return parent.expression === node; + case 214: + case 195: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 184) { + if (node.kind === 185) { node = node.expression; } - else if (node.kind === 191 && node.operator === 50) { + else if (node.kind === 192 && node.operator === 51) { node = node.operand; } else { - return node.kind === 193 && (node.operatorToken.kind === 52 || - node.operatorToken.kind === 53); + return node.kind === 194 && (node.operatorToken.kind === 53 || + node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 184 || - node.parent.kind === 191 && - node.parent.operator === 50) { + while (node.parent.kind === 185 || + node.parent.kind === 192 && + node.parent.operator === 51) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -17524,7 +18003,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 221 + var enclosingLabeledStatement = node.parent.kind === 222 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -17556,10 +18035,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; + if (node.kind === 216) { + bind(node.awaitModifier); + } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 226) { + if (node.initializer.kind !== 227) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -17581,7 +18063,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 218) { + if (node.kind === 219) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -17601,7 +18083,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 217 ? breakTarget : continueTarget; + var flowLabel = node.kind === 218 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -17664,7 +18146,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 258; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -17729,13 +18211,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 211) { + if (!node.statement || node.statement.kind !== 212) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 193 && node.operatorToken.kind === 57) { + if (node.kind === 194 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -17746,10 +18228,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 197) { + if (e.kind === 198) { bindAssignmentTargetFlow(e.expression); } else { @@ -17757,16 +18239,16 @@ var ts; } } } - else if (node.kind === 177) { + else if (node.kind === 178) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 260) { + if (p.kind === 261) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 261) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 262) { + else if (p.kind === 263) { bindAssignmentTargetFlow(p.expression); } } @@ -17774,7 +18256,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 52) { + if (node.operatorToken.kind === 53) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -17785,7 +18267,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 50) { + if (node.operator === 51) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -17795,20 +18277,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 52 || operator === 53) { + if (operator === 53 || operator === 54) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -17822,7 +18304,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 179) { + if (operator === 58 && node.left.kind === 180) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17833,7 +18315,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 178) { + if (node.expression.kind === 179) { bindAssignmentTargetFlow(node.expression); } } @@ -17866,16 +18348,31 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { + if (node.initializer || node.parent.parent.kind === 215 || node.parent.parent.kind === 216) { bindInitializedVariableFlow(node); } } + function bindJSDocComment(node) { + ts.forEachChild(node, function (n) { + if (n.kind !== 290) { + bind(n); + } + }); + } + function bindJSDocTypedefTag(node) { + ts.forEachChild(node, function (n) { + if (node.fullName && n === node.name && node.fullName.kind !== 71) { + return; + } + bind(n); + }); + } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 184) { + while (expr.kind === 185) { expr = expr.expression; } - if (expr.kind === 185 || expr.kind === 186) { + if (expr.kind === 186 || expr.kind === 187) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -17883,7 +18380,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 178) { + if (node.expression.kind === 179) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -17892,53 +18389,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 198: - case 228: - case 231: - case 177: - case 162: - case 291: - case 274: - case 253: - return 1; + case 199: case 229: - return 1 | 64; - case 278: case 232: + case 178: + case 163: + case 292: + case 275: + case 254: + return 1; case 230: - case 171: + return 1 | 64; + case 279: + case 233: + case 231: + case 172: return 1 | 32; - case 264: + case 265: return 1 | 4 | 32; - case 150: + case 151: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 151: - case 227: - case 149: case 152: + case 228: + case 150: case 153: case 154: case 155: case 156: - case 159: + case 157: case 160: + case 161: return 1 | 4 | 32 | 8; - case 185: case 186: + case 187: return 1 | 4 | 32 | 8 | 16; - case 233: + case 234: return 4; - case 148: + case 149: return node.initializer ? 4 : 0; - case 259: - case 213: + case 260: case 214: case 215: - case 234: + case 216: + case 235: return 2; - case 206: + case 207: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -17954,38 +18451,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 232: + case 233: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 264: + case 265: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 198: - case 228: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 231: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 162: - case 177: + case 199: case 229: - case 274: - case 291: - case 253: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 232: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 163: + case 178: + case 230: + case 275: + case 292: + case 254: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 159: case 160: - case 154: + case 161: case 155: case 156: - case 150: - case 149: + case 157: case 151: + case 150: case 152: case 153: - case 227: - case 185: + case 154: + case 228: case 186: - case 278: - case 230: - case 171: + case 187: + case 279: + case 231: + case 172: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -18000,11 +18497,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 264 ? node : node.body; - if (body && (body.kind === 264 || body.kind === 233)) { + var body = node.kind === 265 ? node : node.body; + if (body && (body.kind === 265 || body.kind === 234)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 243 || stat.kind === 242) { + if (stat.kind === 244 || stat.kind === 243) { return true; } } @@ -18082,11 +18579,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 || prop.name.kind !== 70) { + if (prop.kind === 263 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 + var currentKind = prop.kind === 261 || prop.kind === 262 || prop.kind === 151 ? 1 : 2; var existingKind = seen.get(identifier.text); @@ -18114,10 +18611,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 232: + case 233: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 264: + case 265: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -18135,8 +18632,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 107 && - node.originalKeywordKind <= 115 && + node.originalKeywordKind >= 108 && + node.originalKeywordKind <= 116 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -18164,17 +18661,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 70) { + if (inStrictMode && node.expression.kind === 71) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 70 && + return node.kind === 71 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 70) { + if (name && name.kind === 71) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -18207,8 +18704,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 264 && - blockScopeContainer.kind !== 232 && + if (blockScopeContainer.kind !== 265 && + blockScopeContainer.kind !== 233 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -18216,7 +18713,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.isOctalLiteral) { + if (inStrictMode && node.numericLiteralFlags & 4) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -18227,7 +18724,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -18250,8 +18747,11 @@ var ts; } node.parent = parent; var saveInStrictMode = inStrictMode; + if (ts.isInJavaScriptFile(node)) { + bindJSDocTypedefTagIfAny(node); + } bindWorker(node); - if (node.kind > 141) { + if (node.kind > 142) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -18268,6 +18768,26 @@ var ts; } inStrictMode = saveInStrictMode; } + function bindJSDocTypedefTagIfAny(node) { + if (!node.jsDoc) { + return; + } + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + if (!jsDoc.tags) { + continue; + } + for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) { + var tag = _c[_b]; + if (tag.kind === 290) { + var savedParent = parent; + parent = jsDoc; + bind(tag); + parent = savedParent; + } + } + } + } function updateStrictModeStatementList(statements) { if (!inStrictMode) { for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { @@ -18288,91 +18808,92 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 70: + case 71: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 289) { + while (parentNode && parentNode.kind !== 290) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } - case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { + case 99: + if (currentFlow && (ts.isExpression(node) || parent.kind === 262)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 178: + case 179: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 193: - if (ts.isInJavaScriptFile(node)) { - var specialKind = ts.getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case 1: - bindExportsPropertyAssignment(node); - break; - case 2: - bindModuleExportsAssignment(node); - break; - case 3: - bindPrototypePropertyAssignment(node); - break; - case 4: - bindThisPropertyAssignment(node); - break; - case 0: - break; - default: - ts.Debug.fail("Unknown special property assignment kind"); - } + case 194: + var specialKind = ts.getSpecialPropertyAssignmentKind(node); + switch (specialKind) { + case 1: + bindExportsPropertyAssignment(node); + break; + case 2: + bindModuleExportsAssignment(node); + break; + case 3: + bindPrototypePropertyAssignment(node); + break; + case 4: + bindThisPropertyAssignment(node); + break; + case 5: + bindStaticPropertyAssignment(node); + break; + case 0: + break; + default: + ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 259: + case 260: return checkStrictModeCatchClause(node); - case 187: + case 188: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 192: + case 193: return checkStrictModePostfixUnaryExpression(node); - case 191: + case 192: return checkStrictModePrefixUnaryExpression(node); - case 219: + case 220: return checkStrictModeWithStatement(node); - case 168: + case 169: seenThisKeyword = true; return; - case 157: + case 158: return checkTypePredicate(node); - case 144: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 145: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 146: return bindParameter(node); - case 225: - case 175: + case 226: + case 176: return bindVariableDeclarationOrBindingElement(node); + case 149: case 148: - case 147: - case 275: + case 276: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); - case 290: + case 291: return bindJSDocProperty(node); - case 260: case 261: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 263: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 262: - case 254: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 264: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 263: + case 255: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 177 && - root.parent.kind === 193 && - root.parent.operatorToken.kind === 57 && + if (root.kind === 178 && + root.parent.kind === 194 && + root.parent.operatorToken.kind === 58 && root.parent.left === root) { hasRest = true; break; @@ -18380,91 +18901,91 @@ var ts; root = root.parent; } return; - case 154: case 155: case 156: + case 157: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 150: - case 149: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 227: - return bindFunctionDeclaration(node); case 151: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 150: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 228: + return bindFunctionDeclaration(node); case 152: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 153: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 154: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 159: case 160: - case 278: + case 161: + case 279: return bindFunctionOrConstructorType(node); - case 162: - case 171: - case 291: - case 274: + case 163: + case 172: + case 292: + case 275: return bindAnonymousDeclaration(node, 2048, "__type"); - case 177: + case 178: return bindObjectLiteralExpression(node); - case 185: case 186: + case 187: return bindFunctionExpression(node); - case 180: + case 181: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 198: - case 228: + case 199: + case 229: inStrictMode = true; return bindClassLikeDeclaration(node); - case 229: + case 230: return bindBlockScopedDeclaration(node, 64, 792968); - case 289: - if (!node.fullName || node.fullName.kind === 70) { + case 290: + if (!node.fullName || node.fullName.kind === 71) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 230: - return bindBlockScopedDeclaration(node, 524288, 793064); case 231: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 232: + return bindEnumDeclaration(node); + case 233: return bindModuleDeclaration(node); - case 253: + case 254: return bindJsxAttributes(node); - case 252: + case 253: return bindJsxAttribute(node, 4, 0); - case 236: - case 239: - case 241: - case 245: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 235: - return bindNamespaceExportDeclaration(node); - case 238: - return bindImportClause(node); - case 243: - return bindExportDeclaration(node); + case 237: + case 240: case 242: + case 246: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 236: + return bindNamespaceExportDeclaration(node); + case 239: + return bindImportClause(node); + case 244: + return bindExportDeclaration(node); + case 243: return bindExportAssignment(node); - case 264: + case 265: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 206: + case 207: if (!ts.isFunctionLike(node.parent)) { return; } - case 233: + case 234: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 70) { + if (parameterName && parameterName.kind === 71) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 168) { + if (parameterName && parameterName.kind === 169) { seenThisKeyword = true; } bind(type); @@ -18483,7 +19004,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 243 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -18493,7 +19014,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 264) { + if (node.parent.kind !== 265) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -18536,24 +19057,56 @@ var ts; setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); } + function isExportsOrModuleExportsOrAlias(node) { + return ts.isExportsIdentifier(node) || + ts.isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + function isNameOfExportsOrModuleExportsAliasDeclaration(node) { + if (node.kind === 71) { + var symbol = lookupSymbolForName(node.text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === 226) { + var declaration = symbol.valueDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + function isExportsOrModuleExportsOrAliasOrAssignemnt(node) { + return isExportsOrModuleExportsOrAlias(node) || + (ts.isAssignmentExpression(node, true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } function bindModuleExportsAssignment(node) { + var assignedExpression = ts.getRightMostAssignedExpression(node.right); + if (ts.isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + setCommonJsModuleIndicator(node); + return; + } setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, 4 | 7340032 | 512, 0); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 227 || container.kind === 185) { - container.symbol.members = container.symbol.members || ts.createMap(); - declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); - } - else if (container.kind === 151) { - var saveContainer = container; - container = container.parent; - var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); - if (symbol) { - symbol.isReplaceableByMethod = true; - } - container = saveContainer; + var container = ts.getThisContainer(node, false); + switch (container.kind) { + case 228: + case 186: + container.symbol.members = container.symbol.members || ts.createMap(); + declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); + break; + case 152: + case 149: + case 151: + case 153: + case 154: + var containingClass = container.parent; + var symbol = declareSymbol(ts.hasModifier(container, 32) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, 4, 0); + if (symbol) { + symbol.isReplaceableByMethod = true; + } + break; } } function bindPrototypePropertyAssignment(node) { @@ -18563,14 +19116,35 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals.get(constructorFunction.text); - if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, true); + } + function bindStaticPropertyAssignment(node) { + var leftSideOfAssignment = node.left; + var target = leftSideOfAssignment.expression; + leftSideOfAssignment.parent = node; + target.parent = leftSideOfAssignment; + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, false); + } + } + function lookupSymbolForName(name) { + return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name)); + } + function bindPropertyAssignment(functionName, propertyAccessExpression, isPrototypeProperty) { + var targetSymbol = lookupSymbolForName(functionName); + if (targetSymbol && ts.isDeclarationOfFunctionOrClassExpression(targetSymbol)) { + targetSymbol = targetSymbol.valueDeclaration.initializer.symbol; + } + if (!targetSymbol || !(targetSymbol.flags & (16 | 32))) { return; } - if (!funcSymbol.members) { - funcSymbol.members = ts.createMap(); - } - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 0); + var symbolTable = isPrototypeProperty ? + (targetSymbol.members || (targetSymbol.members = ts.createMap())) : + (targetSymbol.exports || (targetSymbol.exports = ts.createMap())); + declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, 4, 0); } function bindCallExpression(node) { if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) { @@ -18578,7 +19152,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 228) { + if (node.kind === 229) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -18638,7 +19212,7 @@ var ts; } function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -18653,7 +19227,7 @@ var ts; } function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -18666,7 +19240,7 @@ var ts; } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -18689,15 +19263,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || - node.kind === 228 || - (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 209) || + node.kind === 229 || + (node.kind === 233 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 207 || + (node.kind !== 208 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -18711,56 +19285,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 180: - return computeCallExpression(node, subtreeFlags); case 181: + return computeCallExpression(node, subtreeFlags); + case 182: return computeNewExpression(node, subtreeFlags); - case 232: + case 233: return computeModuleDeclaration(node, subtreeFlags); - case 184: - return computeParenthesizedExpression(node, subtreeFlags); - case 193: - return computeBinaryExpression(node, subtreeFlags); - case 209: - return computeExpressionStatement(node, subtreeFlags); - case 145: - return computeParameter(node, subtreeFlags); - case 186: - return computeArrowFunction(node, subtreeFlags); case 185: + return computeParenthesizedExpression(node, subtreeFlags); + case 194: + return computeBinaryExpression(node, subtreeFlags); + case 210: + return computeExpressionStatement(node, subtreeFlags); + case 146: + return computeParameter(node, subtreeFlags); + case 187: + return computeArrowFunction(node, subtreeFlags); + case 186: return computeFunctionExpression(node, subtreeFlags); - case 227: - return computeFunctionDeclaration(node, subtreeFlags); - case 225: - return computeVariableDeclaration(node, subtreeFlags); - case 226: - return computeVariableDeclarationList(node, subtreeFlags); - case 207: - return computeVariableStatement(node, subtreeFlags); - case 221: - return computeLabeledStatement(node, subtreeFlags); case 228: + return computeFunctionDeclaration(node, subtreeFlags); + case 226: + return computeVariableDeclaration(node, subtreeFlags); + case 227: + return computeVariableDeclarationList(node, subtreeFlags); + case 208: + return computeVariableStatement(node, subtreeFlags); + case 222: + return computeLabeledStatement(node, subtreeFlags); + case 229: return computeClassDeclaration(node, subtreeFlags); - case 198: + case 199: return computeClassExpression(node, subtreeFlags); - case 258: - return computeHeritageClause(node, subtreeFlags); case 259: + return computeHeritageClause(node, subtreeFlags); + case 260: return computeCatchClause(node, subtreeFlags); - case 200: + case 201: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 151: - return computeConstructor(node, subtreeFlags); - case 148: - return computePropertyDeclaration(node, subtreeFlags); - case 150: - return computeMethod(node, subtreeFlags); case 152: + return computeConstructor(node, subtreeFlags); + case 149: + return computePropertyDeclaration(node, subtreeFlags); + case 151: + return computeMethod(node, subtreeFlags); case 153: + case 154: return computeAccessor(node, subtreeFlags); - case 236: + case 237: return computeImportEquals(node, subtreeFlags); - case 178: + case 179: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -18783,13 +19357,13 @@ var ts; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 96: + case 97: return true; - case 178: case 179: + case 180: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 96; + return expressionKind === 97; } return false; } @@ -18808,14 +19382,14 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 177) { + if (operatorTokenKind === 58 && leftKind === 178) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 176) { + else if (operatorTokenKind === 58 && leftKind === 177) { transformFlags |= 192 | 3072; } - else if (operatorTokenKind === 39 - || operatorTokenKind === 61) { + else if (operatorTokenKind === 40 + || operatorTokenKind === 62) { transformFlags |= 32; } node.transformFlags = transformFlags | 536870912; @@ -18850,8 +19424,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 201 - || expressionKind === 183) { + if (expressionKind === 202 + || expressionKind === 184) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -18894,10 +19468,10 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 84: + case 85: transformFlags |= 192; break; - case 107: + case 108: transformFlags |= 3; break; default: @@ -18948,9 +19522,9 @@ var ts; transformFlags |= 8; } if (ts.hasModifier(node, 256)) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; @@ -18993,7 +19567,7 @@ var ts; transformFlags |= 3; } if (modifierFlags & 256) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } if (subtreeFlags & 1048576) { transformFlags |= 8; @@ -19001,7 +19575,7 @@ var ts; if (subtreeFlags & 163840) { transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } } @@ -19016,7 +19590,7 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } if (subtreeFlags & 1048576) { transformFlags |= 8; @@ -19024,7 +19598,7 @@ var ts; if (subtreeFlags & 163840) { transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; @@ -19053,7 +19627,7 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 96) { + if (expressionKind === 97) { transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; @@ -19136,63 +19710,76 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536872257; switch (kind) { - case 119: - case 190: - transformFlags |= 16; + case 120: + case 191: + transformFlags |= 8 | 16; break; - case 113: - case 111: + case 114: case 112: - case 116: - case 123: - case 75: - case 231: - case 263: - case 183: - case 201: + case 113: + case 117: + case 124: + case 76: + case 232: + case 264: + case 184: case 202: - case 130: + case 203: + case 131: transformFlags |= 3; break; - case 248: case 249: case 250: - case 10: case 251: + case 10: case 252: case 253: case 254: case 255: + case 256: transformFlags |= 4; break; - case 215: - transformFlags |= 8; - case 12: case 13: case 14: case 15: - case 195: - case 182: - case 261: - case 114: - case 203: + case 16: + case 196: + case 183: + case 262: + case 115: + case 204: transformFlags |= 192; break; - case 196: - transformFlags |= 192 | 16777216; + case 9: + if (node.hasExtendedUnicodeEscape) { + transformFlags |= 192; + } break; - case 118: - case 132: - case 129: + case 8: + if (node.numericLiteralFlags & 48) { + transformFlags |= 192; + } + break; + case 216: + if (node.awaitModifier) { + transformFlags |= 8; + } + transformFlags |= 192; + break; + case 197: + transformFlags |= 8 | 192 | 16777216; + break; + case 119: case 133: - case 135: - case 121: + case 130: + case 134: case 136: - case 104: - case 144: - case 147: - case 149: - case 154: + case 122: + case 137: + case 105: + case 145: + case 148: + case 150: case 155: case 156: case 157: @@ -19206,55 +19793,56 @@ var ts; case 165: case 166: case 167: - case 229: - case 230: case 168: + case 230: + case 231: case 169: case 170: case 171: case 172: + case 173: transformFlags = 3; excludeFlags = -3; break; - case 143: + case 144: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 197: + case 198: transformFlags |= 192 | 524288; break; - case 262: + case 263: transformFlags |= 8 | 1048576; break; - case 96: + case 97: transformFlags |= 192; break; - case 98: + case 99: transformFlags |= 16384; break; - case 173: + case 174: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 175: + case 176: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 146: + case 147: transformFlags |= 3 | 4096; break; - case 177: + case 178: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -19266,29 +19854,29 @@ var ts; transformFlags |= 8; } break; - case 176: - case 181: + case 177: + case 182: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 211: case 212: case 213: case 214: + case 215: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 264: + case 265: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 218: - case 216: + case 219: case 217: + case 218: transformFlags |= 33554432; break; } @@ -19296,57 +19884,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 157 && kind <= 172) { + if (kind >= 158 && kind <= 173) { return -3; } switch (kind) { - case 180: case 181: - case 176: + case 182: + case 177: return 537396545; - case 232: + case 233: return 574674241; - case 145: + case 146: return 536872257; - case 186: + case 187: return 601249089; - case 185: - case 227: - return 601281857; - case 226: - return 546309441; + case 186: case 228: - case 198: + return 601281857; + case 227: + return 546309441; + case 229: + case 199: return 539358529; - case 151: - return 601015617; - case 150: case 152: - case 153: return 601015617; - case 118: - case 132: - case 129: - case 135: - case 133: - case 121: - case 136: - case 104: - case 144: - case 147: - case 149: + case 151: + case 153: case 154: + return 601015617; + case 119: + case 133: + case 130: + case 136: + case 134: + case 122: + case 137: + case 105: + case 145: + case 148: + case 150: case 155: case 156: - case 229: + case 157: case 230: + case 231: return -3; - case 177: + case 178: return 540087617; - case 259: + case 260: return 537920833; - case 173: case 174: + case 175: return 537396545; default: return 536872257; @@ -19442,7 +20030,7 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) { var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -19610,7 +20198,7 @@ var ts; } directoryPathMap.set(parent, result); current = parent; - if (current == commonPrefix) { + if (current === commonPrefix) { break; } } @@ -20032,9 +20620,22 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } + function mangleScopedPackage(moduleName, state) { + if (ts.startsWith(moduleName, "@")) { + var replaceSlash = moduleName.replace(ts.directorySeparator, "__"); + if (replaceSlash !== moduleName) { + var mangled = replaceSlash.slice(1); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled); + } + return mangled; + } + } + return moduleName; + } function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { var result = cache && cache.get(containingDirectory); if (result) { @@ -20140,15 +20741,19 @@ var ts; var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; var symbolCount = 0; + var symbolInstantiationDepth = 0; var emptyArray = []; var emptySymbols = ts.createMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; + var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); var noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; - var strictNullChecks = compilerOptions.strictNullChecks; + var strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks; + var noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny; + var noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; var emitResolver = createResolver(); + var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; var argumentsSymbol = createSymbol(4, "arguments"); @@ -20160,10 +20765,18 @@ var ts; isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, + getMergedSymbol: getMergedSymbol, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, - getSymbolsOfParameterPropertyDeclaration: getSymbolsOfParameterPropertyDeclaration, + getTypeOfSymbolAtLocation: function (symbol, location) { + location = ts.getParseTreeNode(location); + return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + }, + getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { + parameter = ts.getParseTreeNode(parameter, ts.isParameter); + ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + return getSymbolsOfParameterPropertyDeclaration(parameter, parameterName); + }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -20171,37 +20784,103 @@ var ts; getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, - getTypeFromTypeNode: getTypeFromTypeNode, + getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, + getWidenedType: getWidenedType, + getTypeFromTypeNode: function (node) { + node = ts.getParseTreeNode(node, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : unknownType; + }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, - getTypeAtLocation: getTypeOfNode, - getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, - signatureToString: signatureToString, - typeToString: typeToString, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, + getSymbolsInScope: function (location, meaning) { + location = ts.getParseTreeNode(location); + return location ? getSymbolsInScope(location, meaning) : []; + }, + getSymbolAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getSymbolAtLocation(node) : undefined; + }, + getShorthandAssignmentValueSymbol: function (node) { + node = ts.getParseTreeNode(node); + return node ? getShorthandAssignmentValueSymbol(node) : undefined; + }, + getExportSpecifierLocalTargetSymbol: function (node) { + node = ts.getParseTreeNode(node, ts.isExportSpecifier); + return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; + }, + getTypeAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getTypeOfNode(node) : unknownType; + }, + getPropertySymbolOfDestructuringAssignment: function (location) { + location = ts.getParseTreeNode(location, ts.isIdentifier); + return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; + }, + signatureToString: function (signature, enclosingDeclaration, flags, kind) { + return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind); + }, + typeToString: function (type, enclosingDeclaration, flags) { + return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags); + }, getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, + symbolToString: function (symbol, enclosingDeclaration, meaning) { + return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning); + }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: getContextualType, + getContextualType: function (node) { + node = ts.getParseTreeNode(node, ts.isExpression); + return node ? getContextualType(node) : undefined; + }, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, + getResolvedSignature: function (node, candidatesOutArray) { + node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + return node ? getResolvedSignature(node, candidatesOutArray) : undefined; + }, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, + isValidPropertyAccess: function (node, propertyName) { + node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedName); + return node ? isValidPropertyAccess(node, propertyName) : false; + }, + getSignatureFromDeclaration: function (declaration) { + declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + return declaration ? getSignatureFromDeclaration(declaration) : undefined; + }, + isImplementationOfOverload: function (node) { + node = ts.getParseTreeNode(node, ts.isFunctionLike); + return node ? isImplementationOfOverload(node) : undefined; + }, + getImmediateAliasedSymbol: function (symbol) { + ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.immediateTarget) { + var node = getDeclarationOfAliasSymbol(symbol); + ts.Debug.assert(!!node); + links.immediateTarget = getTargetOfAliasDeclaration(node, true); + } + return links.immediateTarget; + }, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, + getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { + node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; + }, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter, + isOptionalParameter: function (node) { + node = ts.getParseTreeNode(node, ts.isParameter); + return node ? isOptionalParameter(node) : false; + }, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); @@ -20249,11 +20928,9 @@ var ts; var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, undefined, 0, false, false); var enumNumberIndexInfo = createIndexInfo(stringType, true); + var jsObjectLiteralIndexInfo = createIndexInfo(anyType, false); var globals = ts.createMap(); var patternAmbientModules; - var getGlobalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var tryGetGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -20262,26 +20939,26 @@ var ts; var globalNumberType; var globalBooleanType; var globalRegExpType; + var globalThisType; var anyArrayType; var autoArrayType; var anyReadonlyArrayType; - var getGlobalTemplateStringsArrayType; - var getGlobalESSymbolType; - var getGlobalIterableType; - var getGlobalIteratorType; - var getGlobalIterableIteratorType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var jsxElementClassType; + var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolType; + var deferredGlobalTypedPropertyDescriptorType; + var deferredGlobalPromiseType; + var deferredGlobalPromiseConstructorSymbol; + var deferredGlobalPromiseConstructorLikeType; + var deferredGlobalIterableType; + var deferredGlobalIteratorType; + var deferredGlobalIterableIteratorType; + var deferredGlobalAsyncIterableType; + var deferredGlobalAsyncIteratorType; + var deferredGlobalAsyncIterableIteratorType; + var deferredGlobalTemplateStringsArrayType; + var deferredJsxElementClassType; + var deferredJsxElementType; + var deferredJsxStatelessElementType; var deferredNodes; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; @@ -20331,15 +21008,19 @@ var ts; "undefined": undefinedType }); var typeofType = createTypeofType(); - var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; + var _jsxElementPropertiesName; + var _hasComputedJsxElementPropertiesName = false; + var _jsxElementChildrenPropertyName; + var _hasComputedJsxElementChildrenPropertyName = false; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", ElementClass: "ElementClass", ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + ElementChildrenAttributeNameContainer: "ElementChildrenAttribute", Element: "Element", IntrinsicAttributes: "IntrinsicAttributes", IntrinsicClassAttributes: "IntrinsicClassAttributes" @@ -20355,7 +21036,7 @@ var ts; initializeTypeChecker(); return checker; function getJsxNamespace() { - if (_jsxNamespace === undefined) { + if (!_jsxNamespace) { _jsxNamespace = "React"; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); @@ -20385,6 +21066,9 @@ var ts; symbol.checkFlags = 0; return symbol; } + function isTransientSymbol(symbol) { + return (symbol.flags & 134217728) !== 0; + } function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2) @@ -20451,7 +21135,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { + (target.valueDeclaration.kind === 233 && source.valueDeclaration.kind !== 233))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -20468,7 +21152,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 || source.flags & 2 @@ -20554,7 +21238,7 @@ var ts; return symbol.flags & 134217728 ? symbol.checkFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 265 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -20591,77 +21275,76 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrInstanceProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 175) { - var errorBindingElement = ts.getAncestor(usage, 175); + if (declaration.kind === 176) { + var errorBindingElement = ts.getAncestor(usage, 176); if (errorBindingElement) { - return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 226), usage); } - else if (declaration.kind === 225) { + else if (declaration.kind === 226) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } + if (usage.parent.kind === 246) { + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); - var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); - return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); + return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 207: - case 213: - case 215: + case 208: + case 214: + case 216: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 214: case 215: + case 216: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { - var current = usage; - while (current) { + function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { + return !!ts.findAncestor(usage, function (current) { if (current === container) { - return false; + return "quit"; } if (ts.isFunctionLike(current)) { return true; } - var initializerOfInstanceProperty = current.parent && - current.parent.kind === 148 && - (ts.getModifierFlags(current.parent) & 32) === 0 && + var initializerOfProperty = current.parent && + current.parent.kind === 149 && current.parent.initializer === current; - if (initializerOfInstanceProperty) { - return !isDeclarationInstanceProperty; + if (initializerOfProperty) { + if (ts.getModifierFlags(current.parent) & 32) { + if (declaration.kind === 151) { + return true; + } + } + else { + var isDeclarationInstanceProperty = declaration.kind === 149 && !(ts.getModifierFlags(declaration) & 32); + if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { + return true; + } + } } - current = current.parent; - } - return false; - } - function getAncestorBindingPattern(node) { - while (node) { - if (ts.isBindingPattern(node)) { - return node; - } - node = node.parent; - } - return undefined; + }); } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { @@ -20676,18 +21359,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 & 793064 && lastLocation.kind !== 282) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 283) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 145 || - lastLocation.kind === 144 + lastLocation.kind === 146 || + lastLocation.kind === 145 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 145 || + lastLocation.kind === 146 || (lastLocation === location.type && - result.valueDeclaration.kind === 145); + result.valueDeclaration.kind === 146); } } if (useResult) { @@ -20699,13 +21382,13 @@ var ts; } } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 232: + case 233: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 264 || ts.isAmbientModule(location)) { + if (location.kind === 265 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -20716,7 +21399,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 8388608 && - ts.getDeclarationOfKind(moduleExport, 245)) { + ts.getDeclarationOfKind(moduleExport, 246)) { break; } } @@ -20724,13 +21407,13 @@ var ts; break loop; } break; - case 231: + case 232: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 149: case 148: - case 147: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -20740,9 +21423,9 @@ var ts; } } break; - case 228: - case 198: case 229: + case 199: + case 230: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -20754,7 +21437,7 @@ var ts; } break loop; } - if (location.kind === 198 && meaning & 32) { + if (location.kind === 199 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -20762,28 +21445,28 @@ var ts; } } break; - case 143: + case 144: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 229) { + if (ts.isClassLike(grandparent) || grandparent.kind === 230) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 227: - case 186: + case 154: + case 228: + case 187: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 185: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -20796,8 +21479,8 @@ var ts; } } break; - case 146: - if (location.parent && location.parent.kind === 145) { + case 147: + if (location.parent && location.parent.kind === 146) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -20820,7 +21503,8 @@ var ts; !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); } } @@ -20832,15 +21516,16 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2) { + if (meaning & 2 || + ((meaning & 32 || meaning & 384) && (meaning & 107455) === 107455)) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2) { + if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 235) { + if (decls && decls.length === 1 && decls[0].kind === 236) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -20850,14 +21535,14 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 144 && decl.parent === container) { + if (decl.kind === 145 && decl.parent === container) { return true; } } return false; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 71 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -20895,10 +21580,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 70: - case 178: + case 71: + case 179: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 200: + case 201: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -20925,46 +21610,60 @@ var ts; } return false; } - function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2) !== 0); - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { + if (meaning & (107455 & ~1024 & ~793064)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, name); + return true; + } } - } - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { + else if (meaning & (793064 & ~1024 & ~107455)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, name); return true; } } return false; } + function checkResolvedBlockScopedVariable(result, errorLocation) { + ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 232) ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (result.flags & 2) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 32) { + error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 384) { + error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + } + function isSameScopeDescendentOf(initial, parent, stopAt) { + return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } - while (node && node.kind !== 237) { - node = node.parent; - } - return node; + return ts.findAncestor(node, function (n) { return n.kind === 238; }); } } function getDeclarationOfAliasSymbol(symbol) { return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 247) { + function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { + if (node.moduleReference.kind === 248) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); } - function getTargetOfImportClause(node) { + function getTargetOfImportClause(node, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -20975,20 +21674,20 @@ var ts; var exportValue = moduleSymbol.exports.get("export="); exportDefaultSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") - : resolveSymbol(moduleSymbol.exports.get("default")); + : resolveSymbol(moduleSymbol.exports.get("default"), dontResolveAlias); } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } return exportDefaultSymbol; } } - function getTargetOfNamespaceImport(node) { + function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); } function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { if (valueSymbol.flags & (793064 | 1920)) { @@ -21005,12 +21704,9 @@ var ts; result.exports = valueSymbol.exports; return result; } - function getExportOfModule(symbol, name) { + function getExportOfModule(symbol, name, dontResolveAlias) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol).get(name); - if (exportedSymbol) { - return resolveSymbol(exportedSymbol); - } + return resolveSymbol(getExportsOfSymbol(symbol).get(name), dontResolveAlias); } } function getPropertyOfVariable(symbol, name) { @@ -21021,9 +21717,9 @@ var ts; } } } - function getExternalModuleMember(node, specifier) { + function getExternalModuleMember(node, specifier, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; if (name.text) { @@ -21037,10 +21733,10 @@ var ts; else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } - symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name.text); + symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); + var symbolFromModule = getExportOfModule(targetSymbol, name.text, dontResolveAlias); if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { - symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : @@ -21052,40 +21748,41 @@ var ts; } } } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); + function getTargetOfImportSpecifier(node, dontResolveAlias) { + return getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); } - function getTargetOfNamespaceExportDeclaration(node) { - return resolveExternalModuleSymbol(node.parent.symbol); + function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) { + return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); } - function getTargetOfExportSpecifier(node) { + function getTargetOfExportSpecifier(node, dontResolveAlias) { return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 | 793064 | 1920); + getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : + resolveEntityName(node.propertyName || node.name, 107455 | 793064 | 1920, false, dontResolveAlias); } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793064 | 1920); + function getTargetOfExportAssignment(node, dontResolveAlias) { + return resolveEntityName(node.expression, 107455 | 793064 | 1920, false, dontResolveAlias); } - function getTargetOfAliasDeclaration(node) { + function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { switch (node.kind) { - case 236: - return getTargetOfImportEqualsDeclaration(node); - case 238: - return getTargetOfImportClause(node); + case 237: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); case 239: - return getTargetOfNamespaceImport(node); - case 241: - return getTargetOfImportSpecifier(node); - case 245: - return getTargetOfExportSpecifier(node); + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 240: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); case 242: - return getTargetOfExportAssignment(node); - case 235: - return getTargetOfNamespaceExportDeclaration(node); + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 246: + return getTargetOfExportSpecifier(node, dontRecursivelyResolve); + case 243: + return getTargetOfExportAssignment(node, dontRecursivelyResolve); + case 236: + return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); } } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793064 | 1920)) ? resolveAlias(symbol) : symbol; + function resolveSymbol(symbol, dontResolveAlias) { + var shouldResolve = !dontResolveAlias && symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793064 | 1920)); + return shouldResolve ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); @@ -21124,10 +21821,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 242) { + if (node.kind === 243) { checkExpressionCached(node.expression); } - else if (node.kind === 245) { + else if (node.kind === 246) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -21136,14 +21833,14 @@ var ts; } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 71 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 142) { + if (entityName.kind === 71 || entityName.parent.kind === 143) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 236); + ts.Debug.assert(entityName.parent.kind === 237); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -21155,16 +21852,26 @@ var ts; return undefined; } var symbol; - if (name.kind === 70) { + if (name.kind === 71) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 142 || name.kind === 178) { - var left = name.kind === 142 ? name.left : name.expression; - var right = name.kind === 142 ? name.right : name.name; + else if (name.kind === 143 || name.kind === 179) { + var left = void 0; + if (name.kind === 143) { + left = name.left; + } + else if (name.kind === 179 && + (name.expression.kind === 185 || ts.isEntityNameExpression(name.expression))) { + left = name.expression; + } + else { + return undefined; + } + var right = name.kind === 143 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -21180,6 +21887,11 @@ var ts; return undefined; } } + else if (name.kind === 185) { + return ts.isEntityNameExpression(name.expression) ? + resolveEntityName(name.expression, meaning, ignoreErrors, dontResolveAlias, location) : + undefined; + } else { ts.Debug.fail("Unknown entity name kind."); } @@ -21191,7 +21903,7 @@ var ts; } function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReferenceExpression.kind !== 9) { + if (moduleReferenceExpression.kind !== 9 && moduleReferenceExpression.kind !== 13) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -21231,8 +21943,10 @@ var ts; var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } - else if (compilerOptions.noImplicitAny && moduleNotFoundError) { - error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + else if (noImplicitAny && moduleNotFoundError) { + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } return undefined; } @@ -21253,12 +21967,12 @@ var ts; } return undefined; } - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; + function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || moduleSymbol; } - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 | 3))) { + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression, dontResolveAlias) { + var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); + if (!dontResolveAlias && symbol && !(symbol.flags & (1536 | 3))) { error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } @@ -21372,7 +22086,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 === 151 && ts.nodeIsPresent(member.body)) { + if (member.kind === 152 && ts.nodeIsPresent(member.body)) { return member; } } @@ -21445,11 +22159,11 @@ var ts; } } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232: + case 233: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -21493,7 +22207,7 @@ var ts; return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -21525,7 +22239,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -21539,10 +22253,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 148: - case 150: - case 152: + case 149: + case 151: case 153: + case 154: continue; default: return false; @@ -21590,15 +22304,12 @@ var ts; } return { accessibility: 0 }; function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } + var node = ts.findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 265 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -21632,11 +22343,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 162 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 142 || entityName.kind === 178 || - entityName.parent.kind === 236) { + else if (entityName.kind === 143 || entityName.kind === 179 || + entityName.parent.kind === 237) { meaning = 1920; } else { @@ -21684,6 +22395,483 @@ var ts; } return result; } + function createNodeBuilder() { + var context; + return { + typeToTypeNode: function (type, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = typeToTypeNodeHelper(type); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + } + }; + function createNodeBuilderContext(enclosingDeclaration, flags) { + return { + enclosingDeclaration: enclosingDeclaration, + flags: flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + function typeToTypeNodeHelper(type) { + if (!type) { + context.encounteredError = true; + return undefined; + } + if (type.flags & 1) { + return ts.createKeywordTypeNode(119); + } + if (type.flags & 2) { + return ts.createKeywordTypeNode(136); + } + if (type.flags & 4) { + return ts.createKeywordTypeNode(133); + } + if (type.flags & 8) { + return ts.createKeywordTypeNode(122); + } + if (type.flags & 16) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & (32)) { + return ts.createLiteralTypeNode((ts.createLiteral(type.text))); + } + if (type.flags & (64)) { + return ts.createLiteralTypeNode((ts.createNumericLiteral(type.text))); + } + if (type.flags & 128) { + return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); + } + if (type.flags & 256) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & 1024) { + return ts.createKeywordTypeNode(105); + } + if (type.flags & 2048) { + return ts.createKeywordTypeNode(139); + } + if (type.flags & 4096) { + return ts.createKeywordTypeNode(95); + } + if (type.flags & 8192) { + return ts.createKeywordTypeNode(130); + } + if (type.flags & 512) { + return ts.createKeywordTypeNode(137); + } + if (type.flags & 16777216) { + return ts.createKeywordTypeNode(134); + } + if (type.flags & 16384 && type.isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return ts.createThis(); + } + var objectFlags = getObjectFlags(type); + if (objectFlags & 4) { + ts.Debug.assert(!!(type.flags & 32768)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & 3) { + ts.Debug.assert(!!(type.flags & 32768)); + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & 16384) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (context.checkAlias && type.aliasSymbol) { + var name = symbolToName(type.aliasSymbol, false); + var typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return ts.createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + if (type.flags & 65536) { + var formattedUnionTypes = formatUnionTypes(type.types); + var unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return ts.createUnionOrIntersectionTypeNode(166, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } + return undefined; + } + } + if (type.flags & 131072) { + return ts.createUnionOrIntersectionTypeNode(167, mapToTypeNodeArray(type.types)); + } + if (objectFlags & (16 | 32)) { + ts.Debug.assert(!!(type.flags & 32768)); + return createAnonymousTypeNode(type); + } + if (type.flags & 262144) { + var indexedType = type.type; + var indexTypeNode = typeToTypeNodeHelper(indexedType); + return ts.createTypeOperatorNode(indexTypeNode); + } + if (type.flags & 524288) { + var objectTypeNode = typeToTypeNodeHelper(type.objectType); + var indexTypeNode = typeToTypeNodeHelper(type.indexType); + return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + ts.Debug.fail("Should be unreachable."); + function mapToTypeNodeArray(types) { + var result = []; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type_1 = types_1[_i]; + var typeNode = typeToTypeNodeHelper(type_1); + if (typeNode) { + result.push(typeNode); + } + } + return result; + } + function createMappedTypeNodeFromType(type) { + ts.Debug.assert(!!(type.flags & 32768)); + var typeParameter = getTypeParameterFromMappedType(type); + var typeParameterNode = typeParameterToDeclaration(typeParameter); + var templateType = getTemplateTypeFromMappedType(type); + var templateTypeNode = typeToTypeNodeHelper(templateType); + var readonlyToken = type.declaration && type.declaration.readonlyToken ? ts.createToken(131) : undefined; + var questionToken = type.declaration && type.declaration.questionToken ? ts.createToken(55) : undefined; + return ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + function createAnonymousTypeNode(type) { + var symbol = type.symbol; + if (symbol) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromSymbol(symbol); + } + else if (ts.contains(context.symbolStack, symbol)) { + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + var entityName = symbolToName(typeAlias, false); + return ts.createTypeReferenceNode(entityName, undefined); + } + else { + return ts.createKeywordTypeNode(119); + } + } + else { + if (!context.symbolStack) { + context.symbolStack = []; + } + context.symbolStack.push(symbol); + var result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + return createTypeNodeFromObjectType(type); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 && + ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 265 || declaration.parent.kind === 234; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + return ts.contains(context.symbolStack, symbol); + } + } + } + function createTypeNodeFromObjectType(type) { + if (type.objectFlags & 32) { + if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { + return createMappedTypeNodeFromType(type); + } + } + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return ts.createTypeLiteralNode(undefined); + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + var signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 160); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + var signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 161); + } + } + var saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + var members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return ts.createTypeLiteralNode(members); + } + function createTypeQueryNodeFromSymbol(symbol) { + var entityName = symbolToName(symbol, false); + return ts.createTypeQueryNode(entityName); + } + function typeReferenceToTypeNode(type) { + var typeArguments = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + var elementType = typeToTypeNodeHelper(typeArguments[0]); + return ts.createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & 8) { + if (typeArguments.length > 0) { + var tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return ts.createTupleTypeNode(tupleConstituentNodes); + } + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; + } + return undefined; + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + var qualifiedName = undefined; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + var start = i; + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + var qualifiedNamePart = symbolToName(parent, true); + if (!qualifiedName) { + qualifiedName = ts.createQualifiedName(qualifiedNamePart, undefined); + } + else { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = ts.createQualifiedName(qualifiedName, undefined); + } + } + } + } + var entityName = undefined; + var nameIdentifier = symbolToName(type.symbol, true); + if (qualifiedName) { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + var typeArgumentNodes = ts.some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return ts.createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + function createTypeNodesFromResolvedType(resolvedType) { + var typeElements = []; + for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 155)); + } + for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 156)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1)); + } + var properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + for (var _d = 0, properties_2 = properties; _d < properties_2.length; _d++) { + var propertySymbol = properties_2[_d]; + var propertyType = getTypeOfSymbol(propertySymbol); + var oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0]; + if (!oldDeclaration) { + return; + } + var propertyName = oldDeclaration.name; + var optionalToken = propertySymbol.flags & 67108864 ? ts.createToken(55) : undefined; + if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length) { + var signatures = getSignaturesOfType(propertyType, 0); + for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { + var signature = signatures_1[_e]; + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 150); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : ts.createKeywordTypeNode(119); + typeElements.push(ts.createPropertySignature(propertyName, optionalToken, propertyTypeNode, undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind) { + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 136 : 133); + var name = ts.getNameFromIndexInfo(indexInfo); + var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); + var typeNode = typeToTypeNodeHelper(indexInfo.type); + return ts.createIndexSignatureDeclaration(undefined, indexInfo.isReadonly ? [ts.createToken(131)] : undefined, [indexingParameter], typeNode); + } + function signatureToSignatureDeclarationHelper(signature, kind) { + var typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter); }); + var returnTypeNode; + if (signature.typePredicate) { + var typePredicate = signature.typePredicate; + var parameterName = typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(); + var typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + } + else { + var returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } + var returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== 119 ? returnTypeNode : undefined; + return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + } + function typeParameterToDeclaration(type) { + var constraint = getConstraintFromTypeParameter(type); + var constraintNode = constraint && typeToTypeNodeHelper(constraint); + var defaultParameter = getDefaultFromTypeParameter(type); + var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + var name = symbolToName(type.symbol, true); + return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); + } + function symbolToParameterDeclaration(parameterSymbol) { + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 146); + var parameterType = getTypeOfSymbol(parameterSymbol); + var parameterTypeNode = typeToTypeNodeHelper(parameterType); + var parameterNode = ts.createParameter(parameterDeclaration.decorators, parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && ts.createToken(24), ts.getSynthesizedClone(parameterDeclaration.name), parameterDeclaration.questionToken && ts.createToken(55), parameterTypeNode, parameterDeclaration.initializer); + return parameterNode; + } + function symbolToName(symbol, expectsIdentifier) { + var chain; + var isTypeParameter = symbol.flags & 262144; + if (!isTypeParameter && context.enclosingDeclaration) { + chain = getSymbolChain(symbol, 0, true); + ts.Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & ts.NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); + function createEntityNameFromSymbolChain(chain, index) { + ts.Debug.assert(chain && 0 <= index && index < chain.length); + var symbol = chain[index]; + var typeParameterString = ""; + if (index > 0) { + var parentSymbol = chain[index - 1]; + var typeParameters = void 0; + if (getCheckFlags(symbol) & 1) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + var targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (32 | 64 | 524288)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if (typeParameters && typeParameters.length > 0) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } + var writer = ts.getSingleLineStringWriter(); + var displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); + typeParameterString = writer.string(); + ts.releaseStringWriter(writer); + } + } + var symbolName = getNameOfSymbol(symbol); + var symbolNameWithTypeParameters = typeParameterString.length > 0 ? symbolName + "<" + typeParameterString + ">" : symbolName; + var identifier = ts.createIdentifier(symbolNameWithTypeParameters); + return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + function getSymbolChain(symbol, meaning, endOfChain) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, false); + var parentSymbol; + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); + if (parentChain) { + parentSymbol = parent; + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + if (endOfChain || + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + !(symbol.flags & (2048 | 4096))) { + return [symbol]; + } + } + function getNameOfSymbol(symbol) { + var declaration = ts.firstOrUndefined(symbol.declarations); + if (declaration) { + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === 226) { + return ts.declarationNameToString(declaration.parent.name); + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case 199: + return "(Anonymous class)"; + case 186: + case 187: + return "(Anonymous function)"; + } + } + return symbol.name; + } + } + } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -21727,11 +22915,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 167) { - node = node.parent; - } - if (node.kind === 230) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 168; }); + if (node.kind === 231) { return getSymbolOfNode(node); } } @@ -21739,7 +22924,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 233 && + node.parent.kind === 234 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -21751,11 +22936,14 @@ var ts; if (declaration.name) { return ts.declarationNameToString(declaration.name); } + if (declaration.parent && declaration.parent.kind === 226) { + return ts.declarationNameToString(declaration.parent.name); + } switch (declaration.kind) { - case 198: + case 199: return "(Anonymous class)"; - case 185: case 186: + case 187: return "(Anonymous function)"; } } @@ -21770,17 +22958,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 20); + writePunctuation(writer, 21); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 21); + writePunctuation(writer, 22); } else { - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeSymbol(symbolName, symbol); } } @@ -21856,7 +23044,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 22); + writePunctuation(writer, 23); appendSymbolNameOnly(type.symbol, writer); } else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { @@ -21883,28 +23071,28 @@ var ts; } else if (type.flags & 524288) { writeType(type.objectType, 64); - writePunctuation(writer, 20); - writeType(type.indexType, 0); writePunctuation(writer, 21); + writeType(type.indexType, 0); + writePunctuation(writer, 22); } else { - writePunctuation(writer, 16); - writeSpace(writer); - writePunctuation(writer, 23); - writeSpace(writer); writePunctuation(writer, 17); + writeSpace(writer); + writePunctuation(writer, 24); + writeSpace(writer); + writePunctuation(writer, 18); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 25) { + if (delimiter !== 26) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 25 ? 0 : 64); + writeType(types[i], delimiter === 26 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -21912,44 +23100,44 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 20); writePunctuation(writer, 21); + writePunctuation(writer, 22); } else if (type.target.objectFlags & 8) { - writePunctuation(writer, 20); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); writePunctuation(writer, 21); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 26); + writePunctuation(writer, 22); } else { var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent, typeArguments, start, i, flags); - writePunctuation(writer, 22); + writePunctuation(writer, 23); } } } @@ -21959,16 +23147,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } if (type.flags & 65536) { - writeTypeList(formatUnionTypes(type.types), 48); + writeTypeList(formatUnionTypes(type.types), 49); } else { - writeTypeList(type.types, 47); + writeTypeList(type.types, 48); } if (flags & 64) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } } function writeAnonymousType(type, flags) { @@ -21987,7 +23175,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 118); + writeKeyword(writer, 119); } } else { @@ -22008,7 +23196,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 264 || declaration.parent.kind === 233; + return declaration.parent.kind === 265 || declaration.parent.kind === 234; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -22017,18 +23205,18 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 102); + writeKeyword(writer, 103); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 67108864) { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -22052,55 +23240,55 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 16); writePunctuation(writer, 17); + writePunctuation(writer, 18); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } - writeKeyword(writer, 93); + writeKeyword(writer, 94); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 16); + writePunctuation(writer, 17); writer.writeLine(); writer.increaseIndent(); writeObjectLiteralType(resolved); writer.decreaseIndent(); - writePunctuation(writer, 17); + writePunctuation(writer, 18); inObjectTypeLiteral = saveInObjectTypeLiteral; } function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); @@ -22110,49 +23298,49 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { - var signature = signatures_1[_f]; + for (var _f = 0, signatures_2 = signatures; _f < signatures_2.length; _f++) { + var signature = signatures_2[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } } function writeMappedType(type) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); writer.writeLine(); writer.increaseIndent(); if (type.declaration.readonlyToken) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); writeSpace(writer); - writeKeyword(writer, 91); + writeKeyword(writer, 92); writeSpace(writer); writeType(getConstraintTypeFromMappedType(type), 0); - writePunctuation(writer, 21); + writePunctuation(writer, 22); if (type.declaration.questionToken) { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); writeType(getTemplateTypeFromMappedType(type), 0); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); writer.decreaseIndent(); - writePunctuation(writer, 17); + writePunctuation(writer, 18); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -22166,64 +23354,64 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 84); + writeKeyword(writer, 85); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } var defaultType = getDefaultFromTypeParameter(tp); if (defaultType) { writeSpace(writer); - writePunctuation(writer, 57); + writePunctuation(writer, 58); writeSpace(writer); buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 23); + if (parameterNode ? ts.isRestParameter(parameterNode) : isTransientSymbol(p) && p.isRestParameter) { + writePunctuation(writer, 24); } - if (ts.isBindingPattern(parameterNode.name)) { + if (parameterNode && ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); } else { appendSymbolNameOnly(p, writer); } - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 54); + if (parameterNode && isOptionalParameter(parameterNode)) { + writePunctuation(writer, 55); } - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); var type = getTypeOfSymbol(p); - if (isRequiredInitializedParameter(parameterNode)) { + if (parameterNode && isRequiredInitializedParameter(parameterNode)) { type = includeFalsyTypes(type, 2048); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 173) { - writePunctuation(writer, 16); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 174) { writePunctuation(writer, 17); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 18); } - else if (bindingPattern.kind === 174) { - writePunctuation(writer, 20); + else if (bindingPattern.kind === 175) { + writePunctuation(writer, 21); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); } - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 175); + ts.Debug.assert(bindingElement.kind === 176); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -22231,22 +23419,22 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); } action(list[i]); @@ -22254,42 +23442,42 @@ var ts; } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); flags = 0; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 98); + writeKeyword(writer, 99); } writeSpace(writer); - writeKeyword(writer, 125); + writeKeyword(writer, 126); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } @@ -22300,10 +23488,10 @@ var ts; } if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 35); + writePunctuation(writer, 36); } else { - writePunctuation(writer, 55); + writePunctuation(writer, 56); } writeSpace(writer); if (signature.typePredicate) { @@ -22315,7 +23503,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 93); + writeKeyword(writer, 94); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -22330,26 +23518,26 @@ var ts; function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); switch (kind) { case 1: - writeKeyword(writer, 132); + writeKeyword(writer, 133); break; case 0: - writeKeyword(writer, 135); + writeKeyword(writer, 136); break; } - writePunctuation(writer, 21); - writePunctuation(writer, 55); + writePunctuation(writer, 22); + writePunctuation(writer, 56); writeSpace(writer); buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } @@ -22378,64 +23566,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 175: + case 176: return isDeclarationVisible(node.parent.parent); - case 225: + case 226: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 232: - case 228: + case 233: case 229: case 230: - case 227: case 231: - case 236: + case 228: + case 232: + case 237: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + !(node.kind !== 237 && parent.kind !== 265 && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 148: - case 147: - case 152: - case 153: - case 150: case 149: + case 148: + case 153: + case 154: + case 151: + case 150: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 151: - case 155: - case 154: + case 152: case 156: - case 145: - case 233: - case 159: + case 155: + case 157: + case 146: + case 234: case 160: - case 162: - case 158: + case 161: case 163: + case 159: case 164: case 165: case 166: case 167: + case 168: return isDeclarationVisible(node.parent); - case 238: case 239: - case 241: - return false; - case 144: - case 264: - case 235: - return true; + case 240: case 242: return false; + case 145: + case 265: + case 236: + return true; + case 243: + return false; default: return false; } @@ -22443,10 +23631,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 242) { + if (node.parent && node.parent.kind === 243) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 245) { + else if (node.parent.kind === 246) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -22478,8 +23666,8 @@ var ts; function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -22521,21 +23709,20 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - while (node) { + node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 225: case 226: + case 227: + case 242: case 241: case 240: case 239: - case 238: - node = node.parent; - break; + return false; default: - return node.parent; + return true; } - } + }); + return node && node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); @@ -22553,7 +23740,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 144 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -22565,8 +23752,8 @@ var ts; } var members = ts.createMap(); var names = ts.createMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var name = properties_3[_i]; names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { @@ -22595,7 +23782,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 173) { + if (pattern.kind === 174) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -22629,7 +23816,7 @@ var ts; } } else { - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, false, false); if (declaration.dotDotDotToken) { type = createArrayType(elementType); } @@ -22665,23 +23852,15 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 95 || expr.kind === 71 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 176 && expr.elements.length === 0; + return expr.kind === 177 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } - function removeOptionalityFromAnnotation(annotatedType, declaration) { - var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 145 && - declaration.initializer && - getFalsyFlags(annotatedType) & 2048 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { var type = getTypeForDeclarationFromJSDocComment(declaration); @@ -22689,22 +23868,23 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 214) { + if (declaration.parent.parent.kind === 215) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 215) { - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + if (declaration.parent.parent.kind === 216) { + var forOfStatement = declaration.parent.parent; + return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + var declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && + if ((noImplicitAny || declaration.flags & 65536) && + declaration.kind === 226 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -22713,10 +23893,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 145) { + if (declaration.kind === 146) { var func = declaration.parent; - if (func.kind === 153 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); + if (func.kind === 154 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 153); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -22745,7 +23925,7 @@ var ts; if (ts.isJsxAttribute(declaration)) { return trueType; } - if (declaration.kind === 261) { + if (declaration.kind === 262) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -22753,20 +23933,36 @@ var ts; } return undefined; } - function getTypeForJSSpecialPropertyDeclaration(declaration) { - var expression = declaration.kind === 193 ? declaration : - declaration.kind === 178 ? ts.getAncestor(declaration, 193) : - undefined; - if (!expression) { - return unknownType; - } - if (expression.flags & 65536) { - var type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol) { + var types = []; + var definedInConstructor = false; + var definedInMethod = false; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = declaration.kind === 194 ? declaration : + declaration.kind === 179 ? ts.getAncestor(declaration, 194) : + undefined; + if (!expression) { + return unknownType; } + if (ts.isPropertyAccessExpression(expression.left) && expression.left.expression.kind === 99) { + if (ts.getThisContainer(expression, false).kind === 152) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, true), definedInMethod && !definedInConstructor)); } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { @@ -22775,7 +23971,7 @@ var ts; if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -22825,7 +24021,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 173 + return pattern.kind === 174 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -22835,13 +24031,13 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 260) { + if (declaration.kind === 261) { return type; } return getWidenedType(type); } type = declaration.dotDotDotToken ? anyArrayType : anyType; - if (reportErrors && compilerOptions.noImplicitAny) { + if (reportErrors && noImplicitAny) { if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } @@ -22850,7 +24046,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 145 ? root.parent : root; + var memberDeclaration = root.kind === 146 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -22863,19 +24059,19 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 242) { + if (declaration.kind === 243) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 291 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 193 || - declaration.kind === 178 && declaration.parent.kind === 193) { - type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); + if (declaration.kind === 194 || + declaration.kind === 179 && declaration.parent.kind === 194) { + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -22889,7 +24085,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 152) { + if (accessor.kind === 153) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -22909,8 +24105,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 152); - var setter = ts.getDeclarationOfKind(symbol, 153); + var getter = ts.getDeclarationOfKind(symbol, 153); + var setter = ts.getDeclarationOfKind(symbol, 154); if (getter && getter.flags & 65536) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -22935,7 +24131,7 @@ var ts; type = getReturnTypeFromBody(getter); } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { if (setter) { error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } @@ -22950,8 +24146,8 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 152); + if (noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 153); 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)); } } @@ -23002,14 +24198,22 @@ var ts; function getTypeOfInstantiatedSymbol(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0)) { - return unknownType; + if (symbolInstantiationDepth === 100) { + error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); + links.type = unknownType; } - var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - if (!popTypeResolution()) { - type = reportCircularityError(symbol); + else { + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + symbolInstantiationDepth++; + var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + symbolInstantiationDepth--; + if (!popTypeResolution()) { + type = reportCircularityError(symbol); + } + links.type = type; } - links.type = type; } return links.type; } @@ -23018,7 +24222,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return unknownType; } - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -23044,6 +24248,12 @@ var ts; } return unknownType; } + function isReferenceToType(type, target) { + return type !== undefined + && target !== undefined + && (getObjectFlags(type) & 4) !== 0 + && type.target === target; + } function getTargetType(type) { return getObjectFlags(type) & 4 ? type.target : type; } @@ -23078,9 +24288,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 228 || node.kind === 198 || - node.kind === 227 || node.kind === 185 || - node.kind === 150 || node.kind === 186) { + if (node.kind === 229 || node.kind === 199 || + node.kind === 228 || node.kind === 186 || + node.kind === 151 || node.kind === 187) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -23089,15 +24299,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230); 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 === 229 || node.kind === 228 || - node.kind === 198 || node.kind === 230) { + if (node.kind === 230 || node.kind === 229 || + node.kind === 199 || node.kind === 231) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -23123,19 +24333,20 @@ var ts; } if (type.flags & 540672) { var constraint = getBaseConstraintOfType(type); - return isValidBaseType(constraint) && isMixinConstructorType(constraint); + return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { + function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); + var isJavaScript = ts.isInJavaScriptFile(location); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); @@ -23159,7 +24370,7 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = unknownType; } - if (baseConstructorType !== unknownType && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); return type.resolvedBaseConstructorType = unknownType; } @@ -23189,7 +24400,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (32768 | 131072))) { + if (!(baseConstructorType.flags & (32768 | 131072 | 1))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -23199,8 +24410,11 @@ var ts; areAllOuterTypeParametersApplied(originalBaseType)) { baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } + else if (baseConstructorType.flags & 1) { + baseType = baseConstructorType; + } else { - var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -23242,14 +24456,14 @@ var ts; return true; } function isValidBaseType(type) { - return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + return type.flags & (32768 | 16777216 | 1) && !isGenericMappedType(type) || type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 230 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -23278,7 +24492,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { if (declaration.flags & 64) { return false; } @@ -23328,7 +24542,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 289); + var declaration = ts.getDeclarationOfKind(symbol, 290); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -23339,7 +24553,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 230); + declaration = ts.getDeclarationOfKind(symbol, 231); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -23364,14 +24578,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 191 && expr.operator === 37 && + expr.kind === 192 && expr.operator === 38 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports.get(expr.text); + expr.kind === 71 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231) { + if (declaration.kind === 232) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -23399,7 +24613,7 @@ var ts; var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231) { + if (declaration.kind === 232) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -23482,21 +24696,21 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: case 133: - case 104: - case 138: - case 94: - case 129: - case 172: + case 122: + case 137: + case 134: + case 105: + case 139: + case 95: + case 130: + case 173: return true; - case 163: + case 164: return isIndependentType(node.elementType); - case 158: + case 159: return isIndependentTypeReference(node); } return false; @@ -23505,7 +24719,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 152 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -23521,12 +24735,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 148: - case 147: - return isIndependentVariableLikeDeclaration(declaration); - case 150: case 149: + case 148: + return isIndependentVariableLikeDeclaration(declaration); case 151: + case 150: + case 152: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -23616,7 +24830,11 @@ var ts; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); + if (!stringIndexInfo) { + stringIndexInfo = instantiatedBaseType === anyType ? + createIndexInfo(anyType, false) : + getIndexInfoOfType(instantiatedBaseType, 0); + } numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } @@ -23655,6 +24873,7 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); + var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = ts.length(typeArguments); var result = []; @@ -23662,8 +24881,8 @@ var ts; var baseSig = baseSignatures_1[_i]; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -23732,8 +24951,8 @@ var ts; 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]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type = types_2[_i]; var indexInfo = getIndexInfoOfType(type, kind); if (!indexInfo) { return undefined; @@ -23821,7 +25040,8 @@ var ts; else { var members = emptySymbols; var constructSignatures = emptyArray; - if (symbol.flags & 1952) { + var stringIndexInfo = undefined; + if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32) { @@ -23835,9 +25055,12 @@ var ts; members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } + else if (baseConstructorType === anyType) { + stringIndexInfo = createIndexInfo(anyType, false); + } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } @@ -23853,7 +25076,7 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 169) { + if (type.declaration.typeParameter.constraint.kind === 170) { for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var propertySymbol = _a[_i]; addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); @@ -23877,10 +25100,10 @@ var ts; var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 8 : 0; prop.type = propType; if (propertySymbol) { - prop.mappedTypeOrigin = propertySymbol; + prop.syntheticOrigin = propertySymbol; } members.set(propName, prop); } @@ -23906,7 +25129,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 169) { + if (constraintDeclaration.kind === 170) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { @@ -23994,14 +25217,29 @@ var ts; getPropertiesOfObjectType(type); } function getConstraintOfType(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : + type.flags & 524288 ? getConstraintOfIndexedAccess(type) : + getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } + function getConstraintOfIndexedAccess(type) { + var baseObjectType = getBaseConstraintOfType(type.objectType); + var baseIndexType = getBaseConstraintOfType(type.indexType); + return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; + } function getBaseConstraintOfType(type) { - var constraint = getResolvedBaseConstraint(type); - return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + if (type.flags & (540672 | 196608)) { + var constraint = getResolvedBaseConstraint(type); + if (constraint !== noConstraintType && constraint !== circularConstraintType) { + return constraint; + } + } + else if (type.flags & 262144) { + return stringType; + } + return undefined; } function hasNonCircularBaseConstraint(type) { return getResolvedBaseConstraint(type) !== circularConstraintType; @@ -24034,9 +25272,9 @@ var ts; if (t.flags & 196608) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_1 = types_2[_i]; - var baseType = getBaseConstraint(type_1); + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; + var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); } @@ -24079,7 +25317,7 @@ var ts; t.flags & 262178 ? globalStringType : t.flags & 340 ? globalNumberType : t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 512 ? getGlobalESSymbolType(languageVersion >= 2) : t.flags & 16777216 ? emptyObjectType : t; } @@ -24089,9 +25327,10 @@ var ts; var isUnion = containingType.flags & 65536; var excludeModifiers = isUnion ? 24 : 0; var commonFlags = isUnion ? 0 : 67108864; - var checkFlags = 2; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + var syntheticFlag = 4; + var checkFlags = 0; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); @@ -24104,21 +25343,24 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | - (!(modifiers & 24) ? 32 : 0) | - (modifiers & 16 ? 64 : 0) | - (modifiers & 8 ? 128 : 0) | - (modifiers & 32 ? 256 : 0); + checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | + (!(modifiers & 24) ? 64 : 0) | + (modifiers & 16 ? 128 : 0) | + (modifiers & 8 ? 256 : 0) | + (modifiers & 32 ? 512 : 0); + if (!isMethodLike(prop)) { + syntheticFlag = 2; + } } else if (isUnion) { - checkFlags |= 8; + checkFlags |= 16; } } } if (!props) { return undefined; } - if (props.length === 1 && !(checkFlags & 8)) { + if (props.length === 1 && !(checkFlags & 16)) { return props[0]; } var propTypes = []; @@ -24134,12 +25376,12 @@ var ts; commonType = type; } else if (type !== commonType) { - checkFlags |= 16; + checkFlags |= 32; } propTypes.push(type); } var result = createSymbol(4 | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -24158,7 +25400,7 @@ var ts; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(getCheckFlags(property) & 8) ? property : undefined; + return property && !(getCheckFlags(property) & 16) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); @@ -24252,7 +25494,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 277) { + if (node.type && node.type.kind === 278) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -24263,7 +25505,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 277; + return paramTag.typeExpression.type.kind === 278; } } } @@ -24296,7 +25538,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 70) { + if (node.parameterName.kind === 71) { var parameterName = node.parameterName; return { kind: 1, @@ -24323,21 +25565,22 @@ var ts; } return minTypeArgumentCount; } - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + var isJavaScript = ts.isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (var i = numTypeArguments; i < numTypeParameters; i++) { var mapper = createTypeMapper(typeParameters, typeArguments); var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -24368,7 +25611,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 172) { + if (param.type && param.type.kind === 173) { hasLiteralTypes = true; } var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || @@ -24379,23 +25622,23 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 152 || declaration.kind === 153) && + if ((declaration.kind === 153 || declaration.kind === 154) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 152 ? 153 : 152; + var otherKind = declaration.kind === 153 ? 154 : 153; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 151 ? + var classType = declaration.kind === 152 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 157 ? + var typePredicate = declaration.type && declaration.type.kind === 158 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -24418,14 +25661,42 @@ var ts; return type; } } - if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 153); + if (declaration.kind === 153 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 154); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { return anyType; } } + function containsArgumentsReference(declaration) { + var links = getNodeLinks(declaration); + if (links.containsArgumentsReference === undefined) { + if (links.flags & 8192) { + links.containsArgumentsReference = true; + } + else { + links.containsArgumentsReference = traverse(declaration.body); + } + } + return links.containsArgumentsReference; + function traverse(node) { + if (!node) + return false; + switch (node.kind) { + case 71: + return node.text === "arguments" && ts.isPartOfExpression(node); + case 149: + case 151: + case 153: + case 154: + return node.name.kind === 144 + && traverse(node.name); + default: + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + } + } + } function getSignaturesOfSymbol(symbol) { if (!symbol) return emptyArray; @@ -24433,20 +25704,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 159: case 160: - case 227: - case 150: - case 149: + case 161: + case 228: case 151: - case 154: + case 150: + case 152: case 155: case 156: - case 152: + case 157: case 153: - case 185: + case 154: case 186: - case 278: + case 187: + case 279: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -24490,7 +25761,7 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { var declaration = signature.declaration; if (declaration.name) { error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name)); @@ -24536,7 +25807,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; + var isConstructor = signature.declaration.kind === 152 || signature.declaration.kind === 156; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -24550,7 +25821,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 135; + var syntaxKind = kind === 1 ? 133 : 136; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -24577,7 +25848,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 144).constraint; + return ts.getDeclarationOfKind(type.symbol, 145).constraint; } function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { @@ -24593,17 +25864,17 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 145).parent); } function getTypeListId(types) { var result = ""; if (types) { - var length_3 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_3) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_3 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -24620,8 +25891,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -24657,13 +25928,13 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -24713,11 +25984,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 158: + case 159: return node.typeName; - case 276: + case 277: return node.name; - case 200: + case 201: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -24741,23 +26012,58 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 276) { + if (symbol.flags & 107455 && node.kind === 277) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); } + function getPrimitiveTypeFromJSDocTypeReference(node) { + if (ts.isIdentifier(node.name)) { + switch (node.name.text) { + case "String": + return stringType; + case "Number": + return numberType; + case "Boolean": + return booleanType; + case "Void": + return voidType; + case "Undefined": + return undefinedType; + case "Null": + return nullType; + case "Object": + return anyType; + case "Function": + return anyFunctionType; + case "Array": + case "array": + return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + case "Promise": + case "promise": + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + } + } + } + function getTypeFromJSDocNullableTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getUnionType([type, nullType]) : type; + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 276) { - var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(typeReferenceName); - type = getTypeReferenceType(node, symbol); + if (node.kind === 277) { + type = getPrimitiveTypeFromJSDocTypeReference(node); + if (!type) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(typeReferenceName); + type = getTypeReferenceType(node, symbol); + } } else { - var typeNameOrExpression = node.kind === 158 + var typeNameOrExpression = node.kind === 159 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -24786,9 +26092,9 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var declaration = declarations_4[_i]; switch (declaration.kind) { - case 228: case 229: - case 231: + case 230: + case 232: return declaration; } } @@ -24807,38 +26113,85 @@ var ts; } return type; } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); + function getGlobalValueSymbol(name, reportErrors) { + return getGlobalSymbol(name, 107455, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793064, ts.Diagnostics.Cannot_find_global_type_0); + function getGlobalTypeSymbol(name, reportErrors) { + return getGlobalSymbol(name, 793064, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name, arity) { + function getGlobalType(name, arity, reportErrors) { + var symbol = getGlobalTypeSymbol(name, reportErrors); + return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; + } + function getGlobalTypedPropertyDescriptorType() { + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType; + } + function getGlobalTemplateStringsArrayType() { + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType; + } + function getGlobalESSymbolConstructorSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); + } + function getGlobalESSymbolType(reportErrors) { + return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType; + } + function getGlobalPromiseType(reportErrors) { + return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType; + } + function getGlobalPromiseConstructorSymbol(reportErrors) { + return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); + } + function getGlobalPromiseConstructorLikeType(reportErrors) { + return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType; + } + function getGlobalAsyncIterableType(reportErrors) { + return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIteratorType(reportErrors) { + return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIterableIteratorType(reportErrors) { + return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableType(reportErrors) { + return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIteratorType(reportErrors) { + return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableIteratorType(reportErrors) { + return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + var symbol = getGlobalSymbol(name, 793064, undefined); + return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getExportedTypeFromNamespace(namespace, name) { var namespaceSymbol = getGlobalSymbol(namespace, 1920, undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793064); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableType(), [elementType]); + function createTypedPropertyDescriptorType(propertyType) { + return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); + function createAsyncIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(true), [iteratedType]); + } + function createAsyncIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(true), [iteratedType]); + } + function createIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]); + } + function createIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(true), [iteratedType]); } function createArrayType(elementType) { return createTypeFromGenericGlobalType(globalArrayType, [elementType]); @@ -24947,14 +26300,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -24962,8 +26315,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -25067,7 +26420,13 @@ var ts; else if (type.flags & 1) { typeSet.containsAny = true; } + else if (getObjectFlags(type) & 16 && isEmptyObjectType(type)) { + typeSet.containsEmptyObject = true; + } else if (!(type.flags & 8192) && (strictNullChecks || !(type.flags & 6144)) && !ts.contains(typeSet, type)) { + if (type.flags & 32768) { + typeSet.containsObjectType = true; + } if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } @@ -25078,8 +26437,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -25092,6 +26451,9 @@ var ts; if (typeSet.containsAny) { return anyType; } + if (typeSet.containsEmptyObject && !typeSet.containsObjectType) { + typeSet.push(emptyObjectType); + } if (typeSet.length === 1) { return typeSet[0]; } @@ -25158,7 +26520,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -25194,7 +26556,7 @@ var ts; return indexInfo.type; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, 1)) { error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } @@ -25206,7 +26568,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 180 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -25216,11 +26578,12 @@ var ts; else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } + return unknownType; } - return unknownType; + return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; @@ -25231,7 +26594,7 @@ var ts; } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 180) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; @@ -25297,7 +26660,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 231 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -25343,7 +26706,7 @@ var ts; skippedPrivateMembers.set(rightProp.name, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.name, rightProp); + members.set(rightProp.name, getNonReadonlySymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -25360,7 +26723,6 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); - result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; @@ -25369,11 +26731,22 @@ var ts; } } else { - members.set(leftProp.name, leftProp); + members.set(leftProp.name, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function getNonReadonlySymbol(prop) { + if (!isReadonlySymbol(prop)) { + return prop; + } + var flags = 4 | (prop.flags & 67108864); + var result = createSymbol(flags, prop.name); + result.type = getTypeOfSymbol(prop); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + return result; + } function isClassMethod(prop) { return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); } @@ -25430,9 +26803,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 230)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 152 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -25448,88 +26821,83 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 118: - case 267: + case 119: case 268: - return anyType; - case 135: - return stringType; - case 132: - return numberType; - case 121: - return booleanType; - case 136: - return esSymbolType; - case 104: - return voidType; - case 138: - return undefinedType; - case 94: - return nullType; - case 129: - return neverType; - case 133: - return nonPrimitiveType; - case 293: - return nullType; - case 294: - return undefinedType; - case 295: - return neverType; - case 168: - case 98: - return getTypeFromThisTypeNode(node); - case 172: - return getTypeFromLiteralTypeNode(node); - case 292: - return getTypeFromLiteralTypeNode(node.literal); - case 158: - case 276: - return getTypeFromTypeReference(node); - case 157: - return booleanType; - case 200: - return getTypeFromTypeReference(node); - case 161: - return getTypeFromTypeQueryNode(node); - case 163: case 269: - return getTypeFromArrayTypeNode(node); - case 164: - return getTypeFromTupleTypeNode(node); - case 165: - case 270: - return getTypeFromUnionTypeNode(node); - case 166: - return getTypeFromIntersectionTypeNode(node); - case 167: - case 272: - case 273: - case 280: - case 281: - case 277: - return getTypeFromTypeNode(node.type); - case 274: - return getTypeFromTypeNode(node.literal); - case 159: - case 160: - case 162: - case 291: - case 278: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + return anyType; + case 136: + return stringType; + case 133: + return numberType; + case 122: + return booleanType; + case 137: + return esSymbolType; + case 105: + return voidType; + case 139: + return undefinedType; + case 95: + return nullType; + case 130: + return neverType; + case 134: + return nonPrimitiveType; case 169: - return getTypeFromTypeOperatorNode(node); + case 99: + return getTypeFromThisTypeNode(node); + case 173: + return getTypeFromLiteralTypeNode(node); + case 293: + return getTypeFromLiteralTypeNode(node.literal); + case 159: + case 277: + return getTypeFromTypeReference(node); + case 158: + return booleanType; + case 201: + return getTypeFromTypeReference(node); + case 162: + return getTypeFromTypeQueryNode(node); + case 164: + case 270: + return getTypeFromArrayTypeNode(node); + case 165: + return getTypeFromTupleTypeNode(node); + case 166: + case 271: + return getTypeFromUnionTypeNode(node); + case 167: + return getTypeFromIntersectionTypeNode(node); + case 273: + return getTypeFromJSDocNullableTypeNode(node); + case 168: + case 274: + case 281: + case 282: + case 278: + return getTypeFromTypeNode(node.type); + case 275: + return getTypeFromTypeNode(node.literal); + case 160: + case 161: + case 163: + case 292: + case 279: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 170: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 171: + return getTypeFromIndexedAccessTypeNode(node); + case 172: return getTypeFromMappedTypeNode(node); - case 70: - case 142: + case 71: + case 143: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 271: + case 272: return getTypeFromJSDocTupleType(node); - case 279: + case 280: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -25718,26 +27086,28 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0]; - while (node) { + return !!ts.findAncestor(symbol.declarations[0], function (node) { + if (node.kind === 233 || node.kind === 265) { + return "quit"; + } switch (node.kind) { - case 159: case 160: - case 227: - case 150: - case 149: + case 161: + case 228: case 151: - case 154: + case 150: + case 152: case 155: case 156: - case 152: + case 157: case 153: - case 185: + case 154: case 186: - case 228: - case 198: + case 187: case 229: + case 199: case 230: + case 231: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -25747,19 +27117,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 229) { + if (ts.isClassLike(node) || node.kind === 230) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 171: + case 172: if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { return true; } break; - case 278: + case 279: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -25768,18 +27138,13 @@ var ts; } } break; - case 232: - case 264: - return false; } - node = node.parent; - } - return false; + }); } function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 264 || parentKind === 233; + return parentKind === 265 || parentKind === 234; } return false; } @@ -25831,33 +27196,33 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 185: case 186: + case 187: return isContextSensitiveFunctionLikeDeclaration(node); - case 177: + case 178: return ts.forEach(node.properties, isContextSensitive); - case 176: + case 177: return ts.forEach(node.elements, isContextSensitive); - case 194: + case 195: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 193: - return node.operatorToken.kind === 53 && + case 194: + return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 260: + case 261: return isContextSensitive(node.initializer); + case 151: case 150: - case 149: return isContextSensitiveFunctionLikeDeclaration(node); - case 184: + case 185: return isContextSensitive(node.expression); - case 253: + case 254: return ts.forEach(node.properties, isContextSensitive); - case 252: + case 253: return node.initializer && isContextSensitive(node.initializer); - case 255: + case 256: return node.expression && isContextSensitive(node.expression); } return false; @@ -25869,7 +27234,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 186) { + if (node.kind === 187) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -25929,9 +27294,9 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + return compareSignaturesRelated(source, target, false, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; } - function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { if (source === target) { return -1; } @@ -25962,9 +27327,15 @@ var ts; var sourceParams = source.parameters; var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - var related = compareTypes(s, t, false) || compareTypes(t, s, reportErrors); + var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); + var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var sourceSig = getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = getSingleCallSignature(getNonNullableType(targetType)); + var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate && + (getFalsyFlags(sourceType) & 6144) === (getFalsyFlags(targetType) & 6144); + var related = callbacks ? + compareSignaturesRelated(targetSig, sourceSig, true, false, reportErrors, errorReporter, compareTypes) : + !checkAsCallback && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); @@ -25991,7 +27362,8 @@ var ts; } } else { - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, false) || + compareTypes(sourceReturnType, targetReturnType, reportErrors); } } return result; @@ -26054,6 +27426,19 @@ var ts; sourceNonRestParamCount; } } + function isEmptyResolvedType(t) { + return t.properties.length === 0 && + t.callSignatures.length === 0 && + t.constructSignatures.length === 0 && + !t.stringIndexInfo && + !t.numberIndexInfo; + } + function isEmptyObjectType(type) { + return type.flags & 32768 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 65536 ? ts.forEach(type.types, isEmptyObjectType) : + type.flags & 131072 ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + false; + } function isEnumTypeRelatedTo(source, target, errorReporter) { if (source === target) { return true; @@ -26144,7 +27529,7 @@ var ts; } } if (source.flags & 1032192 || target.flags & 1032192) { - return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); + return checkTypeRelatedTo(source, target, relation, undefined); } return false; } @@ -26198,7 +27583,7 @@ var ts; if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType() === source && esSymbolType === target)) { + (getGlobalESSymbolType(false) === source && esSymbolType === target)) { reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -26257,102 +27642,24 @@ var ts; return result; } } - else if (target.flags & 65536) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { - return result; - } - } - else if (target.flags & 131072) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & 131072) { - if (result = someTypeRelatedToType(source, target, false)) { - return result; - } - } - else if (target.flags & 16384) { - if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!source.declaration.questionToken) { - var templateType = getTemplateTypeFromMappedType(source); - var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { - return result; - } - } - } - } - else if (target.flags & 262144) { - if (source.flags & 262144) { - if (result = isRelatedTo(target.type, source.type, false)) { - return result; - } - } - var constraint = getConstraintOfType(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } - } - } - else if (target.flags & 524288) { - if (source.flags & 524288 && source.indexType === target.indexType) { - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - return result; - } - } - var constraint = getBaseConstraintOfType(target); - if (constraint) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (source.flags & 16384) { - if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { - var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); - var templateType = getTemplateTypeFromMappedType(target); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - var constraint = getConstraintOfTypeParameter(source); - if (constraint || !(target.flags & 16777216)) { - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - } - else if (source.flags & 524288) { - var constraint = getBaseConstraintOfType(source); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } else { - if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + if (target.flags & 65536) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { return result; } } - var apparentSource = getApparentType(source); - if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + else if (target.flags & 131072) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072) { + if (result = someTypeRelatedToType(source, target, false)) { + return result; + } + } + if (source.flags & 1032192 || target.flags & 1032192) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -26372,12 +27679,7 @@ var ts; function isIdenticalTo(source, target) { var result; if (source.flags & 32768 && target.flags & 32768) { - if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, false); + return recursiveTypeRelatedTo(source, target, false); } if (source.flags & 65536 && target.flags & 65536 || source.flags & 131072 && target.flags & 131072) { @@ -26392,14 +27694,8 @@ var ts; function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && - (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { - return true; - } - else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { - return true; - } - else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { return true; } } @@ -26413,25 +27709,19 @@ var ts; } return false; } - function isEmptyResolvedType(t) { - return t.properties.length === 0 && - t.callSignatures.length === 0 && - t.constructSignatures.length === 0 && - !t.stringIndexInfo && - !t.numberIndexInfo; - } - function isEmptyObjectType(type) { - return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); - } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { var isComparingJsxAttributes = !!(source.flags & 33554432); + if ((relation === assignableRelation || relation === comparableRelation) && + (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { + return false; + } for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - if (ts.isJsxAttributes(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -26551,7 +27841,7 @@ var ts; } return result; } - function objectTypeRelatedTo(source, originalSource, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -26588,32 +27878,11 @@ var ts; maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1; - } - else if (isGenericMappedType(source) || isGenericMappedType(target)) { - result = mappedTypeRelatedTo(source, target, reportErrors); - } - else { - result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 0, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 1, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 0, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 1, reportErrors); - } - } - } - } - } + var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -26626,6 +27895,118 @@ var ts; } return result; } + function structuredTypeRelatedTo(source, target, reportErrors) { + var result; + var saveErrorInfo = errorInfo; + if (target.flags & 16384) { + if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!source.declaration.questionToken) { + var templateType = getTemplateTypeFromMappedType(source); + var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + } + else if (target.flags & 262144) { + if (source.flags & 262144) { + if (result = isRelatedTo(target.type, source.type, false)) { + return result; + } + } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } + else if (target.flags & 524288) { + var constraint = getConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (source.flags & 16384) { + if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + var templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + var constraint = getConstraintOfTypeParameter(source); + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + } + else if (source.flags & 524288) { + var constraint = getConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (target.flags & 524288 && source.indexType === target.indexType) { + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + return result; + } + } + } + else { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + var sourceIsPrimitive = !!(source.flags & 8190); + if (relation !== identityRelation) { + source = getApparentType(source); + } + if (source.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportStructuralErrors); + } + else { + result = propertiesRelatedTo(source, target, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors); + } + } + } + } + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + return 0; + } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -26663,8 +28044,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -26679,7 +28060,7 @@ var ts; var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { - if (getCheckFlags(sourceProp) & 128) { + if (getCheckFlags(sourceProp) & 256) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); } @@ -26797,7 +28178,7 @@ var ts; return result; } function signatureRelatedTo(source, target, reportErrors) { - return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, false, false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -26839,12 +28220,12 @@ var ts; } return related; } - function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors) { if (relation === identityRelation) { return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || ((targetInfo.type.flags & 1) && !(originalSource.flags & 8190))) { + if (!targetInfo || targetInfo.type.flags & 1 && !sourceIsPrimitive) { return -1; } var sourceInfo = getIndexInfoOfType(source, kind) || @@ -26903,7 +28284,7 @@ var ts; } } function forEachProperty(prop, callback) { - if (getCheckFlags(prop) & 2) { + if (getCheckFlags(prop) & 6) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.name); @@ -26945,16 +28326,18 @@ var ts; } return false; } - function isDeeplyNestedGeneric(type, stack, depth) { - if (getObjectFlags(type) & (4 | 64) && depth >= 5) { + function isDeeplyNestedType(type, stack, depth) { + if (depth >= 5 && type.flags & 32768) { var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (getObjectFlags(t) & (4 | 64) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; + if (symbol) { + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & 32768 && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } } } } @@ -27046,8 +28429,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -27055,8 +28438,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -27147,8 +28530,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -27211,7 +28594,6 @@ var ts; var updated = f(original); members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } - ; return members; } function getRegularTypeOfObjectLiteral(type) { @@ -27230,11 +28612,17 @@ var ts; type.regularType = regularNew; return regularNew; } + function getWidenedProperty(prop) { + var original = getTypeOfSymbol(prop); + var widened = getWidenedType(original); + return widened === original ? prop : createSymbolWithType(prop, widened); + } function getWidenedTypeOfObjectLiteral(type) { - var members = transformTypeOfMembers(type, function (prop) { - var widened = getWidenedType(prop); - return prop === widened ? prop : widened; - }); + var members = ts.createMap(); + for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + members.set(prop.name, prop.flags & 4 ? getWidenedProperty(prop) : prop); + } 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)); @@ -27295,25 +28683,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 149: case 148: - case 147: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 145: + case 146: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 175: + case 176: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 227: + case 228: + case 151: case 150: - case 149: - case 152: case 153: - case 185: + case 154: case 186: + case 187: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -27326,7 +28714,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { + if (produceDiagnostics && noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -27352,13 +28740,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, inferUnionTypes) { + function createInferenceContext(signature, inferUnionTypes, useAnyForNoInferences) { var inferences = ts.map(signature.typeParameters, createTypeInferencesObject); return { signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences: useAnyForNoInferences }; } function createTypeInferencesObject() { @@ -27400,14 +28789,14 @@ var ts; var readonlyMask = target.declaration.readonlyToken ? false : true; var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var prop = properties_5[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (!inferredPropType) { return undefined; } var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 8 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; members.set(prop.name, inferredProp); @@ -27549,7 +28938,7 @@ var ts; if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } var key = source.id + "," + target.id; @@ -27597,8 +28986,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -27648,8 +29037,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -27695,7 +29084,7 @@ var ts; inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; } @@ -27729,29 +29118,17 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - while (node) { - switch (node.kind) { - case 161: - return true; - case 70: - case 142: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); + return !!ts.findAncestor(node, function (n) { return n.kind === 162 ? true : n.kind === 71 || n.kind === 143 ? false : "quit"; }); } function getFlowCacheKey(node) { - if (node.kind === 70) { + if (node.kind === 71) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 98) { + if (node.kind === 99) { return "0"; } - if (node.kind === 178) { + if (node.kind === 179) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -27759,31 +29136,33 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 70: - case 98: + case 71: + case 99: return node; - case 178: + case 179: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 70: - return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 225 || target.kind === 175) && + case 71: + return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 226 || target.kind === 176) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 98: - return target.kind === 98; - case 178: - return target.kind === 178 && + case 99: + return target.kind === 99; + case 97: + return target.kind === 97; + case 179: + return target.kind === 179 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 178) { + while (source.kind === 179) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -27792,15 +29171,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 178 && + return target.kind === 179 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 70) { + if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 178) { + if (expr.kind === 179) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -27811,7 +29190,7 @@ var ts; var prop = getUnionOrIntersectionProperty(type, name); if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 32 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -27830,7 +29209,7 @@ var ts; } } } - if (callExpression.expression.kind === 178 && + if (callExpression.expression.kind === 179 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -27869,8 +29248,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -27924,9 +29303,8 @@ var ts; if (flags & 16777216) { return strictNullChecks ? 6166480 : 8378320; } - if (flags & 16384) { - var constraint = getConstraintOfTypeParameter(type); - return getTypeFacts(constraint || emptyObjectType); + if (flags & 540672) { + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & 196608) { return getTypeFactsOfTypes(type.types); @@ -27952,22 +29330,22 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, undefined, false) || + checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 177 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 261 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 193 && parent.parent.left === parent || - parent.parent.kind === 215 && parent.parent.initializer === parent; + return parent.parent.kind === 194 && parent.parent.left === parent || + parent.parent.kind === 216 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); @@ -27984,21 +29362,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 214: - return stringType; case 215: - return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 193: + return stringType; + case 216: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; + case 194: return getAssignedTypeOfBinaryExpression(parent); - case 187: + case 188: return undefinedType; - case 176: + case 177: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 197: + case 198: return getAssignedTypeOfSpreadExpression(parent); - case 260: - return getAssignedTypeOfPropertyAssignment(parent); case 261: + return getAssignedTypeOfPropertyAssignment(parent); + case 262: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -28006,7 +29384,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 173 ? + var type = pattern.kind === 174 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -28021,39 +29399,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 214) { + if (node.parent.parent.kind === 215) { return stringType; } - if (node.parent.parent.kind === 215) { - return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; + if (node.parent.parent.kind === 216) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 225 ? + return node.kind === 226 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 225 || node.kind === 175 ? + return node.kind === 226 || node.kind === 176 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 225 && node.initializer && + return node.kind === 226 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 175 && node.parent.kind === 193 && + node.kind !== 176 && node.parent.kind === 194 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 184: + case 185: return getReferenceCandidate(node.expression); - case 193: + case 194: switch (node.operatorToken.kind) { - case 57: + case 58: return getReferenceCandidate(node.left); - case 25: + case 26: return getReferenceCandidate(node.right); } } @@ -28061,13 +29439,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 184 || - parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 185 || + parent.kind === 194 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 194 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 256) { + if (clause.kind === 257) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -28113,8 +29491,29 @@ var ts; } return f(type) ? type : neverType; } - function mapType(type, f) { - return type.flags & 65536 ? getUnionType(ts.map(type.types, f)) : f(type); + function mapType(type, mapper) { + if (!(type.flags & 65536)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -28148,7 +29547,7 @@ var ts; return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); } function addEvolvingArrayElementType(evolvingArrayType, node) { - var elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node)); + var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { @@ -28169,8 +29568,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -28188,12 +29587,12 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || - parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 179 && + var isLengthPushOrUnshift = parent.kind === 179 && (parent.name.text === "length" || + parent.parent.kind === 181 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 180 && parent.expression === root && - parent.parent.kind === 193 && - parent.parent.operatorToken.kind === 57 && + parent.parent.kind === 194 && + parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 340 | 2048); @@ -28207,7 +29606,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 96) { + if (node.expression.kind !== 97) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -28219,19 +29618,17 @@ var ts; } return false; } - function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { + function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { + if (initialType === void 0) { initialType = declaredType; } var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810431)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 203 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -28285,7 +29682,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 178) { + if (container && container !== flowContainer && reference.kind !== 179 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -28328,7 +29725,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 180 ? + var expr = node.kind === 181 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -28336,7 +29733,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 180) { + if (node.kind === 181) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -28460,7 +29857,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 178 && + return expr.kind === 179 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -28485,19 +29882,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 57: + case 58: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 31: case 32: case 33: case 34: + case 35: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 188 && right_1.kind === 9) { + if (left_1.kind === 189 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 188 && left_1.kind === 9) { + if (right_1.kind === 189 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -28516,9 +29913,9 @@ var ts; return declaredType; } break; - case 92: + case 93: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 25: + case 26: return narrowType(type, expr.right, assumeTrue); } return type; @@ -28527,7 +29924,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 32 || operator === 34) { + if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); @@ -28535,10 +29932,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 31 || operator === 32; + var doubleEquals = operator === 32 || operator === 33; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 94 ? + value.kind === 95 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -28564,13 +29961,21 @@ var ts; } return type; } - if (operator === 32 || operator === 34) { + if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { var targetType = typeofTypesByName.get(literal.text); - if (targetType && isTypeSubtypeOf(targetType, type)) { - return targetType; + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } } } var facts = assumeTrue ? @@ -28644,10 +30049,9 @@ var ts; return assignableType; } } - var targetType = type.flags & 16384 ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, targetType) ? candidate : + isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { @@ -28663,7 +30067,7 @@ var ts; return type; } if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + var predicateArgument = callExpression.arguments[predicate.parameterIndex - (signature.thisParameter ? 1 : 0)]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -28675,7 +30079,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { + if (invokedExpression.kind === 180 || invokedExpression.kind === 179) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -28690,18 +30094,19 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 70: - case 98: - case 178: + case 71: + case 99: + case 97: + case 179: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 180: + case 181: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 184: + case 185: return narrowType(type, expr.expression, assumeTrue); - case 193: + case 194: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 191: - if (expr.operator === 50) { + case 192: + if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -28710,7 +30115,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 70) { + if (location.kind === 71) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -28724,15 +30129,12 @@ var ts; return getTypeOfSymbol(symbol); } function getControlFlowContainer(node) { - while (true) { - node = node.parent; - if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 233 || - node.kind === 264 || - node.kind === 148) { - return node; - } - } + return ts.findAncestor(node.parent, function (node) { + return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || + node.kind === 234 || + node.kind === 265 || + node.kind === 149; + }); } function isParameterAssigned(symbol) { var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; @@ -28746,21 +30148,13 @@ var ts; return symbol.isAssigned || false; } function hasParentWithAssignmentsMarked(node) { - while (true) { - node = node.parent; - if (!node) { - return false; - } - if (ts.isFunctionLike(node) && getNodeLinks(node).flags & 4194304) { - return true; - } - } + return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 4194304); }); } function markParameterAssignments(node) { - if (node.kind === 70) { + if (node.kind === 71) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 146) { symbol.isAssigned = true; } } @@ -28772,6 +30166,14 @@ var ts; function isConstVariable(symbol) { return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + function removeOptionalityFromDeclaredType(declaredType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 146 && + declaration.initializer && + getFalsyFlags(declaredType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072) : declaredType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -28780,16 +30182,14 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 186) { + if (container.kind === 187) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 16384) { - getNodeLinks(container).flags |= 8192; - } + getNodeLinks(container).flags |= 8192; return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -28798,7 +30198,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 228 + if (declaration_1.kind === 229 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -28810,11 +30210,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 198) { + else if (declaration_1.kind === 199) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 148 && ts.hasModifier(container, 32)) { + if (container.kind === 149 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -28844,22 +30244,25 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 145; + var isParameter = ts.getRootDeclaration(declaration).kind === 146; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || - flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 186 || + flowContainer.kind === 187 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node) || node.parent.kind === 246) || ts.isInAmbientContext(declaration); - var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, ts.getRootDeclaration(declaration)) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, 2048); + var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } @@ -28873,19 +30276,12 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; + return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 259) { + symbol.valueDeclaration.parent.kind === 260) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -28903,8 +30299,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 213 && - ts.getAncestor(symbol.valueDeclaration, 226).parent === container && + if (container.kind === 214 && + ts.getAncestor(symbol.valueDeclaration, 227).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -28916,33 +30312,25 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 184) { + while (current.parent.kind === 185) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 191 || current.parent.kind === 192)) { + else if ((current.parent.kind === 192 || current.parent.kind === 193)) { var expr = current.parent; - isAssigned = expr.operator === 42 || expr.operator === 43; + isAssigned = expr.operator === 43 || expr.operator === 44; } if (!isAssigned) { return false; } - while (current !== container) { - if (current === container.statement) { - return true; - } - else { - current = current.parent; - } - } - return false; + return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 148 || container.kind === 151) { + if (container.kind === 149 || container.kind === 152) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -28986,32 +30374,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 151) { + if (container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 186) { + if (container.kind === 187) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 232: + case 233: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 231: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 151: + case 152: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 149: case 148: - case 147: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 143: + case 144: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -29020,8 +30408,8 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 185 && - ts.isInJavaScriptFile(container.parent) && + if (container.kind === 186 && + container.parent.kind === 194 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -29040,7 +30428,7 @@ var ts; if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - return getFlowTypeOfReference(node, type, true, undefined); + return getFlowTypeOfReference(node, type); } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); @@ -29048,34 +30436,29 @@ var ts; return type; } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } return anyType; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 278) { + if (jsdocType && jsdocType.kind === 279) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 282) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 145) { - return true; - } - } - return false; + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 146; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 181 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 186) { + while (container && container.kind === 187) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -29083,17 +30466,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = node; - while (current && current !== container && current.kind !== 143) { - current = current.parent; - } - if (current && current.kind === 143) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 144; }); + if (current && current.kind === 144) { 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 === 177)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 178)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -29101,7 +30481,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 151) { + if (!isCallExpression && container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -29111,7 +30491,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 150 && ts.getModifierFlags(container) & 256) { + if (container.kind === 151 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -29122,7 +30502,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 177) { + if (container.parent.kind === 178) { 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; @@ -29140,7 +30520,7 @@ var ts; } return unknownType; } - if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 152 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -29152,32 +30532,50 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 151; + return container.kind === 152; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 177) { + if (ts.isClassLike(container.parent) || container.parent.kind === 178) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 150 || - container.kind === 149 || - container.kind === 152 || - container.kind === 153; + return container.kind === 151 || + container.kind === 150 || + container.kind === 153 || + container.kind === 154; } else { - return container.kind === 150 || - container.kind === 149 || - container.kind === 152 || + return container.kind === 151 || + container.kind === 150 || container.kind === 153 || + container.kind === 154 || + container.kind === 149 || container.kind === 148 || - container.kind === 147 || - container.kind === 151; + container.kind === 152; } } } return false; } } + function getContainingObjectLiteral(func) { + return (func.kind === 151 || + func.kind === 153 || + func.kind === 154) && func.parent.kind === 178 ? func.parent : + func.kind === 186 && func.parent.kind === 261 ? func.parent.parent : + undefined; + } + function getThisTypeArgument(type) { + return getObjectFlags(type) & 4 && type.target === globalThisType ? type.typeArguments[0] : undefined; + } + function getThisTypeFromContextualType(type) { + return mapType(type, function (t) { + return t.flags & 131072 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + }); + } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { + if (func.kind === 187) { + return undefined; + } + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -29186,6 +30584,32 @@ var ts; } } } + if (noImplicitThis) { + var containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + var contextualType = getApparentTypeOfContextualType(containingLiteral); + var literal = containingLiteral; + var type = contextualType; + while (type) { + var thisType = getThisTypeFromContextualType(type); + if (thisType) { + return instantiateType(thisType, getContextualMapper(containingLiteral)); + } + if (literal.parent.kind !== 261) { + break; + } + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); + } + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); + } + if (func.parent.kind === 194 && func.parent.operatorToken.kind === 58) { + var target = func.parent.left; + if (target.kind === 179 || target.kind === 180) { + return checkExpressionCached(target.expression); + } + } + } return undefined; } function getContextuallyTypedParameterType(parameter) { @@ -29233,7 +30657,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 145) { + if (declaration.kind === 146) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -29245,7 +30669,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (ts.isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== 176 && parentDeclaration.type && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -29259,33 +30683,34 @@ var ts; } function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); - if (ts.isAsyncFunctionLike(func)) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getPromisedType(contextualReturnType); + if (func) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1) { + return undefined; } - return undefined; - } - if (func && !func.asteriskToken) { - return getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func); + return functionFlags & 2 + ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) + : contextualReturnType; } return undefined; } function getContextualTypeForYieldOperand(node) { var func = ts.getContainingFunction(node); if (func) { + var functionFlags = ts.getFunctionFlags(func); var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); + : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & 2) !== 0); } } return undefined; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 145 && node.parent.initializer === node) { + if (node.parent.kind === 146 && node.parent.initializer === node) { return true; } node = node.parent; @@ -29294,8 +30719,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 151 || - functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { + functionDecl.kind === 152 || + functionDecl.kind === 153 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 154))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -29314,7 +30739,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 182) { + if (template.parent.kind === 183) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -29322,7 +30747,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 57 && operator <= 69) { + if (operator >= 58 && operator <= 70) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -29330,52 +30755,28 @@ var ts; return getTypeOfExpression(binaryExpression.left); } } - else if (operator === 53) { + else if (operator === 54) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = getTypeOfExpression(binaryExpression.left); } return type; } - else if (operator === 52 || operator === 25) { + else if (operator === 53 || operator === 26) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } } return undefined; } - function applyToContextualType(type, mapper) { - if (!(type.flags & 65536)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { + return mapType(type, function (t) { var prop = t.flags & 229376 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 65536 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); @@ -29410,7 +30811,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1) - || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); + || getIteratedTypeOrElementType(type, undefined, false, false, false); } return undefined; } @@ -29418,6 +30819,25 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(node) { + var jsxAttributes = ts.isJsxAttributeLike(node.parent) ? + node.parent.parent : + node.parent.openingElement.attributes; + var attributesType = getContextualType(jsxAttributes); + if (!attributesType || isTypeAny(attributesType)) { + return undefined; + } + if (ts.isJsxAttribute(node.parent)) { + return getTypeOfPropertyOfType(attributesType, node.parent.name.text); + } + else if (node.parent.kind === 249) { + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + } + else { + return attributesType; + } + } function getContextualTypeForJsxAttribute(attribute) { var attributesType = getContextualType(attribute.parent); if (ts.isJsxAttribute(attribute)) { @@ -29443,48 +30863,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 225: - case 145: + case 226: + case 146: + case 149: case 148: - case 147: - case 175: - return getContextualTypeForInitializerExpression(node); - case 186: - case 218: - return getContextualTypeForReturnExpression(node); - case 196: - return getContextualTypeForYieldOperand(parent); - case 180: - case 181: - return getContextualTypeForArgument(parent, node); - case 183: - case 201: - return getTypeFromTypeNode(parent.type); - case 193: - return getContextualTypeForBinaryOperand(node); - case 260: - case 261: - return getContextualTypeForObjectLiteralElement(parent); case 176: - return getContextualTypeForElementExpression(node); - case 194: - return getContextualTypeForConditionalOperand(node); - case 204: - ts.Debug.assert(parent.parent.kind === 195); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 187: + case 219: + return getContextualTypeForReturnExpression(node); + case 197: + return getContextualTypeForYieldOperand(parent); + case 181: + case 182: + return getContextualTypeForArgument(parent, node); case 184: + case 202: + return getTypeFromTypeNode(parent.type); + case 194: + return getContextualTypeForBinaryOperand(node); + case 261: + case 262: + return getContextualTypeForObjectLiteralElement(parent); + case 263: + return getApparentTypeOfContextualType(parent.parent); + case 177: + return getContextualTypeForElementExpression(node); + case 195: + return getContextualTypeForConditionalOperand(node); + case 205: + ts.Debug.assert(parent.parent.kind === 196); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 185: return getContextualType(parent); + case 256: + return getContextualTypeForJsxExpression(parent); + case 253: case 255: - return getContextualType(parent); - case 252: - case 254: return getContextualTypeForJsxAttribute(parent); + case 251: case 250: - case 249: return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } + function getContextualMapper(node) { + node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return node ? node.contextualMapper : identityMapper; + } function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { @@ -29509,7 +30935,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 185 || node.kind === 186; + return node.kind === 186 || node.kind === 187; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -29522,7 +30948,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -29532,8 +30958,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var current = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var current = types_17[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -29555,37 +30981,37 @@ var ts; } return result; } - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function checkSpreadExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpression(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + function checkSpreadExpression(node, checkMode) { + if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 1536); + } + var arrayOrIterableType = checkExpression(node.expression, checkMode); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 175 && !!node.initializer) || - (node.kind === 193 && node.operatorToken.kind === 57); + return (node.kind === 176 && !!node.initializer) || + (node.kind === 194 && node.operatorToken.kind === 58); } - function checkArrayLiteral(node, contextualMapper) { + function checkArrayLiteral(node, checkMode) { var elements = node.elements; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 197) { - var restArrayType = checkExpression(e.expression, contextualMapper); + if (inDestructuringPattern && e.kind === 198) { + var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || - (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); if (restElementType) { elementTypes.push(restElementType); } } else { - var type = checkExpressionForMutableLocation(e, contextualMapper); + var type = checkExpressionForMutableLocation(e, checkMode); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 197; + hasSpreadElement = hasSpreadElement || e.kind === 198; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -29596,7 +31022,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { + if (pattern && (pattern.kind === 175 || pattern.kind === 177)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -29604,7 +31030,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 199) { + if (patternElement.kind !== 200) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -29621,7 +31047,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 144 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -29658,7 +31084,7 @@ var ts; var unionType = propTypes.length ? getUnionType(propTypes, true) : undefinedType; return createIndexInfo(unionType, false); } - function checkObjectLiteral(node, contextualMapper) { + function checkObjectLiteral(node, checkMode) { var inDestructuringPattern = ts.isAssignmentTarget(node); checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); @@ -29667,7 +31093,8 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); + (contextualType.pattern.kind === 174 || contextualType.pattern.kind === 178); + var isJSObjectLiteral = !contextualType && ts.isInJavaScriptFile(node); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -29676,25 +31103,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 260 || - memberDecl.kind === 261 || + if (memberDecl.kind === 261 || + memberDecl.kind === 262 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 260) { - type = checkPropertyAssignment(memberDecl, contextualMapper); + if (memberDecl.kind === 261) { + type = checkPropertyAssignment(memberDecl, checkMode); } - else if (memberDecl.kind === 150) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); + else if (memberDecl.kind === 151) { + type = checkObjectLiteralMethod(memberDecl, checkMode); } else { - ts.Debug.assert(memberDecl.kind === 261); - type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 262); + type = checkExpressionForMutableLocation(memberDecl.name, checkMode); } typeFlags |= type.flags; var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 261 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 262 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 67108864; } @@ -29720,7 +31147,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 262) { + else if (memberDecl.kind === 263) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -29742,8 +31169,8 @@ var ts; continue; } else { - ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); - checkAccessorDeclaration(memberDecl); + ts.Debug.assert(memberDecl.kind === 153 || memberDecl.kind === 154); + checkNodeDeferred(memberDecl); } if (ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { @@ -29782,8 +31209,8 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; + var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); @@ -29807,7 +31234,7 @@ var ts; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function checkJsxElement(node) { checkJsxOpeningLikeElement(node.openingElement); @@ -29817,34 +31244,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 255: - checkJsxExpression(child); - break; - case 248: - checkJsxElement(child); - break; - case 249: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function isUnhyphenatedJsxName(name) { return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 178 || tagName.kind === 98) { + if (tagName.kind === 179 || tagName.kind === 99) { return false; } else { return ts.isIntrinsicJsxName(tagName.text); } } - function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createMap(); var spread = emptyObjectType; @@ -29854,7 +31267,7 @@ var ts; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = attributeDecl.initializer ? - checkExpression(attributeDecl.initializer, contextualMapper) : + checkExpression(attributeDecl.initializer, checkMode) : trueType; var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); attributeSymbol.declarations = member.declarations; @@ -29868,14 +31281,14 @@ var ts; attributesArray.push(attributeSymbol); } else { - ts.Debug.assert(attributeDecl.kind === 254); + ts.Debug.assert(attributeDecl.kind === 255); if (attributesArray.length > 0) { spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = ts.createMap(); } var exprType = checkExpression(attributeDecl.expression); - if (!(exprType.flags & (32768 | 1))) { + if (!isValidSpreadType(exprType)) { error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return anyType; } @@ -29901,6 +31314,32 @@ var ts; } }); } + var parent = openingLikeElement.parent.kind === 249 ? openingLikeElement.parent : undefined; + if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { + var childrenTypes = []; + for (var _b = 0, _c = parent.children; _b < _c.length; _b++) { + var child = _c[_b]; + if (child.kind === 10) { + if (!child.containsOnlyWhiteSpaces) { + childrenTypes.push(stringType); + } + } + else { + childrenTypes.push(checkExpression(child, checkMode)); + } + } + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { + if (attributesTable.has(jsxChildrenPropertyName)) { + error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); + } + var childrenPropSymbol = createSymbol(4 | 134217728, jsxChildrenPropertyName); + childrenPropSymbol.type = childrenTypes.length === 1 ? + childrenTypes[0] : + createArrayType(getUnionType(childrenTypes, false)); + attributesTable.set(jsxChildrenPropertyName, childrenPropSymbol); + } + } return createJsxAttributesType(attributes.symbol, attributesTable); function createJsxAttributesType(symbol, attributesTable) { var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); @@ -29910,8 +31349,8 @@ var ts; return result; } } - function checkJsxAttributes(node, contextualMapper) { - return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); + function checkJsxAttributes(node, checkMode) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, checkMode); } function getJsxType(name) { var jsxType = jsxTypes.get(name); @@ -29939,7 +31378,7 @@ var ts; return links.resolvedSymbol = unknownSymbol; } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } return links.resolvedSymbol = unknownSymbol; @@ -29962,36 +31401,48 @@ var ts; } return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } - function getJsxElementPropertiesName() { + function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer) { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793064); - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - if (attribProperties.length === 0) { + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 793064); + var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); + var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); + if (propertiesOfJsxElementAttribPropInterface) { + if (propertiesOfJsxElementAttribPropInterface.length === 0) { return ""; } - else if (attribProperties.length === 1) { - return attribProperties[0].name; + else if (propertiesOfJsxElementAttribPropInterface.length === 1) { + return propertiesOfJsxElementAttribPropInterface[0].name; } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; + else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, nameOfAttribPropContainer); } } - else { - return undefined; + return undefined; + } + function getJsxElementPropertiesName() { + if (!_hasComputedJsxElementPropertiesName) { + _hasComputedJsxElementPropertiesName = true; + _jsxElementPropertiesName = getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer); } + return _jsxElementPropertiesName; + } + function getJsxElementChildrenPropertyname() { + if (!_hasComputedJsxElementChildrenPropertyName) { + _hasComputedJsxElementChildrenPropertyName = true; + _jsxElementChildrenPropertyName = getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer); + } + return _jsxElementChildrenPropertyName; } function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); if (callSignature !== unknownSignature) { var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { paramType = intersectTypes(intrinsicAttributes, paramType); @@ -30006,7 +31457,8 @@ var ts; function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { var candidatesOutArray = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); var result = void 0; @@ -30015,7 +31467,7 @@ var ts; var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var shouldBeCandidate = true; for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { var attribute = _b[_a]; @@ -30101,10 +31553,6 @@ var ts; else if (isTypeAny(attributesType) || (attributesType === unknownType)) { return attributesType; } - else if (attributesType.flags & 65536) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); - return anyType; - } else { var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes); @@ -30174,10 +31622,25 @@ var ts; return prop || unknownSymbol; } function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + if (!deferredJsxElementClassType) { + deferredJsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } - return jsxElementClassType; + return deferredJsxElementClassType; + } + function getJsxGlobalElementType() { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + function getJsxGlobalStatelessElementType() { + if (!deferredJsxStatelessElementType) { + var jsxElementType = getJsxGlobalElementType(); + if (jsxElementType) { + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; } function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); @@ -30187,8 +31650,8 @@ var ts; if ((compilerOptions.jsx || 0) === 0) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { + if (getJsxGlobalElementType() === undefined) { + if (noImplicitAny) { error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -30221,9 +31684,9 @@ var ts; checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node, contextualMapper) { + function checkJsxExpression(node, checkMode) { if (node.expression) { - var type = checkExpression(node.expression, contextualMapper); + var type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -30234,19 +31697,19 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 148; + return s.valueDeclaration ? s.valueDeclaration.kind : 149; } function getDeclarationModifierFlagsFromSymbol(s) { if (s.valueDeclaration) { var flags = ts.getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & 32 ? flags : flags & ~28; } - if (getCheckFlags(s) & 2) { + if (getCheckFlags(s) & 6) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 128 ? 8 : - checkFlags & 32 ? 4 : + var accessModifier = checkFlags & 256 ? 8 : + checkFlags & 64 ? 4 : 16; - var staticModifier = checkFlags & 256 ? 32 : 0; + var staticModifier = checkFlags & 512 ? 32 : 0; return accessModifier | staticModifier; } if (s.flags & 16777216) { @@ -30257,19 +31720,25 @@ var ts; function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol) { + return !!(symbol.flags & 8192 || getCheckFlags(symbol) & 4); + } function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 178 || node.kind === 225 ? + var errorNode = node.kind === 179 || node.kind === 226 ? node.name : node.right; - if (getCheckFlags(prop) & 128) { + if (getCheckFlags(prop) & 256) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; } - if (left.kind === 96) { + if (left.kind === 97) { if (languageVersion < 2) { - var propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== 150 && propKind !== 149) { + var hasNonMethodDeclaration = forEachProperty(prop, function (p) { + var propKind = getDeclarationKindFromSymbol(p); + return propKind !== 151 && propKind !== 150; + }); + if (hasNonMethodDeclaration) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -30290,7 +31759,7 @@ var ts; } return true; } - if (left.kind === 96) { + if (left.kind === 97) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -30363,7 +31832,7 @@ var ts; } function isInPropertyInitializer(node) { while (node) { - if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + if (node.parent && node.parent.kind === 149 && node.parent.initializer === node) { return true; } node = node.parent; @@ -30390,10 +31859,17 @@ var ts; } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === 229 && + node.parent && node.parent.kind !== 159 && + !ts.isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; @@ -30406,16 +31882,16 @@ var ts; return unknownType; } } - if (node.kind !== 178 || assignmentKind === 1 || + if (node.kind !== 179 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - var flowType = getFlowTypeOfReference(node, propType, true, undefined); + var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 178 + var left = node.kind === 179 ? node.expression : node.left; var type = checkExpression(left); @@ -30429,13 +31905,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 226) { + if (initializer.kind === 227) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 70) { + else if (initializer.kind === 71) { return getResolvedSymbol(initializer); } return undefined; @@ -30445,13 +31921,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 70) { + if (e.kind === 71) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 214 && + if (node.kind === 215 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -30469,7 +31945,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 181 && node.parent.expression === node) { + if (node.parent.kind === 182 && 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); @@ -30509,7 +31985,7 @@ var ts; if (!leftHandSideSymbol) { return false; } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + var globalESSymbol = getGlobalESSymbolConstructorSymbol(true); if (!globalESSymbol) { return false; } @@ -30522,10 +31998,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 182) { + if (node.kind === 183) { checkExpression(node.template); } - else if (node.kind !== 146) { + else if (node.kind !== 147) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -30544,8 +32020,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var signature = signatures_2[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -30576,7 +32052,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 197) { + if (arg && arg.kind === 198) { return i; } } @@ -30592,11 +32068,11 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 182) { + if (node.kind === 183) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 195) { + if (tagExpression.template.kind === 196) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -30604,11 +32080,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 12); + ts.Debug.assert(templateLiteral.kind === 13); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 146) { + else if (node.kind === 147) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -30616,7 +32092,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 181); + ts.Debug.assert(callExpression.kind === 182); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -30651,7 +32127,7 @@ var ts; return undefined; } function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, true); + var context = createInferenceContext(signature, true, false); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { inferTypesWithContext(context, instantiateType(source, contextualMapper), target); }); @@ -30677,7 +32153,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 !== 199) { + if (arg === undefined || arg.kind !== 200) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -30744,7 +32220,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 181) { + if (thisType && thisType !== voidType && node.kind !== 182) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -30757,7 +32233,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 !== 199) { + if (arg === undefined || arg.kind !== 200) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -30772,28 +32248,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 180) { + if (node.kind === 181) { var callee = node.expression; - if (callee.kind === 178) { + if (callee.kind === 179) { return callee.expression; } - else if (callee.kind === 179) { + else if (callee.kind === 180) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 182) { + if (node.kind === 183) { var template = node.template; args = [undefined]; - if (template.kind === 195) { + if (template.kind === 196) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 146) { + else if (node.kind === 147) { return undefined; } else if (ts.isJsxOpeningLikeElement(node)) { @@ -30805,21 +32281,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 146) { + if (node.kind === 147) { switch (node.parent.kind) { - case 228: - case 198: + case 229: + case 199: return 1; - case 148: + case 149: return 2; - case 150: - case 152: + case 151: case 153: + case 154: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 145: + case 146: return 3; } } @@ -30828,48 +32304,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 145) { + if (node.kind === 146) { node = node.parent; - if (node.kind === 151) { + if (node.kind === 152) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 153 || + node.kind === 154) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 145) { + if (node.kind === 146) { node = node.parent; - if (node.kind === 151) { + if (node.kind === 152) { return anyType; } } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 153 || + node.kind === 154) { var element = node; switch (element.name.kind) { - case 70: + case 71: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 143: + case 144: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -30886,20 +32362,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 145) { + if (node.kind === 146) { return numberType; } - if (node.kind === 148) { + if (node.kind === 149) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 151 || + node.kind === 153 || + node.kind === 154) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -30920,26 +32396,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 146) { + if (node.kind === 147) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 182) { + else if (argIndex === 0 && node.kind === 183) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 146 || - (argIndex === 0 && node.kind === 182)) { + if (node.kind === 147 || + (argIndex === 0 && node.kind === 183)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 146) { + if (node.kind === 147) { return node.expression; } - else if (argIndex === 0 && node.kind === 182) { + else if (argIndex === 0 && node.kind === 183) { return node.template; } else { @@ -30947,16 +32423,30 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 182; - var isDecorator = node.kind === 146; + var isTaggedTemplate = node.kind === 183; + var isDecorator = node.kind === 147; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; - if (node.expression.kind !== 96) { + if (node.expression.kind !== 97) { ts.forEach(typeArguments, checkSourceElement); } } + if (signatures.length === 1) { + var declaration = signatures[0].declaration; + if (declaration && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration)) { + if (containsArgumentsReference(declaration)) { + var signatureWithRest = cloneSignature(signatures[0]); + var syntheticArgsSymbol = createSymbol(3, "args"); + syntheticArgsSymbol.type = anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + signatureWithRest.parameters = ts.concatenate(signatureWithRest.parameters, [syntheticArgsSymbol]); + signatureWithRest.hasRestParameter = true; + signatures = [signatureWithRest]; + } + } + } var candidates = candidatesOutArray || []; reorderCandidates(signatures, candidates); if (!candidates.length) { @@ -30979,7 +32469,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 181 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -31047,7 +32537,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, false) + ? createInferenceContext(originalCandidate, false, ts.isInJavaScriptFile(node)) : undefined; while (true) { candidate = originalCandidate; @@ -31097,12 +32587,12 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -31251,16 +32741,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 228: - case 198: + case 229: + case 199: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 148: + case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 150: - case 152: + case 151: case 153: + case 154: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -31294,8 +32784,8 @@ var ts; if (elementType.flags & 65536) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var type = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var type = types_18[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -31310,16 +32800,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 180: - return resolveCallExpression(node, candidatesOutArray); case 181: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 182: + return resolveNewExpression(node, candidatesOutArray); + case 183: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 146: + case 147: return resolveDecorator(node, candidatesOutArray); + case 251: case 250: - case 249: return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -31348,23 +32838,26 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { return voidType; } - if (node.kind === 181) { + if (node.kind === 182) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 151 && - declaration.kind !== 155 && - declaration.kind !== 160 && + declaration.kind !== 152 && + declaration.kind !== 156 && + declaration.kind !== 161 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 70 ? + var funcSymbol = node.expression.kind === 71 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { + funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + } + if (funcSymbol && funcSymbol.members && funcSymbol.flags & 16) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -31387,9 +32880,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 227 + ? 228 : resolvedRequire.flags & 3 - ? 225 + ? 226 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -31417,13 +32910,12 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 151) { + else if (container.kind === 152) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -31447,9 +32939,12 @@ var ts; pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; } - function assignContextualParameterTypes(signature, context, mapper) { + function getTypeOfFirstParameterOfSignature(signature) { + return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + } + function assignContextualParameterTypes(signature, context, mapper, checkMode) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - if (isInferentialContext(mapper)) { + if (checkMode === 2) { for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -31463,21 +32958,21 @@ var ts; if (!parameter) { signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper, checkMode); } } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } } @@ -31486,7 +32981,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 70) { + if (element.name.kind === 71) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -31494,18 +32989,18 @@ var ts; } } } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper, checkMode) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 173 || - parameter.valueDeclaration.name.kind === 174)) { + (parameter.valueDeclaration.name.kind === 174 || + parameter.valueDeclaration.name.kind === 175)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); } - else if (isInferentialContext(mapper)) { + else if (checkMode === 2) { inferTypesWithContext(mapper.context, links.type, instantiateType(contextualType, mapper)); } } @@ -31517,9 +33012,9 @@ var ts; return undefined; } function createPromiseType(promisedType) { - var globalPromiseType = getGlobalPromiseType(); + var globalPromiseType = getGlobalPromiseType(true); if (globalPromiseType !== emptyGenericType) { - promisedType = getAwaitedType(promisedType); + promisedType = getAwaitedType(promisedType) || emptyObjectType; return createTypeReference(globalPromiseType, [promisedType]); } return emptyObjectType; @@ -31530,49 +33025,56 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } - else if (!getGlobalPromiseConstructorSymbol()) { + else if (!getGlobalPromiseConstructorSymbol(true)) { error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } return promiseType; } - function getReturnTypeFromBody(func, contextualMapper) { + function getReturnTypeFromBody(func, checkMode) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } - var isAsync = ts.isAsyncFunctionLike(func); + var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 206) { - 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); + if (func.body.kind !== 207) { + type = checkExpressionCached(func.body, checkMode); + if (functionFlags & 2) { + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } } else { var types = void 0; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { + if (functionFlags & 1) { + types = ts.concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode)); + if (!types || types.length === 0) { + var iterableIteratorAny = functionFlags & 2 + ? createAsyncIterableIteratorType(anyType) + : createIterableIteratorType(anyType); + if (noImplicitAny) { error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); } return iterableIteratorAny; } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { - return isAsync ? createPromiseReturnType(func, neverType) : neverType; + return functionFlags & 2 + ? createPromiseReturnType(func, neverType) + : neverType; } if (types.length === 0) { - return isAsync ? createPromiseReturnType(func, voidType) : voidType; + return functionFlags & 2 + ? createPromiseReturnType(func, voidType) + : voidType; } } type = getUnionType(types, true); - if (funcIsGenerator) { - type = createIterableIteratorType(type); + if (functionFlags & 1) { + type = functionFlags & 2 + ? createAsyncIterableIteratorType(type) + : createIterableIteratorType(type); } } if (!contextualSignature) { @@ -31584,16 +33086,24 @@ var ts; type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); - return isAsync ? createPromiseReturnType(func, widenedType) : widenedType; + return (functionFlags & 3) === 2 + ? createPromiseReturnType(func, widenedType) + : widenedType; } - function checkAndAggregateYieldOperandTypes(func, contextualMapper) { + function checkAndAggregateYieldOperandTypes(func, checkMode) { var aggregatedTypes = []; + var functionFlags = ts.getFunctionFlags(func); ts.forEachYieldExpression(func.body, function (yieldExpression) { var expr = yieldExpression.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); + var type = checkExpressionCached(expr, checkMode); if (yieldExpression.asteriskToken) { - type = checkElementTypeOfIterable(type, yieldExpression.expression); + type = checkIteratedTypeOrElementType(type, yieldExpression.expression, false, (functionFlags & 2) !== 0); + } + if (functionFlags & 2) { + type = checkAwaitedType(type, expr, yieldExpression.asteriskToken + ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); @@ -31621,22 +33131,22 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 221 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; } - function checkAndAggregateReturnExpressionTypes(func, contextualMapper) { - var isAsync = ts.isAsyncFunctionLike(func); + function checkAndAggregateReturnExpressionTypes(func, checkMode) { + var functionFlags = ts.getFunctionFlags(func); var aggregatedTypes = []; var hasReturnWithNoExpression = functionHasImplicitReturn(func); var hasReturnOfTypeNever = false; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var type = checkExpressionCached(expr, checkMode); + if (functionFlags & 2) { + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (type.flags & 8192) { hasReturnOfTypeNever = true; @@ -31650,7 +33160,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 185 || func.kind === 186)) { + func.kind === 186 || func.kind === 187)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -31667,7 +33177,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 207 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -31693,20 +33203,20 @@ var ts; error(func.type || func, ts.Diagnostics.Not_all_code_paths_return_a_value); } } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 185) { + if (!hasGrammarError && node.kind === 186) { checkGrammarForGenerator(node); } - if (contextualMapper === identityMapper && isContextSensitive(node)) { + if (checkMode === 1 && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + var mightFixTypeParameters = contextSensitive && checkMode === 2; if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); var contextChecked = !!(links.flags & 1024); @@ -31715,10 +33225,10 @@ var ts; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + assignContextualParameterTypes(signature, contextualSignature, getContextualMapper(node), checkMode); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); + var returnType = getReturnTypeFromBody(node, checkMode); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -31730,7 +33240,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 150) { + if (produceDiagnostics && node.kind !== 151) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -31738,24 +33248,27 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); + var functionFlags = ts.getFunctionFlags(node); + var returnOrPromisedType = node.type && + ((functionFlags & 3) === 2 ? + checkAsyncFunctionReturnType(node) : + getTypeFromTypeNode(node.type)); + if ((functionFlags & 1) === 0) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (node.body) { if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 206) { + if (node.body.kind === 207) { checkSourceElement(node.body); } else { var exprType = checkExpression(node.body); if (returnOrPromisedType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + if ((functionFlags & 3) === 2) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } else { @@ -31774,7 +33287,7 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return !!(getCheckFlags(symbol) & 4 || + return !!(getCheckFlags(symbol) & 8 || symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || @@ -31783,10 +33296,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 178 || expr.kind === 179) && - expr.expression.kind === 98) { + (expr.kind === 179 || expr.kind === 180) && + expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 151)) + if (!(func && func.kind === 152)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -31795,13 +33308,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 178 || expr.kind === 179) { + if (expr.kind === 179 || expr.kind === 180) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 70) { + if (node.kind === 71) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 239; + return declaration && declaration.kind === 240; } } } @@ -31809,7 +33322,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { + if (node.kind !== 71 && node.kind !== 179 && node.kind !== 180) { error(expr, invalidReferenceMessage); return false; } @@ -31818,7 +33331,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 178 && expr.kind !== 179) { + if (expr.kind !== 179 && expr.kind !== 180) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -31847,32 +33360,32 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); + return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 37 && node.operand.kind === 8) { + if (node.operator === 38 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 36: case 37: - case 51: + case 38: + case 52: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 50: + case 51: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 42: case 43: + case 44: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -31898,8 +33411,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -31913,8 +33426,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -31923,8 +33436,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { - var t = types_20[_a]; + for (var _a = 0, types_21 = types; _a < types_21.length; _a++) { + var t = types_21[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -31962,23 +33475,23 @@ var ts; if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 260 || property.kind === 261) { + if (property.kind === 261 || property.kind === 262) { var name = property.name; - if (name.kind === 143) { + if (name.kind === 144) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -31991,7 +33504,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 261) { + if (property.kind === 262) { return checkDestructuringAssignment(property, type); } else { @@ -32002,7 +33515,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 262) { + else if (property.kind === 263) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -32019,19 +33532,22 @@ var ts; error(property, ts.Diagnostics.Property_assignment_expected); } } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + function checkArrayLiteralAssignment(node, sourceType, checkMode) { + if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512); + } + var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } return sourceType; } - function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { + function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 199) { - if (element.kind !== 197) { + if (element.kind !== 200) { + if (element.kind !== 198) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -32039,7 +33555,7 @@ var ts; ? getTypeOfPropertyOfType(sourceType, propName) : elementType; if (type) { - return checkDestructuringAssignment(element, type, contextualMapper); + return checkDestructuringAssignment(element, type, checkMode); } else { checkExpression(element); @@ -32057,48 +33573,48 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 194 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { - return checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); } } } } return undefined; } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 261) { + if (exprOrAssignment.kind === 262) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 2048)) { sourceType = getTypeWithFacts(sourceType, 131072); } - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } target = exprOrAssignment.name; } else { target = exprOrAssignment; } - if (target.kind === 193 && target.operatorToken.kind === 57) { - checkBinaryExpression(target, contextualMapper); + if (target.kind === 194 && target.operatorToken.kind === 58) { + checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 177) { + if (target.kind === 178) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 176) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 177) { + return checkArrayLiteralAssignment(target, sourceType, checkMode); } - return checkReferenceAssignment(target, sourceType, contextualMapper); + return checkReferenceAssignment(target, sourceType, checkMode); } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 262 ? + function checkReferenceAssignment(target, sourceType, checkMode) { + var targetType = checkExpression(target, checkMode); + var error = target.parent.kind === 263 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -32109,49 +33625,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 70: + case 71: case 9: - case 11: - case 182: - case 195: case 12: + case 183: + case 196: + case 13: case 8: - case 100: - case 85: - case 94: - case 138: - case 185: - case 198: + case 101: + case 86: + case 95: + case 139: case 186: - case 176: + case 199: + case 187: case 177: - case 188: - case 202: + case 178: + case 189: + case 203: + case 250: case 249: - case 248: return true; - case 194: + case 195: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 193: + case 194: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 191: case 192: + case 193: switch (node.operator) { - case 50: - case 36: - case 37: case 51: + case 37: + case 38: + case 52: return true; } return false; - case 189: - case 183: - case 201: + case 190: + case 184: + case 202: default: return false; } @@ -32166,39 +33682,39 @@ var ts; firstAssignableToSecond && !secondAssignableToFirst ? type2 : getUnionType([type1, type2], true); } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + function checkBinaryExpression(node, checkMode) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 177 || left.kind === 176)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + if (operator === 58 && (left.kind === 178 || left.kind === 177)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); + var leftType = checkExpression(left, checkMode); + var rightType = checkExpression(right, checkMode); switch (operator) { - case 38: case 39: - case 60: - case 61: case 40: + case 61: case 62: case 41: case 63: - case 37: - case 59: - case 44: + case 42: case 64: + case 38: + case 60: case 45: case 65: case 46: case 66: - case 48: - case 68: - case 49: - case 69: case 47: case 67: + case 49: + case 69: + case 50: + case 70: + case 48: + case 68: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -32218,8 +33734,8 @@ var ts; } } return numberType; - case 36: - case 58: + case 37: + case 59: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -32246,14 +33762,14 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 58) { + if (operator === 59) { checkAssignmentOperator(resultType); } return resultType; - case 26: - case 28: + case 27: case 29: case 30: + case 31: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -32262,10 +33778,10 @@ var ts; } } return booleanType; - case 31: case 32: case 33: case 34: + case 35: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -32276,27 +33792,30 @@ var ts; reportOperatorError(); } return booleanType; - case 92: + case 93: return checkInstanceOfExpression(left, right, leftType, rightType); - case 91: + case 92: return checkInExpression(left, right, leftType, rightType); - case 52: + case 53: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 53: + case 54: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 57: + case 58: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 25: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { + case 26: + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; } + function isEvalNode(node) { + return node.kind === 71 && node.text === "eval"; + } function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 512) ? left : maybeTypeOfKind(rightType, 512) ? right : @@ -32309,21 +33828,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 49: + case 69: + return 54; + case 50: + case 70: + return 35; case 48: case 68: return 53; - case 49: - case 69: - return 34; - case 47: - case 67: - return 52; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 57 && operator <= 69) { + if (produceDiagnostics && operator >= 58 && operator <= 70) { if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(valueType, leftType, left, undefined); } @@ -32359,30 +33878,45 @@ var ts; } if (node.expression) { var func = ts.getContainingFunction(node); - if (func && func.asteriskToken) { + var functionFlags = func && ts.getFunctionFlags(func); + if (node.asteriskToken) { + if (functionFlags & 2) { + if (languageVersion < 4) { + checkExternalEmitHelpers(node, 4096); + } + } + else if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256); + } + } + if (functionFlags & 1) { var expressionType = checkExpressionCached(node.expression, undefined); var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + expressionElementType = checkIteratedTypeOrElementType(expressionType, node.expression, false, (functionFlags & 2) !== 0); } if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(func.type), (functionFlags & 2) !== 0) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(functionFlags & 2 + ? getAwaitedType(expressionElementType, node.expression, ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionElementType, signatureElementType, node.expression, undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(functionFlags & 2 + ? getAwaitedType(expressionType, node.expression, ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionType, signatureElementType, node.expression, undefined); } } } } return anyType; } - function checkConditionalExpression(node, contextualMapper) { + function checkConditionalExpression(node, checkMode) { checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); + var type1 = checkExpression(node.whenTrue, checkMode); + var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { @@ -32394,9 +33928,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 100: + case 101: return trueType; - case 85: + case 86: return falseType; } } @@ -32408,27 +33942,32 @@ var ts; } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; + var saveContextualMapper = node.contextualMapper; node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); + node.contextualMapper = contextualMapper; + var checkMode = contextualMapper === identityMapper ? 1 : + contextualMapper ? 2 : 0; + var result = checkExpression(node, checkMode); node.contextualType = saveContextualType; + node.contextualMapper = saveContextualMapper; return result; } - function checkExpressionCached(node, contextualMapper) { + function checkExpressionCached(node, checkMode) { var links = getNodeLinks(node); if (!links.resolvedType) { var saveFlowLoopStart = flowLoopStart; flowLoopStart = flowLoopCount; - links.resolvedType = checkExpression(node, contextualMapper); + links.resolvedType = checkExpression(node, checkMode); flowLoopStart = saveFlowLoopStart; } return links.resolvedType; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 183 || node.kind === 201; + return node.kind === 184 || node.kind === 202; } function checkDeclarationInitializer(declaration) { - var type = checkExpressionCached(declaration.initializer); + var type = getTypeOfExpression(declaration.initializer, true); return ts.getCombinedNodeFlags(declaration) & 2 || ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -32446,147 +33985,154 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, contextualMapper) { - var type = checkExpression(node, contextualMapper); + function checkExpressionForMutableLocation(node, checkMode) { + var type = checkExpression(node, checkMode); return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } - function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 143) { + function checkPropertyAssignment(node, checkMode) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } - return checkExpressionForMutableLocation(node.initializer, contextualMapper); + return checkExpressionForMutableLocation(node.initializer, checkMode); } - function checkObjectLiteralMethod(node, contextualMapper) { + function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { + function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { + if (checkMode === 2) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getApparentTypeOfContextualType(node); if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, getContextualMapper(node))); } } } } return type; } - function getTypeOfExpression(node) { - if (node.kind === 180 && node.expression.kind !== 96) { + function getTypeOfExpression(node, cache) { + if (node.kind === 181 && node.expression.kind !== 97 && !ts.isRequireCall(node, true)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); } - function checkExpression(node, contextualMapper) { + function getContextFreeTypeOfExpression(node) { + var saveContextualType = node.contextualType; + node.contextualType = anyType; + var type = getTypeOfExpression(node); + node.contextualType = saveContextualType; + return type; + } + function checkExpression(node, checkMode) { var type; - if (node.kind === 142) { + if (node.kind === 143) { type = checkQualifiedName(node); } else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkExpressionWorker(node, checkMode); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 178 && node.parent.expression === node) || - (node.parent.kind === 179 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 142) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 179 && node.parent.expression === node) || + (node.parent.kind === 180 && node.parent.expression === node) || + ((node.kind === 71 || node.kind === 143) && 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); } } return type; } - function checkExpressionWorker(node, contextualMapper) { + function checkExpressionWorker(node, checkMode) { switch (node.kind) { - case 70: + case 71: return checkIdentifier(node); - case 98: + case 99: return checkThisExpression(node); - case 96: + case 97: return checkSuperExpression(node); - case 94: + case 95: return nullWideningType; case 9: case 8: - case 100: - case 85: + case 101: + case 86: return checkLiteralExpression(node); - case 195: - return checkTemplateExpression(node); - case 12: - return stringType; - case 11: - return globalRegExpType; - case 176: - return checkArrayLiteral(node, contextualMapper); - case 177: - return checkObjectLiteral(node, contextualMapper); - case 178: - return checkPropertyAccessExpression(node); - case 179: - return checkIndexedAccess(node); - case 180: - case 181: - return checkCallExpression(node); - case 182: - return checkTaggedTemplateExpression(node); - case 184: - return checkExpression(node.expression, contextualMapper); - case 198: - return checkClassExpression(node); - case 185: - case 186: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 188: - return checkTypeOfExpression(node); - case 183: - case 201: - return checkAssertion(node); - case 202: - return checkNonNullAssertion(node); - case 203: - return checkMetaProperty(node); - case 187: - return checkDeleteExpression(node); - case 189: - return checkVoidExpression(node); - case 190: - return checkAwaitExpression(node); - case 191: - return checkPrefixUnaryExpression(node); - case 192: - return checkPostfixUnaryExpression(node); - case 193: - return checkBinaryExpression(node, contextualMapper); - case 194: - return checkConditionalExpression(node, contextualMapper); - case 197: - return checkSpreadExpression(node, contextualMapper); - case 199: - return undefinedWideningType; case 196: + return checkTemplateExpression(node); + case 13: + return stringType; + case 12: + return globalRegExpType; + case 177: + return checkArrayLiteral(node, checkMode); + case 178: + return checkObjectLiteral(node, checkMode); + case 179: + return checkPropertyAccessExpression(node); + case 180: + return checkIndexedAccess(node); + case 181: + case 182: + return checkCallExpression(node); + case 183: + return checkTaggedTemplateExpression(node); + case 185: + return checkExpression(node.expression, checkMode); + case 199: + return checkClassExpression(node); + case 186: + case 187: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 189: + return checkTypeOfExpression(node); + case 184: + case 202: + return checkAssertion(node); + case 203: + return checkNonNullAssertion(node); + case 204: + return checkMetaProperty(node); + case 188: + return checkDeleteExpression(node); + case 190: + return checkVoidExpression(node); + case 191: + return checkAwaitExpression(node); + case 192: + return checkPrefixUnaryExpression(node); + case 193: + return checkPostfixUnaryExpression(node); + case 194: + return checkBinaryExpression(node, checkMode); + case 195: + return checkConditionalExpression(node, checkMode); + case 198: + return checkSpreadExpression(node, checkMode); + case 200: + return undefinedWideningType; + case 197: return checkYieldExpression(node); - case 255: - return checkJsxExpression(node, contextualMapper); - case 248: - return checkJsxElement(node); + case 256: + return checkJsxExpression(node, checkMode); case 249: - return checkJsxSelfClosingElement(node); - case 253: - return checkJsxAttributes(node, contextualMapper); + return checkJsxElement(node); case 250: + return checkJsxSelfClosingElement(node); + case 254: + return checkJsxAttributes(node, checkMode); + case 251: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -32616,7 +34162,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 152 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -32627,7 +34173,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 151 || func.kind === 155 || func.kind === 160) { + if (func.kind === 152 || func.kind === 156 || func.kind === 161) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -32635,19 +34181,11 @@ var ts; error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 150 || - node.kind === 227 || - node.kind === 185; - } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 70 && + if (param.name.kind === 71 && param.name.text === parameter.text) { return i; } @@ -32697,13 +34235,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 187: + case 155: + case 228: case 186: - case 154: - case 227: - case 185: - case 159: + case 160: + case 151: case 150: - case 149: var parent = node.parent; if (node === parent.type) { return parent; @@ -32717,13 +34255,13 @@ var ts; continue; } var name = element.name; - if (name.kind === 70 && + if (name.kind === 71 && name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 174 || - name.kind === 173) { + else if (name.kind === 175 || + name.kind === 174) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -32731,20 +34269,29 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 156) { + if (node.kind === 157) { checkGrammarIndexSignature(node); } - else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || - node.kind === 154 || node.kind === 151 || - node.kind === 155) { + else if (node.kind === 160 || node.kind === 228 || node.kind === 161 || + node.kind === 155 || node.kind === 152 || + node.kind === 156) { checkGrammarFunctionLikeDeclaration(node); } - if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { + var functionFlags = ts.getFunctionFlags(node); + if ((functionFlags & 7) === 2 && languageVersion < 4) { checkExternalEmitHelpers(node, 64); if (languageVersion < 2) { checkExternalEmitHelpers(node, 128); } } + if ((functionFlags & 5) === 1) { + if (functionFlags & 2 && languageVersion < 4) { + checkExternalEmitHelpers(node, 2048); + } + else if (languageVersion < 2) { + checkExternalEmitHelpers(node, 128); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -32752,29 +34299,32 @@ var ts; } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { + if (noImplicitAny && !node.type) { switch (node.kind) { - case 155: + case 156: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 154: + case 155: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { + var functionFlags_1 = ts.getFunctionFlags(node); + if ((functionFlags_1 & 5) === 1) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + var generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags_1 & 2) !== 0) || anyType; + var iterableIteratorInstantiation = functionFlags_1 & 2 + ? createAsyncIterableIteratorType(generatorElementType) + : createIterableIteratorType(generatorElementType); checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if (ts.isAsyncFunctionLike(node)) { + else if ((functionFlags_1 & 3) === 2) { checkAsyncFunctionReturnType(node); } } @@ -32788,7 +34338,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151) { + if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -32802,16 +34352,16 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 152: + case 153: addName(names, member.name, memberName, 1); break; - case 153: + case 154: addName(names, member.name, memberName, 2); break; - case 148: + case 149: addName(names, member.name, memberName, 3); break; - case 150: + case 151: addName(names, member.name, memberName, 4); break; } @@ -32863,12 +34413,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 147) { + if (member.kind === 148) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 70: + case 71: memberName = member.name.text; break; default: @@ -32885,7 +34435,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 229) { + if (node.kind === 230) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -32900,7 +34450,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 135: + case 136: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -32908,7 +34458,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 132: + case 133: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -32964,15 +34514,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 98) { + if (n.kind === 99) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 185 && n.kind !== 227) { + else if (n.kind !== 186 && n.kind !== 228) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 148 && + return n.kind === 149 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -32992,7 +34542,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -33015,18 +34565,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 152) { + if (node.kind === 153) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 152 ? 153 : 152; + var otherKind = node.kind === 153 ? 154 : 153; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -33040,17 +34590,12 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 152) { + if (node.kind === 153) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 177) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - else { - checkNodeDeferred(node); - } + checkSourceElement(node.body); + registerForUnusedIdentifiersCheck(node); } function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { var firstType = getAnnotatedType(first); @@ -33059,10 +34604,6 @@ var ts; error(first, message); } } - function checkAccessorDeferred(node) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } function checkMissingDeclaration(node) { checkDecorators(node); } @@ -33159,9 +34700,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 229 && - n.parent.kind !== 228 && - n.parent.kind !== 198 && + if (n.parent.kind !== 230 && + n.parent.kind !== 229 && + n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -33238,7 +34779,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 150 || node.kind === 149) && + var reportError = (node.kind === 151 || node.kind === 150) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -33271,11 +34812,11 @@ var ts; var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 230 || node.parent.kind === 163 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { + if (node.kind === 228 || node.kind === 151 || node.kind === 150 || node.kind === 152) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -33326,8 +34867,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; + for (var _a = 0, signatures_4 = signatures; _a < signatures_4.length; _a++) { + var signature = signatures_4[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -33386,16 +34927,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 229: + case 230: return 2097152; - case 232: + case 233: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 228: - case 231: + case 229: + case 232: return 2097152 | 1048576; - case 236: + case 237: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -33405,40 +34946,30 @@ var ts; } } } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - var apparentType = getApparentType(type); - if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; + function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage) { + var promisedType = getPromisedTypeOfPromise(type, errorNode); + return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage); } - function getPromisedType(promise) { + function getPromisedTypeOfPromise(promise, errorNode) { if (isTypeAny(promise)) { return undefined; } - if (getObjectFlags(promise) & 4) { - if (promise.target === tryGetGlobalPromiseType() - || promise.target === getGlobalPromiseLikeType()) { - return promise.typeArguments[0]; - } + var typeAsPromise = promise; + if (typeAsPromise.promisedTypeOfPromise) { + return typeAsPromise.promisedTypeOfPromise; } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; + if (isReferenceToType(promise, getGlobalPromiseType(false))) { + return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (!thenFunction || isTypeAny(thenFunction)) { + if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = getSignaturesOfType(thenFunction, 0); + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; if (thenSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); + } return undefined; } var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288); @@ -33447,46 +34978,60 @@ var ts; } var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); if (onfulfilledParameterSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); + } return undefined; } - return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), true); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), true); } - function getTypeOfFirstParameterOfSignature(signature) { - return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + function checkAwaitedType(type, errorNode, diagnosticMessage) { + return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; } - function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 65536) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types, true); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } + function getAwaitedType(type, errorNode, diagnosticMessage) { + var typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } + if (isTypeAny(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + if (type.flags & 65536) { + var types = void 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types = ts.append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage)); + } + if (!types) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, true); + } + var promisedType = getPromisedTypeOfPromise(type); + if (promisedType) { + if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } + awaitedTypeStack.push(type.id); + var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage); + awaitedTypeStack.pop(); + if (!awaitedType) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = awaitedType; + } + var thenFunction = getTypeOfPropertyOfType(type, "then"); + if (thenFunction && getSignaturesOfType(thenFunction, 0).length > 0) { + if (errorNode) { + ts.Debug.assert(!!diagnosticMessage); + error(errorNode, diagnosticMessage); + } + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = type; } function checkAsyncFunctionReturnType(node) { var returnType = getTypeFromTypeNode(node.type); @@ -33494,8 +35039,8 @@ var ts; if (returnType === unknownType) { return unknownType; } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + var globalPromiseType = getGlobalPromiseType(true); + if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); return unknownType; } @@ -33513,7 +35058,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + if (promiseConstructorName.kind === 71 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -33521,7 +35066,7 @@ var ts; } return unknownType; } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true); if (globalPromiseConstructorLikeType === emptyObjectType) { error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); return unknownType; @@ -33536,7 +35081,7 @@ var ts; return unknownType; } } - return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -33548,22 +35093,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 228: + case 229: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 148: + case 149: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 150: - case 152: + case 151: case 153: + case 154: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -33574,7 +35119,7 @@ var ts; function markTypeNodeAsReferenced(node) { var typeName = node && ts.getEntityNameFromTypeNode(node); var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 ? 793064 : 1920) | 8388608, undefined, undefined); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 71 ? 793064 : 1920) | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608 && symbolIsValue(rootSymbol) @@ -33597,13 +35142,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 145) { + if (node.kind === 146) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 228: + case 229: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -33612,19 +35157,19 @@ var ts; } } break; - case 150: - case 152: + case 151: case 153: + case 154: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 148: + case 149: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 145: + case 146: markTypeNodeAsReferenced(node.type); break; } @@ -33644,8 +35189,8 @@ var ts; function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 143) { + var functionFlags = ts.getFunctionFlags(node); + if (node.name && node.name.kind === 144) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -33663,15 +35208,17 @@ var ts; } } checkSourceElement(node.body); - if (!node.asteriskToken) { - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if ((functionFlags & 1) === 0) { + var returnOrPromisedType = node.type && (functionFlags & 2 + ? checkAsyncFunctionReturnType(node) + : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (produceDiagnostics && !node.type) { - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + if (functionFlags & 1 && ts.nodeIsPresent(node.body)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } } @@ -33687,55 +35234,54 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 264: - case 232: + case 265: + case 233: checkUnusedModuleMembers(node); break; - case 228: - case 198: + case 229: + case 199: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 229: + case 230: checkUnusedTypeParameters(node); break; - case 206: - case 234: - case 213: + case 207: + case 235: case 214: case 215: + case 216: checkUnusedLocalsAndParameters(node); break; - case 151: - case 185: - case 227: - case 186: - case 150: case 152: + case 186: + case 228: + case 187: + case 151: case 153: + case 154: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 149: - case 154: + case 150: case 155: case 156: - case 159: + case 157: case 160: + case 161: checkUnusedTypeParameters(node); break; } - ; } } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 230 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 146) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -33761,13 +35307,13 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 225 && - (declaration.parent.parent.kind === 214 || - declaration.parent.parent.kind === 215)) { + if (declaration.kind === 226 && + (declaration.parent.parent.kind === 215 || + declaration.parent.parent.kind === 216)) { return; } } - if (!isRemovedPropertyFromObjectSpread(node.kind === 70 ? node.parent : node)) { + if (!isRemovedPropertyFromObjectSpread(node.kind === 71 ? node.parent : node)) { error(node, ts.Diagnostics._0_is_declared_but_never_used, name); } } @@ -33775,19 +35321,19 @@ var ts; return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); } function isIdentifierThatStartsWithUnderScore(node) { - return node.kind === 70 && node.text.charCodeAt(0) === 95; + return node.kind === 71 && node.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 || member.kind === 148) { + if (member.kind === 151 || member.kind === 149) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 151) { + else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -33831,7 +35377,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 206) { + if (node.kind === 207) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -33853,19 +35399,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 148 || - node.kind === 147 || + if (node.kind === 149 || + node.kind === 148 || + node.kind === 151 || node.kind === 150 || - node.kind === 149 || - node.kind === 152 || - node.kind === 153) { + node.kind === 153 || + node.kind === 154) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 146 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -33881,36 +35427,32 @@ var ts; } } function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 70; + var isDeclaration_1 = node.kind !== 71; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 70; + var isDeclaration_2 = node.kind !== 71; if (isDeclaration_2) { error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { @@ -33921,7 +35463,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_3 = node.kind !== 70; + var isDeclaration_3 = node.kind !== 71; if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -33937,11 +35479,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 233 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 265 && 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)); } } @@ -33949,11 +35491,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 233 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 265 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { 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)); } } @@ -33961,7 +35503,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 225 && !node.initializer) { + if (node.kind === 226 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -33971,15 +35513,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); - var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 227); + var container = varDeclList.parent.kind === 208 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 206 && ts.isFunctionLike(container.parent) || + (container.kind === 207 && ts.isFunctionLike(container.parent) || + container.kind === 234 || container.kind === 233 || - container.kind === 232 || - container.kind === 264); + container.kind === 265); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -33989,7 +35531,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 145) { + if (ts.getRootDeclaration(node).kind !== 146) { return; } var func = ts.getContainingFunction(node); @@ -33998,10 +35540,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 178) { + if (n.kind === 179) { return visit(n.expression); } - else if (n.kind === 70) { + else if (n.kind === 71) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -34012,22 +35554,21 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 145 || - symbol.valueDeclaration.kind === 175) { + if (symbol.valueDeclaration.kind === 146 || + symbol.valueDeclaration.kind === 176) { if (symbol.valueDeclaration.pos < node.pos) { return; } - var current = n; - while (current !== node.initializer) { - if (ts.isFunctionLike(current.parent)) { - return; + if (ts.findAncestor(n, function (current) { + if (current === node.initializer) { + return "quit"; } - if (current.parent.kind === 148 && - !(ts.hasModifier(current.parent, 32)) && - ts.isClassLike(current.parent.parent)) { - return; - } - current = current.parent; + return ts.isFunctionLike(current.parent) || + (current.parent.kind === 149 && + !(ts.hasModifier(current.parent, 32)) && + ts.isClassLike(current.parent.parent)); + })) { + return; } } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); @@ -34044,17 +35585,17 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 175) { - if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { + if (node.kind === 176) { + if (node.parent.kind === 174 && languageVersion < 5) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 143) { + if (node.propertyName && node.propertyName.kind === 144) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -34067,14 +35608,17 @@ var ts; } } if (ts.isBindingPattern(node.name)) { + if (node.name.kind === 175 && languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512); + } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 146 && 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 !== 214) { + if (node.initializer && node.parent.parent.kind !== 215) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -34083,7 +35627,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 214) { + if (node.initializer && node.parent.parent.kind !== 215) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -34101,9 +35645,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 148 && node.kind !== 147) { + if (node.kind !== 149 && node.kind !== 148) { checkExportsOnMergedDeclarations(node); - if (node.kind === 225 || node.kind === 175) { + if (node.kind === 226 || node.kind === 176) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -34114,8 +35658,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 145 && right.kind === 225) || - (left.kind === 225 && right.kind === 145)) { + if ((left.kind === 146 && right.kind === 226) || + (left.kind === 226 && right.kind === 146)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -34142,8 +35686,8 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 177) { - if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers && node.parent.kind === 178) { + if (ts.getFunctionFlags(node) & 2) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -34161,7 +35705,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 208) { + if (node.thenStatement.kind === 209) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -34178,12 +35722,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 226) { + if (node.initializer && node.initializer.kind === 227) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 226) { + if (node.initializer.kind === 227) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -34201,13 +35745,23 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 226) { + if (node.kind === 216) { + if (node.awaitModifier) { + if (languageVersion < 4) { + checkExternalEmitHelpers(node, 8192); + } + } + else if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256); + } + } + if (node.initializer.kind === 227) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 176 || varExpr.kind === 177) { + var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); + if (varExpr.kind === 177 || varExpr.kind === 178) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -34226,7 +35780,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 226) { + if (node.initializer.kind === 227) { 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); @@ -34236,7 +35790,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 176 || varExpr.kind === 177) { + if (varExpr.kind === 177 || varExpr.kind === 178) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -34246,7 +35800,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -34261,146 +35815,67 @@ var ts; checkVariableDeclaration(decl); } } - function checkRightHandSideOfForOf(rhsExpression) { + function checkRightHandSideOfForOf(rhsExpression, awaitModifier) { var expressionType = checkNonNullExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable) { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1); - if (indexType) { - return indexType; - } - } - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - } - return unknownType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, true) || anyType; } - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableType()) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature), true), errorNode); + function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, checkAssignability) { + var uplevelIteration = languageVersion >= 2; + var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + var iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + if (iteratedType || uplevelIteration) { + return iteratedType; } } - return typeAsIterable.iterableElementType; - } - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - if ((getObjectFlags(type) & 4) && type.target === getGlobalIteratorType()) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature), true); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableIteratorType()) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); - } - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2); - var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 65536) { - var arrayTypes = arrayOrStringType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); - if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, true); - } - } - else if (arrayOrStringType.flags & 262178) { - arrayType = neverType; - } - var hasStringConstituent = arrayOrStringType !== arrayType; + var arrayType = inputType; var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; + var hasStringConstituent = false; + if (allowStringInput) { + if (arrayType.flags & 65536) { + var arrayTypes = inputType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, true); + } } - if (arrayType.flags & 8192) { - return stringType; + else if (arrayType.flags & 262178) { + arrayType = neverType; + } + hasStringConstituent = arrayType !== inputType; + if (hasStringConstituent) { + if (languageVersion < 1) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + } + if (arrayType.flags & 8192) { + return stringType; + } } } if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + if (errorNode && !reportedError) { + var diagnostic = !allowStringInput || hasStringConstituent + ? downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type + : downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; error(errorNode, diagnostic, typeToString(arrayType)); } - return hasStringConstituent ? stringType : unknownType; + return hasStringConstituent ? stringType : undefined; } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; - if (hasStringConstituent) { + var arrayElementType = getIndexTypeOfType(arrayType, 1); + if (hasStringConstituent && arrayElementType) { if (arrayElementType.flags & 262178) { return stringType; } @@ -34408,14 +35883,131 @@ var ts; } return arrayElementType; } + function getIteratedTypeOfIterable(type, errorNode, isAsyncIterable, allowNonAsyncIterables, checkAssignability) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { + return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; + } + if (isAsyncIterable) { + if (isReferenceToType(type, getGlobalAsyncIterableType(false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0]; + } + } + if (!isAsyncIterable || allowNonAsyncIterables) { + if (isReferenceToType(type, getGlobalIterableType(false)) || + isReferenceToType(type, getGlobalIterableIteratorType(false))) { + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0] + : typeAsIterable.iteratedTypeOfIterable = type.typeArguments[0]; + } + } + var iteratorMethodSignatures; + var isNonAsyncIterable = false; + if (isAsyncIterable) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); + } + if (!isAsyncIterable || (allowNonAsyncIterables && !ts.some(iteratorMethodSignatures))) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); + isNonAsyncIterable = true; + } + if (ts.some(iteratorMethodSignatures)) { + var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), true); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, !isNonAsyncIterable); + if (checkAssignability && errorNode && iteratedType) { + checkTypeAssignableTo(type, isNonAsyncIterable + ? createIterableType(iteratedType) + : createAsyncIterableType(iteratedType), errorNode); + } + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType + : typeAsIterable.iteratedTypeOfIterable = iteratedType; + } + if (errorNode) { + error(errorNode, isAsyncIterable + ? ts.Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + function getIteratedTypeOfIterator(type, errorNode, isAsyncIterator) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { + return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; + } + var getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; + if (isReferenceToType(type, getIteratorType(false))) { + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = type.typeArguments[0] + : typeAsIterator.iteratedTypeOfIterator = type.typeArguments[0]; + } + var nextMethod = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(nextMethod)) { + return undefined; + } + var nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, 0) : emptyArray; + if (nextMethodSignatures.length === 0) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.An_async_iterator_must_have_a_next_method + : ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var nextResult = getUnionType(ts.map(nextMethodSignatures, getReturnTypeOfSignature), true); + if (isTypeAny(nextResult)) { + return undefined; + } + if (isAsyncIterator) { + nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); + if (isTypeAny(nextResult)) { + return undefined; + } + } + var nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value"); + if (!nextValue) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue + : typeAsIterator.iteratedTypeOfIterator = nextValue; + } + function getIteratedTypeOfGenerator(returnType, isAsyncGenerator) { + if (isTypeAny(returnType)) { + return undefined; + } + return getIteratedTypeOfIterable(returnType, undefined, isAsyncGenerator, false, false) + || getIteratedTypeOfIterator(returnType, undefined, isAsyncGenerator); + } function checkBreakOrContinueStatement(node) { checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); + return !!(node.kind === 153 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 154))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { - var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; + var unwrappedReturnType = (ts.getFunctionFlags(func) & 3) === 2 + ? getPromisedTypeOfPromise(returnType) + : returnType; return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 1024 | 1); } function checkReturnStatement(node) { @@ -34431,23 +36023,24 @@ var ts; var returnType = getReturnTypeOfSignature(signature); if (strictNullChecks || node.expression || returnType.flags & 8192) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.asteriskToken) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1) { return; } - if (func.kind === 153) { + if (func.kind === 154) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 151) { + else if (func.kind === 152) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (functionFlags & 2) { + var promisedType = getPromisedTypeOfPromise(returnType); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); if (promisedType) { checkTypeAssignableTo(awaitedType, promisedType, node); } @@ -34457,7 +36050,7 @@ var ts; } } } - else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 152 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -34483,7 +36076,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 257 && !hasDuplicateDefaultClause) { + if (clause.kind === 258 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -34495,7 +36088,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 256) { + if (produceDiagnostics && clause.kind === 257) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -34516,18 +36109,16 @@ var ts; } function checkLabeledStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { + ts.findAncestor(node.parent, function (current) { if (ts.isFunctionLike(current)) { - break; + return "quit"; } - if (current.kind === 221 && current.label.text === node.label.text) { + if (current.kind === 222 && 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; + return true; } - current = current.parent; - } + }); } checkSourceElement(node.statement); } @@ -34614,7 +36205,7 @@ var ts; return; } var errorNode; - if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + if (propDeclaration && (propDeclaration.name.kind === 144 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { @@ -34735,7 +36326,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); @@ -34757,7 +36348,7 @@ var ts; } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (languageVersion < 2 && !ts.isInAmbientContext(node)) { + if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); } var baseTypes = getBaseTypes(type); @@ -34769,7 +36360,7 @@ var ts; checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { var constructor = _a[_i]; if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; @@ -34781,15 +36372,8 @@ var ts; if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && - !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 228) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { - error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); 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); } @@ -34843,7 +36427,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 228 || d.kind === 229; + return d.kind === 229 || d.kind === 230; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -34861,7 +36445,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 198) { + if (derivedClassDecl.kind === 199) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -34871,41 +36455,37 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 8) || (derivedDeclarationFlags & 8)) { + if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { continue; } if ((baseDeclarationFlags & 32) !== (derivedDeclarationFlags & 32)) { continue; } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & 98308 && derived.flags & 98308) { continue; } var errorMessage = void 0; - if (base.flags & 8192) { + if (isMethodLike(base)) { if (derived.flags & 98304) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert((derived.flags & 4) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } } function isAccessor(kind) { - return kind === 152 || kind === 153; + return kind === 153 || kind === 154; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -34918,8 +36498,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.name); if (!existing) { seen.set(prop.name, { prop: prop, containingType: base }); @@ -34947,7 +36527,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 230); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -35043,18 +36623,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 191: + case 192: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 36: return value_1; - case 37: return -value_1; - case 51: return ~value_1; + case 37: return value_1; + case 38: return -value_1; + case 52: return ~value_1; } return undefined; - case 193: + case 194: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -35064,38 +36644,38 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 48: return left | right; - case 47: return left & right; - case 45: return left >> right; - case 46: return left >>> right; - case 44: return left << right; - case 49: return left ^ right; - case 38: return left * right; - case 40: return left / right; - case 36: return left + right; - case 37: return left - right; - case 41: return left % right; + case 49: return left | right; + case 48: return left & right; + case 46: return left >> right; + case 47: return left >>> right; + case 45: return left << right; + case 50: return left ^ right; + case 39: return left * right; + case 41: return left / right; + case 37: return left + right; + case 38: return left - right; + case 42: return left % right; } return undefined; case 8: checkGrammarNumericLiteral(e); return +e.text; - case 184: + case 185: return evalConstant(e.expression); - case 70: + case 71: + case 180: case 179: - case 178: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 70) { + if (e.kind === 71) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 179) { + if (e.kind === 180) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -35109,10 +36689,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 70) { + if (current.kind === 71) { break; } - else if (current.kind === 178) { + else if (current.kind === 179) { current = current.expression; } else { @@ -35173,7 +36753,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 231) { + if (declaration.kind !== 232) { return false; } var enumDeclaration = declaration; @@ -35196,8 +36776,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 228 || - (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 229 || + (declaration.kind === 228 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -35256,7 +36836,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, 228); + var mergedClass = ts.getDeclarationOfKind(symbol, 229); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -35299,22 +36879,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 207: + case 208: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 242: case 243: + case 244: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 236: case 237: + case 238: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 175: - case 225: + case 176: + case 226: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -35323,12 +36903,12 @@ var ts; } break; } - case 228: - case 231: - case 227: case 229: case 232: + case 228: case 230: + case 233: + case 231: if (isGlobalAugmentation) { return; } @@ -35344,17 +36924,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 70: + case 71: return node; - case 142: + case 143: do { node = node.left; - } while (node.kind !== 70); + } while (node.kind !== 71); return node; - case 178: + case 179: do { node = node.expression; - } while (node.kind !== 70); + } while (node.kind !== 71); return node; } } @@ -35364,9 +36944,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 264 && !inAmbientExternalModule) { - error(moduleName, node.kind === 243 ? + var inAmbientExternalModule = node.parent.kind === 234 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 265 && !inAmbientExternalModule) { + error(moduleName, node.kind === 244 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -35387,7 +36967,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 245 ? + var message = node.kind === 246 ? 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)); @@ -35414,7 +36994,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239) { + if (importClause.namedBindings.kind === 240) { checkImportBinding(importClause.namedBindings); } else { @@ -35465,10 +37045,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + var inAmbientExternalModule = node.parent.kind === 234 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 234 && !node.moduleSpecifier && ts.isInAmbientContext(node); - if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 265 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -35481,7 +37061,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; + var isInAppropriateContext = node.parent.kind === 265 || node.parent.kind === 234 || node.parent.kind === 233; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -35504,8 +37084,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 264 ? node.parent : node.parent.parent; - if (container.kind === 232 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 265 ? node.parent : node.parent.parent; + if (container.kind === 233 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -35517,7 +37097,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { markExportAsReferenced(node); } else { @@ -35572,7 +37152,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 227 && declaration.kind !== 150) || + return (declaration.kind !== 228 && declaration.kind !== 151) || !!declaration.body; } } @@ -35583,123 +37163,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 232: - case 228: + case 233: case 229: - case 227: + case 230: + case 228: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 144: - return checkTypeParameter(node); case 145: + return checkTypeParameter(node); + case 146: return checkParameter(node); + case 149: case 148: - case 147: return checkPropertyDeclaration(node); - case 159: case 160: - case 154: + case 161: case 155: - return checkSignatureDeclaration(node); case 156: return checkSignatureDeclaration(node); - case 150: - case 149: - return checkMethodDeclaration(node); - case 151: - return checkConstructorDeclaration(node); - case 152: - case 153: - return checkAccessorDeclaration(node); - case 158: - return checkTypeReferenceNode(node); case 157: + return checkSignatureDeclaration(node); + case 151: + case 150: + return checkMethodDeclaration(node); + case 152: + return checkConstructorDeclaration(node); + case 153: + case 154: + return checkAccessorDeclaration(node); + case 159: + return checkTypeReferenceNode(node); + case 158: return checkTypePredicate(node); - case 161: - return checkTypeQuery(node); case 162: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 163: - return checkArrayType(node); + return checkTypeLiteral(node); case 164: - return checkTupleType(node); + return checkArrayType(node); case 165: + return checkTupleType(node); case 166: - return checkUnionOrIntersectionType(node); case 167: - case 169: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 168: case 170: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 171: + return checkIndexedAccessType(node); + case 172: return checkMappedType(node); - case 227: - return checkFunctionDeclaration(node); - case 206: - case 233: - return checkBlock(node); - case 207: - return checkVariableStatement(node); - case 209: - return checkExpressionStatement(node); - case 210: - return checkIfStatement(node); - case 211: - return checkDoStatement(node); - case 212: - return checkWhileStatement(node); - case 213: - return checkForStatement(node); - case 214: - return checkForInStatement(node); - case 215: - return checkForOfStatement(node); - case 216: - case 217: - return checkBreakOrContinueStatement(node); - case 218: - return checkReturnStatement(node); - case 219: - return checkWithStatement(node); - case 220: - return checkSwitchStatement(node); - case 221: - return checkLabeledStatement(node); - case 222: - return checkThrowStatement(node); - case 223: - return checkTryStatement(node); - case 225: - return checkVariableDeclaration(node); - case 175: - return checkBindingElement(node); case 228: - return checkClassDeclaration(node); - case 229: - return checkInterfaceDeclaration(node); - case 230: - return checkTypeAliasDeclaration(node); - case 231: - return checkEnumDeclaration(node); - case 232: - return checkModuleDeclaration(node); - case 237: - return checkImportDeclaration(node); - case 236: - return checkImportEqualsDeclaration(node); - case 243: - return checkExportDeclaration(node); - case 242: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 207: + case 234: + return checkBlock(node); case 208: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 210: + return checkExpressionStatement(node); + case 211: + return checkIfStatement(node); + case 212: + return checkDoStatement(node); + case 213: + return checkWhileStatement(node); + case 214: + return checkForStatement(node); + case 215: + return checkForInStatement(node); + case 216: + return checkForOfStatement(node); + case 217: + case 218: + return checkBreakOrContinueStatement(node); + case 219: + return checkReturnStatement(node); + case 220: + return checkWithStatement(node); + case 221: + return checkSwitchStatement(node); + case 222: + return checkLabeledStatement(node); + case 223: + return checkThrowStatement(node); case 224: + return checkTryStatement(node); + case 226: + return checkVariableDeclaration(node); + case 176: + return checkBindingElement(node); + case 229: + return checkClassDeclaration(node); + case 230: + return checkInterfaceDeclaration(node); + case 231: + return checkTypeAliasDeclaration(node); + case 232: + return checkEnumDeclaration(node); + case 233: + return checkModuleDeclaration(node); + case 238: + return checkImportDeclaration(node); + case 237: + return checkImportEqualsDeclaration(node); + case 244: + return checkExportDeclaration(node); + case 243: + return checkExportAssignment(node); + case 209: checkGrammarStatementInAmbientContext(node); return; - case 246: + case 225: + checkGrammarStatementInAmbientContext(node); + return; + case 247: return checkMissingDeclaration(node); } } @@ -35712,17 +37292,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 185: case 186: + case 187: + case 151: case 150: - case 149: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 152: case 153: - checkAccessorDeferred(node); + case 154: + checkAccessorDeclaration(node); break; - case 198: + case 199: checkClassExpressionDeferred(node); break; } @@ -35810,7 +37390,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 219 && node.parent.statement === node) { + if (node.parent.kind === 220 && node.parent.statement === node) { return true; } node = node.parent; @@ -35819,11 +37399,11 @@ var ts; return false; } function getSymbolsInScope(location, meaning) { - var symbols = ts.createMap(); - var memberFlags = 0; if (isInsideWithStatementBody(location)) { return []; } + var symbols = ts.createMap(); + var memberFlags = 0; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -35832,28 +37412,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232: + case 233: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 231: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 198: + case 199: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 228: case 229: + case 230: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 185: + case 186: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -35885,33 +37465,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 70 && + return name.kind === 71 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 144: - case 228: + case 145: case 229: case 230: case 231: + case 232: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 142) { + while (node.parent && node.parent.kind === 143) { node = node.parent; } - return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); + return node.parent && (node.parent.kind === 159 || node.parent.kind === 277); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 178) { + while (node.parent && node.parent.kind === 179) { node = node.parent; } - return node.parent && node.parent.kind === 200; + return node.parent && node.parent.kind === 201; } function forEachEnclosingClass(node, callback) { var result; @@ -35928,13 +37508,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 142) { + while (nodeOnRightSide.parent.kind === 143) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 237) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242) { + if (nodeOnRightSide.parent.kind === 243) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -35942,27 +37522,35 @@ var ts; function isInRightSideOfImportOrExportAssignment(node) { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } + function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1: + case 3: + return getSymbolOfNode(entityName.parent); + case 4: + case 2: + case 5: + return getSymbolOfNode(entityName.parent.parent); + } + } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { - 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 (ts.isInJavaScriptFile(entityName) && + entityName.parent.kind === 179 && + entityName.parent === entityName.parent.parent.left) { + var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); + if (specialPropertyAssignmentSymbol) { + return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 243 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 236); + if (entityName.kind !== 179 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 237); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -35971,7 +37559,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 200) { + if (entityName.parent.kind === 201) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -35981,26 +37569,29 @@ var ts; meaning = 1920; } meaning |= 8388608; - return resolveEntityName(entityName, meaning); + var entityNameSymbol = resolveEntityName(entityName, meaning); + if (entityNameSymbol) { + return entityNameSymbol; + } } - else if (ts.isPartOfExpression(entityName)) { + if (ts.isPartOfExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 70) { + if (entityName.kind === 71) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 178) { + else if (entityName.kind === 179) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 142) { + else if (entityName.kind === 143) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -36009,19 +37600,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 159 || entityName.parent.kind === 277) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 252) { + else if (entityName.parent.kind === 253) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 157) { + if (entityName.parent.kind === 158) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 264) { + if (node.kind === 265) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -36033,12 +37624,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 70) { + if (node.kind === 71) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 175 && - node.parent.parent.kind === 173 && + else if (node.parent.kind === 176 && + node.parent.parent.kind === 174 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -36048,11 +37639,11 @@ var ts; } } switch (node.kind) { - case 70: - case 178: - case 142: + case 71: + case 179: + case 143: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 98: + case 99: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -36060,21 +37651,21 @@ var ts; return sig.thisParameter; } } - case 96: + case 97: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 168: + case 169: return getTypeFromTypeNode(node).symbol; - case 122: + case 123: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 151) { + if (constructorDeclaration && constructorDeclaration.kind === 152) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 237 || node.parent.kind === 243) && + ((node.parent.kind === 238 || node.parent.kind === 244) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -36082,7 +37673,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 179 && node.parent.argumentExpression === node) { + if (node.parent.kind === 180 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -36096,7 +37687,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 261) { + if (location && location.kind === 262) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -36111,13 +37702,22 @@ var ts; return unknownType; } if (ts.isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + var typeFromTypeNode = getTypeFromTypeNode(node); + if (typeFromTypeNode && ts.isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + var containingClass = ts.getContainingClass(node); + var classType = getTypeOfNode(containingClass); + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + return typeFromTypeNode; } if (ts.isPartOfExpression(node)) { return getRegularTypeOfExpression(node); } if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + var classNode = ts.getContainingClass(node); + var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)); + var baseType = getBaseTypes(classType)[0]; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); @@ -36146,22 +37746,22 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 177 || expr.kind === 176); - if (expr.parent.kind === 215) { - var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); + ts.Debug.assert(expr.kind === 178 || expr.kind === 177); + if (expr.parent.kind === 216) { + var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 193) { + if (expr.parent.kind === 194) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 260) { + if (expr.parent.kind === 261) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 176); + ts.Debug.assert(expr.parent.kind === 177); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); } function getPropertySymbolOfDestructuringAssignment(location) { @@ -36193,7 +37793,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (getCheckFlags(symbol) & 2) { + if (getCheckFlags(symbol) & 6) { var symbols_3 = []; var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { @@ -36207,10 +37807,10 @@ var ts; else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; - return [links.leftSpread, links.rightSpread]; + return getRootSymbols(links.leftSpread).concat(getRootSymbols(links.rightSpread)); } - if (symbol.mappedTypeOrigin) { - return getRootSymbols(symbol.mappedTypeOrigin); + if (symbol.syntheticOrigin) { + return getRootSymbols(symbol.syntheticOrigin); } var target = void 0; var next = symbol; @@ -36227,7 +37827,7 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 179 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -36268,19 +37868,15 @@ var ts; } symbol = exportSymbol; } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { - var symbolFile = parentSymbol.valueDeclaration; + var parentSymbol_1 = getParentOfSymbol(symbol); + if (parentSymbol_1) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 265) { + var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - for (var n = node.parent; n; n = n.parent) { - if (ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } + return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; }); } } } @@ -36308,7 +37904,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 207 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -36343,23 +37939,19 @@ var ts; return false; } function isValueAliasDeclaration(node) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - return true; - } switch (node.kind) { - case 236: - case 238: + case 237: case 239: - case 241: - case 245: + case 240: + case 242: + case 246: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 243: + case 244: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 242: + case 243: return node.expression - && node.expression.kind === 70 + && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -36367,7 +37959,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 265 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -36385,10 +37977,6 @@ var ts; return isConstEnumSymbol(s) || s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - return true; - } if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (symbol && getSymbolLinks(symbol).referenced) { @@ -36416,15 +38004,23 @@ var ts; !(ts.getModifierFlags(parameter) & 92); } function getNodeCheckFlags(node) { - node = ts.getParseTreeNode(node); - return node ? getNodeLinks(node).flags : undefined; + return getNodeLinks(node).flags; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function canHaveConstantValue(node) { + switch (node.kind) { + case 264: + case 179: + case 180: + return true; + } + return false; + } function getConstantValue(node) { - if (node.kind === 263) { + if (node.kind === 264) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -36442,7 +38038,7 @@ var ts; var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { return ts.TypeReferenceSerializationKind.Promise; } @@ -36574,10 +38170,19 @@ var ts; getReferencedImportDeclaration: getReferencedImportDeclaration, getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, isDeclarationWithCollidingName: isDeclarationWithCollidingName, - isValueAliasDeclaration: isValueAliasDeclaration, + isValueAliasDeclaration: function (node) { + node = ts.getParseTreeNode(node); + return node ? isValueAliasDeclaration(node) : true; + }, hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, + isReferencedAliasDeclaration: function (node, checkChildren) { + node = ts.getParseTreeNode(node); + return node ? isReferencedAliasDeclaration(node, checkChildren) : true; + }, + getNodeCheckFlags: function (node) { + node = ts.getParseTreeNode(node); + return node ? getNodeCheckFlags(node) : undefined; + }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, @@ -36588,7 +38193,10 @@ var ts; writeBaseConstructorTypeOfClass: writeBaseConstructorTypeOfClass, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, collectLinkedAliases: collectLinkedAliases, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, @@ -36606,7 +38214,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 179) || (node.kind === 71 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -36649,7 +38257,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 265 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -36668,7 +38276,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 264); + return ts.getDeclarationOfKind(moduleSymbol, 265); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -36707,57 +38315,29 @@ var ts; } addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true); getSymbolLinks(unknownSymbol).type = unknownType; - globalArrayType = getGlobalType("Array", 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalESSymbolConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Symbol"); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793064, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - tryGetGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalSymbol("Promise", 107455, undefined) && getGlobalPromiseConstructorSymbol(); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2) { - getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); - getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", 1); }); - getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", 1); }); - getGlobalIterableIteratorType = ts.memoize(function () { return getGlobalType("IterableIterator", 1); }); - } - else { - getGlobalESSymbolType = ts.memoize(function () { return emptyObjectType; }); - getGlobalIterableType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIteratorType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); - } + globalArrayType = getGlobalType("Array", 1, true); + globalObjectType = getGlobalType("Object", 0, true); + globalFunctionType = getGlobalType("Function", 0, true); + globalStringType = getGlobalType("String", 0, true); + globalNumberType = getGlobalType("Number", 0, true); + globalBooleanType = getGlobalType("Boolean", 0, true); + globalRegExpType = getGlobalType("RegExp", 0, true); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); - var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); - globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); + globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; + globalThisType = getGlobalTypeOrUndefined("ThisType", 1); } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !ts.isInAmbientContext(location)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1; helper <= 128; helper <<= 1) { + for (var helper = 1; helper <= 8192; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); @@ -36781,6 +38361,13 @@ var ts; case 32: return "__param"; case 64: return "__awaiter"; case 128: return "__generator"; + case 256: return "__values"; + case 512: return "__read"; + case 1024: return "__spread"; + case 2048: return "__asyncGenerator"; + case 4096: return "__asyncDelegator"; + case 8192: return "__asyncValues"; + default: ts.Debug.fail("Unrecognized helper."); } } function resolveHelpersModule(node, errorNode) { @@ -36789,36 +38376,19 @@ var ts; } return externalHelpersModule; } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - var thenPropertySymbol = createSymbol(4, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(16); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 151 && !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 === 152 || node.kind === 153) { + else if (node.kind === 153 || node.kind === 154) { 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); @@ -36835,28 +38405,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 130) { - if (node.kind === 147 || node.kind === 149) { + if (modifier.kind !== 131) { + if (node.kind === 148 || node.kind === 150) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 156) { + if (node.kind === 157) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 75: - if (node.kind !== 231 && node.parent.kind === 228) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); + case 76: + if (node.kind !== 232 && node.parent.kind === 229) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; + case 114: case 113: case 112: - case 111: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 112) { + if (modifier.kind === 113) { lastProtected = modifier; } - else if (modifier.kind === 111) { + else if (modifier.kind === 112) { lastPrivate = modifier; } if (flags & 28) { @@ -36871,11 +38441,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 233 || node.parent.kind === 264) { + else if (node.parent.kind === 234 || node.parent.kind === 265) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 111) { + if (modifier.kind === 112) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -36884,7 +38454,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 114: + case 115: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -36894,10 +38464,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 233 || node.parent.kind === 264) { + else if (node.parent.kind === 234 || node.parent.kind === 265) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -36906,17 +38476,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 130: + case 131: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { + else if (node.kind !== 149 && node.kind !== 148 && node.kind !== 157 && node.kind !== 146) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 83: + case 84: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -36929,45 +38499,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 123: + case 124: 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 === 228) { + else if (node.parent.kind === 229) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 234) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 116: + case 117: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 228) { - if (node.kind !== 150 && - node.kind !== 148 && - node.kind !== 152 && - node.kind !== 153) { + if (node.kind !== 229) { + if (node.kind !== 151 && + node.kind !== 149 && + node.kind !== 153 && + node.kind !== 154) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 229 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -36979,14 +38549,14 @@ var ts; } flags |= 128; break; - case 119: + case 120: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -36994,7 +38564,7 @@ var ts; break; } } - if (node.kind === 151) { + if (node.kind === 152) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -37009,13 +38579,13 @@ var ts; } return; } - else if ((node.kind === 237 || node.kind === 236) && flags & 2) { + else if ((node.kind === 238 || node.kind === 237) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 146 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 146 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -37031,38 +38601,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 152: case 153: - case 151: - case 148: - case 147: - case 150: + case 154: + case 152: case 149: - case 156: - case 232: + case 148: + case 151: + case 150: + case 157: + case 233: + case 238: case 237: - case 236: + case 244: case 243: - case 242: - case 185: case 186: - case 145: + case 187: + case 146: return false; default: - if (node.parent.kind === 233 || node.parent.kind === 264) { + if (node.parent.kind === 234 || node.parent.kind === 265) { return false; } switch (node.kind) { - case 227: - return nodeHasAnyModifiersExcept(node, 119); case 228: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 120); case 229: - case 207: + return nodeHasAnyModifiersExcept(node, 117); case 230: - return true; + case 208: case 231: - return nodeHasAnyModifiersExcept(node, 75); + return true; + case 232: + return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); return false; @@ -37074,14 +38644,11 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 150: - case 227: - case 185: + case 151: + case 228: case 186: - if (!node.asteriskToken) { - return false; - } - break; + case 187: + return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } @@ -37138,8 +38705,12 @@ var ts; return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } function checkGrammarArrowFunction(node, file) { - if (node.kind === 186) { + if (node.kind === 187) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -37174,7 +38745,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 136 && parameter.type.kind !== 133) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -37201,7 +38772,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 199) { + if (arg.kind === 200) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -37227,7 +38798,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84) { + if (heritageClause.token === 85) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -37240,7 +38811,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107); + ts.Debug.assert(heritageClause.token === 108); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -37255,14 +38826,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84) { + if (heritageClause.token === 85) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107); + ts.Debug.assert(heritageClause.token === 108); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -37271,28 +38842,25 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 143) { + if (node.kind !== 144) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 194 && computedPropertyName.expression.operatorToken.kind === 26) { 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 === 227 || - node.kind === 185 || - node.kind === 150); + ts.Debug.assert(node.kind === 228 || + node.kind === 186 || + node.kind === 151); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); - } } } function checkGrammarForInvalidQuestionMark(questionToken, message) { @@ -37308,39 +38876,39 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262) { + if (prop.kind === 263) { continue; } var name = prop.name; - if (name.kind === 143) { + if (name.kind === 144) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 262 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 150) { + if (mod.kind !== 120 || prop.kind !== 151) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 260 || prop.kind === 261) { + if (prop.kind === 261 || prop.kind === 262) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = Property; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = GetAccessor; } - else if (prop.kind === 153) { + else if (prop.kind === 154) { currentKind = SetAccessor; } else { @@ -37376,7 +38944,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 254) { + if (attr.kind === 255) { continue; } var jsxAttr = attr; @@ -37388,7 +38956,7 @@ var ts; return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 255 && !initializer.expression) { + if (initializer && initializer.kind === 256 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -37397,7 +38965,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 226) { + if (forInOrOfStatement.kind === 216 && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 16384) === 0) { + return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + } + } + if (forInOrOfStatement.initializer.kind === 227) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -37405,20 +38978,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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 === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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 === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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); @@ -37445,11 +39018,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 152 ? + return grammarErrorOnNode(accessor.name, kind === 153 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 153) { + else if (kind === 154) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -37468,10 +39041,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 153 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 153 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -37486,7 +39059,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 177) { + if (node.parent.kind === 178) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -37502,10 +39075,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 === 229) { + else if (node.parent.kind === 230) { 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 === 162) { + else if (node.parent.kind === 163) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -37516,9 +39089,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 221: + case 222: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 216 + var isMisplacedContinueLabel = node.kind === 217 && !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); @@ -37526,8 +39099,8 @@ var ts; return false; } break; - case 220: - if (node.kind === 217 && !node.label) { + case 221: + if (node.kind === 218 && !node.label) { return false; } break; @@ -37540,13 +39113,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 217 + var message = node.kind === 218 ? 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 === 217 + var message = node.kind === 218 ? 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); @@ -37558,7 +39131,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 174 || node.name.kind === 173) { + if (node.name.kind === 175 || node.name.kind === 174) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -37568,11 +39141,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 191 && expr.operator === 37 && + expr.kind === 192 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { + if (node.parent.parent.kind !== 215 && node.parent.parent.kind !== 216) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -37607,7 +39180,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 70) { + if (name.kind === 71) { if (ts.unescapeIdentifier(name.text) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -37623,8 +39196,8 @@ var ts; } } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 70) { - if (name.originalKeywordKind === 109) { + if (name.kind === 71) { + if (name.originalKeywordKind === 110) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -37649,15 +39222,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 210: case 211: case 212: - case 219: case 213: + case 220: case 214: case 215: + case 216: return false; - case 221: + case 222: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -37673,9 +39246,9 @@ var ts; } } function checkGrammarMetaProperty(node) { - if (node.keywordToken === 93) { + if (node.keywordToken === 94) { if (node.name.text !== "target") { - return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, ts.tokenToString(node.keywordToken), "target"); } } } @@ -37719,7 +39292,7 @@ var ts; return true; } } - else if (node.parent.kind === 229) { + else if (node.parent.kind === 230) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37727,7 +39300,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 162) { + else if (node.parent.kind === 163) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -37740,13 +39313,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 229 || - node.kind === 230 || + if (node.kind === 230 || + node.kind === 231 || + node.kind === 238 || node.kind === 237 || - node.kind === 236 || + node.kind === 244 || node.kind === 243 || - node.kind === 242 || - node.kind === 235 || + node.kind === 236 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -37755,7 +39328,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 === 207) { + if (ts.isDeclaration(decl) || decl.kind === 208) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -37774,7 +39347,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 === 206 || node.parent.kind === 233 || node.parent.kind === 264) { + if (node.parent.kind === 207 || node.parent.kind === 234 || node.parent.kind === 265) { 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); @@ -37785,19 +39358,19 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral) { + if (node.numericLiteralFlags & 4) { var diagnosticMessage = void 0; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 172)) { + else if (ts.isChildOfNodeWithKind(node, 173)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 263)) { + else if (ts.isChildOfNodeWithKind(node, 264)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 38; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -37825,407 +39398,17 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function reduceNode(node, f, initial) { - return node ? f(initial, node) : initial; - } - function reduceNodeArray(nodes, f, initial) { - return nodes ? f(initial, nodes) : initial; - } - function reduceEachChild(node, initial, cbNode, cbNodeArray) { - if (node === undefined) { - return initial; - } - var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; - var cbNodes = cbNodeArray || cbNode; - var kind = node.kind; - if ((kind > 0 && kind <= 141)) { - return initial; - } - if ((kind >= 157 && kind <= 172)) { - return initial; - } - var result = initial; - switch (node.kind) { - case 205: - case 208: - case 199: - case 224: - case 297: - break; - case 142: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 143: - result = reduceNode(node.expression, cbNode, result); - break; - case 145: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 146: - result = reduceNode(node.expression, cbNode, result); - break; - case 148: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 150: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 151: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 152: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 153: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 173: - case 174: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 175: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 176: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 177: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 178: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 179: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); - break; - case 180: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 181: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 182: - result = reduceNode(node.tag, cbNode, result); - result = reduceNode(node.template, cbNode, result); - break; - case 183: - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 185: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 186: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 184: - case 187: - case 188: - case 189: - case 190: - case 196: - case 197: - case 202: - result = reduceNode(node.expression, cbNode, result); - break; - case 191: - case 192: - result = reduceNode(node.operand, cbNode, result); - break; - case 193: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 194: - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.whenTrue, cbNode, result); - result = reduceNode(node.whenFalse, cbNode, result); - break; - case 195: - result = reduceNode(node.head, cbNode, result); - result = reduceNodes(node.templateSpans, cbNodes, result); - break; - case 198: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 200: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - break; - case 201: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.type, cbNode, result); - break; - case 202: - result = reduceNode(node.expression, cbNode, result); - break; - case 204: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.literal, cbNode, result); - break; - case 206: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 207: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.declarationList, cbNode, result); - break; - case 209: - result = reduceNode(node.expression, cbNode, result); - break; - case 210: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.thenStatement, cbNode, result); - result = reduceNode(node.elseStatement, cbNode, result); - break; - case 211: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 212: - case 219: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 213: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.incrementor, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 214: - case 215: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 218: - case 222: - result = reduceNode(node.expression, cbNode, result); - break; - case 220: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.caseBlock, cbNode, result); - break; - case 221: - result = reduceNode(node.label, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 223: - result = reduceNode(node.tryBlock, cbNode, result); - result = reduceNode(node.catchClause, cbNode, result); - result = reduceNode(node.finallyBlock, cbNode, result); - break; - case 225: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 226: - result = reduceNodes(node.declarations, cbNodes, result); - break; - case 227: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 228: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 231: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 232: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 233: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 234: - result = reduceNodes(node.clauses, cbNodes, result); - break; - case 236: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.moduleReference, cbNode, result); - break; - case 237: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.importClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 238: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.namedBindings, cbNode, result); - break; - case 239: - result = reduceNode(node.name, cbNode, result); - break; - case 240: - case 244: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 241: - case 245: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 242: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 243: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.exportClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 247: - result = reduceNode(node.expression, cbNode, result); - break; - case 248: - result = reduceNode(node.openingElement, cbNode, result); - result = ts.reduceLeft(node.children, cbNode, result); - result = reduceNode(node.closingElement, cbNode, result); - break; - case 249: - case 250: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNode(node.attributes, cbNode, result); - break; - case 251: - result = reduceNode(node.tagName, cbNode, result); - break; - case 253: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 252: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 254: - result = reduceNode(node.expression, cbNode, result); - break; - case 255: - result = reduceNode(node.expression, cbNode, result); - break; - case 256: - result = reduceNode(node.expression, cbNode, result); - case 257: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 258: - result = reduceNodes(node.types, cbNodes, result); - break; - case 259: - result = reduceNode(node.variableDeclaration, cbNode, result); - result = reduceNode(node.block, cbNode, result); - break; - case 260: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 261: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); - break; - case 262: - result = reduceNode(node.expression, cbNode, result); - break; - case 263: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - case 264: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 298: - result = reduceNode(node.expression, cbNode, result); - break; - default: - break; - } - return result; - } - ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift) { + function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; } - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; } var visitedNode; if (visited === undefined) { - if (!optional) { - Debug.failNotOptional(); - } return undefined; } else if (ts.isArray(visited)) { @@ -38234,14 +39417,14 @@ var ts; else { visitedNode = visited; } - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; function visitNodes(nodes, visitor, test, start, count) { - if (nodes === undefined) { - return undefined; + if (nodes === undefined || visitor === undefined) { + return nodes; } var updated; var length = nodes.length; @@ -38256,7 +39439,7 @@ var ts; } for (var i = 0; i < count; i++) { var node = nodes[i + start]; - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -38267,14 +39450,14 @@ var ts; if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - Debug.assertNode(visited, test); - aggregateTransformFlags(visited); + ts.Debug.assertNode(visited, test); + ts.aggregateTransformFlags(visited); updated.push(visited); } } @@ -38293,9 +39476,10 @@ var ts; return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; - function visitParameterList(nodes, visitor, context) { + function visitParameterList(nodes, visitor, context, nodesVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } context.startLexicalEnvironment(); - var updated = visitNodes(nodes, visitor, ts.isParameterDeclaration); + var updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -38306,220 +39490,655 @@ var ts; var declarations = context.endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(updated); - var statements = mergeLexicalEnvironment(block.statements, declarations); + var statements = ts.mergeLexicalEnvironment(block.statements, declarations); return ts.updateBlock(block, statements); } return updated; } ts.visitFunctionBody = visitFunctionBody; - function visitEachChild(node, visitor, context) { + function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (node === undefined) { return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 141)) { - return node; - } - if ((kind >= 157 && kind <= 172)) { + if ((kind > 0 && kind <= 142) || kind === 169) { return node; } switch (node.kind) { - case 205: - case 208: - case 199: - case 224: - return node; - case 142: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 143: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 145: - return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 146: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - case 148: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 150: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 151: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 152: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 153: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 173: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 174: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 175: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 176: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 177: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 178: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 179: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 180: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 182: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 186: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 187: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 190: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 191: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 192: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 194: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 195: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 196: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 200: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 201: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 202: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 206: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 207: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 209: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); - case 211: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 212: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 213: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 214: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 215: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 216: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 217: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 218: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 219: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 220: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 221: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 222: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + case 200: case 225: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 226: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 227: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 228: - return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 231: - return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); - case 232: - return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 233: - return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 234: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236: - return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 237: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 238: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); - case 239: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 240: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 241: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 242: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 243: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); - case 244: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 245: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 247: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 253: - return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 250: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 251: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 252: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 254: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 255: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 256: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 257: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 258: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 259: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); - case 260: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 261: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 262: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 263: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 264: - return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); case 298: + case 247: + return node; + case 143: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 144: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 160: + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 161: + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 155: + return ts.updateCallSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 156: + return ts.updateConstructSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 150: + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + case 157: + return ts.updateIndexSignatureDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 146: + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 147: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 159: + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + case 158: + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 162: + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + case 163: + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor)); + case 164: + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + case 165: + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 166: + case 167: + return ts.updateUnionOrIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 168: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 172: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameter), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 173: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + case 145: + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + case 148: + return ts.updatePropertySignature(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 149: + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 151: + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 152: + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 153: + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 154: + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 174: + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + case 175: + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + case 176: + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + case 177: + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + case 178: + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 179: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 180: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 181: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 182: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 183: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 184: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 185: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 186: + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 187: + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 188: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 189: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 190: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 191: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 194: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 192: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 193: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 195: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 196: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + case 197: + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 198: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 199: + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 201: + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 203: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 205: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 207: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 208: + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 210: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 211: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + case 212: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 213: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 214: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 215: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 216: + return ts.updateForOf(node, node.awaitModifier, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 217: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 218: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 219: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 221: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 222: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 223: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 224: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + case 226: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 227: + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + case 228: + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 229: + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 232: + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + case 233: + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 234: + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 235: + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + case 237: + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 238: + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 239: + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + case 240: + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + case 241: + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + case 242: + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 243: + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 244: + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 245: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 246: + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 248: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); + case 249: + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + case 254: + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + case 250: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 252: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 253: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + case 255: + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + case 256: + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 257: + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + case 258: + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 259: + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 260: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 261: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 262: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 263: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 264: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 265: + return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); + case 296: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: return node; } } ts.visitEachChild = visitEachChild; + function extractSingleNode(nodes) { + ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output."); + return ts.singleOrUndefined(nodes); + } +})(ts || (ts = {})); +(function (ts) { + function reduceNode(node, f, initial) { + return node ? f(initial, node) : initial; + } + function reduceNodeArray(nodes, f, initial) { + return nodes ? f(initial, nodes) : initial; + } + function reduceEachChild(node, initial, cbNode, cbNodeArray) { + if (node === undefined) { + return initial; + } + var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; + var cbNodes = cbNodeArray || cbNode; + var kind = node.kind; + if ((kind > 0 && kind <= 142)) { + return initial; + } + if ((kind >= 158 && kind <= 173)) { + return initial; + } + var result = initial; + switch (node.kind) { + case 206: + case 209: + case 200: + case 225: + case 295: + break; + case 143: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 144: + result = reduceNode(node.expression, cbNode, result); + break; + case 146: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 147: + result = reduceNode(node.expression, cbNode, result); + break; + case 149: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 151: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 152: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 154: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 174: + case 175: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 176: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 177: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 178: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 179: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 180: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 183: + result = reduceNode(node.tag, cbNode, result); + result = reduceNode(node.template, cbNode, result); + break; + case 184: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 186: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 187: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 185: + case 188: + case 189: + case 190: + case 191: + case 197: + case 198: + case 203: + result = reduceNode(node.expression, cbNode, result); + break; + case 192: + case 193: + result = reduceNode(node.operand, cbNode, result); + break; + case 194: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 195: + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.whenTrue, cbNode, result); + result = reduceNode(node.whenFalse, cbNode, result); + break; + case 196: + result = reduceNode(node.head, cbNode, result); + result = reduceNodes(node.templateSpans, cbNodes, result); + break; + case 199: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + break; + case 202: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 203: + result = reduceNode(node.expression, cbNode, result); + break; + case 205: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.literal, cbNode, result); + break; + case 207: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 208: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.declarationList, cbNode, result); + break; + case 210: + result = reduceNode(node.expression, cbNode, result); + break; + case 211: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.thenStatement, cbNode, result); + result = reduceNode(node.elseStatement, cbNode, result); + break; + case 212: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 213: + case 220: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 214: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.incrementor, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 215: + case 216: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 219: + case 223: + result = reduceNode(node.expression, cbNode, result); + break; + case 221: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.caseBlock, cbNode, result); + break; + case 222: + result = reduceNode(node.label, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 224: + result = reduceNode(node.tryBlock, cbNode, result); + result = reduceNode(node.catchClause, cbNode, result); + result = reduceNode(node.finallyBlock, cbNode, result); + break; + case 226: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 227: + result = reduceNodes(node.declarations, cbNodes, result); + break; + case 228: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 229: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 233: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 234: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 235: + result = reduceNodes(node.clauses, cbNodes, result); + break; + case 237: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 238: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.importClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 239: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); + break; + case 240: + result = reduceNode(node.name, cbNode, result); + break; + case 241: + case 245: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 242: + case 246: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 243: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 244: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.exportClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 248: + result = reduceNode(node.expression, cbNode, result); + break; + case 249: + result = reduceNode(node.openingElement, cbNode, result); + result = ts.reduceLeft(node.children, cbNode, result); + result = reduceNode(node.closingElement, cbNode, result); + break; + case 250: + case 251: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 254: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: + result = reduceNode(node.tagName, cbNode, result); + break; + case 253: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 255: + result = reduceNode(node.expression, cbNode, result); + break; + case 256: + result = reduceNode(node.expression, cbNode, result); + break; + case 257: + result = reduceNode(node.expression, cbNode, result); + case 258: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 259: + result = reduceNodes(node.types, cbNodes, result); + break; + case 260: + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); + break; + case 261: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 262: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); + break; + case 263: + result = reduceNode(node.expression, cbNode, result); + break; + case 264: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 265: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 296: + result = reduceNode(node.expression, cbNode, result); + break; + default: + break; + } + return result; + } + ts.reduceEachChild = reduceEachChild; function mergeLexicalEnvironment(statements, declarations) { if (!ts.some(declarations)) { return statements; @@ -38529,27 +40148,11 @@ var ts; : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; - function mergeFunctionBodyLexicalEnvironment(body, declarations) { - if (body && declarations !== undefined && declarations.length > 0) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); - } - else { - return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); - } - } - return body; - } - ts.mergeFunctionBodyLexicalEnvironment = mergeFunctionBodyLexicalEnvironment; function liftToBlock(nodes) { Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block."); return ts.singleOrUndefined(nodes) || ts.createBlock(nodes); } ts.liftToBlock = liftToBlock; - function extractSingleNode(nodes) { - Debug.assert(nodes.length <= 1, "Too many nodes written to output."); - return ts.singleOrUndefined(nodes); - } function aggregateTransformFlags(node) { aggregateTransformFlagsForNode(node); return node; @@ -38580,7 +40183,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 201)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -38593,9 +40196,6 @@ var ts; } var Debug; (function (Debug) { - Debug.failNotOptional = Debug.shouldAssert(1) - ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : ts.noop; @@ -38636,7 +40236,7 @@ var ts; var value; if (ts.isDestructuringAssignment(node)) { value = node.right; - while (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) { if (ts.isDestructuringAssignment(value)) { location = node = value; value = node.right; @@ -38650,6 +40250,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -38697,6 +40298,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -38814,7 +40416,12 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + if (flattenContext.level < 1 && flattenContext.downlevelIteration) { + value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) + ? undefined + : numElements, location), false, location); + } + else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -38953,8 +40560,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178); context.enableSubstitution(179); + context.enableSubstitution(180); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -38987,15 +40594,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 264: + case 265: + case 235: case 234: - case 233: - case 206: + case 207: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 229: case 228: - case 227: if (ts.hasModifier(node, 2)) { break; } @@ -39020,13 +40627,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 242: - return visitExportAssignment(node); case 243: + return visitExportAssignment(node); + case 244: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -39036,11 +40643,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 243 || - node.kind === 237 || + if (node.kind === 244 || node.kind === 238 || - (node.kind === 236 && - node.moduleReference.kind === 247)) { + node.kind === 239 || + (node.kind === 237 && + node.moduleReference.kind === 248)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -39056,15 +40663,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 151: - return undefined; - case 148: - case 156: case 152: + return undefined; + case 149: + case 157: case 153: - case 150: + case 154: + case 151: return visitorWorker(node); - case 205: + case 206: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -39075,7 +40682,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270) { return undefined; } - else if (currentNamespace && node.kind === 83) { + else if (currentNamespace && node.kind === 84) { return undefined; } return node; @@ -39085,33 +40692,32 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return currentNamespace ? undefined : node; - case 113: - case 111: + case 114: case 112: - case 116: - case 75: - case 123: - case 130: - case 163: + case 113: + case 117: + case 76: + case 124: + case 131: case 164: - case 162: - case 157: - case 144: - case 118: - case 121: - case 135: - case 132: - case 129: - case 104: - case 136: - case 160: - case 159: - case 161: - case 158: case 165: + case 163: + case 158: + case 145: + case 119: + case 122: + case 136: + case 133: + case 130: + case 105: + case 137: + case 161: + case 160: + case 162: + case 159: case 166: case 167: case 168: @@ -39119,57 +40725,58 @@ var ts; case 170: case 171: case 172: - case 156: - case 146: - case 230: - case 148: - return undefined; - case 151: - return visitConstructor(node); - case 229: - return ts.createNotEmittedStatement(node); - case 228: - return visitClassDeclaration(node); - case 198: - return visitClassExpression(node); - case 258: - return visitHeritageClause(node); - case 200: - return visitExpressionWithTypeArguments(node); - case 150: - return visitMethodDeclaration(node); - case 152: - return visitGetAccessor(node); - case 153: - return visitSetAccessor(node); - case 227: - return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); - case 186: - return visitArrowFunction(node); - case 145: - return visitParameter(node); - case 184: - return visitParenthesizedExpression(node); - case 183: - case 201: - return visitAssertionExpression(node); - case 180: - return visitCallExpression(node); - case 181: - return visitNewExpression(node); - case 202: - return visitNonNullExpression(node); + case 173: + case 157: + case 147: case 231: - return visitEnumDeclaration(node); - case 207: - return visitVariableStatement(node); - case 225: - return visitVariableDeclaration(node); + case 149: + return undefined; + case 152: + return visitConstructor(node); + case 230: + return ts.createNotEmittedStatement(node); + case 229: + return visitClassDeclaration(node); + case 199: + return visitClassExpression(node); + case 259: + return visitHeritageClause(node); + case 201: + return visitExpressionWithTypeArguments(node); + case 151: + return visitMethodDeclaration(node); + case 153: + return visitGetAccessor(node); + case 154: + return visitSetAccessor(node); + case 228: + return visitFunctionDeclaration(node); + case 186: + return visitFunctionExpression(node); + case 187: + return visitArrowFunction(node); + case 146: + return visitParameter(node); + case 185: + return visitParenthesizedExpression(node); + case 184: + case 202: + return visitAssertionExpression(node); + case 181: + return visitCallExpression(node); + case 182: + return visitNewExpression(node); + case 203: + return visitNonNullExpression(node); case 232: + return visitEnumDeclaration(node); + case 208: + return visitVariableStatement(node); + case 226: + return visitVariableDeclaration(node); + case 233: return visitModuleDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -39177,7 +40784,8 @@ var ts; } } function visitSourceFile(node) { - var alwaysStrict = compilerOptions.alwaysStrict && !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && + !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -39198,7 +40806,7 @@ var ts; var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -39224,7 +40832,7 @@ var ts; } if (statements.length > 1) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 2097152); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304); } return ts.singleOrMany(statements); } @@ -39259,7 +40867,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85; })); var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, node); @@ -39270,7 +40878,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - ts.setEmitFlags(classExpression, 32768 | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -39319,18 +40927,18 @@ var ts; if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } - ts.addRange(statements, endLexicalEnvironment()); + statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { var statements = ctor.body.statements; - var index = ts.addPrologueDirectives(result, statements, false, visitor); + var index = ts.addPrologue(result, statements, false, visitor); if (index === statements.length) { return index; } var statement = statements[index]; - if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -39364,13 +40972,13 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 148 + return member.kind === 149 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { - var property = properties_8[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -39379,8 +40987,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -39437,12 +41045,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 152: case 153: + case 154: return getAllDecoratorsOfAccessors(node, member); - case 150: + case 151: return getAllDecoratorsOfMethod(member); - case 148: + case 149: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -39521,7 +41129,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 148 + ? member.kind === 149 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -39590,13 +41198,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); @@ -39605,37 +41213,37 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 150 - || kind === 152 + return kind === 151 || kind === 153 - || kind === 148; + || kind === 154 + || kind === 149; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 150; + return node.kind === 151; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 228: - case 198: + case 229: + case 199: return ts.getFirstConstructorWithBody(node) !== undefined; - case 150: - case 152: + case 151: case 153: + case 154: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 148: - case 145: - case 152: - return serializeTypeNode(node.type); + case 149: + case 146: case 153: + return serializeTypeNode(node.type); + case 154: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 228: - case 198: - case 150: + case 229: + case 199: + case 151: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -39667,7 +41275,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 152) { + if (container && node.kind === 153) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -39679,7 +41287,7 @@ var ts; if (ts.isFunctionLike(node) && node.type) { return serializeTypeNode(node.type); } - else if (ts.isAsyncFunctionLike(node)) { + else if (ts.isAsyncFunction(node)) { return ts.createIdentifier("Promise"); } return ts.createVoidZero(); @@ -39689,56 +41297,58 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 104: - case 138: - case 94: - case 129: + case 105: + case 139: + case 95: + case 130: return ts.createVoidZero(); - case 167: + case 168: return serializeTypeNode(node.type); - case 159: case 160: + case 161: return ts.createIdentifier("Function"); - case 163: case 164: + case 165: return ts.createIdentifier("Array"); - case 157: - case 121: + case 158: + case 122: return ts.createIdentifier("Boolean"); - case 135: + case 136: return ts.createIdentifier("String"); - case 172: + case 134: + return ts.createIdentifier("Object"); + case 173: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 100: - case 85: + case 101: + case 86: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 132: + case 133: return ts.createIdentifier("Number"); - case 136: + case 137: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 158: + case 159: return serializeTypeReferenceNode(node); + case 167: case 166: - case 165: return serializeUnionOrIntersectionType(node); - case 161: - case 169: + case 162: case 170: case 171: - case 162: - case 118: - case 168: + case 172: + case 163: + case 119: + case 169: break; default: ts.Debug.failBadSyntaxKind(node); @@ -39805,7 +41415,7 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 70: + case 71: var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; @@ -39814,13 +41424,13 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 142: + case 143: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 70) { + if (node.left.kind === 71) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -39865,9 +41475,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 84) { + if (node.token === 85) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(84, types), node); + return ts.setTextRange(ts.createHeritageClause(85, types), node); } return undefined; } @@ -39881,13 +41491,13 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - return ts.visitEachChild(node, visitor, context); + return ts.updateConstructor(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context)); } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); if (updated !== node) { ts.setCommentRange(updated, node); ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); @@ -39923,7 +41533,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); + var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); if (isNamespaceExport(node)) { var statements = [updated]; addExportMemberAssignment(statements, node); @@ -39932,10 +41542,10 @@ var ts; return updated; } function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { + if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createOmittedExpression(); } - var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); return updated; } function visitArrowFunction(node) { @@ -40099,20 +41709,20 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 231) { + if (node.kind === 232) { ts.setSourceMapRange(statement.declarationList, node); } else { ts.setSourceMapRange(statement, node); } ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 1024 | 2097152); + ts.setEmitFlags(statement, 1024 | 4194304); statements.push(statement); return true; } else { var mergeMarker = ts.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 | 2097152); + ts.setEmitFlags(mergeMarker, 1536 | 4194304); statements.push(mergeMarker); return false; } @@ -40160,7 +41770,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 233) { + if (body.kind === 234) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -40184,13 +41794,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 233) { + if (body.kind !== 234) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 232) { + if (moduleDeclaration.body.kind === 233) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -40199,18 +41809,18 @@ var ts; if (!node.importClause) { return node; } - var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) : undefined; } function visitImportClause(node) { var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; - var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings); return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 239) { + if (node.kind === 240) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -40233,7 +41843,7 @@ var ts; if (!resolver.isValueAliasDeclaration(node)) { return undefined; } - var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports); return exportClause ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) : undefined; @@ -40331,32 +41941,36 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(70); + context.enableSubstitution(71); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(70); + context.enableSubstitution(71); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(70); - context.enableSubstitution(261); - context.enableEmitNotification(232); + context.enableSubstitution(71); + context.enableSubstitution(262); + context.enableEmitNotification(233); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 232; + return ts.getOriginalNode(node).kind === 233; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 231; + return ts.getOriginalNode(node).kind === 232; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSourceFile = currentSourceFile; + if (ts.isSourceFile(node)) { + currentSourceFile = node; + } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -40365,6 +41979,7 @@ var ts; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; + currentSourceFile = savedCurrentSourceFile; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); @@ -40392,11 +42007,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 178: - return substitutePropertyAccessExpression(node); case 179: + return substitutePropertyAccessExpression(node); + case 180: return substituteElementAccessExpression(node); } return node; @@ -40426,9 +42041,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 264) { - var substitute = (applicableSubstitutions & 2 && container.kind === 232) || - (applicableSubstitutions & 8 && container.kind === 231); + if (container && container.kind !== 265) { + var substitute = (applicableSubstitutions & 2 && container.kind === 233) || + (applicableSubstitutions & 8 && container.kind === 232); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -40445,16 +42060,14 @@ var ts; function substituteConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { + ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); - ts.setSourceMapRange(substitute, node); - ts.setCommentRange(substitute, node); if (!compilerOptions.removeComments) { var propertyName = ts.isPropertyAccessExpression(node) ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - substitute.trailingComment = " " + propertyName + " "; + ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " "); } - ts.setConstantValue(node, constantValue); return substitute; } return node; @@ -40469,40 +42082,7 @@ var ts; } } ts.transformTypeScript = transformTypeScript; - var paramHelper = { - name: "typescript:param", - scoped: false, - priority: 4, - text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" - }; - function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ - ts.createLiteral(parameterOffset), - expression - ]), location); - } - var metadataHelper = { - name: "typescript:metadata", - scoped: false, - priority: 3, - text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" - }; - function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), undefined, [ - ts.createLiteral(metadataKey), - metadataValue - ]); - } - var decorateHelper = { - name: "typescript:decorate", - scoped: false, - priority: 2, - text: "\n var __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 };" - }; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { - context.requestEmitHelper(decorateHelper); var argumentsArray = []; argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); @@ -40512,13 +42092,297 @@ var ts; argumentsArray.push(descriptor); } } + context.requestEmitHelper(decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } + var decorateHelper = { + name: "typescript:decorate", + scoped: false, + priority: 2, + text: "\n var __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 };" + }; + function createMetadataHelper(context, metadataKey, metadataValue) { + context.requestEmitHelper(metadataHelper); + return ts.createCall(ts.getHelperName("__metadata"), undefined, [ + ts.createLiteral(metadataKey), + metadataValue + ]); + } + var metadataHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" + }; + function createParamHelper(context, expression, parameterOffset, location) { + context.requestEmitHelper(paramHelper); + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ + ts.createLiteral(parameterOffset), + expression + ]), location); + } + var paramHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" + }; +})(ts || (ts = {})); +var ts; +(function (ts) { + function transformES2017(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFile; + var enabledSubstitutions; + var enclosingSuperContainerFlags = 0; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; + } + function visitor(node) { + if ((node.transformFlags & 16) === 0) { + return node; + } + switch (node.kind) { + case 120: + return undefined; + case 191: + return visitAwaitExpression(node); + case 151: + return visitMethodDeclaration(node); + case 228: + return visitFunctionDeclaration(node); + case 186: + return visitFunctionExpression(node); + case 187: + return visitArrowFunction(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); + } + function visitMethodDeclaration(node) { + return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitFunctionDeclaration(node) { + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitFunctionExpression(node) { + return ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitArrowFunction(node) { + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function transformAsyncFunctionBody(node) { + resumeLexicalEnvironment(); + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 187; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; + } + else { + var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); + var declarations = endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(expression); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); + } + return expression; + } + } + function transformFunctionBodyWorker(body, start) { + if (ts.isBlock(body)) { + return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); + } + else { + startLexicalEnvironment(); + var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); + var declarations = endLexicalEnvironment(); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); + } + } + function getPromiseConstructor(type) { + var typeName = type && ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(181); + context.enableSubstitution(179); + context.enableSubstitution(180); + context.enableEmitNotification(229); + context.enableEmitNotification(151); + context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(152); + } + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179: + return substitutePropertyAccessExpression(node); + case 180: + return substituteElementAccessExpression(node); + case 181: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 + || kind === 152 + || kind === 151 + || kind === 153 + || kind === 154; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); + } + } + } + ts.transformES2017 = transformES2017; + var awaiterHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: "\n var __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 };" + }; + function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + context.requestEmitHelper(awaiterHelper); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(39), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; + return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ + ts.createThis(), + hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), + promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), + generatorFunc + ]); + } + ts.asyncSuperHelper = { + name: "typescript:async-super", + scoped: true, + text: "\n const _super = name => super[name];\n " + }; + ts.advancedAsyncSuperHelper = { + name: "typescript:advanced-async-super", + scoped: true, + text: "\n const _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);\n " + }; })(ts || (ts = {})); var ts; (function (ts) { function transformESNext(context) { - var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + var enabledSubstitutions; + var enclosingFunctionFlags; + var enclosingSuperContainerFlags = 0; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -40534,53 +42398,93 @@ var ts; function visitorNoDestructuringValue(node) { return visitorWorker(node, true); } + function visitorNoAsyncModifier(node) { + if (node.kind === 120) { + return undefined; + } + return node; + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 8) === 0) { return node; } switch (node.kind) { - case 177: + case 191: + return visitAwaitExpression(node); + case 197: + return visitYieldExpression(node); + case 222: + return visitLabeledStatement(node); + case 178: return visitObjectLiteralExpression(node); - case 193: + case 194: return visitBinaryExpression(node, noDestructuringValue); - case 225: + case 226: return visitVariableDeclaration(node); - case 215: - return visitForOfStatement(node); - case 213: + case 216: + return visitForOfStatement(node, undefined); + case 214: return visitForStatement(node); - case 189: + case 190: return visitVoidExpression(node); - case 151: - return visitConstructorDeclaration(node); - case 150: - return visitMethodDeclaration(node); case 152: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 151: + return visitMethodDeclaration(node); case 153: + return visitGetAccessorDeclaration(node); + case 154: return visitSetAccessorDeclaration(node); - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); case 186: + return visitFunctionExpression(node); + case 187: return visitArrowFunction(node); - case 145: + case 146: return visitParameter(node); - case 209: + case 210: return visitExpressionStatement(node); - case 184: + case 185: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); } } + function visitAwaitExpression(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.createArrayLiteral([ts.createLiteral("await"), expression])), node), node); + } + return ts.visitEachChild(node, visitor, context); + } + function visitYieldExpression(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.updateYield(node, node.asteriskToken, node.asteriskToken + ? createAsyncDelegatorHelper(context, expression, expression) + : ts.createArrayLiteral(expression + ? [ts.createLiteral("yield"), expression] + : [ts.createLiteral("yield")])); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var statement = ts.unwrapInnermostStatementOfLabel(node); + if (statement.kind === 216 && statement.awaitModifier) { + return visitForOfStatement(statement, node); + } + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), node); + } + return ts.visitEachChild(node, visitor, context); + } function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 262) { + if (e.kind === 263) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -40592,7 +42496,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 260) { + if (e.kind === 261) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -40609,7 +42513,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 177) { + if (objects.length && objects[0].kind !== 178) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -40626,7 +42530,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); } - else if (node.operatorToken.kind === 25) { + else if (node.operatorToken.kind === 26) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -40643,69 +42547,202 @@ var ts; function visitVoidExpression(node) { return ts.visitEachChild(node, visitorNoDestructuringValue, context); } - function visitForOfStatement(node) { - var leadingStatements; - var temp; - var initializer = ts.skipParentheses(node.initializer); - if (initializer.transformFlags & 1048576) { - if (ts.isVariableDeclarationList(initializer)) { - temp = ts.createTempVariable(undefined); - var firstDeclaration = ts.firstOrUndefined(initializer.declarations); - var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); - if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); - ts.setTextRange(statement, initializer); - leadingStatements = ts.append(leadingStatements, statement); - } - } - else if (ts.isAssignmentPattern(initializer)) { - temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); - } + function visitForOfStatement(node, outermostLabeledStatement) { + if (node.initializer.transformFlags & 1048576) { + node = transformForOfStatementWithObjectRest(node); } - if (temp) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) - : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); - return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + if (node.awaitModifier) { + return transformForAwaitOfStatement(node, outermostLabeledStatement); + } + else { + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); + } + } + function transformForOfStatementWithObjectRest(node) { + var initializerWithoutParens = ts.skipParentheses(node.initializer); + if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) { + var bodyLocation = void 0; + var statementsLocation = void 0; + var temp = ts.createTempVariable(undefined); + var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)]; + if (ts.isBlock(node.statement)) { + ts.addRange(statements, node.statement.statements); + bodyLocation = node.statement; + statementsLocation = node.statement.statements; + } + return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) - ], 1), node.initializer), expression, block); + ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation)); } - return ts.visitEachChild(node, visitor, context); + return node; + } + function convertForOfStatementHead(node, boundValue) { + var binding = ts.createForOfBindingStatement(node.initializer, boundValue); + var bodyLocation; + var statementsLocation; + var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384); + } + function transformForAwaitOfStatement(node, outermostLabeledStatement) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(undefined); + var values = createAsyncValuesHelper(context, expression, node.expression); + var next = ts.createYield(undefined, enclosingFunctionFlags & 1 + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []) + ]) + : ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, [])); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression), + ts.createVariableDeclaration(result, undefined, next) + ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"))), node), 256); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1)), ts.createBlock([ + ts.createTry(ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createYield(undefined, enclosingFunctionFlags & 1 + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createFunctionCall(returnMethod, iterator, []) + ]) + : ts.createFunctionCall(returnMethod, iterator, [])))), 1) + ]), undefined, ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) + ]), 1)) + ])); } function visitParameter(node) { if (node.transformFlags & 1048576) { - return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } function visitConstructorDeclaration(node) { - return ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitGetAccessorDeclaration(node) { - return ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitSetAccessorDeclaration(node) { - return ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitMethodDeclaration(node) { - return ts.updateMethod(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(undefined, visitor, ts.isToken), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; + } + function transformAsyncGeneratorFunctionBody(node) { + resumeLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); + appendObjectRestAssignmentsIfNeeded(statements, node); + statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(39), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.updateBlock(node.body, statements); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; } function transformFunctionBody(node) { resumeLexicalEnvironment(); - var leadingStatements; + var statementOffset = 0; + var statements = []; + var body = ts.visitNode(node.body, visitor, ts.isConciseBody); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologue(statements, body.statements, false, visitor); + } + ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node)); + var trailingStatements = endLexicalEnvironment(); + if (statementOffset > 0 || ts.some(statements) || ts.some(trailingStatements)) { + var block = ts.convertToFunctionBody(body, true); + ts.addRange(statements, block.statements.slice(statementOffset)); + ts.addRange(statements, trailingStatements); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); + } + return body; + } + function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; if (parameter.transformFlags & 1048576) { @@ -40713,18 +42750,96 @@ var ts; var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations)); - ts.setEmitFlags(statement, 524288); - leadingStatements = ts.append(leadingStatements, statement); + ts.setEmitFlags(statement, 1048576); + statements = ts.append(statements, statement); } } } - var body = ts.visitNode(node.body, visitor, ts.isConciseBody); - var trailingStatements = endLexicalEnvironment(); - if (ts.some(leadingStatements) || ts.some(trailingStatements)) { - var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); + return statements; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(181); + context.enableSubstitution(179); + context.enableSubstitution(180); + context.enableEmitNotification(229); + context.enableEmitNotification(151); + context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(152); + } + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179: + return substitutePropertyAccessExpression(node); + case 180: + return substituteElementAccessExpression(node); + case 181: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 + || kind === 152 + || kind === 151 + || kind === 153 + || kind === 154; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } - return body; } } ts.transformESNext = transformESNext; @@ -40742,21 +42857,51 @@ var ts; return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; + var asyncGeneratorHelper = { + name: "typescript:asyncGenerator", + scoped: false, + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + }; + function createAsyncGeneratorHelper(context, generatorFunc) { + context.requestEmitHelper(asyncGeneratorHelper); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; + return ts.createCall(ts.getHelperName("__asyncGenerator"), undefined, [ + ts.createThis(), + ts.createIdentifier("arguments"), + generatorFunc + ]); + } + var asyncDelegator = { + name: "typescript:asyncDelegator", + scoped: false, + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " + }; + function createAsyncDelegatorHelper(context, expression, location) { + context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); + } + var asyncValues = { + name: "typescript:asyncValues", + scoped: false, + text: "\n var __asyncValues = (this && this.__asyncIterator) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator];\n return m ? m.call(o) : typeof __values === \"function\" ? __values(o) : o[Symbol.iterator]();\n };\n " + }; + function createAsyncValuesHelper(context, expression, location) { + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), undefined, [expression]), location); + } })(ts || (ts = {})); var ts; (function (ts) { function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -40769,11 +42914,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 248: - return visitJsxElement(node, false); case 249: + return visitJsxElement(node, false); + case 250: return visitJsxSelfClosingElement(node, false); - case 255: + case 256: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -40783,11 +42928,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 255: + case 256: return visitJsxExpression(node); - case 248: - return visitJsxElement(node, true); case 249: + return visitJsxElement(node, true); + case 250: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -40841,7 +42986,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 255) { + else if (node.kind === 256) { if (node.expression === undefined) { return ts.createTrue(); } @@ -40901,7 +43046,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 248) { + if (node.kind === 249) { return getTagName(node.openingElement); } else { @@ -41185,264 +43330,6 @@ var ts; }); })(ts || (ts = {})); var ts; -(function (ts) { - function transformES2017(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var resolver = context.getEmitResolver(); - var compilerOptions = context.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFile; - var enabledSubstitutions; - var currentSuperContainer; - var previousOnEmitNode = context.onEmitNode; - var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - var visited = ts.visitEachChild(node, visitor, context); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; - return visited; - } - function visitor(node) { - if ((node.transformFlags & 16) === 0) { - return node; - } - switch (node.kind) { - case 119: - return undefined; - case 190: - return visitAwaitExpression(node); - case 150: - return visitMethodDeclaration(node); - case 227: - return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); - case 186: - return visitArrowFunction(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); - } - function visitMethodDeclaration(node) { - return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { - return ts.createOmittedExpression(); - } - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function transformAsyncFunctionBody(node) { - resumeLexicalEnvironment(); - var original = ts.getOriginalNode(node, ts.isFunctionLike); - var nodeType = original.type; - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 186; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, true); - ts.setTextRange(block, node.body); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, advancedAsyncSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, asyncSuperHelper); - } - } - return block; - } - else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); - var declarations = endLexicalEnvironment(); - if (ts.some(declarations)) { - var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); - } - return expression; - } - } - function transformFunctionBodyWorker(body, start) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); - } - else { - startLexicalEnvironment(); - var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); - var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); - } - } - function getPromiseConstructor(type) { - var typeName = type && ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1) === 0) { - enabledSubstitutions |= 1; - context.enableSubstitution(180); - context.enableSubstitution(178); - context.enableSubstitution(179); - context.enableEmitNotification(228); - context.enableEmitNotification(150); - context.enableEmitNotification(152); - context.enableEmitNotification(153); - context.enableEmitNotification(151); - } - } - function substituteExpression(node) { - switch (node.kind) { - case 178: - return substitutePropertyAccessExpression(node); - case 179: - return substituteElementAccessExpression(node); - case 180: - if (enabledSubstitutions & 1) { - return substituteCallExpression(node); - } - break; - } - return node; - } - function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 1 && node.expression.kind === 96) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } - return node; - } - function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 1 && node.expression.kind === 96) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } - return node; - } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 228 - || kind === 151 - || kind === 150 - || kind === 152 - || kind === 153; - } - function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 && isSuperContainer(node)) { - var savedCurrentSuperContainer = currentSuperContainer; - currentSuperContainer = node; - previousOnEmitNode(hint, node, emitCallback); - currentSuperContainer = savedCurrentSuperContainer; - } - else { - previousOnEmitNode(hint, node, emitCallback); - } - } - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (hint === 1) { - return substituteExpression(node); - } - return node; - } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); - } - else { - return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } - } - ts.transformES2017 = transformES2017; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); - var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(38), undefined, undefined, [], undefined, body); - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 131072; - return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ - ts.createThis(), - hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), - promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), - generatorFunc - ]); - } - var awaiterHelper = { - name: "typescript:awaiter", - scoped: false, - priority: 5, - text: "\n var __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 asyncSuperHelper = { - name: "typescript:async-super", - scoped: true, - text: "\n const _super = name => super[name];" - }; - var advancedAsyncSuperHelper = { - name: "typescript:advanced-async-super", - scoped: true, - text: "\n const _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);" - }; -})(ts || (ts = {})); -var ts; (function (ts) { function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; @@ -41458,7 +43345,7 @@ var ts; return node; } switch (node.kind) { - case 193: + case 194: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41466,9 +43353,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 61: + case 62: return visitExponentiationAssignmentExpression(node); - case 39: + case 40: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41508,6 +43395,7 @@ var ts; (function (ts) { function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -41542,7 +43430,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 - && node.kind === 218 + && node.kind === 219 && !node.expression; } function shouldVisitNode(node) { @@ -41566,100 +43454,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 96) { + if (node.kind === 97) { return visitSuperKeyword(true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 114: + case 115: return undefined; - case 228: + case 229: return visitClassDeclaration(node); - case 198: + case 199: return visitClassExpression(node); - case 145: + case 146: return visitParameter(node); - case 227: + case 228: return visitFunctionDeclaration(node); - case 186: + case 187: return visitArrowFunction(node); - case 185: + case 186: return visitFunctionExpression(node); - case 225: - return visitVariableDeclaration(node); - case 70: - return visitIdentifier(node); case 226: + return visitVariableDeclaration(node); + case 71: + return visitIdentifier(node); + case 227: return visitVariableDeclarationList(node); - case 220: - return visitSwitchStatement(node); - case 234: - return visitCaseBlock(node); - case 206: - return visitBlock(node, false); - case 217: - case 216: - return visitBreakOrContinueStatement(node); case 221: + return visitSwitchStatement(node); + case 235: + return visitCaseBlock(node); + case 207: + return visitBlock(node, false); + case 218: + case 217: + return visitBreakOrContinueStatement(node); + case 222: return visitLabeledStatement(node); - case 211: case 212: - return visitDoOrWhileStatement(node, undefined); case 213: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 214: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 215: + return visitForInStatement(node, undefined); + case 216: return visitForOfStatement(node, undefined); - case 209: + case 210: return visitExpressionStatement(node); - case 177: + case 178: return visitObjectLiteralExpression(node); - case 259: + case 260: return visitCatchClause(node); - case 261: + case 262: return visitShorthandPropertyAssignment(node); - case 143: + case 144: return visitComputedPropertyName(node); - case 176: + case 177: return visitArrayLiteralExpression(node); - case 180: - return visitCallExpression(node); case 181: + return visitCallExpression(node); + case 182: return visitNewExpression(node); - case 184: + case 185: return visitParenthesizedExpression(node, true); - case 193: + case 194: return visitBinaryExpression(node, true); - case 12: case 13: case 14: case 15: + case 16: return visitTemplateLiteral(node); - case 182: + case 9: + return visitStringLiteral(node); + case 8: + return visitNumericLiteral(node); + case 183: return visitTaggedTemplateExpression(node); - case 195: - return visitTemplateExpression(node); case 196: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 197: + return visitYieldExpression(node); + case 198: return visitSpreadElement(node); - case 96: + case 97: return visitSuperKeyword(false); - case 98: + case 99: return visitThisKeyword(node); - case 203: + case 204: return visitMetaProperty(node); - case 150: + case 151: return visitMethodDeclaration(node); - case 152: case 153: + case 154: return visitAccessorDeclaration(node); - case 207: + case 208: return visitVariableStatement(node); - case 218: + case 219: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -41669,8 +43561,9 @@ var ts; var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); + var statementOffset = ts.addStandardPrologue(statements, node.statements, false); addCaptureThisForNodeIfNeeded(statements, node); + statementOffset = ts.addCustomPrologue(statements, node.statements, statementOffset, visitor); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); @@ -41736,13 +43629,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 217 ? 2 : 4; + var jump = node.kind === 218 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 217) { + if (node.kind === 218) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -41752,7 +43645,7 @@ var ts; } } else { - if (node.kind === 217) { + if (node.kind === 218) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -41771,10 +43664,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 25, copyExpr); + expr = ts.createBinary(expr, 26, copyExpr); } } - returnExpression = ts.createBinary(expr, 25, returnExpression); + returnExpression = ts.createBinary(expr, 26, returnExpression); } return ts.createReturn(returnExpression); } @@ -41798,9 +43691,9 @@ var ts; statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 2097152) === 0) { + if ((emitFlags & 4194304) === 0) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 2097152); + ts.setEmitFlags(statement, emitFlags | 4194304); } return ts.singleOrMany(statements); } @@ -41813,8 +43706,8 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (ts.getEmitFlags(node) & 32768) { - ts.setEmitFlags(classFunction, 32768); + if (ts.getEmitFlags(node) & 65536) { + ts.setEmitFlags(classFunction, 65536); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; @@ -41832,8 +43725,8 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); - var localName = ts.getLocalName(node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18); + var localName = ts.getInternalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; ts.setEmitFlags(outer, 1536); @@ -41857,7 +43750,7 @@ var ts; var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); @@ -41878,14 +43771,17 @@ var ts; statementOffset = 0; } else if (constructor) { - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + statementOffset = ts.addStandardPrologue(statements, constructor.body.statements, false); } if (constructor) { addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + if (!hasSynthesizedSuper) { + statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor); + } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; @@ -41913,17 +43809,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 218) { + if (statement.kind === 219) { return true; } - else if (statement.kind === 210) { + else if (statement.kind === 211) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 206) { + else if (statement.kind === 207) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -41952,7 +43848,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 210 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -41960,8 +43856,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 193 - || superCallExpression.left.kind !== 180) { + if (superCallExpression.kind !== 194 + || superCallExpression.left.kind !== 181) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -42018,10 +43914,10 @@ var ts; function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 524288)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 1048576)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 524288)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { @@ -42031,11 +43927,11 @@ var ts; ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 | 32 | 524288); + ts.setEmitFlags(statement, 384 | 32 | 1048576); statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 71 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -42049,7 +43945,7 @@ var ts; var temp = ts.createLoopVariable(); statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ])), parameter), 524288)); + ])), parameter), 1048576)); var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ @@ -42057,12 +43953,12 @@ var ts; ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); - ts.setEmitFlags(forStatement, 524288); + ts.setEmitFlags(forStatement, 1048576); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 186) { + if (node.transformFlags & 32768 && node.kind !== 187) { captureThisForNode(statements, node, ts.createThis()); } } @@ -42071,7 +43967,7 @@ var ts; var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setEmitFlags(captureThisStatement, 1536 | 1048576); ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); @@ -42080,19 +43976,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 186: + case 187: return statements; - case 150: - case 152: + case 151: case 153: + case 154: newTarget = ts.createVoidZero(); break; - case 151: + case 152: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 227: - case 185: - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + case 228: + case 186: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: ts.Debug.failBadSyntaxKind(node); @@ -42112,20 +44008,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 205: + case 206: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 150: + case 151: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 152: case 153: + case 154: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 151: + case 152: break; default: ts.Debug.failBadSyntaxKind(node); @@ -42211,7 +44107,7 @@ var ts; return func; } function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 131072 + var ancestorFacts = ts.getEmitFlags(node) & 262144 ? enterSubtree(16278, 69) : enterSubtree(16286, 65); var savedConvertedLoopState = convertedLoopState; @@ -42225,7 +44121,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); + return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; @@ -42240,7 +44136,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body); } function transformFunctionLikeToExpression(node, location, name, container) { var savedConvertedLoopState = convertedLoopState; @@ -42250,7 +44146,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 228 || node.kind === 186)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -42267,7 +44163,7 @@ var ts; var statementOffset; resumeLexicalEnvironment(); if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + statementOffset = ts.addStandardPrologue(statements, body.statements, false); } addCaptureThisForNodeIfNeeded(statements, node); addDefaultValueAssignmentsIfNeeded(statements, node); @@ -42276,6 +44172,7 @@ var ts; multiLine = true; } if (ts.isBlock(body)) { + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor); statementsLocation = body.statements; ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); if (!multiLine && body.multiLine) { @@ -42283,7 +44180,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 186); + ts.Debug.assert(node.kind === 187); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -42313,7 +44210,7 @@ var ts; ts.setEmitFlags(block, 1); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17, closeBraceLocation); + ts.setTokenSourceMapRange(block, 18, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -42335,9 +44232,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 184: + case 185: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 193: + case 194: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -42345,9 +44242,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 184: + case 185: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 193: + case 194: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -42373,13 +44270,13 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 58, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } - (assignments || (assignments = [])).push(assignment); + assignments = ts.append(assignments, assignment); } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 26, acc); })), node); } else { updated = undefined; @@ -42464,11 +44361,24 @@ var ts; if (convertedLoopState && !convertedLoopState.labels) { convertedLoopState.labels = ts.createMap(); } - var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); - return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) ? visitIterationStatement(statement, node) : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 212: + case 213: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 214: + return visitForStatement(node, outermostLabeledStatement); + case 215: + return visitForInStatement(node, outermostLabeledStatement); + case 216: + return visitForOfStatement(node, outermostLabeledStatement); + } + } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); @@ -42485,27 +44395,19 @@ var ts; return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } - function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; + function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 - ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) - : ts.createTempVariable(undefined); - var elementAccess = ts.createElementAccess(rhsReference, counter); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { + if (ts.isVariableDeclarationList(node.initializer)) { + if (node.initializer.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations); - ts.setOriginalNode(declarationList, initializer); - ts.setTextRange(declarationList, initializer); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue); + var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); + ts.setOriginalNode(declarationList, node.initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); @@ -42513,18 +44415,19 @@ var ts; } else { statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue) + ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); } } else { - var assignment = ts.createAssignment(initializer, elementAccess); + var assignment = ts.createAssignment(node.initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(assignment, visitor, context, 0))); + ts.aggregateTransformFlags(assignment); + statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); } else { - assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); + assignment.end = node.initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); } } var bodyLocation; @@ -42533,7 +44436,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -42543,30 +44446,49 @@ var ts; statements.push(statement); } } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384); + } + function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var counter = ts.createLoopVariable(); + var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); - ts.setTextRange(body, bodyLocation); - ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) - ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); + ]), node.expression), 2097152), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), convertForOfStatementHead(node, ts.createElementAccess(rhsReference, counter), convertedLoopBodyStatements)), node); ts.setEmitFlags(forStatement, 256); ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } - function visitIterationStatement(node, outermostLabeledStatement) { - switch (node.kind) { - case 211: - case 212: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 213: - return visitForStatement(node, outermostLabeledStatement); - case 214: - return visitForInStatement(node, outermostLabeledStatement); - case 215: - return visitForOfStatement(node, outermostLabeledStatement); - } + function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(undefined); + var values = ts.createValuesHelper(context, expression, node.expression); + var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression), + ts.createVariableDeclaration(result, undefined, next) + ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1)), ts.createBlock([ + ts.createTry(ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), + ]), undefined, ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) + ]), 1)) + ])); } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -42579,7 +44501,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 143) { + if (property.name.kind === 144) { numInitialProperties = i; break; } @@ -42590,7 +44512,7 @@ var ts; } var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -42610,7 +44532,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 70) { + if (node.kind === 71) { state.hoistedLocalVariables.push(node); } else { @@ -42641,11 +44563,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 213: case 214: case 215: + case 216: var initializer = node.initializer; - if (initializer && initializer.kind === 226) { + if (initializer && initializer.kind === 227) { loopInitializer = initializer; } break; @@ -42672,7 +44594,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -42690,18 +44612,18 @@ var ts; else { loopBody = ts.createBlock([loopBody], true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 - && (node.statement.transformFlags & 16777216) !== 0; + var containsYield = (node.statement.transformFlags & 16777216) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8; } if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 131072; + loopBodyFlags |= 262144; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ]), 1048576)); + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(39) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ]), 2097152)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -42746,7 +44668,7 @@ var ts; if (extraVariableDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -42766,7 +44688,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 57, source); + return ts.createBinary(target, 58, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -42781,7 +44703,9 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; + var callResult = isAsyncBlockContainingAwait + ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) + : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -42800,10 +44724,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 34, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -42869,20 +44793,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 152: case 153: + case 154: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 150: + case 151: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 260: + case 261: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 261: + case 262: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -42951,7 +44875,20 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16286, 65); - var updated = ts.visitEachChild(node, visitor, context); + var updated; + if (node.transformFlags & 32768) { + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (node.kind === 153) { + updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + } + else { + updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body); + } + } + else { + updated = ts.visitEachChild(node, visitor, context); + } exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; return updated; @@ -42985,7 +44922,7 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { ts.setEmitFlags(thisArg, 4); } var resultingCall; @@ -42995,7 +44932,7 @@ var ts; else { resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -43017,13 +44954,27 @@ var ts; var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 - ? ts.createArraySlice(segments[0]) - : segments[0]; + if (compilerOptions.downlevelIteration) { + if (segments.length === 1) { + var firstSegment = segments[0]; + if (ts.isCallExpression(firstSegment) + && ts.isIdentifier(firstSegment.expression) + && (ts.getEmitFlags(firstSegment.expression) & 4096) + && firstSegment.expression.text === "___spread") { + return segments[0]; + } + } + return ts.createSpreadHelper(context, segments); + } + else { + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 177 + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + return ts.createArrayConcat(segments.shift(), segments); } - return ts.createArrayConcat(segments.shift(), segments); } function partitionSpread(node) { return ts.isSpreadExpression(node) @@ -43045,6 +44996,18 @@ var ts; function visitTemplateLiteral(node) { return ts.setTextRange(ts.createLiteral(node.text), node); } + function visitStringLiteral(node) { + if (node.hasExtendedUnicodeEscape) { + return ts.setTextRange(ts.createLiteral(node.text), node); + } + return node; + } + function visitNumericLiteral(node) { + if (node.numericLiteralFlags & 48) { + return ts.setTextRange(ts.createNumericLiteral(node.text), node); + } + return node; + } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -43074,7 +45037,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 12 || node.kind === 15; + var isLast = node.kind === 13 || node.kind === 16; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.setTextRange(ts.createLiteral(text), node); @@ -43116,7 +45079,7 @@ var ts; : ts.createIdentifier("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 93 && node.name.text === "target") { + if (node.keywordToken === 94 && node.name.text === "target") { if (hierarchyFacts & 8192) { hierarchyFacts |= 32768; } @@ -43141,20 +45104,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(70); + context.enableSubstitution(71); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(98); - context.enableEmitNotification(151); - context.enableEmitNotification(150); + context.enableSubstitution(99); context.enableEmitNotification(152); + context.enableEmitNotification(151); context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(187); context.enableEmitNotification(186); - context.enableEmitNotification(185); - context.enableEmitNotification(227); + context.enableEmitNotification(228); } } function onSubstituteNode(hint, node) { @@ -43168,10 +45131,10 @@ var ts; return node; } function substituteIdentifier(node) { - if (enabledSubstitutions & 2) { + if (enabledSubstitutions & 2 && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + return ts.setTextRange(ts.getGeneratedNameForNode(original), node); } } return node; @@ -43179,10 +45142,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 175: - case 228: - case 231: - case 225: + case 176: + case 229: + case 232: + case 226: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -43190,22 +45153,40 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 98: + case 99: return substituteThisKeyword(node); } return node; } function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2) { + if (enabledSubstitutions & 2 && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { + return ts.setTextRange(ts.getGeneratedNameForNode(declaration.name), node); } } return node; } + function isPartOfClassBody(declaration, node) { + var currentNode = ts.getParseTreeNode(node); + if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) { + return false; + } + var blockScope = ts.getEnclosingBlockScopeContainer(declaration); + while (currentNode) { + if (currentNode === blockScope || currentNode === declaration) { + return false; + } + if (ts.isClassElement(currentNode) && currentNode.parent === declaration) { + return currentNode.kind !== 149 + || (ts.getModifierFlags(currentNode) & 32) === 0; + } + currentNode = currentNode.parent; + } + return false; + } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && hierarchyFacts & 16) { @@ -43214,8 +45195,9 @@ var ts; return node; } function getClassMemberPrefix(node, member) { - var expression = ts.getLocalName(node); - return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + return ts.hasModifier(member, 32) + ? ts.getInternalName(node) + : ts.createPropertyAccess(ts.getInternalName(node), "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { if (!constructor || !hasExtendsClause) { @@ -43225,19 +45207,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 210) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 181) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 198) { return false; } var expression = callArgument.expression; @@ -43268,24 +45250,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(250); context.enableEmitNotification(251); - context.enableEmitNotification(249); + context.enableEmitNotification(252); + context.enableEmitNotification(250); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178); - context.enableSubstitution(260); + context.enableSubstitution(179); + context.enableSubstitution(261); return transformSourceFile; function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 250: case 251: - case 249: + case 252: + case 250: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -43321,7 +45303,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 && token <= 106) { + if (token >= 72 && token <= 107) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -43405,13 +45387,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 211: - return visitDoStatement(node); case 212: + return visitDoStatement(node); + case 213: return visitWhileStatement(node); - case 220: - return visitSwitchStatement(node); case 221: + return visitSwitchStatement(node); + case 222: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -43419,24 +45401,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: + case 186: return visitFunctionExpression(node); - case 152: case 153: + case 154: return visitAccessorDeclaration(node); - case 207: + case 208: return visitVariableStatement(node); - case 213: - return visitForStatement(node); case 214: + return visitForStatement(node); + case 215: return visitForInStatement(node); - case 217: - return visitBreakStatement(node); - case 216: - return visitContinueStatement(node); case 218: + return visitBreakStatement(node); + case 217: + return visitContinueStatement(node); + case 219: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -43452,21 +45434,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 193: - return visitBinaryExpression(node); case 194: + return visitBinaryExpression(node); + case 195: return visitConditionalExpression(node); - case 196: + case 197: return visitYieldExpression(node); - case 176: - return visitArrayLiteralExpression(node); case 177: + return visitArrayLiteralExpression(node); + case 178: return visitObjectLiteralExpression(node); - case 179: - return visitElementAccessExpression(node); case 180: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 181: + return visitCallExpression(node); + case 182: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43474,9 +45456,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: + case 186: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -43484,7 +45466,7 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { @@ -43505,7 +45487,7 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { @@ -43558,7 +45540,7 @@ var ts; operationLocations = undefined; state = ts.createTempVariable(undefined); resumeLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + var statementOffset = ts.addPrologue(statements, body.statements, false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); ts.addRange(statements, endLexicalEnvironment()); @@ -43584,7 +45566,7 @@ var ts; return undefined; } else { - if (ts.getEmitFlags(node) & 524288) { + if (ts.getEmitFlags(node) & 1048576) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -43609,23 +45591,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 58 - && kind <= 69; + return kind >= 59 + && kind <= 70; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; case 63: return 41; - case 64: return 44; + case 64: return 42; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; case 69: return 49; + case 70: return 50; } } function visitRightAssociativeBinaryExpression(node) { @@ -43633,10 +45615,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 178: + case 179: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 179: + case 180: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -43658,7 +45640,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 25) { + else if (node.operatorToken.kind === 26) { return visitCommaExpression(node); } var clone_5 = ts.getMutableClone(node); @@ -43672,7 +45654,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 52) { + if (node.operatorToken.kind === 53) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -43688,7 +45670,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { visit(node.left); visit(node.right); } @@ -43720,7 +45702,10 @@ var ts; var resumeLabel = defineLabel(); var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { - emitYieldStar(expression, node); + var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0 + ? ts.createValuesHelper(context, expression, node) + : expression; + emitYieldStar(iterator, node); } else { emitYield(expression, node); @@ -43733,25 +45718,27 @@ var ts; } function visitElements(elements, leadingElement, location, multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); - var temp = declareLocal(); - var hasAssignedTemp = false; + var temp; if (numInitialElements > 0) { + temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement ? [leadingElement].concat(initialElements) : initialElements)); leadingElement = undefined; - hasAssignedTemp = true; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); - return hasAssignedTemp + return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { + var hasAssignedTemp = temp !== undefined; + if (!temp) { + temp = declareLocal(); + } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); - hasAssignedTemp = true; leadingElement = undefined; expressions = []; } @@ -43832,38 +45819,38 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 206: + case 207: return transformAndEmitBlock(node); - case 209: - return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 211: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 212: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 213: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 214: + return transformAndEmitForStatement(node); + case 215: return transformAndEmitForInStatement(node); - case 216: - return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 218: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 219: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 220: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 221: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 222: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 223: + return transformAndEmitThrowStatement(node); + case 224: return transformAndEmitTryStatement(node); default: - return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); + return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); } } function transformAndEmitBlock(node) { @@ -44015,7 +46002,7 @@ var ts; beginScriptLoopBlock(); } var initializer = node.initializer; - if (ts.isVariableDeclarationList(initializer)) { + if (initializer && ts.isVariableDeclarationList(initializer)) { for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { var variable = _a[_i]; hoistVariableDeclaration(variable.name); @@ -44023,7 +46010,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = ts.updateFor(node, variables.length > 0 ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression, true), ts.visitNode(node.incrementor, visitor, ts.isExpression, true), ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -44081,7 +46068,7 @@ var ts; var variable = _a[_i]; hoistVariableDeclaration(variable.name); } - node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -44120,10 +46107,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function transformAndEmitReturnStatement(node) { - emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression, true), node); + emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node); } function visitReturnStatement(node) { - return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression, true), node); + return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node); } function transformAndEmitWithStatement(node) { if (containsYield(node)) { @@ -44146,7 +46133,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 257 && defaultClauseIndex === -1) { + if (clause.kind === 258 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -44156,7 +46143,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 256) { + if (clause.kind === 257) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -44272,7 +46259,7 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { + if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); @@ -44291,7 +46278,7 @@ var ts; } function cacheExpression(node) { var temp; - if (ts.isGeneratedIdentifier(node)) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) { return node; } temp = ts.createTempVariable(hoistVariableDeclaration); @@ -44383,15 +46370,22 @@ var ts; } function beginCatchBlock(variable) { ts.Debug.assert(peekBlockKind() === 0); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = []; - context.enableSubstitution(70); + var name; + if (ts.isGeneratedIdentifier(variable.name)) { + name = variable.name; + hoistVariableDeclaration(variable.name); + } + else { + var text = variable.name.text; + name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = []; + context.enableSubstitution(71); + } + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } - renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); var endLabel = exception.endLabel; @@ -44591,7 +46585,7 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = getInstructionName(instruction); + ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction)); return literal; } function createInlineBreak(label, location) { @@ -44673,7 +46667,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 524288)); } function buildStatements() { if (operations) { @@ -44944,7 +46938,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); var ts; @@ -44967,12 +46961,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(193); - context.enableSubstitution(191); + context.enableSubstitution(71); + context.enableSubstitution(194); context.enableSubstitution(192); - context.enableSubstitution(261); - context.enableEmitNotification(264); + context.enableSubstitution(193); + context.enableSubstitution(262); + context.enableEmitNotification(265); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -44980,9 +46974,7 @@ var ts; var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (ts.isDeclarationFile(node) || !(ts.isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } currentSourceFile = node; @@ -44994,17 +46986,24 @@ var ts; currentModuleInfo = undefined; return ts.aggregateTransformFlags(updated); } + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) { + return true; + } + return false; + } function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); + ts.addRange(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); @@ -45076,13 +47075,15 @@ var ts; var importNode = _c[_b]; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 4); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); + if (externalModuleName) { + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 4); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; @@ -45090,14 +47091,14 @@ var ts; function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); + ts.addRange(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); @@ -45122,23 +47123,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 243: + case 244: return visitExportDeclaration(node); - case 242: + case 243: return visitExportAssignment(node); - case 207: + case 208: return visitVariableStatement(node); - case 227: - return visitFunctionDeclaration(node); case 228: + return visitFunctionDeclaration(node); + case 229: return visitClassDeclaration(node); - case 299: + case 297: return visitMergeDeclarationMarker(node); - case 300: + case 298: return visitEndOfDeclarationMarker(node); default: return node; @@ -45336,14 +47337,14 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; + return (ts.getEmitFlags(node) & 4194304) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -45368,10 +47369,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239: + case 240: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240: + case 241: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -45456,7 +47457,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 524288); + ts.setEmitFlags(statement, 1048576); return statement; } function createExportStatement(name, value, location, allowComments) { @@ -45472,14 +47473,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264) { + if (node.kind === 265) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -45519,12 +47520,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 193: + case 194: return substituteBinaryExpression(node); + case 193: case 192: - case 191: return substituteUnaryExpression(node); } return node; @@ -45539,7 +47540,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 264) { + if (exportContainer && exportContainer.kind === 265) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -45575,15 +47576,15 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) + if ((node.operator === 43 || node.operator === 44) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) + var expression = node.kind === 193 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -45624,11 +47625,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(193); - context.enableSubstitution(191); + context.enableSubstitution(71); + context.enableSubstitution(194); context.enableSubstitution(192); - context.enableEmitNotification(264); + context.enableSubstitution(193); + context.enableEmitNotification(265); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -45688,17 +47689,19 @@ var ts; for (var i = 0; i < externalImports.length; i++) { var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - var groupIndex = groupIndices.get(text); - if (groupIndex !== undefined) { - dependencyGroups[groupIndex].externalImports.push(externalImport); - } - else { - groupIndices.set(text, dependencyGroups.length); - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); + if (externalModuleName) { + var text = externalModuleName.text; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices.set(text, dependencyGroups.length); + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } } return dependencyGroups; @@ -45706,11 +47709,12 @@ var ts; function createSystemModuleBody(node, dependencyGroups) { var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) ]))); - ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); @@ -45731,7 +47735,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 243 && externalImport.exportClause) { + if (externalImport.kind === 244 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -45754,7 +47758,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 243) { + if (externalImport.kind !== 244) { continue; } var exportDecl = externalImport; @@ -45806,15 +47810,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 237: + case 238: if (!entry.importClause) { break; } - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 243: + case 244: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -45836,13 +47840,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 243: + case 244: return undefined; - case 242: + case 243: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -45891,7 +47895,7 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); } else { hoistedStatements = ts.append(hoistedStatements, node); @@ -45962,8 +47966,8 @@ var ts; } } function shouldHoistVariableDeclarationList(node) { - return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 264 + return (ts.getEmitFlags(node) & 2097152) === 0 + && (enclosingBlockScopedContainer.kind === 265 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -45985,7 +47989,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -45993,7 +47997,7 @@ var ts; return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; + return (ts.getEmitFlags(node) & 4194304) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -46018,10 +48022,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239: + case 240: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240: + case 241: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46120,43 +48124,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 207: + case 208: return visitVariableStatement(node); - case 227: - return visitFunctionDeclaration(node); case 228: + return visitFunctionDeclaration(node); + case 229: return visitClassDeclaration(node); - case 213: - return visitForStatement(node); case 214: - return visitForInStatement(node); + return visitForStatement(node); case 215: + return visitForInStatement(node); + case 216: return visitForOfStatement(node); - case 211: - return visitDoStatement(node); case 212: + return visitDoStatement(node); + case 213: return visitWhileStatement(node); - case 221: + case 222: return visitLabeledStatement(node); - case 219: - return visitWithStatement(node); case 220: + return visitWithStatement(node); + case 221: return visitSwitchStatement(node); - case 234: + case 235: return visitCaseBlock(node); - case 256: - return visitCaseClause(node); case 257: + return visitCaseClause(node); + case 258: return visitDefaultClause(node); - case 223: + case 224: return visitTryStatement(node); - case 259: + case 260: return visitCatchClause(node); - case 206: + case 207: return visitBlock(node); - case 299: + case 297: return visitMergeDeclarationMarker(node); - case 300: + case 298: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -46165,21 +48169,21 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForOf(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -46188,6 +48192,9 @@ var ts; && shouldHoistVariableDeclarationList(node); } function visitForInitializer(node) { + if (!node) { + return node; + } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -46201,16 +48208,16 @@ var ts; } } function visitDoStatement(node) { - return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); } function visitWhileStatement(node) { - return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitLabeledStatement(node) { - return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitWithStatement(node) { - return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitSwitchStatement(node) { return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); @@ -46247,7 +48254,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 193) { + && node.kind === 194) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -46264,7 +48271,7 @@ var ts; return ts.visitEachChild(node, destructuringVisitor, context); } function hasExportedReferenceInDestructuringTarget(node) { - if (ts.isAssignmentExpression(node)) { + if (ts.isAssignmentExpression(node, true)) { return hasExportedReferenceInDestructuringTarget(node.left); } else if (ts.isSpreadExpression(node)) { @@ -46284,7 +48291,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 264; + return container !== undefined && container.kind === 265; } else { return false; @@ -46292,14 +48299,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264) { + if (node.kind === 265) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -46330,12 +48337,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 193: + case 194: return substituteBinaryExpression(node); - case 191: case 192: + case 193: return substituteUnaryExpression(node); } return node; @@ -46380,22 +48387,22 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) + if ((node.operator === 43 || node.operator === 44) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 + var expression = node.kind === 193 ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 192) { - expression = node.operator === 42 + if (node.kind === 193) { + expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -46411,7 +48418,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 264) { + if (exportContainer && exportContainer.kind === 265) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -46439,8 +48446,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(264); - context.enableSubstitution(70); + context.enableEmitNotification(265); + context.enableSubstitution(71); var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { @@ -46451,7 +48458,7 @@ var ts; var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); if (externalHelpersModuleName) { var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); + var statementOffset = ts.addPrologue(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); @@ -46464,9 +48471,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 236: + case 237: return undefined; - case 242: + case 243: return visitExportAssignment(node); } return node; @@ -46515,11 +48522,12 @@ var ts; return ts.transformModule; } } - function getTransformers(compilerOptions) { + function getTransformers(compilerOptions, customTransformers) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; + ts.addRange(transformers, customTransformers && customTransformers.before); transformers.push(ts.transformTypeScript); if (jsx === 2) { transformers.push(ts.transformJsx); @@ -46541,12 +48549,12 @@ var ts; if (languageVersion < 1) { transformers.push(ts.transformES5); } + ts.addRange(transformers, customTransformers && customTransformers.after); return transformers; } ts.getTransformers = getTransformers; - function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(301); - var lexicalEnvironmentDisabled = false; + function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { + var enabledSyntaxKindFeatures = new Array(299); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -46554,8 +48562,11 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; + var onSubstituteNode = function (_, node) { return node; }; + var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var state = 0; var context = { - getCompilerOptions: function () { return host.getCompilerOptions(); }, + getCompilerOptions: function () { return options; }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, startLexicalEnvironment: startLexicalEnvironment, @@ -46566,46 +48577,57 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, - isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, - isEmitNotificationEnabled: isEmitNotificationEnabled + isSubstitutionEnabled: isSubstitutionEnabled, + isEmitNotificationEnabled: isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode; }, + set onSubstituteNode(value) { + ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode; }, + set onEmitNode(value) { + ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + } }; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); - var transformed = ts.map(sourceFiles, transformSourceFile); - lexicalEnvironmentDisabled = true; + state = 1; + var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot); + state = 2; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, - emitNodeWithSubstitution: emitNodeWithSubstitution, - emitNodeWithNotification: emitNodeWithNotification + substituteNode: substituteNode, + emitNodeWithNotification: emitNodeWithNotification, + dispose: dispose }; - function transformSourceFile(sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return sourceFile; - } - return transformation(sourceFile); + function transformRoot(node) { + return node && (!ts.isSourceFile(node) || !ts.isDeclarationFile(node)) ? transformation(node) : node; } function enableSubstitution(kind) { + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 1; } function isSubstitutionEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(hint, node, emitCallback) { - if (node) { - if (isSubstitutionEnabled(node)) { - node = context.onSubstituteNode(hint, node) || node; - } - emitCallback(hint, node); - } + function substituteNode(hint, node) { + ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } function enableEmitNotification(kind) { + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 2; } function isEmitNotificationEnabled(node) { @@ -46613,9 +48635,10 @@ var ts; || (ts.getEmitFlags(node) & 2) !== 0; } function emitNodeWithNotification(hint, node, emitCallback) { + ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(hint, node, emitCallback); + onEmitNode(hint, node, emitCallback); } else { emitCallback(hint, node); @@ -46623,7 +48646,8 @@ var ts; } } function hoistVariableDeclaration(name) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); var decl = ts.createVariableDeclaration(name); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; @@ -46633,7 +48657,8 @@ var ts; } } function hoistFunctionDeclaration(func) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -46642,7 +48667,8 @@ var ts; } } function startLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; @@ -46651,17 +48677,20 @@ var ts; lexicalEnvironmentFunctionDeclarations = undefined; } function suspendLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } function resumeLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } function endLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { @@ -46688,18 +48717,36 @@ var ts; return statements; } function requestEmitHelper(helper) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } + function dispose() { + if (state < 3) { + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentVariableDeclarationsStack = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentFunctionDeclarationsStack = undefined; + onSubstituteNode = undefined; + onEmitNode = undefined; + emitHelpers = undefined; + state = 3; + } + } } - ts.transformFiles = transformFiles; + ts.transformNodes = transformNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -46764,7 +48811,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 264) { + if (sourceFileOrBundle.kind === 265) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -46864,7 +48911,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 297 + if (node.kind !== 295 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -46877,7 +48924,7 @@ var ts; else { emitCallback(hint, node); } - if (node.kind !== 297 + if (node.kind !== 295 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -47006,23 +49053,18 @@ var ts; return; } if (node) { - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var emitFlags = ts.getEmitFlags(node); + hasWrittenComment = false; + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 297; + var isEmittedNode = node.kind !== 295; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -47036,23 +49078,16 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 226) { + if (node.kind === 227) { declarationListContainerEnd = end; } } if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); if (extendedDiagnostics) { - ts.performance.mark("beginEmitNodeWithComment"); + ts.performance.mark("postEmitNodeWithComment"); } containerPos = savedContainerPos; containerEnd = savedContainerEnd; @@ -47061,11 +49096,75 @@ var ts; emitTrailingComments(end); } if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitNodeWithComment"); + ts.performance.measure("commentTime", "postEmitNodeWithComment"); } } } } + function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { + var leadingComments = emitNode && emitNode.leadingComments; + if (ts.some(leadingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("preEmitNodeWithSynthesizedComments"); + } + ts.forEach(leadingComments, emitLeadingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); + } + } + emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); + var trailingComments = emitNode && emitNode.trailingComments; + if (ts.some(trailingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("postEmitNodeWithSynthesizedComments"); + } + ts.forEach(trailingComments, emitTrailingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); + } + } + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2) { + writer.writeLine(); + } + else { + writer.write(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.write(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { + if (emitFlags & 2048) { + disabled = true; + emitCallback(hint, node); + disabled = false; + } + else { + emitCallback(hint, node); + } + } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { if (extendedDiagnostics) { ts.performance.mark("preEmitBodyWithDetachedComments"); @@ -47267,8 +49366,8 @@ var ts; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { - var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; - var isBundledEmit = sourceFileOrBundle.kind === 265; + var sourceFiles = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 266; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -47330,7 +49429,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 237); + ts.Debug.assert(aliasEmitInfo.node.kind === 238); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -47403,10 +49502,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 225) { + if (declaration.kind === 226) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { + else if (declaration.kind === 241 || declaration.kind === 242 || declaration.kind === 239) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -47417,7 +49516,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 237) { + if (moduleElementEmitInfo.node.kind === 238) { moduleElementEmitInfo.isVisible = true; } else { @@ -47425,12 +49524,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 232) { + if (nodeToCheck.kind === 233) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 232) { + if (nodeToCheck.kind === 233) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -47492,7 +49591,7 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - var shouldUseResolverType = declaration.kind === 145 && + var shouldUseResolverType = declaration.kind === 146 && resolver.isRequiredInitializedParameter(declaration); if (type && !shouldUseResolverType) { emitType(type); @@ -47518,15 +49617,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var node = nodes_6[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { - var node = nodes_5[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -47552,74 +49651,74 @@ var ts; } function emitType(type) { switch (type.kind) { - case 118: - case 135: - case 132: - case 121: - case 133: + case 119: case 136: - case 104: - case 138: - case 94: - case 129: - case 168: - case 172: - return writeTextOfNode(currentText, type); - case 200: - return emitExpressionWithTypeArguments(type); - case 158: - return emitTypeReference(type); - case 161: - return emitTypeQuery(type); - case 163: - return emitArrayType(type); - case 164: - return emitTupleType(type); - case 165: - return emitUnionType(type); - case 166: - return emitIntersectionType(type); - case 167: - return emitParenType(type); + case 133: + case 122: + case 134: + case 137: + case 105: + case 139: + case 95: + case 130: case 169: - return emitTypeOperator(type); - case 170: - return emitIndexedAccessType(type); - case 171: - return emitMappedType(type); + case 173: + return writeTextOfNode(currentText, type); + case 201: + return emitExpressionWithTypeArguments(type); case 159: - case 160: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 162: + return emitTypeQuery(type); + case 164: + return emitArrayType(type); + case 165: + return emitTupleType(type); + case 166: + return emitUnionType(type); + case 167: + return emitIntersectionType(type); + case 168: + return emitParenType(type); + case 170: + return emitTypeOperator(type); + case 171: + return emitIndexedAccessType(type); + case 172: + return emitMappedType(type); + case 160: + case 161: + return emitSignatureDeclarationWithJsDocComments(type); + case 163: return emitTypeLiteral(type); - case 70: + case 71: return emitEntityName(type); - case 142: + case 143: return emitEntityName(type); - case 157: + case 158: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 70) { + if (entityName.kind === 71) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 142 ? entityName.left : entityName.expression; - var right = entityName.kind === 142 ? entityName.right : entityName.name; + var left = entityName.kind === 143 ? entityName.left : entityName.expression; + var right = entityName.kind === 143 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 237 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); + ts.Debug.assert(node.expression.kind === 71 || node.expression.kind === 179); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -47736,7 +49835,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -47757,7 +49856,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -47775,10 +49874,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 236 || - (node.parent.kind === 264 && isCurrentFileExternalModule)) { + else if (node.kind === 237 || + (node.parent.kind === 265 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 265) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -47787,7 +49886,7 @@ var ts; }); } else { - if (node.kind === 237) { + if (node.kind === 238) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -47805,30 +49904,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 227: - return writeFunctionDeclaration(node); - case 207: - return writeVariableStatement(node); - case 229: - return writeInterfaceDeclaration(node); case 228: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 208: + return writeVariableStatement(node); case 230: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 229: + return writeClassDeclaration(node); case 231: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 232: + return writeEnumDeclaration(node); + case 233: return writeModuleDeclaration(node); - case 236: - return writeImportEqualsDeclaration(node); case 237: + return writeImportEqualsDeclaration(node); + case 238: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 264) { + if (node.parent.kind === 265) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -47836,7 +49935,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 229 && !noDeclare) { + else if (node.kind !== 230 && !noDeclare) { write("declare "); } } @@ -47886,7 +49985,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 239) { + if (namedBindings.kind === 240) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -47909,7 +50008,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 239) { + if (node.importClause.namedBindings.kind === 240) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -47926,13 +50025,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 233; var moduleSpecifier; - if (parent.kind === 236) { + if (parent.kind === 237) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 232) { + else if (parent.kind === 233) { moduleSpecifier = parent.name; } else { @@ -48000,7 +50099,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 233) { + while (node.body && node.body.kind !== 234) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -48070,7 +50169,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 151 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -48080,15 +50179,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - (node.parent.parent && node.parent.parent.kind === 162)) { - ts.Debug.assert(node.parent.kind === 150 || - node.parent.kind === 149 || - node.parent.kind === 159 || + if (node.parent.kind === 160 || + node.parent.kind === 161 || + (node.parent.parent && node.parent.parent.kind === 163)) { + ts.Debug.assert(node.parent.kind === 151 || + node.parent.kind === 150 || node.parent.kind === 160 || - node.parent.kind === 154 || - node.parent.kind === 155); + node.parent.kind === 161 || + node.parent.kind === 155 || + node.parent.kind === 156); emitType(node.constraint); } else { @@ -48097,15 +50196,15 @@ var ts; } if (node.default && !isPrivateMethodTypeParameter(node)) { write(" = "); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - (node.parent.parent && node.parent.parent.kind === 162)) { - ts.Debug.assert(node.parent.kind === 150 || - node.parent.kind === 149 || - node.parent.kind === 159 || + if (node.parent.kind === 160 || + node.parent.kind === 161 || + (node.parent.parent && node.parent.parent.kind === 163)) { + ts.Debug.assert(node.parent.kind === 151 || + node.parent.kind === 150 || node.parent.kind === 160 || - node.parent.kind === 154 || - node.parent.kind === 155); + node.parent.kind === 161 || + node.parent.kind === 155 || + node.parent.kind === 156); emitType(node.default); } else { @@ -48115,34 +50214,34 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 229: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 155: + case 156: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 151: case 150: - case 149: if (ts.hasModifier(node.parent, 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 === 228) { + else if (node.parent.parent.kind === 229) { 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 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 230: + case 231: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -48170,7 +50269,7 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 94) { + else if (!isImplementsList && node.expression.kind === 95) { write("null"); } else { @@ -48181,7 +50280,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 228) { + if (node.parent.parent.kind === 229) { 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; @@ -48265,17 +50364,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 226 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 148 || node.kind === 147 || - (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 149 || node.kind === 148 || + (node.kind === 146 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { + if ((node.kind === 149 || node.kind === 148) && node.parent.kind === 163) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -48288,14 +50387,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 225) { + if (node.kind === 226) { 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 === 148 || node.kind === 147) { + else if (node.kind === 149 || node.kind === 148) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48303,7 +50402,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { 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 : @@ -48329,7 +50428,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 199) { + if (element.kind !== 200) { elements.push(element); } } @@ -48395,7 +50494,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 153 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -48408,7 +50507,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 152 + return accessor.kind === 153 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -48417,7 +50516,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 153) { + if (accessorWithTypeAnnotation.kind === 154) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 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 : @@ -48463,17 +50562,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 227) { + if (node.kind === 228) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 150 || node.kind === 151) { + else if (node.kind === 151 || node.kind === 152) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 227) { + if (node.kind === 228) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 151) { + else if (node.kind === 152) { write("constructor"); } else { @@ -48493,15 +50592,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 156) { + if (node.kind === 157) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 155 || node.kind === 160) { + if (node.kind === 156 || node.kind === 161) { write("new "); } - else if (node.kind === 159) { + else if (node.kind === 160) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -48512,20 +50611,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 156) { + if (node.kind === 157) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; - if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { + var isFunctionTypeOrConstructorType = node.kind === 160 || node.kind === 161; + if (isFunctionTypeOrConstructorType || node.parent.kind === 163) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 152 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -48539,23 +50638,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 155: + case 156: 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 154: + case 155: 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 156: + case 157: 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 151: case 150: - case 149: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48563,7 +50662,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { 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 : @@ -48576,7 +50675,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 227: + case 228: 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 : @@ -48608,9 +50707,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - node.parent.parent.kind === 162) { + if (node.parent.kind === 160 || + node.parent.kind === 161 || + node.parent.parent.kind === 163) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -48626,26 +50725,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 151: + case 152: 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 155: + case 156: 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 154: + case 155: 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 156: + case 157: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 151: case 150: - case 149: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -48653,7 +50752,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 228) { + else if (node.parent.parent.kind === 229) { 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 : @@ -48665,7 +50764,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 227: + case 228: 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 : @@ -48676,12 +50775,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 173) { + if (bindingPattern.kind === 174) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 174) { + else if (bindingPattern.kind === 175) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -48692,10 +50791,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 199) { + if (bindingElement.kind === 200) { write(" "); } - else if (bindingElement.kind === 175) { + else if (bindingElement.kind === 176) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -48705,7 +50804,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 70); + ts.Debug.assert(bindingElement.name.kind === 71); if (bindingElement.dotDotDotToken) { write("..."); } @@ -48717,39 +50816,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 227: - case 232: - case 236: - case 229: case 228: - case 230: - case 231: - return emitModuleElement(node, isModuleElementVisible(node)); - case 207: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 233: case 237: + case 230: + case 229: + case 231: + case 232: + return emitModuleElement(node, isModuleElementVisible(node)); + case 208: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 238: return emitModuleElement(node, !node.importClause); - case 243: + case 244: return emitExportDeclaration(node); + case 152: case 151: case 150: - case 149: return writeFunctionDeclaration(node); - case 155: - case 154: case 156: + case 155: + case 157: return emitSignatureDeclarationWithJsDocComments(node); - case 152: case 153: + case 154: return emitAccessorDeclaration(node); + case 149: case 148: - case 147: return emitPropertyDeclaration(node); - case 263: - return emitEnumMemberDeclaration(node); - case 242: - return emitExportAssignment(node); case 264: + return emitEnumMemberDeclaration(node); + case 243: + return emitExportAssignment(node); + case 265: return emitSourceFile(node); } } @@ -48768,7 +50867,7 @@ var ts; } return addedBundledEmitReference; function getDeclFileName(emitFileNames, sourceFileOrBundle) { - var isBundledEmit = sourceFileOrBundle.kind === 265; + var isBundledEmit = sourceFileOrBundle.kind === 266; if (isBundledEmit && !addBundledFileReference) { return; } @@ -48782,7 +50881,7 @@ var ts; var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { - var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var sourceFiles = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -48808,14 +50907,13 @@ var ts; (function (ts) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers) { var compilerOptions = host.getCompilerOptions(); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var sourceMap = ts.createSourceMapWriter(host, writer); var currentSourceFile; @@ -48823,11 +50921,11 @@ var ts; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var transform = ts.transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, false); var printer = createPrinter(compilerOptions, { hasGlobalName: resolver.hasGlobalName, onEmitNode: transform.emitNodeWithNotification, - onSubstituteNode: transform.emitNodeWithSubstitution, + substituteNode: transform.substituteNode, onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, onEmitSourceMapOfPosition: sourceMap.emitPos, @@ -48837,10 +50935,7 @@ var ts; ts.performance.mark("beforePrint"); ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; - ts.disposeEmitNodes(sourceFile); - } + transform.dispose(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -48873,8 +50968,8 @@ var ts; } } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { - var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); if (bundle) { @@ -48910,7 +51005,7 @@ var ts; } function emitHelpers(node, writeLines) { var helpersEmitted = false; - var bundle = node.kind === 265 ? node : undefined; + var bundle = node.kind === 266 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -48949,9 +51044,8 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray; var newLine = ts.getNewLineCharacter(printerOptions); - var languageVersion = ts.getEmitScriptTarget(printerOptions); var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; var currentSourceFile; @@ -48984,8 +51078,8 @@ var ts; break; } switch (node.kind) { - case 264: return printFile(node); - case 265: return printBundle(node); + case 265: return printFile(node); + case 266: return printBundle(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -49008,6 +51102,8 @@ var ts; function writeBundle(bundle, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(bundle); + emitPrologueDirectivesIfNeeded(bundle); emitHelpersIndirect(bundle); for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { var sourceFile = _b[_a]; @@ -49019,6 +51115,8 @@ var ts; function writeFile(sourceFile, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(sourceFile); + emitPrologueDirectivesIfNeeded(sourceFile); print(0, sourceFile, sourceFile); reset(); writer = previousWriter; @@ -49055,9 +51153,8 @@ var ts; comments.reset(); setWriter(undefined); } - function emit(node, hint) { - if (hint === void 0) { hint = 3; } - pipelineEmitWithNotification(hint, node); + function emit(node) { + pipelineEmitWithNotification(3, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -49074,6 +51171,7 @@ var ts; } } function pipelineEmitWithComments(hint, node) { + node = trySubstituteNode(hint, node); if (emitNodeWithComments && hint !== 0) { emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); } @@ -49083,15 +51181,7 @@ var ts; } function pipelineEmitWithSourceMap(hint, node) { if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { - onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); - } - else { - pipelineEmitWithSubstitution(hint, node); - } - } - function pipelineEmitWithSubstitution(hint, node) { - if (onSubstituteNode) { - onSubstituteNode(hint, node, pipelineEmitWithHint); + onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); } else { pipelineEmitWithHint(hint, node); @@ -49120,200 +51210,204 @@ var ts; return; } switch (kind) { - case 13: case 14: case 15: + case 16: return emitLiteral(node); - case 70: + case 71: return emitIdentifier(node); - case 142: - return emitQualifiedName(node); case 143: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 144: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 145: - return emitParameter(node); + return emitTypeParameter(node); case 146: - return emitDecorator(node); + return emitParameter(node); case 147: - return emitPropertySignature(node); + return emitDecorator(node); case 148: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 149: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 150: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 151: - return emitConstructor(node); + return emitMethodDeclaration(node); case 152: + return emitConstructor(node); case 153: - return emitAccessorDeclaration(node); case 154: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 155: - return emitConstructSignature(node); + return emitCallSignature(node); case 156: - return emitIndexSignature(node); + return emitConstructSignature(node); case 157: - return emitTypePredicate(node); + return emitIndexSignature(node); case 158: - return emitTypeReference(node); + return emitTypePredicate(node); case 159: - return emitFunctionType(node); + return emitTypeReference(node); case 160: - return emitConstructorType(node); + return emitFunctionType(node); case 161: - return emitTypeQuery(node); + return emitConstructorType(node); case 162: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 163: - return emitArrayType(node); + return emitTypeLiteral(node); case 164: - return emitTupleType(node); + return emitArrayType(node); case 165: - return emitUnionType(node); + return emitTupleType(node); case 166: - return emitIntersectionType(node); + return emitUnionType(node); case 167: - return emitParenthesizedType(node); - case 200: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 168: - return emitThisType(); + return emitParenthesizedType(node); + case 201: + return emitExpressionWithTypeArguments(node); case 169: - return emitTypeOperator(node); + return emitThisType(); case 170: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 171: - return emitMappedType(node); + return emitIndexedAccessType(node); case 172: - return emitLiteralType(node); + return emitMappedType(node); case 173: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 174: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 175: + return emitArrayBindingPattern(node); + case 176: return emitBindingElement(node); - case 204: - return emitTemplateSpan(node); case 205: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 206: - return emitBlock(node); + return emitSemicolonClassElement(); case 207: - return emitVariableStatement(node); + return emitBlock(node); case 208: - return emitEmptyStatement(); + return emitVariableStatement(node); case 209: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 210: - return emitIfStatement(node); + return emitExpressionStatement(node); case 211: - return emitDoStatement(node); + return emitIfStatement(node); case 212: - return emitWhileStatement(node); + return emitDoStatement(node); case 213: - return emitForStatement(node); + return emitWhileStatement(node); case 214: - return emitForInStatement(node); + return emitForStatement(node); case 215: - return emitForOfStatement(node); + return emitForInStatement(node); case 216: - return emitContinueStatement(node); + return emitForOfStatement(node); case 217: - return emitBreakStatement(node); + return emitContinueStatement(node); case 218: - return emitReturnStatement(node); + return emitBreakStatement(node); case 219: - return emitWithStatement(node); + return emitReturnStatement(node); case 220: - return emitSwitchStatement(node); + return emitWithStatement(node); case 221: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 222: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 223: - return emitTryStatement(node); + return emitThrowStatement(node); case 224: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 225: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 226: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 227: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 228: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 229: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 230: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 231: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 232: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 233: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 234: + return emitModuleBlock(node); + case 235: return emitCaseBlock(node); - case 236: - return emitImportEqualsDeclaration(node); case 237: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 238: - return emitImportClause(node); + return emitImportDeclaration(node); case 239: - return emitNamespaceImport(node); + return emitImportClause(node); case 240: - return emitNamedImports(node); + return emitNamespaceImport(node); case 241: - return emitImportSpecifier(node); + return emitNamedImports(node); case 242: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 243: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 244: - return emitNamedExports(node); + return emitExportDeclaration(node); case 245: - return emitExportSpecifier(node); + return emitNamedExports(node); case 246: - return; + return emitExportSpecifier(node); case 247: + return; + case 248: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 250: - return emitJsxOpeningElement(node); case 251: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 252: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 253: - return emitJsxAttributes(node); + return emitJsxAttribute(node); case 254: - return emitJsxSpreadAttribute(node); + return emitJsxAttributes(node); case 255: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 256: - return emitCaseClause(node); + return emitJsxExpression(node); case 257: - return emitDefaultClause(node); + return emitCaseClause(node); case 258: - return emitHeritageClause(node); + return emitDefaultClause(node); case 259: - return emitCatchClause(node); + return emitHeritageClause(node); case 260: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 261: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 262: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 263: + return emitSpreadAssignment(node); + case 264: return emitEnumMember(node); } if (ts.isExpression(node)) { - return pipelineEmitWithSubstitution(1, node); + return pipelineEmitExpression(trySubstituteNode(1, node)); + } + if (ts.isToken(node)) { + writeTokenText(kind); + return; } } function pipelineEmitExpression(node) { @@ -49322,87 +51416,82 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 11: case 12: + case 13: return emitLiteral(node); - case 70: + case 71: return emitIdentifier(node); - case 85: - case 94: - case 96: - case 100: - case 98: + case 86: + case 95: + case 97: + case 101: + case 99: writeTokenText(kind); return; - case 176: - return emitArrayLiteralExpression(node); case 177: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 178: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 179: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 180: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 181: - return emitNewExpression(node); + return emitCallExpression(node); case 182: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 183: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 184: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 185: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 186: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 187: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 188: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 189: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 190: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 191: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 192: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 193: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 194: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 195: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 196: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 197: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 198: - return emitClassExpression(node); + return emitSpreadExpression(node); case 199: + return emitClassExpression(node); + case 200: return; - case 201: - return emitAsExpression(node); case 202: - return emitNonNullExpression(node); + return emitAsExpression(node); case 203: + return emitNonNullExpression(node); + case 204: return emitMetaProperty(node); - case 248: - return emitJsxElement(node); case 249: + return emitJsxElement(node); + case 250: return emitJsxSelfClosingElement(node); - case 298: + case 296: return emitPartiallyEmittedExpression(node); } } - function emitBodyIndirect(node, elements, emitCallback) { - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(node, elements, emitCallback); - } - else { - emitCallback(node); - } + function trySubstituteNode(hint, node) { + return node && substituteNode && substituteNode(hint, node) || node; } function emitHelpersIndirect(node) { if (onEmitHelpers) { @@ -49411,9 +51500,6 @@ var ts; } function emitNumericLiteral(node) { emitLiteral(node); - if (node.trailingComment) { - write(" /*" + node.trailingComment + "*/"); - } } function emitLiteral(node) { var text = getLiteralTextOfNode(node); @@ -49434,7 +51520,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -49456,8 +51542,8 @@ var ts; writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator) { write("@"); @@ -49504,7 +51590,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 152 ? "get " : "set "); + write(node.kind === 153 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -49665,12 +51751,12 @@ var ts; write("{}"); } else { - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = languageVersion >= 1 ? 32 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; emitList(node, properties, 978 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -49680,10 +51766,10 @@ var ts; function emitPropertyAccessExpression(node) { var indentBeforeDot = false; var indentAfterDot = false; - if (!(ts.getEmitFlags(node) & 65536)) { + if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 23, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -49696,11 +51782,11 @@ var ts; decreaseIndentIf(indentBeforeDot, indentAfterDot); } function needsDotDotForPropertyAccess(expression) { - if (expression.kind === 8) { + expression = ts.skipPartiallyEmittedExpressions(expression); + if (ts.isNumericLiteral(expression)) { var text = getLiteralTextOfNode(expression); - return ts.getNumericLiteralFlags(text, 15) === 0 - && !expression.isOctalLiteral - && text.indexOf(ts.tokenToString(22)) < 0; + return !expression.numericLiteralFlags + && text.indexOf(ts.tokenToString(23)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -49781,16 +51867,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 191 - && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) - || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); + return operand.kind === 192 + && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) + || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 25; + var isCommaOperator = node.operatorToken.kind !== 26; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -49858,17 +51944,17 @@ var ts; } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(16, node.pos, node); + writeToken(17, node.pos, node); write(" "); - writeToken(17, node.statements.end, node); + writeToken(18, node.statements.end, node); } else { - writeToken(16, node.pos, node); + writeToken(17, node.pos, node); emitBlockStatements(node); increaseIndent(); emitLeadingCommentsOfPosition(node.statements.end); decreaseIndent(); - writeToken(17, node.statements.end, node); + writeToken(18, node.statements.end, node); } } function emitBlockStatements(node) { @@ -49892,16 +51978,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(89, node.pos, node); + var openParenPos = writeToken(90, node.pos, node); write(" "); - writeToken(18, openParenPos, node); + writeToken(19, openParenPos, node); emitExpression(node.expression); - writeToken(19, node.expression.end, node); + writeToken(20, node.expression.end, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 210) { + writeToken(82, node.thenStatement.end, node); + if (node.elseStatement.kind === 211) { write(" "); emit(node.elseStatement); } @@ -49930,9 +52016,9 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos, node); + writeToken(19, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -49942,28 +52028,29 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos); + emitWithSuffix(node.awaitModifier, " "); + writeToken(19, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 226) { + if (node.kind === 227) { emit(node); } else { @@ -49972,17 +52059,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(71, node.pos); + writeToken(72, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(95, node.pos, node); + writeToken(96, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -49993,11 +52080,11 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(97, node.pos); + var openParenPos = writeToken(98, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); write(" "); emit(node.caseBlock); } @@ -50025,7 +52112,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(77, node.pos); + writeToken(78, node.pos); write(";"); } function emitVariableDeclaration(node) { @@ -50047,22 +52134,35 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint, body) { + emitBlockFunctionBody(body); + } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } - if (ts.getEmitFlags(node) & 262144) { + if (ts.getEmitFlags(node) & 524288) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } if (indentedFlag) { @@ -50115,9 +52215,14 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - emitBodyIndirect(body, body.statements, emitBlockFunctionBody); + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); + } + else { + emitBlockFunctionBody(body); + } decreaseIndent(); - writeToken(17, body.statements.end, body); + writeToken(18, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -50143,7 +52248,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } @@ -50194,7 +52299,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 232) { + while (body.kind === 233) { write("."); emit(body.name); body = body.body; @@ -50209,16 +52314,15 @@ var ts; else { pushNameGenerationScope(); write("{"); - increaseIndent(); emitBlockStatements(node); write("}"); popNameGenerationScope(); } } function emitCaseBlock(node) { - writeToken(16, node.pos); + writeToken(17, node.pos); emitList(node, node.clauses, 65); - writeToken(17, node.clauses.end); + writeToken(18, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -50229,7 +52333,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -50359,7 +52463,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -50396,11 +52500,11 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - var openParenPos = writeToken(73, node.pos); + var openParenPos = writeToken(74, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emit(node.variableDeclaration); - writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(20, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -50433,27 +52537,43 @@ var ts; } function emitSourceFile(node) { writeLine(); - emitShebang(); - emitBodyIndirect(node, node.statements, emitSourceFileWorker); + var statements = node.statements; + if (emitBodyWithDetachedComments) { + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; + } + } + emitSourceFileWorker(node); } function emitSourceFileWorker(node) { var statements = node.statements; - var statementOffset = emitPrologueDirectives(statements); pushNameGenerationScope(); emitHelpersIndirect(node); - emitList(node, statements, 1, statementOffset); + var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); + emitList(node, statements, 1, index === -1 ? statements.length : index); popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); } - function emitPrologueDirectives(statements, startWithNewLine) { + function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { for (var i = 0; i < statements.length; i++) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); + var statement = statements[i]; + if (ts.isPrologueDirective(statement)) { + var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; + if (shouldEmitPrologueDirective) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statement); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(statement.expression.text, statement.expression.text); + } } - emit(statements[i]); } else { return i; @@ -50461,11 +52581,36 @@ var ts; } return statements.length; } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - writeLine(); + function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + setSourceFile(sourceFileOrBundle); + emitPrologueDirectives(sourceFileOrBundle.statements); + } + else { + var seenPrologueDirectives = ts.createMap(); + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + setSourceFile(sourceFile); + emitPrologueDirectives(sourceFile.statements, true, seenPrologueDirectives); + } + } + } + function emitShebangIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + var shebang = ts.getShebang(sourceFileOrBundle.text); + if (shebang) { + write(shebang); + writeLine(); + return true; + } + } + else { + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + if (emitShebangIfNeeded(sourceFile)) { + break; + } + } } } function emitModifiers(node, modifiers) { @@ -50550,6 +52695,9 @@ var ts; if (format & 7680) { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } if (isEmpty) { if (format & 1) { writeLine(); @@ -50626,6 +52774,9 @@ var ts; write(" "); } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } if (format & 7680) { write(getClosingBracket(format)); } @@ -50687,7 +52838,7 @@ var ts; for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { var line = lines_1[_a]; for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) { if (indentation === undefined || i < indentation) { indentation = i; break; @@ -50810,7 +52961,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 184 && ts.nodeIsSynthesized(node)) { + while (node.kind === 185 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -50840,7 +52991,7 @@ var ts; return getLiteralTextOfNode(textSourceNode); } } - return ts.getLiteralText(node, currentSourceFile, languageVersion); + return ts.getLiteralText(node, currentSourceFile); } function pushNameGenerationScope() { tempFlagsStack.push(tempFlags); @@ -50938,23 +53089,23 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 70: + case 71: return makeUniqueName(getTextOfNode(node)); + case 233: case 232: - case 231: return generateNameForModuleOrEnum(node); - case 237: - case 243: + case 238: + case 244: return generateNameForImportOrExportDeclaration(node); - case 227: case 228: - case 242: + case 229: + case 243: return generateNameForExportDefault(); - case 198: + case 199: return generateNameForClassExpression(); - case 150: - case 152: + case 151: case 153: + case 154: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); @@ -51017,6 +53168,7 @@ var ts; var ts; (function (ts) { var emptyArray = []; + var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } while (true) { @@ -51076,7 +53228,6 @@ var ts; function getCanonicalFileName(fileName) { return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - var unsupportedFileEncodingErrorCode = -2147024809; function getSourceFile(fileName, languageVersion, onError) { var text; try { @@ -51087,9 +53238,7 @@ var ts; } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } @@ -51252,6 +53401,8 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; + var cachedSemanticDiagnosticsForFile = {}; + var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; @@ -51411,7 +53562,7 @@ var ts; : emptyArray; var j = 0; for (var i = 0; i < result.length; i++) { - if (result[i] == predictedToResolveToAmbientModuleMarker) { + if (result[i] === predictedToResolveToAmbientModuleMarker) { result[i] = undefined; } else { @@ -51562,13 +53713,13 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -51589,7 +53740,8 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -51650,16 +53802,45 @@ var ts; } } function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + var includeCheckDiagnostics = !ts.isSourceFileJavaScript(sourceFile) || ts.isCheckJsEnabledForFile(sourceFile, options); + var checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return ts.isSourceFileJavaScript(sourceFile) + ? ts.filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + function shouldReportDiagnostic(diagnostic) { + var file = diagnostic.file, start = diagnostic.start; + if (file) { + var lineStarts = ts.getLineStarts(file); + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + while (line > 0) { + var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + return true; + } + if (result[3]) { + return false; + } + line--; + } + } + return true; + } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; @@ -51668,57 +53849,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 145: - case 148: + case 146: + case 149: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: - case 227: - case 225: + case 228: + case 187: + case 228: + case 226: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 236: + case 237: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 242: + case 243: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 258: + case 259: var heritageClause = node; - if (heritageClause.token === 107) { + if (heritageClause.token === 108) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 232: + case 233: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 231: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 183: + case 184: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -51733,53 +53914,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, 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)); } switch (parent.kind) { - case 228: - case 150: - case 149: + case 229: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: - case 227: + case 228: + case 187: + case 228: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 207: + case 208: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 207); + return checkModifiers(nodes, parent.kind === 208); } break; - case 148: + case 149: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 114) { + if (modifier.kind !== 115) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 145: + case 146: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 180: case 181: - case 200: + case 182: + case 201: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; } break; } - for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { - var node = nodes_6[_b]; + for (var _b = 0, nodes_8 = nodes; _b < nodes_8.length; _b++) { + var node = nodes_8[_b]; walk(node); } } @@ -51787,21 +53968,21 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 75: + case 76: if (isConstValid) { continue; } - case 113: - case 111: + case 114: case 112: - case 130: - case 123: - case 116: + case 113: + case 131: + case 124: + case 117: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; - case 114: - case 83: - case 78: + case 115: + case 84: + case 79: } } } @@ -51815,11 +53996,33 @@ var ts; }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } + function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) { + var cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + if (cachedResult) { + return cachedResult; + } + var result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = ts.createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } @@ -51878,9 +54081,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 238: case 237: - case 236: - case 243: + case 244: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -51892,7 +54095,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 232: + case 233: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -51976,7 +54179,7 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); @@ -52134,8 +54337,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var file = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var file = sourceFiles_2[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -52146,8 +54349,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var sourceFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -52240,7 +54443,7 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } - if (options.noImplicitUseStrict && options.alwaysStrict) { + if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); } var languageVersion = options.target || 0; @@ -52280,6 +54483,9 @@ var ts; if (!options.noEmit && options.allowJs && options.declaration) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); @@ -52355,40 +54561,12 @@ var ts; (function (ts) { ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, }, { @@ -52396,215 +54574,52 @@ var ts; shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMapFromTemplate({ - "preserve": 1, - "react-native": 3, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMapFromTemplate({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMapFromTemplate({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, { name: "project", shortName: "p", type: "string", isFilePath: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { - name: "removeComments", + name: "pretty", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", + name: "watch", + shortName: "w", type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Watch_input_files, }, { name: "target", @@ -52618,133 +54633,27 @@ var ts; "es2017": 4, "esnext": 5, }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, paramType: ts.Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", + name: "module", + shortName: "m", type: ts.createMapFromTemplate({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - 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: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_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 - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -52758,6 +54667,7 @@ var ts; "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", "webworker": "lib.webworker.d.ts", @@ -52775,29 +54685,466 @@ var ts; "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1, + "react-native": 3, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + { + name: "noUnusedLocals", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + paramType: ts.Diagnostics.STRATEGY, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + { + name: "experimentalDecorators", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "jsxFactory", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + { + name: "out", + type: "string", + isFilePath: false, + category: ts.Diagnostics.Advanced_Options, + paramType: ts.Diagnostics.FILE, + description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0, + "lf": 1 + }), + paramType: ts.Diagnostics.NEWLINE, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, { name: "plugins", type: "list", @@ -52805,7 +55152,8 @@ var ts; element: { name: "plugin", type: "object" - } + }, + description: ts.Diagnostics.List_of_language_service_plugins } ]; ts.typeAcquisitionDeclarations = [ @@ -52837,8 +55185,7 @@ var ts; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1, - noImplicitAny: false, - sourceMap: false, + strict: true }; var optionNameMapCache; function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -53029,7 +55376,7 @@ var ts; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { + function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -53037,7 +55384,7 @@ var ts; if (fileNames && fileNames.length) { configurations.files = fileNames; } - return configurations; + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition) { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { return undefined; @@ -53061,41 +55408,110 @@ var ts; var optionsNameMap = getOptionNameMap().optionNameMap; for (var name in options) { if (ts.hasProperty(options, name)) { - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + continue; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return ts.arrayFrom(option.type.keys())[0]; + } + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + var categorizedOptions = ts.reduceLeft(ts.filter(ts.optionDeclarations, function (o) { return o.category !== ts.Diagnostics.Command_line_Options && o.category !== ts.Diagnostics.Advanced_Options; }), function (memo, value) { + if (value.category) { + var name = ts.getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, {}); + var marginLength = 0; + var seenKnownKeys = 0; + var nameColumn = []; + var descriptionColumn = []; + var knownKeysCount = ts.getOwnKeys(configurations.compilerOptions).length; + for (var category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push("/* " + category + " */"); + descriptionColumn.push(""); + for (var _i = 0, _a = categorizedOptions[category]; _i < _a.length; _i++) { + var option = _a[_i]; + var optionName = void 0; + if (ts.hasProperty(configurations.compilerOptions, option.name)) { + optionName = "\"" + option.name + "\": " + JSON.stringify(configurations.compilerOptions[option.name]) + ((seenKnownKeys += 1) === knownKeysCount ? "" : ","); + } + else { + optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + } + nameColumn.push(optionName); + descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + marginLength = Math.max(optionName.length, marginLength); + } + } + var tab = makePadding(2); + var result = []; + result.push("{"); + result.push(tab + "\"compilerOptions\": {"); + for (var i = 0; i < nameColumn.length; i++) { + var optionName = nameColumn[i]; + var description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(tab + "},"); + result.push(tab + "\"files\": ["); + for (var i = 0; i < configurations.files.length; i++) { + result.push("" + tab + tab + JSON.stringify(configurations.files[i]) + (i === configurations.files.length - 1 ? "" : ",")); + } + result.push(tab + "]"); + } + else { + result.push(tab + "}"); + } + result.push("}"); + return result.join(newLine); + } } ts.generateTSConfig = generateTSConfig; function removeComments(jsonText) { @@ -53136,10 +55552,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -53159,6 +55576,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -53196,7 +55616,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -53439,7 +55859,6 @@ var ts; } } } - ; } return wildcardDirectories; } @@ -53502,7 +55921,7 @@ var ts; } } function reportEmittedFiles(files) { - if (!files || files.length == 0) { + if (!files || files.length === 0) { return; } var currentDir = ts.sys.getCurrentDirectory(); @@ -53550,9 +55969,9 @@ var ts; function reportDiagnosticWithColorAndContext(diagnostic, host) { var output = ""; if (diagnostic.file) { - var start = diagnostic.start, length_4 = diagnostic.length, file = diagnostic.file; + var start = diagnostic.start, length_5 = diagnostic.length, file = diagnostic.file; var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character; - var _b = ts.getLineAndCharacterOfPosition(file, start + length_4), lastLine = _b.line, lastLineChar = _b.character; + var _b = ts.getLineAndCharacterOfPosition(file, start + length_5), lastLine = _b.line, lastLineChar = _b.character; var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line; var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName; var hasMoreThanFiveLines = (lastLine - firstLine) >= 4; @@ -53656,9 +56075,9 @@ var ts; printVersion(); return ts.sys.exit(ts.ExitStatus.Success); } - if (commandLine.options.help) { + if (commandLine.options.help || commandLine.options.all) { printVersion(); - printHelp(); + printHelp(commandLine.options.all); return ts.sys.exit(ts.ExitStatus.Success); } if (commandLine.options.project) { @@ -53692,7 +56111,7 @@ var ts; } if (commandLine.fileNames.length === 0 && !configFileName) { printVersion(); - printHelp(); + printHelp(commandLine.options.all); return ts.sys.exit(ts.ExitStatus.Success); } if (ts.isWatchSet(commandLine.options)) { @@ -53705,7 +56124,7 @@ var ts; } if (ts.sys.watchDirectory && configFileName) { var directory = ts.getDirectoryPath(configFileName); - directoryWatcher = ts.sys.watchDirectory(directory == "" ? "." : directory, watchedDirectoryChanged, true); + directoryWatcher = ts.sys.watchDirectory(directory === "" ? "." : directory, watchedDirectoryChanged, true); } } performCompilation(); @@ -53748,9 +56167,8 @@ var ts; } if (!directoryWatcher && ts.sys.watchDirectory && configFileName) { var directory = ts.getDirectoryPath(configFileName); - directoryWatcher = ts.sys.watchDirectory(directory == "" ? "." : directory, watchedDirectoryChanged, true); + directoryWatcher = ts.sys.watchDirectory(directory === "" ? "." : directory, watchedDirectoryChanged, true); } - ; } return configParseResult; } @@ -53965,7 +56383,7 @@ var ts; function printVersion() { ts.sys.write(getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + ts.sys.newLine); } - function printHelp() { + function printHelp(showAllOptions) { var output = []; var syntaxLength = getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length; var examplesLength = getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length; @@ -53977,11 +56395,12 @@ var ts; var padding = makePadding(marginLength); output.push(getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + ts.sys.newLine); output.push(padding + "tsc --outFile file.js file.ts" + ts.sys.newLine); - output.push(padding + "tsc --project tsconfig.json" + ts.sys.newLine); + output.push(padding + "tsc @args.txt" + ts.sys.newLine); output.push(ts.sys.newLine); output.push(getDiagnosticText(ts.Diagnostics.Options_Colon) + ts.sys.newLine); - var optsList = ts.filter(ts.optionDeclarations.slice(), function (v) { return !v.experimental; }); - optsList.sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }); + var optsList = showAllOptions ? + ts.optionDeclarations.slice().sort(function (a, b) { return ts.compareValues(a.name.toLowerCase(), b.name.toLowerCase()); }) : + ts.filter(ts.optionDeclarations.slice(), function (v) { return v.showInSimplifiedHelpView; }); marginLength = 0; var usageColumn = []; var descriptionColumn = []; @@ -54053,7 +56472,7 @@ var ts; reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file), undefined); } else { - ts.sys.writeFile(file, JSON.stringify(ts.generateTSConfig(options, fileNames), undefined, 4)); + ts.sys.writeFile(file, ts.generateTSConfig(options, fileNames, ts.sys.newLine)); reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file), undefined); } return; diff --git a/lib/tsserver.js b/lib/tsserver.js index 04ad7e50ce9..05f4c1e5fd1 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -13,6 +13,14 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || @@ -38,326 +46,324 @@ var ts; SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; - SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; - SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; - SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; - SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; - SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; - SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 126] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 127] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 128] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 129] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 130] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 131] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 132] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 133] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 134] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 135] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 136] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 137] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 138] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 139] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 140] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 141] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 142] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 143] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 144] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 145] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 146] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 147] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 149] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 151] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 152] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 153] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 154] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 155] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 156] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 157] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 158] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 159] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 160] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 161] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 162] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 163] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 164] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 165] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 166] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 167] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 168] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 169] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 170] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 171] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 172] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 173] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 174] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 175] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 176] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 177] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 178] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 179] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 180] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 181] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 182] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 183] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 184] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 185] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 187] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 188] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 189] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 190] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 191] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 192] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 193] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 194] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 195] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 196] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 197] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 198] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 199] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 200] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 201] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 202] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 203] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 204] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 205] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 206] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 207] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 208] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 209] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 210] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 211] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 212] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 213] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 214] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 215] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 216] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 217] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 218] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 219] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 220] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 221] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 222] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 223] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 224] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 225] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 226] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 227] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 228] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 229] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 230] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 231] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 232] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 233] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 234] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 235] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 236] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 237] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 238] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 239] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 240] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 241] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 242] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 243] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 244] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 245] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 246] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 247] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 248] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 249] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 250] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 251] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 252] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 253] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 254] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 255] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 256] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 257] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 258] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 259] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 260] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 261] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 262] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 263] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 264] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 265] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 266] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 267] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 268] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 269] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 270] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 271] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 272] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 273] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 274] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 275] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 276] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 277] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 278] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 279] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 280] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 281] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 282] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 283] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 284] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 285] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 286] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 287] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 288] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 289] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 290] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 291] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 293] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["SyntaxList"] = 294] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 295] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 296] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 297] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 298] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 299] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 142] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 158] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 173] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 142] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 143] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 267] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 293] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 283] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 293] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -429,6 +435,16 @@ var ts; GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 2] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["HexSpecifier"] = 8] = "HexSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinarySpecifier"] = 16] = "BinarySpecifier"; + NumericLiteralFlags[NumericLiteralFlags["OctalSpecifier"] = 32] = "OctalSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalSpecifier"] = 48] = "BinaryOrOctalSpecifier"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -459,6 +475,16 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + NodeBuilderFlags[NodeBuilderFlags["allowThisInObjectLiteral"] = 1] = "allowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["allowQualifedNameInPlaceOfIdentifier"] = 2] = "allowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowTypeParameterInQualifiedName"] = 4] = "allowTypeParameterInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["allowAnonymousIdentifier"] = 8] = "allowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyUnionOrIntersection"] = 16] = "allowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyTuple"] = 32] = "allowEmptyTuple"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); var TypeFormatFlags; (function (TypeFormatFlags) { TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; @@ -582,13 +608,15 @@ var ts; (function (CheckFlags) { CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; - CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; - CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; - CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; - CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; - CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; - CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; - CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod"; + CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 16] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; + CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var NodeCheckFlags; (function (NodeCheckFlags) { @@ -674,7 +702,6 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -694,6 +721,7 @@ var ts; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property"; })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -974,13 +1002,15 @@ var ts; EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; - EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; - EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName"; + EmitFlags[EmitFlags["Indented"] = 65536] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); var ExternalEmitHelpers; (function (ExternalEmitHelpers) { @@ -992,8 +1022,17 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values"; + ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read"; + ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 2048] = "AsyncGenerator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 4096] = "AsyncDelegator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 8192] = "AsyncValues"; + ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 8192] = "ForAwaitOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes"; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; - ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 8192] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); var EmitHint; (function (EmitHint) { @@ -1064,7 +1103,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.3.0"; + ts.version = "2.4.0"; })(ts || (ts = {})); (function (ts) { var Ternary; @@ -1228,6 +1267,20 @@ var ts; return undefined; } ts.forEach = forEach; + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; function zipWith(arrayA, arrayB, callback) { Debug.assert(arrayA.length === arrayB.length); for (var i = 0; i < arrayA.length; i++) { @@ -1781,10 +1834,10 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function arrayFrom(iterator) { + function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { - result.push(value); + result.push(map ? map(value) : value); } return result; var _b; @@ -1837,10 +1890,10 @@ var ts; } for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { var arg = args_1[_a]; - for (var _b = 0, _c = getOwnKeys(arg); _b < _c.length; _b++) { - var p = _c[_b]; - t[p] = arg[p]; - } + for (var p in arg) + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } } return t; } @@ -2980,136 +3033,29 @@ var ts; } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; + function isCheckJsEnabledForFile(sourceFile, compilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; })(ts || (ts = {})); var ts; (function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var shell = new ActiveXObject("WScript.Shell"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function getDirectories(path) { - var folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - function getAccessibleFileSystemEntries(path) { - try { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - var directories = getNames(folder.subfolders); - return { files: files, directories: directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function readDirectory(path, extensions, excludes, includes) { - return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - var wscriptSystem = { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return shell.CurrentDirectory; - }, - getDirectories: getDirectories, - getEnvironmentVariable: function (name) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings("%" + name + "%"); - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; + function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; } + var version = process.version; + if (!version) { + return undefined; + } + var dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + ts.getNodeMajorVersion = getNodeMajorVersion; + ts.sys = (function () { function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); @@ -3173,9 +3119,8 @@ var ts; } } var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } + var nodeVersion = getNodeMajorVersion(); + var isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive() { if (platform === "win32" || platform === "win64") { return false; @@ -3314,10 +3259,10 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + if (!directoryExists(directoryName)) { return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { @@ -3327,11 +3272,7 @@ var ts; if (eventName === "rename") { callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName))); } - ; }); - function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; - } }, resolvePath: function (path) { return _path.resolve(path); @@ -3447,9 +3388,6 @@ var ts; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { sys = getNodeSystem(); } @@ -3518,11 +3456,11 @@ var ts; Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", message: "The return type of an async function must either be a valid promise or must not contain a callable 'then' member." }, + A_promise_must_have_a_then_method: { code: 1059, category: ts.DiagnosticCategory.Error, key: "A_promise_must_have_a_then_method_1059", message: "A promise must have a 'then' method." }, + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: { code: 1060, category: ts.DiagnosticCategory.Error, key: "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", message: "The first parameter of the 'then' method of a promise must be a callback." }, 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." }, + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "Type 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." }, @@ -3547,6 +3485,7 @@ var ts; Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: { code: 1103, category: ts.DiagnosticCategory.Error, key: "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", message: "A 'for-await-of' statement is only allowed within an async function or async generator." }, A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, @@ -3554,7 +3493,7 @@ var ts; Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'." }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, @@ -3586,9 +3525,9 @@ var ts; 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_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." }, - 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" }, + 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" }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized." }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, @@ -3637,8 +3576,8 @@ var ts; Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_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." }, @@ -3690,6 +3629,9 @@ var ts; A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1320, category: ts.DiagnosticCategory.Error, key: "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", message: "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1321, category: ts.DiagnosticCategory.Error, key: "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", message: "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1322, category: ts.DiagnosticCategory.Error, key: "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", message: "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -3751,13 +3693,13 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'." }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, @@ -3797,12 +3739,12 @@ var ts; The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class." }, The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - 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_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}'." }, 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}'." }, @@ -3811,19 +3753,19 @@ var ts; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, 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}'" }, + 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_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}'" }, + 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." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged." }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged." }, Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name." }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'." }, Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'." }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, @@ -3832,18 +3774,20 @@ 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." }, + Class_0_used_before_its_declaration: { code: 2449, category: ts.DiagnosticCategory.Error, key: "Class_0_used_before_its_declaration_2449", message: "Class '{0}' used before its declaration." }, + Enum_0_used_before_its_declaration: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Enum_0_used_before_its_declaration_2450", message: "Enum '{0}' used before its declaration." }, 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." }, Variable_0_is_used_before_being_assigned: { code: 2454, category: ts.DiagnosticCategory.Error, key: "Variable_0_is_used_before_being_assigned_2454", message: "Variable '{0}' is used before being assigned." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'." }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern." }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -3864,13 +3808,13 @@ var ts; let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, 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}'" }, + 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_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, 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." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause." }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, @@ -3882,6 +3826,7 @@ var ts; A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: { code: 2504, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", message: "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, @@ -3896,6 +3841,7 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, + An_async_iterator_must_have_a_next_method: { code: 2519, category: ts.DiagnosticCategory.Error, key: "An_async_iterator_must_have_a_next_method_2519", message: "An async iterator must have a 'next()' method." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", message: "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method." }, @@ -3923,25 +3869,29 @@ var ts; Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, + The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: { code: 2547, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", message: "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property." }, + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2548, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", message: "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2549, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", message: "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: { code: 2550, category: ts.DiagnosticCategory.Error, key: "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", message: "Generic type instantiation is excessively deep and possibly infinite." }, 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." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'." }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property." }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property." }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React." }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, - Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element." }, + Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'." }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", message: "Cannot export '{0}'. Only local declarations can be exported from a module." }, @@ -3973,7 +3923,6 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, - A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { code: 2693, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", message: "'{0}' only refers to a type, but is being used as a value here." }, @@ -3986,11 +3935,14 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, - The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference." }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property." }, An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, + Cannot_use_namespace_0_as_a_value: { code: 2708, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_value_2708", message: "Cannot use namespace '{0}' as a value." }, + Cannot_use_namespace_0_as_a_type: { code: 2709, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_type_2709", message: "Cannot use namespace '{0}' as a type." }, + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: { code: 2710, category: ts.DiagnosticCategory.Error, key: "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", message: "'{0}' are specified twice. The attribute named '{0}' will be overwritten." }, 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}'." }, @@ -4070,12 +4022,11 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { code: 5011, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011", message: "File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}." }, Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", message: "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, @@ -4084,12 +4035,12 @@ var ts; A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, 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}'" }, + 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}'." }, 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" }, + 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." }, Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." }, Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, @@ -4107,11 +4058,11 @@ var ts; Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'." }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -4131,7 +4082,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_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}" }, + Argument_for_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}." }, 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}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, @@ -4153,18 +4104,18 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context (experimental)." }, Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'." }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, 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}." }, 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." }, - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", message: "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit" }, Enable_tracing_of_the_name_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_name_resolution_process_6085", message: "Enable tracing of the name 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}'." }, @@ -4186,12 +4137,12 @@ var ts; 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_0_field_in_package_json_to_be_string_got_1: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", message: "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'." }, - 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" }, + 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." }, Enable_strict_null_checks: { code: 6113, category: ts.DiagnosticCategory.Message, key: "Enable_strict_null_checks_6113", message: "Enable strict null checks." }, Unknown_option_excludes_Did_you_mean_exclude: { code: 6114, category: ts.DiagnosticCategory.Error, key: "Unknown_option_excludes_Did_you_mean_exclude_6114", message: "Unknown option 'excludes'. Did you mean 'exclude'?" }, @@ -4201,26 +4152,26 @@ var ts; Resolving_from_node_modules_folder: { code: 6118, category: ts.DiagnosticCategory.Message, key: "Resolving_from_node_modules_folder_6118", message: "Resolving from node_modules folder..." }, Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { code: 6119, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", message: "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========" }, Type_reference_directive_0_was_not_resolved: { code: 6120, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_not_resolved_6120", message: "======== Type reference directive '{0}' was not resolved. ========" }, - Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'" }, + Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'." }, Root_directory_cannot_be_determined_skipping_primary_search_paths: { code: 6122, category: ts.DiagnosticCategory.Message, key: "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", message: "Root directory cannot be determined, skipping primary search paths." }, Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { code: 6123, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", message: "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========" }, Type_declaration_files_to_be_included_in_compilation: { code: 6124, category: ts.DiagnosticCategory.Message, key: "Type_declaration_files_to_be_included_in_compilation_6124", message: "Type declaration files to be included in compilation." }, - Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'" }, + Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'." }, Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { code: 6126, category: ts.DiagnosticCategory.Message, key: "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", message: "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { code: 6127, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", message: "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========" }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" }, The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." }, - Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, + Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'." }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, - File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it." }, _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files." }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file." }, Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, @@ -4228,6 +4179,40 @@ var ts; Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, + Show_diagnostic_information: { code: 6149, category: ts.DiagnosticCategory.Message, key: "Show_diagnostic_information_6149", message: "Show diagnostic information." }, + Show_verbose_diagnostic_information: { code: 6150, category: ts.DiagnosticCategory.Message, key: "Show_verbose_diagnostic_information_6150", message: "Show verbose diagnostic information." }, + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: { code: 6151, category: ts.DiagnosticCategory.Message, key: "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", message: "Emit a single file with source maps instead of having a separate file." }, + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: { code: 6152, category: ts.DiagnosticCategory.Message, key: "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", message: "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set." }, + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: { code: 6153, category: ts.DiagnosticCategory.Message, key: "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", message: "Transpile each file as a separate module (similar to 'ts.transpileModule')." }, + Print_names_of_generated_files_part_of_the_compilation: { code: 6154, category: ts.DiagnosticCategory.Message, key: "Print_names_of_generated_files_part_of_the_compilation_6154", message: "Print names of generated files part of the compilation." }, + Print_names_of_files_part_of_the_compilation: { code: 6155, category: ts.DiagnosticCategory.Message, key: "Print_names_of_files_part_of_the_compilation_6155", message: "Print names of files part of the compilation." }, + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: { code: 6156, category: ts.DiagnosticCategory.Message, key: "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", message: "The locale used when displaying messages to the user (e.g. 'en-us')" }, + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: { code: 6157, category: ts.DiagnosticCategory.Message, key: "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", message: "Do not generate custom helper functions like '__extends' in compiled output." }, + Do_not_include_the_default_library_file_lib_d_ts: { code: 6158, category: ts.DiagnosticCategory.Message, key: "Do_not_include_the_default_library_file_lib_d_ts_6158", message: "Do not include the default library file (lib.d.ts)." }, + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: { code: 6159, category: ts.DiagnosticCategory.Message, key: "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", message: "Do not add triple-slash references or imported modules to the list of compiled files." }, + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: { code: 6160, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", message: "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files." }, + List_of_folders_to_include_type_definitions_from: { code: 6161, category: ts.DiagnosticCategory.Message, key: "List_of_folders_to_include_type_definitions_from_6161", message: "List of folders to include type definitions from." }, + Disable_size_limitations_on_JavaScript_projects: { code: 6162, category: ts.DiagnosticCategory.Message, key: "Disable_size_limitations_on_JavaScript_projects_6162", message: "Disable size limitations on JavaScript projects." }, + The_character_set_of_the_input_files: { code: 6163, category: ts.DiagnosticCategory.Message, key: "The_character_set_of_the_input_files_6163", message: "The character set of the input files." }, + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: { code: 6164, category: ts.DiagnosticCategory.Message, key: "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", message: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." }, + Do_not_truncate_error_messages: { code: 6165, category: ts.DiagnosticCategory.Message, key: "Do_not_truncate_error_messages_6165", message: "Do not truncate error messages." }, + Output_directory_for_generated_declaration_files: { code: 6166, category: ts.DiagnosticCategory.Message, key: "Output_directory_for_generated_declaration_files_6166", message: "Output directory for generated declaration files." }, + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: { code: 6167, category: ts.DiagnosticCategory.Message, key: "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", message: "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'." }, + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: { code: 6168, category: ts.DiagnosticCategory.Message, key: "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", message: "List of root folders whose combined content represents the structure of the project at runtime." }, + Show_all_compiler_options: { code: 6169, category: ts.DiagnosticCategory.Message, key: "Show_all_compiler_options_6169", message: "Show all compiler options." }, + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: { code: 6170, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", message: "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file" }, + Command_line_Options: { code: 6171, category: ts.DiagnosticCategory.Message, key: "Command_line_Options_6171", message: "Command-line Options" }, + Basic_Options: { code: 6172, category: ts.DiagnosticCategory.Message, key: "Basic_Options_6172", message: "Basic Options" }, + Strict_Type_Checking_Options: { code: 6173, category: ts.DiagnosticCategory.Message, key: "Strict_Type_Checking_Options_6173", message: "Strict Type-Checking Options" }, + Module_Resolution_Options: { code: 6174, category: ts.DiagnosticCategory.Message, key: "Module_Resolution_Options_6174", message: "Module Resolution Options" }, + Source_Map_Options: { code: 6175, category: ts.DiagnosticCategory.Message, key: "Source_Map_Options_6175", message: "Source Map Options" }, + Additional_Checks: { code: 6176, category: ts.DiagnosticCategory.Message, key: "Additional_Checks_6176", message: "Additional Checks" }, + Experimental_Options: { code: 6177, category: ts.DiagnosticCategory.Message, key: "Experimental_Options_6177", message: "Experimental Options" }, + Advanced_Options: { code: 6178, category: ts.DiagnosticCategory.Message, key: "Advanced_Options_6178", message: "Advanced Options" }, + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: { code: 6179, category: ts.DiagnosticCategory.Message, key: "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", message: "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'." }, + Enable_all_strict_type_checking_options: { code: 6180, category: ts.DiagnosticCategory.Message, key: "Enable_all_strict_type_checking_options_6180", message: "Enable all strict type-checking options." }, + List_of_language_service_plugins: { code: 6181, category: ts.DiagnosticCategory.Message, key: "List_of_language_service_plugins_6181", message: "List of language service plugins." }, + Scoped_package_detected_looking_in_0: { code: 6182, category: ts.DiagnosticCategory.Message, key: "Scoped_package_detected_looking_in_0_6182", message: "Scoped package detected, looking in '{0}'" }, 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." }, @@ -4245,7 +4230,7 @@ var ts; _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists." }, Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, @@ -4254,6 +4239,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, + Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: { code: 7035, category: ts.DiagnosticCategory.Error, key: "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", message: "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4277,14 +4263,14 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + 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." }, 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." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" }, Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, @@ -4293,17 +4279,24 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: '{0}'." }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig." }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, - Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, - Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, - Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}." }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}." }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." }, + Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." }, + Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'." }, + Disable_checking_for_this_file: { code: 90018, category: ts.DiagnosticCategory.Message, key: "Disable_checking_for_this_file_90018", message: "Disable checking for this file." }, + Ignore_this_error_message: { code: 90019, category: ts.DiagnosticCategory.Message, key: "Ignore_this_error_message_90019", message: "Ignore this error message." }, + Initialize_property_0_in_the_constructor: { code: 90020, category: ts.DiagnosticCategory.Message, key: "Initialize_property_0_in_the_constructor_90020", message: "Initialize property '{0}' in the constructor." }, + Initialize_static_property_0: { code: 90021, category: ts.DiagnosticCategory.Message, key: "Initialize_static_property_0_90021", message: "Initialize static property '{0}'." }, Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, + Report_errors_in_js_files: { code: 8019, category: ts.DiagnosticCategory.Message, key: "Report_errors_in_js_files_8019", message: "Report errors in .js files." }, }; })(ts || (ts = {})); var ts; @@ -4394,7 +4387,7 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) { var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -4562,7 +4555,7 @@ var ts; } directoryPathMap.set(parent, result); current = parent; - if (current == commonPrefix) { + if (current === commonPrefix) { break; } } @@ -4984,9 +4977,22 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } + function mangleScopedPackage(moduleName, state) { + if (ts.startsWith(moduleName, "@")) { + var replaceSlash = moduleName.replace(ts.directorySeparator, "__"); + if (replaceSlash !== moduleName) { + var mangled = replaceSlash.slice(1); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled); + } + return mangled; + } + } + return moduleName; + } function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { var result = cache && cache.get(containingDirectory); if (result) { @@ -5190,7 +5196,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 264) { + while (node && node.kind !== 265) { node = node.parent; } return node; @@ -5198,11 +5204,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 206: - case 234: - case 213: + case 207: + case 235: case 214: case 215: + case 216: return true; } return false; @@ -5257,6 +5263,10 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isToken(n) { + return n.kind >= 0 && n.kind <= 142; + } + ts.isToken = isToken; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -5267,18 +5277,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 296 && node._children.length > 0) { + if (node.kind === 294 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 266 && node.kind <= 295; + return node.kind >= 267 && node.kind <= 293; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 282 && node.kind <= 295; + return node.kind >= 283 && node.kind <= 293; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -5309,27 +5319,20 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } + function getLiteralText(node, sourceFile) { if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; + return getSourceTextOfNodeFromSourceFile(sourceFile, node); } switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 15: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 16: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -5337,48 +5340,6 @@ var ts; ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - return node.kind === 8 - && (getNumericLiteralFlags(text, 6) & 6) !== 0; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - var NumericLiteralFlags; - (function (NumericLiteralFlags) { - NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; - NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; - NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; - NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; - })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); - function getNumericLiteralFlags(text, hint) { - if (text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - return 2; - case 111: - case 79: - return 4; - case 120: - case 88: - return 1; - } - if (hint & 8) { - for (var i = text.length - 1; i >= 0; i--) { - switch (text.charCodeAt(i)) { - case 101: - case 69: - return 8; - } - } - } - } - return 0; - } - ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -5397,11 +5358,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 225 && node.parent.kind === 259; + return node.kind === 226 && node.parent.kind === 260; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 232 && + return node && node.kind === 233 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -5410,11 +5371,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 232 && (!node.body); + return node && node.kind === 233 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 264 || - node.kind === 232 || + return node.kind === 265 || + node.kind === 233 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -5427,9 +5388,9 @@ var ts; return false; } switch (node.parent.kind) { - case 264: + case 265: return ts.isExternalModule(node.parent); - case 233: + case 234: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -5441,22 +5402,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 264: - case 234: - case 259: - case 232: - case 213: + case 265: + case 235: + case 260: + case 233: case 214: case 215: - case 151: - case 150: + case 216: case 152: + case 151: case 153: - case 227: - case 185: + case 154: + case 228: case 186: + case 187: return true; - case 206: + case 207: return parentNode && !isFunctionLike(parentNode); } return false; @@ -5476,14 +5437,18 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getNameFromIndexInfo(info) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } + ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 70: + case 71: return name.text; case 9: case 8: return name.text; - case 143: + case 144: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -5493,11 +5458,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 70: + case 71: return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); - case 142: + case 143: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 178: + case 179: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -5534,7 +5499,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 206) { + if (node.body && node.body.kind === 207) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -5546,29 +5511,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 264: + case 265: 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 225: - case 175: - case 228: - case 198: + case 226: + case 176: case 229: - case 232: - case 231: - case 263: - case 227: - case 185: - case 150: - case 152: - case 153: + case 199: case 230: + case 233: + case 232: + case 264: + case 228: + case 186: + case 151: + case 153: + case 154: + case 231: errorNode = node.name; break; - case 186: + case 187: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -5589,7 +5554,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 231 && isConst(node); + return node.kind === 232 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -5602,11 +5567,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 180 && n.expression.kind === 96; + return n.kind === 181 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 209 + return node.kind === 210 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -5619,10 +5584,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 145 || - node.kind === 144 || - node.kind === 185 || - node.kind === 186) ? + var commentRanges = (node.kind === 146 || + node.kind === 145 || + node.kind === 186 || + node.kind === 187) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -5636,69 +5601,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (157 <= node.kind && node.kind <= 172) { + if (158 <= node.kind && node.kind <= 173) { return true; } switch (node.kind) { - case 118: - case 132: - case 135: - case 121: + case 119: + case 133: case 136: - case 138: - case 129: + case 122: + case 137: + case 139: + case 130: return true; - case 104: - return node.parent.kind !== 189; - case 200: + case 105: + return node.parent.kind !== 190; + case 201: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 142 && node.parent.right === node) { + case 71: + if (node.parent.kind === 143 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 178 && node.parent.name === node) { + else if (node.parent.kind === 179 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 142: - case 178: - case 98: + ts.Debug.assert(node.kind === 71 || node.kind === 143 || node.kind === 179, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 143: + case 179: + case 99: var parent = node.parent; - if (parent.kind === 161) { + if (parent.kind === 162) { return false; } - if (157 <= parent.kind && parent.kind <= 172) { + if (158 <= parent.kind && parent.kind <= 173) { return true; } switch (parent.kind) { - case 200: + case 201: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 144: - return node === parent.constraint; - case 148: - case 147: case 145: - case 225: + return node === parent.constraint; + case 149: + case 148: + case 146: + case 226: return node === parent.type; - case 227: - case 185: + case 228: case 186: + case 187: + case 152: case 151: case 150: - case 149: - case 152: case 153: - return node === parent.type; case 154: + return node === parent.type; case 155: case 156: + case 157: return node === parent.type; - case 183: + case 184: return node === parent.type; - case 180: case 181: - return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; case 182: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 183: return false; } } @@ -5716,30 +5681,30 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 218: + case 219: return visitor(node); - case 234: - case 206: - case 210: + case 235: + case 207: case 211: case 212: case 213: case 214: case 215: - case 219: + case 216: case 220: - case 256: - case 257: case 221: - case 223: - case 259: + case 257: + case 258: + case 222: + case 224: + case 260: return ts.forEachChild(node, traverse); } } @@ -5749,23 +5714,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 196: + case 197: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 231: - case 229: + return; case 232: case 230: - case 228: - case 198: + case 233: + case 231: + case 229: + case 199: return; default: if (isFunctionLike(node)) { var name = node.name; - if (name && name.kind === 143) { + if (name && name.kind === 144) { traverse(name.expression); return; } @@ -5778,10 +5744,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 163) { + if (node && node.kind === 164) { return node.elementType; } - else if (node && node.kind === 158) { + else if (node && node.kind === 159) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -5792,14 +5758,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 175: - case 263: - case 145: - case 260: - case 148: - case 147: + case 176: + case 264: + case 146: case 261: - case 225: + case 149: + case 148: + case 262: + case 226: return true; } } @@ -5807,11 +5773,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 152 || node.kind === 153); + return node && (node.kind === 153 || node.kind === 154); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 228 || node.kind === 198); + return node && (node.kind === 229 || node.kind === 199); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -5820,19 +5786,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 151: - case 185: - case 227: - case 186: - case 150: - case 149: case 152: + case 186: + case 228: + case 187: + case 151: + case 150: case 153: case 154: case 155: case 156: - case 159: + case 157: case 160: + case 161: return true; } return false; @@ -5840,13 +5806,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 227: - case 185: + case 154: + case 228: + case 186: return true; } return false; @@ -5854,42 +5820,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 213: case 214: case 215: - case 211: + case 216: case 212: + case 213: return true; - case 221: + case 222: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; - function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) { while (true) { if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 221) { + if (node.statement.kind !== 222) { return node.statement; } node = node.statement; } } - ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 206 && isFunctionLike(node.parent); + return node && node.kind === 207 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 150 && node.parent.kind === 177; + return node && node.kind === 151 && node.parent.kind === 178; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 150 && - (node.parent.kind === 177 || - node.parent.kind === 198); + return node.kind === 151 && + (node.parent.kind === 178 || + node.parent.kind === 199); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -5925,39 +5891,39 @@ var ts; return undefined; } switch (node.kind) { - case 143: + case 144: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 146: - if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + case 147: + if (node.parent.kind === 146 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 186: + case 187: if (!includeArrowFunctions) { continue; } - case 227: - case 185: - case 232: - case 148: - case 147: - case 150: + case 228: + case 186: + case 233: case 149: + case 148: case 151: + case 150: case 152: case 153: case 154: case 155: case 156: - case 231: - case 264: + case 157: + case 232: + case 265: return node; } } @@ -5967,9 +5933,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 151: - case 227: - case 185: + case 152: + case 228: + case 186: return container; } } @@ -5983,25 +5949,25 @@ var ts; return node; } switch (node.kind) { - case 143: + case 144: node = node.parent; break; - case 227: - case 185: + case 228: case 186: + case 187: if (!stopOnFunctions) { continue; } - case 148: - case 147: - case 150: case 149: + case 148: case 151: + case 150: case 152: case 153: + case 154: return node; - case 146: - if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + case 147: + if (node.parent.kind === 146 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -6013,14 +5979,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 185 || func.kind === 186) { + if (func.kind === 186 || func.kind === 187) { var prev = func; var parent = func.parent; - while (parent.kind === 184) { + while (parent.kind === 185) { prev = parent; parent = parent.parent; } - if (parent.kind === 180 && parent.expression === prev) { + if (parent.kind === 181 && parent.expression === prev) { return parent; } } @@ -6028,21 +5994,21 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 178 || kind === 179) - && node.expression.kind === 96; + return (kind === 179 || kind === 180) + && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 158: - case 276: + case 159: + case 277: return node.typeName; - case 200: + case 201: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 70: - case 142: + case 71: + case 143: return node; } return undefined; @@ -6050,12 +6016,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { + case 251: case 250: - case 249: - case 180: case 181: case 182: - case 146: + case 183: + case 147: return true; default: return false; @@ -6063,7 +6029,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 182) { + if (node.kind === 183) { return node.tag; } else if (isJsxOpeningLikeElement(node)) { @@ -6074,21 +6040,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 228: + case 229: return true; - case 148: - return node.parent.kind === 228; - case 152: + case 149: + return node.parent.kind === 229; case 153: - case 150: + case 154: + case 151: return node.body !== undefined - && node.parent.kind === 228; - case 145: + && node.parent.kind === 229; + case 146: return node.parent.body !== undefined - && (node.parent.kind === 151 - || node.parent.kind === 150 - || node.parent.kind === 153) - && node.parent.parent.kind === 228; + && (node.parent.kind === 152 + || node.parent.kind === 151 + || node.parent.kind === 154) + && node.parent.parent.kind === 229; } return false; } @@ -6104,19 +6070,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 228: + case 229: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 150: - case 153: + case 151: + case 154: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 250 || - parent.kind === 249 || - parent.kind === 251) { + if (parent.kind === 251 || + parent.kind === 250 || + parent.kind === 252) { return parent.tagName === node; } return false; @@ -6124,99 +6090,99 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 98: - case 96: - case 94: - case 100: - case 85: - case 11: - case 176: + case 99: + case 97: + case 95: + case 101: + case 86: + case 12: case 177: case 178: case 179: case 180: case 181: case 182: - case 201: case 183: case 202: case 184: + case 203: case 185: - case 198: case 186: - case 189: + case 199: case 187: + case 190: case 188: - case 191: + case 189: case 192: case 193: case 194: - case 197: case 195: - case 12: - case 199: - case 248: - case 249: + case 198: case 196: - case 190: - case 203: + case 13: + case 200: + case 249: + case 250: + case 197: + case 191: + case 204: return true; - case 142: - while (node.parent.kind === 142) { + case 143: + while (node.parent.kind === 143) { node = node.parent; } - return node.parent.kind === 161 || isJSXTagName(node); - case 70: - if (node.parent.kind === 161 || isJSXTagName(node)) { + return node.parent.kind === 162 || isJSXTagName(node); + case 71: + if (node.parent.kind === 162 || isJSXTagName(node)) { return true; } case 8: case 9: - case 98: + case 99: var parent = node.parent; switch (parent.kind) { - case 225: - case 145: + case 226: + case 146: + case 149: case 148: - case 147: - case 263: - case 260: - case 175: + case 264: + case 261: + case 176: return parent.initializer === node; - case 209: case 210: case 211: case 212: - case 218: + case 213: case 219: case 220: - case 256: - case 222: - case 220: + case 221: + case 257: + case 223: + case 221: return parent.expression === node; - case 213: + case 214: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || forStatement.condition === node || forStatement.incrementor === node; - case 214: case 215: + case 216: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || forInStatement.expression === node; - case 183: - case 201: + case 184: + case 202: return node === parent.expression; - case 204: + case 205: return node === parent.expression; - case 143: + case 144: return node === parent.expression; - case 146: + case 147: + case 256: case 255: - case 254: - case 262: + case 263: return true; - case 200: + case 201: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: if (isPartOfExpression(parent)) { @@ -6234,7 +6200,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 && node.moduleReference.kind === 247; + return node.kind === 237 && node.moduleReference.kind === 248; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -6243,7 +6209,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 && node.moduleReference.kind !== 247; + return node.kind === 237 && node.moduleReference.kind !== 248; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -6254,39 +6220,58 @@ var ts; return node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 180 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + function isRequireCall(callExpression, checkArgumentIsStringLiteral) { + if (callExpression.kind !== 181) { + return false; + } + var _a = callExpression, expression = _a.expression, args = _a.arguments; + if (expression.kind !== 71 || expression.text !== "require") { + return false; + } + if (args.length !== 1) { + return false; + } + var arg = args[0]; + return !checkArgumentIsStringLiteral || arg.kind === 9 || arg.kind === 13; } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { return charCode === 39 || charCode === 34; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 225) { + function isDeclarationOfFunctionOrClassExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 226) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 185; + return declaration.initializer && (declaration.initializer.kind === 186 || declaration.initializer.kind === 199); } return false; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + ts.isDeclarationOfFunctionOrClassExpression = isDeclarationOfFunctionOrClassExpression; + function getRightMostAssignedExpression(node) { + while (isAssignmentExpression(node, true)) { + node = node.right; + } + return node; + } + ts.getRightMostAssignedExpression = getRightMostAssignedExpression; + function isExportsIdentifier(node) { + return isIdentifier(node) && node.text === "exports"; + } + ts.isExportsIdentifier = isExportsIdentifier; + function isModuleExportsPropertyAccessExpression(node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; function getSpecialPropertyAssignmentKind(expression) { if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 193) { - return 0; - } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { + if (expr.operatorToken.kind !== 58 || expr.left.kind !== 179) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 70) { + if (lhs.expression.kind === 71) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -6294,13 +6279,16 @@ var ts; else if (lhsId.text === "module" && lhs.name.text === "exports") { return 2; } + else { + return 5; + } } - else if (lhs.expression.kind === 98) { + else if (lhs.expression.kind === 99) { return 4; } - else if (lhs.expression.kind === 178) { + else if (lhs.expression.kind === 179) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { + if (innerPropertyAccess.expression.kind === 71) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -6314,35 +6302,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 237) { + if (node.kind === 238) { return node.moduleSpecifier; } - if (node.kind === 236) { + if (node.kind === 237) { var reference = node.moduleReference; - if (reference.kind === 247) { + if (reference.kind === 248) { return reference.expression; } } - if (node.kind === 243) { + if (node.kind === 244) { return node.moduleSpecifier; } - if (node.kind === 232 && node.name.kind === 9) { + if (node.kind === 233 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 240) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 237 + return node.kind === 238 && node.importClause && !!node.importClause.name; } @@ -6350,13 +6338,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 145: + case 146: + case 151: case 150: - case 149: + case 262: case 261: - case 260: + case 149: case 148: - case 147: return node.questionToken !== undefined; } } @@ -6364,9 +6352,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 278 && + return node.kind === 279 && node.parameters.length > 0 && - node.parameters[0].type.kind === 280; + node.parameters[0].type.kind === 281; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -6374,7 +6362,7 @@ var ts; } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; function hasJSDocParameterTags(node) { - var parameterTags = getJSDocTags(node, 285); + var parameterTags = getJSDocTags(node, 286); return parameterTags && parameterTags.length > 0; } ts.hasJSDocParameterTags = hasJSDocParameterTags; @@ -6384,13 +6372,16 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 285) { + if (doc.kind === 286) { if (doc.kind === kind) { result.push(doc); } } else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + var tags = doc.tags; + if (tags) { + result.push.apply(result, ts.filter(tags, function (tag) { return tag.kind === kind; })); + } } } return result; @@ -6410,9 +6401,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 207; + parent.parent.parent.kind === 208; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 207; + parent.parent.kind === 208; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -6420,19 +6411,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 193 && - parent.operatorToken.kind === 57 && - parent.parent.kind === 209; + parent.kind === 194 && + parent.operatorToken.kind === 58 && + parent.parent.kind === 210; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 232 && - parent && parent.kind === 232; - var isPropertyAssignmentExpression = parent && parent.kind === 260; + var isModuleDeclaration = node.kind === 233 && + parent && parent.kind === 233; + var isPropertyAssignmentExpression = parent && parent.kind === 261; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 145) { + if (node.kind === 146) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -6441,22 +6432,23 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 285); + var tags = getJSDocTags(func, 286); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 286; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } - else if (param.name.kind === 70) { + else if (param.name.kind === 71) { var name_1 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); + return ts.filter(tags, function (tag) { return tag.kind === 286 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -6464,8 +6456,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 287); - if (!tag && node.kind === 145) { + var tag = getFirstJSDocTag(node, 288); + if (!tag && node.kind === 146) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -6475,15 +6467,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 286); + return getFirstJSDocTag(node, 287); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 288); + return getFirstJSDocTag(node, 289); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -6496,8 +6488,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 279 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { + if (node.type && node.type.kind === 280 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 280; })) { return true; } } @@ -6518,30 +6510,30 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 193: + case 194: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 ? 1 : 2 : + binaryOperator === 58 ? 1 : 2 : 0; - case 191: case 192: + case 193: var unaryOperator = parent.operator; - return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 214: + return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; case 215: + case 216: return parent.initializer === node ? 1 : 0; - case 184: - case 176: - case 197: + case 185: + case 177: + case 198: node = parent; break; - case 261: + case 262: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 260: + case 261: if (parent.name === node) { return 0; } @@ -6559,14 +6551,14 @@ var ts; } ts.isAssignmentTarget = isAssignmentTarget; function isDeleteTarget(node) { - if (node.kind !== 178 && node.kind !== 179) { + if (node.kind !== 179 && node.kind !== 180) { return false; } node = node.parent; - while (node && node.kind === 184) { + while (node && node.kind === 185) { node = node.parent; } - return node && node.kind === 187; + return node && node.kind === 188; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -6580,7 +6572,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 265 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -6589,11 +6581,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 71 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 241 || parent.kind === 245) { + if (parent.kind === 242 || parent.kind === 246) { if (parent.propertyName) { return true; } @@ -6606,48 +6598,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 143 && + node.parent.kind === 144 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 148: - case 147: - case 150: case 149: - case 152: + case 148: + case 151: + case 150: case 153: - case 263: - case 260: - case 178: + case 154: + case 264: + case 261: + case 179: return parent.name === node; - case 142: + case 143: if (parent.right === node) { - while (parent.kind === 142) { + while (parent.kind === 143) { parent = parent.parent; } - return parent.kind === 161; + return parent.kind === 162; } return false; - case 175: - case 241: + case 176: + case 242: return parent.propertyName === node; - case 245: + case 246: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 236 || - node.kind === 235 || - node.kind === 238 && !!node.name || - node.kind === 239 || - node.kind === 241 || - node.kind === 245 || - node.kind === 242 && exportAssignmentIsAlias(node); + return node.kind === 237 || + node.kind === 236 || + node.kind === 239 && !!node.name || + node.kind === 240 || + node.kind === 242 || + node.kind === 246 || + node.kind === 243 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -6655,17 +6647,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); + var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); + var heritageClause = getHeritageClause(node.heritageClauses, 108); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); + var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -6733,17 +6725,61 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 141; + return 72 <= token && token <= 142; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + var FunctionFlags; + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal"; + FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator"; + FunctionFlags[FunctionFlags["Async"] = 2] = "Async"; + FunctionFlags[FunctionFlags["AsyncOrAsyncGenerator"] = 3] = "AsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid"; + FunctionFlags[FunctionFlags["InvalidAsyncOrAsyncGenerator"] = 7] = "InvalidAsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["InvalidGenerator"] = 5] = "InvalidGenerator"; + })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); + function getFunctionFlags(node) { + var flags = 0; + switch (node.kind) { + case 228: + case 186: + case 151: + if (node.asteriskToken) { + flags |= 1; + } + case 187: + if (hasModifier(node, 256)) { + flags |= 2; + } + break; + } + if (!node.body) { + flags |= 4; + } + return flags; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; + ts.getFunctionFlags = getFunctionFlags; + function isAsyncFunction(node) { + switch (node.kind) { + case 228: + case 186: + case 187: + case 151: + return node.body !== undefined + && node.asteriskToken === undefined + && hasModifier(node, 256); + } + return false; + } + ts.isAsyncFunction = isAsyncFunction; + function isNumericLiteral(node) { + return node.kind === 8; + } + ts.isNumericLiteral = isNumericLiteral; function isStringOrNumericLiteral(node) { var kind = node.kind; return kind === 9 @@ -6755,7 +6791,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 143 && + return name.kind === 144 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -6765,10 +6801,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { + if (name.kind === 71 || name.kind === 9 || name.kind === 8 || name.kind === 146) { return name.text; } - if (name.kind === 143) { + if (name.kind === 144) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -6786,7 +6822,7 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; + return node.kind === 71 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -6795,17 +6831,17 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 130: + case 117: + case 120: + case 76: + case 124: + case 79: + case 84: case 114: + case 112: + case 113: + case 131: + case 115: return true; } return false; @@ -6813,11 +6849,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 145; + return root.kind === 146; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 175) { + while (node.kind === 176) { node = node.parent.parent; } return node; @@ -6825,15 +6861,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 151 - || kind === 185 - || kind === 227 + return kind === 152 || kind === 186 - || kind === 150 - || kind === 152 + || kind === 228 + || kind === 187 + || kind === 151 || kind === 153 - || kind === 232 - || kind === 264; + || kind === 154 + || kind === 233 + || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -6842,7 +6878,7 @@ var ts; } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFileOrBundle(sourceFileOrBundle) { - if (sourceFileOrBundle.kind === 265) { + if (sourceFileOrBundle.kind === 266) { return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } return getOriginalSourceFile(sourceFileOrBundle); @@ -6867,38 +6903,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 181: + case 182: return hasArguments ? 0 : 1; - case 191: - case 188: + case 192: case 189: - case 187: case 190: - case 194: - case 196: + case 188: + case 191: + case 195: + case 197: return 1; - case 193: + case 194: switch (operator) { - case 39: - case 57: + case 40: case 58: case 59: - case 61: case 60: case 62: + case 61: case 63: case 64: case 65: case 66: case 67: - case 69: case 68: + case 70: + case 69: return 1; } } @@ -6907,15 +6943,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 193) { + if (expression.kind === 194) { return expression.operatorToken.kind; } - else if (expression.kind === 191 || expression.kind === 192) { + else if (expression.kind === 192 || expression.kind === 193) { return expression.operator; } else { @@ -6925,106 +6961,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - case 85: + case 99: + case 97: + case 71: + case 95: + case 101: + case 86: case 8: case 9: - case 176: case 177: - case 185: - case 186: - case 198: - case 248: - case 249: - case 11: - case 12: - case 195: - case 184: - case 199: - return 19; - case 182: case 178: - case 179: - return 18; - case 181: - return hasArguments ? 18 : 17; - case 180: - return 17; - case 192: - return 16; - case 191: - case 188: - case 189: + case 186: case 187: - case 190: - return 15; + case 199: + case 249: + case 250: + case 12: + case 13: + case 196: + case 185: + case 200: + return 19; + case 183: + case 179: + case 180: + return 18; + case 182: + return hasArguments ? 18 : 17; + case 181: + return 17; case 193: + return 16; + case 192: + case 189: + case 190: + case 188: + case 191: + return 15; + case 194: switch (operatorKind) { - case 50: case 51: + case 52: return 15; - case 39: - case 38: case 40: + case 39: case 41: + case 42: return 14; - case 36: case 37: + case 38: return 13; - case 44: case 45: case 46: + case 47: return 12; - case 26: - case 29: - case 28: + case 27: case 30: - case 91: - case 92: - return 11; + case 29: case 31: - case 33: + case 92: + case 93: + return 11; case 32: case 34: + case 33: + case 35: return 10; - case 47: - return 9; - case 49: - return 8; case 48: + return 9; + case 50: + return 8; + case 49: return 7; - case 52: - return 6; case 53: + return 6; + case 54: return 5; - case 57: case 58: case 59: - case 61: case 60: case 62: + case 61: case 63: case 64: case 65: case 66: case 67: - case 69: case 68: + case 70: + case 69: return 3; - case 25: + case 26: return 0; default: return -1; } - case 194: + case 195: return 4; - case 196: - return 2; case 197: + return 2; + case 198: return 1; default: return -1; @@ -7285,7 +7321,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -7340,7 +7376,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 151 && nodeIsPresent(member.body)) { + if (member.kind === 152 && nodeIsPresent(member.body)) { return member; } }); @@ -7367,11 +7403,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); + return node && node.kind === 71 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; + return id.originalKeywordKind === 99; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -7381,10 +7417,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 152) { + if (accessor.kind === 153) { getAccessor = accessor; } - else if (accessor.kind === 153) { + else if (accessor.kind === 154) { setAccessor = accessor; } else { @@ -7393,7 +7429,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 152 || member.kind === 153) + if ((member.kind === 153 || member.kind === 154) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -7404,10 +7440,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 152 && !getAccessor) { + if (member.kind === 153 && !getAccessor) { getAccessor = member; } - if (member.kind === 153 && !setAccessor) { + if (member.kind === 154 && !setAccessor) { setAccessor = member; } } @@ -7590,7 +7626,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 71 && node.isInJSDocNamespace)) { flags |= 1; } node.modifierFlagsCache = flags | 536870912; @@ -7599,34 +7635,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 130: return 64; + case 115: return 32; + case 114: return 4; + case 113: return 16; + case 112: return 8; + case 117: return 128; + case 84: return 1; + case 124: return 2; + case 76: return 2048; + case 79: return 512; + case 120: return 256; + case 131: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; + return token === 54 + || token === 53 + || token === 51; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 57 && token <= 69; + return token >= 58 && token <= 70; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 200 && - node.parent.token === 84 && + if (node.kind === 201 && + node.parent.token === 85 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -7635,7 +7671,7 @@ var ts; function isAssignmentExpression(node, excludeCompoundAssignment) { return isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 + ? node.operatorToken.kind === 58 : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left); } @@ -7643,8 +7679,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 177 - || kind === 176; + return kind === 178 + || kind === 177; } return false; } @@ -7654,7 +7690,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { + if (node.kind === 71) { return true; } else if (isPropertyAccessExpression(node)) { @@ -7668,27 +7704,35 @@ var ts; return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isExpressionWithTypeArgumentsInClassImplementsClause(node) { + return node.kind === 201 + && isEntityNameExpression(node.expression) + && node.parent + && node.parent.token === 108 + && node.parent.parent + && isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassImplementsClause = isExpressionWithTypeArgumentsInClassImplementsClause; function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 178 && isEntityNameExpression(node.expression); + return node.kind === 71 || + node.kind === 179 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 142 && node.parent.right === node) || - (node.parent.kind === 178 && node.parent.name === node); + return (node.parent.kind === 143 && node.parent.right === node) || + (node.parent.kind === 179 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 177) { - return expression.properties.length === 0; - } - if (kind === 176) { - return expression.elements.length === 0; - } - return false; + function isEmptyObjectLiteral(expression) { + return expression.kind === 178 && + expression.properties.length === 0; } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + ts.isEmptyObjectLiteral = isEmptyObjectLiteral; + function isEmptyArrayLiteral(expression) { + return expression.kind === 177 && + expression.elements.length === 0; + } + ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -7696,7 +7740,6 @@ var ts; function isExportDefaultSymbol(symbol) { return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); } - ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -7778,49 +7821,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 11 || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { + || kind === 13 + || kind === 71 + || kind === 99 + || kind === 97 + || kind === 101 + || kind === 86 + || kind === 95) { return true; } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 179) { + else if (kind === 180) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 191 - || kind === 192) { + else if (kind === 192 + || kind === 193) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 193) { - return node.operatorToken.kind !== 39 + else if (kind === 194) { + return node.operatorToken.kind !== 40 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 194) { + else if (kind === 195) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 189 - || kind === 188 - || kind === 187) { + else if (kind === 190 + || kind === 189 + || kind === 188) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 176) { + else if (kind === 177) { return node.elements.length === 0; } - else if (kind === 177) { + else if (kind === 178) { return node.properties.length === 0; } - else if (kind === 180) { + else if (kind === 181) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -7941,8 +7984,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 231: case 232: + case 233: return parseNode === parseNode.parent.name; } } @@ -7960,7 +8003,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 && declaration !== node) { + if (declaration.kind === 229 && declaration !== node) { return true; } } @@ -7978,15 +8021,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; + return node.kind === 13; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; + return 8 <= kind && kind <= 13; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; + return kind === 9 || kind === 13; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -7994,25 +8037,25 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; + return 13 <= kind && kind <= 16; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 13; + return node.kind === 14; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 14 - || kind === 15; + return kind === 15 + || kind === 16; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 70; + return node.kind === 71; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 189; + return node.kind === 190; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -8024,131 +8067,135 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 143; + return node.kind === 144; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 142 - || kind === 70; + return kind === 143 + || kind === 71; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 70 + return kind === 71 || kind === 9 || kind === 8 - || kind === 143; + || kind === 144; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 70 + return kind === 71 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 70 - || kind === 173 - || kind === 174; + return kind === 71 + || kind === 174 + || kind === 175; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 145; + return node.kind === 146; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 146; + return node.kind === 147; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 150; + return node.kind === 151; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 151 - || kind === 148 - || kind === 150 - || kind === 152 + return kind === 152 + || kind === 149 + || kind === 151 || kind === 153 - || kind === 156 - || kind === 205; + || kind === 154 + || kind === 157 + || kind === 206; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 260 - || kind === 261 + return kind === 261 || kind === 262 - || kind === 150 - || kind === 152 + || kind === 263 + || kind === 151 || kind === 153 - || kind === 246; + || kind === 154 + || kind === 247; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 157 && kind <= 172) - || kind === 118 - || kind === 132 - || kind === 121 - || kind === 135 + return (kind >= 158 && kind <= 173) + || kind === 119 + || kind === 133 + || kind === 134 + || kind === 122 || kind === 136 - || kind === 104 - || kind === 129 - || kind === 200; + || kind === 137 + || kind === 99 + || kind === 105 + || kind === 139 + || kind === 95 + || kind === 130 + || kind === 201; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 174; + return node.kind === 175; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 174 - || kind === 173; + return kind === 175 + || kind === 174; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 176 - || kind === 177; + return kind === 177 + || kind === 178; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 175; + return node.kind === 176; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 175 - || kind === 199; + return kind === 176 + || kind === 200; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 225: - case 145: - case 175: + case 226: + case 146: + case 176: return true; } return false; @@ -8161,8 +8208,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 177: + case 174: + case 178: return true; } return false; @@ -8170,94 +8217,100 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 174: - case 176: + case 175: + case 177: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessOrQualifiedName(node) { + var kind = node.kind; + return kind === 179 + || kind === 143; + } + ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isElementAccessExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 180; + return node.kind === 181; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 195 - || kind === 12; + return kind === 196 + || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 200; + return node.kind === 201; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 178 - || kind === 179 - || kind === 181 + return kind === 179 || kind === 180 - || kind === 248 - || kind === 249 || kind === 182 - || kind === 176 - || kind === 184 + || kind === 181 + || kind === 249 + || kind === 250 + || kind === 183 || kind === 177 - || kind === 198 || kind === 185 - || kind === 70 - || kind === 11 + || kind === 178 + || kind === 199 + || kind === 186 + || kind === 71 + || kind === 12 || kind === 8 || kind === 9 - || kind === 12 - || kind === 195 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 202 - || kind === 203; + || kind === 13 + || kind === 196 + || kind === 86 + || kind === 95 + || kind === 99 + || kind === 101 + || kind === 97 + || kind === 203 + || kind === 204; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 191 - || kind === 192 - || kind === 187 + return kind === 192 + || kind === 193 || kind === 188 || kind === 189 || kind === 190 - || kind === 183 + || kind === 191 + || kind === 184 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -8265,13 +8318,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 194 - || kind === 196 - || kind === 186 - || kind === 193 + return kind === 195 || kind === 197 - || kind === 201 - || kind === 199 + || kind === 187 + || kind === 194 + || kind === 198 + || kind === 202 + || kind === 200 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -8280,16 +8333,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 183 - || kind === 201; + return kind === 184 + || kind === 202; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 298; + return node.kind === 296; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 297; + return node.kind === 295; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -8298,15 +8351,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 204; + return node.kind === 205; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 206; + return node.kind === 207; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -8324,135 +8377,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 225; + return node.kind === 226; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 226; + return node.kind === 227; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 234; + return node.kind === 235; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 233 - || kind === 232 - || kind === 70; + return kind === 234 + || kind === 233 + || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 70 - || kind === 232; + return kind === 71 + || kind === 233; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 238; + return node.kind === 239; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 240 - || kind === 239; + return kind === 241 + || kind === 240; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 241; + return node.kind === 242; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 244; + return node.kind === 245; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 245; + return node.kind === 246; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 232 || node.kind === 231; + return node.kind === 233 || node.kind === 232; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 186 - || kind === 175 - || kind === 228 - || kind === 198 - || kind === 151 - || kind === 231 - || kind === 263 - || kind === 245 - || kind === 227 - || kind === 185 - || kind === 152 - || kind === 238 - || kind === 236 - || kind === 241 + return kind === 187 + || kind === 176 || kind === 229 - || kind === 252 - || kind === 150 - || kind === 149 + || kind === 199 + || kind === 152 || kind === 232 - || kind === 235 - || kind === 239 - || kind === 145 - || kind === 260 - || kind === 148 - || kind === 147 - || kind === 153 - || kind === 261 - || kind === 230 - || kind === 144 - || kind === 225 - || kind === 289; - } - function isDeclarationStatementKind(kind) { - return kind === 227 + || kind === 264 || kind === 246 || kind === 228 + || kind === 186 + || kind === 153 + || kind === 239 + || kind === 237 + || kind === 242 + || kind === 230 + || kind === 253 + || kind === 151 + || kind === 150 + || kind === 233 + || kind === 236 + || kind === 240 + || kind === 146 + || kind === 261 + || kind === 149 + || kind === 148 + || kind === 154 + || kind === 262 + || kind === 231 + || kind === 145 + || kind === 226 + || kind === 290; + } + function isDeclarationStatementKind(kind) { + return kind === 228 + || kind === 247 || kind === 229 || kind === 230 || kind === 231 || kind === 232 + || kind === 233 + || kind === 238 || kind === 237 - || kind === 236 + || kind === 244 || kind === 243 - || kind === 242 - || kind === 235; + || kind === 236; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 217 - || kind === 216 - || kind === 224 - || kind === 211 - || kind === 209 - || kind === 208 - || kind === 214 - || kind === 215 - || kind === 213 - || kind === 210 - || kind === 221 - || kind === 218 - || kind === 220 - || kind === 222 - || kind === 223 - || kind === 207 + return kind === 218 + || kind === 217 + || kind === 225 || kind === 212 + || kind === 210 + || kind === 209 + || kind === 215 + || kind === 216 + || kind === 214 + || kind === 211 + || kind === 222 || kind === 219 - || kind === 297 - || kind === 300 - || kind === 299; + || kind === 221 + || kind === 223 + || kind === 224 + || kind === 208 + || kind === 213 + || kind === 220 + || kind === 295 + || kind === 298 + || kind === 297; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -8470,96 +8523,98 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 206; + || kind === 207; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 247 - || kind === 142 - || kind === 70; + return kind === 248 + || kind === 143 + || kind === 71; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 178; + return kind === 99 + || kind === 71 + || kind === 179; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 248 - || kind === 255 - || kind === 249 + return kind === 249 + || kind === 256 + || kind === 250 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributes(node) { var kind = node.kind; - return kind === 253; + return kind === 254; } ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 252 - || kind === 254; + return kind === 253 + || kind === 255; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 254; + return node.kind === 255; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 252; + return node.kind === 253; } ts.isJsxAttribute = isJsxAttribute; - function isJsxOpeningLikeElement(node) { - return node.kind === 250 || node.kind === 249; - } - ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 255; + || kind === 256; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isJsxOpeningLikeElement(node) { + var kind = node.kind; + return kind === 251 + || kind === 250; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 256 - || kind === 257; + return kind === 257 + || kind === 258; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 258; + return node.kind === 259; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 259; + return node.kind === 260; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 260; + return node.kind === 261; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 261; + return node.kind === 262; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 263; + return node.kind === 264; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 264; + return node.kind === 265; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -8571,10 +8626,11 @@ var ts; function getDefaultLibFileName(options) { switch (options.target) { case 5: + return "lib.esnext.full.d.ts"; case 4: - return "lib.es2017.d.ts"; + return "lib.es2017.full.d.ts"; case 3: - return "lib.es2016.d.ts"; + return "lib.es2016.full.d.ts"; case 2: return "lib.es6.d.ts"; default: @@ -8698,9 +8754,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 144) { + if (d && d.kind === 145) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 230) { return current; } } @@ -8708,11 +8764,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 175 || ts.isBindingPattern(node))) { + while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -8720,14 +8776,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 225) { + if (node.kind === 226) { node = node.parent; } - if (node && node.kind === 226) { + if (node && node.kind === 227) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 207) { + if (node && node.kind === 208) { flags |= ts.getModifierFlags(node); } return flags; @@ -8736,14 +8792,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 225) { + if (node.kind === 226) { node = node.parent; } - if (node && node.kind === 226) { + if (node && node.kind === 227) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 207) { + if (node && node.kind === 208) { flags |= node.flags; } return flags; @@ -8810,7 +8866,7 @@ var ts; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { + if (node === undefined || isParseTreeNode(node)) { return node; } node = getOriginalNode(node); @@ -8828,135 +8884,135 @@ var ts; var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 70; + return token >= 71; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMapFromTemplate({ - "abstract": 116, - "any": 118, - "as": 117, - "boolean": 121, - "break": 71, - "case": 72, - "catch": 73, - "class": 74, - "continue": 76, - "const": 75, - "constructor": 122, - "debugger": 77, - "declare": 123, - "default": 78, - "delete": 79, - "do": 80, - "else": 81, - "enum": 82, - "export": 83, - "extends": 84, - "false": 85, - "finally": 86, - "for": 87, - "from": 139, - "function": 88, - "get": 124, - "if": 89, - "implements": 107, - "import": 90, - "in": 91, - "instanceof": 92, - "interface": 108, - "is": 125, - "keyof": 126, - "let": 109, - "module": 127, - "namespace": 128, - "never": 129, - "new": 93, - "null": 94, - "number": 132, - "object": 133, - "package": 110, - "private": 111, - "protected": 112, - "public": 113, - "readonly": 130, - "require": 131, - "global": 140, - "return": 95, - "set": 134, - "static": 114, - "string": 135, - "super": 96, - "switch": 97, - "symbol": 136, - "this": 98, - "throw": 99, - "true": 100, - "try": 101, - "type": 137, - "typeof": 102, - "undefined": 138, - "var": 103, - "void": 104, - "while": 105, - "with": 106, - "yield": 115, - "async": 119, - "await": 120, - "of": 141, - "{": 16, - "}": 17, - "(": 18, - ")": 19, - "[": 20, - "]": 21, - ".": 22, - "...": 23, - ";": 24, - ",": 25, - "<": 26, - ">": 28, - "<=": 29, - ">=": 30, - "==": 31, - "!=": 32, - "===": 33, - "!==": 34, - "=>": 35, - "+": 36, - "-": 37, - "**": 39, - "*": 38, - "/": 40, - "%": 41, - "++": 42, - "--": 43, - "<<": 44, - ">": 45, - ">>>": 46, - "&": 47, - "|": 48, - "^": 49, - "!": 50, - "~": 51, - "&&": 52, - "||": 53, - "?": 54, - ":": 55, - "=": 57, - "+=": 58, - "-=": 59, - "*=": 60, - "**=": 61, - "/=": 62, - "%=": 63, - "<<=": 64, - ">>=": 65, - ">>>=": 66, - "&=": 67, - "|=": 68, - "^=": 69, - "@": 56, + "abstract": 117, + "any": 119, + "as": 118, + "boolean": 122, + "break": 72, + "case": 73, + "catch": 74, + "class": 75, + "continue": 77, + "const": 76, + "constructor": 123, + "debugger": 78, + "declare": 124, + "default": 79, + "delete": 80, + "do": 81, + "else": 82, + "enum": 83, + "export": 84, + "extends": 85, + "false": 86, + "finally": 87, + "for": 88, + "from": 140, + "function": 89, + "get": 125, + "if": 90, + "implements": 108, + "import": 91, + "in": 92, + "instanceof": 93, + "interface": 109, + "is": 126, + "keyof": 127, + "let": 110, + "module": 128, + "namespace": 129, + "never": 130, + "new": 94, + "null": 95, + "number": 133, + "object": 134, + "package": 111, + "private": 112, + "protected": 113, + "public": 114, + "readonly": 131, + "require": 132, + "global": 141, + "return": 96, + "set": 135, + "static": 115, + "string": 136, + "super": 97, + "switch": 98, + "symbol": 137, + "this": 99, + "throw": 100, + "true": 101, + "try": 102, + "type": 138, + "typeof": 103, + "undefined": 139, + "var": 104, + "void": 105, + "while": 106, + "with": 107, + "yield": 116, + "async": 120, + "await": 121, + "of": 142, + "{": 17, + "}": 18, + "(": 19, + ")": 20, + "[": 21, + "]": 22, + ".": 23, + "...": 24, + ";": 25, + ",": 26, + "<": 27, + ">": 29, + "<=": 30, + ">=": 31, + "==": 32, + "!=": 33, + "===": 34, + "!==": 35, + "=>": 36, + "+": 37, + "-": 38, + "**": 40, + "*": 39, + "/": 41, + "%": 42, + "++": 43, + "--": 44, + "<<": 45, + ">": 46, + ">>>": 47, + "&": 48, + "|": 49, + "^": 50, + "!": 51, + "~": 52, + "&&": 53, + "||": 54, + "?": 55, + ":": 56, + "=": 58, + "+=": 59, + "-=": 60, + "*=": 61, + "**=": 62, + "/=": 63, + "%=": 64, + "<<=": 65, + ">>=": 66, + ">>>=": 67, + "&=": 68, + "|=": 69, + "^=": 70, + "@": 57, }); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -9068,10 +9124,10 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function isWhiteSpace(ch) { + function isWhiteSpaceLike(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - ts.isWhiteSpace = isWhiteSpace; + ts.isWhiteSpaceLike = isWhiteSpaceLike; function isWhiteSpaceSingleLine(ch) { return ch === 32 || ch === 9 || @@ -9187,7 +9243,7 @@ var ts; } break; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -9321,7 +9377,7 @@ var ts; } break scan; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -9356,7 +9412,7 @@ var ts; if (!comments) { comments = []; } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine }); return comments; } function getLeadingCommentRanges(text, pos) { @@ -9408,6 +9464,7 @@ var ts; var precedingLineBreak; var hasExtendedUnicodeEscape; var tokenIsUnterminated; + var numericLiteralFlags; setText(text, start, length); return { getStartPos: function () { return startPos; }, @@ -9418,9 +9475,10 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 70 || token > 106; }, - isReservedWord: function () { return token >= 71 && token <= 106; }, + isIdentifier: function () { return token === 71 || token > 107; }, + isReservedWord: function () { return token >= 72 && token <= 107; }, isUnterminated: function () { return tokenIsUnterminated; }, + getNumericLiteralFlags: function () { return numericLiteralFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, @@ -9457,6 +9515,7 @@ var ts; var end = pos; if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { pos++; + numericLiteralFlags = 2; if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++; if (isDigit(text.charCodeAt(pos))) { @@ -9555,20 +9614,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 13 : 14; + resultingToken = startedWithBacktick ? 14 : 15; break; } if (currChar === 92) { @@ -9733,7 +9792,7 @@ var ts; } } } - return token = 70; + return token = 71; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -9759,6 +9818,7 @@ var ts; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -9808,12 +9868,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 34; + return pos += 3, token = 35; } - return pos += 2, token = 32; + return pos += 2, token = 33; } pos++; - return token = 50; + return token = 51; case 34: case 39: tokenValue = scanString(); @@ -9822,51 +9882,39 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } pos++; - return token = 41; + return token = 42; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 52; + return pos += 2, token = 53; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; - return token = 47; + return token = 48; case 40: pos++; - return token = 18; + return token = 19; case 41: pos++; - return token = 19; + return token = 20; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 61; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 62; } - return pos += 2, token = 39; + return pos += 2, token = 40; } pos++; - return token = 38; + return token = 39; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 44: - pos++; - return token = 25; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { @@ -9874,16 +9922,28 @@ var ts; } pos++; return token = 37; + case 44: + pos++; + return token = 26; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + pos++; + return token = 38; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 23; + return pos += 3, token = 24; } pos++; - return token = 22; + return token = 23; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -9927,10 +9987,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -9940,6 +10000,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 8; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { @@ -9950,6 +10011,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 16; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { @@ -9960,10 +10022,12 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 32; return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = 4; return token = 8; } case 49: @@ -9979,10 +10043,10 @@ var ts; return token = 8; case 58: pos++; - return token = 55; + return token = 56; case 59: pos++; - return token = 24; + return token = 25; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -9995,20 +10059,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 64; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 29; + return pos += 2, token = 30; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 27; + return pos += 2, token = 28; } pos++; - return token = 26; + return token = 27; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -10021,15 +10085,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 35; + return pos += 2, token = 36; } pos++; - return token = 57; + return token = 58; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -10041,43 +10105,43 @@ var ts; } } pos++; - return token = 28; + return token = 29; case 63: pos++; - return token = 54; + return token = 55; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 70; + } + pos++; + return token = 50; + case 123: + pos++; + return token = 17; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 54; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 69; } pos++; return token = 49; - case 123: - pos++; - return token = 16; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 53; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; case 125: pos++; - return token = 17; + return token = 18; case 126: pos++; - return token = 51; + return token = 52; case 64: pos++; - return token = 56; + return token = 57; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -10115,29 +10179,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 28) { + if (token === 29) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 66; + return pos += 3, token = 67; } - return pos += 2, token = 46; + return pos += 2, token = 47; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 66; } pos++; - return token = 45; + return token = 46; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 30; + return token = 31; } } return token; } function reScanSlashToken() { - if (token === 40 || token === 62) { + if (token === 41 || token === 63) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -10176,12 +10240,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 11; + token = 12; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 18, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -10198,23 +10262,37 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 27; + return token = 28; } pos++; - return token = 26; + return token = 27; } if (char === 123) { pos++; - return token = 16; + return token = 17; } + var firstNonWhitespace = 0; while (pos < end) { - pos++; char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { + if (char === 123) { break; } + if (char === 60) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = 7; + } + break; + } + if (isLineBreak(char) && firstNonWhitespace === 0) { + firstNonWhitespace = -1; + } + else if (!isWhiteSpaceLike(char)) { + firstNonWhitespace = pos; + } + pos++; } - return token = 10; + return firstNonWhitespace === -1 ? 11 : 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -10261,42 +10339,42 @@ var ts; return token = 5; case 64: pos++; - return token = 56; + return token = 57; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 38; + return token = 39; case 123: pos++; - return token = 16; + return token = 17; case 125: pos++; - return token = 17; + return token = 18; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 61: pos++; - return token = 57; + return token = 58; case 44: pos++; - return token = 25; + return token = 26; case 46: pos++; - return token = 22; + return token = 23; } if (isIdentifierStart(ch, 5)) { pos++; while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } - return token = 70; + return token = 71; } else { return pos += 1, token = 0; @@ -10444,6 +10522,7 @@ var ts; function createNumericLiteral(value) { var node = createSynthesizedNode(8); node.text = value; + node.numericLiteralFlags = 0; return node; } ts.createNumericLiteral = createNumericLiteral; @@ -10458,7 +10537,7 @@ var ts; return node; } function createIdentifier(text) { - var node = createSynthesizedNode(70); + var node = createSynthesizedNode(71); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; @@ -10508,27 +10587,27 @@ var ts; } ts.createToken = createToken; function createSuper() { - return createSynthesizedNode(96); + return createSynthesizedNode(97); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(98); + return createSynthesizedNode(99); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(94); + return createSynthesizedNode(95); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(100); + return createSynthesizedNode(101); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(85); + return createSynthesizedNode(86); } ts.createFalse = createFalse; function createQualifiedName(left, right) { - var node = createSynthesizedNode(142); + var node = createSynthesizedNode(143); node.left = left; node.right = asName(right); return node; @@ -10542,7 +10621,7 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function createComputedPropertyName(expression) { - var node = createSynthesizedNode(143); + var node = createSynthesizedNode(144); node.expression = expression; return node; } @@ -10553,8 +10632,285 @@ var ts; : node; } ts.updateComputedPropertyName = updateComputedPropertyName; + function createSignatureDeclaration(kind, typeParameters, parameters, type) { + var signatureDeclaration = createSynthesizedNode(kind); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + ts.createSignatureDeclaration = createSignatureDeclaration; + function updateSignatureDeclaration(node, typeParameters, parameters, type) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + function createFunctionTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(160, typeParameters, parameters, type); + } + ts.createFunctionTypeNode = createFunctionTypeNode; + function updateFunctionTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateFunctionTypeNode = updateFunctionTypeNode; + function createConstructorTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(161, typeParameters, parameters, type); + } + ts.createConstructorTypeNode = createConstructorTypeNode; + function updateConstructorTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructorTypeNode = updateConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(155, typeParameters, parameters, type); + } + ts.createCallSignatureDeclaration = createCallSignatureDeclaration; + function updateCallSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateCallSignatureDeclaration = updateCallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(156, typeParameters, parameters, type); + } + ts.createConstructSignatureDeclaration = createConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructSignatureDeclaration = updateConstructSignatureDeclaration; + function createMethodSignature(typeParameters, parameters, type, name, questionToken) { + var methodSignature = createSignatureDeclaration(150, typeParameters, parameters, type); + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + ts.createMethodSignature = createMethodSignature; + function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + ts.updateMethodSignature = updateMethodSignature; + function createKeywordTypeNode(kind) { + return createSynthesizedNode(kind); + } + ts.createKeywordTypeNode = createKeywordTypeNode; + function createThisTypeNode() { + return createSynthesizedNode(169); + } + ts.createThisTypeNode = createThisTypeNode; + function createLiteralTypeNode(literal) { + var literalTypeNode = createSynthesizedNode(173); + literalTypeNode.literal = literal; + return literalTypeNode; + } + ts.createLiteralTypeNode = createLiteralTypeNode; + function updateLiteralTypeNode(node, literal) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + ts.updateLiteralTypeNode = updateLiteralTypeNode; + function createTypeReferenceNode(typeName, typeArguments) { + var typeReference = createSynthesizedNode(159); + typeReference.typeName = asName(typeName); + typeReference.typeArguments = asNodeArray(typeArguments); + return typeReference; + } + ts.createTypeReferenceNode = createTypeReferenceNode; + function updateTypeReferenceNode(node, typeName, typeArguments) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + ts.updateTypeReferenceNode = updateTypeReferenceNode; + function createTypePredicateNode(parameterName, type) { + var typePredicateNode = createSynthesizedNode(158); + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + ts.createTypePredicateNode = createTypePredicateNode; + function updateTypePredicateNode(node, parameterName, type) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function createTypeQueryNode(exprName) { + var typeQueryNode = createSynthesizedNode(162); + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + ts.createTypeQueryNode = createTypeQueryNode; + function updateTypeQueryNode(node, exprName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; + } + ts.updateTypeQueryNode = updateTypeQueryNode; + function createArrayTypeNode(elementType) { + var arrayTypeNode = createSynthesizedNode(164); + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + ts.createArrayTypeNode = createArrayTypeNode; + function updateArrayTypeNode(node, elementType) { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + ts.updateArrayTypeNode = updateArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind, types) { + var unionTypeNode = createSynthesizedNode(kind); + unionTypeNode.types = createNodeArray(types); + return unionTypeNode; + } + ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node, types) { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + ts.updateUnionOrIntersectionTypeNode = updateUnionOrIntersectionTypeNode; + function createParenthesizedType(type) { + var node = createSynthesizedNode(168); + node.type = type; + return node; + } + ts.createParenthesizedType = createParenthesizedType; + function updateParenthesizedType(node, type) { + return node.type !== type + ? updateNode(createParenthesizedType(type), node) + : node; + } + ts.updateParenthesizedType = updateParenthesizedType; + function createTypeLiteralNode(members) { + var typeLiteralNode = createSynthesizedNode(163); + typeLiteralNode.members = createNodeArray(members); + return typeLiteralNode; + } + ts.createTypeLiteralNode = createTypeLiteralNode; + function updateTypeLiteralNode(node, members) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + ts.updateTypeLiteralNode = updateTypeLiteralNode; + function createTupleTypeNode(elementTypes) { + var tupleTypeNode = createSynthesizedNode(165); + tupleTypeNode.elementTypes = createNodeArray(elementTypes); + return tupleTypeNode; + } + ts.createTupleTypeNode = createTupleTypeNode; + function updateTypleTypeNode(node, elementTypes) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + ts.updateTypleTypeNode = updateTypleTypeNode; + function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { + var mappedTypeNode = createSynthesizedNode(172); + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + ts.createMappedTypeNode = createMappedTypeNode; + function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + ts.updateMappedTypeNode = updateMappedTypeNode; + function createTypeOperatorNode(type) { + var typeOperatorNode = createSynthesizedNode(170); + typeOperatorNode.operator = 127; + typeOperatorNode.type = type; + return typeOperatorNode; + } + ts.createTypeOperatorNode = createTypeOperatorNode; + function updateTypeOperatorNode(node, type) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + ts.updateTypeOperatorNode = updateTypeOperatorNode; + function createIndexedAccessTypeNode(objectType, indexType) { + var indexedAccessTypeNode = createSynthesizedNode(171); + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node, objectType, indexType) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; + function createTypeParameterDeclaration(name, constraint, defaultType) { + var typeParameter = createSynthesizedNode(145); + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultType; + return typeParameter; + } + ts.createTypeParameterDeclaration = createTypeParameterDeclaration; + function updateTypeParameterDeclaration(node, name, constraint, defaultType) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) + : node; + } + ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; + function createPropertySignature(name, questionToken, type, initializer) { + var propertySignature = createSynthesizedNode(148); + propertySignature.name = asName(name); + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + ts.createPropertySignature = createPropertySignature; + function updatePropertySignature(node, name, questionToken, type, initializer) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + ts.updatePropertySignature = updatePropertySignature; + function createIndexSignatureDeclaration(decorators, modifiers, parameters, type) { + var indexSignature = createSynthesizedNode(157); + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; + return indexSignature; + } + ts.createIndexSignatureDeclaration = createIndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node, decorators, modifiers, parameters, type) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) + : node; + } + ts.updateIndexSignatureDeclaration = updateIndexSignatureDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(145); + var node = createSynthesizedNode(146); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -10565,11 +10921,12 @@ var ts; return node; } ts.createParameter = createParameter; - function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { + function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -10577,7 +10934,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(146); + var node = createSynthesizedNode(147); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -10589,7 +10946,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createProperty(decorators, modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148); + var node = createSynthesizedNode(149); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -10609,33 +10966,35 @@ var ts; : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(150); + function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(151); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - ts.createMethod = createMethod; - function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + ts.createMethodDeclaration = createMethodDeclaration; + function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(152); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -10655,7 +11014,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(153); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -10678,7 +11037,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(154); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -10699,7 +11058,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } @@ -10711,7 +11070,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(174); + var node = createSynthesizedNode(175); node.elements = createNodeArray(elements); return node; } @@ -10722,10 +11081,10 @@ var ts; : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer) { - var node = createSynthesizedNode(175); - node.propertyName = asName(propertyName); + function createBindingElement(dotDotDotToken, propertyName, name, initializer) { + var node = createSynthesizedNode(176); node.dotDotDotToken = dotDotDotToken; + node.propertyName = asName(propertyName); node.name = asName(name); node.initializer = initializer; return node; @@ -10736,12 +11095,12 @@ var ts; || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer - ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) : node; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(177); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -10756,7 +11115,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(178); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -10771,10 +11130,10 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(179); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); - setEmitFlags(node, 65536); + setEmitFlags(node, 131072); return node; } ts.createPropertyAccess = createPropertyAccess; @@ -10786,7 +11145,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(180); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -10800,7 +11159,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(181); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -10816,7 +11175,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(182); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -10832,7 +11191,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(183); node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; @@ -10846,7 +11205,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(184); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -10860,7 +11219,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(185); node.expression = expression; return node; } @@ -10872,7 +11231,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(186); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -10883,24 +11242,25 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.name !== name || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(187); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -10916,7 +11276,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -10928,7 +11288,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(189); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -10940,7 +11300,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(190); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -10952,7 +11312,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(191); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -10964,7 +11324,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(192); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -10977,7 +11337,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(193); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -10990,7 +11350,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(194); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -11007,11 +11367,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(195); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(55); + node.colonToken = whenFalse ? colonToken : createToken(56); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -11025,7 +11385,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(196); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -11039,20 +11399,21 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(196); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(197); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; - function updateYield(node, expression) { + function updateYield(node, asteriskToken, expression) { return node.expression !== expression - ? updateNode(createYield(node.asteriskToken, expression), node) + || node.asteriskToken !== asteriskToken + ? updateNode(createYield(asteriskToken, expression), node) : node; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(198); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -11064,7 +11425,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(199); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11085,11 +11446,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(199); + return createSynthesizedNode(200); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(201); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -11103,7 +11464,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(202); node.expression = expression; node.type = type; return node; @@ -11117,7 +11478,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(203); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -11129,7 +11490,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(205); node.expression = expression; node.literal = literal; return node; @@ -11143,7 +11504,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(206); + var block = createSynthesizedNode(207); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -11157,7 +11518,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(208); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11172,7 +11533,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(227); node.flags |= flags; node.declarations = createNodeArray(declarations); return node; @@ -11185,7 +11546,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(226); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -11201,11 +11562,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement() { - return createSynthesizedNode(208); + return createSynthesizedNode(209); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(210); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11217,7 +11578,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(211); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11233,7 +11594,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(211); + var node = createSynthesizedNode(212); node.statement = statement; node.expression = expression; return node; @@ -11247,7 +11608,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(213); node.expression = expression; node.statement = statement; return node; @@ -11261,7 +11622,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(214); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11279,7 +11640,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11294,24 +11655,26 @@ var ts; : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement) { - var node = createSynthesizedNode(215); + function createForOf(awaitModifier, initializer, expression, statement) { + var node = createSynthesizedNode(216); + node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; node.statement = statement; return node; } ts.createForOf = createForOf; - function updateForOf(node, initializer, expression, statement) { - return node.initializer !== initializer + function updateForOf(node, awaitModifier, initializer, expression, statement) { + return node.awaitModifier !== awaitModifier + || node.initializer !== initializer || node.expression !== expression || node.statement !== statement - ? updateNode(createForOf(initializer, expression, statement), node) + ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node) : node; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(216); + var node = createSynthesizedNode(217); node.label = asName(label); return node; } @@ -11323,7 +11686,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(218); node.label = asName(label); return node; } @@ -11335,7 +11698,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(219); node.expression = expression; return node; } @@ -11347,7 +11710,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(220); node.expression = expression; node.statement = statement; return node; @@ -11361,7 +11724,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(221); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11375,7 +11738,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(222); node.label = asName(label); node.statement = statement; return node; @@ -11389,7 +11752,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(223); node.expression = expression; return node; } @@ -11401,7 +11764,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(224); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11417,7 +11780,7 @@ var ts; } ts.updateTry = updateTry; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(228); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -11429,20 +11792,21 @@ var ts; return node; } ts.createFunctionDeclaration = createFunctionDeclaration; - function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(229); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11464,7 +11828,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(232); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11482,7 +11846,7 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(233); node.flags |= flags; node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -11513,7 +11877,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(235); node.clauses = createNodeArray(clauses); return node; } @@ -11525,7 +11889,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11543,7 +11907,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -11560,7 +11924,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(239); node.name = name; node.namedBindings = namedBindings; return node; @@ -11574,7 +11938,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(240); node.name = name; return node; } @@ -11586,7 +11950,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(241); node.elements = createNodeArray(elements); return node; } @@ -11598,7 +11962,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(242); node.propertyName = propertyName; node.name = name; return node; @@ -11612,7 +11976,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -11629,7 +11993,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -11647,7 +12011,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(245); node.elements = createNodeArray(elements); return node; } @@ -11658,21 +12022,22 @@ var ts; : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName) { - var node = createSynthesizedNode(245); - node.name = asName(name); + function createExportSpecifier(propertyName, name) { + var node = createSynthesizedNode(246); node.propertyName = asName(propertyName); + node.name = asName(name); return node; } ts.createExportSpecifier = createExportSpecifier; - function updateExportSpecifier(node, name, propertyName) { - return node.name !== name || node.propertyName !== propertyName - ? updateNode(createExportSpecifier(name, propertyName), node) + function updateExportSpecifier(node, propertyName, name) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createExportSpecifier(propertyName, name), node) : node; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(248); node.expression = expression; return node; } @@ -11684,7 +12049,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(249); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -11700,7 +12065,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(250); node.tagName = tagName; node.attributes = attributes; return node; @@ -11714,7 +12079,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(251); node.tagName = tagName; node.attributes = attributes; return node; @@ -11728,7 +12093,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(252); node.tagName = tagName; return node; } @@ -11740,7 +12105,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttributes(properties) { - var jsxAttributes = createSynthesizedNode(253); + var jsxAttributes = createSynthesizedNode(254); jsxAttributes.properties = createNodeArray(properties); return jsxAttributes; } @@ -11753,7 +12118,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(253); node.name = name; node.initializer = initializer; return node; @@ -11767,7 +12132,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(255); node.expression = expression; return node; } @@ -11778,8 +12143,8 @@ var ts; : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken) { - var node = createSynthesizedNode(255); + function createJsxExpression(dotDotDotToken, expression) { + var node = createSynthesizedNode(256); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -11787,12 +12152,12 @@ var ts; ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { return node.expression !== expression - ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node) : node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(259); node.token = token; node.types = createNodeArray(types); return node; @@ -11806,7 +12171,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(257); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -11820,7 +12185,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(258); node.statements = createNodeArray(statements); return node; } @@ -11833,7 +12198,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(259); + var node = createSynthesizedNode(260); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -11847,7 +12212,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(261); node.name = asName(name); node.questionToken = undefined; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -11862,18 +12227,12 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(262); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression) { - var node = createSynthesizedNode(262); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; - return node; - } - ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); @@ -11881,6 +12240,12 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(263); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { return updateNode(createSpreadAssignment(expression), node); @@ -11889,7 +12254,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(264); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -11904,7 +12269,7 @@ var ts; ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createSynthesizedNode(264); + var updated = createSynthesizedNode(265); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -11973,28 +12338,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(297); + var node = createSynthesizedNode(295); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(300); + var node = createSynthesizedNode(298); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(299); + var node = createSynthesizedNode(297); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(298); + var node = createSynthesizedNode(296); node.expression = expression; node.original = original; setTextRange(node, original); @@ -12009,7 +12374,7 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createBundle(sourceFiles) { - var node = ts.createNode(265); + var node = ts.createNode(266); node.sourceFiles = sourceFiles; return node; } @@ -12022,47 +12387,47 @@ var ts; } ts.updateBundle = updateBundle; function createComma(left, right) { - return createBinary(left, 25, right); + return createBinary(left, 26, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 26, right); + return createBinary(left, 27, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 57, right); + return createBinary(left, 58, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 34, right); + return createBinary(left, 35, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 37, right); + return createBinary(left, 38, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 42); + return createPostfix(operand, 43); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 53, right); + return createBinary(left, 54, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(50, operand); + return createPrefix(51, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -12074,7 +12439,7 @@ var ts; } ts.createExportDefault = createExportDefault; function createExternalModuleExport(exportName) { - return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); + return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; function asName(name) { @@ -12104,7 +12469,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 264) { + if (node.kind === 265) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12166,6 +12531,34 @@ var ts; return node; } ts.setCommentRange = setCommentRange; + function getSyntheticLeadingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.leadingComments; + } + ts.getSyntheticLeadingComments = getSyntheticLeadingComments; + function setSyntheticLeadingComments(node, comments) { + getOrCreateEmitNode(node).leadingComments = comments; + return node; + } + ts.setSyntheticLeadingComments = setSyntheticLeadingComments; + function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticLeadingComment = addSyntheticLeadingComment; + function getSyntheticTrailingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.trailingComments; + } + ts.getSyntheticTrailingComments = getSyntheticTrailingComments; + function setSyntheticTrailingComments(node, comments) { + getOrCreateEmitNode(node).trailingComments = comments; + return node; + } + ts.setSyntheticTrailingComments = setSyntheticTrailingComments; + function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticTrailingComment = addSyntheticTrailingComment; function getConstantValue(node) { var emitNode = node.emitNode; return emitNode && emitNode.constantValue; @@ -12259,9 +12652,13 @@ var ts; } ts.setOriginalNode = setOriginalNode; function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + var flags = sourceEmitNode.flags, leadingComments = sourceEmitNode.leadingComments, trailingComments = sourceEmitNode.trailingComments, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; if (!destEmitNode) destEmitNode = {}; + if (leadingComments) + destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) + destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; if (commentRange) @@ -12383,11 +12780,65 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + var valuesHelper = { + name: "typescript:values", + scoped: false, + text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };\n " + }; + function createValuesHelper(context, expression, location) { + context.requestEmitHelper(valuesHelper); + return ts.setTextRange(ts.createCall(getHelperName("__values"), undefined, [expression]), location); + } + ts.createValuesHelper = createValuesHelper; + var readHelper = { + name: "typescript:read", + scoped: false, + text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };\n " + }; + function createReadHelper(context, iteratorRecord, count, location) { + context.requestEmitHelper(readHelper); + return ts.setTextRange(ts.createCall(getHelperName("__read"), undefined, count !== undefined + ? [iteratorRecord, ts.createLiteral(count)] + : [iteratorRecord]), location); + } + ts.createReadHelper = createReadHelper; + var spreadHelper = { + name: "typescript:spread", + scoped: false, + text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" + }; + function createSpreadHelper(context, argumentList, location) { + context.requestEmitHelper(readHelper); + context.requestEmitHelper(spreadHelper); + return ts.setTextRange(ts.createCall(getHelperName("__spread"), undefined, argumentList), location); + } + ts.createSpreadHelper = createSpreadHelper; + function createForOfBindingStatement(node, boundValue) { + if (ts.isVariableDeclarationList(node)) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue); + return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node); + } + else { + var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node); + return ts.setTextRange(ts.createStatement(updatedExpression), node); + } + } + ts.createForOfBindingStatement = createForOfBindingStatement; + function insertLeadingStatement(dest, source) { + if (ts.isBlock(dest)) { + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + } + else { + return ts.createBlock(ts.createNodeArray([dest, source]), true); + } + } + ts.insertLeadingStatement = insertLeadingStatement; function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 222 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -12399,19 +12850,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 70: + case 71: return cacheIdentifiers; - case 98: + case 99: case 8: case 9: return false; - case 176: + case 177: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 177: + case 178: return target.properties.length > 0; default: return true; @@ -12425,15 +12876,19 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 96) { + else if (callee.kind === 97) { thisArg = ts.createThis(); target = languageVersion < 2 ? ts.setTextRange(ts.createIdentifier("_super"), callee) : callee; } + else if (ts.getEmitFlags(callee) & 4096) { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(callee); + } else { switch (callee.kind) { - case 178: { + case 179: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -12445,7 +12900,7 @@ var ts; } break; } - case 179: { + case 180: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -12496,14 +12951,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 152: case 153: + case 154: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 260: - return createExpressionForPropertyAssignment(property, receiver); case 261: + return createExpressionForPropertyAssignment(property, receiver); + case 262: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 150: + case 151: return createExpressionForMethodDeclaration(property, receiver); } } @@ -12546,6 +13001,14 @@ var ts; function createExpressionForMethodDeclaration(method, receiver) { return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); } + function getInternalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384 | 32768); + } + ts.getInternalName = getInternalName; + function isInternalName(node) { + return (ts.getEmitFlags(node) & 32768) !== 0; + } + ts.isInternalName = isInternalName; function getLocalName(node, allowComments, allowSourceMaps) { return getName(node, allowComments, allowSourceMaps, 16384); } @@ -12607,7 +13070,12 @@ var ts; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + function addPrologue(target, source, ensureUseStrict, visitor) { + var offset = addStandardPrologue(target, source, ensureUseStrict); + return addCustomPrologue(target, source, offset, visitor); + } + ts.addPrologue = addPrologue; + function addStandardPrologue(target, source, ensureUseStrict) { ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; @@ -12628,9 +13096,14 @@ var ts; if (ensureUseStrict && !foundUseStrict) { target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } + return statementOffset; + } + ts.addStandardPrologue = addStandardPrologue; + function addCustomPrologue(target, source, statementOffset, visitor) { + var numStatements = source.length; while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 524288) { + if (ts.getEmitFlags(statement) & 1048576) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -12640,7 +13113,7 @@ var ts; } return statementOffset; } - ts.addPrologueDirectives = addPrologueDirectives; + ts.addCustomPrologue = addCustomPrologue; function startsWithUseStrict(statements) { var firstStatement = ts.firstOrUndefined(statements); return firstStatement !== undefined @@ -12670,9 +13143,19 @@ var ts; return statements; } ts.ensureUseStrict = ensureUseStrict; + function parenthesizeConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(195, 55); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeConditionalHead = parenthesizeConditionalHead; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 184) { + if (skipped.kind === 185) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -12681,15 +13164,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(194, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(194, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 196) { + && operand.kind === 197) { return false; } return true; @@ -12705,7 +13188,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 36) { + if (binaryOperator === 37) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -12718,17 +13201,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 + return binaryOperator === 39 + || binaryOperator === 49 || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; + || binaryOperator === 50; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.kind === 194 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -12743,7 +13226,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var conditionalPrecedence = ts.getOperatorPrecedence(195, 55); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -12753,7 +13236,7 @@ var ts; } ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 193 && e.operatorToken.kind === 25 + return e.kind === 194 && e.operatorToken.kind === 26 ? ts.createParen(e) : e; } @@ -12761,9 +13244,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 180: - return ts.createParen(expression); case 181: + return ts.createParen(expression); + case 182: return emittedExpression.arguments ? expression : ts.createParen(expression); @@ -12774,8 +13257,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 181 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { + && (emittedExpression.kind !== 182 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -12813,7 +13295,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(193, 25); + var commaPrecedence = ts.getOperatorPrecedence(194, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -12824,7 +13306,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 185 || kind === 186) { + if (kind === 186 || kind === 187) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -12832,7 +13314,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { return ts.setTextRange(ts.createParen(expression), expression); } } @@ -12850,21 +13332,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 192: + case 193: node = node.operand; continue; - case 193: + case 194: node = node.left; continue; - case 194: + case 195: node = node.condition; continue; + case 181: case 180: case 179: - case 178: node = node.expression; continue; - case 298: + case 296: node = node.expression; continue; } @@ -12872,8 +13354,7 @@ var ts; } } function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 177) { + if (!ts.isBlock(body) && getLeftmostExpression(body).kind === 178) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -12905,7 +13386,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 184) { + while (node.kind === 185) { node = node.expression; } return node; @@ -12919,7 +13400,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 298) { + while (node.kind === 296) { node = node.expression; } return node; @@ -12962,10 +13443,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 237 && node.importClause) { + if (node.kind === 238 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 243 && node.moduleSpecifier) { + if (node.kind === 244 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -13027,11 +13508,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 260: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 261: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 262: + return bindingElement.name; + case 263: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -13047,11 +13528,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 145: - case 175: + case 146: + case 176: return bindingElement.dotDotDotToken; - case 197: - case 262: + case 198: + case 263: return bindingElement; } return undefined; @@ -13059,7 +13540,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 175: + case 176: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13067,7 +13548,7 @@ var ts; : propertyName; } break; - case 260: + case 261: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -13075,7 +13556,7 @@ var ts; : propertyName; } break; - case 262: + case 263: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -13089,11 +13570,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 173: case 174: - case 176: - return name.elements; + case 175: case 177: + return name.elements; + case 178: return name.properties; } } @@ -13132,11 +13613,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 174: - case 176: - return convertToArrayAssignmentPattern(node); - case 173: + case 175: case 177: + return convertToArrayAssignmentPattern(node); + case 174: + case 178: return convertToObjectAssignmentPattern(node); } } @@ -13182,15 +13663,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 237: + case 238: externalImports.push(node); break; - case 236: - if (node.moduleReference.kind === 247) { + case 237: + if (node.moduleReference.kind === 248) { externalImports.push(node); } break; - case 243: + case 244: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -13217,12 +13698,12 @@ var ts; } } break; - case 242: + case 243: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 207: + case 208: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -13230,7 +13711,7 @@ var ts; } } break; - case 227: + case 228: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13248,7 +13729,7 @@ var ts; } } break; - case 228: + case 229: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -13306,13 +13787,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 264) { + if (kind === 265) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 70) { + else if (kind === 71) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 142) { + else if (kind < 143) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -13348,29 +13829,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 142: + case 143: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 144: + case 145: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 261: + case 262: 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 262: + case 263: return visitNode(cbNode, node.expression); - case 145: + case 146: + case 149: case 148: - case 147: - case 260: - case 225: - case 175: + case 261: + case 226: + case 176: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -13379,24 +13860,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 159: case 160: - case 154: + case 161: case 155: case 156: + case 157: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: + case 228: + case 187: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -13407,174 +13888,168 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 158: + case 159: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 157: + case 158: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 161: - return visitNode(cbNode, node.exprName); case 162: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 163: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 164: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 165: + return visitNodes(cbNodes, node.elementTypes); case 166: - return visitNodes(cbNodes, node.types); case 167: - case 169: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 168: case 170: + return visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 171: + case 172: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 172: - return visitNode(cbNode, node.literal); case 173: + return visitNode(cbNode, node.literal); case 174: - return visitNodes(cbNodes, node.elements); - case 176: + case 175: return visitNodes(cbNodes, node.elements); case 177: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 178: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 179: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 180: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 181: + case 182: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 182: + case 183: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 183: + case 184: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 187: + case 185: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); - case 191: - return visitNode(cbNode, node.operand); - case 196: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 190: return visitNode(cbNode, node.expression); case 192: return visitNode(cbNode, node.operand); + case 197: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 191: + return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.operand); + case 194: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 201: + case 202: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.name); - case 194: + case 195: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 197: + case 198: return visitNode(cbNode, node.expression); - case 206: - case 233: + case 207: + case 234: return visitNodes(cbNodes, node.statements); - case 264: + case 265: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 207: + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 226: + case 227: return visitNodes(cbNodes, node.declarations); - case 209: - return visitNode(cbNode, node.expression); case 210: + return visitNode(cbNode, node.expression); + case 211: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 211: + case 212: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 213: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 215: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 216: - case 217: - return visitNode(cbNode, node.label); - case 218: - return visitNode(cbNode, node.expression); - case 219: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.awaitModifier) || + visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 217: + case 218: + return visitNode(cbNode, node.label); + case 219: + return visitNode(cbNode, node.expression); case 220: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 221: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 234: + case 235: return visitNodes(cbNodes, node.clauses); - case 256: + case 257: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 257: + case 258: return visitNodes(cbNodes, node.statements); - case 221: + case 222: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 222: - return visitNode(cbNode, node.expression); case 223: + return visitNode(cbNode, node.expression); + case 224: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 259: + case 260: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 146: + case 147: return visitNode(cbNode, node.expression); - case 228: - case 198: - 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 229: + case 199: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -13586,146 +14061,153 @@ 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 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 263: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 232: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 264: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 233: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 237: + case 238: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 238: + case 239: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 235: - return visitNode(cbNode, node.name); - case 239: + case 236: return visitNode(cbNode, node.name); case 240: - case 244: + return visitNode(cbNode, node.name); + case 241: + case 245: return visitNodes(cbNodes, node.elements); - case 243: + case 244: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 241: - case 245: + case 242: + case 246: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 242: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 195: + case 196: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 204: + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.types); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 247: - return visitNode(cbNode, node.expression); - case 246: - return visitNodes(cbNodes, node.decorators); case 248: + return visitNode(cbNode, node.expression); + case 247: + return visitNodes(cbNodes, node.decorators); + case 249: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 249: case 250: + case 251: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.attributes); - case 253: + case 254: return visitNodes(cbNodes, node.properties); - case 252: + case 253: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 254: - return visitNode(cbNode, node.expression); case 255: + return visitNode(cbNode, node.expression); + case 256: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 251: + case 252: return visitNode(cbNode, node.tagName); - case 266: + case 267: return visitNode(cbNode, node.type); - case 270: - return visitNodes(cbNodes, node.types); case 271: return visitNodes(cbNodes, node.types); - case 269: + case 272: + return visitNodes(cbNodes, node.types); + case 270: return visitNode(cbNode, node.elementType); + case 274: + return visitNode(cbNode, node.type); case 273: return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.type); - case 274: + case 275: return visitNode(cbNode, node.literal); - case 276: + case 277: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 277: - return visitNode(cbNode, node.type); case 278: + return visitNode(cbNode, node.type); + case 279: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 279: - return visitNode(cbNode, node.type); case 280: return visitNode(cbNode, node.type); case 281: return visitNode(cbNode, node.type); - case 275: + case 282: + return visitNode(cbNode, node.type); + case 276: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 282: + case 283: return visitNodes(cbNodes, node.tags); - case 285: + case 286: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 286: - return visitNode(cbNode, node.typeExpression); case 287: return visitNode(cbNode, node.typeExpression); - case 284: - return visitNode(cbNode, node.typeExpression); case 288: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 285: + return visitNode(cbNode, node.typeExpression); case 289: + return visitNodes(cbNodes, node.typeParameters); + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 291: + case 292: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 290: + case 291: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 298: + case 296: return visitNode(cbNode, node.expression); - case 292: + case 293: return visitNode(cbNode, node.literal); } } @@ -13889,7 +14371,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(265, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -14045,16 +14527,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 70) { + if (token() === 71) { return true; } - if (token() === 115 && inYieldContext()) { + if (token() === 116 && inYieldContext()) { return false; } - if (token() === 120 && inAwaitContext()) { + if (token() === 121 && inAwaitContext()) { return false; } - return token() > 106; + return token() > 107; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -14095,20 +14577,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 24) { + if (token() === 25) { return true; } - return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 18 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 24) { + if (token() === 25) { nextToken(); } return true; } else { - return parseExpected(24); + return parseExpected(25); } } function createNode(kind, pos) { @@ -14116,8 +14598,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 142 ? new NodeConstructor(kind, pos, pos) : - kind === 70 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 143 ? new NodeConstructor(kind, pos, pos) : + kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -14162,15 +14644,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(70); - if (token() !== 70) { + var node = createNode(71); + if (token() !== 71) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -14187,7 +14669,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 20) { + if (allowComputedPropertyNames && token() === 21) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -14202,10 +14684,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(143); - parseExpected(20); - node.expression = allowInAnd(parseExpression); + var node = createNode(144); parseExpected(21); + node.expression = allowInAnd(parseExpression); + parseExpected(22); return finishNode(node); } function parseContextualModifier(t) { @@ -14219,20 +14701,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 75) { - return nextToken() === 82; + if (token() === 76) { + return nextToken() === 83; } - if (token() === 83) { + if (token() === 84) { nextToken(); - if (token() === 78) { + if (token() === 79) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); + return token() !== 39 && token() !== 118 && token() !== 17 && canFollowModifier(); } - if (token() === 78) { + if (token() === 79) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 114) { + if (token() === 115) { nextToken(); return canFollowModifier(); } @@ -14242,16 +14724,17 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 20 - || token() === 16 - || token() === 38 - || token() === 23 + return token() === 21 + || token() === 17 + || token() === 39 + || token() === 24 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 74 || token() === 88 || - (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 75 || token() === 89 || + (token() === 117 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 120 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -14262,23 +14745,23 @@ var ts; case 0: case 1: case 3: - return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 25 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 72 || token() === 78; + return token() === 73 || token() === 79; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 25 && !inErrorRecovery); case 6: - return token() === 20 || isLiteralPropertyName(); + return token() === 21 || isLiteralPropertyName(); case 12: - return token() === 20 || token() === 38 || token() === 23 || isLiteralPropertyName(); + return token() === 21 || token() === 39 || token() === 24 || isLiteralPropertyName(); case 17: return isLiteralPropertyName(); case 9: - return token() === 20 || token() === 23 || isLiteralPropertyName(); + return token() === 21 || token() === 24 || isLiteralPropertyName(); case 7: - if (token() === 16) { + if (token() === 17) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -14290,23 +14773,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 25 || token() === 23 || isIdentifierOrPattern(); + return token() === 26 || token() === 24 || isIdentifierOrPattern(); case 18: return isIdentifier(); case 11: case 15: - return token() === 25 || token() === 23 || isStartOfExpression(); + return token() === 26 || token() === 24 || isStartOfExpression(); case 16: return isStartOfParameter(); case 19: case 20: - return token() === 25 || isStartOfType(); + return token() === 26 || isStartOfType(); case 21: return isHeritageClause(); case 22: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17; case 14: return true; case 23: @@ -14319,10 +14802,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 16); - if (nextToken() === 17) { + ts.Debug.assert(token() === 17); + if (nextToken() === 18) { var next = nextToken(); - return next === 25 || next === 16 || next === 84 || next === 107; + return next === 26 || next === 17 || next === 85 || next === 108; } return true; } @@ -14335,8 +14818,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 107 || - token() === 84) { + if (token() === 108 || + token() === 85) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -14358,40 +14841,40 @@ var ts; case 12: case 9: case 22: - return token() === 17; + return token() === 18; case 3: - return token() === 17 || token() === 72 || token() === 78; + return token() === 18 || token() === 73 || token() === 79; case 7: - return token() === 16 || token() === 84 || token() === 107; + return token() === 17 || token() === 85 || token() === 108; case 8: return isVariableDeclaratorListTerminator(); case 18: - return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; + return token() === 29 || token() === 19 || token() === 17 || token() === 85 || token() === 108; case 11: - return token() === 19 || token() === 24; + return token() === 20 || token() === 25; case 15: case 20: case 10: - return token() === 21; + return token() === 22; case 16: case 17: - return token() === 19 || token() === 21; + return token() === 20 || token() === 22; case 19: - return token() !== 25; + return token() !== 26; case 21: - return token() === 16 || token() === 17; + return token() === 17 || token() === 18; case 13: - return token() === 28 || token() === 40; + return token() === 29 || token() === 41; case 14: - return token() === 26 && lookAhead(nextTokenIsSlash); + return token() === 27 && lookAhead(nextTokenIsSlash); case 23: - return token() === 19 || token() === 55 || token() === 17; + return token() === 20 || token() === 56 || token() === 18; case 24: - return token() === 28 || token() === 17; + return token() === 29 || token() === 18; case 26: - return token() === 21 || token() === 17; + return token() === 22 || token() === 18; case 25: - return token() === 17; + return token() === 18; } } function isVariableDeclaratorListTerminator() { @@ -14401,7 +14884,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 35) { + if (token() === 36) { return true; } return false; @@ -14507,17 +14990,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 151: - case 156: case 152: + case 157: case 153: - case 148: - case 205: + case 154: + case 149: + case 206: return true; - case 150: + case 151: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 70 && - methodDeclaration.name.originalKeywordKind === 122; + var nameIsConstructor = methodDeclaration.name.kind === 71 && + methodDeclaration.name.originalKeywordKind === 123; return !nameIsConstructor; } } @@ -14526,8 +15009,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 256: case 257: + case 258: return true; } } @@ -14536,65 +15019,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 227: + case 228: + case 208: case 207: - case 206: + case 211: case 210: - case 209: - case 222: + case 223: + case 219: + case 221: case 218: - case 220: case 217: + case 215: case 216: case 214: - case 215: case 213: - case 212: - case 219: - case 208: - case 223: - case 221: - case 211: + case 220: + case 209: case 224: + case 222: + case 212: + case 225: + case 238: case 237: - case 236: + case 244: case 243: - case 242: - case 232: - case 228: + case 233: case 229: - case 231: case 230: + case 232: + case 231: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 263; + return node.kind === 264; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 155: - case 149: case 156: - case 147: - case 154: + case 150: + case 157: + case 148: + case 155: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 225) { + if (node.kind !== 226) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 145) { + if (node.kind !== 146) { return false; } var parameter = node; @@ -14639,7 +15122,6 @@ var ts; case 25: return ts.Diagnostics.Property_assignment_expected; } } - ; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -14649,15 +15131,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(25)) { + if (parseOptional(26)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(25); - if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { + parseExpected(26); + if (considerSemicolonAsDelimiter && token() === 25 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -14689,8 +15171,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(22)) { - var node = createNode(142, entity.pos); + while (parseOptional(23)) { + var node = createNode(143, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -14701,33 +15183,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(71, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(195); + var template = createNode(196); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(204); + var span = createNode(205); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 17) { + if (token() === 18) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); + literal = parseExpectedToken(16, false, ts.Diagnostics._0_expected, ts.tokenToString(18)); } span.literal = literal; return finishNode(span); @@ -14737,12 +15219,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 14, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 || fragment.kind === 16, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -14755,47 +15237,43 @@ var ts; if (scanner.isUnterminated()) { node.isUnterminated = true; } - var tokenPos = scanner.getTokenPos(); + if (node.kind === 8) { + node.numericLiteralFlags = scanner.getNumericLiteralFlags(); + } nextToken(); finishNode(node); - if (node.kind === 8 - && sourceText.charCodeAt(tokenPos) === 48 - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.isOctalLiteral = true; - } return node; } function parseTypeReference() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(158, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 26) { - node.typeArguments = parseBracketedList(19, parseType, 26, 28); + var node = createNode(159); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token() === 27) { + node.typeArguments = parseBracketedList(19, parseType, 27, 29); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(157, lhs.pos); + var node = createNode(158, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(168); + var node = createNode(169); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(161); - parseExpected(102); + var node = createNode(162); + parseExpected(103); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(144); + var node = createNode(145); node.name = parseIdentifier(); - if (parseOptional(84)) { + if (parseOptional(85)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -14803,40 +15281,40 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(57)) { + if (parseOptional(58)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 26) { - return parseBracketedList(18, parseTypeParameter, 26, 28); + if (token() === 27) { + return parseBracketedList(18, parseTypeParameter, 27, 29); } } function parseParameterType() { - if (parseOptional(55)) { + if (parseOptional(56)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; + return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 57 || token() === 99; } function parseParameter() { - var node = createNode(145); - if (token() === 98) { - node.name = createIdentifier(true, undefined); + var node = createNode(146); + if (token() === 99) { + node.name = createIdentifier(true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(23); + node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(54); + node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -14848,7 +15326,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 35; + var returnTokenRequired = returnToken === 36; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -14860,7 +15338,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(18)) { + if (parseExpected(19)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -14868,7 +15346,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(19) && requireCompleteParameterList) { + if (!parseExpected(20) && requireCompleteParameterList) { return undefined; } return result; @@ -14876,29 +15354,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(25)) { + if (parseOptional(26)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 155) { - parseExpected(93); + if (kind === 156) { + parseExpected(94); } - fillSignature(55, false, false, false, node); + fillSignature(56, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 20) { + if (token() !== 21) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 23 || token() === 21) { + if (token() === 24 || token() === 22) { return true; } if (ts.isModifierKind(token())) { @@ -14913,43 +15391,43 @@ var ts; else { nextToken(); } - if (token() === 55 || token() === 25) { + if (token() === 56 || token() === 26) { return true; } - if (token() !== 54) { + if (token() !== 55) { return false; } nextToken(); - return token() === 55 || token() === 25 || token() === 21; + return token() === 56 || token() === 26 || token() === 22; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(156, fullStart); + var node = createNode(157, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 20, 21); + node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (token() === 18 || token() === 26) { - var method = createNode(149, fullStart); + var questionToken = parseOptionalToken(55); + if (token() === 19 || token() === 27) { + var method = createNode(150, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(55, false, false, false, method); + fillSignature(56, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 57) { + if (token() === 58) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -14957,38 +15435,38 @@ var ts; } } function isTypeMemberStart() { - var idToken; - if (token() === 18 || token() === 26) { + if (token() === 19 || token() === 27) { return true; } + var idToken; while (ts.isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } - if (token() === 20) { + if (token() === 21) { return true; } if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } if (idToken) { - return token() === 18 || - token() === 26 || - token() === 54 || + return token() === 19 || + token() === 27 || token() === 55 || - token() === 25 || + token() === 56 || + token() === 26 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 18 || token() === 26) { - return parseSignatureMember(154); - } - if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + if (token() === 19 || token() === 27) { return parseSignatureMember(155); } + if (token() === 94 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(156); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -14998,18 +15476,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 18 || token() === 26; + return token() === 19 || token() === 27; } function parseTypeLiteral() { - var node = createNode(162); + var node = createNode(163); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(16)) { + if (parseExpected(17)) { members = parseList(4, parseTypeMember); - parseExpected(17); + parseExpected(18); } else { members = createMissingList(); @@ -15018,57 +15496,57 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 130) { + if (token() === 131) { nextToken(); } - return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; + return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; } function parseMappedTypeParameter() { - var node = createNode(144); + var node = createNode(145); node.name = parseIdentifier(); - parseExpected(91); + parseExpected(92); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(171); - parseExpected(16); - node.readonlyToken = parseOptionalToken(130); - parseExpected(20); - node.typeParameter = parseMappedTypeParameter(); + var node = createNode(172); + parseExpected(17); + node.readonlyToken = parseOptionalToken(131); parseExpected(21); - node.questionToken = parseOptionalToken(54); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(22); + node.questionToken = parseOptionalToken(55); node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(17); + parseExpected(18); return finishNode(node); } function parseTupleType() { - var node = createNode(164); - node.elementTypes = parseBracketedList(20, parseType, 20, 21); + var node = createNode(165); + node.elementTypes = parseBracketedList(20, parseType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(167); - parseExpected(18); - node.type = parseType(); + var node = createNode(168); parseExpected(19); + node.type = parseType(); + parseExpected(20); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 160) { - parseExpected(93); + if (kind === 161) { + parseExpected(94); } - fillSignature(35, false, false, false, node); + fillSignature(36, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 22 ? undefined : node; + return token() === 23 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(172); + var node = createNode(173); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -15078,42 +15556,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: - case 138: - case 129: case 133: + case 122: + case 137: + case 139: + case 130: + case 134: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 100: - case 85: + case 101: + case 86: return parseLiteralTypeNode(); - case 37: + case 38: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 104: - case 94: + case 105: + case 95: return parseTokenNode(); - case 98: { + case 99: { var thisKeyword = parseThisTypeNode(); - if (token() === 125 && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 102: + case 103: return parseTypeQuery(); - case 16: + case 17: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 20: + case 21: return parseTupleType(); - case 18: + case 19: return parseParenthesizedType(); default: return parseTypeReference(); @@ -15121,32 +15599,32 @@ var ts; } function isStartOfType() { switch (token()) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: - case 104: - case 138: - case 94: - case 98: - case 102: - case 129: - case 16: - case 20: - case 26: + case 133: + case 122: + case 137: + case 105: + case 139: + case 95: + case 99: + case 103: + case 130: + case 17: + case 21: + case 27: + case 49: case 48: - case 47: - case 93: + case 94: case 9: case 8: - case 100: - case 85: - case 133: + case 101: + case 86: + case 134: return true; - case 37: + case 38: return lookAhead(nextTokenIsNumericLiteral); - case 18: + case 19: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -15154,29 +15632,29 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 19 || isStartOfParameter() || isStartOfType(); + return token() === 20 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + while (!scanner.hasPrecedingLineBreak() && parseOptional(21)) { if (isStartOfType()) { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(21); + parseExpected(22); type = finishNode(node); } else { - var node = createNode(163, type.pos); + var node = createNode(164, type.pos); node.elementType = type; - parseExpected(21); + parseExpected(22); type = finishNode(node); } } return type; } function parseTypeOperator(operator) { - var node = createNode(169); + var node = createNode(170); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -15184,8 +15662,8 @@ var ts; } function parseTypeOperatorOrHigher() { switch (token()) { - case 126: - return parseTypeOperator(126); + case 127: + return parseTypeOperator(127); } return parseArrayTypeOrHigher(); } @@ -15205,26 +15683,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(167, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(166, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { - if (token() === 26) { + if (token() === 27) { return true; } - return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 19 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 98) { + if (isIdentifier() || token() === 99) { nextToken(); return true; } - if (token() === 20 || token() === 16) { + if (token() === 21 || token() === 17) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -15233,17 +15711,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 19 || token() === 23) { + if (token() === 20 || token() === 24) { return true; } if (skipParameterStart()) { - if (token() === 55 || token() === 25 || - token() === 54 || token() === 57) { + if (token() === 56 || token() === 26 || + token() === 55 || token() === 58) { return true; } - if (token() === 19) { + if (token() === 20) { nextToken(); - if (token() === 35) { + if (token() === 36) { return true; } } @@ -15254,7 +15732,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(157, typePredicateVariable.pos); + var node = createNode(158, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -15265,7 +15743,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 125 && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -15275,36 +15753,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(159); - } - if (token() === 93) { return parseFunctionOrConstructorType(160); } + if (token() === 94) { + return parseFunctionOrConstructorType(161); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(55) ? parseType() : undefined; + return parseOptional(56) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 98: - case 96: - case 94: - case 100: - case 85: + case 99: + case 97: + case 95: + case 101: + case 86: case 8: case 9: - case 12: case 13: - case 18: - case 20: - case 16: - case 88: - case 74: - case 93: - case 40: - case 62: - case 70: + case 14: + case 19: + case 21: + case 17: + case 89: + case 75: + case 94: + case 41: + case 63: + case 71: return true; default: return isIdentifier(); @@ -15315,18 +15793,18 @@ var ts; return true; } switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 79: - case 102: - case 104: - case 42: + case 80: + case 103: + case 105: case 43: - case 26: - case 120: - case 115: + case 44: + case 27: + case 121: + case 116: return true; default: if (isBinaryOperator()) { @@ -15336,10 +15814,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 16 && - token() !== 88 && - token() !== 74 && - token() !== 56 && + return token() !== 17 && + token() !== 89 && + token() !== 75 && + token() !== 57 && isStartOfExpression(); } function parseExpression() { @@ -15349,7 +15827,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(25))) { + while ((operatorToken = parseOptionalToken(26))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -15358,12 +15836,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 57) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { + if (token() !== 58) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } } - parseExpected(57); + parseExpected(58); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -15375,7 +15853,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 70 && token() === 35) { + if (expr.kind === 71 && token() === 36) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -15384,7 +15862,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 115) { + if (token() === 116) { if (inYieldContext()) { return true; } @@ -15397,11 +15875,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(196); + var node = createNode(197); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 38 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(38); + (token() === 39 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(39); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15410,21 +15888,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(186, asyncModifier.pos); + node = createNode(187, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(186, identifier.pos); + node = createNode(187, identifier.pos); } - var parameter = createNode(145, identifier.pos); + var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -15441,78 +15919,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 35 || lastToken === 16) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 36 || lastToken === 17) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 18 || token() === 26 || token() === 119) { + if (token() === 19 || token() === 27 || token() === 120) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 35) { + if (token() === 36) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 119) { + if (token() === 120) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 18 && token() !== 26) { + if (token() !== 19 && token() !== 27) { return 0; } } var first = token(); var second = nextToken(); - if (first === 18) { - if (second === 19) { + if (first === 19) { + if (second === 20) { var third = nextToken(); switch (third) { - case 35: - case 55: - case 16: + case 36: + case 56: + case 17: return 1; default: return 0; } } - if (second === 20 || second === 16) { + if (second === 21 || second === 17) { return 2; } - if (second === 23) { + if (second === 24) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 55) { + if (nextToken() === 56) { return 1; } return 2; } else { - ts.Debug.assert(first === 26); + ts.Debug.assert(first === 27); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 84) { + if (third === 85) { var fourth = nextToken(); switch (fourth) { - case 57: - case 28: + case 58: + case 29: return false; default: return true; } } - else if (third === 25) { + else if (third === 26) { return true; } return false; @@ -15529,7 +16007,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 119) { + if (token() === 120) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -15540,38 +16018,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 119) { + if (token() === 120) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 35) { + if (scanner.hasPrecedingLineBreak() || token() === 36) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 && token() === 36) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(186); + var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(55, false, isAsync, !allowAmbiguity, node); + fillSignature(56, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 35 && token() !== 16) { + if (!allowAmbiguity && token() !== 36 && token() !== 17) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 16) { + if (token() === 17) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 24 && - token() !== 88 && - token() !== 74 && + if (token() !== 25 && + token() !== 89 && + token() !== 75 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -15581,15 +16059,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(54); + var questionToken = parseOptionalToken(55); if (!questionToken) { return leftOperand; } - var node = createNode(194, leftOperand.pos); + var node = createNode(195, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); + node.colonToken = parseExpectedToken(56, false, ts.Diagnostics._0_expected, ts.tokenToString(56)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -15598,22 +16076,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 141; + return t === 92 || t === 142; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 39 ? + var consumeCurrentOperator = token() === 40 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 91 && inDisallowInContext()) { + if (token() === 92 && inDisallowInContext()) { break; } - if (token() === 117) { + if (token() === 118) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -15629,92 +16107,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 91) { + if (inDisallowInContext() && token() === 92) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 53: + case 54: return 1; - case 52: + case 53: return 2; - case 48: - return 3; case 49: + return 3; + case 50: return 4; - case 47: + case 48: return 5; - case 31: case 32: case 33: case 34: + case 35: return 6; - case 26: - case 28: + case 27: case 29: case 30: + case 31: + case 93: case 92: - case 91: - case 117: + case 118: return 7; - case 44: case 45: case 46: + case 47: return 8; - case 36: case 37: - return 9; case 38: - case 40: - case 41: - return 10; + return 9; case 39: + case 41: + case 42: + return 10; + case 40: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(193, left.pos); + var node = createNode(194, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(201, left.pos); + var node = createNode(202, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(191); + var node = createNode(192); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(187); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(189); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(190); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 120) { + if (token() === 121) { if (inAwaitContext()) { return true; } @@ -15723,7 +16201,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -15731,15 +16209,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 39 ? + return token() === 40 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 39) { + if (token() === 40) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 183) { + if (simpleUnaryExpression.kind === 184) { 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 { @@ -15750,20 +16228,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: return parsePrefixUnaryExpression(); - case 79: + case 80: return parseDeleteExpression(); - case 102: + case 103: return parseTypeOfExpression(); - case 104: + case 105: return parseVoidExpression(); - case 26: + case 27: return parseTypeAssertion(); - case 120: + case 121: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -15773,16 +16251,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 79: - case 102: - case 104: - case 120: + case 80: + case 103: + case 105: + case 121: return false; - case 26: + case 27: if (sourceFile.languageVariant !== 1) { return false; } @@ -15791,20 +16269,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 42 || token() === 43) { - var node = createNode(191); + if (token() === 43 || token() === 44) { + var node = createNode(192); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 27 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(192, expression.pos); + if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(193, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -15813,7 +16291,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 96 + var expression = token() === 97 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -15824,12 +16302,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 18 || token() === 22 || token() === 20) { + if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(178, expression.pos); + var node = createNode(179, expression.pos); node.expression = expression; - parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(23, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -15837,10 +16315,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 70) { + if (lhs.kind === 71) { return lhs.text === rhs.text; } - if (lhs.kind === 98) { + if (lhs.kind === 99) { return true; } return lhs.name.text === rhs.name.text && @@ -15849,8 +16327,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 250) { - var node = createNode(248, opening.pos); + if (opening.kind === 251) { + var node = createNode(249, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -15860,18 +16338,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 249); + ts.Debug.assert(opening.kind === 250); result = opening; } - if (inExpressionContext && token() === 26) { + if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(193, result.pos); + var badNode = createNode(194, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(25, false, undefined); + badNode.operatorToken = createMissingNode(26, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -15880,16 +16358,18 @@ var ts; } function parseJsxText() { var node = createNode(10, scanner.getStartPos()); + node.containsOnlyWhiteSpaces = currentToken === 11; currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { case 10: + case 11: return parseJsxText(); - case 16: + case 17: return parseJsxExpression(false); - case 26: + case 27: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -15900,44 +16380,50 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 27) { + if (token() === 28) { break; } else if (token() === 1) { parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } - result.push(parseJsxChild()); + else if (token() === 7) { + break; + } + var child = parseJsxChild(); + if (child) { + result.push(child); + } } result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; return result; } function parseJsxAttributes() { - var jsxAttributes = createNode(253); + var jsxAttributes = createNode(254); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(26); + parseExpected(27); var tagName = parseJsxElementName(); var attributes = parseJsxAttributes(); var node; - if (token() === 28) { - node = createNode(250, fullStart); + if (token() === 29) { + node = createNode(251, fullStart); scanJsxText(); } else { - parseExpected(40); + parseExpected(41); if (inExpressionContext) { - parseExpected(28); + parseExpected(29); } else { - parseExpected(28, undefined, false); + parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(249, fullStart); + node = createNode(250, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -15945,10 +16431,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 98 ? + var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(22)) { - var propertyAccess = createNode(178, expression.pos); + while (parseOptional(23)) { + var propertyAccess = createNode(179, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -15956,29 +16442,29 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(255); - parseExpected(16); - if (token() !== 17) { - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(256); + parseExpected(17); + if (token() !== 18) { + node.dotDotDotToken = parseOptionalToken(24); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(17); + parseExpected(18); } else { - parseExpected(17, undefined, false); + parseExpected(18, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 16) { + if (token() === 17) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(252); + var node = createNode(253); node.name = parseIdentifierName(); - if (token() === 57) { + if (token() === 58) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -15991,69 +16477,69 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(254); - parseExpected(16); - parseExpected(23); - node.expression = parseExpression(); + var node = createNode(255); parseExpected(17); + parseExpected(24); + node.expression = parseExpression(); + parseExpected(18); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(251); - parseExpected(27); + var node = createNode(252); + parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(28); + parseExpected(29); } else { - parseExpected(28, undefined, false); + parseExpected(29, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(183); - parseExpected(26); + var node = createNode(184); + parseExpected(27); node.type = parseType(); - parseExpected(28); + parseExpected(29); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(22); + var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(178, expression.pos); + var propertyAccess = createNode(179, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 50 && !scanner.hasPrecedingLineBreak()) { + if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(202, expression.pos); + var nonNullExpression = createNode(203, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(179, expression.pos); + if (!inDecoratorContext() && parseOptional(21)) { + var indexedAccess = createNode(180, expression.pos); indexedAccess.expression = expression; - if (token() !== 21) { + if (token() !== 22) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(21); + parseExpected(22); expression = finishNode(indexedAccess); continue; } - if (token() === 12 || token() === 13) { - var tagExpression = createNode(182, expression.pos); + if (token() === 13 || token() === 14) { + var tagExpression = createNode(183, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 12 + tagExpression.template = token() === 13 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -16065,20 +16551,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 26) { + if (token() === 27) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(180, expression.pos); + var callExpr = createNode(181, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 18) { - var callExpr = createNode(180, expression.pos); + else if (token() === 19) { + var callExpr = createNode(181, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -16088,17 +16574,17 @@ var ts; } } function parseArgumentList() { - parseExpected(18); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(19); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(20); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(26)) { + if (!parseOptional(27)) { return undefined; } var typeArguments = parseDelimitedList(19, parseType); - if (!parseExpected(28)) { + if (!parseExpected(29)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -16107,27 +16593,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 18: - case 22: case 19: - case 21: + case 23: + case 20: + case 22: + case 56: + case 25: case 55: - case 24: - case 54: - case 31: - case 33: case 32: case 34: - case 52: + case 33: + case 35: case 53: - case 49: - case 47: + case 54: + case 50: case 48: - case 17: + case 49: + case 18: case 1: return true; - case 25: - case 16: + case 26: + case 17: default: return false; } @@ -16136,87 +16622,87 @@ var ts; switch (token()) { case 8: case 9: - case 12: + case 13: return parseLiteralNode(); - case 98: - case 96: - case 94: - case 100: - case 85: + case 99: + case 97: + case 95: + case 101: + case 86: return parseTokenNode(); - case 18: + case 19: return parseParenthesizedExpression(); - case 20: + case 21: return parseArrayLiteralExpression(); - case 16: + case 17: return parseObjectLiteralExpression(); - case 119: + case 120: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 74: + case 75: return parseClassExpression(); - case 88: + case 89: return parseFunctionExpression(); - case 93: + case 94: return parseNewExpression(); - case 40: - case 62: - if (reScanSlashToken() === 11) { + case 41: + case 63: + if (reScanSlashToken() === 12) { return parseLiteralNode(); } break; - case 13: + case 14: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(184); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(185); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(197); - parseExpected(23); + var node = createNode(198); + parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(199) : + return token() === 24 ? parseSpreadElement() : + token() === 26 ? createNode(200) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(176); - parseExpected(20); + var node = createNode(177); + parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(21); + parseExpected(22); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(124)) { - return parseAccessorDeclaration(152, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(134)) { + if (parseContextualModifier(125)) { return parseAccessorDeclaration(153, fullStart, decorators, modifiers); } + else if (parseContextualModifier(135)) { + return parseAccessorDeclaration(154, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); - var dotDotDotToken = parseOptionalToken(23); + var dotDotDotToken = parseOptionalToken(24); if (dotDotDotToken) { - var spreadElement = createNode(262, fullStart); + var spreadElement = createNode(263, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -16226,19 +16712,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(38); + var asteriskToken = parseOptionalToken(39); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (asteriskToken || token() === 18 || token() === 26) { + var questionToken = parseOptionalToken(55); + if (asteriskToken || token() === 19 || token() === 27) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(261, fullStart); + var shorthandDeclaration = createNode(262, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(57); + var equalsToken = parseOptionalToken(58); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -16246,23 +16732,23 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(260, fullStart); + var propertyAssignment = createNode(261, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(55); + parseExpected(56); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(177); - parseExpected(16); + var node = createNode(178); + parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(17); + parseExpected(18); return finishNode(node); } function parseFunctionExpression() { @@ -16270,10 +16756,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiers(); - parseExpected(88); - node.asteriskToken = parseOptionalToken(38); + parseExpected(89); + node.asteriskToken = parseOptionalToken(39); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -16281,7 +16767,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(55, isGenerator, isAsync, false, node); + fillSignature(56, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -16293,29 +16779,29 @@ var ts; } function parseNewExpression() { var fullStart = scanner.getStartPos(); - parseExpected(93); - if (parseOptional(22)) { - var node_1 = createNode(203, fullStart); - node_1.keywordToken = 93; + parseExpected(94); + if (parseOptional(23)) { + var node_1 = createNode(204, fullStart); + node_1.keywordToken = 94; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(181, fullStart); + var node = createNode(182, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 18) { + if (node.typeArguments || token() === 19) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(206); - if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(207); + if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(17); + parseExpected(18); } else { node.statements = createMissingList(); @@ -16340,47 +16826,48 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(208); - parseExpected(24); + var node = createNode(209); + parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(210); - parseExpected(89); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(211); + parseExpected(90); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(81) ? parseStatement() : undefined; + node.elseStatement = parseOptional(82) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(211); - parseExpected(80); + var node = createNode(212); + parseExpected(81); node.statement = parseStatement(); - parseExpected(105); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + parseExpected(106); parseExpected(19); - parseOptional(24); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + parseOptional(25); return finishNode(node); } function parseWhileStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(87); - parseExpected(18); + parseExpected(88); + var awaitToken = parseOptionalToken(121); + parseExpected(19); var initializer = undefined; - if (token() !== 24) { - if (token() === 103 || token() === 109 || token() === 75) { + if (token() !== 25) { + if (token() === 104 || token() === 110 || token() === 76) { initializer = parseVariableDeclarationList(true); } else { @@ -16388,32 +16875,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(91)) { - var forInStatement = createNode(214, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(19); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(141)) { - var forOfStatement = createNode(215, pos); + if (awaitToken ? parseExpected(142) : parseOptional(142)) { + var forOfStatement = createNode(216, pos); + forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(19); + parseExpected(20); forOrForInOrForOfStatement = forOfStatement; } + else if (parseOptional(92)) { + var forInStatement = createNode(215, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(20); + forOrForInOrForOfStatement = forInStatement; + } else { - var forStatement = createNode(213, pos); + var forStatement = createNode(214, pos); forStatement.initializer = initializer; - parseExpected(24); - if (token() !== 24 && token() !== 19) { + parseExpected(25); + if (token() !== 25 && token() !== 20) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(24); - if (token() !== 19) { + parseExpected(25); + if (token() !== 20) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(19); + parseExpected(20); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -16421,7 +16909,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 217 ? 71 : 76); + parseExpected(kind === 218 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -16429,8 +16917,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(218); - parseExpected(95); + var node = createNode(219); + parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -16438,90 +16926,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(219); - parseExpected(106); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(220); + parseExpected(107); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(256); - parseExpected(72); + var node = createNode(257); + parseExpected(73); node.expression = allowInAnd(parseExpression); - parseExpected(55); + parseExpected(56); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(257); - parseExpected(78); - parseExpected(55); + var node = createNode(258); + parseExpected(79); + parseExpected(56); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 72 ? parseCaseClause() : parseDefaultClause(); + return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(220); - parseExpected(97); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(221); + parseExpected(98); parseExpected(19); - var caseBlock = createNode(234, scanner.getStartPos()); - parseExpected(16); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + var caseBlock = createNode(235, scanner.getStartPos()); parseExpected(17); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(18); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(222); - parseExpected(99); + var node = createNode(223); + parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(223); - parseExpected(101); + var node = createNode(224); + parseExpected(102); node.tryBlock = parseBlock(false); - node.catchClause = token() === 73 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 86) { - parseExpected(86); + node.catchClause = token() === 74 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 87) { + parseExpected(87); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(259); - parseExpected(73); - if (parseExpected(18)) { + var result = createNode(260); + parseExpected(74); + if (parseExpected(19)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(19); + parseExpected(20); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(224); - parseExpected(77); + var node = createNode(225); + parseExpected(78); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(221, fullStart); + if (expression.kind === 71 && parseOptional(56)) { + var labeledStatement = createNode(222, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(209, fullStart); + var expressionStatement = createNode(210, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -16531,9 +17019,13 @@ var ts; nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsClassKeywordOnSameLine() { + nextToken(); + return token() === 75 && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 88 && !scanner.hasPrecedingLineBreak(); + return token() === 89 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -16542,47 +17034,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 103: - case 109: + case 104: + case 110: + case 76: + case 89: case 75: - case 88: - case 74: - case 82: + case 83: return true; - case 108: - case 137: + case 109: + case 138: return nextTokenIsIdentifierOnSameLine(); - case 127: case 128: + case 129: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 119: - case 123: - case 111: + case 117: + case 120: + case 124: case 112: case 113: - case 130: + case 114: + case 131: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 140: + case 141: nextToken(); - return token() === 16 || token() === 70 || token() === 83; - case 90: + return token() === 17 || token() === 71 || token() === 84; + case 91: nextToken(); - return token() === 9 || token() === 38 || - token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); - case 83: + return token() === 9 || token() === 39 || + token() === 17 || ts.tokenIsIdentifierOrKeyword(token()); + case 84: nextToken(); - if (token() === 57 || token() === 38 || - token() === 16 || token() === 78 || - token() === 117) { + if (token() === 58 || token() === 39 || + token() === 17 || token() === 79 || + token() === 118) { return true; } continue; - case 114: + case 115: nextToken(); continue; default: @@ -16595,46 +17087,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 56: - case 24: - case 16: - case 103: - case 109: - case 88: - case 74: - case 82: + case 57: + case 25: + case 17: + case 104: + case 110: case 89: - case 80: - case 105: - case 87: - case 76: - case 71: - case 95: - case 106: - case 97: - case 99: - case 101: - case 77: - case 73: - case 86: - return true; case 75: case 83: case 90: - return isStartOfDeclaration(); - case 119: - case 123: - case 108: - case 127: - case 128: - case 137: - case 140: + case 81: + case 106: + case 88: + case 77: + case 72: + case 96: + case 107: + case 98: + case 100: + case 102: + case 78: + case 74: + case 87: + return true; + case 76: + case 84: + case 91: + return isStartOfDeclaration(); + case 120: + case 124: + case 109: + case 128: + case 129: + case 138: + case 141: return true; - case 113: - case 111: - case 112: case 114: - case 130: + case 112: + case 113: + case 115: + case 131: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -16642,73 +17134,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 16 || token() === 20; + return isIdentifier() || token() === 17 || token() === 21; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 24: + case 25: return parseEmptyStatement(); - case 16: + case 17: return parseBlock(false); - case 103: + case 104: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 109: + case 110: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 88: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 74: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 89: - return parseIfStatement(); - case 80: - return parseDoStatement(); - case 105: - return parseWhileStatement(); - case 87: - return parseForOrForInOrForOfStatement(); - case 76: - return parseBreakOrContinueStatement(216); - case 71: - return parseBreakOrContinueStatement(217); - case 95: - return parseReturnStatement(); - case 106: - return parseWithStatement(); - case 97: - return parseSwitchStatement(); - case 99: - return parseThrowStatement(); - case 101: - case 73: - case 86: - return parseTryStatement(); - case 77: - return parseDebuggerStatement(); - case 56: - return parseDeclaration(); - case 119: - case 108: - case 137: - case 127: - case 128: - case 123: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 75: - case 82: - case 83: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 90: - case 111: + return parseIfStatement(); + case 81: + return parseDoStatement(); + case 106: + return parseWhileStatement(); + case 88: + return parseForOrForInOrForOfStatement(); + case 77: + return parseBreakOrContinueStatement(217); + case 72: + return parseBreakOrContinueStatement(218); + case 96: + return parseReturnStatement(); + case 107: + return parseWithStatement(); + case 98: + return parseSwitchStatement(); + case 100: + return parseThrowStatement(); + case 102: + case 74: + case 87: + return parseTryStatement(); + case 78: + return parseDebuggerStatement(); + case 57: + return parseDeclaration(); + case 120: + case 109: + case 138: + case 128: + case 129: + case 124: + case 76: + case 83: + case 84: + case 91: case 112: case 113: - case 116: case 114: - case 130: - case 140: + case 117: + case 115: + case 131: + case 141: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -16721,40 +17213,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 103: - case 109: - case 75: + case 104: + case 110: + case 76: return parseVariableStatement(fullStart, decorators, modifiers); - case 88: + case 89: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 74: + case 75: return parseClassDeclaration(fullStart, decorators, modifiers); - case 108: + case 109: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 137: + case 138: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 82: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 140: - case 127: - case 128: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 90: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 83: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 141: + case 128: + case 129: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 91: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 84: nextToken(); switch (token()) { - case 78: - case 57: + case 79: + case 58: return parseExportAssignment(fullStart, decorators, modifiers); - case 117: + case 118: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(247, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -16767,32 +17259,32 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 16 && canParseSemicolon()) { + if (token() !== 17 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 25) { - return createNode(199); + if (token() === 26) { + return createNode(200); } - var node = createNode(175); - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(176); + node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(175); - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(176); + node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 55) { + if (tokenIsIdentifier && token() !== 56) { node.name = propertyName; } else { - parseExpected(55); + parseExpected(56); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -16800,33 +17292,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(173); - parseExpected(16); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(174); parseExpected(17); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(174); - parseExpected(20); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(175); parseExpected(21); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(22); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 16 || token() === 20 || isIdentifier(); + return token() === 17 || token() === 21 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 20) { + if (token() === 21) { return parseArrayBindingPattern(); } - if (token() === 16) { + if (token() === 17) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(225); + var node = createNode(226); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -16835,21 +17327,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(226); + var node = createNode(227); switch (token()) { - case 103: + case 104: break; - case 109: + case 110: node.flags |= 1; break; - case 75: + case 76: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 142 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -16861,10 +17353,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 19; + return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(207, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -16872,29 +17364,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(88); - node.asteriskToken = parseOptionalToken(38); + parseExpected(89); + node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(55, isGenerator, isAsync, false, node); + fillSignature(56, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(151, pos); + var node = createNode(152, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(122); - fillSignature(55, false, false, false, node); + parseExpected(123); + fillSignature(56, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(150, fullStart); + var method = createNode(151, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -16902,12 +17394,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(55, isGenerator, isAsync, false, method); + fillSignature(56, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(148, fullStart); + var property = createNode(149, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -16920,10 +17412,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(38); + var asteriskToken = parseOptionalToken(39); var name = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (asteriskToken || token() === 18 || token() === 26) { + var questionToken = parseOptionalToken(55); + if (asteriskToken || token() === 19 || token() === 27) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -16938,17 +17430,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(55, false, false, false, node); + fillSignature(56, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 113: - case 111: - case 112: case 114: - case 130: + case 112: + case 113: + case 115: + case 131: return true; default: return false; @@ -16956,7 +17448,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 56) { + if (token() === 57) { return true; } while (ts.isModifierKind(token())) { @@ -16966,26 +17458,26 @@ var ts; } nextToken(); } - if (token() === 38) { + if (token() === 39) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 20) { + if (token() === 21) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 135 || idToken === 125) { return true; } switch (token()) { - case 18: - case 26: + case 19: + case 27: + case 56: + case 58: case 55: - case 57: - case 54: return true; default: return canParseSemicolon(); @@ -16997,10 +17489,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(56)) { + if (!parseOptional(57)) { break; } - var decorator = createNode(146, decoratorStart); + var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -17020,7 +17512,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 75 && permitInvalidConstAsModifier) { + if (token() === 76 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -17045,7 +17537,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 119) { + if (token() === 120) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -17056,8 +17548,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 24) { - var result = createNode(205); + if (token() === 25) { + var result = createNode(206); nextToken(); return finishNode(result); } @@ -17068,7 +17560,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 122) { + if (token() === 123) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -17077,33 +17569,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 38 || - token() === 20) { + token() === 39 || + token() === 21) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 199); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 229); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(74); + parseExpected(75); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(16)) { + if (parseExpected(17)) { node.members = parseClassMembers(); - parseExpected(17); + parseExpected(18); } else { node.members = createMissingList(); @@ -17116,7 +17608,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 108 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -17125,9 +17617,10 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 84 || token() === 107) { - var node = createNode(258); - node.token = token(); + var tok = token(); + if (tok === 85 || tok === 108) { + var node = createNode(259); + node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); @@ -17135,24 +17628,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(200); + var node = createNode(201); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 26) { - node.typeArguments = parseBracketedList(19, parseType, 26, 28); + if (token() === 27) { + node.typeArguments = parseBracketedList(19, parseType, 27, 29); } return finishNode(node); } function isHeritageClause() { - return token() === 84 || token() === 107; + return token() === 85 || token() === 108; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(108); + parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -17160,32 +17653,32 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(137); + parseExpected(138); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(57); + parseExpected(58); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(263, scanner.getStartPos()); + var node = createNode(264, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(82); + parseExpected(83); node.name = parseIdentifier(); - if (parseExpected(16)) { + if (parseExpected(17)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(17); + parseExpected(18); } else { node.members = createMissingList(); @@ -17193,10 +17686,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(233, scanner.getStartPos()); - if (parseExpected(16)) { + var node = createNode(234, scanner.getStartPos()); + if (parseExpected(17)) { node.statements = parseList(1, parseStatement); - parseExpected(17); + parseExpected(18); } else { node.statements = createMissingList(); @@ -17204,29 +17697,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(232, fullStart); + var node = createNode(233, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(22) + node.body = parseOptional(23) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(232, fullStart); + var node = createNode(233, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 140) { + if (token() === 141) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 16) { + if (token() === 17) { node.body = parseModuleBlock(); } else { @@ -17236,14 +17729,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 140) { + if (token() === 141) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(128)) { + else if (parseOptional(129)) { flags |= 16; } else { - parseExpected(127); + parseExpected(128); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -17251,63 +17744,66 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 131 && + return token() === 132 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 18; + return nextToken() === 19; } function nextTokenIsSlash() { - return nextToken() === 40; + return nextToken() === 41; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(235, fullStart); + var exportDeclaration = createNode(236, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(117); - parseExpected(128); + parseExpected(118); + parseExpected(129); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(90); + parseExpected(91); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 139) { - var importEqualsDeclaration = createNode(236, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(57); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + if (token() !== 26 && token() !== 140) { + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } - var importDeclaration = createNode(237, fullStart); + var importDeclaration = createNode(238, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 38 || - token() === 16) { + token() === 39 || + token() === 17) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(139); + parseExpected(140); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier) { + var importEqualsDeclaration = createNode(237, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(58); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } function parseImportClause(identifier, fullStart) { - var importClause = createNode(238, fullStart); + var importClause = createNode(239, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); + parseOptional(26)) { + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(241); } return finishNode(importClause); } @@ -17317,11 +17813,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(247); - parseExpected(131); - parseExpected(18); - node.expression = parseModuleSpecifier(); + var node = createNode(248); + parseExpected(132); parseExpected(19); + node.expression = parseModuleSpecifier(); + parseExpected(20); return finishNode(node); } function parseModuleSpecifier() { @@ -17335,22 +17831,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(239); - parseExpected(38); - parseExpected(117); + var namespaceImport = createNode(240); + parseExpected(39); + parseExpected(118); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 241 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(245); + return parseImportOrExportSpecifier(246); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(241); + return parseImportOrExportSpecifier(242); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -17358,9 +17854,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 117) { + if (token() === 118) { node.propertyName = identifierName; - parseExpected(117); + parseExpected(118); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -17369,23 +17865,23 @@ var ts; else { node.name = identifierName; } - if (kind === 241 && checkIdentifierIsKeyword) { + if (kind === 242 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(243, fullStart); + var node = createNode(244, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(38)) { - parseExpected(139); + if (parseOptional(39)) { + parseExpected(140); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(244); - if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(139); + node.exportClause = parseNamedImportsOrExports(245); + if (token() === 140 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(140); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -17393,14 +17889,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(242, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(57)) { + if (parseOptional(58)) { node.isExportEquals = true; } else { - parseExpected(78); + parseExpected(79); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -17412,6 +17908,7 @@ var ts; var typeReferenceDirectives = []; var amdDependencies = []; var amdModuleName; + var checkJsDirective = undefined; while (true) { var kind = triviaScanner.scan(); if (kind !== 2) { @@ -17422,7 +17919,11 @@ var ts; break; } } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var range = { + kind: triviaScanner.getToken(), + pos: triviaScanner.getTokenPos(), + end: triviaScanner.getTextPos(), + }; var comment = sourceText.substring(range.pos, range.end); var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { @@ -17462,20 +17963,30 @@ var ts; amdDependencies.push(amdDependency); } } + var checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; + var checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: ts.compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", true) === 0, + end: range.end, + pos: range.pos + }; + } } } sourceFile.referencedFiles = referencedFiles; sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 236 && node.moduleReference.kind === 247 - || node.kind === 237 - || node.kind === 242 + || node.kind === 237 && node.moduleReference.kind === 248 + || node.kind === 238 || node.kind === 243 + || node.kind === 244 ? node : undefined; }); @@ -17521,16 +18032,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 38: - case 54: - case 18: - case 20: - case 50: - case 16: - case 88: - case 23: - case 93: - case 98: + case 39: + case 55: + case 19: + case 21: + case 51: + case 17: + case 89: + case 24: + case 94: + case 99: return true; } return ts.tokenIsIdentifierOrKeyword(token()); @@ -17548,23 +18059,23 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(266, scanner.getTokenPos()); - parseExpected(16); - result.type = parseJSDocTopLevelType(); + var result = createNode(267, scanner.getTokenPos()); parseExpected(17); + result.type = parseJSDocTopLevelType(); + parseExpected(18); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 48) { - var unionType = createNode(270, type.pos); + if (token() === 49) { + var unionType = createNode(271, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 57) { - var optionalType = createNode(277, type.pos); + if (token() === 58) { + var optionalType = createNode(278, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -17574,21 +18085,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 20) { - var arrayType = createNode(269, type.pos); + if (token() === 21) { + var arrayType = createNode(270, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(21); + parseExpected(22); type = finishNode(arrayType); } - else if (token() === 54) { - var nullableType = createNode(272, type.pos); + else if (token() === 55) { + var nullableType = createNode(273, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 50) { - var nonNullableType = createNode(273, type.pos); + else if (token() === 51) { + var nonNullableType = createNode(274, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -17601,95 +18112,95 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 38: + case 39: return parseJSDocAllType(); - case 54: + case 55: return parseJSDocUnknownOrNullableType(); - case 18: + case 19: return parseJSDocUnionType(); - case 20: + case 21: return parseJSDocTupleType(); - case 50: + case 51: return parseJSDocNonNullableType(); - case 16: + case 17: return parseJSDocRecordType(); - case 88: + case 89: return parseJSDocFunctionType(); - case 23: + case 24: return parseJSDocVariadicType(); - case 93: - return parseJSDocConstructorType(); - case 98: - return parseJSDocThisType(); - case 118: - case 135: - case 132: - case 121: - case 136: - case 104: case 94: - case 138: - case 129: + return parseJSDocConstructorType(); + case 99: + return parseJSDocThisType(); + case 119: + case 136: case 133: + case 122: + case 137: + case 105: + case 95: + case 139: + case 130: + case 134: return parseTokenNode(); case 9: case 8: - case 100: - case 85: + case 101: + case 86: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(281); + var result = createNode(282); nextToken(); - parseExpected(55); + parseExpected(56); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(280); + var result = createNode(281); nextToken(); - parseExpected(55); + parseExpected(56); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(279); + var result = createNode(280); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(278); + var result = createNode(279); nextToken(); - parseExpected(18); + parseExpected(19); result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(19); - if (token() === 55) { + parseExpected(20); + if (token() === 56) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(145); + var parameter = createNode(146); parameter.type = parseJSDocType(); - if (parseOptional(57)) { - parameter.questionToken = createNode(57); + if (parseOptional(58)) { + parameter.questionToken = createNode(58); } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(276); + var result = createNode(277); result.name = parseSimplePropertyName(); - if (token() === 26) { + if (token() === 27) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(22)) { - if (token() === 26) { + while (parseOptional(23)) { + if (token() === 27) { result.typeArguments = parseTypeArguments(); break; } @@ -17705,7 +18216,7 @@ var ts; var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(28); + parseExpected(29); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -17716,28 +18227,28 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(142, left.pos); + var result = createNode(143, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(274); + var result = createNode(275); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(273); + var result = createNode(274); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(271); + var result = createNode(272); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(21); + parseExpected(22); return finishNode(result); } function checkForTrailingComma(list) { @@ -17747,45 +18258,45 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(270); + var result = createNode(271); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(19); + parseExpected(20); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(48)) { + while (parseOptional(49)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(267); + var result = createNode(268); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(292); + var result = createNode(293); result.literal = parseLiteralTypeNode(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 25 || - token() === 17 || - token() === 19 || - token() === 28 || - token() === 57 || - token() === 48) { - var result = createNode(268, pos); + if (token() === 26 || + token() === 18 || + token() === 20 || + token() === 29 || + token() === 58 || + token() === 49) { + var result = createNode(269, pos); return finishNode(result); } else { - var result = createNode(272, pos); + var result = createNode(273, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -17856,7 +18367,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 56: + case 57: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -17874,7 +18385,7 @@ var ts; state = 0; indent = 0; break; - case 38: + case 39: var asterisk = scanner.getTokenText(); if (state === 1 || state === 2) { state = 2; @@ -17885,7 +18396,7 @@ var ts; indent += asterisk.length; } break; - case 70: + case 71: pushComment(scanner.getTokenText()); state = 2; break; @@ -17935,7 +18446,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(282, start); + var result = createNode(283, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -17946,8 +18457,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 56); - var atToken = createNode(56, scanner.getTokenPos()); + ts.Debug.assert(token() === 57); + var atToken = createNode(57, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -17992,7 +18503,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1; + var state = 0; var margin; function pushComment(text) { if (!margin) { @@ -18001,7 +18512,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 56 && token() !== 1) { + while (token() !== 57 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -18010,7 +18521,7 @@ var ts; } indent = 0; break; - case 56: + case 57: break; case 5: if (state === 2) { @@ -18024,7 +18535,7 @@ var ts; indent += whitespace.length; } break; - case 38: + case 39: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -18035,7 +18546,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 56) { + if (token() === 57) { break; } nextJSDocToken(); @@ -18045,7 +18556,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -18063,7 +18574,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 16) { + if (token() !== 17) { return undefined; } return parseJSDocTypeExpression(); @@ -18074,14 +18585,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(20)) { + if (parseOptionalToken(21)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(57)) { + if (parseOptionalToken(58)) { parseExpression(); } - parseExpected(21); + parseExpected(22); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -18100,7 +18611,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(285, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -18111,20 +18622,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 286; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 287; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(287, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -18139,7 +18650,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(290, atToken.pos); + var result = createNode(291, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -18148,7 +18659,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -18157,15 +18668,15 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(289, atToken.pos); + var typedefTag = createNode(290, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; while (true) { - if (rightNode.kind === 70 || !rightNode.body) { - typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + if (rightNode.kind === 71 || !rightNode.body) { + typedefTag.name = rightNode.kind === 71 ? rightNode : rightNode.name; break; } rightNode = rightNode.body; @@ -18174,9 +18685,9 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 276) { + if (typeExpression.type.kind === 277) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 70) { + if (jsDocTypeReference.name.kind === 71) { var name = jsDocTypeReference.name; if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -18192,7 +18703,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(292, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -18200,7 +18711,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 56: + case 57: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -18214,14 +18725,15 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 38: + case 39: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 70: + case 71: canParseTag = false; + break; case 1: break; } @@ -18232,8 +18744,8 @@ var ts; function parseJSDocTypeNameWithNamespace(flags) { var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(232, pos); + if (typeNameOrNamespaceName && parseOptional(23)) { + var jsDocNamespaceNode = createNode(233, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -18246,8 +18758,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 56); - var atToken = createNode(56, scanner.getStartPos()); + ts.Debug.assert(token() === 57); + var atToken = createNode(57, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -18277,7 +18789,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 288; })) { + if (ts.forEach(tags, function (t) { return t.kind === 289; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -18288,11 +18800,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(144, name.pos); + var typeParameter = createNode(145, name.pos); typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 25) { + if (token() === 26) { nextJSDocToken(); skipWhitespace(); } @@ -18300,7 +18812,7 @@ var ts; break; } } - var result = createNode(288, atToken.pos); + var result = createNode(289, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -18321,7 +18833,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(70, pos); + var result = createNode(71, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -18402,7 +18914,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 70: + case 71: return true; } return false; @@ -18629,16 +19141,16 @@ var ts; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { - if (node.kind === 229 || node.kind === 230) { + if (node.kind === 230 || node.kind === 231) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 238 || node.kind === 237) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 233) { + else if (node.kind === 234) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -18654,11 +19166,11 @@ var ts; }); return state_1; } - else if (node.kind === 232) { + else if (node.kind === 233) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } - else if (node.kind === 70 && node.isInJSDocNamespace) { + else if (node.kind === 71 && node.isInJSDocNamespace) { return 0; } else { @@ -18748,7 +19260,7 @@ var ts; } return bindSourceFile; function bindInStrictMode(file, opts) { - if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !ts.isDeclarationFile(file)) { return true; } else { @@ -18775,7 +19287,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 233)) { symbol.valueDeclaration = node; } } @@ -18785,7 +19297,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 143) { + if (node.name.kind === 144) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -18796,49 +19308,50 @@ var ts; return node.name.text; } switch (node.kind) { - case 151: + case 152: return "__constructor"; - case 159: - case 154: - return "__call"; case 160: case 155: - return "__new"; + return "__call"; + case 161: case 156: + return "__new"; + case 157: return "__index"; - case 243: + case 244: return "__export"; - case 242: + case 243: return node.isExportEquals ? "export=" : "default"; - case 193: + case 194: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; case 1: case 4: + case 5: return node.left.name.text; case 3: return node.left.expression.name.text; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 227: case 228: + case 229: return ts.hasModifier(node, 512) ? "default" : undefined; - case 278: + case 279: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 145: - ts.Debug.assert(node.parent.kind === 278); + case 146: + ts.Debug.assert(node.parent.kind === 279); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 289: + case 290: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 207) { + if (parentNode && parentNode.kind === 208) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70) { + if (nameIdentifier.kind === 71) { nameFromParentNode = nameIdentifier.text; } } @@ -18882,7 +19395,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 243 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -18902,7 +19415,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { + if (node.kind === 246 || (node.kind === 237 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -18910,9 +19423,9 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 289 && + var isJSDocTypedefInJSDocNamespace = node.kind === 290 && node.name && - node.name.kind === 70 && + node.name.kind === 71 && node.name.isInJSDocNamespace; if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | @@ -18971,7 +19484,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 264) { + if (node.kind === 265) { node.flags |= emitFlags; } if (isIIFE) { @@ -19047,66 +19560,72 @@ var ts; return; } switch (node.kind) { - case 212: + case 213: bindWhileStatement(node); break; - case 211: + case 212: bindDoStatement(node); break; - case 213: + case 214: bindForStatement(node); break; - case 214: case 215: + case 216: bindForInOrForOfStatement(node); break; - case 210: + case 211: bindIfStatement(node); break; - case 218: - case 222: + case 219: + case 223: bindReturnOrThrow(node); break; + case 218: case 217: - case 216: bindBreakOrContinueStatement(node); break; - case 223: + case 224: bindTryStatement(node); break; - case 220: + case 221: bindSwitchStatement(node); break; - case 234: + case 235: bindCaseBlock(node); break; - case 256: + case 257: bindCaseClause(node); break; - case 221: + case 222: bindLabeledStatement(node); break; - case 191: + case 192: bindPrefixUnaryExpressionFlow(node); break; - case 192: + case 193: bindPostfixUnaryExpressionFlow(node); break; - case 193: + case 194: bindBinaryExpressionFlow(node); break; - case 187: + case 188: bindDeleteExpressionFlow(node); break; - case 194: + case 195: bindConditionalExpressionFlow(node); break; - case 225: + case 226: bindVariableDeclarationFlow(node); break; - case 180: + case 181: bindCallExpressionFlow(node); break; + case 283: + bindJSDocComment(node); + break; + case 290: + bindJSDocTypedefTag(node); + break; default: bindEachChild(node); break; @@ -19114,25 +19633,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 70: - case 98: - case 178: + case 71: + case 99: + case 179: return isNarrowableReference(expr); - case 180: + case 181: return hasNarrowableArgument(expr); - case 184: + case 185: return isNarrowingExpression(expr.expression); - case 193: + case 194: return isNarrowingBinaryExpression(expr); - case 191: - return expr.operator === 50 && isNarrowingExpression(expr.operand); + case 192: + return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 70 || - expr.kind === 98 || - expr.kind === 178 && isNarrowableReference(expr.expression); + return expr.kind === 71 || + expr.kind === 99 || + expr.kind === 97 || + expr.kind === 179 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -19143,41 +19663,41 @@ var ts; } } } - if (expr.expression.kind === 178 && + if (expr.expression.kind === 179 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 189 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 57: + case 58: return isNarrowableReference(expr.left); - case 31: case 32: case 33: case 34: + case 35: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 92: + case 93: return isNarrowableOperand(expr.left); - case 25: + case 26: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 184: + case 185: return isNarrowableOperand(expr.expression); - case 193: + case 194: switch (expr.operatorToken.kind) { - case 57: + case 58: return isNarrowableOperand(expr.left); - case 25: + case 26: return isNarrowableOperand(expr.right); } } @@ -19211,8 +19731,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 100 && flags & 64 || - expression.kind === 85 && flags & 32) { + if (expression.kind === 101 && flags & 64 || + expression.kind === 86 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -19267,34 +19787,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 210: - case 212: case 211: - return parent.expression === node; case 213: - case 194: + case 212: + return parent.expression === node; + case 214: + case 195: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 184) { + if (node.kind === 185) { node = node.expression; } - else if (node.kind === 191 && node.operator === 50) { + else if (node.kind === 192 && node.operator === 51) { node = node.operand; } else { - return node.kind === 193 && (node.operatorToken.kind === 52 || - node.operatorToken.kind === 53); + return node.kind === 194 && (node.operatorToken.kind === 53 || + node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 184 || - node.parent.kind === 191 && - node.parent.operator === 50) { + while (node.parent.kind === 185 || + node.parent.kind === 192 && + node.parent.operator === 51) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -19335,7 +19855,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 221 + var enclosingLabeledStatement = node.parent.kind === 222 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -19367,10 +19887,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; + if (node.kind === 216) { + bind(node.awaitModifier); + } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 226) { + if (node.initializer.kind !== 227) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -19392,7 +19915,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 218) { + if (node.kind === 219) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -19412,7 +19935,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 217 ? breakTarget : continueTarget; + var flowLabel = node.kind === 218 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -19475,7 +19998,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 258; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -19540,13 +20063,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 211) { + if (!node.statement || node.statement.kind !== 212) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 193 && node.operatorToken.kind === 57) { + if (node.kind === 194 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -19557,10 +20080,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 197) { + if (e.kind === 198) { bindAssignmentTargetFlow(e.expression); } else { @@ -19568,16 +20091,16 @@ var ts; } } } - else if (node.kind === 177) { + else if (node.kind === 178) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 260) { + if (p.kind === 261) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 261) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 262) { + else if (p.kind === 263) { bindAssignmentTargetFlow(p.expression); } } @@ -19585,7 +20108,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 52) { + if (node.operatorToken.kind === 53) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -19596,7 +20119,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 50) { + if (node.operator === 51) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -19606,20 +20129,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 52 || operator === 53) { + if (operator === 53 || operator === 54) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -19633,7 +20156,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 179) { + if (operator === 58 && node.left.kind === 180) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19644,7 +20167,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 178) { + if (node.expression.kind === 179) { bindAssignmentTargetFlow(node.expression); } } @@ -19677,16 +20200,31 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { + if (node.initializer || node.parent.parent.kind === 215 || node.parent.parent.kind === 216) { bindInitializedVariableFlow(node); } } + function bindJSDocComment(node) { + ts.forEachChild(node, function (n) { + if (n.kind !== 290) { + bind(n); + } + }); + } + function bindJSDocTypedefTag(node) { + ts.forEachChild(node, function (n) { + if (node.fullName && n === node.name && node.fullName.kind !== 71) { + return; + } + bind(n); + }); + } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 184) { + while (expr.kind === 185) { expr = expr.expression; } - if (expr.kind === 185 || expr.kind === 186) { + if (expr.kind === 186 || expr.kind === 187) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -19694,7 +20232,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 178) { + if (node.expression.kind === 179) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -19703,53 +20241,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 198: - case 228: - case 231: - case 177: - case 162: - case 291: - case 274: - case 253: - return 1; + case 199: case 229: - return 1 | 64; - case 278: case 232: + case 178: + case 163: + case 292: + case 275: + case 254: + return 1; case 230: - case 171: + return 1 | 64; + case 279: + case 233: + case 231: + case 172: return 1 | 32; - case 264: + case 265: return 1 | 4 | 32; - case 150: + case 151: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 151: - case 227: - case 149: case 152: + case 228: + case 150: case 153: case 154: case 155: case 156: - case 159: + case 157: case 160: + case 161: return 1 | 4 | 32 | 8; - case 185: case 186: + case 187: return 1 | 4 | 32 | 8 | 16; - case 233: + case 234: return 4; - case 148: + case 149: return node.initializer ? 4 : 0; - case 259: - case 213: + case 260: case 214: case 215: - case 234: + case 216: + case 235: return 2; - case 206: + case 207: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -19765,38 +20303,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 232: + case 233: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 264: + case 265: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 198: - case 228: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 231: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 162: - case 177: + case 199: case 229: - case 274: - case 291: - case 253: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 232: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 163: + case 178: + case 230: + case 275: + case 292: + case 254: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 159: case 160: - case 154: + case 161: case 155: case 156: - case 150: - case 149: + case 157: case 151: + case 150: case 152: case 153: - case 227: - case 185: + case 154: + case 228: case 186: - case 278: - case 230: - case 171: + case 187: + case 279: + case 231: + case 172: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -19811,11 +20349,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 264 ? node : node.body; - if (body && (body.kind === 264 || body.kind === 233)) { + var body = node.kind === 265 ? node : node.body; + if (body && (body.kind === 265 || body.kind === 234)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 243 || stat.kind === 242) { + if (stat.kind === 244 || stat.kind === 243) { return true; } } @@ -19898,11 +20436,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 || prop.name.kind !== 70) { + if (prop.kind === 263 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 + var currentKind = prop.kind === 261 || prop.kind === 262 || prop.kind === 151 ? 1 : 2; var existingKind = seen.get(identifier.text); @@ -19930,10 +20468,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 232: + case 233: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 264: + case 265: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -19951,8 +20489,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 107 && - node.originalKeywordKind <= 115 && + node.originalKeywordKind >= 108 && + node.originalKeywordKind <= 116 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -19980,17 +20518,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 70) { + if (inStrictMode && node.expression.kind === 71) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 70 && + return node.kind === 71 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 70) { + if (name && name.kind === 71) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -20023,8 +20561,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 264 && - blockScopeContainer.kind !== 232 && + if (blockScopeContainer.kind !== 265 && + blockScopeContainer.kind !== 233 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -20032,7 +20570,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.isOctalLiteral) { + if (inStrictMode && node.numericLiteralFlags & 4) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -20043,7 +20581,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -20066,8 +20604,11 @@ var ts; } node.parent = parent; var saveInStrictMode = inStrictMode; + if (ts.isInJavaScriptFile(node)) { + bindJSDocTypedefTagIfAny(node); + } bindWorker(node); - if (node.kind > 141) { + if (node.kind > 142) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -20084,6 +20625,26 @@ var ts; } inStrictMode = saveInStrictMode; } + function bindJSDocTypedefTagIfAny(node) { + if (!node.jsDoc) { + return; + } + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + if (!jsDoc.tags) { + continue; + } + for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) { + var tag = _c[_b]; + if (tag.kind === 290) { + var savedParent = parent; + parent = jsDoc; + bind(tag); + parent = savedParent; + } + } + } + } function updateStrictModeStatementList(statements) { if (!inStrictMode) { for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { @@ -20104,91 +20665,92 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 70: + case 71: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 289) { + while (parentNode && parentNode.kind !== 290) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } - case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { + case 99: + if (currentFlow && (ts.isExpression(node) || parent.kind === 262)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 178: + case 179: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 193: - if (ts.isInJavaScriptFile(node)) { - var specialKind = ts.getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case 1: - bindExportsPropertyAssignment(node); - break; - case 2: - bindModuleExportsAssignment(node); - break; - case 3: - bindPrototypePropertyAssignment(node); - break; - case 4: - bindThisPropertyAssignment(node); - break; - case 0: - break; - default: - ts.Debug.fail("Unknown special property assignment kind"); - } + case 194: + var specialKind = ts.getSpecialPropertyAssignmentKind(node); + switch (specialKind) { + case 1: + bindExportsPropertyAssignment(node); + break; + case 2: + bindModuleExportsAssignment(node); + break; + case 3: + bindPrototypePropertyAssignment(node); + break; + case 4: + bindThisPropertyAssignment(node); + break; + case 5: + bindStaticPropertyAssignment(node); + break; + case 0: + break; + default: + ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 259: + case 260: return checkStrictModeCatchClause(node); - case 187: + case 188: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 192: + case 193: return checkStrictModePostfixUnaryExpression(node); - case 191: + case 192: return checkStrictModePrefixUnaryExpression(node); - case 219: + case 220: return checkStrictModeWithStatement(node); - case 168: + case 169: seenThisKeyword = true; return; - case 157: + case 158: return checkTypePredicate(node); - case 144: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 145: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 146: return bindParameter(node); - case 225: - case 175: + case 226: + case 176: return bindVariableDeclarationOrBindingElement(node); + case 149: case 148: - case 147: - case 275: + case 276: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); - case 290: + case 291: return bindJSDocProperty(node); - case 260: case 261: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 263: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 262: - case 254: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 264: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 263: + case 255: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 177 && - root.parent.kind === 193 && - root.parent.operatorToken.kind === 57 && + if (root.kind === 178 && + root.parent.kind === 194 && + root.parent.operatorToken.kind === 58 && root.parent.left === root) { hasRest = true; break; @@ -20196,91 +20758,91 @@ var ts; root = root.parent; } return; - case 154: case 155: case 156: + case 157: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 150: - case 149: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 227: - return bindFunctionDeclaration(node); case 151: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 150: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 228: + return bindFunctionDeclaration(node); case 152: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 153: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 154: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 159: case 160: - case 278: + case 161: + case 279: return bindFunctionOrConstructorType(node); - case 162: - case 171: - case 291: - case 274: + case 163: + case 172: + case 292: + case 275: return bindAnonymousDeclaration(node, 2048, "__type"); - case 177: + case 178: return bindObjectLiteralExpression(node); - case 185: case 186: + case 187: return bindFunctionExpression(node); - case 180: + case 181: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 198: - case 228: + case 199: + case 229: inStrictMode = true; return bindClassLikeDeclaration(node); - case 229: + case 230: return bindBlockScopedDeclaration(node, 64, 792968); - case 289: - if (!node.fullName || node.fullName.kind === 70) { + case 290: + if (!node.fullName || node.fullName.kind === 71) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 230: - return bindBlockScopedDeclaration(node, 524288, 793064); case 231: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 232: + return bindEnumDeclaration(node); + case 233: return bindModuleDeclaration(node); - case 253: + case 254: return bindJsxAttributes(node); - case 252: + case 253: return bindJsxAttribute(node, 4, 0); - case 236: - case 239: - case 241: - case 245: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 235: - return bindNamespaceExportDeclaration(node); - case 238: - return bindImportClause(node); - case 243: - return bindExportDeclaration(node); + case 237: + case 240: case 242: + case 246: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 236: + return bindNamespaceExportDeclaration(node); + case 239: + return bindImportClause(node); + case 244: + return bindExportDeclaration(node); + case 243: return bindExportAssignment(node); - case 264: + case 265: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 206: + case 207: if (!ts.isFunctionLike(node.parent)) { return; } - case 233: + case 234: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 70) { + if (parameterName && parameterName.kind === 71) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 168) { + if (parameterName && parameterName.kind === 169) { seenThisKeyword = true; } bind(type); @@ -20299,7 +20861,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 243 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -20309,7 +20871,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 264) { + if (node.parent.kind !== 265) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -20352,24 +20914,56 @@ var ts; setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); } + function isExportsOrModuleExportsOrAlias(node) { + return ts.isExportsIdentifier(node) || + ts.isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + function isNameOfExportsOrModuleExportsAliasDeclaration(node) { + if (node.kind === 71) { + var symbol = lookupSymbolForName(node.text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === 226) { + var declaration = symbol.valueDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + function isExportsOrModuleExportsOrAliasOrAssignemnt(node) { + return isExportsOrModuleExportsOrAlias(node) || + (ts.isAssignmentExpression(node, true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } function bindModuleExportsAssignment(node) { + var assignedExpression = ts.getRightMostAssignedExpression(node.right); + if (ts.isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + setCommonJsModuleIndicator(node); + return; + } setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, 4 | 7340032 | 512, 0); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 227 || container.kind === 185) { - container.symbol.members = container.symbol.members || ts.createMap(); - declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); - } - else if (container.kind === 151) { - var saveContainer = container; - container = container.parent; - var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); - if (symbol) { - symbol.isReplaceableByMethod = true; - } - container = saveContainer; + var container = ts.getThisContainer(node, false); + switch (container.kind) { + case 228: + case 186: + container.symbol.members = container.symbol.members || ts.createMap(); + declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); + break; + case 152: + case 149: + case 151: + case 153: + case 154: + var containingClass = container.parent; + var symbol = declareSymbol(ts.hasModifier(container, 32) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, 4, 0); + if (symbol) { + symbol.isReplaceableByMethod = true; + } + break; } } function bindPrototypePropertyAssignment(node) { @@ -20379,14 +20973,35 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals.get(constructorFunction.text); - if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, true); + } + function bindStaticPropertyAssignment(node) { + var leftSideOfAssignment = node.left; + var target = leftSideOfAssignment.expression; + leftSideOfAssignment.parent = node; + target.parent = leftSideOfAssignment; + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, false); + } + } + function lookupSymbolForName(name) { + return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name)); + } + function bindPropertyAssignment(functionName, propertyAccessExpression, isPrototypeProperty) { + var targetSymbol = lookupSymbolForName(functionName); + if (targetSymbol && ts.isDeclarationOfFunctionOrClassExpression(targetSymbol)) { + targetSymbol = targetSymbol.valueDeclaration.initializer.symbol; + } + if (!targetSymbol || !(targetSymbol.flags & (16 | 32))) { return; } - if (!funcSymbol.members) { - funcSymbol.members = ts.createMap(); - } - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 0); + var symbolTable = isPrototypeProperty ? + (targetSymbol.members || (targetSymbol.members = ts.createMap())) : + (targetSymbol.exports || (targetSymbol.exports = ts.createMap())); + declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, 4, 0); } function bindCallExpression(node) { if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) { @@ -20394,7 +21009,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 228) { + if (node.kind === 229) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -20454,7 +21069,7 @@ var ts; } function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -20469,7 +21084,7 @@ var ts; } function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -20482,7 +21097,7 @@ var ts; } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -20505,15 +21120,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || - node.kind === 228 || - (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 209) || + node.kind === 229 || + (node.kind === 233 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 207 || + (node.kind !== 208 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -20527,56 +21142,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 180: - return computeCallExpression(node, subtreeFlags); case 181: + return computeCallExpression(node, subtreeFlags); + case 182: return computeNewExpression(node, subtreeFlags); - case 232: + case 233: return computeModuleDeclaration(node, subtreeFlags); - case 184: - return computeParenthesizedExpression(node, subtreeFlags); - case 193: - return computeBinaryExpression(node, subtreeFlags); - case 209: - return computeExpressionStatement(node, subtreeFlags); - case 145: - return computeParameter(node, subtreeFlags); - case 186: - return computeArrowFunction(node, subtreeFlags); case 185: + return computeParenthesizedExpression(node, subtreeFlags); + case 194: + return computeBinaryExpression(node, subtreeFlags); + case 210: + return computeExpressionStatement(node, subtreeFlags); + case 146: + return computeParameter(node, subtreeFlags); + case 187: + return computeArrowFunction(node, subtreeFlags); + case 186: return computeFunctionExpression(node, subtreeFlags); - case 227: - return computeFunctionDeclaration(node, subtreeFlags); - case 225: - return computeVariableDeclaration(node, subtreeFlags); - case 226: - return computeVariableDeclarationList(node, subtreeFlags); - case 207: - return computeVariableStatement(node, subtreeFlags); - case 221: - return computeLabeledStatement(node, subtreeFlags); case 228: + return computeFunctionDeclaration(node, subtreeFlags); + case 226: + return computeVariableDeclaration(node, subtreeFlags); + case 227: + return computeVariableDeclarationList(node, subtreeFlags); + case 208: + return computeVariableStatement(node, subtreeFlags); + case 222: + return computeLabeledStatement(node, subtreeFlags); + case 229: return computeClassDeclaration(node, subtreeFlags); - case 198: + case 199: return computeClassExpression(node, subtreeFlags); - case 258: - return computeHeritageClause(node, subtreeFlags); case 259: + return computeHeritageClause(node, subtreeFlags); + case 260: return computeCatchClause(node, subtreeFlags); - case 200: + case 201: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 151: - return computeConstructor(node, subtreeFlags); - case 148: - return computePropertyDeclaration(node, subtreeFlags); - case 150: - return computeMethod(node, subtreeFlags); case 152: + return computeConstructor(node, subtreeFlags); + case 149: + return computePropertyDeclaration(node, subtreeFlags); + case 151: + return computeMethod(node, subtreeFlags); case 153: + case 154: return computeAccessor(node, subtreeFlags); - case 236: + case 237: return computeImportEquals(node, subtreeFlags); - case 178: + case 179: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -20599,13 +21214,13 @@ var ts; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 96: + case 97: return true; - case 178: case 179: + case 180: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 96; + return expressionKind === 97; } return false; } @@ -20624,14 +21239,14 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 177) { + if (operatorTokenKind === 58 && leftKind === 178) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 176) { + else if (operatorTokenKind === 58 && leftKind === 177) { transformFlags |= 192 | 3072; } - else if (operatorTokenKind === 39 - || operatorTokenKind === 61) { + else if (operatorTokenKind === 40 + || operatorTokenKind === 62) { transformFlags |= 32; } node.transformFlags = transformFlags | 536870912; @@ -20666,8 +21281,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 201 - || expressionKind === 183) { + if (expressionKind === 202 + || expressionKind === 184) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -20710,10 +21325,10 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 84: + case 85: transformFlags |= 192; break; - case 107: + case 108: transformFlags |= 3; break; default: @@ -20764,9 +21379,9 @@ var ts; transformFlags |= 8; } if (ts.hasModifier(node, 256)) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; @@ -20809,7 +21424,7 @@ var ts; transformFlags |= 3; } if (modifierFlags & 256) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } if (subtreeFlags & 1048576) { transformFlags |= 8; @@ -20817,7 +21432,7 @@ var ts; if (subtreeFlags & 163840) { transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } } @@ -20832,7 +21447,7 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } if (subtreeFlags & 1048576) { transformFlags |= 8; @@ -20840,7 +21455,7 @@ var ts; if (subtreeFlags & 163840) { transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; @@ -20869,7 +21484,7 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 96) { + if (expressionKind === 97) { transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; @@ -20952,63 +21567,76 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536872257; switch (kind) { - case 119: - case 190: - transformFlags |= 16; + case 120: + case 191: + transformFlags |= 8 | 16; break; - case 113: - case 111: + case 114: case 112: - case 116: - case 123: - case 75: - case 231: - case 263: - case 183: - case 201: + case 113: + case 117: + case 124: + case 76: + case 232: + case 264: + case 184: case 202: - case 130: + case 203: + case 131: transformFlags |= 3; break; - case 248: case 249: case 250: - case 10: case 251: + case 10: case 252: case 253: case 254: case 255: + case 256: transformFlags |= 4; break; - case 215: - transformFlags |= 8; - case 12: case 13: case 14: case 15: - case 195: - case 182: - case 261: - case 114: - case 203: + case 16: + case 196: + case 183: + case 262: + case 115: + case 204: transformFlags |= 192; break; - case 196: - transformFlags |= 192 | 16777216; + case 9: + if (node.hasExtendedUnicodeEscape) { + transformFlags |= 192; + } break; - case 118: - case 132: - case 129: + case 8: + if (node.numericLiteralFlags & 48) { + transformFlags |= 192; + } + break; + case 216: + if (node.awaitModifier) { + transformFlags |= 8; + } + transformFlags |= 192; + break; + case 197: + transformFlags |= 8 | 192 | 16777216; + break; + case 119: case 133: - case 135: - case 121: + case 130: + case 134: case 136: - case 104: - case 144: - case 147: - case 149: - case 154: + case 122: + case 137: + case 105: + case 145: + case 148: + case 150: case 155: case 156: case 157: @@ -21022,55 +21650,56 @@ var ts; case 165: case 166: case 167: - case 229: - case 230: case 168: + case 230: + case 231: case 169: case 170: case 171: case 172: + case 173: transformFlags = 3; excludeFlags = -3; break; - case 143: + case 144: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 197: + case 198: transformFlags |= 192 | 524288; break; - case 262: + case 263: transformFlags |= 8 | 1048576; break; - case 96: + case 97: transformFlags |= 192; break; - case 98: + case 99: transformFlags |= 16384; break; - case 173: + case 174: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 175: + case 176: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 146: + case 147: transformFlags |= 3 | 4096; break; - case 177: + case 178: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -21082,29 +21711,29 @@ var ts; transformFlags |= 8; } break; - case 176: - case 181: + case 177: + case 182: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 211: case 212: case 213: case 214: + case 215: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 264: + case 265: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 218: - case 216: + case 219: case 217: + case 218: transformFlags |= 33554432; break; } @@ -21112,57 +21741,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 157 && kind <= 172) { + if (kind >= 158 && kind <= 173) { return -3; } switch (kind) { - case 180: case 181: - case 176: + case 182: + case 177: return 537396545; - case 232: + case 233: return 574674241; - case 145: + case 146: return 536872257; - case 186: + case 187: return 601249089; - case 185: - case 227: - return 601281857; - case 226: - return 546309441; + case 186: case 228: - case 198: + return 601281857; + case 227: + return 546309441; + case 229: + case 199: return 539358529; - case 151: - return 601015617; - case 150: case 152: - case 153: return 601015617; - case 118: - case 132: - case 129: - case 135: - case 133: - case 121: - case 136: - case 104: - case 144: - case 147: - case 149: + case 151: + case 153: case 154: + return 601015617; + case 119: + case 133: + case 130: + case 136: + case 134: + case 122: + case 137: + case 105: + case 145: + case 148: + case 150: case 155: case 156: - case 229: + case 157: case 230: + case 231: return -3; - case 177: + case 178: return 540087617; - case 259: + case 260: return 537920833; - case 173: case 174: + case 175: return 537396545; default: return 536872257; @@ -21202,15 +21831,19 @@ var ts; var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; var symbolCount = 0; + var symbolInstantiationDepth = 0; var emptyArray = []; var emptySymbols = ts.createMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; + var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); var noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; - var strictNullChecks = compilerOptions.strictNullChecks; + var strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks; + var noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny; + var noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; var emitResolver = createResolver(); + var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; var argumentsSymbol = createSymbol(4, "arguments"); @@ -21222,10 +21855,18 @@ var ts; isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, + getMergedSymbol: getMergedSymbol, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, - getSymbolsOfParameterPropertyDeclaration: getSymbolsOfParameterPropertyDeclaration, + getTypeOfSymbolAtLocation: function (symbol, location) { + location = ts.getParseTreeNode(location); + return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + }, + getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { + parameter = ts.getParseTreeNode(parameter, ts.isParameter); + ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + return getSymbolsOfParameterPropertyDeclaration(parameter, parameterName); + }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -21233,37 +21874,103 @@ var ts; getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, - getTypeFromTypeNode: getTypeFromTypeNode, + getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, + getWidenedType: getWidenedType, + getTypeFromTypeNode: function (node) { + node = ts.getParseTreeNode(node, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : unknownType; + }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, - getTypeAtLocation: getTypeOfNode, - getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, - signatureToString: signatureToString, - typeToString: typeToString, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, + getSymbolsInScope: function (location, meaning) { + location = ts.getParseTreeNode(location); + return location ? getSymbolsInScope(location, meaning) : []; + }, + getSymbolAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getSymbolAtLocation(node) : undefined; + }, + getShorthandAssignmentValueSymbol: function (node) { + node = ts.getParseTreeNode(node); + return node ? getShorthandAssignmentValueSymbol(node) : undefined; + }, + getExportSpecifierLocalTargetSymbol: function (node) { + node = ts.getParseTreeNode(node, ts.isExportSpecifier); + return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; + }, + getTypeAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getTypeOfNode(node) : unknownType; + }, + getPropertySymbolOfDestructuringAssignment: function (location) { + location = ts.getParseTreeNode(location, ts.isIdentifier); + return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; + }, + signatureToString: function (signature, enclosingDeclaration, flags, kind) { + return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind); + }, + typeToString: function (type, enclosingDeclaration, flags) { + return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags); + }, getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, + symbolToString: function (symbol, enclosingDeclaration, meaning) { + return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning); + }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: getContextualType, + getContextualType: function (node) { + node = ts.getParseTreeNode(node, ts.isExpression); + return node ? getContextualType(node) : undefined; + }, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, + getResolvedSignature: function (node, candidatesOutArray) { + node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + return node ? getResolvedSignature(node, candidatesOutArray) : undefined; + }, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, + isValidPropertyAccess: function (node, propertyName) { + node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedName); + return node ? isValidPropertyAccess(node, propertyName) : false; + }, + getSignatureFromDeclaration: function (declaration) { + declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + return declaration ? getSignatureFromDeclaration(declaration) : undefined; + }, + isImplementationOfOverload: function (node) { + node = ts.getParseTreeNode(node, ts.isFunctionLike); + return node ? isImplementationOfOverload(node) : undefined; + }, + getImmediateAliasedSymbol: function (symbol) { + ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.immediateTarget) { + var node = getDeclarationOfAliasSymbol(symbol); + ts.Debug.assert(!!node); + links.immediateTarget = getTargetOfAliasDeclaration(node, true); + } + return links.immediateTarget; + }, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, + getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { + node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; + }, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter, + isOptionalParameter: function (node) { + node = ts.getParseTreeNode(node, ts.isParameter); + return node ? isOptionalParameter(node) : false; + }, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); @@ -21311,11 +22018,9 @@ var ts; var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, undefined, 0, false, false); var enumNumberIndexInfo = createIndexInfo(stringType, true); + var jsObjectLiteralIndexInfo = createIndexInfo(anyType, false); var globals = ts.createMap(); var patternAmbientModules; - var getGlobalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var tryGetGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -21324,26 +22029,26 @@ var ts; var globalNumberType; var globalBooleanType; var globalRegExpType; + var globalThisType; var anyArrayType; var autoArrayType; var anyReadonlyArrayType; - var getGlobalTemplateStringsArrayType; - var getGlobalESSymbolType; - var getGlobalIterableType; - var getGlobalIteratorType; - var getGlobalIterableIteratorType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var jsxElementClassType; + var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolType; + var deferredGlobalTypedPropertyDescriptorType; + var deferredGlobalPromiseType; + var deferredGlobalPromiseConstructorSymbol; + var deferredGlobalPromiseConstructorLikeType; + var deferredGlobalIterableType; + var deferredGlobalIteratorType; + var deferredGlobalIterableIteratorType; + var deferredGlobalAsyncIterableType; + var deferredGlobalAsyncIteratorType; + var deferredGlobalAsyncIterableIteratorType; + var deferredGlobalTemplateStringsArrayType; + var deferredJsxElementClassType; + var deferredJsxElementType; + var deferredJsxStatelessElementType; var deferredNodes; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; @@ -21453,15 +22158,19 @@ var ts; "undefined": undefinedType }); var typeofType = createTypeofType(); - var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; + var _jsxElementPropertiesName; + var _hasComputedJsxElementPropertiesName = false; + var _jsxElementChildrenPropertyName; + var _hasComputedJsxElementChildrenPropertyName = false; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", ElementClass: "ElementClass", ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + ElementChildrenAttributeNameContainer: "ElementChildrenAttribute", Element: "Element", IntrinsicAttributes: "IntrinsicAttributes", IntrinsicClassAttributes: "IntrinsicClassAttributes" @@ -21479,12 +22188,18 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["SkipContextSensitive"] = 1] = "SkipContextSensitive"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createMap(); builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { - if (_jsxNamespace === undefined) { + if (!_jsxNamespace) { _jsxNamespace = "React"; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); @@ -21514,6 +22229,9 @@ var ts; symbol.checkFlags = 0; return symbol; } + function isTransientSymbol(symbol) { + return (symbol.flags & 134217728) !== 0; + } function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2) @@ -21580,7 +22298,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { + (target.valueDeclaration.kind === 233 && source.valueDeclaration.kind !== 233))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -21597,7 +22315,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 || source.flags & 2 @@ -21683,7 +22401,7 @@ var ts; return symbol.flags & 134217728 ? symbol.checkFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 265 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -21720,77 +22438,76 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrInstanceProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 175) { - var errorBindingElement = ts.getAncestor(usage, 175); + if (declaration.kind === 176) { + var errorBindingElement = ts.getAncestor(usage, 176); if (errorBindingElement) { - return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 226), usage); } - else if (declaration.kind === 225) { + else if (declaration.kind === 226) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } + if (usage.parent.kind === 246) { + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); - var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); - return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); + return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 207: - case 213: - case 215: + case 208: + case 214: + case 216: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 214: case 215: + case 216: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { - var current = usage; - while (current) { + function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { + return !!ts.findAncestor(usage, function (current) { if (current === container) { - return false; + return "quit"; } if (ts.isFunctionLike(current)) { return true; } - var initializerOfInstanceProperty = current.parent && - current.parent.kind === 148 && - (ts.getModifierFlags(current.parent) & 32) === 0 && + var initializerOfProperty = current.parent && + current.parent.kind === 149 && current.parent.initializer === current; - if (initializerOfInstanceProperty) { - return !isDeclarationInstanceProperty; + if (initializerOfProperty) { + if (ts.getModifierFlags(current.parent) & 32) { + if (declaration.kind === 151) { + return true; + } + } + else { + var isDeclarationInstanceProperty = declaration.kind === 149 && !(ts.getModifierFlags(declaration) & 32); + if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { + return true; + } + } } - current = current.parent; - } - return false; - } - function getAncestorBindingPattern(node) { - while (node) { - if (ts.isBindingPattern(node)) { - return node; - } - node = node.parent; - } - return undefined; + }); } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { @@ -21805,18 +22522,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 & 793064 && lastLocation.kind !== 282) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 283) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 145 || - lastLocation.kind === 144 + lastLocation.kind === 146 || + lastLocation.kind === 145 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 145 || + lastLocation.kind === 146 || (lastLocation === location.type && - result.valueDeclaration.kind === 145); + result.valueDeclaration.kind === 146); } } if (useResult) { @@ -21828,13 +22545,13 @@ var ts; } } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 232: + case 233: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 264 || ts.isAmbientModule(location)) { + if (location.kind === 265 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -21845,7 +22562,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 8388608 && - ts.getDeclarationOfKind(moduleExport, 245)) { + ts.getDeclarationOfKind(moduleExport, 246)) { break; } } @@ -21853,13 +22570,13 @@ var ts; break loop; } break; - case 231: + case 232: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 149: case 148: - case 147: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -21869,9 +22586,9 @@ var ts; } } break; - case 228: - case 198: case 229: + case 199: + case 230: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -21883,7 +22600,7 @@ var ts; } break loop; } - if (location.kind === 198 && meaning & 32) { + if (location.kind === 199 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -21891,28 +22608,28 @@ var ts; } } break; - case 143: + case 144: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 229) { + if (ts.isClassLike(grandparent) || grandparent.kind === 230) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 227: - case 186: + case 154: + case 228: + case 187: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 185: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -21925,8 +22642,8 @@ var ts; } } break; - case 146: - if (location.parent && location.parent.kind === 145) { + case 147: + if (location.parent && location.parent.kind === 146) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -21949,7 +22666,8 @@ var ts; !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); } } @@ -21961,15 +22679,16 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2) { + if (meaning & 2 || + ((meaning & 32 || meaning & 384) && (meaning & 107455) === 107455)) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2) { + if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 235) { + if (decls && decls.length === 1 && decls[0].kind === 236) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -21979,14 +22698,14 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 144 && decl.parent === container) { + if (decl.kind === 145 && decl.parent === container) { return true; } } return false; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 71 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -22024,10 +22743,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 70: - case 178: + case 71: + case 179: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 200: + case 201: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -22054,46 +22773,60 @@ var ts; } return false; } - function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2) !== 0); - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { + if (meaning & (107455 & ~1024 & ~793064)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, name); + return true; + } } - } - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { + else if (meaning & (793064 & ~1024 & ~107455)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, name); return true; } } return false; } + function checkResolvedBlockScopedVariable(result, errorLocation) { + ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 232) ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (result.flags & 2) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 32) { + error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 384) { + error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + } + function isSameScopeDescendentOf(initial, parent, stopAt) { + return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } - while (node && node.kind !== 237) { - node = node.parent; - } - return node; + return ts.findAncestor(node, function (n) { return n.kind === 238; }); } } function getDeclarationOfAliasSymbol(symbol) { return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 247) { + function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { + if (node.moduleReference.kind === 248) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); } - function getTargetOfImportClause(node) { + function getTargetOfImportClause(node, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -22104,20 +22837,20 @@ var ts; var exportValue = moduleSymbol.exports.get("export="); exportDefaultSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") - : resolveSymbol(moduleSymbol.exports.get("default")); + : resolveSymbol(moduleSymbol.exports.get("default"), dontResolveAlias); } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } return exportDefaultSymbol; } } - function getTargetOfNamespaceImport(node) { + function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); } function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { if (valueSymbol.flags & (793064 | 1920)) { @@ -22134,12 +22867,9 @@ var ts; result.exports = valueSymbol.exports; return result; } - function getExportOfModule(symbol, name) { + function getExportOfModule(symbol, name, dontResolveAlias) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol).get(name); - if (exportedSymbol) { - return resolveSymbol(exportedSymbol); - } + return resolveSymbol(getExportsOfSymbol(symbol).get(name), dontResolveAlias); } } function getPropertyOfVariable(symbol, name) { @@ -22150,9 +22880,9 @@ var ts; } } } - function getExternalModuleMember(node, specifier) { + function getExternalModuleMember(node, specifier, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; if (name.text) { @@ -22166,10 +22896,10 @@ var ts; else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } - symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name.text); + symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); + var symbolFromModule = getExportOfModule(targetSymbol, name.text, dontResolveAlias); if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { - symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : @@ -22181,40 +22911,41 @@ var ts; } } } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); + function getTargetOfImportSpecifier(node, dontResolveAlias) { + return getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); } - function getTargetOfNamespaceExportDeclaration(node) { - return resolveExternalModuleSymbol(node.parent.symbol); + function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) { + return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); } - function getTargetOfExportSpecifier(node) { + function getTargetOfExportSpecifier(node, dontResolveAlias) { return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 | 793064 | 1920); + getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : + resolveEntityName(node.propertyName || node.name, 107455 | 793064 | 1920, false, dontResolveAlias); } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793064 | 1920); + function getTargetOfExportAssignment(node, dontResolveAlias) { + return resolveEntityName(node.expression, 107455 | 793064 | 1920, false, dontResolveAlias); } - function getTargetOfAliasDeclaration(node) { + function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { switch (node.kind) { - case 236: - return getTargetOfImportEqualsDeclaration(node); - case 238: - return getTargetOfImportClause(node); + case 237: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); case 239: - return getTargetOfNamespaceImport(node); - case 241: - return getTargetOfImportSpecifier(node); - case 245: - return getTargetOfExportSpecifier(node); + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 240: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); case 242: - return getTargetOfExportAssignment(node); - case 235: - return getTargetOfNamespaceExportDeclaration(node); + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 246: + return getTargetOfExportSpecifier(node, dontRecursivelyResolve); + case 243: + return getTargetOfExportAssignment(node, dontRecursivelyResolve); + case 236: + return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); } } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793064 | 1920)) ? resolveAlias(symbol) : symbol; + function resolveSymbol(symbol, dontResolveAlias) { + var shouldResolve = !dontResolveAlias && symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793064 | 1920)); + return shouldResolve ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); @@ -22253,10 +22984,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 242) { + if (node.kind === 243) { checkExpressionCached(node.expression); } - else if (node.kind === 245) { + else if (node.kind === 246) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -22265,14 +22996,14 @@ var ts; } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 71 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 142) { + if (entityName.kind === 71 || entityName.parent.kind === 143) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 236); + ts.Debug.assert(entityName.parent.kind === 237); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -22284,16 +23015,26 @@ var ts; return undefined; } var symbol; - if (name.kind === 70) { + if (name.kind === 71) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 142 || name.kind === 178) { - var left = name.kind === 142 ? name.left : name.expression; - var right = name.kind === 142 ? name.right : name.name; + else if (name.kind === 143 || name.kind === 179) { + var left = void 0; + if (name.kind === 143) { + left = name.left; + } + else if (name.kind === 179 && + (name.expression.kind === 185 || ts.isEntityNameExpression(name.expression))) { + left = name.expression; + } + else { + return undefined; + } + var right = name.kind === 143 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -22309,6 +23050,11 @@ var ts; return undefined; } } + else if (name.kind === 185) { + return ts.isEntityNameExpression(name.expression) ? + resolveEntityName(name.expression, meaning, ignoreErrors, dontResolveAlias, location) : + undefined; + } else { ts.Debug.fail("Unknown entity name kind."); } @@ -22320,7 +23066,7 @@ var ts; } function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReferenceExpression.kind !== 9) { + if (moduleReferenceExpression.kind !== 9 && moduleReferenceExpression.kind !== 13) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -22360,8 +23106,10 @@ var ts; var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } - else if (compilerOptions.noImplicitAny && moduleNotFoundError) { - error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + else if (noImplicitAny && moduleNotFoundError) { + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } return undefined; } @@ -22382,12 +23130,12 @@ var ts; } return undefined; } - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; + function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || moduleSymbol; } - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 | 3))) { + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression, dontResolveAlias) { + var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); + if (!dontResolveAlias && symbol && !(symbol.flags & (1536 | 3))) { error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } @@ -22501,7 +23249,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 === 151 && ts.nodeIsPresent(member.body)) { + if (member.kind === 152 && ts.nodeIsPresent(member.body)) { return member; } } @@ -22574,11 +23322,11 @@ var ts; } } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232: + case 233: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -22622,7 +23370,7 @@ var ts; return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -22654,7 +23402,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -22668,10 +23416,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 148: - case 150: - case 152: + case 149: + case 151: case 153: + case 154: continue; default: return false; @@ -22719,15 +23467,12 @@ var ts; } return { accessibility: 0 }; function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } + var node = ts.findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 265 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -22761,11 +23506,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 162 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 142 || entityName.kind === 178 || - entityName.parent.kind === 236) { + else if (entityName.kind === 143 || entityName.kind === 179 || + entityName.parent.kind === 237) { meaning = 1920; } else { @@ -22813,6 +23558,483 @@ var ts; } return result; } + function createNodeBuilder() { + var context; + return { + typeToTypeNode: function (type, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = typeToTypeNodeHelper(type); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + } + }; + function createNodeBuilderContext(enclosingDeclaration, flags) { + return { + enclosingDeclaration: enclosingDeclaration, + flags: flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + function typeToTypeNodeHelper(type) { + if (!type) { + context.encounteredError = true; + return undefined; + } + if (type.flags & 1) { + return ts.createKeywordTypeNode(119); + } + if (type.flags & 2) { + return ts.createKeywordTypeNode(136); + } + if (type.flags & 4) { + return ts.createKeywordTypeNode(133); + } + if (type.flags & 8) { + return ts.createKeywordTypeNode(122); + } + if (type.flags & 16) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & (32)) { + return ts.createLiteralTypeNode((ts.createLiteral(type.text))); + } + if (type.flags & (64)) { + return ts.createLiteralTypeNode((ts.createNumericLiteral(type.text))); + } + if (type.flags & 128) { + return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); + } + if (type.flags & 256) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & 1024) { + return ts.createKeywordTypeNode(105); + } + if (type.flags & 2048) { + return ts.createKeywordTypeNode(139); + } + if (type.flags & 4096) { + return ts.createKeywordTypeNode(95); + } + if (type.flags & 8192) { + return ts.createKeywordTypeNode(130); + } + if (type.flags & 512) { + return ts.createKeywordTypeNode(137); + } + if (type.flags & 16777216) { + return ts.createKeywordTypeNode(134); + } + if (type.flags & 16384 && type.isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return ts.createThis(); + } + var objectFlags = getObjectFlags(type); + if (objectFlags & 4) { + ts.Debug.assert(!!(type.flags & 32768)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & 3) { + ts.Debug.assert(!!(type.flags & 32768)); + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & 16384) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (context.checkAlias && type.aliasSymbol) { + var name = symbolToName(type.aliasSymbol, false); + var typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return ts.createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + if (type.flags & 65536) { + var formattedUnionTypes = formatUnionTypes(type.types); + var unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return ts.createUnionOrIntersectionTypeNode(166, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } + return undefined; + } + } + if (type.flags & 131072) { + return ts.createUnionOrIntersectionTypeNode(167, mapToTypeNodeArray(type.types)); + } + if (objectFlags & (16 | 32)) { + ts.Debug.assert(!!(type.flags & 32768)); + return createAnonymousTypeNode(type); + } + if (type.flags & 262144) { + var indexedType = type.type; + var indexTypeNode = typeToTypeNodeHelper(indexedType); + return ts.createTypeOperatorNode(indexTypeNode); + } + if (type.flags & 524288) { + var objectTypeNode = typeToTypeNodeHelper(type.objectType); + var indexTypeNode = typeToTypeNodeHelper(type.indexType); + return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + ts.Debug.fail("Should be unreachable."); + function mapToTypeNodeArray(types) { + var result = []; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type_1 = types_1[_i]; + var typeNode = typeToTypeNodeHelper(type_1); + if (typeNode) { + result.push(typeNode); + } + } + return result; + } + function createMappedTypeNodeFromType(type) { + ts.Debug.assert(!!(type.flags & 32768)); + var typeParameter = getTypeParameterFromMappedType(type); + var typeParameterNode = typeParameterToDeclaration(typeParameter); + var templateType = getTemplateTypeFromMappedType(type); + var templateTypeNode = typeToTypeNodeHelper(templateType); + var readonlyToken = type.declaration && type.declaration.readonlyToken ? ts.createToken(131) : undefined; + var questionToken = type.declaration && type.declaration.questionToken ? ts.createToken(55) : undefined; + return ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + function createAnonymousTypeNode(type) { + var symbol = type.symbol; + if (symbol) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromSymbol(symbol); + } + else if (ts.contains(context.symbolStack, symbol)) { + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + var entityName = symbolToName(typeAlias, false); + return ts.createTypeReferenceNode(entityName, undefined); + } + else { + return ts.createKeywordTypeNode(119); + } + } + else { + if (!context.symbolStack) { + context.symbolStack = []; + } + context.symbolStack.push(symbol); + var result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + return createTypeNodeFromObjectType(type); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 && + ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 265 || declaration.parent.kind === 234; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + return ts.contains(context.symbolStack, symbol); + } + } + } + function createTypeNodeFromObjectType(type) { + if (type.objectFlags & 32) { + if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { + return createMappedTypeNodeFromType(type); + } + } + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return ts.createTypeLiteralNode(undefined); + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + var signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 160); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + var signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 161); + } + } + var saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + var members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return ts.createTypeLiteralNode(members); + } + function createTypeQueryNodeFromSymbol(symbol) { + var entityName = symbolToName(symbol, false); + return ts.createTypeQueryNode(entityName); + } + function typeReferenceToTypeNode(type) { + var typeArguments = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + var elementType = typeToTypeNodeHelper(typeArguments[0]); + return ts.createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & 8) { + if (typeArguments.length > 0) { + var tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return ts.createTupleTypeNode(tupleConstituentNodes); + } + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; + } + return undefined; + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + var qualifiedName = undefined; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + var start = i; + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + var qualifiedNamePart = symbolToName(parent, true); + if (!qualifiedName) { + qualifiedName = ts.createQualifiedName(qualifiedNamePart, undefined); + } + else { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = ts.createQualifiedName(qualifiedName, undefined); + } + } + } + } + var entityName = undefined; + var nameIdentifier = symbolToName(type.symbol, true); + if (qualifiedName) { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + var typeArgumentNodes = ts.some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return ts.createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + function createTypeNodesFromResolvedType(resolvedType) { + var typeElements = []; + for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 155)); + } + for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 156)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1)); + } + var properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + for (var _d = 0, properties_2 = properties; _d < properties_2.length; _d++) { + var propertySymbol = properties_2[_d]; + var propertyType = getTypeOfSymbol(propertySymbol); + var oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0]; + if (!oldDeclaration) { + return; + } + var propertyName = oldDeclaration.name; + var optionalToken = propertySymbol.flags & 67108864 ? ts.createToken(55) : undefined; + if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length) { + var signatures = getSignaturesOfType(propertyType, 0); + for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { + var signature = signatures_1[_e]; + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 150); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : ts.createKeywordTypeNode(119); + typeElements.push(ts.createPropertySignature(propertyName, optionalToken, propertyTypeNode, undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind) { + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 136 : 133); + var name = ts.getNameFromIndexInfo(indexInfo); + var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); + var typeNode = typeToTypeNodeHelper(indexInfo.type); + return ts.createIndexSignatureDeclaration(undefined, indexInfo.isReadonly ? [ts.createToken(131)] : undefined, [indexingParameter], typeNode); + } + function signatureToSignatureDeclarationHelper(signature, kind) { + var typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter); }); + var returnTypeNode; + if (signature.typePredicate) { + var typePredicate = signature.typePredicate; + var parameterName = typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(); + var typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + } + else { + var returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } + var returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== 119 ? returnTypeNode : undefined; + return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + } + function typeParameterToDeclaration(type) { + var constraint = getConstraintFromTypeParameter(type); + var constraintNode = constraint && typeToTypeNodeHelper(constraint); + var defaultParameter = getDefaultFromTypeParameter(type); + var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + var name = symbolToName(type.symbol, true); + return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); + } + function symbolToParameterDeclaration(parameterSymbol) { + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 146); + var parameterType = getTypeOfSymbol(parameterSymbol); + var parameterTypeNode = typeToTypeNodeHelper(parameterType); + var parameterNode = ts.createParameter(parameterDeclaration.decorators, parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && ts.createToken(24), ts.getSynthesizedClone(parameterDeclaration.name), parameterDeclaration.questionToken && ts.createToken(55), parameterTypeNode, parameterDeclaration.initializer); + return parameterNode; + } + function symbolToName(symbol, expectsIdentifier) { + var chain; + var isTypeParameter = symbol.flags & 262144; + if (!isTypeParameter && context.enclosingDeclaration) { + chain = getSymbolChain(symbol, 0, true); + ts.Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & ts.NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); + function createEntityNameFromSymbolChain(chain, index) { + ts.Debug.assert(chain && 0 <= index && index < chain.length); + var symbol = chain[index]; + var typeParameterString = ""; + if (index > 0) { + var parentSymbol = chain[index - 1]; + var typeParameters = void 0; + if (getCheckFlags(symbol) & 1) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + var targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (32 | 64 | 524288)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if (typeParameters && typeParameters.length > 0) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } + var writer = ts.getSingleLineStringWriter(); + var displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); + typeParameterString = writer.string(); + ts.releaseStringWriter(writer); + } + } + var symbolName = getNameOfSymbol(symbol); + var symbolNameWithTypeParameters = typeParameterString.length > 0 ? symbolName + "<" + typeParameterString + ">" : symbolName; + var identifier = ts.createIdentifier(symbolNameWithTypeParameters); + return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + function getSymbolChain(symbol, meaning, endOfChain) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, false); + var parentSymbol; + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); + if (parentChain) { + parentSymbol = parent; + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + if (endOfChain || + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + !(symbol.flags & (2048 | 4096))) { + return [symbol]; + } + } + function getNameOfSymbol(symbol) { + var declaration = ts.firstOrUndefined(symbol.declarations); + if (declaration) { + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === 226) { + return ts.declarationNameToString(declaration.parent.name); + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case 199: + return "(Anonymous class)"; + case 186: + case 187: + return "(Anonymous function)"; + } + } + return symbol.name; + } + } + } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -22856,11 +24078,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 167) { - node = node.parent; - } - if (node.kind === 230) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 168; }); + if (node.kind === 231) { return getSymbolOfNode(node); } } @@ -22868,7 +24087,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 233 && + node.parent.kind === 234 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -22880,11 +24099,14 @@ var ts; if (declaration.name) { return ts.declarationNameToString(declaration.name); } + if (declaration.parent && declaration.parent.kind === 226) { + return ts.declarationNameToString(declaration.parent.name); + } switch (declaration.kind) { - case 198: + case 199: return "(Anonymous class)"; - case 185: case 186: + case 187: return "(Anonymous function)"; } } @@ -22899,17 +24121,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 20); + writePunctuation(writer, 21); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 21); + writePunctuation(writer, 22); } else { - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeSymbol(symbolName, symbol); } } @@ -22985,7 +24207,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 22); + writePunctuation(writer, 23); appendSymbolNameOnly(type.symbol, writer); } else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { @@ -23012,28 +24234,28 @@ var ts; } else if (type.flags & 524288) { writeType(type.objectType, 64); - writePunctuation(writer, 20); - writeType(type.indexType, 0); writePunctuation(writer, 21); + writeType(type.indexType, 0); + writePunctuation(writer, 22); } else { - writePunctuation(writer, 16); - writeSpace(writer); - writePunctuation(writer, 23); - writeSpace(writer); writePunctuation(writer, 17); + writeSpace(writer); + writePunctuation(writer, 24); + writeSpace(writer); + writePunctuation(writer, 18); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 25) { + if (delimiter !== 26) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 25 ? 0 : 64); + writeType(types[i], delimiter === 26 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -23041,44 +24263,44 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 20); writePunctuation(writer, 21); + writePunctuation(writer, 22); } else if (type.target.objectFlags & 8) { - writePunctuation(writer, 20); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); writePunctuation(writer, 21); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 26); + writePunctuation(writer, 22); } else { var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent, typeArguments, start, i, flags); - writePunctuation(writer, 22); + writePunctuation(writer, 23); } } } @@ -23088,16 +24310,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } if (type.flags & 65536) { - writeTypeList(formatUnionTypes(type.types), 48); + writeTypeList(formatUnionTypes(type.types), 49); } else { - writeTypeList(type.types, 47); + writeTypeList(type.types, 48); } if (flags & 64) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } } function writeAnonymousType(type, flags) { @@ -23116,7 +24338,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 118); + writeKeyword(writer, 119); } } else { @@ -23137,7 +24359,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 264 || declaration.parent.kind === 233; + return declaration.parent.kind === 265 || declaration.parent.kind === 234; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -23146,18 +24368,18 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 102); + writeKeyword(writer, 103); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 67108864) { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -23181,55 +24403,55 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 16); writePunctuation(writer, 17); + writePunctuation(writer, 18); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } - writeKeyword(writer, 93); + writeKeyword(writer, 94); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 16); + writePunctuation(writer, 17); writer.writeLine(); writer.increaseIndent(); writeObjectLiteralType(resolved); writer.decreaseIndent(); - writePunctuation(writer, 17); + writePunctuation(writer, 18); inObjectTypeLiteral = saveInObjectTypeLiteral; } function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); @@ -23239,49 +24461,49 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { - var signature = signatures_1[_f]; + for (var _f = 0, signatures_2 = signatures; _f < signatures_2.length; _f++) { + var signature = signatures_2[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } } function writeMappedType(type) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); writer.writeLine(); writer.increaseIndent(); if (type.declaration.readonlyToken) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); writeSpace(writer); - writeKeyword(writer, 91); + writeKeyword(writer, 92); writeSpace(writer); writeType(getConstraintTypeFromMappedType(type), 0); - writePunctuation(writer, 21); + writePunctuation(writer, 22); if (type.declaration.questionToken) { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); writeType(getTemplateTypeFromMappedType(type), 0); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); writer.decreaseIndent(); - writePunctuation(writer, 17); + writePunctuation(writer, 18); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -23295,64 +24517,64 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 84); + writeKeyword(writer, 85); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } var defaultType = getDefaultFromTypeParameter(tp); if (defaultType) { writeSpace(writer); - writePunctuation(writer, 57); + writePunctuation(writer, 58); writeSpace(writer); buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 23); + if (parameterNode ? ts.isRestParameter(parameterNode) : isTransientSymbol(p) && p.isRestParameter) { + writePunctuation(writer, 24); } - if (ts.isBindingPattern(parameterNode.name)) { + if (parameterNode && ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); } else { appendSymbolNameOnly(p, writer); } - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 54); + if (parameterNode && isOptionalParameter(parameterNode)) { + writePunctuation(writer, 55); } - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); var type = getTypeOfSymbol(p); - if (isRequiredInitializedParameter(parameterNode)) { + if (parameterNode && isRequiredInitializedParameter(parameterNode)) { type = includeFalsyTypes(type, 2048); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 173) { - writePunctuation(writer, 16); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 174) { writePunctuation(writer, 17); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 18); } - else if (bindingPattern.kind === 174) { - writePunctuation(writer, 20); + else if (bindingPattern.kind === 175) { + writePunctuation(writer, 21); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); } - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 175); + ts.Debug.assert(bindingElement.kind === 176); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -23360,22 +24582,22 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); } action(list[i]); @@ -23383,42 +24605,42 @@ var ts; } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); flags = 0; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 98); + writeKeyword(writer, 99); } writeSpace(writer); - writeKeyword(writer, 125); + writeKeyword(writer, 126); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } @@ -23429,10 +24651,10 @@ var ts; } if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 35); + writePunctuation(writer, 36); } else { - writePunctuation(writer, 55); + writePunctuation(writer, 56); } writeSpace(writer); if (signature.typePredicate) { @@ -23444,7 +24666,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 93); + writeKeyword(writer, 94); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -23459,26 +24681,26 @@ var ts; function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); switch (kind) { case 1: - writeKeyword(writer, 132); + writeKeyword(writer, 133); break; case 0: - writeKeyword(writer, 135); + writeKeyword(writer, 136); break; } - writePunctuation(writer, 21); - writePunctuation(writer, 55); + writePunctuation(writer, 22); + writePunctuation(writer, 56); writeSpace(writer); buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } @@ -23507,64 +24729,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 175: + case 176: return isDeclarationVisible(node.parent.parent); - case 225: + case 226: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 232: - case 228: + case 233: case 229: case 230: - case 227: case 231: - case 236: + case 228: + case 232: + case 237: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + !(node.kind !== 237 && parent.kind !== 265 && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 148: - case 147: - case 152: - case 153: - case 150: case 149: + case 148: + case 153: + case 154: + case 151: + case 150: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 151: - case 155: - case 154: + case 152: case 156: - case 145: - case 233: - case 159: + case 155: + case 157: + case 146: + case 234: case 160: - case 162: - case 158: + case 161: case 163: + case 159: case 164: case 165: case 166: case 167: + case 168: return isDeclarationVisible(node.parent); - case 238: case 239: - case 241: - return false; - case 144: - case 264: - case 235: - return true; + case 240: case 242: return false; + case 145: + case 265: + case 236: + return true; + case 243: + return false; default: return false; } @@ -23572,10 +24794,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 242) { + if (node.parent && node.parent.kind === 243) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 245) { + else if (node.parent.kind === 246) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -23607,8 +24829,8 @@ var ts; function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -23650,21 +24872,20 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - while (node) { + node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 225: case 226: + case 227: + case 242: case 241: case 240: case 239: - case 238: - node = node.parent; - break; + return false; default: - return node.parent; + return true; } - } + }); + return node && node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); @@ -23682,7 +24903,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 144 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -23694,8 +24915,8 @@ var ts; } var members = ts.createMap(); var names = ts.createMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var name = properties_3[_i]; names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { @@ -23724,7 +24945,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 173) { + if (pattern.kind === 174) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -23758,7 +24979,7 @@ var ts; } } else { - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, false, false); if (declaration.dotDotDotToken) { type = createArrayType(elementType); } @@ -23794,23 +25015,15 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 95 || expr.kind === 71 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 176 && expr.elements.length === 0; + return expr.kind === 177 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } - function removeOptionalityFromAnnotation(annotatedType, declaration) { - var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 145 && - declaration.initializer && - getFalsyFlags(annotatedType) & 2048 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { var type = getTypeForDeclarationFromJSDocComment(declaration); @@ -23818,22 +25031,23 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 214) { + if (declaration.parent.parent.kind === 215) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 215) { - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + if (declaration.parent.parent.kind === 216) { + var forOfStatement = declaration.parent.parent; + return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + var declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && + if ((noImplicitAny || declaration.flags & 65536) && + declaration.kind === 226 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -23842,10 +25056,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 145) { + if (declaration.kind === 146) { var func = declaration.parent; - if (func.kind === 153 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); + if (func.kind === 154 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 153); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -23874,7 +25088,7 @@ var ts; if (ts.isJsxAttribute(declaration)) { return trueType; } - if (declaration.kind === 261) { + if (declaration.kind === 262) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -23882,20 +25096,36 @@ var ts; } return undefined; } - function getTypeForJSSpecialPropertyDeclaration(declaration) { - var expression = declaration.kind === 193 ? declaration : - declaration.kind === 178 ? ts.getAncestor(declaration, 193) : - undefined; - if (!expression) { - return unknownType; - } - if (expression.flags & 65536) { - var type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol) { + var types = []; + var definedInConstructor = false; + var definedInMethod = false; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = declaration.kind === 194 ? declaration : + declaration.kind === 179 ? ts.getAncestor(declaration, 194) : + undefined; + if (!expression) { + return unknownType; } + if (ts.isPropertyAccessExpression(expression.left) && expression.left.expression.kind === 99) { + if (ts.getThisContainer(expression, false).kind === 152) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, true), definedInMethod && !definedInConstructor)); } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { @@ -23904,7 +25134,7 @@ var ts; if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -23954,7 +25184,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 173 + return pattern.kind === 174 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -23964,13 +25194,13 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 260) { + if (declaration.kind === 261) { return type; } return getWidenedType(type); } type = declaration.dotDotDotToken ? anyArrayType : anyType; - if (reportErrors && compilerOptions.noImplicitAny) { + if (reportErrors && noImplicitAny) { if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } @@ -23979,7 +25209,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 145 ? root.parent : root; + var memberDeclaration = root.kind === 146 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -23992,19 +25222,19 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 242) { + if (declaration.kind === 243) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 291 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 193 || - declaration.kind === 178 && declaration.parent.kind === 193) { - type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); + if (declaration.kind === 194 || + declaration.kind === 179 && declaration.parent.kind === 194) { + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -24018,7 +25248,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 152) { + if (accessor.kind === 153) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -24038,8 +25268,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 152); - var setter = ts.getDeclarationOfKind(symbol, 153); + var getter = ts.getDeclarationOfKind(symbol, 153); + var setter = ts.getDeclarationOfKind(symbol, 154); if (getter && getter.flags & 65536) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -24064,7 +25294,7 @@ var ts; type = getReturnTypeFromBody(getter); } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { if (setter) { error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } @@ -24079,8 +25309,8 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 152); + if (noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 153); 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)); } } @@ -24131,14 +25361,22 @@ var ts; function getTypeOfInstantiatedSymbol(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0)) { - return unknownType; + if (symbolInstantiationDepth === 100) { + error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); + links.type = unknownType; } - var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - if (!popTypeResolution()) { - type = reportCircularityError(symbol); + else { + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + symbolInstantiationDepth++; + var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + symbolInstantiationDepth--; + if (!popTypeResolution()) { + type = reportCircularityError(symbol); + } + links.type = type; } - links.type = type; } return links.type; } @@ -24147,7 +25385,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return unknownType; } - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -24173,6 +25411,12 @@ var ts; } return unknownType; } + function isReferenceToType(type, target) { + return type !== undefined + && target !== undefined + && (getObjectFlags(type) & 4) !== 0 + && type.target === target; + } function getTargetType(type) { return getObjectFlags(type) & 4 ? type.target : type; } @@ -24207,9 +25451,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 228 || node.kind === 198 || - node.kind === 227 || node.kind === 185 || - node.kind === 150 || node.kind === 186) { + if (node.kind === 229 || node.kind === 199 || + node.kind === 228 || node.kind === 186 || + node.kind === 151 || node.kind === 187) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -24218,15 +25462,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230); 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 === 229 || node.kind === 228 || - node.kind === 198 || node.kind === 230) { + if (node.kind === 230 || node.kind === 229 || + node.kind === 199 || node.kind === 231) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -24252,19 +25496,20 @@ var ts; } if (type.flags & 540672) { var constraint = getBaseConstraintOfType(type); - return isValidBaseType(constraint) && isMixinConstructorType(constraint); + return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { + function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); + var isJavaScript = ts.isInJavaScriptFile(location); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); @@ -24288,7 +25533,7 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = unknownType; } - if (baseConstructorType !== unknownType && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); return type.resolvedBaseConstructorType = unknownType; } @@ -24318,7 +25563,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (32768 | 131072))) { + if (!(baseConstructorType.flags & (32768 | 131072 | 1))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -24328,8 +25573,11 @@ var ts; areAllOuterTypeParametersApplied(originalBaseType)) { baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } + else if (baseConstructorType.flags & 1) { + baseType = baseConstructorType; + } else { - var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -24371,14 +25619,14 @@ var ts; return true; } function isValidBaseType(type) { - return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + return type.flags & (32768 | 16777216 | 1) && !isGenericMappedType(type) || type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 230 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -24407,7 +25655,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { if (declaration.flags & 64) { return false; } @@ -24457,7 +25705,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 289); + var declaration = ts.getDeclarationOfKind(symbol, 290); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -24468,7 +25716,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 230); + declaration = ts.getDeclarationOfKind(symbol, 231); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -24493,14 +25741,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 191 && expr.operator === 37 && + expr.kind === 192 && expr.operator === 38 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports.get(expr.text); + expr.kind === 71 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231) { + if (declaration.kind === 232) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -24528,7 +25776,7 @@ var ts; var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231) { + if (declaration.kind === 232) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -24611,21 +25859,21 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: case 133: - case 104: - case 138: - case 94: - case 129: - case 172: + case 122: + case 137: + case 134: + case 105: + case 139: + case 95: + case 130: + case 173: return true; - case 163: + case 164: return isIndependentType(node.elementType); - case 158: + case 159: return isIndependentTypeReference(node); } return false; @@ -24634,7 +25882,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 152 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -24650,12 +25898,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 148: - case 147: - return isIndependentVariableLikeDeclaration(declaration); - case 150: case 149: + case 148: + return isIndependentVariableLikeDeclaration(declaration); case 151: + case 150: + case 152: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -24745,7 +25993,11 @@ var ts; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); + if (!stringIndexInfo) { + stringIndexInfo = instantiatedBaseType === anyType ? + createIndexInfo(anyType, false) : + getIndexInfoOfType(instantiatedBaseType, 0); + } numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } @@ -24784,6 +26036,7 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); + var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = ts.length(typeArguments); var result = []; @@ -24791,8 +26044,8 @@ var ts; var baseSig = baseSignatures_1[_i]; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -24861,8 +26114,8 @@ var ts; 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]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type = types_2[_i]; var indexInfo = getIndexInfoOfType(type, kind); if (!indexInfo) { return undefined; @@ -24950,7 +26203,8 @@ var ts; else { var members = emptySymbols; var constructSignatures = emptyArray; - if (symbol.flags & 1952) { + var stringIndexInfo = undefined; + if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32) { @@ -24964,9 +26218,12 @@ var ts; members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } + else if (baseConstructorType === anyType) { + stringIndexInfo = createIndexInfo(anyType, false); + } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } @@ -24982,7 +26239,7 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 169) { + if (type.declaration.typeParameter.constraint.kind === 170) { for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var propertySymbol = _a[_i]; addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); @@ -25006,10 +26263,10 @@ var ts; var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 8 : 0; prop.type = propType; if (propertySymbol) { - prop.mappedTypeOrigin = propertySymbol; + prop.syntheticOrigin = propertySymbol; } members.set(propName, prop); } @@ -25035,7 +26292,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 169) { + if (constraintDeclaration.kind === 170) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { @@ -25123,14 +26380,29 @@ var ts; getPropertiesOfObjectType(type); } function getConstraintOfType(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : + type.flags & 524288 ? getConstraintOfIndexedAccess(type) : + getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } + function getConstraintOfIndexedAccess(type) { + var baseObjectType = getBaseConstraintOfType(type.objectType); + var baseIndexType = getBaseConstraintOfType(type.indexType); + return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; + } function getBaseConstraintOfType(type) { - var constraint = getResolvedBaseConstraint(type); - return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + if (type.flags & (540672 | 196608)) { + var constraint = getResolvedBaseConstraint(type); + if (constraint !== noConstraintType && constraint !== circularConstraintType) { + return constraint; + } + } + else if (type.flags & 262144) { + return stringType; + } + return undefined; } function hasNonCircularBaseConstraint(type) { return getResolvedBaseConstraint(type) !== circularConstraintType; @@ -25163,9 +26435,9 @@ var ts; if (t.flags & 196608) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_1 = types_2[_i]; - var baseType = getBaseConstraint(type_1); + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; + var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); } @@ -25208,7 +26480,7 @@ var ts; t.flags & 262178 ? globalStringType : t.flags & 340 ? globalNumberType : t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 512 ? getGlobalESSymbolType(languageVersion >= 2) : t.flags & 16777216 ? emptyObjectType : t; } @@ -25218,9 +26490,10 @@ var ts; var isUnion = containingType.flags & 65536; var excludeModifiers = isUnion ? 24 : 0; var commonFlags = isUnion ? 0 : 67108864; - var checkFlags = 2; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + var syntheticFlag = 4; + var checkFlags = 0; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); @@ -25233,21 +26506,24 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | - (!(modifiers & 24) ? 32 : 0) | - (modifiers & 16 ? 64 : 0) | - (modifiers & 8 ? 128 : 0) | - (modifiers & 32 ? 256 : 0); + checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | + (!(modifiers & 24) ? 64 : 0) | + (modifiers & 16 ? 128 : 0) | + (modifiers & 8 ? 256 : 0) | + (modifiers & 32 ? 512 : 0); + if (!isMethodLike(prop)) { + syntheticFlag = 2; + } } else if (isUnion) { - checkFlags |= 8; + checkFlags |= 16; } } } if (!props) { return undefined; } - if (props.length === 1 && !(checkFlags & 8)) { + if (props.length === 1 && !(checkFlags & 16)) { return props[0]; } var propTypes = []; @@ -25263,12 +26539,12 @@ var ts; commonType = type; } else if (type !== commonType) { - checkFlags |= 16; + checkFlags |= 32; } propTypes.push(type); } var result = createSymbol(4 | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -25287,7 +26563,7 @@ var ts; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(getCheckFlags(property) & 8) ? property : undefined; + return property && !(getCheckFlags(property) & 16) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); @@ -25381,7 +26657,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 277) { + if (node.type && node.type.kind === 278) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -25392,7 +26668,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 277; + return paramTag.typeExpression.type.kind === 278; } } } @@ -25425,7 +26701,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 70) { + if (node.parameterName.kind === 71) { var parameterName = node.parameterName; return { kind: 1, @@ -25452,21 +26728,22 @@ var ts; } return minTypeArgumentCount; } - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + var isJavaScript = ts.isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (var i = numTypeArguments; i < numTypeParameters; i++) { var mapper = createTypeMapper(typeParameters, typeArguments); var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -25497,7 +26774,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 172) { + if (param.type && param.type.kind === 173) { hasLiteralTypes = true; } var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || @@ -25508,23 +26785,23 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 152 || declaration.kind === 153) && + if ((declaration.kind === 153 || declaration.kind === 154) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 152 ? 153 : 152; + var otherKind = declaration.kind === 153 ? 154 : 153; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 151 ? + var classType = declaration.kind === 152 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 157 ? + var typePredicate = declaration.type && declaration.type.kind === 158 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -25547,14 +26824,42 @@ var ts; return type; } } - if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 153); + if (declaration.kind === 153 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 154); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { return anyType; } } + function containsArgumentsReference(declaration) { + var links = getNodeLinks(declaration); + if (links.containsArgumentsReference === undefined) { + if (links.flags & 8192) { + links.containsArgumentsReference = true; + } + else { + links.containsArgumentsReference = traverse(declaration.body); + } + } + return links.containsArgumentsReference; + function traverse(node) { + if (!node) + return false; + switch (node.kind) { + case 71: + return node.text === "arguments" && ts.isPartOfExpression(node); + case 149: + case 151: + case 153: + case 154: + return node.name.kind === 144 + && traverse(node.name); + default: + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + } + } + } function getSignaturesOfSymbol(symbol) { if (!symbol) return emptyArray; @@ -25562,20 +26867,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 159: case 160: - case 227: - case 150: - case 149: + case 161: + case 228: case 151: - case 154: + case 150: + case 152: case 155: case 156: - case 152: + case 157: case 153: - case 185: + case 154: case 186: - case 278: + case 187: + case 279: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -25619,7 +26924,7 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { var declaration = signature.declaration; if (declaration.name) { error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name)); @@ -25665,7 +26970,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; + var isConstructor = signature.declaration.kind === 152 || signature.declaration.kind === 156; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -25679,7 +26984,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 135; + var syntaxKind = kind === 1 ? 133 : 136; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -25706,7 +27011,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 144).constraint; + return ts.getDeclarationOfKind(type.symbol, 145).constraint; } function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { @@ -25722,17 +27027,17 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 145).parent); } function getTypeListId(types) { var result = ""; if (types) { - var length_3 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_3) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_3 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -25749,8 +27054,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -25786,13 +27091,13 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -25842,11 +27147,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 158: + case 159: return node.typeName; - case 276: + case 277: return node.name; - case 200: + case 201: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -25870,23 +27175,58 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 276) { + if (symbol.flags & 107455 && node.kind === 277) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); } + function getPrimitiveTypeFromJSDocTypeReference(node) { + if (ts.isIdentifier(node.name)) { + switch (node.name.text) { + case "String": + return stringType; + case "Number": + return numberType; + case "Boolean": + return booleanType; + case "Void": + return voidType; + case "Undefined": + return undefinedType; + case "Null": + return nullType; + case "Object": + return anyType; + case "Function": + return anyFunctionType; + case "Array": + case "array": + return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + case "Promise": + case "promise": + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + } + } + } + function getTypeFromJSDocNullableTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getUnionType([type, nullType]) : type; + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 276) { - var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(typeReferenceName); - type = getTypeReferenceType(node, symbol); + if (node.kind === 277) { + type = getPrimitiveTypeFromJSDocTypeReference(node); + if (!type) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(typeReferenceName); + type = getTypeReferenceType(node, symbol); + } } else { - var typeNameOrExpression = node.kind === 158 + var typeNameOrExpression = node.kind === 159 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -25915,9 +27255,9 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var declaration = declarations_4[_i]; switch (declaration.kind) { - case 228: case 229: - case 231: + case 230: + case 232: return declaration; } } @@ -25936,38 +27276,85 @@ var ts; } return type; } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); + function getGlobalValueSymbol(name, reportErrors) { + return getGlobalSymbol(name, 107455, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793064, ts.Diagnostics.Cannot_find_global_type_0); + function getGlobalTypeSymbol(name, reportErrors) { + return getGlobalSymbol(name, 793064, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name, arity) { + function getGlobalType(name, arity, reportErrors) { + var symbol = getGlobalTypeSymbol(name, reportErrors); + return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; + } + function getGlobalTypedPropertyDescriptorType() { + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType; + } + function getGlobalTemplateStringsArrayType() { + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType; + } + function getGlobalESSymbolConstructorSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); + } + function getGlobalESSymbolType(reportErrors) { + return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType; + } + function getGlobalPromiseType(reportErrors) { + return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType; + } + function getGlobalPromiseConstructorSymbol(reportErrors) { + return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); + } + function getGlobalPromiseConstructorLikeType(reportErrors) { + return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType; + } + function getGlobalAsyncIterableType(reportErrors) { + return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIteratorType(reportErrors) { + return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIterableIteratorType(reportErrors) { + return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableType(reportErrors) { + return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIteratorType(reportErrors) { + return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableIteratorType(reportErrors) { + return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + var symbol = getGlobalSymbol(name, 793064, undefined); + return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getExportedTypeFromNamespace(namespace, name) { var namespaceSymbol = getGlobalSymbol(namespace, 1920, undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793064); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableType(), [elementType]); + function createTypedPropertyDescriptorType(propertyType) { + return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); + function createAsyncIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(true), [iteratedType]); + } + function createAsyncIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(true), [iteratedType]); + } + function createIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]); + } + function createIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(true), [iteratedType]); } function createArrayType(elementType) { return createTypeFromGenericGlobalType(globalArrayType, [elementType]); @@ -26076,14 +27463,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -26091,8 +27478,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -26196,7 +27583,13 @@ var ts; else if (type.flags & 1) { typeSet.containsAny = true; } + else if (getObjectFlags(type) & 16 && isEmptyObjectType(type)) { + typeSet.containsEmptyObject = true; + } else if (!(type.flags & 8192) && (strictNullChecks || !(type.flags & 6144)) && !ts.contains(typeSet, type)) { + if (type.flags & 32768) { + typeSet.containsObjectType = true; + } if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } @@ -26207,8 +27600,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -26221,6 +27614,9 @@ var ts; if (typeSet.containsAny) { return anyType; } + if (typeSet.containsEmptyObject && !typeSet.containsObjectType) { + typeSet.push(emptyObjectType); + } if (typeSet.length === 1) { return typeSet[0]; } @@ -26287,7 +27683,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -26323,7 +27719,7 @@ var ts; return indexInfo.type; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, 1)) { error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } @@ -26335,7 +27731,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 180 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -26345,11 +27741,12 @@ var ts; else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } + return unknownType; } - return unknownType; + return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; @@ -26360,7 +27757,7 @@ var ts; } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 180) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; @@ -26426,7 +27823,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 231 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -26472,7 +27869,7 @@ var ts; skippedPrivateMembers.set(rightProp.name, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.name, rightProp); + members.set(rightProp.name, getNonReadonlySymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -26489,7 +27886,6 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); - result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; @@ -26498,11 +27894,22 @@ var ts; } } else { - members.set(leftProp.name, leftProp); + members.set(leftProp.name, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function getNonReadonlySymbol(prop) { + if (!isReadonlySymbol(prop)) { + return prop; + } + var flags = 4 | (prop.flags & 67108864); + var result = createSymbol(flags, prop.name); + result.type = getTypeOfSymbol(prop); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + return result; + } function isClassMethod(prop) { return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); } @@ -26559,9 +27966,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 230)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 152 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -26577,88 +27984,83 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 118: - case 267: + case 119: case 268: - return anyType; - case 135: - return stringType; - case 132: - return numberType; - case 121: - return booleanType; - case 136: - return esSymbolType; - case 104: - return voidType; - case 138: - return undefinedType; - case 94: - return nullType; - case 129: - return neverType; - case 133: - return nonPrimitiveType; - case 293: - return nullType; - case 294: - return undefinedType; - case 295: - return neverType; - case 168: - case 98: - return getTypeFromThisTypeNode(node); - case 172: - return getTypeFromLiteralTypeNode(node); - case 292: - return getTypeFromLiteralTypeNode(node.literal); - case 158: - case 276: - return getTypeFromTypeReference(node); - case 157: - return booleanType; - case 200: - return getTypeFromTypeReference(node); - case 161: - return getTypeFromTypeQueryNode(node); - case 163: case 269: - return getTypeFromArrayTypeNode(node); - case 164: - return getTypeFromTupleTypeNode(node); - case 165: - case 270: - return getTypeFromUnionTypeNode(node); - case 166: - return getTypeFromIntersectionTypeNode(node); - case 167: - case 272: - case 273: - case 280: - case 281: - case 277: - return getTypeFromTypeNode(node.type); - case 274: - return getTypeFromTypeNode(node.literal); - case 159: - case 160: - case 162: - case 291: - case 278: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + return anyType; + case 136: + return stringType; + case 133: + return numberType; + case 122: + return booleanType; + case 137: + return esSymbolType; + case 105: + return voidType; + case 139: + return undefinedType; + case 95: + return nullType; + case 130: + return neverType; + case 134: + return nonPrimitiveType; case 169: - return getTypeFromTypeOperatorNode(node); + case 99: + return getTypeFromThisTypeNode(node); + case 173: + return getTypeFromLiteralTypeNode(node); + case 293: + return getTypeFromLiteralTypeNode(node.literal); + case 159: + case 277: + return getTypeFromTypeReference(node); + case 158: + return booleanType; + case 201: + return getTypeFromTypeReference(node); + case 162: + return getTypeFromTypeQueryNode(node); + case 164: + case 270: + return getTypeFromArrayTypeNode(node); + case 165: + return getTypeFromTupleTypeNode(node); + case 166: + case 271: + return getTypeFromUnionTypeNode(node); + case 167: + return getTypeFromIntersectionTypeNode(node); + case 273: + return getTypeFromJSDocNullableTypeNode(node); + case 168: + case 274: + case 281: + case 282: + case 278: + return getTypeFromTypeNode(node.type); + case 275: + return getTypeFromTypeNode(node.literal); + case 160: + case 161: + case 163: + case 292: + case 279: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 170: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 171: + return getTypeFromIndexedAccessTypeNode(node); + case 172: return getTypeFromMappedTypeNode(node); - case 70: - case 142: + case 71: + case 143: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 271: + case 272: return getTypeFromJSDocTupleType(node); - case 279: + case 280: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -26847,26 +28249,28 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0]; - while (node) { + return !!ts.findAncestor(symbol.declarations[0], function (node) { + if (node.kind === 233 || node.kind === 265) { + return "quit"; + } switch (node.kind) { - case 159: case 160: - case 227: - case 150: - case 149: + case 161: + case 228: case 151: - case 154: + case 150: + case 152: case 155: case 156: - case 152: + case 157: case 153: - case 185: + case 154: case 186: - case 228: - case 198: + case 187: case 229: + case 199: case 230: + case 231: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -26876,19 +28280,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 229) { + if (ts.isClassLike(node) || node.kind === 230) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 171: + case 172: if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { return true; } break; - case 278: + case 279: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -26897,18 +28301,13 @@ var ts; } } break; - case 232: - case 264: - return false; } - node = node.parent; - } - return false; + }); } function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 264 || parentKind === 233; + return parentKind === 265 || parentKind === 234; } return false; } @@ -26960,33 +28359,33 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 185: case 186: + case 187: return isContextSensitiveFunctionLikeDeclaration(node); - case 177: + case 178: return ts.forEach(node.properties, isContextSensitive); - case 176: + case 177: return ts.forEach(node.elements, isContextSensitive); - case 194: + case 195: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 193: - return node.operatorToken.kind === 53 && + case 194: + return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 260: + case 261: return isContextSensitive(node.initializer); + case 151: case 150: - case 149: return isContextSensitiveFunctionLikeDeclaration(node); - case 184: + case 185: return isContextSensitive(node.expression); - case 253: + case 254: return ts.forEach(node.properties, isContextSensitive); - case 252: + case 253: return node.initializer && isContextSensitive(node.initializer); - case 255: + case 256: return node.expression && isContextSensitive(node.expression); } return false; @@ -26998,7 +28397,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 186) { + if (node.kind === 187) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -27058,9 +28457,9 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + return compareSignaturesRelated(source, target, false, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; } - function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { if (source === target) { return -1; } @@ -27091,9 +28490,15 @@ var ts; var sourceParams = source.parameters; var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - var related = compareTypes(s, t, false) || compareTypes(t, s, reportErrors); + var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); + var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var sourceSig = getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = getSingleCallSignature(getNonNullableType(targetType)); + var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate && + (getFalsyFlags(sourceType) & 6144) === (getFalsyFlags(targetType) & 6144); + var related = callbacks ? + compareSignaturesRelated(targetSig, sourceSig, true, false, reportErrors, errorReporter, compareTypes) : + !checkAsCallback && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); @@ -27120,7 +28525,8 @@ var ts; } } else { - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, false) || + compareTypes(sourceReturnType, targetReturnType, reportErrors); } } return result; @@ -27183,6 +28589,19 @@ var ts; sourceNonRestParamCount; } } + function isEmptyResolvedType(t) { + return t.properties.length === 0 && + t.callSignatures.length === 0 && + t.constructSignatures.length === 0 && + !t.stringIndexInfo && + !t.numberIndexInfo; + } + function isEmptyObjectType(type) { + return type.flags & 32768 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 65536 ? ts.forEach(type.types, isEmptyObjectType) : + type.flags & 131072 ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + false; + } function isEnumTypeRelatedTo(source, target, errorReporter) { if (source === target) { return true; @@ -27273,7 +28692,7 @@ var ts; } } if (source.flags & 1032192 || target.flags & 1032192) { - return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); + return checkTypeRelatedTo(source, target, relation, undefined); } return false; } @@ -27327,7 +28746,7 @@ var ts; if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType() === source && esSymbolType === target)) { + (getGlobalESSymbolType(false) === source && esSymbolType === target)) { reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -27386,102 +28805,24 @@ var ts; return result; } } - else if (target.flags & 65536) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { - return result; - } - } - else if (target.flags & 131072) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & 131072) { - if (result = someTypeRelatedToType(source, target, false)) { - return result; - } - } - else if (target.flags & 16384) { - if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!source.declaration.questionToken) { - var templateType = getTemplateTypeFromMappedType(source); - var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { - return result; - } - } - } - } - else if (target.flags & 262144) { - if (source.flags & 262144) { - if (result = isRelatedTo(target.type, source.type, false)) { - return result; - } - } - var constraint = getConstraintOfType(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } - } - } - else if (target.flags & 524288) { - if (source.flags & 524288 && source.indexType === target.indexType) { - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - return result; - } - } - var constraint = getBaseConstraintOfType(target); - if (constraint) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (source.flags & 16384) { - if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { - var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); - var templateType = getTemplateTypeFromMappedType(target); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - var constraint = getConstraintOfTypeParameter(source); - if (constraint || !(target.flags & 16777216)) { - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - } - else if (source.flags & 524288) { - var constraint = getBaseConstraintOfType(source); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } else { - if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + if (target.flags & 65536) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { return result; } } - var apparentSource = getApparentType(source); - if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + else if (target.flags & 131072) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072) { + if (result = someTypeRelatedToType(source, target, false)) { + return result; + } + } + if (source.flags & 1032192 || target.flags & 1032192) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -27501,12 +28842,7 @@ var ts; function isIdenticalTo(source, target) { var result; if (source.flags & 32768 && target.flags & 32768) { - if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, false); + return recursiveTypeRelatedTo(source, target, false); } if (source.flags & 65536 && target.flags & 65536 || source.flags & 131072 && target.flags & 131072) { @@ -27521,14 +28857,8 @@ var ts; function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && - (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { - return true; - } - else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { - return true; - } - else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { return true; } } @@ -27542,25 +28872,19 @@ var ts; } return false; } - function isEmptyResolvedType(t) { - return t.properties.length === 0 && - t.callSignatures.length === 0 && - t.constructSignatures.length === 0 && - !t.stringIndexInfo && - !t.numberIndexInfo; - } - function isEmptyObjectType(type) { - return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); - } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { var isComparingJsxAttributes = !!(source.flags & 33554432); + if ((relation === assignableRelation || relation === comparableRelation) && + (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { + return false; + } for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - if (ts.isJsxAttributes(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -27680,7 +29004,7 @@ var ts; } return result; } - function objectTypeRelatedTo(source, originalSource, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -27717,32 +29041,11 @@ var ts; maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1; - } - else if (isGenericMappedType(source) || isGenericMappedType(target)) { - result = mappedTypeRelatedTo(source, target, reportErrors); - } - else { - result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 0, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 1, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 0, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 1, reportErrors); - } - } - } - } - } + var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -27755,6 +29058,118 @@ var ts; } return result; } + function structuredTypeRelatedTo(source, target, reportErrors) { + var result; + var saveErrorInfo = errorInfo; + if (target.flags & 16384) { + if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!source.declaration.questionToken) { + var templateType = getTemplateTypeFromMappedType(source); + var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + } + else if (target.flags & 262144) { + if (source.flags & 262144) { + if (result = isRelatedTo(target.type, source.type, false)) { + return result; + } + } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } + else if (target.flags & 524288) { + var constraint = getConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (source.flags & 16384) { + if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + var templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + var constraint = getConstraintOfTypeParameter(source); + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + } + else if (source.flags & 524288) { + var constraint = getConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (target.flags & 524288 && source.indexType === target.indexType) { + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + return result; + } + } + } + else { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + var sourceIsPrimitive = !!(source.flags & 8190); + if (relation !== identityRelation) { + source = getApparentType(source); + } + if (source.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportStructuralErrors); + } + else { + result = propertiesRelatedTo(source, target, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors); + } + } + } + } + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + return 0; + } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -27792,8 +29207,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -27808,7 +29223,7 @@ var ts; var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { - if (getCheckFlags(sourceProp) & 128) { + if (getCheckFlags(sourceProp) & 256) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); } @@ -27926,7 +29341,7 @@ var ts; return result; } function signatureRelatedTo(source, target, reportErrors) { - return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, false, false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -27968,12 +29383,12 @@ var ts; } return related; } - function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors) { if (relation === identityRelation) { return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || ((targetInfo.type.flags & 1) && !(originalSource.flags & 8190))) { + if (!targetInfo || targetInfo.type.flags & 1 && !sourceIsPrimitive) { return -1; } var sourceInfo = getIndexInfoOfType(source, kind) || @@ -28032,7 +29447,7 @@ var ts; } } function forEachProperty(prop, callback) { - if (getCheckFlags(prop) & 2) { + if (getCheckFlags(prop) & 6) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.name); @@ -28074,16 +29489,18 @@ var ts; } return false; } - function isDeeplyNestedGeneric(type, stack, depth) { - if (getObjectFlags(type) & (4 | 64) && depth >= 5) { + function isDeeplyNestedType(type, stack, depth) { + if (depth >= 5 && type.flags & 32768) { var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (getObjectFlags(t) & (4 | 64) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; + if (symbol) { + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & 32768 && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } } } } @@ -28175,8 +29592,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -28184,8 +29601,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -28276,8 +29693,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -28340,7 +29757,6 @@ var ts; var updated = f(original); members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } - ; return members; } function getRegularTypeOfObjectLiteral(type) { @@ -28359,11 +29775,17 @@ var ts; type.regularType = regularNew; return regularNew; } + function getWidenedProperty(prop) { + var original = getTypeOfSymbol(prop); + var widened = getWidenedType(original); + return widened === original ? prop : createSymbolWithType(prop, widened); + } function getWidenedTypeOfObjectLiteral(type) { - var members = transformTypeOfMembers(type, function (prop) { - var widened = getWidenedType(prop); - return prop === widened ? prop : widened; - }); + var members = ts.createMap(); + for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + members.set(prop.name, prop.flags & 4 ? getWidenedProperty(prop) : prop); + } 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)); @@ -28424,25 +29846,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 149: case 148: - case 147: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 145: + case 146: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 175: + case 176: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 227: + case 228: + case 151: case 150: - case 149: - case 152: case 153: - case 185: + case 154: case 186: + case 187: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -28455,7 +29877,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { + if (produceDiagnostics && noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -28481,13 +29903,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, inferUnionTypes) { + function createInferenceContext(signature, inferUnionTypes, useAnyForNoInferences) { var inferences = ts.map(signature.typeParameters, createTypeInferencesObject); return { signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences: useAnyForNoInferences }; } function createTypeInferencesObject() { @@ -28529,14 +29952,14 @@ var ts; var readonlyMask = target.declaration.readonlyToken ? false : true; var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var prop = properties_5[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (!inferredPropType) { return undefined; } var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 8 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; members.set(prop.name, inferredProp); @@ -28678,7 +30101,7 @@ var ts; if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } var key = source.id + "," + target.id; @@ -28726,8 +30149,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -28777,8 +30200,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -28824,7 +30247,7 @@ var ts; inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; } @@ -28858,29 +30281,17 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - while (node) { - switch (node.kind) { - case 161: - return true; - case 70: - case 142: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); + return !!ts.findAncestor(node, function (n) { return n.kind === 162 ? true : n.kind === 71 || n.kind === 143 ? false : "quit"; }); } function getFlowCacheKey(node) { - if (node.kind === 70) { + if (node.kind === 71) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 98) { + if (node.kind === 99) { return "0"; } - if (node.kind === 178) { + if (node.kind === 179) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -28888,31 +30299,33 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 70: - case 98: + case 71: + case 99: return node; - case 178: + case 179: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 70: - return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 225 || target.kind === 175) && + case 71: + return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 226 || target.kind === 176) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 98: - return target.kind === 98; - case 178: - return target.kind === 178 && + case 99: + return target.kind === 99; + case 97: + return target.kind === 97; + case 179: + return target.kind === 179 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 178) { + while (source.kind === 179) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -28921,15 +30334,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 178 && + return target.kind === 179 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 70) { + if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 178) { + if (expr.kind === 179) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -28940,7 +30353,7 @@ var ts; var prop = getUnionOrIntersectionProperty(type, name); if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 32 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -28959,7 +30372,7 @@ var ts; } } } - if (callExpression.expression.kind === 178 && + if (callExpression.expression.kind === 179 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -28998,8 +30411,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -29053,9 +30466,8 @@ var ts; if (flags & 16777216) { return strictNullChecks ? 6166480 : 8378320; } - if (flags & 16384) { - var constraint = getConstraintOfTypeParameter(type); - return getTypeFacts(constraint || emptyObjectType); + if (flags & 540672) { + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & 196608) { return getTypeFactsOfTypes(type.types); @@ -29081,22 +30493,22 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, undefined, false) || + checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 177 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 261 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 193 && parent.parent.left === parent || - parent.parent.kind === 215 && parent.parent.initializer === parent; + return parent.parent.kind === 194 && parent.parent.left === parent || + parent.parent.kind === 216 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); @@ -29113,21 +30525,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 214: - return stringType; case 215: - return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 193: + return stringType; + case 216: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; + case 194: return getAssignedTypeOfBinaryExpression(parent); - case 187: + case 188: return undefinedType; - case 176: + case 177: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 197: + case 198: return getAssignedTypeOfSpreadExpression(parent); - case 260: - return getAssignedTypeOfPropertyAssignment(parent); case 261: + return getAssignedTypeOfPropertyAssignment(parent); + case 262: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -29135,7 +30547,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 173 ? + var type = pattern.kind === 174 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -29150,39 +30562,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 214) { + if (node.parent.parent.kind === 215) { return stringType; } - if (node.parent.parent.kind === 215) { - return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; + if (node.parent.parent.kind === 216) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 225 ? + return node.kind === 226 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 225 || node.kind === 175 ? + return node.kind === 226 || node.kind === 176 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 225 && node.initializer && + return node.kind === 226 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 175 && node.parent.kind === 193 && + node.kind !== 176 && node.parent.kind === 194 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 184: + case 185: return getReferenceCandidate(node.expression); - case 193: + case 194: switch (node.operatorToken.kind) { - case 57: + case 58: return getReferenceCandidate(node.left); - case 25: + case 26: return getReferenceCandidate(node.right); } } @@ -29190,13 +30602,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 184 || - parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 185 || + parent.kind === 194 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 194 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 256) { + if (clause.kind === 257) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -29242,8 +30654,29 @@ var ts; } return f(type) ? type : neverType; } - function mapType(type, f) { - return type.flags & 65536 ? getUnionType(ts.map(type.types, f)) : f(type); + function mapType(type, mapper) { + if (!(type.flags & 65536)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -29277,7 +30710,7 @@ var ts; return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); } function addEvolvingArrayElementType(evolvingArrayType, node) { - var elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node)); + var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { @@ -29298,8 +30731,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -29317,12 +30750,12 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || - parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 179 && + var isLengthPushOrUnshift = parent.kind === 179 && (parent.name.text === "length" || + parent.parent.kind === 181 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 180 && parent.expression === root && - parent.parent.kind === 193 && - parent.parent.operatorToken.kind === 57 && + parent.parent.kind === 194 && + parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 340 | 2048); @@ -29336,7 +30769,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 96) { + if (node.expression.kind !== 97) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -29348,19 +30781,17 @@ var ts; } return false; } - function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { + function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { + if (initialType === void 0) { initialType = declaredType; } var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810431)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 203 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -29414,7 +30845,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 178) { + if (container && container !== flowContainer && reference.kind !== 179 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -29457,7 +30888,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 180 ? + var expr = node.kind === 181 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -29465,7 +30896,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 180) { + if (node.kind === 181) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -29589,7 +31020,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 178 && + return expr.kind === 179 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -29614,19 +31045,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 57: + case 58: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 31: case 32: case 33: case 34: + case 35: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 188 && right_1.kind === 9) { + if (left_1.kind === 189 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 188 && left_1.kind === 9) { + if (right_1.kind === 189 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -29645,9 +31076,9 @@ var ts; return declaredType; } break; - case 92: + case 93: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 25: + case 26: return narrowType(type, expr.right, assumeTrue); } return type; @@ -29656,7 +31087,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 32 || operator === 34) { + if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); @@ -29664,10 +31095,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 31 || operator === 32; + var doubleEquals = operator === 32 || operator === 33; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 94 ? + value.kind === 95 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -29693,13 +31124,21 @@ var ts; } return type; } - if (operator === 32 || operator === 34) { + if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { var targetType = typeofTypesByName.get(literal.text); - if (targetType && isTypeSubtypeOf(targetType, type)) { - return targetType; + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } } } var facts = assumeTrue ? @@ -29773,10 +31212,9 @@ var ts; return assignableType; } } - var targetType = type.flags & 16384 ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, targetType) ? candidate : + isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { @@ -29792,7 +31230,7 @@ var ts; return type; } if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + var predicateArgument = callExpression.arguments[predicate.parameterIndex - (signature.thisParameter ? 1 : 0)]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -29804,7 +31242,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { + if (invokedExpression.kind === 180 || invokedExpression.kind === 179) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -29819,18 +31257,19 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 70: - case 98: - case 178: + case 71: + case 99: + case 97: + case 179: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 180: + case 181: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 184: + case 185: return narrowType(type, expr.expression, assumeTrue); - case 193: + case 194: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 191: - if (expr.operator === 50) { + case 192: + if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -29839,7 +31278,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 70) { + if (location.kind === 71) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -29853,15 +31292,12 @@ var ts; return getTypeOfSymbol(symbol); } function getControlFlowContainer(node) { - while (true) { - node = node.parent; - if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 233 || - node.kind === 264 || - node.kind === 148) { - return node; - } - } + return ts.findAncestor(node.parent, function (node) { + return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || + node.kind === 234 || + node.kind === 265 || + node.kind === 149; + }); } function isParameterAssigned(symbol) { var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; @@ -29875,21 +31311,13 @@ var ts; return symbol.isAssigned || false; } function hasParentWithAssignmentsMarked(node) { - while (true) { - node = node.parent; - if (!node) { - return false; - } - if (ts.isFunctionLike(node) && getNodeLinks(node).flags & 4194304) { - return true; - } - } + return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 4194304); }); } function markParameterAssignments(node) { - if (node.kind === 70) { + if (node.kind === 71) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 146) { symbol.isAssigned = true; } } @@ -29901,6 +31329,14 @@ var ts; function isConstVariable(symbol) { return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + function removeOptionalityFromDeclaredType(declaredType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 146 && + declaration.initializer && + getFalsyFlags(declaredType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072) : declaredType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -29909,16 +31345,14 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 186) { + if (container.kind === 187) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 16384) { - getNodeLinks(container).flags |= 8192; - } + getNodeLinks(container).flags |= 8192; return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -29927,7 +31361,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 228 + if (declaration_1.kind === 229 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -29939,11 +31373,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 198) { + else if (declaration_1.kind === 199) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 148 && ts.hasModifier(container, 32)) { + if (container.kind === 149 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -29973,22 +31407,25 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 145; + var isParameter = ts.getRootDeclaration(declaration).kind === 146; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || - flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 186 || + flowContainer.kind === 187 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node) || node.parent.kind === 246) || ts.isInAmbientContext(declaration); - var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, ts.getRootDeclaration(declaration)) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, 2048); + var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } @@ -30002,19 +31439,12 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; + return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 259) { + symbol.valueDeclaration.parent.kind === 260) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -30032,8 +31462,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 213 && - ts.getAncestor(symbol.valueDeclaration, 226).parent === container && + if (container.kind === 214 && + ts.getAncestor(symbol.valueDeclaration, 227).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -30045,33 +31475,25 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 184) { + while (current.parent.kind === 185) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 191 || current.parent.kind === 192)) { + else if ((current.parent.kind === 192 || current.parent.kind === 193)) { var expr = current.parent; - isAssigned = expr.operator === 42 || expr.operator === 43; + isAssigned = expr.operator === 43 || expr.operator === 44; } if (!isAssigned) { return false; } - while (current !== container) { - if (current === container.statement) { - return true; - } - else { - current = current.parent; - } - } - return false; + return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 148 || container.kind === 151) { + if (container.kind === 149 || container.kind === 152) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -30115,32 +31537,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 151) { + if (container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 186) { + if (container.kind === 187) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 232: + case 233: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 231: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 151: + case 152: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 149: case 148: - case 147: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 143: + case 144: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -30149,8 +31571,8 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 185 && - ts.isInJavaScriptFile(container.parent) && + if (container.kind === 186 && + container.parent.kind === 194 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -30169,7 +31591,7 @@ var ts; if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - return getFlowTypeOfReference(node, type, true, undefined); + return getFlowTypeOfReference(node, type); } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); @@ -30177,34 +31599,29 @@ var ts; return type; } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } return anyType; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 278) { + if (jsdocType && jsdocType.kind === 279) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 282) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 145) { - return true; - } - } - return false; + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 146; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 181 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 186) { + while (container && container.kind === 187) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -30212,17 +31629,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = node; - while (current && current !== container && current.kind !== 143) { - current = current.parent; - } - if (current && current.kind === 143) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 144; }); + if (current && current.kind === 144) { 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 === 177)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 178)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -30230,7 +31644,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 151) { + if (!isCallExpression && container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -30240,7 +31654,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 150 && ts.getModifierFlags(container) & 256) { + if (container.kind === 151 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -30251,7 +31665,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 177) { + if (container.parent.kind === 178) { 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; @@ -30269,7 +31683,7 @@ var ts; } return unknownType; } - if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 152 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -30281,32 +31695,50 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 151; + return container.kind === 152; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 177) { + if (ts.isClassLike(container.parent) || container.parent.kind === 178) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 150 || - container.kind === 149 || - container.kind === 152 || - container.kind === 153; + return container.kind === 151 || + container.kind === 150 || + container.kind === 153 || + container.kind === 154; } else { - return container.kind === 150 || - container.kind === 149 || - container.kind === 152 || + return container.kind === 151 || + container.kind === 150 || container.kind === 153 || + container.kind === 154 || + container.kind === 149 || container.kind === 148 || - container.kind === 147 || - container.kind === 151; + container.kind === 152; } } } return false; } } + function getContainingObjectLiteral(func) { + return (func.kind === 151 || + func.kind === 153 || + func.kind === 154) && func.parent.kind === 178 ? func.parent : + func.kind === 186 && func.parent.kind === 261 ? func.parent.parent : + undefined; + } + function getThisTypeArgument(type) { + return getObjectFlags(type) & 4 && type.target === globalThisType ? type.typeArguments[0] : undefined; + } + function getThisTypeFromContextualType(type) { + return mapType(type, function (t) { + return t.flags & 131072 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + }); + } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { + if (func.kind === 187) { + return undefined; + } + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -30315,6 +31747,32 @@ var ts; } } } + if (noImplicitThis) { + var containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + var contextualType = getApparentTypeOfContextualType(containingLiteral); + var literal = containingLiteral; + var type = contextualType; + while (type) { + var thisType = getThisTypeFromContextualType(type); + if (thisType) { + return instantiateType(thisType, getContextualMapper(containingLiteral)); + } + if (literal.parent.kind !== 261) { + break; + } + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); + } + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); + } + if (func.parent.kind === 194 && func.parent.operatorToken.kind === 58) { + var target = func.parent.left; + if (target.kind === 179 || target.kind === 180) { + return checkExpressionCached(target.expression); + } + } + } return undefined; } function getContextuallyTypedParameterType(parameter) { @@ -30362,7 +31820,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 145) { + if (declaration.kind === 146) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -30374,7 +31832,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (ts.isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== 176 && parentDeclaration.type && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -30388,33 +31846,34 @@ var ts; } function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); - if (ts.isAsyncFunctionLike(func)) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getPromisedType(contextualReturnType); + if (func) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1) { + return undefined; } - return undefined; - } - if (func && !func.asteriskToken) { - return getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func); + return functionFlags & 2 + ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) + : contextualReturnType; } return undefined; } function getContextualTypeForYieldOperand(node) { var func = ts.getContainingFunction(node); if (func) { + var functionFlags = ts.getFunctionFlags(func); var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); + : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & 2) !== 0); } } return undefined; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 145 && node.parent.initializer === node) { + if (node.parent.kind === 146 && node.parent.initializer === node) { return true; } node = node.parent; @@ -30423,8 +31882,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 151 || - functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { + functionDecl.kind === 152 || + functionDecl.kind === 153 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 154))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -30443,7 +31902,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 182) { + if (template.parent.kind === 183) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -30451,7 +31910,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 57 && operator <= 69) { + if (operator >= 58 && operator <= 70) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -30459,52 +31918,28 @@ var ts; return getTypeOfExpression(binaryExpression.left); } } - else if (operator === 53) { + else if (operator === 54) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = getTypeOfExpression(binaryExpression.left); } return type; } - else if (operator === 52 || operator === 25) { + else if (operator === 53 || operator === 26) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } } return undefined; } - function applyToContextualType(type, mapper) { - if (!(type.flags & 65536)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { + return mapType(type, function (t) { var prop = t.flags & 229376 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 65536 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); @@ -30539,7 +31974,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1) - || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); + || getIteratedTypeOrElementType(type, undefined, false, false, false); } return undefined; } @@ -30547,6 +31982,25 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(node) { + var jsxAttributes = ts.isJsxAttributeLike(node.parent) ? + node.parent.parent : + node.parent.openingElement.attributes; + var attributesType = getContextualType(jsxAttributes); + if (!attributesType || isTypeAny(attributesType)) { + return undefined; + } + if (ts.isJsxAttribute(node.parent)) { + return getTypeOfPropertyOfType(attributesType, node.parent.name.text); + } + else if (node.parent.kind === 249) { + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + } + else { + return attributesType; + } + } function getContextualTypeForJsxAttribute(attribute) { var attributesType = getContextualType(attribute.parent); if (ts.isJsxAttribute(attribute)) { @@ -30572,48 +32026,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 225: - case 145: + case 226: + case 146: + case 149: case 148: - case 147: - case 175: - return getContextualTypeForInitializerExpression(node); - case 186: - case 218: - return getContextualTypeForReturnExpression(node); - case 196: - return getContextualTypeForYieldOperand(parent); - case 180: - case 181: - return getContextualTypeForArgument(parent, node); - case 183: - case 201: - return getTypeFromTypeNode(parent.type); - case 193: - return getContextualTypeForBinaryOperand(node); - case 260: - case 261: - return getContextualTypeForObjectLiteralElement(parent); case 176: - return getContextualTypeForElementExpression(node); - case 194: - return getContextualTypeForConditionalOperand(node); - case 204: - ts.Debug.assert(parent.parent.kind === 195); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 187: + case 219: + return getContextualTypeForReturnExpression(node); + case 197: + return getContextualTypeForYieldOperand(parent); + case 181: + case 182: + return getContextualTypeForArgument(parent, node); case 184: + case 202: + return getTypeFromTypeNode(parent.type); + case 194: + return getContextualTypeForBinaryOperand(node); + case 261: + case 262: + return getContextualTypeForObjectLiteralElement(parent); + case 263: + return getApparentTypeOfContextualType(parent.parent); + case 177: + return getContextualTypeForElementExpression(node); + case 195: + return getContextualTypeForConditionalOperand(node); + case 205: + ts.Debug.assert(parent.parent.kind === 196); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 185: return getContextualType(parent); + case 256: + return getContextualTypeForJsxExpression(parent); + case 253: case 255: - return getContextualType(parent); - case 252: - case 254: return getContextualTypeForJsxAttribute(parent); + case 251: case 250: - case 249: return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } + function getContextualMapper(node) { + node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return node ? node.contextualMapper : identityMapper; + } function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { @@ -30638,7 +32098,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 185 || node.kind === 186; + return node.kind === 186 || node.kind === 187; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -30651,7 +32111,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -30661,8 +32121,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var current = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var current = types_17[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -30684,37 +32144,37 @@ var ts; } return result; } - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function checkSpreadExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpression(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + function checkSpreadExpression(node, checkMode) { + if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 1536); + } + var arrayOrIterableType = checkExpression(node.expression, checkMode); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 175 && !!node.initializer) || - (node.kind === 193 && node.operatorToken.kind === 57); + return (node.kind === 176 && !!node.initializer) || + (node.kind === 194 && node.operatorToken.kind === 58); } - function checkArrayLiteral(node, contextualMapper) { + function checkArrayLiteral(node, checkMode) { var elements = node.elements; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 197) { - var restArrayType = checkExpression(e.expression, contextualMapper); + if (inDestructuringPattern && e.kind === 198) { + var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || - (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); if (restElementType) { elementTypes.push(restElementType); } } else { - var type = checkExpressionForMutableLocation(e, contextualMapper); + var type = checkExpressionForMutableLocation(e, checkMode); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 197; + hasSpreadElement = hasSpreadElement || e.kind === 198; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -30725,7 +32185,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { + if (pattern && (pattern.kind === 175 || pattern.kind === 177)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -30733,7 +32193,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 199) { + if (patternElement.kind !== 200) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -30750,7 +32210,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 144 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -30787,7 +32247,7 @@ var ts; var unionType = propTypes.length ? getUnionType(propTypes, true) : undefinedType; return createIndexInfo(unionType, false); } - function checkObjectLiteral(node, contextualMapper) { + function checkObjectLiteral(node, checkMode) { var inDestructuringPattern = ts.isAssignmentTarget(node); checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); @@ -30796,7 +32256,8 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); + (contextualType.pattern.kind === 174 || contextualType.pattern.kind === 178); + var isJSObjectLiteral = !contextualType && ts.isInJavaScriptFile(node); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -30805,25 +32266,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 260 || - memberDecl.kind === 261 || + if (memberDecl.kind === 261 || + memberDecl.kind === 262 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 260) { - type = checkPropertyAssignment(memberDecl, contextualMapper); + if (memberDecl.kind === 261) { + type = checkPropertyAssignment(memberDecl, checkMode); } - else if (memberDecl.kind === 150) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); + else if (memberDecl.kind === 151) { + type = checkObjectLiteralMethod(memberDecl, checkMode); } else { - ts.Debug.assert(memberDecl.kind === 261); - type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 262); + type = checkExpressionForMutableLocation(memberDecl.name, checkMode); } typeFlags |= type.flags; var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 261 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 262 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 67108864; } @@ -30849,7 +32310,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 262) { + else if (memberDecl.kind === 263) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -30871,8 +32332,8 @@ var ts; continue; } else { - ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); - checkAccessorDeclaration(memberDecl); + ts.Debug.assert(memberDecl.kind === 153 || memberDecl.kind === 154); + checkNodeDeferred(memberDecl); } if (ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { @@ -30911,8 +32372,8 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; + var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); @@ -30936,7 +32397,7 @@ var ts; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function checkJsxElement(node) { checkJsxOpeningLikeElement(node.openingElement); @@ -30946,34 +32407,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 255: - checkJsxExpression(child); - break; - case 248: - checkJsxElement(child); - break; - case 249: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function isUnhyphenatedJsxName(name) { return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 178 || tagName.kind === 98) { + if (tagName.kind === 179 || tagName.kind === 99) { return false; } else { return ts.isIntrinsicJsxName(tagName.text); } } - function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createMap(); var spread = emptyObjectType; @@ -30983,7 +32430,7 @@ var ts; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = attributeDecl.initializer ? - checkExpression(attributeDecl.initializer, contextualMapper) : + checkExpression(attributeDecl.initializer, checkMode) : trueType; var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); attributeSymbol.declarations = member.declarations; @@ -30997,14 +32444,14 @@ var ts; attributesArray.push(attributeSymbol); } else { - ts.Debug.assert(attributeDecl.kind === 254); + ts.Debug.assert(attributeDecl.kind === 255); if (attributesArray.length > 0) { spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = ts.createMap(); } var exprType = checkExpression(attributeDecl.expression); - if (!(exprType.flags & (32768 | 1))) { + if (!isValidSpreadType(exprType)) { error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return anyType; } @@ -31030,6 +32477,32 @@ var ts; } }); } + var parent = openingLikeElement.parent.kind === 249 ? openingLikeElement.parent : undefined; + if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { + var childrenTypes = []; + for (var _b = 0, _c = parent.children; _b < _c.length; _b++) { + var child = _c[_b]; + if (child.kind === 10) { + if (!child.containsOnlyWhiteSpaces) { + childrenTypes.push(stringType); + } + } + else { + childrenTypes.push(checkExpression(child, checkMode)); + } + } + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { + if (attributesTable.has(jsxChildrenPropertyName)) { + error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); + } + var childrenPropSymbol = createSymbol(4 | 134217728, jsxChildrenPropertyName); + childrenPropSymbol.type = childrenTypes.length === 1 ? + childrenTypes[0] : + createArrayType(getUnionType(childrenTypes, false)); + attributesTable.set(jsxChildrenPropertyName, childrenPropSymbol); + } + } return createJsxAttributesType(attributes.symbol, attributesTable); function createJsxAttributesType(symbol, attributesTable) { var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); @@ -31039,8 +32512,8 @@ var ts; return result; } } - function checkJsxAttributes(node, contextualMapper) { - return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); + function checkJsxAttributes(node, checkMode) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, checkMode); } function getJsxType(name) { var jsxType = jsxTypes.get(name); @@ -31068,7 +32541,7 @@ var ts; return links.resolvedSymbol = unknownSymbol; } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } return links.resolvedSymbol = unknownSymbol; @@ -31091,36 +32564,48 @@ var ts; } return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } - function getJsxElementPropertiesName() { + function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer) { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793064); - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - if (attribProperties.length === 0) { + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 793064); + var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); + var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); + if (propertiesOfJsxElementAttribPropInterface) { + if (propertiesOfJsxElementAttribPropInterface.length === 0) { return ""; } - else if (attribProperties.length === 1) { - return attribProperties[0].name; + else if (propertiesOfJsxElementAttribPropInterface.length === 1) { + return propertiesOfJsxElementAttribPropInterface[0].name; } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; + else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, nameOfAttribPropContainer); } } - else { - return undefined; + return undefined; + } + function getJsxElementPropertiesName() { + if (!_hasComputedJsxElementPropertiesName) { + _hasComputedJsxElementPropertiesName = true; + _jsxElementPropertiesName = getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer); } + return _jsxElementPropertiesName; + } + function getJsxElementChildrenPropertyname() { + if (!_hasComputedJsxElementChildrenPropertyName) { + _hasComputedJsxElementChildrenPropertyName = true; + _jsxElementChildrenPropertyName = getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer); + } + return _jsxElementChildrenPropertyName; } function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); if (callSignature !== unknownSignature) { var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { paramType = intersectTypes(intrinsicAttributes, paramType); @@ -31135,7 +32620,8 @@ var ts; function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { var candidatesOutArray = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); var result = void 0; @@ -31144,7 +32630,7 @@ var ts; var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var shouldBeCandidate = true; for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { var attribute = _b[_a]; @@ -31230,10 +32716,6 @@ var ts; else if (isTypeAny(attributesType) || (attributesType === unknownType)) { return attributesType; } - else if (attributesType.flags & 65536) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); - return anyType; - } else { var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes); @@ -31303,10 +32785,25 @@ var ts; return prop || unknownSymbol; } function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + if (!deferredJsxElementClassType) { + deferredJsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } - return jsxElementClassType; + return deferredJsxElementClassType; + } + function getJsxGlobalElementType() { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + function getJsxGlobalStatelessElementType() { + if (!deferredJsxStatelessElementType) { + var jsxElementType = getJsxGlobalElementType(); + if (jsxElementType) { + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; } function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); @@ -31316,8 +32813,8 @@ var ts; if ((compilerOptions.jsx || 0) === 0) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { + if (getJsxGlobalElementType() === undefined) { + if (noImplicitAny) { error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -31350,9 +32847,9 @@ var ts; checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node, contextualMapper) { + function checkJsxExpression(node, checkMode) { if (node.expression) { - var type = checkExpression(node.expression, contextualMapper); + var type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -31363,19 +32860,19 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 148; + return s.valueDeclaration ? s.valueDeclaration.kind : 149; } function getDeclarationModifierFlagsFromSymbol(s) { if (s.valueDeclaration) { var flags = ts.getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & 32 ? flags : flags & ~28; } - if (getCheckFlags(s) & 2) { + if (getCheckFlags(s) & 6) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 128 ? 8 : - checkFlags & 32 ? 4 : + var accessModifier = checkFlags & 256 ? 8 : + checkFlags & 64 ? 4 : 16; - var staticModifier = checkFlags & 256 ? 32 : 0; + var staticModifier = checkFlags & 512 ? 32 : 0; return accessModifier | staticModifier; } if (s.flags & 16777216) { @@ -31386,19 +32883,25 @@ var ts; function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol) { + return !!(symbol.flags & 8192 || getCheckFlags(symbol) & 4); + } function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 178 || node.kind === 225 ? + var errorNode = node.kind === 179 || node.kind === 226 ? node.name : node.right; - if (getCheckFlags(prop) & 128) { + if (getCheckFlags(prop) & 256) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; } - if (left.kind === 96) { + if (left.kind === 97) { if (languageVersion < 2) { - var propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== 150 && propKind !== 149) { + var hasNonMethodDeclaration = forEachProperty(prop, function (p) { + var propKind = getDeclarationKindFromSymbol(p); + return propKind !== 151 && propKind !== 150; + }); + if (hasNonMethodDeclaration) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -31419,7 +32922,7 @@ var ts; } return true; } - if (left.kind === 96) { + if (left.kind === 97) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -31492,7 +32995,7 @@ var ts; } function isInPropertyInitializer(node) { while (node) { - if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + if (node.parent && node.parent.kind === 149 && node.parent.initializer === node) { return true; } node = node.parent; @@ -31519,10 +33022,17 @@ var ts; } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === 229 && + node.parent && node.parent.kind !== 159 && + !ts.isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; @@ -31535,16 +33045,16 @@ var ts; return unknownType; } } - if (node.kind !== 178 || assignmentKind === 1 || + if (node.kind !== 179 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - var flowType = getFlowTypeOfReference(node, propType, true, undefined); + var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 178 + var left = node.kind === 179 ? node.expression : node.left; var type = checkExpression(left); @@ -31558,13 +33068,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 226) { + if (initializer.kind === 227) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 70) { + else if (initializer.kind === 71) { return getResolvedSymbol(initializer); } return undefined; @@ -31574,13 +33084,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 70) { + if (e.kind === 71) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 214 && + if (node.kind === 215 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -31598,7 +33108,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 181 && node.parent.expression === node) { + if (node.parent.kind === 182 && 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); @@ -31638,7 +33148,7 @@ var ts; if (!leftHandSideSymbol) { return false; } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + var globalESSymbol = getGlobalESSymbolConstructorSymbol(true); if (!globalESSymbol) { return false; } @@ -31651,10 +33161,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 182) { + if (node.kind === 183) { checkExpression(node.template); } - else if (node.kind !== 146) { + else if (node.kind !== 147) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -31673,8 +33183,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var signature = signatures_2[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -31705,7 +33215,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 197) { + if (arg && arg.kind === 198) { return i; } } @@ -31721,11 +33231,11 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 182) { + if (node.kind === 183) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 195) { + if (tagExpression.template.kind === 196) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -31733,11 +33243,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 12); + ts.Debug.assert(templateLiteral.kind === 13); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 146) { + else if (node.kind === 147) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -31745,7 +33255,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 181); + ts.Debug.assert(callExpression.kind === 182); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -31780,7 +33290,7 @@ var ts; return undefined; } function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, true); + var context = createInferenceContext(signature, true, false); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { inferTypesWithContext(context, instantiateType(source, contextualMapper), target); }); @@ -31806,7 +33316,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 !== 199) { + if (arg === undefined || arg.kind !== 200) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31873,7 +33383,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 181) { + if (thisType && thisType !== voidType && node.kind !== 182) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -31886,7 +33396,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 !== 199) { + if (arg === undefined || arg.kind !== 200) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -31901,28 +33411,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 180) { + if (node.kind === 181) { var callee = node.expression; - if (callee.kind === 178) { + if (callee.kind === 179) { return callee.expression; } - else if (callee.kind === 179) { + else if (callee.kind === 180) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 182) { + if (node.kind === 183) { var template = node.template; args = [undefined]; - if (template.kind === 195) { + if (template.kind === 196) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 146) { + else if (node.kind === 147) { return undefined; } else if (ts.isJsxOpeningLikeElement(node)) { @@ -31934,21 +33444,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 146) { + if (node.kind === 147) { switch (node.parent.kind) { - case 228: - case 198: + case 229: + case 199: return 1; - case 148: + case 149: return 2; - case 150: - case 152: + case 151: case 153: + case 154: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 145: + case 146: return 3; } } @@ -31957,48 +33467,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 145) { + if (node.kind === 146) { node = node.parent; - if (node.kind === 151) { + if (node.kind === 152) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 153 || + node.kind === 154) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 145) { + if (node.kind === 146) { node = node.parent; - if (node.kind === 151) { + if (node.kind === 152) { return anyType; } } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 153 || + node.kind === 154) { var element = node; switch (element.name.kind) { - case 70: + case 71: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 143: + case 144: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -32015,20 +33525,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 145) { + if (node.kind === 146) { return numberType; } - if (node.kind === 148) { + if (node.kind === 149) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 151 || + node.kind === 153 || + node.kind === 154) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -32049,26 +33559,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 146) { + if (node.kind === 147) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 182) { + else if (argIndex === 0 && node.kind === 183) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 146 || - (argIndex === 0 && node.kind === 182)) { + if (node.kind === 147 || + (argIndex === 0 && node.kind === 183)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 146) { + if (node.kind === 147) { return node.expression; } - else if (argIndex === 0 && node.kind === 182) { + else if (argIndex === 0 && node.kind === 183) { return node.template; } else { @@ -32076,16 +33586,30 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 182; - var isDecorator = node.kind === 146; + var isTaggedTemplate = node.kind === 183; + var isDecorator = node.kind === 147; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; - if (node.expression.kind !== 96) { + if (node.expression.kind !== 97) { ts.forEach(typeArguments, checkSourceElement); } } + if (signatures.length === 1) { + var declaration = signatures[0].declaration; + if (declaration && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration)) { + if (containsArgumentsReference(declaration)) { + var signatureWithRest = cloneSignature(signatures[0]); + var syntheticArgsSymbol = createSymbol(3, "args"); + syntheticArgsSymbol.type = anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + signatureWithRest.parameters = ts.concatenate(signatureWithRest.parameters, [syntheticArgsSymbol]); + signatureWithRest.hasRestParameter = true; + signatures = [signatureWithRest]; + } + } + } var candidates = candidatesOutArray || []; reorderCandidates(signatures, candidates); if (!candidates.length) { @@ -32108,7 +33632,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 181 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -32176,7 +33700,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, false) + ? createInferenceContext(originalCandidate, false, ts.isInJavaScriptFile(node)) : undefined; while (true) { candidate = originalCandidate; @@ -32226,12 +33750,12 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -32380,16 +33904,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 228: - case 198: + case 229: + case 199: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 148: + case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 150: - case 152: + case 151: case 153: + case 154: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -32423,8 +33947,8 @@ var ts; if (elementType.flags & 65536) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var type = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var type = types_18[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -32439,16 +33963,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 180: - return resolveCallExpression(node, candidatesOutArray); case 181: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 182: + return resolveNewExpression(node, candidatesOutArray); + case 183: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 146: + case 147: return resolveDecorator(node, candidatesOutArray); + case 251: case 250: - case 249: return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -32477,23 +34001,26 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { return voidType; } - if (node.kind === 181) { + if (node.kind === 182) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 151 && - declaration.kind !== 155 && - declaration.kind !== 160 && + declaration.kind !== 152 && + declaration.kind !== 156 && + declaration.kind !== 161 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 70 ? + var funcSymbol = node.expression.kind === 71 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { + funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + } + if (funcSymbol && funcSymbol.members && funcSymbol.flags & 16) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -32516,9 +34043,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 227 + ? 228 : resolvedRequire.flags & 3 - ? 225 + ? 226 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -32546,13 +34073,12 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 151) { + else if (container.kind === 152) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -32576,9 +34102,12 @@ var ts; pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; } - function assignContextualParameterTypes(signature, context, mapper) { + function getTypeOfFirstParameterOfSignature(signature) { + return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + } + function assignContextualParameterTypes(signature, context, mapper, checkMode) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - if (isInferentialContext(mapper)) { + if (checkMode === 2) { for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -32592,21 +34121,21 @@ var ts; if (!parameter) { signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper, checkMode); } } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } } @@ -32615,7 +34144,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 70) { + if (element.name.kind === 71) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -32623,18 +34152,18 @@ var ts; } } } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper, checkMode) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 173 || - parameter.valueDeclaration.name.kind === 174)) { + (parameter.valueDeclaration.name.kind === 174 || + parameter.valueDeclaration.name.kind === 175)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); } - else if (isInferentialContext(mapper)) { + else if (checkMode === 2) { inferTypesWithContext(mapper.context, links.type, instantiateType(contextualType, mapper)); } } @@ -32646,9 +34175,9 @@ var ts; return undefined; } function createPromiseType(promisedType) { - var globalPromiseType = getGlobalPromiseType(); + var globalPromiseType = getGlobalPromiseType(true); if (globalPromiseType !== emptyGenericType) { - promisedType = getAwaitedType(promisedType); + promisedType = getAwaitedType(promisedType) || emptyObjectType; return createTypeReference(globalPromiseType, [promisedType]); } return emptyObjectType; @@ -32659,49 +34188,56 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } - else if (!getGlobalPromiseConstructorSymbol()) { + else if (!getGlobalPromiseConstructorSymbol(true)) { error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } return promiseType; } - function getReturnTypeFromBody(func, contextualMapper) { + function getReturnTypeFromBody(func, checkMode) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } - var isAsync = ts.isAsyncFunctionLike(func); + var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 206) { - 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); + if (func.body.kind !== 207) { + type = checkExpressionCached(func.body, checkMode); + if (functionFlags & 2) { + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } } else { var types = void 0; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { + if (functionFlags & 1) { + types = ts.concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode)); + if (!types || types.length === 0) { + var iterableIteratorAny = functionFlags & 2 + ? createAsyncIterableIteratorType(anyType) + : createIterableIteratorType(anyType); + if (noImplicitAny) { error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); } return iterableIteratorAny; } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { - return isAsync ? createPromiseReturnType(func, neverType) : neverType; + return functionFlags & 2 + ? createPromiseReturnType(func, neverType) + : neverType; } if (types.length === 0) { - return isAsync ? createPromiseReturnType(func, voidType) : voidType; + return functionFlags & 2 + ? createPromiseReturnType(func, voidType) + : voidType; } } type = getUnionType(types, true); - if (funcIsGenerator) { - type = createIterableIteratorType(type); + if (functionFlags & 1) { + type = functionFlags & 2 + ? createAsyncIterableIteratorType(type) + : createIterableIteratorType(type); } } if (!contextualSignature) { @@ -32713,16 +34249,24 @@ var ts; type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); - return isAsync ? createPromiseReturnType(func, widenedType) : widenedType; + return (functionFlags & 3) === 2 + ? createPromiseReturnType(func, widenedType) + : widenedType; } - function checkAndAggregateYieldOperandTypes(func, contextualMapper) { + function checkAndAggregateYieldOperandTypes(func, checkMode) { var aggregatedTypes = []; + var functionFlags = ts.getFunctionFlags(func); ts.forEachYieldExpression(func.body, function (yieldExpression) { var expr = yieldExpression.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); + var type = checkExpressionCached(expr, checkMode); if (yieldExpression.asteriskToken) { - type = checkElementTypeOfIterable(type, yieldExpression.expression); + type = checkIteratedTypeOrElementType(type, yieldExpression.expression, false, (functionFlags & 2) !== 0); + } + if (functionFlags & 2) { + type = checkAwaitedType(type, expr, yieldExpression.asteriskToken + ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); @@ -32750,22 +34294,22 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 221 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; } - function checkAndAggregateReturnExpressionTypes(func, contextualMapper) { - var isAsync = ts.isAsyncFunctionLike(func); + function checkAndAggregateReturnExpressionTypes(func, checkMode) { + var functionFlags = ts.getFunctionFlags(func); var aggregatedTypes = []; var hasReturnWithNoExpression = functionHasImplicitReturn(func); var hasReturnOfTypeNever = false; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var type = checkExpressionCached(expr, checkMode); + if (functionFlags & 2) { + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (type.flags & 8192) { hasReturnOfTypeNever = true; @@ -32779,7 +34323,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 185 || func.kind === 186)) { + func.kind === 186 || func.kind === 187)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -32796,7 +34340,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 207 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -32822,20 +34366,20 @@ var ts; error(func.type || func, ts.Diagnostics.Not_all_code_paths_return_a_value); } } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 185) { + if (!hasGrammarError && node.kind === 186) { checkGrammarForGenerator(node); } - if (contextualMapper === identityMapper && isContextSensitive(node)) { + if (checkMode === 1 && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + var mightFixTypeParameters = contextSensitive && checkMode === 2; if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); var contextChecked = !!(links.flags & 1024); @@ -32844,10 +34388,10 @@ var ts; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + assignContextualParameterTypes(signature, contextualSignature, getContextualMapper(node), checkMode); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); + var returnType = getReturnTypeFromBody(node, checkMode); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -32859,7 +34403,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 150) { + if (produceDiagnostics && node.kind !== 151) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -32867,24 +34411,27 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); + var functionFlags = ts.getFunctionFlags(node); + var returnOrPromisedType = node.type && + ((functionFlags & 3) === 2 ? + checkAsyncFunctionReturnType(node) : + getTypeFromTypeNode(node.type)); + if ((functionFlags & 1) === 0) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (node.body) { if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 206) { + if (node.body.kind === 207) { checkSourceElement(node.body); } else { var exprType = checkExpression(node.body); if (returnOrPromisedType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + if ((functionFlags & 3) === 2) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } else { @@ -32903,7 +34450,7 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return !!(getCheckFlags(symbol) & 4 || + return !!(getCheckFlags(symbol) & 8 || symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || @@ -32912,10 +34459,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 178 || expr.kind === 179) && - expr.expression.kind === 98) { + (expr.kind === 179 || expr.kind === 180) && + expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 151)) + if (!(func && func.kind === 152)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -32924,13 +34471,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 178 || expr.kind === 179) { + if (expr.kind === 179 || expr.kind === 180) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 70) { + if (node.kind === 71) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 239; + return declaration && declaration.kind === 240; } } } @@ -32938,7 +34485,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { + if (node.kind !== 71 && node.kind !== 179 && node.kind !== 180) { error(expr, invalidReferenceMessage); return false; } @@ -32947,7 +34494,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 178 && expr.kind !== 179) { + if (expr.kind !== 179 && expr.kind !== 180) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -32976,32 +34523,32 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); + return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 37 && node.operand.kind === 8) { + if (node.operator === 38 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 36: case 37: - case 51: + case 38: + case 52: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 50: + case 51: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 42: case 43: + case 44: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -33027,8 +34574,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -33042,8 +34589,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -33052,8 +34599,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { - var t = types_20[_a]; + for (var _a = 0, types_21 = types; _a < types_21.length; _a++) { + var t = types_21[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -33091,23 +34638,23 @@ var ts; if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 260 || property.kind === 261) { + if (property.kind === 261 || property.kind === 262) { var name = property.name; - if (name.kind === 143) { + if (name.kind === 144) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -33120,7 +34667,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 261) { + if (property.kind === 262) { return checkDestructuringAssignment(property, type); } else { @@ -33131,7 +34678,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 262) { + else if (property.kind === 263) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -33148,19 +34695,22 @@ var ts; error(property, ts.Diagnostics.Property_assignment_expected); } } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + function checkArrayLiteralAssignment(node, sourceType, checkMode) { + if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512); + } + var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } return sourceType; } - function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { + function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 199) { - if (element.kind !== 197) { + if (element.kind !== 200) { + if (element.kind !== 198) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -33168,7 +34718,7 @@ var ts; ? getTypeOfPropertyOfType(sourceType, propName) : elementType; if (type) { - return checkDestructuringAssignment(element, type, contextualMapper); + return checkDestructuringAssignment(element, type, checkMode); } else { checkExpression(element); @@ -33186,48 +34736,48 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 194 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { - return checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); } } } } return undefined; } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 261) { + if (exprOrAssignment.kind === 262) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 2048)) { sourceType = getTypeWithFacts(sourceType, 131072); } - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } target = exprOrAssignment.name; } else { target = exprOrAssignment; } - if (target.kind === 193 && target.operatorToken.kind === 57) { - checkBinaryExpression(target, contextualMapper); + if (target.kind === 194 && target.operatorToken.kind === 58) { + checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 177) { + if (target.kind === 178) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 176) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 177) { + return checkArrayLiteralAssignment(target, sourceType, checkMode); } - return checkReferenceAssignment(target, sourceType, contextualMapper); + return checkReferenceAssignment(target, sourceType, checkMode); } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 262 ? + function checkReferenceAssignment(target, sourceType, checkMode) { + var targetType = checkExpression(target, checkMode); + var error = target.parent.kind === 263 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -33238,49 +34788,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 70: + case 71: case 9: - case 11: - case 182: - case 195: case 12: + case 183: + case 196: + case 13: case 8: - case 100: - case 85: - case 94: - case 138: - case 185: - case 198: + case 101: + case 86: + case 95: + case 139: case 186: - case 176: + case 199: + case 187: case 177: - case 188: - case 202: + case 178: + case 189: + case 203: + case 250: case 249: - case 248: return true; - case 194: + case 195: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 193: + case 194: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 191: case 192: + case 193: switch (node.operator) { - case 50: - case 36: - case 37: case 51: + case 37: + case 38: + case 52: return true; } return false; - case 189: - case 183: - case 201: + case 190: + case 184: + case 202: default: return false; } @@ -33295,39 +34845,39 @@ var ts; firstAssignableToSecond && !secondAssignableToFirst ? type2 : getUnionType([type1, type2], true); } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + function checkBinaryExpression(node, checkMode) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 177 || left.kind === 176)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + if (operator === 58 && (left.kind === 178 || left.kind === 177)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); + var leftType = checkExpression(left, checkMode); + var rightType = checkExpression(right, checkMode); switch (operator) { - case 38: case 39: - case 60: - case 61: case 40: + case 61: case 62: case 41: case 63: - case 37: - case 59: - case 44: + case 42: case 64: + case 38: + case 60: case 45: case 65: case 46: case 66: - case 48: - case 68: - case 49: - case 69: case 47: case 67: + case 49: + case 69: + case 50: + case 70: + case 48: + case 68: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -33347,8 +34897,8 @@ var ts; } } return numberType; - case 36: - case 58: + case 37: + case 59: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -33375,14 +34925,14 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 58) { + if (operator === 59) { checkAssignmentOperator(resultType); } return resultType; - case 26: - case 28: + case 27: case 29: case 30: + case 31: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -33391,10 +34941,10 @@ var ts; } } return booleanType; - case 31: case 32: case 33: case 34: + case 35: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -33405,27 +34955,30 @@ var ts; reportOperatorError(); } return booleanType; - case 92: + case 93: return checkInstanceOfExpression(left, right, leftType, rightType); - case 91: + case 92: return checkInExpression(left, right, leftType, rightType); - case 52: + case 53: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 53: + case 54: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 57: + case 58: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 25: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { + case 26: + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; } + function isEvalNode(node) { + return node.kind === 71 && node.text === "eval"; + } function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 512) ? left : maybeTypeOfKind(rightType, 512) ? right : @@ -33438,21 +34991,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 49: + case 69: + return 54; + case 50: + case 70: + return 35; case 48: case 68: return 53; - case 49: - case 69: - return 34; - case 47: - case 67: - return 52; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 57 && operator <= 69) { + if (produceDiagnostics && operator >= 58 && operator <= 70) { if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(valueType, leftType, left, undefined); } @@ -33488,30 +35041,45 @@ var ts; } if (node.expression) { var func = ts.getContainingFunction(node); - if (func && func.asteriskToken) { + var functionFlags = func && ts.getFunctionFlags(func); + if (node.asteriskToken) { + if (functionFlags & 2) { + if (languageVersion < 4) { + checkExternalEmitHelpers(node, 4096); + } + } + else if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256); + } + } + if (functionFlags & 1) { var expressionType = checkExpressionCached(node.expression, undefined); var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + expressionElementType = checkIteratedTypeOrElementType(expressionType, node.expression, false, (functionFlags & 2) !== 0); } if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(func.type), (functionFlags & 2) !== 0) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(functionFlags & 2 + ? getAwaitedType(expressionElementType, node.expression, ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionElementType, signatureElementType, node.expression, undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(functionFlags & 2 + ? getAwaitedType(expressionType, node.expression, ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionType, signatureElementType, node.expression, undefined); } } } } return anyType; } - function checkConditionalExpression(node, contextualMapper) { + function checkConditionalExpression(node, checkMode) { checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); + var type1 = checkExpression(node.whenTrue, checkMode); + var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { @@ -33523,9 +35091,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 100: + case 101: return trueType; - case 85: + case 86: return falseType; } } @@ -33537,27 +35105,32 @@ var ts; } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; + var saveContextualMapper = node.contextualMapper; node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); + node.contextualMapper = contextualMapper; + var checkMode = contextualMapper === identityMapper ? 1 : + contextualMapper ? 2 : 0; + var result = checkExpression(node, checkMode); node.contextualType = saveContextualType; + node.contextualMapper = saveContextualMapper; return result; } - function checkExpressionCached(node, contextualMapper) { + function checkExpressionCached(node, checkMode) { var links = getNodeLinks(node); if (!links.resolvedType) { var saveFlowLoopStart = flowLoopStart; flowLoopStart = flowLoopCount; - links.resolvedType = checkExpression(node, contextualMapper); + links.resolvedType = checkExpression(node, checkMode); flowLoopStart = saveFlowLoopStart; } return links.resolvedType; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 183 || node.kind === 201; + return node.kind === 184 || node.kind === 202; } function checkDeclarationInitializer(declaration) { - var type = checkExpressionCached(declaration.initializer); + var type = getTypeOfExpression(declaration.initializer, true); return ts.getCombinedNodeFlags(declaration) & 2 || ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -33575,147 +35148,154 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, contextualMapper) { - var type = checkExpression(node, contextualMapper); + function checkExpressionForMutableLocation(node, checkMode) { + var type = checkExpression(node, checkMode); return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } - function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 143) { + function checkPropertyAssignment(node, checkMode) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } - return checkExpressionForMutableLocation(node.initializer, contextualMapper); + return checkExpressionForMutableLocation(node.initializer, checkMode); } - function checkObjectLiteralMethod(node, contextualMapper) { + function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { + function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { + if (checkMode === 2) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getApparentTypeOfContextualType(node); if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, getContextualMapper(node))); } } } } return type; } - function getTypeOfExpression(node) { - if (node.kind === 180 && node.expression.kind !== 96) { + function getTypeOfExpression(node, cache) { + if (node.kind === 181 && node.expression.kind !== 97 && !ts.isRequireCall(node, true)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); } - function checkExpression(node, contextualMapper) { + function getContextFreeTypeOfExpression(node) { + var saveContextualType = node.contextualType; + node.contextualType = anyType; + var type = getTypeOfExpression(node); + node.contextualType = saveContextualType; + return type; + } + function checkExpression(node, checkMode) { var type; - if (node.kind === 142) { + if (node.kind === 143) { type = checkQualifiedName(node); } else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkExpressionWorker(node, checkMode); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 178 && node.parent.expression === node) || - (node.parent.kind === 179 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 142) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 179 && node.parent.expression === node) || + (node.parent.kind === 180 && node.parent.expression === node) || + ((node.kind === 71 || node.kind === 143) && 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); } } return type; } - function checkExpressionWorker(node, contextualMapper) { + function checkExpressionWorker(node, checkMode) { switch (node.kind) { - case 70: + case 71: return checkIdentifier(node); - case 98: + case 99: return checkThisExpression(node); - case 96: + case 97: return checkSuperExpression(node); - case 94: + case 95: return nullWideningType; case 9: case 8: - case 100: - case 85: + case 101: + case 86: return checkLiteralExpression(node); - case 195: - return checkTemplateExpression(node); - case 12: - return stringType; - case 11: - return globalRegExpType; - case 176: - return checkArrayLiteral(node, contextualMapper); - case 177: - return checkObjectLiteral(node, contextualMapper); - case 178: - return checkPropertyAccessExpression(node); - case 179: - return checkIndexedAccess(node); - case 180: - case 181: - return checkCallExpression(node); - case 182: - return checkTaggedTemplateExpression(node); - case 184: - return checkExpression(node.expression, contextualMapper); - case 198: - return checkClassExpression(node); - case 185: - case 186: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 188: - return checkTypeOfExpression(node); - case 183: - case 201: - return checkAssertion(node); - case 202: - return checkNonNullAssertion(node); - case 203: - return checkMetaProperty(node); - case 187: - return checkDeleteExpression(node); - case 189: - return checkVoidExpression(node); - case 190: - return checkAwaitExpression(node); - case 191: - return checkPrefixUnaryExpression(node); - case 192: - return checkPostfixUnaryExpression(node); - case 193: - return checkBinaryExpression(node, contextualMapper); - case 194: - return checkConditionalExpression(node, contextualMapper); - case 197: - return checkSpreadExpression(node, contextualMapper); - case 199: - return undefinedWideningType; case 196: + return checkTemplateExpression(node); + case 13: + return stringType; + case 12: + return globalRegExpType; + case 177: + return checkArrayLiteral(node, checkMode); + case 178: + return checkObjectLiteral(node, checkMode); + case 179: + return checkPropertyAccessExpression(node); + case 180: + return checkIndexedAccess(node); + case 181: + case 182: + return checkCallExpression(node); + case 183: + return checkTaggedTemplateExpression(node); + case 185: + return checkExpression(node.expression, checkMode); + case 199: + return checkClassExpression(node); + case 186: + case 187: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 189: + return checkTypeOfExpression(node); + case 184: + case 202: + return checkAssertion(node); + case 203: + return checkNonNullAssertion(node); + case 204: + return checkMetaProperty(node); + case 188: + return checkDeleteExpression(node); + case 190: + return checkVoidExpression(node); + case 191: + return checkAwaitExpression(node); + case 192: + return checkPrefixUnaryExpression(node); + case 193: + return checkPostfixUnaryExpression(node); + case 194: + return checkBinaryExpression(node, checkMode); + case 195: + return checkConditionalExpression(node, checkMode); + case 198: + return checkSpreadExpression(node, checkMode); + case 200: + return undefinedWideningType; + case 197: return checkYieldExpression(node); - case 255: - return checkJsxExpression(node, contextualMapper); - case 248: - return checkJsxElement(node); + case 256: + return checkJsxExpression(node, checkMode); case 249: - return checkJsxSelfClosingElement(node); - case 253: - return checkJsxAttributes(node, contextualMapper); + return checkJsxElement(node); case 250: + return checkJsxSelfClosingElement(node); + case 254: + return checkJsxAttributes(node, checkMode); + case 251: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -33745,7 +35325,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 152 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -33756,7 +35336,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 151 || func.kind === 155 || func.kind === 160) { + if (func.kind === 152 || func.kind === 156 || func.kind === 161) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -33764,19 +35344,11 @@ var ts; error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 150 || - node.kind === 227 || - node.kind === 185; - } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 70 && + if (param.name.kind === 71 && param.name.text === parameter.text) { return i; } @@ -33826,13 +35398,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 187: + case 155: + case 228: case 186: - case 154: - case 227: - case 185: - case 159: + case 160: + case 151: case 150: - case 149: var parent = node.parent; if (node === parent.type) { return parent; @@ -33846,13 +35418,13 @@ var ts; continue; } var name = element.name; - if (name.kind === 70 && + if (name.kind === 71 && name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 174 || - name.kind === 173) { + else if (name.kind === 175 || + name.kind === 174) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -33860,20 +35432,29 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 156) { + if (node.kind === 157) { checkGrammarIndexSignature(node); } - else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || - node.kind === 154 || node.kind === 151 || - node.kind === 155) { + else if (node.kind === 160 || node.kind === 228 || node.kind === 161 || + node.kind === 155 || node.kind === 152 || + node.kind === 156) { checkGrammarFunctionLikeDeclaration(node); } - if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { + var functionFlags = ts.getFunctionFlags(node); + if ((functionFlags & 7) === 2 && languageVersion < 4) { checkExternalEmitHelpers(node, 64); if (languageVersion < 2) { checkExternalEmitHelpers(node, 128); } } + if ((functionFlags & 5) === 1) { + if (functionFlags & 2 && languageVersion < 4) { + checkExternalEmitHelpers(node, 2048); + } + else if (languageVersion < 2) { + checkExternalEmitHelpers(node, 128); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -33881,29 +35462,32 @@ var ts; } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { + if (noImplicitAny && !node.type) { switch (node.kind) { - case 155: + case 156: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 154: + case 155: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { + var functionFlags_1 = ts.getFunctionFlags(node); + if ((functionFlags_1 & 5) === 1) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + var generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags_1 & 2) !== 0) || anyType; + var iterableIteratorInstantiation = functionFlags_1 & 2 + ? createAsyncIterableIteratorType(generatorElementType) + : createIterableIteratorType(generatorElementType); checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if (ts.isAsyncFunctionLike(node)) { + else if ((functionFlags_1 & 3) === 2) { checkAsyncFunctionReturnType(node); } } @@ -33924,7 +35508,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151) { + if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -33938,16 +35522,16 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 152: + case 153: addName(names, member.name, memberName, 1); break; - case 153: + case 154: addName(names, member.name, memberName, 2); break; - case 148: + case 149: addName(names, member.name, memberName, 3); break; - case 150: + case 151: addName(names, member.name, memberName, 4); break; } @@ -33999,12 +35583,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 147) { + if (member.kind === 148) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 70: + case 71: memberName = member.name.text; break; default: @@ -34021,7 +35605,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 229) { + if (node.kind === 230) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -34036,7 +35620,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 135: + case 136: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -34044,7 +35628,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 132: + case 133: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -34100,15 +35684,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 98) { + if (n.kind === 99) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 185 && n.kind !== 227) { + else if (n.kind !== 186 && n.kind !== 228) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 148 && + return n.kind === 149 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -34128,7 +35712,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -34151,18 +35735,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 152) { + if (node.kind === 153) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 152 ? 153 : 152; + var otherKind = node.kind === 153 ? 154 : 153; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -34176,17 +35760,12 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 152) { + if (node.kind === 153) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 177) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - else { - checkNodeDeferred(node); - } + checkSourceElement(node.body); + registerForUnusedIdentifiersCheck(node); } function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { var firstType = getAnnotatedType(first); @@ -34195,10 +35774,6 @@ var ts; error(first, message); } } - function checkAccessorDeferred(node) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } function checkMissingDeclaration(node) { checkDecorators(node); } @@ -34295,9 +35870,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 229 && - n.parent.kind !== 228 && - n.parent.kind !== 198 && + if (n.parent.kind !== 230 && + n.parent.kind !== 229 && + n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -34374,7 +35949,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 150 || node.kind === 149) && + var reportError = (node.kind === 151 || node.kind === 150) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -34407,11 +35982,11 @@ var ts; var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 230 || node.parent.kind === 163 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { + if (node.kind === 228 || node.kind === 151 || node.kind === 150 || node.kind === 152) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -34462,8 +36037,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; + for (var _a = 0, signatures_4 = signatures; _a < signatures_4.length; _a++) { + var signature = signatures_4[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -34522,16 +36097,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 229: + case 230: return 2097152; - case 232: + case 233: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 228: - case 231: + case 229: + case 232: return 2097152 | 1048576; - case 236: + case 237: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -34541,40 +36116,30 @@ var ts; } } } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - var apparentType = getApparentType(type); - if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; + function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage) { + var promisedType = getPromisedTypeOfPromise(type, errorNode); + return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage); } - function getPromisedType(promise) { + function getPromisedTypeOfPromise(promise, errorNode) { if (isTypeAny(promise)) { return undefined; } - if (getObjectFlags(promise) & 4) { - if (promise.target === tryGetGlobalPromiseType() - || promise.target === getGlobalPromiseLikeType()) { - return promise.typeArguments[0]; - } + var typeAsPromise = promise; + if (typeAsPromise.promisedTypeOfPromise) { + return typeAsPromise.promisedTypeOfPromise; } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; + if (isReferenceToType(promise, getGlobalPromiseType(false))) { + return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (!thenFunction || isTypeAny(thenFunction)) { + if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = getSignaturesOfType(thenFunction, 0); + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; if (thenSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); + } return undefined; } var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288); @@ -34583,46 +36148,60 @@ var ts; } var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); if (onfulfilledParameterSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); + } return undefined; } - return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), true); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), true); } - function getTypeOfFirstParameterOfSignature(signature) { - return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + function checkAwaitedType(type, errorNode, diagnosticMessage) { + return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; } - function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 65536) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types, true); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } + function getAwaitedType(type, errorNode, diagnosticMessage) { + var typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } + if (isTypeAny(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + if (type.flags & 65536) { + var types = void 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types = ts.append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage)); + } + if (!types) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, true); + } + var promisedType = getPromisedTypeOfPromise(type); + if (promisedType) { + if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } + awaitedTypeStack.push(type.id); + var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage); + awaitedTypeStack.pop(); + if (!awaitedType) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = awaitedType; + } + var thenFunction = getTypeOfPropertyOfType(type, "then"); + if (thenFunction && getSignaturesOfType(thenFunction, 0).length > 0) { + if (errorNode) { + ts.Debug.assert(!!diagnosticMessage); + error(errorNode, diagnosticMessage); + } + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = type; } function checkAsyncFunctionReturnType(node) { var returnType = getTypeFromTypeNode(node.type); @@ -34630,8 +36209,8 @@ var ts; if (returnType === unknownType) { return unknownType; } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + var globalPromiseType = getGlobalPromiseType(true); + if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); return unknownType; } @@ -34649,7 +36228,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + if (promiseConstructorName.kind === 71 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -34657,7 +36236,7 @@ var ts; } return unknownType; } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true); if (globalPromiseConstructorLikeType === emptyObjectType) { error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); return unknownType; @@ -34672,7 +36251,7 @@ var ts; return unknownType; } } - return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -34684,22 +36263,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 228: + case 229: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 148: + case 149: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 150: - case 152: + case 151: case 153: + case 154: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -34710,7 +36289,7 @@ var ts; function markTypeNodeAsReferenced(node) { var typeName = node && ts.getEntityNameFromTypeNode(node); var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 ? 793064 : 1920) | 8388608, undefined, undefined); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 71 ? 793064 : 1920) | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608 && symbolIsValue(rootSymbol) @@ -34733,13 +36312,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 145) { + if (node.kind === 146) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 228: + case 229: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -34748,19 +36327,19 @@ var ts; } } break; - case 150: - case 152: + case 151: case 153: + case 154: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 148: + case 149: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 145: + case 146: markTypeNodeAsReferenced(node.type); break; } @@ -34780,8 +36359,8 @@ var ts; function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 143) { + var functionFlags = ts.getFunctionFlags(node); + if (node.name && node.name.kind === 144) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -34799,15 +36378,17 @@ var ts; } } checkSourceElement(node.body); - if (!node.asteriskToken) { - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if ((functionFlags & 1) === 0) { + var returnOrPromisedType = node.type && (functionFlags & 2 + ? checkAsyncFunctionReturnType(node) + : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (produceDiagnostics && !node.type) { - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + if (functionFlags & 1 && ts.nodeIsPresent(node.body)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } } @@ -34823,55 +36404,54 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 264: - case 232: + case 265: + case 233: checkUnusedModuleMembers(node); break; - case 228: - case 198: + case 229: + case 199: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 229: + case 230: checkUnusedTypeParameters(node); break; - case 206: - case 234: - case 213: + case 207: + case 235: case 214: case 215: + case 216: checkUnusedLocalsAndParameters(node); break; - case 151: - case 185: - case 227: - case 186: - case 150: case 152: + case 186: + case 228: + case 187: + case 151: case 153: + case 154: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 149: - case 154: + case 150: case 155: case 156: - case 159: + case 157: case 160: + case 161: checkUnusedTypeParameters(node); break; } - ; } } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 230 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 146) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -34897,13 +36477,13 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 225 && - (declaration.parent.parent.kind === 214 || - declaration.parent.parent.kind === 215)) { + if (declaration.kind === 226 && + (declaration.parent.parent.kind === 215 || + declaration.parent.parent.kind === 216)) { return; } } - if (!isRemovedPropertyFromObjectSpread(node.kind === 70 ? node.parent : node)) { + if (!isRemovedPropertyFromObjectSpread(node.kind === 71 ? node.parent : node)) { error(node, ts.Diagnostics._0_is_declared_but_never_used, name); } } @@ -34911,19 +36491,19 @@ var ts; return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); } function isIdentifierThatStartsWithUnderScore(node) { - return node.kind === 70 && node.text.charCodeAt(0) === 95; + return node.kind === 71 && node.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 || member.kind === 148) { + if (member.kind === 151 || member.kind === 149) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 151) { + else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -34967,7 +36547,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 206) { + if (node.kind === 207) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -34989,19 +36569,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 148 || - node.kind === 147 || + if (node.kind === 149 || + node.kind === 148 || + node.kind === 151 || node.kind === 150 || - node.kind === 149 || - node.kind === 152 || - node.kind === 153) { + node.kind === 153 || + node.kind === 154) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 146 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -35017,36 +36597,32 @@ var ts; } } function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 70; + var isDeclaration_1 = node.kind !== 71; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 70; + var isDeclaration_2 = node.kind !== 71; if (isDeclaration_2) { error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { @@ -35057,7 +36633,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_3 = node.kind !== 70; + var isDeclaration_3 = node.kind !== 71; if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -35073,11 +36649,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 233 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 265 && 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)); } } @@ -35085,11 +36661,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 233 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 265 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { 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)); } } @@ -35097,7 +36673,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 225 && !node.initializer) { + if (node.kind === 226 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -35107,15 +36683,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); - var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 227); + var container = varDeclList.parent.kind === 208 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 206 && ts.isFunctionLike(container.parent) || + (container.kind === 207 && ts.isFunctionLike(container.parent) || + container.kind === 234 || container.kind === 233 || - container.kind === 232 || - container.kind === 264); + container.kind === 265); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -35125,7 +36701,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 145) { + if (ts.getRootDeclaration(node).kind !== 146) { return; } var func = ts.getContainingFunction(node); @@ -35134,10 +36710,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 178) { + if (n.kind === 179) { return visit(n.expression); } - else if (n.kind === 70) { + else if (n.kind === 71) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -35148,22 +36724,21 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 145 || - symbol.valueDeclaration.kind === 175) { + if (symbol.valueDeclaration.kind === 146 || + symbol.valueDeclaration.kind === 176) { if (symbol.valueDeclaration.pos < node.pos) { return; } - var current = n; - while (current !== node.initializer) { - if (ts.isFunctionLike(current.parent)) { - return; + if (ts.findAncestor(n, function (current) { + if (current === node.initializer) { + return "quit"; } - if (current.parent.kind === 148 && - !(ts.hasModifier(current.parent, 32)) && - ts.isClassLike(current.parent.parent)) { - return; - } - current = current.parent; + return ts.isFunctionLike(current.parent) || + (current.parent.kind === 149 && + !(ts.hasModifier(current.parent, 32)) && + ts.isClassLike(current.parent.parent)); + })) { + return; } } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); @@ -35180,17 +36755,17 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 175) { - if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { + if (node.kind === 176) { + if (node.parent.kind === 174 && languageVersion < 5) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 143) { + if (node.propertyName && node.propertyName.kind === 144) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -35203,14 +36778,17 @@ var ts; } } if (ts.isBindingPattern(node.name)) { + if (node.name.kind === 175 && languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512); + } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 146 && 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 !== 214) { + if (node.initializer && node.parent.parent.kind !== 215) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -35219,7 +36797,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 214) { + if (node.initializer && node.parent.parent.kind !== 215) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -35237,9 +36815,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 148 && node.kind !== 147) { + if (node.kind !== 149 && node.kind !== 148) { checkExportsOnMergedDeclarations(node); - if (node.kind === 225 || node.kind === 175) { + if (node.kind === 226 || node.kind === 176) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -35250,8 +36828,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 145 && right.kind === 225) || - (left.kind === 225 && right.kind === 145)) { + if ((left.kind === 146 && right.kind === 226) || + (left.kind === 226 && right.kind === 146)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -35278,8 +36856,8 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 177) { - if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers && node.parent.kind === 178) { + if (ts.getFunctionFlags(node) & 2) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -35297,7 +36875,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 208) { + if (node.thenStatement.kind === 209) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -35314,12 +36892,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 226) { + if (node.initializer && node.initializer.kind === 227) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 226) { + if (node.initializer.kind === 227) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -35337,13 +36915,23 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 226) { + if (node.kind === 216) { + if (node.awaitModifier) { + if (languageVersion < 4) { + checkExternalEmitHelpers(node, 8192); + } + } + else if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256); + } + } + if (node.initializer.kind === 227) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 176 || varExpr.kind === 177) { + var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); + if (varExpr.kind === 177 || varExpr.kind === 178) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -35362,7 +36950,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 226) { + if (node.initializer.kind === 227) { 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); @@ -35372,7 +36960,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 176 || varExpr.kind === 177) { + if (varExpr.kind === 177 || varExpr.kind === 178) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -35382,7 +36970,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -35397,146 +36985,67 @@ var ts; checkVariableDeclaration(decl); } } - function checkRightHandSideOfForOf(rhsExpression) { + function checkRightHandSideOfForOf(rhsExpression, awaitModifier) { var expressionType = checkNonNullExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable) { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1); - if (indexType) { - return indexType; - } - } - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - } - return unknownType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, true) || anyType; } - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableType()) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature), true), errorNode); + function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, checkAssignability) { + var uplevelIteration = languageVersion >= 2; + var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + var iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + if (iteratedType || uplevelIteration) { + return iteratedType; } } - return typeAsIterable.iterableElementType; - } - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - if ((getObjectFlags(type) & 4) && type.target === getGlobalIteratorType()) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature), true); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableIteratorType()) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); - } - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2); - var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 65536) { - var arrayTypes = arrayOrStringType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); - if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, true); - } - } - else if (arrayOrStringType.flags & 262178) { - arrayType = neverType; - } - var hasStringConstituent = arrayOrStringType !== arrayType; + var arrayType = inputType; var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; + var hasStringConstituent = false; + if (allowStringInput) { + if (arrayType.flags & 65536) { + var arrayTypes = inputType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, true); + } } - if (arrayType.flags & 8192) { - return stringType; + else if (arrayType.flags & 262178) { + arrayType = neverType; + } + hasStringConstituent = arrayType !== inputType; + if (hasStringConstituent) { + if (languageVersion < 1) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + } + if (arrayType.flags & 8192) { + return stringType; + } } } if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + if (errorNode && !reportedError) { + var diagnostic = !allowStringInput || hasStringConstituent + ? downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type + : downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; error(errorNode, diagnostic, typeToString(arrayType)); } - return hasStringConstituent ? stringType : unknownType; + return hasStringConstituent ? stringType : undefined; } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; - if (hasStringConstituent) { + var arrayElementType = getIndexTypeOfType(arrayType, 1); + if (hasStringConstituent && arrayElementType) { if (arrayElementType.flags & 262178) { return stringType; } @@ -35544,14 +37053,131 @@ var ts; } return arrayElementType; } + function getIteratedTypeOfIterable(type, errorNode, isAsyncIterable, allowNonAsyncIterables, checkAssignability) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { + return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; + } + if (isAsyncIterable) { + if (isReferenceToType(type, getGlobalAsyncIterableType(false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0]; + } + } + if (!isAsyncIterable || allowNonAsyncIterables) { + if (isReferenceToType(type, getGlobalIterableType(false)) || + isReferenceToType(type, getGlobalIterableIteratorType(false))) { + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0] + : typeAsIterable.iteratedTypeOfIterable = type.typeArguments[0]; + } + } + var iteratorMethodSignatures; + var isNonAsyncIterable = false; + if (isAsyncIterable) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); + } + if (!isAsyncIterable || (allowNonAsyncIterables && !ts.some(iteratorMethodSignatures))) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); + isNonAsyncIterable = true; + } + if (ts.some(iteratorMethodSignatures)) { + var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), true); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, !isNonAsyncIterable); + if (checkAssignability && errorNode && iteratedType) { + checkTypeAssignableTo(type, isNonAsyncIterable + ? createIterableType(iteratedType) + : createAsyncIterableType(iteratedType), errorNode); + } + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType + : typeAsIterable.iteratedTypeOfIterable = iteratedType; + } + if (errorNode) { + error(errorNode, isAsyncIterable + ? ts.Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + function getIteratedTypeOfIterator(type, errorNode, isAsyncIterator) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { + return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; + } + var getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; + if (isReferenceToType(type, getIteratorType(false))) { + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = type.typeArguments[0] + : typeAsIterator.iteratedTypeOfIterator = type.typeArguments[0]; + } + var nextMethod = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(nextMethod)) { + return undefined; + } + var nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, 0) : emptyArray; + if (nextMethodSignatures.length === 0) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.An_async_iterator_must_have_a_next_method + : ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var nextResult = getUnionType(ts.map(nextMethodSignatures, getReturnTypeOfSignature), true); + if (isTypeAny(nextResult)) { + return undefined; + } + if (isAsyncIterator) { + nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); + if (isTypeAny(nextResult)) { + return undefined; + } + } + var nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value"); + if (!nextValue) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue + : typeAsIterator.iteratedTypeOfIterator = nextValue; + } + function getIteratedTypeOfGenerator(returnType, isAsyncGenerator) { + if (isTypeAny(returnType)) { + return undefined; + } + return getIteratedTypeOfIterable(returnType, undefined, isAsyncGenerator, false, false) + || getIteratedTypeOfIterator(returnType, undefined, isAsyncGenerator); + } function checkBreakOrContinueStatement(node) { checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); + return !!(node.kind === 153 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 154))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { - var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; + var unwrappedReturnType = (ts.getFunctionFlags(func) & 3) === 2 + ? getPromisedTypeOfPromise(returnType) + : returnType; return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 1024 | 1); } function checkReturnStatement(node) { @@ -35567,23 +37193,24 @@ var ts; var returnType = getReturnTypeOfSignature(signature); if (strictNullChecks || node.expression || returnType.flags & 8192) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.asteriskToken) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1) { return; } - if (func.kind === 153) { + if (func.kind === 154) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 151) { + else if (func.kind === 152) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (functionFlags & 2) { + var promisedType = getPromisedTypeOfPromise(returnType); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); if (promisedType) { checkTypeAssignableTo(awaitedType, promisedType, node); } @@ -35593,7 +37220,7 @@ var ts; } } } - else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 152 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -35619,7 +37246,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 257 && !hasDuplicateDefaultClause) { + if (clause.kind === 258 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -35631,7 +37258,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 256) { + if (produceDiagnostics && clause.kind === 257) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -35652,18 +37279,16 @@ var ts; } function checkLabeledStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { + ts.findAncestor(node.parent, function (current) { if (ts.isFunctionLike(current)) { - break; + return "quit"; } - if (current.kind === 221 && current.label.text === node.label.text) { + if (current.kind === 222 && 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; + return true; } - current = current.parent; - } + }); } checkSourceElement(node.statement); } @@ -35750,7 +37375,7 @@ var ts; return; } var errorNode; - if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + if (propDeclaration && (propDeclaration.name.kind === 144 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { @@ -35871,7 +37496,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); @@ -35893,7 +37518,7 @@ var ts; } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (languageVersion < 2 && !ts.isInAmbientContext(node)) { + if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); } var baseTypes = getBaseTypes(type); @@ -35905,7 +37530,7 @@ var ts; checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { var constructor = _a[_i]; if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; @@ -35917,15 +37542,8 @@ var ts; if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && - !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 228) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { - error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); 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); } @@ -35979,7 +37597,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 228 || d.kind === 229; + return d.kind === 229 || d.kind === 230; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -35997,7 +37615,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 198) { + if (derivedClassDecl.kind === 199) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -36007,41 +37625,37 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 8) || (derivedDeclarationFlags & 8)) { + if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { continue; } if ((baseDeclarationFlags & 32) !== (derivedDeclarationFlags & 32)) { continue; } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & 98308 && derived.flags & 98308) { continue; } var errorMessage = void 0; - if (base.flags & 8192) { + if (isMethodLike(base)) { if (derived.flags & 98304) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert((derived.flags & 4) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } } function isAccessor(kind) { - return kind === 152 || kind === 153; + return kind === 153 || kind === 154; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -36054,8 +37668,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.name); if (!existing) { seen.set(prop.name, { prop: prop, containingType: base }); @@ -36083,7 +37697,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 230); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -36179,18 +37793,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 191: + case 192: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 36: return value_1; - case 37: return -value_1; - case 51: return ~value_1; + case 37: return value_1; + case 38: return -value_1; + case 52: return ~value_1; } return undefined; - case 193: + case 194: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -36200,38 +37814,38 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 48: return left | right; - case 47: return left & right; - case 45: return left >> right; - case 46: return left >>> right; - case 44: return left << right; - case 49: return left ^ right; - case 38: return left * right; - case 40: return left / right; - case 36: return left + right; - case 37: return left - right; - case 41: return left % right; + case 49: return left | right; + case 48: return left & right; + case 46: return left >> right; + case 47: return left >>> right; + case 45: return left << right; + case 50: return left ^ right; + case 39: return left * right; + case 41: return left / right; + case 37: return left + right; + case 38: return left - right; + case 42: return left % right; } return undefined; case 8: checkGrammarNumericLiteral(e); return +e.text; - case 184: + case 185: return evalConstant(e.expression); - case 70: + case 71: + case 180: case 179: - case 178: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 70) { + if (e.kind === 71) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 179) { + if (e.kind === 180) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -36245,10 +37859,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 70) { + if (current.kind === 71) { break; } - else if (current.kind === 178) { + else if (current.kind === 179) { current = current.expression; } else { @@ -36309,7 +37923,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 231) { + if (declaration.kind !== 232) { return false; } var enumDeclaration = declaration; @@ -36332,8 +37946,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 228 || - (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 229 || + (declaration.kind === 228 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -36392,7 +38006,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, 228); + var mergedClass = ts.getDeclarationOfKind(symbol, 229); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -36435,22 +38049,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 207: + case 208: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 242: case 243: + case 244: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 236: case 237: + case 238: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 175: - case 225: + case 176: + case 226: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -36459,12 +38073,12 @@ var ts; } break; } - case 228: - case 231: - case 227: case 229: case 232: + case 228: case 230: + case 233: + case 231: if (isGlobalAugmentation) { return; } @@ -36480,17 +38094,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 70: + case 71: return node; - case 142: + case 143: do { node = node.left; - } while (node.kind !== 70); + } while (node.kind !== 71); return node; - case 178: + case 179: do { node = node.expression; - } while (node.kind !== 70); + } while (node.kind !== 71); return node; } } @@ -36500,9 +38114,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 264 && !inAmbientExternalModule) { - error(moduleName, node.kind === 243 ? + var inAmbientExternalModule = node.parent.kind === 234 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 265 && !inAmbientExternalModule) { + error(moduleName, node.kind === 244 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -36523,7 +38137,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 245 ? + var message = node.kind === 246 ? 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)); @@ -36550,7 +38164,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239) { + if (importClause.namedBindings.kind === 240) { checkImportBinding(importClause.namedBindings); } else { @@ -36601,10 +38215,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + var inAmbientExternalModule = node.parent.kind === 234 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 234 && !node.moduleSpecifier && ts.isInAmbientContext(node); - if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 265 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -36617,7 +38231,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; + var isInAppropriateContext = node.parent.kind === 265 || node.parent.kind === 234 || node.parent.kind === 233; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -36640,8 +38254,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 264 ? node.parent : node.parent.parent; - if (container.kind === 232 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 265 ? node.parent : node.parent.parent; + if (container.kind === 233 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -36653,7 +38267,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { markExportAsReferenced(node); } else { @@ -36708,7 +38322,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 227 && declaration.kind !== 150) || + return (declaration.kind !== 228 && declaration.kind !== 151) || !!declaration.body; } } @@ -36719,123 +38333,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 232: - case 228: + case 233: case 229: - case 227: + case 230: + case 228: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 144: - return checkTypeParameter(node); case 145: + return checkTypeParameter(node); + case 146: return checkParameter(node); + case 149: case 148: - case 147: return checkPropertyDeclaration(node); - case 159: case 160: - case 154: + case 161: case 155: - return checkSignatureDeclaration(node); case 156: return checkSignatureDeclaration(node); - case 150: - case 149: - return checkMethodDeclaration(node); - case 151: - return checkConstructorDeclaration(node); - case 152: - case 153: - return checkAccessorDeclaration(node); - case 158: - return checkTypeReferenceNode(node); case 157: + return checkSignatureDeclaration(node); + case 151: + case 150: + return checkMethodDeclaration(node); + case 152: + return checkConstructorDeclaration(node); + case 153: + case 154: + return checkAccessorDeclaration(node); + case 159: + return checkTypeReferenceNode(node); + case 158: return checkTypePredicate(node); - case 161: - return checkTypeQuery(node); case 162: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 163: - return checkArrayType(node); + return checkTypeLiteral(node); case 164: - return checkTupleType(node); + return checkArrayType(node); case 165: + return checkTupleType(node); case 166: - return checkUnionOrIntersectionType(node); case 167: - case 169: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 168: case 170: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 171: + return checkIndexedAccessType(node); + case 172: return checkMappedType(node); - case 227: - return checkFunctionDeclaration(node); - case 206: - case 233: - return checkBlock(node); - case 207: - return checkVariableStatement(node); - case 209: - return checkExpressionStatement(node); - case 210: - return checkIfStatement(node); - case 211: - return checkDoStatement(node); - case 212: - return checkWhileStatement(node); - case 213: - return checkForStatement(node); - case 214: - return checkForInStatement(node); - case 215: - return checkForOfStatement(node); - case 216: - case 217: - return checkBreakOrContinueStatement(node); - case 218: - return checkReturnStatement(node); - case 219: - return checkWithStatement(node); - case 220: - return checkSwitchStatement(node); - case 221: - return checkLabeledStatement(node); - case 222: - return checkThrowStatement(node); - case 223: - return checkTryStatement(node); - case 225: - return checkVariableDeclaration(node); - case 175: - return checkBindingElement(node); case 228: - return checkClassDeclaration(node); - case 229: - return checkInterfaceDeclaration(node); - case 230: - return checkTypeAliasDeclaration(node); - case 231: - return checkEnumDeclaration(node); - case 232: - return checkModuleDeclaration(node); - case 237: - return checkImportDeclaration(node); - case 236: - return checkImportEqualsDeclaration(node); - case 243: - return checkExportDeclaration(node); - case 242: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 207: + case 234: + return checkBlock(node); case 208: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 210: + return checkExpressionStatement(node); + case 211: + return checkIfStatement(node); + case 212: + return checkDoStatement(node); + case 213: + return checkWhileStatement(node); + case 214: + return checkForStatement(node); + case 215: + return checkForInStatement(node); + case 216: + return checkForOfStatement(node); + case 217: + case 218: + return checkBreakOrContinueStatement(node); + case 219: + return checkReturnStatement(node); + case 220: + return checkWithStatement(node); + case 221: + return checkSwitchStatement(node); + case 222: + return checkLabeledStatement(node); + case 223: + return checkThrowStatement(node); case 224: + return checkTryStatement(node); + case 226: + return checkVariableDeclaration(node); + case 176: + return checkBindingElement(node); + case 229: + return checkClassDeclaration(node); + case 230: + return checkInterfaceDeclaration(node); + case 231: + return checkTypeAliasDeclaration(node); + case 232: + return checkEnumDeclaration(node); + case 233: + return checkModuleDeclaration(node); + case 238: + return checkImportDeclaration(node); + case 237: + return checkImportEqualsDeclaration(node); + case 244: + return checkExportDeclaration(node); + case 243: + return checkExportAssignment(node); + case 209: checkGrammarStatementInAmbientContext(node); return; - case 246: + case 225: + checkGrammarStatementInAmbientContext(node); + return; + case 247: return checkMissingDeclaration(node); } } @@ -36848,17 +38462,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 185: case 186: + case 187: + case 151: case 150: - case 149: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 152: case 153: - checkAccessorDeferred(node); + case 154: + checkAccessorDeclaration(node); break; - case 198: + case 199: checkClassExpressionDeferred(node); break; } @@ -36946,7 +38560,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 219 && node.parent.statement === node) { + if (node.parent.kind === 220 && node.parent.statement === node) { return true; } node = node.parent; @@ -36955,11 +38569,11 @@ var ts; return false; } function getSymbolsInScope(location, meaning) { - var symbols = ts.createMap(); - var memberFlags = 0; if (isInsideWithStatementBody(location)) { return []; } + var symbols = ts.createMap(); + var memberFlags = 0; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -36968,28 +38582,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232: + case 233: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 231: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 198: + case 199: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 228: case 229: + case 230: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 185: + case 186: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -37021,33 +38635,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 70 && + return name.kind === 71 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 144: - case 228: + case 145: case 229: case 230: case 231: + case 232: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 142) { + while (node.parent && node.parent.kind === 143) { node = node.parent; } - return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); + return node.parent && (node.parent.kind === 159 || node.parent.kind === 277); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 178) { + while (node.parent && node.parent.kind === 179) { node = node.parent; } - return node.parent && node.parent.kind === 200; + return node.parent && node.parent.kind === 201; } function forEachEnclosingClass(node, callback) { var result; @@ -37064,13 +38678,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 142) { + while (nodeOnRightSide.parent.kind === 143) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 237) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242) { + if (nodeOnRightSide.parent.kind === 243) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -37078,27 +38692,35 @@ var ts; function isInRightSideOfImportOrExportAssignment(node) { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } + function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1: + case 3: + return getSymbolOfNode(entityName.parent); + case 4: + case 2: + case 5: + return getSymbolOfNode(entityName.parent.parent); + } + } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { - 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 (ts.isInJavaScriptFile(entityName) && + entityName.parent.kind === 179 && + entityName.parent === entityName.parent.parent.left) { + var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); + if (specialPropertyAssignmentSymbol) { + return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 243 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 236); + if (entityName.kind !== 179 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 237); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -37107,7 +38729,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 200) { + if (entityName.parent.kind === 201) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -37117,26 +38739,29 @@ var ts; meaning = 1920; } meaning |= 8388608; - return resolveEntityName(entityName, meaning); + var entityNameSymbol = resolveEntityName(entityName, meaning); + if (entityNameSymbol) { + return entityNameSymbol; + } } - else if (ts.isPartOfExpression(entityName)) { + if (ts.isPartOfExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 70) { + if (entityName.kind === 71) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 178) { + else if (entityName.kind === 179) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 142) { + else if (entityName.kind === 143) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -37145,19 +38770,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 159 || entityName.parent.kind === 277) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 252) { + else if (entityName.parent.kind === 253) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 157) { + if (entityName.parent.kind === 158) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 264) { + if (node.kind === 265) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -37169,12 +38794,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 70) { + if (node.kind === 71) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 175 && - node.parent.parent.kind === 173 && + else if (node.parent.kind === 176 && + node.parent.parent.kind === 174 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -37184,11 +38809,11 @@ var ts; } } switch (node.kind) { - case 70: - case 178: - case 142: + case 71: + case 179: + case 143: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 98: + case 99: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -37196,21 +38821,21 @@ var ts; return sig.thisParameter; } } - case 96: + case 97: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 168: + case 169: return getTypeFromTypeNode(node).symbol; - case 122: + case 123: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 151) { + if (constructorDeclaration && constructorDeclaration.kind === 152) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 237 || node.parent.kind === 243) && + ((node.parent.kind === 238 || node.parent.kind === 244) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -37218,7 +38843,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 179 && node.parent.argumentExpression === node) { + if (node.parent.kind === 180 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -37232,7 +38857,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 261) { + if (location && location.kind === 262) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -37247,13 +38872,22 @@ var ts; return unknownType; } if (ts.isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + var typeFromTypeNode = getTypeFromTypeNode(node); + if (typeFromTypeNode && ts.isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + var containingClass = ts.getContainingClass(node); + var classType = getTypeOfNode(containingClass); + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + return typeFromTypeNode; } if (ts.isPartOfExpression(node)) { return getRegularTypeOfExpression(node); } if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + var classNode = ts.getContainingClass(node); + var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)); + var baseType = getBaseTypes(classType)[0]; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); @@ -37282,22 +38916,22 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 177 || expr.kind === 176); - if (expr.parent.kind === 215) { - var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); + ts.Debug.assert(expr.kind === 178 || expr.kind === 177); + if (expr.parent.kind === 216) { + var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 193) { + if (expr.parent.kind === 194) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 260) { + if (expr.parent.kind === 261) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 176); + ts.Debug.assert(expr.parent.kind === 177); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); } function getPropertySymbolOfDestructuringAssignment(location) { @@ -37329,7 +38963,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (getCheckFlags(symbol) & 2) { + if (getCheckFlags(symbol) & 6) { var symbols_3 = []; var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { @@ -37343,10 +38977,10 @@ var ts; else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; - return [links.leftSpread, links.rightSpread]; + return getRootSymbols(links.leftSpread).concat(getRootSymbols(links.rightSpread)); } - if (symbol.mappedTypeOrigin) { - return getRootSymbols(symbol.mappedTypeOrigin); + if (symbol.syntheticOrigin) { + return getRootSymbols(symbol.syntheticOrigin); } var target = void 0; var next = symbol; @@ -37363,7 +38997,7 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 179 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -37404,19 +39038,15 @@ var ts; } symbol = exportSymbol; } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { - var symbolFile = parentSymbol.valueDeclaration; + var parentSymbol_1 = getParentOfSymbol(symbol); + if (parentSymbol_1) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 265) { + var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - for (var n = node.parent; n; n = n.parent) { - if (ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } + return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; }); } } } @@ -37444,7 +39074,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 207 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -37479,23 +39109,19 @@ var ts; return false; } function isValueAliasDeclaration(node) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - return true; - } switch (node.kind) { - case 236: - case 238: + case 237: case 239: - case 241: - case 245: + case 240: + case 242: + case 246: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 243: + case 244: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 242: + case 243: return node.expression - && node.expression.kind === 70 + && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -37503,7 +39129,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 265 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -37521,10 +39147,6 @@ var ts; return isConstEnumSymbol(s) || s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - return true; - } if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (symbol && getSymbolLinks(symbol).referenced) { @@ -37552,15 +39174,23 @@ var ts; !(ts.getModifierFlags(parameter) & 92); } function getNodeCheckFlags(node) { - node = ts.getParseTreeNode(node); - return node ? getNodeLinks(node).flags : undefined; + return getNodeLinks(node).flags; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function canHaveConstantValue(node) { + switch (node.kind) { + case 264: + case 179: + case 180: + return true; + } + return false; + } function getConstantValue(node) { - if (node.kind === 263) { + if (node.kind === 264) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -37578,7 +39208,7 @@ var ts; var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { return ts.TypeReferenceSerializationKind.Promise; } @@ -37710,10 +39340,19 @@ var ts; getReferencedImportDeclaration: getReferencedImportDeclaration, getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, isDeclarationWithCollidingName: isDeclarationWithCollidingName, - isValueAliasDeclaration: isValueAliasDeclaration, + isValueAliasDeclaration: function (node) { + node = ts.getParseTreeNode(node); + return node ? isValueAliasDeclaration(node) : true; + }, hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, + isReferencedAliasDeclaration: function (node, checkChildren) { + node = ts.getParseTreeNode(node); + return node ? isReferencedAliasDeclaration(node, checkChildren) : true; + }, + getNodeCheckFlags: function (node) { + node = ts.getParseTreeNode(node); + return node ? getNodeCheckFlags(node) : undefined; + }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, @@ -37724,7 +39363,10 @@ var ts; writeBaseConstructorTypeOfClass: writeBaseConstructorTypeOfClass, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, collectLinkedAliases: collectLinkedAliases, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, @@ -37742,7 +39384,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 179) || (node.kind === 71 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -37785,7 +39427,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 265 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -37804,7 +39446,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 264); + return ts.getDeclarationOfKind(moduleSymbol, 265); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -37843,57 +39485,29 @@ var ts; } addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true); getSymbolLinks(unknownSymbol).type = unknownType; - globalArrayType = getGlobalType("Array", 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalESSymbolConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Symbol"); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793064, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - tryGetGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalSymbol("Promise", 107455, undefined) && getGlobalPromiseConstructorSymbol(); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2) { - getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); - getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", 1); }); - getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", 1); }); - getGlobalIterableIteratorType = ts.memoize(function () { return getGlobalType("IterableIterator", 1); }); - } - else { - getGlobalESSymbolType = ts.memoize(function () { return emptyObjectType; }); - getGlobalIterableType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIteratorType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); - } + globalArrayType = getGlobalType("Array", 1, true); + globalObjectType = getGlobalType("Object", 0, true); + globalFunctionType = getGlobalType("Function", 0, true); + globalStringType = getGlobalType("String", 0, true); + globalNumberType = getGlobalType("Number", 0, true); + globalBooleanType = getGlobalType("Boolean", 0, true); + globalRegExpType = getGlobalType("RegExp", 0, true); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); - var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); - globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); + globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; + globalThisType = getGlobalTypeOrUndefined("ThisType", 1); } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !ts.isInAmbientContext(location)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1; helper <= 128; helper <<= 1) { + for (var helper = 1; helper <= 8192; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); @@ -37917,6 +39531,13 @@ var ts; case 32: return "__param"; case 64: return "__awaiter"; case 128: return "__generator"; + case 256: return "__values"; + case 512: return "__read"; + case 1024: return "__spread"; + case 2048: return "__asyncGenerator"; + case 4096: return "__asyncDelegator"; + case 8192: return "__asyncValues"; + default: ts.Debug.fail("Unrecognized helper."); } } function resolveHelpersModule(node, errorNode) { @@ -37925,36 +39546,19 @@ var ts; } return externalHelpersModule; } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - var thenPropertySymbol = createSymbol(4, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(16); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 151 && !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 === 152 || node.kind === 153) { + else if (node.kind === 153 || node.kind === 154) { 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); @@ -37971,28 +39575,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 130) { - if (node.kind === 147 || node.kind === 149) { + if (modifier.kind !== 131) { + if (node.kind === 148 || node.kind === 150) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 156) { + if (node.kind === 157) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 75: - if (node.kind !== 231 && node.parent.kind === 228) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); + case 76: + if (node.kind !== 232 && node.parent.kind === 229) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; + case 114: case 113: case 112: - case 111: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 112) { + if (modifier.kind === 113) { lastProtected = modifier; } - else if (modifier.kind === 111) { + else if (modifier.kind === 112) { lastPrivate = modifier; } if (flags & 28) { @@ -38007,11 +39611,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 233 || node.parent.kind === 264) { + else if (node.parent.kind === 234 || node.parent.kind === 265) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 111) { + if (modifier.kind === 112) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -38020,7 +39624,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 114: + case 115: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -38030,10 +39634,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 233 || node.parent.kind === 264) { + else if (node.parent.kind === 234 || node.parent.kind === 265) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -38042,17 +39646,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 130: + case 131: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { + else if (node.kind !== 149 && node.kind !== 148 && node.kind !== 157 && node.kind !== 146) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 83: + case 84: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -38065,45 +39669,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 123: + case 124: 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 === 228) { + else if (node.parent.kind === 229) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 234) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 116: + case 117: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 228) { - if (node.kind !== 150 && - node.kind !== 148 && - node.kind !== 152 && - node.kind !== 153) { + if (node.kind !== 229) { + if (node.kind !== 151 && + node.kind !== 149 && + node.kind !== 153 && + node.kind !== 154) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 229 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -38115,14 +39719,14 @@ var ts; } flags |= 128; break; - case 119: + case 120: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -38130,7 +39734,7 @@ var ts; break; } } - if (node.kind === 151) { + if (node.kind === 152) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -38145,13 +39749,13 @@ var ts; } return; } - else if ((node.kind === 237 || node.kind === 236) && flags & 2) { + else if ((node.kind === 238 || node.kind === 237) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 146 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 146 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -38167,38 +39771,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 152: case 153: - case 151: - case 148: - case 147: - case 150: + case 154: + case 152: case 149: - case 156: - case 232: + case 148: + case 151: + case 150: + case 157: + case 233: + case 238: case 237: - case 236: + case 244: case 243: - case 242: - case 185: case 186: - case 145: + case 187: + case 146: return false; default: - if (node.parent.kind === 233 || node.parent.kind === 264) { + if (node.parent.kind === 234 || node.parent.kind === 265) { return false; } switch (node.kind) { - case 227: - return nodeHasAnyModifiersExcept(node, 119); case 228: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 120); case 229: - case 207: + return nodeHasAnyModifiersExcept(node, 117); case 230: - return true; + case 208: case 231: - return nodeHasAnyModifiersExcept(node, 75); + return true; + case 232: + return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); return false; @@ -38210,14 +39814,11 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 150: - case 227: - case 185: + case 151: + case 228: case 186: - if (!node.asteriskToken) { - return false; - } - break; + case 187: + return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } @@ -38274,8 +39875,12 @@ var ts; return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } function checkGrammarArrowFunction(node, file) { - if (node.kind === 186) { + if (node.kind === 187) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -38310,7 +39915,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 136 && parameter.type.kind !== 133) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -38337,7 +39942,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 199) { + if (arg.kind === 200) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -38363,7 +39968,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84) { + if (heritageClause.token === 85) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -38376,7 +39981,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107); + ts.Debug.assert(heritageClause.token === 108); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -38391,14 +39996,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84) { + if (heritageClause.token === 85) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107); + ts.Debug.assert(heritageClause.token === 108); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -38407,28 +40012,25 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 143) { + if (node.kind !== 144) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 194 && computedPropertyName.expression.operatorToken.kind === 26) { 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 === 227 || - node.kind === 185 || - node.kind === 150); + ts.Debug.assert(node.kind === 228 || + node.kind === 186 || + node.kind === 151); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); - } } } function checkGrammarForInvalidQuestionMark(questionToken, message) { @@ -38444,39 +40046,39 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262) { + if (prop.kind === 263) { continue; } var name = prop.name; - if (name.kind === 143) { + if (name.kind === 144) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 262 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 150) { + if (mod.kind !== 120 || prop.kind !== 151) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 260 || prop.kind === 261) { + if (prop.kind === 261 || prop.kind === 262) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = Property; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = GetAccessor; } - else if (prop.kind === 153) { + else if (prop.kind === 154) { currentKind = SetAccessor; } else { @@ -38512,7 +40114,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 254) { + if (attr.kind === 255) { continue; } var jsxAttr = attr; @@ -38524,7 +40126,7 @@ var ts; return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 255 && !initializer.expression) { + if (initializer && initializer.kind === 256 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -38533,7 +40135,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 226) { + if (forInOrOfStatement.kind === 216 && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 16384) === 0) { + return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + } + } + if (forInOrOfStatement.initializer.kind === 227) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -38541,20 +40148,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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 === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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 === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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); @@ -38581,11 +40188,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 152 ? + return grammarErrorOnNode(accessor.name, kind === 153 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 153) { + else if (kind === 154) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -38604,10 +40211,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 153 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 153 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -38622,7 +40229,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 177) { + if (node.parent.kind === 178) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -38638,10 +40245,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 === 229) { + else if (node.parent.kind === 230) { 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 === 162) { + else if (node.parent.kind === 163) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -38652,9 +40259,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 221: + case 222: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 216 + var isMisplacedContinueLabel = node.kind === 217 && !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); @@ -38662,8 +40269,8 @@ var ts; return false; } break; - case 220: - if (node.kind === 217 && !node.label) { + case 221: + if (node.kind === 218 && !node.label) { return false; } break; @@ -38676,13 +40283,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 217 + var message = node.kind === 218 ? 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 === 217 + var message = node.kind === 218 ? 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); @@ -38694,7 +40301,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 174 || node.name.kind === 173) { + if (node.name.kind === 175 || node.name.kind === 174) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -38704,11 +40311,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 191 && expr.operator === 37 && + expr.kind === 192 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { + if (node.parent.parent.kind !== 215 && node.parent.parent.kind !== 216) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -38743,7 +40350,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 70) { + if (name.kind === 71) { if (ts.unescapeIdentifier(name.text) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -38759,8 +40366,8 @@ var ts; } } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 70) { - if (name.originalKeywordKind === 109) { + if (name.kind === 71) { + if (name.originalKeywordKind === 110) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -38785,15 +40392,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 210: case 211: case 212: - case 219: case 213: + case 220: case 214: case 215: + case 216: return false; - case 221: + case 222: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -38809,9 +40416,9 @@ var ts; } } function checkGrammarMetaProperty(node) { - if (node.keywordToken === 93) { + if (node.keywordToken === 94) { if (node.name.text !== "target") { - return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, ts.tokenToString(node.keywordToken), "target"); } } } @@ -38855,7 +40462,7 @@ var ts; return true; } } - else if (node.parent.kind === 229) { + else if (node.parent.kind === 230) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -38863,7 +40470,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 162) { + else if (node.parent.kind === 163) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -38876,13 +40483,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 229 || - node.kind === 230 || + if (node.kind === 230 || + node.kind === 231 || + node.kind === 238 || node.kind === 237 || - node.kind === 236 || + node.kind === 244 || node.kind === 243 || - node.kind === 242 || - node.kind === 235 || + node.kind === 236 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -38891,7 +40498,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 === 207) { + if (ts.isDeclaration(decl) || decl.kind === 208) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -38910,7 +40517,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 === 206 || node.parent.kind === 233 || node.parent.kind === 264) { + if (node.parent.kind === 207 || node.parent.kind === 234 || node.parent.kind === 265) { 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); @@ -38921,19 +40528,19 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral) { + if (node.numericLiteralFlags & 4) { var diagnosticMessage = void 0; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 172)) { + else if (ts.isChildOfNodeWithKind(node, 173)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 263)) { + else if (ts.isChildOfNodeWithKind(node, 264)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 38; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -38961,407 +40568,17 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function reduceNode(node, f, initial) { - return node ? f(initial, node) : initial; - } - function reduceNodeArray(nodes, f, initial) { - return nodes ? f(initial, nodes) : initial; - } - function reduceEachChild(node, initial, cbNode, cbNodeArray) { - if (node === undefined) { - return initial; - } - var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; - var cbNodes = cbNodeArray || cbNode; - var kind = node.kind; - if ((kind > 0 && kind <= 141)) { - return initial; - } - if ((kind >= 157 && kind <= 172)) { - return initial; - } - var result = initial; - switch (node.kind) { - case 205: - case 208: - case 199: - case 224: - case 297: - break; - case 142: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 143: - result = reduceNode(node.expression, cbNode, result); - break; - case 145: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 146: - result = reduceNode(node.expression, cbNode, result); - break; - case 148: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 150: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 151: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 152: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 153: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 173: - case 174: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 175: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 176: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 177: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 178: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 179: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); - break; - case 180: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 181: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 182: - result = reduceNode(node.tag, cbNode, result); - result = reduceNode(node.template, cbNode, result); - break; - case 183: - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 185: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 186: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 184: - case 187: - case 188: - case 189: - case 190: - case 196: - case 197: - case 202: - result = reduceNode(node.expression, cbNode, result); - break; - case 191: - case 192: - result = reduceNode(node.operand, cbNode, result); - break; - case 193: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 194: - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.whenTrue, cbNode, result); - result = reduceNode(node.whenFalse, cbNode, result); - break; - case 195: - result = reduceNode(node.head, cbNode, result); - result = reduceNodes(node.templateSpans, cbNodes, result); - break; - case 198: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 200: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - break; - case 201: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.type, cbNode, result); - break; - case 202: - result = reduceNode(node.expression, cbNode, result); - break; - case 204: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.literal, cbNode, result); - break; - case 206: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 207: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.declarationList, cbNode, result); - break; - case 209: - result = reduceNode(node.expression, cbNode, result); - break; - case 210: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.thenStatement, cbNode, result); - result = reduceNode(node.elseStatement, cbNode, result); - break; - case 211: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 212: - case 219: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 213: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.incrementor, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 214: - case 215: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 218: - case 222: - result = reduceNode(node.expression, cbNode, result); - break; - case 220: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.caseBlock, cbNode, result); - break; - case 221: - result = reduceNode(node.label, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 223: - result = reduceNode(node.tryBlock, cbNode, result); - result = reduceNode(node.catchClause, cbNode, result); - result = reduceNode(node.finallyBlock, cbNode, result); - break; - case 225: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 226: - result = reduceNodes(node.declarations, cbNodes, result); - break; - case 227: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 228: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 231: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 232: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 233: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 234: - result = reduceNodes(node.clauses, cbNodes, result); - break; - case 236: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.moduleReference, cbNode, result); - break; - case 237: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.importClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 238: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.namedBindings, cbNode, result); - break; - case 239: - result = reduceNode(node.name, cbNode, result); - break; - case 240: - case 244: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 241: - case 245: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 242: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 243: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.exportClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 247: - result = reduceNode(node.expression, cbNode, result); - break; - case 248: - result = reduceNode(node.openingElement, cbNode, result); - result = ts.reduceLeft(node.children, cbNode, result); - result = reduceNode(node.closingElement, cbNode, result); - break; - case 249: - case 250: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNode(node.attributes, cbNode, result); - break; - case 251: - result = reduceNode(node.tagName, cbNode, result); - break; - case 253: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 252: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 254: - result = reduceNode(node.expression, cbNode, result); - break; - case 255: - result = reduceNode(node.expression, cbNode, result); - break; - case 256: - result = reduceNode(node.expression, cbNode, result); - case 257: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 258: - result = reduceNodes(node.types, cbNodes, result); - break; - case 259: - result = reduceNode(node.variableDeclaration, cbNode, result); - result = reduceNode(node.block, cbNode, result); - break; - case 260: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 261: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); - break; - case 262: - result = reduceNode(node.expression, cbNode, result); - break; - case 263: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - case 264: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 298: - result = reduceNode(node.expression, cbNode, result); - break; - default: - break; - } - return result; - } - ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift) { + function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; } - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; } var visitedNode; if (visited === undefined) { - if (!optional) { - Debug.failNotOptional(); - } return undefined; } else if (ts.isArray(visited)) { @@ -39370,14 +40587,14 @@ var ts; else { visitedNode = visited; } - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; function visitNodes(nodes, visitor, test, start, count) { - if (nodes === undefined) { - return undefined; + if (nodes === undefined || visitor === undefined) { + return nodes; } var updated; var length = nodes.length; @@ -39392,7 +40609,7 @@ var ts; } for (var i = 0; i < count; i++) { var node = nodes[i + start]; - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -39403,14 +40620,14 @@ var ts; if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - Debug.assertNode(visited, test); - aggregateTransformFlags(visited); + ts.Debug.assertNode(visited, test); + ts.aggregateTransformFlags(visited); updated.push(visited); } } @@ -39429,9 +40646,10 @@ var ts; return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; - function visitParameterList(nodes, visitor, context) { + function visitParameterList(nodes, visitor, context, nodesVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } context.startLexicalEnvironment(); - var updated = visitNodes(nodes, visitor, ts.isParameterDeclaration); + var updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -39442,220 +40660,655 @@ var ts; var declarations = context.endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(updated); - var statements = mergeLexicalEnvironment(block.statements, declarations); + var statements = ts.mergeLexicalEnvironment(block.statements, declarations); return ts.updateBlock(block, statements); } return updated; } ts.visitFunctionBody = visitFunctionBody; - function visitEachChild(node, visitor, context) { + function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (node === undefined) { return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 141)) { - return node; - } - if ((kind >= 157 && kind <= 172)) { + if ((kind > 0 && kind <= 142) || kind === 169) { return node; } switch (node.kind) { - case 205: - case 208: - case 199: - case 224: - return node; - case 142: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 143: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 145: - return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 146: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - case 148: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 150: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 151: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 152: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 153: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 173: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 174: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 175: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 176: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 177: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 178: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 179: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 180: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 182: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 186: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 187: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 190: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 191: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 192: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 194: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 195: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 196: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 200: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 201: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 202: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 206: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 207: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 209: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); - case 211: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 212: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 213: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 214: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 215: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 216: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 217: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 218: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 219: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 220: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 221: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 222: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + case 200: case 225: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 226: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 227: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 228: - return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 231: - return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); - case 232: - return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 233: - return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 234: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236: - return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 237: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 238: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); - case 239: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 240: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 241: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 242: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 243: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); - case 244: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 245: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 247: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 253: - return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 250: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 251: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 252: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 254: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 255: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 256: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 257: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 258: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 259: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); - case 260: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 261: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 262: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 263: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 264: - return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); case 298: + case 247: + return node; + case 143: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 144: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 160: + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 161: + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 155: + return ts.updateCallSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 156: + return ts.updateConstructSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 150: + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + case 157: + return ts.updateIndexSignatureDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 146: + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 147: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 159: + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + case 158: + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 162: + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + case 163: + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor)); + case 164: + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + case 165: + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 166: + case 167: + return ts.updateUnionOrIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 168: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 172: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameter), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 173: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + case 145: + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + case 148: + return ts.updatePropertySignature(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 149: + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 151: + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 152: + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 153: + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 154: + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 174: + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + case 175: + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + case 176: + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + case 177: + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + case 178: + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 179: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 180: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 181: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 182: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 183: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 184: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 185: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 186: + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 187: + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 188: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 189: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 190: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 191: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 194: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 192: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 193: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 195: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 196: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + case 197: + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 198: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 199: + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 201: + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 203: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 205: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 207: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 208: + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 210: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 211: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + case 212: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 213: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 214: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 215: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 216: + return ts.updateForOf(node, node.awaitModifier, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 217: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 218: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 219: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 221: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 222: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 223: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 224: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + case 226: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 227: + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + case 228: + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 229: + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 232: + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + case 233: + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 234: + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 235: + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + case 237: + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 238: + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 239: + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + case 240: + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + case 241: + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + case 242: + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 243: + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 244: + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 245: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 246: + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 248: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); + case 249: + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + case 254: + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + case 250: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 252: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 253: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + case 255: + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + case 256: + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 257: + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + case 258: + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 259: + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 260: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 261: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 262: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 263: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 264: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 265: + return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); + case 296: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: return node; } } ts.visitEachChild = visitEachChild; + function extractSingleNode(nodes) { + ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output."); + return ts.singleOrUndefined(nodes); + } +})(ts || (ts = {})); +(function (ts) { + function reduceNode(node, f, initial) { + return node ? f(initial, node) : initial; + } + function reduceNodeArray(nodes, f, initial) { + return nodes ? f(initial, nodes) : initial; + } + function reduceEachChild(node, initial, cbNode, cbNodeArray) { + if (node === undefined) { + return initial; + } + var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; + var cbNodes = cbNodeArray || cbNode; + var kind = node.kind; + if ((kind > 0 && kind <= 142)) { + return initial; + } + if ((kind >= 158 && kind <= 173)) { + return initial; + } + var result = initial; + switch (node.kind) { + case 206: + case 209: + case 200: + case 225: + case 295: + break; + case 143: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 144: + result = reduceNode(node.expression, cbNode, result); + break; + case 146: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 147: + result = reduceNode(node.expression, cbNode, result); + break; + case 149: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 151: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 152: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 154: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 174: + case 175: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 176: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 177: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 178: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 179: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 180: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 183: + result = reduceNode(node.tag, cbNode, result); + result = reduceNode(node.template, cbNode, result); + break; + case 184: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 186: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 187: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 185: + case 188: + case 189: + case 190: + case 191: + case 197: + case 198: + case 203: + result = reduceNode(node.expression, cbNode, result); + break; + case 192: + case 193: + result = reduceNode(node.operand, cbNode, result); + break; + case 194: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 195: + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.whenTrue, cbNode, result); + result = reduceNode(node.whenFalse, cbNode, result); + break; + case 196: + result = reduceNode(node.head, cbNode, result); + result = reduceNodes(node.templateSpans, cbNodes, result); + break; + case 199: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + break; + case 202: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 203: + result = reduceNode(node.expression, cbNode, result); + break; + case 205: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.literal, cbNode, result); + break; + case 207: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 208: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.declarationList, cbNode, result); + break; + case 210: + result = reduceNode(node.expression, cbNode, result); + break; + case 211: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.thenStatement, cbNode, result); + result = reduceNode(node.elseStatement, cbNode, result); + break; + case 212: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 213: + case 220: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 214: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.incrementor, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 215: + case 216: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 219: + case 223: + result = reduceNode(node.expression, cbNode, result); + break; + case 221: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.caseBlock, cbNode, result); + break; + case 222: + result = reduceNode(node.label, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 224: + result = reduceNode(node.tryBlock, cbNode, result); + result = reduceNode(node.catchClause, cbNode, result); + result = reduceNode(node.finallyBlock, cbNode, result); + break; + case 226: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 227: + result = reduceNodes(node.declarations, cbNodes, result); + break; + case 228: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 229: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 233: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 234: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 235: + result = reduceNodes(node.clauses, cbNodes, result); + break; + case 237: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 238: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.importClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 239: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); + break; + case 240: + result = reduceNode(node.name, cbNode, result); + break; + case 241: + case 245: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 242: + case 246: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 243: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 244: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.exportClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 248: + result = reduceNode(node.expression, cbNode, result); + break; + case 249: + result = reduceNode(node.openingElement, cbNode, result); + result = ts.reduceLeft(node.children, cbNode, result); + result = reduceNode(node.closingElement, cbNode, result); + break; + case 250: + case 251: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 254: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: + result = reduceNode(node.tagName, cbNode, result); + break; + case 253: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 255: + result = reduceNode(node.expression, cbNode, result); + break; + case 256: + result = reduceNode(node.expression, cbNode, result); + break; + case 257: + result = reduceNode(node.expression, cbNode, result); + case 258: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 259: + result = reduceNodes(node.types, cbNodes, result); + break; + case 260: + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); + break; + case 261: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 262: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); + break; + case 263: + result = reduceNode(node.expression, cbNode, result); + break; + case 264: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 265: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 296: + result = reduceNode(node.expression, cbNode, result); + break; + default: + break; + } + return result; + } + ts.reduceEachChild = reduceEachChild; function mergeLexicalEnvironment(statements, declarations) { if (!ts.some(declarations)) { return statements; @@ -39665,27 +41318,11 @@ var ts; : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; - function mergeFunctionBodyLexicalEnvironment(body, declarations) { - if (body && declarations !== undefined && declarations.length > 0) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); - } - else { - return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); - } - } - return body; - } - ts.mergeFunctionBodyLexicalEnvironment = mergeFunctionBodyLexicalEnvironment; function liftToBlock(nodes) { Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block."); return ts.singleOrUndefined(nodes) || ts.createBlock(nodes); } ts.liftToBlock = liftToBlock; - function extractSingleNode(nodes) { - Debug.assert(nodes.length <= 1, "Too many nodes written to output."); - return ts.singleOrUndefined(nodes); - } function aggregateTransformFlags(node) { aggregateTransformFlagsForNode(node); return node; @@ -39716,7 +41353,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 201)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -39729,9 +41366,6 @@ var ts; } var Debug; (function (Debug) { - Debug.failNotOptional = Debug.shouldAssert(1) - ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : ts.noop; @@ -39777,7 +41411,7 @@ var ts; var value; if (ts.isDestructuringAssignment(node)) { value = node.right; - while (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) { if (ts.isDestructuringAssignment(value)) { location = node = value; value = node.right; @@ -39791,6 +41425,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -39838,6 +41473,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -39955,7 +41591,12 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + if (flattenContext.level < 1 && flattenContext.downlevelIteration) { + value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) + ? undefined + : numElements, location), false, location); + } + else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -40100,8 +41741,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178); context.enableSubstitution(179); + context.enableSubstitution(180); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -40134,15 +41775,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 264: + case 265: + case 235: case 234: - case 233: - case 206: + case 207: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 229: case 228: - case 227: if (ts.hasModifier(node, 2)) { break; } @@ -40167,13 +41808,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 242: - return visitExportAssignment(node); case 243: + return visitExportAssignment(node); + case 244: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -40183,11 +41824,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 243 || - node.kind === 237 || + if (node.kind === 244 || node.kind === 238 || - (node.kind === 236 && - node.moduleReference.kind === 247)) { + node.kind === 239 || + (node.kind === 237 && + node.moduleReference.kind === 248)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -40203,15 +41844,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 151: - return undefined; - case 148: - case 156: case 152: + return undefined; + case 149: + case 157: case 153: - case 150: + case 154: + case 151: return visitorWorker(node); - case 205: + case 206: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -40222,7 +41863,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270) { return undefined; } - else if (currentNamespace && node.kind === 83) { + else if (currentNamespace && node.kind === 84) { return undefined; } return node; @@ -40232,33 +41873,32 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return currentNamespace ? undefined : node; - case 113: - case 111: + case 114: case 112: - case 116: - case 75: - case 123: - case 130: - case 163: + case 113: + case 117: + case 76: + case 124: + case 131: case 164: - case 162: - case 157: - case 144: - case 118: - case 121: - case 135: - case 132: - case 129: - case 104: - case 136: - case 160: - case 159: - case 161: - case 158: case 165: + case 163: + case 158: + case 145: + case 119: + case 122: + case 136: + case 133: + case 130: + case 105: + case 137: + case 161: + case 160: + case 162: + case 159: case 166: case 167: case 168: @@ -40266,57 +41906,58 @@ var ts; case 170: case 171: case 172: - case 156: - case 146: - case 230: - case 148: - return undefined; - case 151: - return visitConstructor(node); - case 229: - return ts.createNotEmittedStatement(node); - case 228: - return visitClassDeclaration(node); - case 198: - return visitClassExpression(node); - case 258: - return visitHeritageClause(node); - case 200: - return visitExpressionWithTypeArguments(node); - case 150: - return visitMethodDeclaration(node); - case 152: - return visitGetAccessor(node); - case 153: - return visitSetAccessor(node); - case 227: - return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); - case 186: - return visitArrowFunction(node); - case 145: - return visitParameter(node); - case 184: - return visitParenthesizedExpression(node); - case 183: - case 201: - return visitAssertionExpression(node); - case 180: - return visitCallExpression(node); - case 181: - return visitNewExpression(node); - case 202: - return visitNonNullExpression(node); + case 173: + case 157: + case 147: case 231: - return visitEnumDeclaration(node); - case 207: - return visitVariableStatement(node); - case 225: - return visitVariableDeclaration(node); + case 149: + return undefined; + case 152: + return visitConstructor(node); + case 230: + return ts.createNotEmittedStatement(node); + case 229: + return visitClassDeclaration(node); + case 199: + return visitClassExpression(node); + case 259: + return visitHeritageClause(node); + case 201: + return visitExpressionWithTypeArguments(node); + case 151: + return visitMethodDeclaration(node); + case 153: + return visitGetAccessor(node); + case 154: + return visitSetAccessor(node); + case 228: + return visitFunctionDeclaration(node); + case 186: + return visitFunctionExpression(node); + case 187: + return visitArrowFunction(node); + case 146: + return visitParameter(node); + case 185: + return visitParenthesizedExpression(node); + case 184: + case 202: + return visitAssertionExpression(node); + case 181: + return visitCallExpression(node); + case 182: + return visitNewExpression(node); + case 203: + return visitNonNullExpression(node); case 232: + return visitEnumDeclaration(node); + case 208: + return visitVariableStatement(node); + case 226: + return visitVariableDeclaration(node); + case 233: return visitModuleDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -40324,7 +41965,8 @@ var ts; } } function visitSourceFile(node) { - var alwaysStrict = compilerOptions.alwaysStrict && !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && + !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -40345,7 +41987,7 @@ var ts; var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -40371,7 +42013,7 @@ var ts; } if (statements.length > 1) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 2097152); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304); } return ts.singleOrMany(statements); } @@ -40406,7 +42048,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85; })); var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, node); @@ -40417,7 +42059,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - ts.setEmitFlags(classExpression, 32768 | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -40466,18 +42108,18 @@ var ts; if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } - ts.addRange(statements, endLexicalEnvironment()); + statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { var statements = ctor.body.statements; - var index = ts.addPrologueDirectives(result, statements, false, visitor); + var index = ts.addPrologue(result, statements, false, visitor); if (index === statements.length) { return index; } var statement = statements[index]; - if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -40511,13 +42153,13 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 148 + return member.kind === 149 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { - var property = properties_8[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -40526,8 +42168,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -40584,12 +42226,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 152: case 153: + case 154: return getAllDecoratorsOfAccessors(node, member); - case 150: + case 151: return getAllDecoratorsOfMethod(member); - case 148: + case 149: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -40668,7 +42310,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 148 + ? member.kind === 149 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -40737,13 +42379,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); @@ -40752,37 +42394,37 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 150 - || kind === 152 + return kind === 151 || kind === 153 - || kind === 148; + || kind === 154 + || kind === 149; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 150; + return node.kind === 151; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 228: - case 198: + case 229: + case 199: return ts.getFirstConstructorWithBody(node) !== undefined; - case 150: - case 152: + case 151: case 153: + case 154: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 148: - case 145: - case 152: - return serializeTypeNode(node.type); + case 149: + case 146: case 153: + return serializeTypeNode(node.type); + case 154: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 228: - case 198: - case 150: + case 229: + case 199: + case 151: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -40814,7 +42456,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 152) { + if (container && node.kind === 153) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -40826,7 +42468,7 @@ var ts; if (ts.isFunctionLike(node) && node.type) { return serializeTypeNode(node.type); } - else if (ts.isAsyncFunctionLike(node)) { + else if (ts.isAsyncFunction(node)) { return ts.createIdentifier("Promise"); } return ts.createVoidZero(); @@ -40836,56 +42478,58 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 104: - case 138: - case 94: - case 129: + case 105: + case 139: + case 95: + case 130: return ts.createVoidZero(); - case 167: + case 168: return serializeTypeNode(node.type); - case 159: case 160: + case 161: return ts.createIdentifier("Function"); - case 163: case 164: + case 165: return ts.createIdentifier("Array"); - case 157: - case 121: + case 158: + case 122: return ts.createIdentifier("Boolean"); - case 135: + case 136: return ts.createIdentifier("String"); - case 172: + case 134: + return ts.createIdentifier("Object"); + case 173: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 100: - case 85: + case 101: + case 86: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 132: + case 133: return ts.createIdentifier("Number"); - case 136: + case 137: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 158: + case 159: return serializeTypeReferenceNode(node); + case 167: case 166: - case 165: return serializeUnionOrIntersectionType(node); - case 161: - case 169: + case 162: case 170: case 171: - case 162: - case 118: - case 168: + case 172: + case 163: + case 119: + case 169: break; default: ts.Debug.failBadSyntaxKind(node); @@ -40952,7 +42596,7 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 70: + case 71: var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; @@ -40961,13 +42605,13 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 142: + case 143: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 70) { + if (node.left.kind === 71) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -41012,9 +42656,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 84) { + if (node.token === 85) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(84, types), node); + return ts.setTextRange(ts.createHeritageClause(85, types), node); } return undefined; } @@ -41028,13 +42672,13 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - return ts.visitEachChild(node, visitor, context); + return ts.updateConstructor(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context)); } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); if (updated !== node) { ts.setCommentRange(updated, node); ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); @@ -41070,7 +42714,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); + var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); if (isNamespaceExport(node)) { var statements = [updated]; addExportMemberAssignment(statements, node); @@ -41079,10 +42723,10 @@ var ts; return updated; } function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { + if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createOmittedExpression(); } - var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); return updated; } function visitArrowFunction(node) { @@ -41246,20 +42890,20 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 231) { + if (node.kind === 232) { ts.setSourceMapRange(statement.declarationList, node); } else { ts.setSourceMapRange(statement, node); } ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 1024 | 2097152); + ts.setEmitFlags(statement, 1024 | 4194304); statements.push(statement); return true; } else { var mergeMarker = ts.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 | 2097152); + ts.setEmitFlags(mergeMarker, 1536 | 4194304); statements.push(mergeMarker); return false; } @@ -41307,7 +42951,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 233) { + if (body.kind === 234) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -41331,13 +42975,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 233) { + if (body.kind !== 234) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 232) { + if (moduleDeclaration.body.kind === 233) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -41346,18 +42990,18 @@ var ts; if (!node.importClause) { return node; } - var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) : undefined; } function visitImportClause(node) { var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; - var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings); return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 239) { + if (node.kind === 240) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -41380,7 +43024,7 @@ var ts; if (!resolver.isValueAliasDeclaration(node)) { return undefined; } - var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports); return exportClause ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) : undefined; @@ -41478,32 +43122,36 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(70); + context.enableSubstitution(71); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(70); + context.enableSubstitution(71); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(70); - context.enableSubstitution(261); - context.enableEmitNotification(232); + context.enableSubstitution(71); + context.enableSubstitution(262); + context.enableEmitNotification(233); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 232; + return ts.getOriginalNode(node).kind === 233; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 231; + return ts.getOriginalNode(node).kind === 232; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSourceFile = currentSourceFile; + if (ts.isSourceFile(node)) { + currentSourceFile = node; + } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -41512,6 +43160,7 @@ var ts; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; + currentSourceFile = savedCurrentSourceFile; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); @@ -41539,11 +43188,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 178: - return substitutePropertyAccessExpression(node); case 179: + return substitutePropertyAccessExpression(node); + case 180: return substituteElementAccessExpression(node); } return node; @@ -41573,9 +43222,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 264) { - var substitute = (applicableSubstitutions & 2 && container.kind === 232) || - (applicableSubstitutions & 8 && container.kind === 231); + if (container && container.kind !== 265) { + var substitute = (applicableSubstitutions & 2 && container.kind === 233) || + (applicableSubstitutions & 8 && container.kind === 232); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -41592,16 +43241,14 @@ var ts; function substituteConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { + ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); - ts.setSourceMapRange(substitute, node); - ts.setCommentRange(substitute, node); if (!compilerOptions.removeComments) { var propertyName = ts.isPropertyAccessExpression(node) ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - substitute.trailingComment = " " + propertyName + " "; + ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " "); } - ts.setConstantValue(node, constantValue); return substitute; } return node; @@ -41616,40 +43263,7 @@ var ts; } } ts.transformTypeScript = transformTypeScript; - var paramHelper = { - name: "typescript:param", - scoped: false, - priority: 4, - text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" - }; - function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ - ts.createLiteral(parameterOffset), - expression - ]), location); - } - var metadataHelper = { - name: "typescript:metadata", - scoped: false, - priority: 3, - text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" - }; - function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), undefined, [ - ts.createLiteral(metadataKey), - metadataValue - ]); - } - var decorateHelper = { - name: "typescript:decorate", - scoped: false, - priority: 2, - text: "\n var __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 };" - }; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { - context.requestEmitHelper(decorateHelper); var argumentsArray = []; argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); @@ -41659,13 +43273,305 @@ var ts; argumentsArray.push(descriptor); } } + context.requestEmitHelper(decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } + var decorateHelper = { + name: "typescript:decorate", + scoped: false, + priority: 2, + text: "\n var __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 };" + }; + function createMetadataHelper(context, metadataKey, metadataValue) { + context.requestEmitHelper(metadataHelper); + return ts.createCall(ts.getHelperName("__metadata"), undefined, [ + ts.createLiteral(metadataKey), + metadataValue + ]); + } + var metadataHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" + }; + function createParamHelper(context, expression, parameterOffset, location) { + context.requestEmitHelper(paramHelper); + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ + ts.createLiteral(parameterOffset), + expression + ]), location); + } + var paramHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" + }; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + function transformES2017(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFile; + var enabledSubstitutions; + var enclosingSuperContainerFlags = 0; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; + } + function visitor(node) { + if ((node.transformFlags & 16) === 0) { + return node; + } + switch (node.kind) { + case 120: + return undefined; + case 191: + return visitAwaitExpression(node); + case 151: + return visitMethodDeclaration(node); + case 228: + return visitFunctionDeclaration(node); + case 186: + return visitFunctionExpression(node); + case 187: + return visitArrowFunction(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); + } + function visitMethodDeclaration(node) { + return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitFunctionDeclaration(node) { + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitFunctionExpression(node) { + return ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitArrowFunction(node) { + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function transformAsyncFunctionBody(node) { + resumeLexicalEnvironment(); + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 187; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; + } + else { + var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); + var declarations = endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(expression); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); + } + return expression; + } + } + function transformFunctionBodyWorker(body, start) { + if (ts.isBlock(body)) { + return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); + } + else { + startLexicalEnvironment(); + var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); + var declarations = endLexicalEnvironment(); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); + } + } + function getPromiseConstructor(type) { + var typeName = type && ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(181); + context.enableSubstitution(179); + context.enableSubstitution(180); + context.enableEmitNotification(229); + context.enableEmitNotification(151); + context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(152); + } + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179: + return substitutePropertyAccessExpression(node); + case 180: + return substituteElementAccessExpression(node); + case 181: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 + || kind === 152 + || kind === 151 + || kind === 153 + || kind === 154; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); + } + } + } + ts.transformES2017 = transformES2017; + var awaiterHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: "\n var __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 };" + }; + function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + context.requestEmitHelper(awaiterHelper); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(39), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; + return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ + ts.createThis(), + hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), + promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), + generatorFunc + ]); + } + ts.asyncSuperHelper = { + name: "typescript:async-super", + scoped: true, + text: "\n const _super = name => super[name];\n " + }; + ts.advancedAsyncSuperHelper = { + name: "typescript:advanced-async-super", + scoped: true, + text: "\n const _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);\n " + }; +})(ts || (ts = {})); +var ts; +(function (ts) { + var ESNextSubstitutionFlags; + (function (ESNextSubstitutionFlags) { + ESNextSubstitutionFlags[ESNextSubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ESNextSubstitutionFlags || (ESNextSubstitutionFlags = {})); function transformESNext(context) { - var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + var enabledSubstitutions; + var enclosingFunctionFlags; + var enclosingSuperContainerFlags = 0; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -41681,53 +43587,93 @@ var ts; function visitorNoDestructuringValue(node) { return visitorWorker(node, true); } + function visitorNoAsyncModifier(node) { + if (node.kind === 120) { + return undefined; + } + return node; + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 8) === 0) { return node; } switch (node.kind) { - case 177: + case 191: + return visitAwaitExpression(node); + case 197: + return visitYieldExpression(node); + case 222: + return visitLabeledStatement(node); + case 178: return visitObjectLiteralExpression(node); - case 193: + case 194: return visitBinaryExpression(node, noDestructuringValue); - case 225: + case 226: return visitVariableDeclaration(node); - case 215: - return visitForOfStatement(node); - case 213: + case 216: + return visitForOfStatement(node, undefined); + case 214: return visitForStatement(node); - case 189: + case 190: return visitVoidExpression(node); - case 151: - return visitConstructorDeclaration(node); - case 150: - return visitMethodDeclaration(node); case 152: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 151: + return visitMethodDeclaration(node); case 153: + return visitGetAccessorDeclaration(node); + case 154: return visitSetAccessorDeclaration(node); - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); case 186: + return visitFunctionExpression(node); + case 187: return visitArrowFunction(node); - case 145: + case 146: return visitParameter(node); - case 209: + case 210: return visitExpressionStatement(node); - case 184: + case 185: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); } } + function visitAwaitExpression(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.createArrayLiteral([ts.createLiteral("await"), expression])), node), node); + } + return ts.visitEachChild(node, visitor, context); + } + function visitYieldExpression(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.updateYield(node, node.asteriskToken, node.asteriskToken + ? createAsyncDelegatorHelper(context, expression, expression) + : ts.createArrayLiteral(expression + ? [ts.createLiteral("yield"), expression] + : [ts.createLiteral("yield")])); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var statement = ts.unwrapInnermostStatementOfLabel(node); + if (statement.kind === 216 && statement.awaitModifier) { + return visitForOfStatement(statement, node); + } + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), node); + } + return ts.visitEachChild(node, visitor, context); + } function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 262) { + if (e.kind === 263) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -41739,7 +43685,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 260) { + if (e.kind === 261) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -41756,7 +43702,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 177) { + if (objects.length && objects[0].kind !== 178) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -41773,7 +43719,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); } - else if (node.operatorToken.kind === 25) { + else if (node.operatorToken.kind === 26) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -41790,69 +43736,202 @@ var ts; function visitVoidExpression(node) { return ts.visitEachChild(node, visitorNoDestructuringValue, context); } - function visitForOfStatement(node) { - var leadingStatements; - var temp; - var initializer = ts.skipParentheses(node.initializer); - if (initializer.transformFlags & 1048576) { - if (ts.isVariableDeclarationList(initializer)) { - temp = ts.createTempVariable(undefined); - var firstDeclaration = ts.firstOrUndefined(initializer.declarations); - var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); - if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); - ts.setTextRange(statement, initializer); - leadingStatements = ts.append(leadingStatements, statement); - } - } - else if (ts.isAssignmentPattern(initializer)) { - temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); - } + function visitForOfStatement(node, outermostLabeledStatement) { + if (node.initializer.transformFlags & 1048576) { + node = transformForOfStatementWithObjectRest(node); } - if (temp) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) - : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); - return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + if (node.awaitModifier) { + return transformForAwaitOfStatement(node, outermostLabeledStatement); + } + else { + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); + } + } + function transformForOfStatementWithObjectRest(node) { + var initializerWithoutParens = ts.skipParentheses(node.initializer); + if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) { + var bodyLocation = void 0; + var statementsLocation = void 0; + var temp = ts.createTempVariable(undefined); + var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)]; + if (ts.isBlock(node.statement)) { + ts.addRange(statements, node.statement.statements); + bodyLocation = node.statement; + statementsLocation = node.statement.statements; + } + return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) - ], 1), node.initializer), expression, block); + ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation)); } - return ts.visitEachChild(node, visitor, context); + return node; + } + function convertForOfStatementHead(node, boundValue) { + var binding = ts.createForOfBindingStatement(node.initializer, boundValue); + var bodyLocation; + var statementsLocation; + var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384); + } + function transformForAwaitOfStatement(node, outermostLabeledStatement) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(undefined); + var values = createAsyncValuesHelper(context, expression, node.expression); + var next = ts.createYield(undefined, enclosingFunctionFlags & 1 + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []) + ]) + : ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, [])); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression), + ts.createVariableDeclaration(result, undefined, next) + ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"))), node), 256); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1)), ts.createBlock([ + ts.createTry(ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createYield(undefined, enclosingFunctionFlags & 1 + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createFunctionCall(returnMethod, iterator, []) + ]) + : ts.createFunctionCall(returnMethod, iterator, [])))), 1) + ]), undefined, ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) + ]), 1)) + ])); } function visitParameter(node) { if (node.transformFlags & 1048576) { - return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } function visitConstructorDeclaration(node) { - return ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitGetAccessorDeclaration(node) { - return ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitSetAccessorDeclaration(node) { - return ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitMethodDeclaration(node) { - return ts.updateMethod(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(undefined, visitor, ts.isToken), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; + } + function transformAsyncGeneratorFunctionBody(node) { + resumeLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); + appendObjectRestAssignmentsIfNeeded(statements, node); + statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(39), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.updateBlock(node.body, statements); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; } function transformFunctionBody(node) { resumeLexicalEnvironment(); - var leadingStatements; + var statementOffset = 0; + var statements = []; + var body = ts.visitNode(node.body, visitor, ts.isConciseBody); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologue(statements, body.statements, false, visitor); + } + ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node)); + var trailingStatements = endLexicalEnvironment(); + if (statementOffset > 0 || ts.some(statements) || ts.some(trailingStatements)) { + var block = ts.convertToFunctionBody(body, true); + ts.addRange(statements, block.statements.slice(statementOffset)); + ts.addRange(statements, trailingStatements); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); + } + return body; + } + function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; if (parameter.transformFlags & 1048576) { @@ -41860,18 +43939,96 @@ var ts; var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations)); - ts.setEmitFlags(statement, 524288); - leadingStatements = ts.append(leadingStatements, statement); + ts.setEmitFlags(statement, 1048576); + statements = ts.append(statements, statement); } } } - var body = ts.visitNode(node.body, visitor, ts.isConciseBody); - var trailingStatements = endLexicalEnvironment(); - if (ts.some(leadingStatements) || ts.some(trailingStatements)) { - var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); + return statements; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(181); + context.enableSubstitution(179); + context.enableSubstitution(180); + context.enableEmitNotification(229); + context.enableEmitNotification(151); + context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(152); + } + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179: + return substitutePropertyAccessExpression(node); + case 180: + return substituteElementAccessExpression(node); + case 181: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 + || kind === 152 + || kind === 151 + || kind === 153 + || kind === 154; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } - return body; } } ts.transformESNext = transformESNext; @@ -41889,21 +44046,51 @@ var ts; return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; + var asyncGeneratorHelper = { + name: "typescript:asyncGenerator", + scoped: false, + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + }; + function createAsyncGeneratorHelper(context, generatorFunc) { + context.requestEmitHelper(asyncGeneratorHelper); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; + return ts.createCall(ts.getHelperName("__asyncGenerator"), undefined, [ + ts.createThis(), + ts.createIdentifier("arguments"), + generatorFunc + ]); + } + var asyncDelegator = { + name: "typescript:asyncDelegator", + scoped: false, + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " + }; + function createAsyncDelegatorHelper(context, expression, location) { + context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); + } + var asyncValues = { + name: "typescript:asyncValues", + scoped: false, + text: "\n var __asyncValues = (this && this.__asyncIterator) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator];\n return m ? m.call(o) : typeof __values === \"function\" ? __values(o) : o[Symbol.iterator]();\n };\n " + }; + function createAsyncValuesHelper(context, expression, location) { + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), undefined, [expression]), location); + } })(ts || (ts = {})); var ts; (function (ts) { function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -41916,11 +44103,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 248: - return visitJsxElement(node, false); case 249: + return visitJsxElement(node, false); + case 250: return visitJsxSelfClosingElement(node, false); - case 255: + case 256: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -41930,11 +44117,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 255: + case 256: return visitJsxExpression(node); - case 248: - return visitJsxElement(node, true); case 249: + return visitJsxElement(node, true); + case 250: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -41988,7 +44175,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 255) { + else if (node.kind === 256) { if (node.expression === undefined) { return ts.createTrue(); } @@ -42048,7 +44235,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 248) { + if (node.kind === 249) { return getTagName(node.openingElement); } else { @@ -42332,268 +44519,6 @@ var ts; }); })(ts || (ts = {})); var ts; -(function (ts) { - var ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); - function transformES2017(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var resolver = context.getEmitResolver(); - var compilerOptions = context.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFile; - var enabledSubstitutions; - var currentSuperContainer; - var previousOnEmitNode = context.onEmitNode; - var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - var visited = ts.visitEachChild(node, visitor, context); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; - return visited; - } - function visitor(node) { - if ((node.transformFlags & 16) === 0) { - return node; - } - switch (node.kind) { - case 119: - return undefined; - case 190: - return visitAwaitExpression(node); - case 150: - return visitMethodDeclaration(node); - case 227: - return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); - case 186: - return visitArrowFunction(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); - } - function visitMethodDeclaration(node) { - return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { - return ts.createOmittedExpression(); - } - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function transformAsyncFunctionBody(node) { - resumeLexicalEnvironment(); - var original = ts.getOriginalNode(node, ts.isFunctionLike); - var nodeType = original.type; - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 186; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, true); - ts.setTextRange(block, node.body); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, advancedAsyncSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, asyncSuperHelper); - } - } - return block; - } - else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); - var declarations = endLexicalEnvironment(); - if (ts.some(declarations)) { - var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); - } - return expression; - } - } - function transformFunctionBodyWorker(body, start) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); - } - else { - startLexicalEnvironment(); - var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); - var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); - } - } - function getPromiseConstructor(type) { - var typeName = type && ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1) === 0) { - enabledSubstitutions |= 1; - context.enableSubstitution(180); - context.enableSubstitution(178); - context.enableSubstitution(179); - context.enableEmitNotification(228); - context.enableEmitNotification(150); - context.enableEmitNotification(152); - context.enableEmitNotification(153); - context.enableEmitNotification(151); - } - } - function substituteExpression(node) { - switch (node.kind) { - case 178: - return substitutePropertyAccessExpression(node); - case 179: - return substituteElementAccessExpression(node); - case 180: - if (enabledSubstitutions & 1) { - return substituteCallExpression(node); - } - break; - } - return node; - } - function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 1 && node.expression.kind === 96) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } - return node; - } - function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 1 && node.expression.kind === 96) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } - return node; - } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 228 - || kind === 151 - || kind === 150 - || kind === 152 - || kind === 153; - } - function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 && isSuperContainer(node)) { - var savedCurrentSuperContainer = currentSuperContainer; - currentSuperContainer = node; - previousOnEmitNode(hint, node, emitCallback); - currentSuperContainer = savedCurrentSuperContainer; - } - else { - previousOnEmitNode(hint, node, emitCallback); - } - } - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (hint === 1) { - return substituteExpression(node); - } - return node; - } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); - } - else { - return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } - } - ts.transformES2017 = transformES2017; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); - var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(38), undefined, undefined, [], undefined, body); - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 131072; - return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ - ts.createThis(), - hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), - promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), - generatorFunc - ]); - } - var awaiterHelper = { - name: "typescript:awaiter", - scoped: false, - priority: 5, - text: "\n var __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 asyncSuperHelper = { - name: "typescript:async-super", - scoped: true, - text: "\n const _super = name => super[name];" - }; - var advancedAsyncSuperHelper = { - name: "typescript:advanced-async-super", - scoped: true, - text: "\n const _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);" - }; -})(ts || (ts = {})); -var ts; (function (ts) { function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; @@ -42609,7 +44534,7 @@ var ts; return node; } switch (node.kind) { - case 193: + case 194: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -42617,9 +44542,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 61: + case 62: return visitExponentiationAssignmentExpression(node); - case 39: + case 40: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -42728,6 +44653,7 @@ var ts; })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -42762,7 +44688,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 - && node.kind === 218 + && node.kind === 219 && !node.expression; } function shouldVisitNode(node) { @@ -42786,100 +44712,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 96) { + if (node.kind === 97) { return visitSuperKeyword(true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 114: + case 115: return undefined; - case 228: + case 229: return visitClassDeclaration(node); - case 198: + case 199: return visitClassExpression(node); - case 145: + case 146: return visitParameter(node); - case 227: + case 228: return visitFunctionDeclaration(node); - case 186: + case 187: return visitArrowFunction(node); - case 185: + case 186: return visitFunctionExpression(node); - case 225: - return visitVariableDeclaration(node); - case 70: - return visitIdentifier(node); case 226: + return visitVariableDeclaration(node); + case 71: + return visitIdentifier(node); + case 227: return visitVariableDeclarationList(node); - case 220: - return visitSwitchStatement(node); - case 234: - return visitCaseBlock(node); - case 206: - return visitBlock(node, false); - case 217: - case 216: - return visitBreakOrContinueStatement(node); case 221: + return visitSwitchStatement(node); + case 235: + return visitCaseBlock(node); + case 207: + return visitBlock(node, false); + case 218: + case 217: + return visitBreakOrContinueStatement(node); + case 222: return visitLabeledStatement(node); - case 211: case 212: - return visitDoOrWhileStatement(node, undefined); case 213: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 214: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 215: + return visitForInStatement(node, undefined); + case 216: return visitForOfStatement(node, undefined); - case 209: + case 210: return visitExpressionStatement(node); - case 177: + case 178: return visitObjectLiteralExpression(node); - case 259: + case 260: return visitCatchClause(node); - case 261: + case 262: return visitShorthandPropertyAssignment(node); - case 143: + case 144: return visitComputedPropertyName(node); - case 176: + case 177: return visitArrayLiteralExpression(node); - case 180: - return visitCallExpression(node); case 181: + return visitCallExpression(node); + case 182: return visitNewExpression(node); - case 184: + case 185: return visitParenthesizedExpression(node, true); - case 193: + case 194: return visitBinaryExpression(node, true); - case 12: case 13: case 14: case 15: + case 16: return visitTemplateLiteral(node); - case 182: + case 9: + return visitStringLiteral(node); + case 8: + return visitNumericLiteral(node); + case 183: return visitTaggedTemplateExpression(node); - case 195: - return visitTemplateExpression(node); case 196: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 197: + return visitYieldExpression(node); + case 198: return visitSpreadElement(node); - case 96: + case 97: return visitSuperKeyword(false); - case 98: + case 99: return visitThisKeyword(node); - case 203: + case 204: return visitMetaProperty(node); - case 150: + case 151: return visitMethodDeclaration(node); - case 152: case 153: + case 154: return visitAccessorDeclaration(node); - case 207: + case 208: return visitVariableStatement(node); - case 218: + case 219: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -42889,8 +44819,9 @@ var ts; var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); + var statementOffset = ts.addStandardPrologue(statements, node.statements, false); addCaptureThisForNodeIfNeeded(statements, node); + statementOffset = ts.addCustomPrologue(statements, node.statements, statementOffset, visitor); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); @@ -42956,13 +44887,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 217 ? 2 : 4; + var jump = node.kind === 218 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 217) { + if (node.kind === 218) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -42972,7 +44903,7 @@ var ts; } } else { - if (node.kind === 217) { + if (node.kind === 218) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -42991,10 +44922,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 25, copyExpr); + expr = ts.createBinary(expr, 26, copyExpr); } } - returnExpression = ts.createBinary(expr, 25, returnExpression); + returnExpression = ts.createBinary(expr, 26, returnExpression); } return ts.createReturn(returnExpression); } @@ -43018,9 +44949,9 @@ var ts; statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 2097152) === 0) { + if ((emitFlags & 4194304) === 0) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 2097152); + ts.setEmitFlags(statement, emitFlags | 4194304); } return ts.singleOrMany(statements); } @@ -43033,8 +44964,8 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (ts.getEmitFlags(node) & 32768) { - ts.setEmitFlags(classFunction, 32768); + if (ts.getEmitFlags(node) & 65536) { + ts.setEmitFlags(classFunction, 65536); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; @@ -43052,8 +44983,8 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); - var localName = ts.getLocalName(node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18); + var localName = ts.getInternalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; ts.setEmitFlags(outer, 1536); @@ -43077,7 +45008,7 @@ var ts; var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); @@ -43098,14 +45029,17 @@ var ts; statementOffset = 0; } else if (constructor) { - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + statementOffset = ts.addStandardPrologue(statements, constructor.body.statements, false); } if (constructor) { addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + if (!hasSynthesizedSuper) { + statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor); + } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; @@ -43133,17 +45067,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 218) { + if (statement.kind === 219) { return true; } - else if (statement.kind === 210) { + else if (statement.kind === 211) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 206) { + else if (statement.kind === 207) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -43172,7 +45106,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 210 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -43180,8 +45114,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 193 - || superCallExpression.left.kind !== 180) { + if (superCallExpression.kind !== 194 + || superCallExpression.left.kind !== 181) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -43238,10 +45172,10 @@ var ts; function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 524288)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 1048576)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 524288)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { @@ -43251,11 +45185,11 @@ var ts; ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 | 32 | 524288); + ts.setEmitFlags(statement, 384 | 32 | 1048576); statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 71 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -43269,7 +45203,7 @@ var ts; var temp = ts.createLoopVariable(); statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ])), parameter), 524288)); + ])), parameter), 1048576)); var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ @@ -43277,12 +45211,12 @@ var ts; ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); - ts.setEmitFlags(forStatement, 524288); + ts.setEmitFlags(forStatement, 1048576); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 186) { + if (node.transformFlags & 32768 && node.kind !== 187) { captureThisForNode(statements, node, ts.createThis()); } } @@ -43291,7 +45225,7 @@ var ts; var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setEmitFlags(captureThisStatement, 1536 | 1048576); ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); @@ -43300,19 +45234,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 186: + case 187: return statements; - case 150: - case 152: + case 151: case 153: + case 154: newTarget = ts.createVoidZero(); break; - case 151: + case 152: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 227: - case 185: - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + case 228: + case 186: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: ts.Debug.failBadSyntaxKind(node); @@ -43332,20 +45266,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 205: + case 206: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 150: + case 151: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 152: case 153: + case 154: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 151: + case 152: break; default: ts.Debug.failBadSyntaxKind(node); @@ -43431,7 +45365,7 @@ var ts; return func; } function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 131072 + var ancestorFacts = ts.getEmitFlags(node) & 262144 ? enterSubtree(16278, 69) : enterSubtree(16286, 65); var savedConvertedLoopState = convertedLoopState; @@ -43445,7 +45379,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); + return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; @@ -43460,7 +45394,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body); } function transformFunctionLikeToExpression(node, location, name, container) { var savedConvertedLoopState = convertedLoopState; @@ -43470,7 +45404,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 228 || node.kind === 186)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -43487,7 +45421,7 @@ var ts; var statementOffset; resumeLexicalEnvironment(); if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + statementOffset = ts.addStandardPrologue(statements, body.statements, false); } addCaptureThisForNodeIfNeeded(statements, node); addDefaultValueAssignmentsIfNeeded(statements, node); @@ -43496,6 +45430,7 @@ var ts; multiLine = true; } if (ts.isBlock(body)) { + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor); statementsLocation = body.statements; ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); if (!multiLine && body.multiLine) { @@ -43503,7 +45438,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 186); + ts.Debug.assert(node.kind === 187); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -43533,7 +45468,7 @@ var ts; ts.setEmitFlags(block, 1); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17, closeBraceLocation); + ts.setTokenSourceMapRange(block, 18, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -43555,9 +45490,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 184: + case 185: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 193: + case 194: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -43565,9 +45500,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 184: + case 185: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 193: + case 194: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -43593,13 +45528,13 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 58, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } - (assignments || (assignments = [])).push(assignment); + assignments = ts.append(assignments, assignment); } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 26, acc); })), node); } else { updated = undefined; @@ -43684,11 +45619,24 @@ var ts; if (convertedLoopState && !convertedLoopState.labels) { convertedLoopState.labels = ts.createMap(); } - var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); - return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) ? visitIterationStatement(statement, node) : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 212: + case 213: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 214: + return visitForStatement(node, outermostLabeledStatement); + case 215: + return visitForInStatement(node, outermostLabeledStatement); + case 216: + return visitForOfStatement(node, outermostLabeledStatement); + } + } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); @@ -43705,27 +45653,19 @@ var ts; return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } - function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; + function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 - ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) - : ts.createTempVariable(undefined); - var elementAccess = ts.createElementAccess(rhsReference, counter); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { + if (ts.isVariableDeclarationList(node.initializer)) { + if (node.initializer.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations); - ts.setOriginalNode(declarationList, initializer); - ts.setTextRange(declarationList, initializer); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue); + var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); + ts.setOriginalNode(declarationList, node.initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); @@ -43733,18 +45673,19 @@ var ts; } else { statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue) + ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); } } else { - var assignment = ts.createAssignment(initializer, elementAccess); + var assignment = ts.createAssignment(node.initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(assignment, visitor, context, 0))); + ts.aggregateTransformFlags(assignment); + statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); } else { - assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); + assignment.end = node.initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); } } var bodyLocation; @@ -43753,7 +45694,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -43763,30 +45704,49 @@ var ts; statements.push(statement); } } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384); + } + function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var counter = ts.createLoopVariable(); + var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); - ts.setTextRange(body, bodyLocation); - ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) - ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); + ]), node.expression), 2097152), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), convertForOfStatementHead(node, ts.createElementAccess(rhsReference, counter), convertedLoopBodyStatements)), node); ts.setEmitFlags(forStatement, 256); ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } - function visitIterationStatement(node, outermostLabeledStatement) { - switch (node.kind) { - case 211: - case 212: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 213: - return visitForStatement(node, outermostLabeledStatement); - case 214: - return visitForInStatement(node, outermostLabeledStatement); - case 215: - return visitForOfStatement(node, outermostLabeledStatement); - } + function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(undefined); + var values = ts.createValuesHelper(context, expression, node.expression); + var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression), + ts.createVariableDeclaration(result, undefined, next) + ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1)), ts.createBlock([ + ts.createTry(ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), + ]), undefined, ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) + ]), 1)) + ])); } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -43799,7 +45759,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 143) { + if (property.name.kind === 144) { numInitialProperties = i; break; } @@ -43810,7 +45770,7 @@ var ts; } var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -43830,7 +45790,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 70) { + if (node.kind === 71) { state.hoistedLocalVariables.push(node); } else { @@ -43861,11 +45821,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 213: case 214: case 215: + case 216: var initializer = node.initializer; - if (initializer && initializer.kind === 226) { + if (initializer && initializer.kind === 227) { loopInitializer = initializer; } break; @@ -43892,7 +45852,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -43910,18 +45870,18 @@ var ts; else { loopBody = ts.createBlock([loopBody], true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 - && (node.statement.transformFlags & 16777216) !== 0; + var containsYield = (node.statement.transformFlags & 16777216) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8; } if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 131072; + loopBodyFlags |= 262144; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ]), 1048576)); + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(39) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ]), 2097152)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -43966,7 +45926,7 @@ var ts; if (extraVariableDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -43986,7 +45946,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 57, source); + return ts.createBinary(target, 58, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -44001,7 +45961,9 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; + var callResult = isAsyncBlockContainingAwait + ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) + : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -44020,10 +45982,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 34, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -44089,20 +46051,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 152: case 153: + case 154: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 150: + case 151: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 260: + case 261: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 261: + case 262: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -44171,7 +46133,20 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16286, 65); - var updated = ts.visitEachChild(node, visitor, context); + var updated; + if (node.transformFlags & 32768) { + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (node.kind === 153) { + updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + } + else { + updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body); + } + } + else { + updated = ts.visitEachChild(node, visitor, context); + } exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; return updated; @@ -44205,7 +46180,7 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { ts.setEmitFlags(thisArg, 4); } var resultingCall; @@ -44215,7 +46190,7 @@ var ts; else { resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -44237,13 +46212,27 @@ var ts; var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 - ? ts.createArraySlice(segments[0]) - : segments[0]; + if (compilerOptions.downlevelIteration) { + if (segments.length === 1) { + var firstSegment = segments[0]; + if (ts.isCallExpression(firstSegment) + && ts.isIdentifier(firstSegment.expression) + && (ts.getEmitFlags(firstSegment.expression) & 4096) + && firstSegment.expression.text === "___spread") { + return segments[0]; + } + } + return ts.createSpreadHelper(context, segments); + } + else { + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 177 + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + return ts.createArrayConcat(segments.shift(), segments); } - return ts.createArrayConcat(segments.shift(), segments); } function partitionSpread(node) { return ts.isSpreadExpression(node) @@ -44265,6 +46254,18 @@ var ts; function visitTemplateLiteral(node) { return ts.setTextRange(ts.createLiteral(node.text), node); } + function visitStringLiteral(node) { + if (node.hasExtendedUnicodeEscape) { + return ts.setTextRange(ts.createLiteral(node.text), node); + } + return node; + } + function visitNumericLiteral(node) { + if (node.numericLiteralFlags & 48) { + return ts.setTextRange(ts.createNumericLiteral(node.text), node); + } + return node; + } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -44294,7 +46295,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 12 || node.kind === 15; + var isLast = node.kind === 13 || node.kind === 16; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.setTextRange(ts.createLiteral(text), node); @@ -44336,7 +46337,7 @@ var ts; : ts.createIdentifier("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 93 && node.name.text === "target") { + if (node.keywordToken === 94 && node.name.text === "target") { if (hierarchyFacts & 8192) { hierarchyFacts |= 32768; } @@ -44361,20 +46362,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(70); + context.enableSubstitution(71); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(98); - context.enableEmitNotification(151); - context.enableEmitNotification(150); + context.enableSubstitution(99); context.enableEmitNotification(152); + context.enableEmitNotification(151); context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(187); context.enableEmitNotification(186); - context.enableEmitNotification(185); - context.enableEmitNotification(227); + context.enableEmitNotification(228); } } function onSubstituteNode(hint, node) { @@ -44388,10 +46389,10 @@ var ts; return node; } function substituteIdentifier(node) { - if (enabledSubstitutions & 2) { + if (enabledSubstitutions & 2 && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + return ts.setTextRange(ts.getGeneratedNameForNode(original), node); } } return node; @@ -44399,10 +46400,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 175: - case 228: - case 231: - case 225: + case 176: + case 229: + case 232: + case 226: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -44410,22 +46411,40 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 98: + case 99: return substituteThisKeyword(node); } return node; } function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2) { + if (enabledSubstitutions & 2 && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { + return ts.setTextRange(ts.getGeneratedNameForNode(declaration.name), node); } } return node; } + function isPartOfClassBody(declaration, node) { + var currentNode = ts.getParseTreeNode(node); + if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) { + return false; + } + var blockScope = ts.getEnclosingBlockScopeContainer(declaration); + while (currentNode) { + if (currentNode === blockScope || currentNode === declaration) { + return false; + } + if (ts.isClassElement(currentNode) && currentNode.parent === declaration) { + return currentNode.kind !== 149 + || (ts.getModifierFlags(currentNode) & 32) === 0; + } + currentNode = currentNode.parent; + } + return false; + } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && hierarchyFacts & 16) { @@ -44434,8 +46453,9 @@ var ts; return node; } function getClassMemberPrefix(node, member) { - var expression = ts.getLocalName(node); - return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + return ts.hasModifier(member, 32) + ? ts.getInternalName(node) + : ts.createPropertyAccess(ts.getInternalName(node), "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { if (!constructor || !hasExtendsClause) { @@ -44445,19 +46465,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 210) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 181) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 198) { return false; } var expression = callArgument.expression; @@ -44600,13 +46620,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 211: - return visitDoStatement(node); case 212: + return visitDoStatement(node); + case 213: return visitWhileStatement(node); - case 220: - return visitSwitchStatement(node); case 221: + return visitSwitchStatement(node); + case 222: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -44614,24 +46634,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: + case 186: return visitFunctionExpression(node); - case 152: case 153: + case 154: return visitAccessorDeclaration(node); - case 207: + case 208: return visitVariableStatement(node); - case 213: - return visitForStatement(node); case 214: + return visitForStatement(node); + case 215: return visitForInStatement(node); - case 217: - return visitBreakStatement(node); - case 216: - return visitContinueStatement(node); case 218: + return visitBreakStatement(node); + case 217: + return visitContinueStatement(node); + case 219: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -44647,21 +46667,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 193: - return visitBinaryExpression(node); case 194: + return visitBinaryExpression(node); + case 195: return visitConditionalExpression(node); - case 196: + case 197: return visitYieldExpression(node); - case 176: - return visitArrayLiteralExpression(node); case 177: + return visitArrayLiteralExpression(node); + case 178: return visitObjectLiteralExpression(node); - case 179: - return visitElementAccessExpression(node); case 180: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 181: + return visitCallExpression(node); + case 182: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -44669,9 +46689,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: + case 186: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -44679,7 +46699,7 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { @@ -44700,7 +46720,7 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { @@ -44753,7 +46773,7 @@ var ts; operationLocations = undefined; state = ts.createTempVariable(undefined); resumeLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + var statementOffset = ts.addPrologue(statements, body.statements, false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); ts.addRange(statements, endLexicalEnvironment()); @@ -44779,7 +46799,7 @@ var ts; return undefined; } else { - if (ts.getEmitFlags(node) & 524288) { + if (ts.getEmitFlags(node) & 1048576) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -44804,23 +46824,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 58 - && kind <= 69; + return kind >= 59 + && kind <= 70; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; case 63: return 41; - case 64: return 44; + case 64: return 42; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; case 69: return 49; + case 70: return 50; } } function visitRightAssociativeBinaryExpression(node) { @@ -44828,10 +46848,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 178: + case 179: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 179: + case 180: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -44853,7 +46873,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 25) { + else if (node.operatorToken.kind === 26) { return visitCommaExpression(node); } var clone_5 = ts.getMutableClone(node); @@ -44867,7 +46887,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 52) { + if (node.operatorToken.kind === 53) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -44883,7 +46903,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { visit(node.left); visit(node.right); } @@ -44915,7 +46935,10 @@ var ts; var resumeLabel = defineLabel(); var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { - emitYieldStar(expression, node); + var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0 + ? ts.createValuesHelper(context, expression, node) + : expression; + emitYieldStar(iterator, node); } else { emitYield(expression, node); @@ -44928,25 +46951,27 @@ var ts; } function visitElements(elements, leadingElement, location, multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); - var temp = declareLocal(); - var hasAssignedTemp = false; + var temp; if (numInitialElements > 0) { + temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement ? [leadingElement].concat(initialElements) : initialElements)); leadingElement = undefined; - hasAssignedTemp = true; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); - return hasAssignedTemp + return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { + var hasAssignedTemp = temp !== undefined; + if (!temp) { + temp = declareLocal(); + } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); - hasAssignedTemp = true; leadingElement = undefined; expressions = []; } @@ -45027,38 +47052,38 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 206: + case 207: return transformAndEmitBlock(node); - case 209: - return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 211: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 212: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 213: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 214: + return transformAndEmitForStatement(node); + case 215: return transformAndEmitForInStatement(node); - case 216: - return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 218: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 219: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 220: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 221: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 222: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 223: + return transformAndEmitThrowStatement(node); + case 224: return transformAndEmitTryStatement(node); default: - return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); + return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); } } function transformAndEmitBlock(node) { @@ -45210,7 +47235,7 @@ var ts; beginScriptLoopBlock(); } var initializer = node.initializer; - if (ts.isVariableDeclarationList(initializer)) { + if (initializer && ts.isVariableDeclarationList(initializer)) { for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { var variable = _a[_i]; hoistVariableDeclaration(variable.name); @@ -45218,7 +47243,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = ts.updateFor(node, variables.length > 0 ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression, true), ts.visitNode(node.incrementor, visitor, ts.isExpression, true), ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -45276,7 +47301,7 @@ var ts; var variable = _a[_i]; hoistVariableDeclaration(variable.name); } - node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -45315,10 +47340,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function transformAndEmitReturnStatement(node) { - emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression, true), node); + emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node); } function visitReturnStatement(node) { - return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression, true), node); + return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node); } function transformAndEmitWithStatement(node) { if (containsYield(node)) { @@ -45341,7 +47366,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 257 && defaultClauseIndex === -1) { + if (clause.kind === 258 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -45351,7 +47376,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 256) { + if (clause.kind === 257) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -45467,7 +47492,7 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { + if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); @@ -45486,7 +47511,7 @@ var ts; } function cacheExpression(node) { var temp; - if (ts.isGeneratedIdentifier(node)) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) { return node; } temp = ts.createTempVariable(hoistVariableDeclaration); @@ -45578,15 +47603,22 @@ var ts; } function beginCatchBlock(variable) { ts.Debug.assert(peekBlockKind() === 0); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = []; - context.enableSubstitution(70); + var name; + if (ts.isGeneratedIdentifier(variable.name)) { + name = variable.name; + hoistVariableDeclaration(variable.name); + } + else { + var text = variable.name.text; + name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = []; + context.enableSubstitution(71); + } + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } - renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); var endLabel = exception.endLabel; @@ -45786,7 +47818,7 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = getInstructionName(instruction); + ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction)); return literal; } function createInlineBreak(label, location) { @@ -45868,7 +47900,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 524288)); } function buildStatements() { if (operations) { @@ -46139,7 +48171,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); var ts; @@ -46151,24 +48183,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(250); context.enableEmitNotification(251); - context.enableEmitNotification(249); + context.enableEmitNotification(252); + context.enableEmitNotification(250); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178); - context.enableSubstitution(260); + context.enableSubstitution(179); + context.enableSubstitution(261); return transformSourceFile; function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 250: case 251: - case 249: + case 252: + case 250: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -46204,7 +48236,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 && token <= 106) { + if (token >= 72 && token <= 107) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -46232,12 +48264,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(193); - context.enableSubstitution(191); + context.enableSubstitution(71); + context.enableSubstitution(194); context.enableSubstitution(192); - context.enableSubstitution(261); - context.enableEmitNotification(264); + context.enableSubstitution(193); + context.enableSubstitution(262); + context.enableEmitNotification(265); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -46245,9 +48277,7 @@ var ts; var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (ts.isDeclarationFile(node) || !(ts.isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } currentSourceFile = node; @@ -46259,17 +48289,24 @@ var ts; currentModuleInfo = undefined; return ts.aggregateTransformFlags(updated); } + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) { + return true; + } + return false; + } function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); + ts.addRange(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); @@ -46341,13 +48378,15 @@ var ts; var importNode = _c[_b]; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 4); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); + if (externalModuleName) { + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 4); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; @@ -46355,14 +48394,14 @@ var ts; function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); + ts.addRange(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); @@ -46387,23 +48426,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 243: + case 244: return visitExportDeclaration(node); - case 242: + case 243: return visitExportAssignment(node); - case 207: + case 208: return visitVariableStatement(node); - case 227: - return visitFunctionDeclaration(node); case 228: + return visitFunctionDeclaration(node); + case 229: return visitClassDeclaration(node); - case 299: + case 297: return visitMergeDeclarationMarker(node); - case 300: + case 298: return visitEndOfDeclarationMarker(node); default: return node; @@ -46601,14 +48640,14 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; + return (ts.getEmitFlags(node) & 4194304) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -46633,10 +48672,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239: + case 240: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240: + case 241: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -46721,7 +48760,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 524288); + ts.setEmitFlags(statement, 1048576); return statement; } function createExportStatement(name, value, location, allowComments) { @@ -46737,14 +48776,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264) { + if (node.kind === 265) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -46784,12 +48823,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 193: + case 194: return substituteBinaryExpression(node); + case 193: case 192: - case 191: return substituteUnaryExpression(node); } return node; @@ -46804,7 +48843,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 264) { + if (exportContainer && exportContainer.kind === 265) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -46840,15 +48879,15 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) + if ((node.operator === 43 || node.operator === 44) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) + var expression = node.kind === 193 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -46889,11 +48928,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(193); - context.enableSubstitution(191); + context.enableSubstitution(71); + context.enableSubstitution(194); context.enableSubstitution(192); - context.enableEmitNotification(264); + context.enableSubstitution(193); + context.enableEmitNotification(265); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -46953,17 +48992,19 @@ var ts; for (var i = 0; i < externalImports.length; i++) { var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - var groupIndex = groupIndices.get(text); - if (groupIndex !== undefined) { - dependencyGroups[groupIndex].externalImports.push(externalImport); - } - else { - groupIndices.set(text, dependencyGroups.length); - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); + if (externalModuleName) { + var text = externalModuleName.text; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices.set(text, dependencyGroups.length); + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } } return dependencyGroups; @@ -46971,11 +49012,12 @@ var ts; function createSystemModuleBody(node, dependencyGroups) { var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) ]))); - ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); @@ -46996,7 +49038,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 243 && externalImport.exportClause) { + if (externalImport.kind === 244 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -47019,7 +49061,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 243) { + if (externalImport.kind !== 244) { continue; } var exportDecl = externalImport; @@ -47071,15 +49113,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 237: + case 238: if (!entry.importClause) { break; } - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 243: + case 244: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -47101,13 +49143,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 243: + case 244: return undefined; - case 242: + case 243: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -47156,7 +49198,7 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); } else { hoistedStatements = ts.append(hoistedStatements, node); @@ -47227,8 +49269,8 @@ var ts; } } function shouldHoistVariableDeclarationList(node) { - return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 264 + return (ts.getEmitFlags(node) & 2097152) === 0 + && (enclosingBlockScopedContainer.kind === 265 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -47250,7 +49292,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -47258,7 +49300,7 @@ var ts; return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; + return (ts.getEmitFlags(node) & 4194304) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -47283,10 +49325,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239: + case 240: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240: + case 241: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -47385,43 +49427,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 207: + case 208: return visitVariableStatement(node); - case 227: - return visitFunctionDeclaration(node); case 228: + return visitFunctionDeclaration(node); + case 229: return visitClassDeclaration(node); - case 213: - return visitForStatement(node); case 214: - return visitForInStatement(node); + return visitForStatement(node); case 215: + return visitForInStatement(node); + case 216: return visitForOfStatement(node); - case 211: - return visitDoStatement(node); case 212: + return visitDoStatement(node); + case 213: return visitWhileStatement(node); - case 221: + case 222: return visitLabeledStatement(node); - case 219: - return visitWithStatement(node); case 220: + return visitWithStatement(node); + case 221: return visitSwitchStatement(node); - case 234: + case 235: return visitCaseBlock(node); - case 256: - return visitCaseClause(node); case 257: + return visitCaseClause(node); + case 258: return visitDefaultClause(node); - case 223: + case 224: return visitTryStatement(node); - case 259: + case 260: return visitCatchClause(node); - case 206: + case 207: return visitBlock(node); - case 299: + case 297: return visitMergeDeclarationMarker(node); - case 300: + case 298: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -47430,21 +49472,21 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForOf(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -47453,6 +49495,9 @@ var ts; && shouldHoistVariableDeclarationList(node); } function visitForInitializer(node) { + if (!node) { + return node; + } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -47466,16 +49511,16 @@ var ts; } } function visitDoStatement(node) { - return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); } function visitWhileStatement(node) { - return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitLabeledStatement(node) { - return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitWithStatement(node) { - return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitSwitchStatement(node) { return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); @@ -47512,7 +49557,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 193) { + && node.kind === 194) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -47529,7 +49574,7 @@ var ts; return ts.visitEachChild(node, destructuringVisitor, context); } function hasExportedReferenceInDestructuringTarget(node) { - if (ts.isAssignmentExpression(node)) { + if (ts.isAssignmentExpression(node, true)) { return hasExportedReferenceInDestructuringTarget(node.left); } else if (ts.isSpreadExpression(node)) { @@ -47549,7 +49594,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 264; + return container !== undefined && container.kind === 265; } else { return false; @@ -47557,14 +49602,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264) { + if (node.kind === 265) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -47595,12 +49640,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 193: + case 194: return substituteBinaryExpression(node); - case 191: case 192: + case 193: return substituteUnaryExpression(node); } return node; @@ -47645,22 +49690,22 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) + if ((node.operator === 43 || node.operator === 44) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 + var expression = node.kind === 193 ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 192) { - expression = node.operator === 42 + if (node.kind === 193) { + expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -47676,7 +49721,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 264) { + if (exportContainer && exportContainer.kind === 265) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -47704,8 +49749,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(264); - context.enableSubstitution(70); + context.enableEmitNotification(265); + context.enableSubstitution(71); var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { @@ -47716,7 +49761,7 @@ var ts; var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); if (externalHelpersModuleName) { var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); + var statementOffset = ts.addPrologue(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); @@ -47729,9 +49774,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 236: + case 237: return undefined; - case 242: + case 243: return visitExportAssignment(node); } return node; @@ -47780,16 +49825,24 @@ var ts; return ts.transformModule; } } + var TransformationState; + (function (TransformationState) { + TransformationState[TransformationState["Uninitialized"] = 0] = "Uninitialized"; + TransformationState[TransformationState["Initialized"] = 1] = "Initialized"; + TransformationState[TransformationState["Completed"] = 2] = "Completed"; + TransformationState[TransformationState["Disposed"] = 3] = "Disposed"; + })(TransformationState || (TransformationState = {})); var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); - function getTransformers(compilerOptions) { + function getTransformers(compilerOptions, customTransformers) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; + ts.addRange(transformers, customTransformers && customTransformers.before); transformers.push(ts.transformTypeScript); if (jsx === 2) { transformers.push(ts.transformJsx); @@ -47811,12 +49864,12 @@ var ts; if (languageVersion < 1) { transformers.push(ts.transformES5); } + ts.addRange(transformers, customTransformers && customTransformers.after); return transformers; } ts.getTransformers = getTransformers; - function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(301); - var lexicalEnvironmentDisabled = false; + function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { + var enabledSyntaxKindFeatures = new Array(299); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -47824,8 +49877,11 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; + var onSubstituteNode = function (_, node) { return node; }; + var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var state = 0; var context = { - getCompilerOptions: function () { return host.getCompilerOptions(); }, + getCompilerOptions: function () { return options; }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, startLexicalEnvironment: startLexicalEnvironment, @@ -47836,46 +49892,57 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, - isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, - isEmitNotificationEnabled: isEmitNotificationEnabled + isSubstitutionEnabled: isSubstitutionEnabled, + isEmitNotificationEnabled: isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode; }, + set onSubstituteNode(value) { + ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode; }, + set onEmitNode(value) { + ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + } }; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); - var transformed = ts.map(sourceFiles, transformSourceFile); - lexicalEnvironmentDisabled = true; + state = 1; + var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot); + state = 2; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, - emitNodeWithSubstitution: emitNodeWithSubstitution, - emitNodeWithNotification: emitNodeWithNotification + substituteNode: substituteNode, + emitNodeWithNotification: emitNodeWithNotification, + dispose: dispose }; - function transformSourceFile(sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return sourceFile; - } - return transformation(sourceFile); + function transformRoot(node) { + return node && (!ts.isSourceFile(node) || !ts.isDeclarationFile(node)) ? transformation(node) : node; } function enableSubstitution(kind) { + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 1; } function isSubstitutionEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(hint, node, emitCallback) { - if (node) { - if (isSubstitutionEnabled(node)) { - node = context.onSubstituteNode(hint, node) || node; - } - emitCallback(hint, node); - } + function substituteNode(hint, node) { + ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } function enableEmitNotification(kind) { + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 2; } function isEmitNotificationEnabled(node) { @@ -47883,9 +49950,10 @@ var ts; || (ts.getEmitFlags(node) & 2) !== 0; } function emitNodeWithNotification(hint, node, emitCallback) { + ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(hint, node, emitCallback); + onEmitNode(hint, node, emitCallback); } else { emitCallback(hint, node); @@ -47893,7 +49961,8 @@ var ts; } } function hoistVariableDeclaration(name) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); var decl = ts.createVariableDeclaration(name); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; @@ -47903,7 +49972,8 @@ var ts; } } function hoistFunctionDeclaration(func) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -47912,7 +49982,8 @@ var ts; } } function startLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; @@ -47921,17 +49992,20 @@ var ts; lexicalEnvironmentFunctionDeclarations = undefined; } function suspendLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } function resumeLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } function endLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { @@ -47958,18 +50032,36 @@ var ts; return statements; } function requestEmitHelper(helper) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } + function dispose() { + if (state < 3) { + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentVariableDeclarationsStack = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentFunctionDeclarationsStack = undefined; + onSubstituteNode = undefined; + onEmitNode = undefined; + emitHelpers = undefined; + state = 3; + } + } } - ts.transformFiles = transformFiles; + ts.transformNodes = transformNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -47984,8 +50076,8 @@ var ts; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { - var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; - var isBundledEmit = sourceFileOrBundle.kind === 265; + var sourceFiles = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 266; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -48047,7 +50139,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 237); + ts.Debug.assert(aliasEmitInfo.node.kind === 238); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -48120,10 +50212,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 225) { + if (declaration.kind === 226) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { + else if (declaration.kind === 241 || declaration.kind === 242 || declaration.kind === 239) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -48134,7 +50226,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 237) { + if (moduleElementEmitInfo.node.kind === 238) { moduleElementEmitInfo.isVisible = true; } else { @@ -48142,12 +50234,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 232) { + if (nodeToCheck.kind === 233) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 232) { + if (nodeToCheck.kind === 233) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -48209,7 +50301,7 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - var shouldUseResolverType = declaration.kind === 145 && + var shouldUseResolverType = declaration.kind === 146 && resolver.isRequiredInitializedParameter(declaration); if (type && !shouldUseResolverType) { emitType(type); @@ -48235,15 +50327,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var node = nodes_6[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { - var node = nodes_5[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -48269,74 +50361,74 @@ var ts; } function emitType(type) { switch (type.kind) { - case 118: - case 135: - case 132: - case 121: - case 133: + case 119: case 136: - case 104: - case 138: - case 94: - case 129: - case 168: - case 172: - return writeTextOfNode(currentText, type); - case 200: - return emitExpressionWithTypeArguments(type); - case 158: - return emitTypeReference(type); - case 161: - return emitTypeQuery(type); - case 163: - return emitArrayType(type); - case 164: - return emitTupleType(type); - case 165: - return emitUnionType(type); - case 166: - return emitIntersectionType(type); - case 167: - return emitParenType(type); + case 133: + case 122: + case 134: + case 137: + case 105: + case 139: + case 95: + case 130: case 169: - return emitTypeOperator(type); - case 170: - return emitIndexedAccessType(type); - case 171: - return emitMappedType(type); + case 173: + return writeTextOfNode(currentText, type); + case 201: + return emitExpressionWithTypeArguments(type); case 159: - case 160: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 162: + return emitTypeQuery(type); + case 164: + return emitArrayType(type); + case 165: + return emitTupleType(type); + case 166: + return emitUnionType(type); + case 167: + return emitIntersectionType(type); + case 168: + return emitParenType(type); + case 170: + return emitTypeOperator(type); + case 171: + return emitIndexedAccessType(type); + case 172: + return emitMappedType(type); + case 160: + case 161: + return emitSignatureDeclarationWithJsDocComments(type); + case 163: return emitTypeLiteral(type); - case 70: + case 71: return emitEntityName(type); - case 142: + case 143: return emitEntityName(type); - case 157: + case 158: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 70) { + if (entityName.kind === 71) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 142 ? entityName.left : entityName.expression; - var right = entityName.kind === 142 ? entityName.right : entityName.name; + var left = entityName.kind === 143 ? entityName.left : entityName.expression; + var right = entityName.kind === 143 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 237 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); + ts.Debug.assert(node.expression.kind === 71 || node.expression.kind === 179); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -48453,7 +50545,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -48474,7 +50566,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -48492,10 +50584,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 236 || - (node.parent.kind === 264 && isCurrentFileExternalModule)) { + else if (node.kind === 237 || + (node.parent.kind === 265 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 265) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -48504,7 +50596,7 @@ var ts; }); } else { - if (node.kind === 237) { + if (node.kind === 238) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -48522,30 +50614,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 227: - return writeFunctionDeclaration(node); - case 207: - return writeVariableStatement(node); - case 229: - return writeInterfaceDeclaration(node); case 228: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 208: + return writeVariableStatement(node); case 230: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 229: + return writeClassDeclaration(node); case 231: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 232: + return writeEnumDeclaration(node); + case 233: return writeModuleDeclaration(node); - case 236: - return writeImportEqualsDeclaration(node); case 237: + return writeImportEqualsDeclaration(node); + case 238: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 264) { + if (node.parent.kind === 265) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -48553,7 +50645,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 229 && !noDeclare) { + else if (node.kind !== 230 && !noDeclare) { write("declare "); } } @@ -48603,7 +50695,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 239) { + if (namedBindings.kind === 240) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -48626,7 +50718,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 239) { + if (node.importClause.namedBindings.kind === 240) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -48643,13 +50735,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 233; var moduleSpecifier; - if (parent.kind === 236) { + if (parent.kind === 237) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 232) { + else if (parent.kind === 233) { moduleSpecifier = parent.name; } else { @@ -48717,7 +50809,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 233) { + while (node.body && node.body.kind !== 234) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -48787,7 +50879,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 151 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -48797,15 +50889,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - (node.parent.parent && node.parent.parent.kind === 162)) { - ts.Debug.assert(node.parent.kind === 150 || - node.parent.kind === 149 || - node.parent.kind === 159 || + if (node.parent.kind === 160 || + node.parent.kind === 161 || + (node.parent.parent && node.parent.parent.kind === 163)) { + ts.Debug.assert(node.parent.kind === 151 || + node.parent.kind === 150 || node.parent.kind === 160 || - node.parent.kind === 154 || - node.parent.kind === 155); + node.parent.kind === 161 || + node.parent.kind === 155 || + node.parent.kind === 156); emitType(node.constraint); } else { @@ -48814,15 +50906,15 @@ var ts; } if (node.default && !isPrivateMethodTypeParameter(node)) { write(" = "); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - (node.parent.parent && node.parent.parent.kind === 162)) { - ts.Debug.assert(node.parent.kind === 150 || - node.parent.kind === 149 || - node.parent.kind === 159 || + if (node.parent.kind === 160 || + node.parent.kind === 161 || + (node.parent.parent && node.parent.parent.kind === 163)) { + ts.Debug.assert(node.parent.kind === 151 || + node.parent.kind === 150 || node.parent.kind === 160 || - node.parent.kind === 154 || - node.parent.kind === 155); + node.parent.kind === 161 || + node.parent.kind === 155 || + node.parent.kind === 156); emitType(node.default); } else { @@ -48832,34 +50924,34 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 229: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 155: + case 156: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 151: case 150: - case 149: if (ts.hasModifier(node.parent, 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 === 228) { + else if (node.parent.parent.kind === 229) { 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 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 230: + case 231: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -48887,7 +50979,7 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 94) { + else if (!isImplementsList && node.expression.kind === 95) { write("null"); } else { @@ -48898,7 +50990,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 228) { + if (node.parent.parent.kind === 229) { 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; @@ -48982,17 +51074,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 226 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 148 || node.kind === 147 || - (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 149 || node.kind === 148 || + (node.kind === 146 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { + if ((node.kind === 149 || node.kind === 148) && node.parent.kind === 163) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -49005,14 +51097,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 225) { + if (node.kind === 226) { 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 === 148 || node.kind === 147) { + else if (node.kind === 149 || node.kind === 148) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -49020,7 +51112,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { 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 : @@ -49046,7 +51138,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 199) { + if (element.kind !== 200) { elements.push(element); } } @@ -49112,7 +51204,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 153 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -49125,7 +51217,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 152 + return accessor.kind === 153 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -49134,7 +51226,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 153) { + if (accessorWithTypeAnnotation.kind === 154) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 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 : @@ -49180,17 +51272,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 227) { + if (node.kind === 228) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 150 || node.kind === 151) { + else if (node.kind === 151 || node.kind === 152) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 227) { + if (node.kind === 228) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 151) { + else if (node.kind === 152) { write("constructor"); } else { @@ -49210,15 +51302,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 156) { + if (node.kind === 157) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 155 || node.kind === 160) { + if (node.kind === 156 || node.kind === 161) { write("new "); } - else if (node.kind === 159) { + else if (node.kind === 160) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -49229,20 +51321,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 156) { + if (node.kind === 157) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; - if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { + var isFunctionTypeOrConstructorType = node.kind === 160 || node.kind === 161; + if (isFunctionTypeOrConstructorType || node.parent.kind === 163) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 152 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -49256,23 +51348,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 155: + case 156: 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 154: + case 155: 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 156: + case 157: 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 151: case 150: - case 149: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -49280,7 +51372,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { 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 : @@ -49293,7 +51385,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 227: + case 228: 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 : @@ -49325,9 +51417,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - node.parent.parent.kind === 162) { + if (node.parent.kind === 160 || + node.parent.kind === 161 || + node.parent.parent.kind === 163) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -49343,26 +51435,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 151: + case 152: 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 155: + case 156: 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 154: + case 155: 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 156: + case 157: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 151: case 150: - case 149: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -49370,7 +51462,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 228) { + else if (node.parent.parent.kind === 229) { 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 : @@ -49382,7 +51474,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 227: + case 228: 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 : @@ -49393,12 +51485,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 173) { + if (bindingPattern.kind === 174) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 174) { + else if (bindingPattern.kind === 175) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -49409,10 +51501,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 199) { + if (bindingElement.kind === 200) { write(" "); } - else if (bindingElement.kind === 175) { + else if (bindingElement.kind === 176) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -49422,7 +51514,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 70); + ts.Debug.assert(bindingElement.name.kind === 71); if (bindingElement.dotDotDotToken) { write("..."); } @@ -49434,39 +51526,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 227: - case 232: - case 236: - case 229: case 228: - case 230: - case 231: - return emitModuleElement(node, isModuleElementVisible(node)); - case 207: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 233: case 237: + case 230: + case 229: + case 231: + case 232: + return emitModuleElement(node, isModuleElementVisible(node)); + case 208: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 238: return emitModuleElement(node, !node.importClause); - case 243: + case 244: return emitExportDeclaration(node); + case 152: case 151: case 150: - case 149: return writeFunctionDeclaration(node); - case 155: - case 154: case 156: + case 155: + case 157: return emitSignatureDeclarationWithJsDocComments(node); - case 152: case 153: + case 154: return emitAccessorDeclaration(node); + case 149: case 148: - case 147: return emitPropertyDeclaration(node); - case 263: - return emitEnumMemberDeclaration(node); - case 242: - return emitExportAssignment(node); case 264: + return emitEnumMemberDeclaration(node); + case 243: + return emitExportAssignment(node); + case 265: return emitSourceFile(node); } } @@ -49485,7 +51577,7 @@ var ts; } return addedBundledEmitReference; function getDeclFileName(emitFileNames, sourceFileOrBundle) { - var isBundledEmit = sourceFileOrBundle.kind === 265; + var isBundledEmit = sourceFileOrBundle.kind === 266; if (isBundledEmit && !addBundledFileReference) { return; } @@ -49499,7 +51591,7 @@ var ts; var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { - var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var sourceFiles = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -49584,7 +51676,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 264) { + if (sourceFileOrBundle.kind === 265) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -49684,7 +51776,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 297 + if (node.kind !== 295 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -49697,7 +51789,7 @@ var ts; else { emitCallback(hint, node); } - if (node.kind !== 297 + if (node.kind !== 295 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -49826,23 +51918,18 @@ var ts; return; } if (node) { - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var emitFlags = ts.getEmitFlags(node); + hasWrittenComment = false; + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 297; + var isEmittedNode = node.kind !== 295; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -49856,23 +51943,16 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 226) { + if (node.kind === 227) { declarationListContainerEnd = end; } } if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); if (extendedDiagnostics) { - ts.performance.mark("beginEmitNodeWithComment"); + ts.performance.mark("postEmitNodeWithComment"); } containerPos = savedContainerPos; containerEnd = savedContainerEnd; @@ -49881,11 +51961,75 @@ var ts; emitTrailingComments(end); } if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitNodeWithComment"); + ts.performance.measure("commentTime", "postEmitNodeWithComment"); } } } } + function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { + var leadingComments = emitNode && emitNode.leadingComments; + if (ts.some(leadingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("preEmitNodeWithSynthesizedComments"); + } + ts.forEach(leadingComments, emitLeadingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); + } + } + emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); + var trailingComments = emitNode && emitNode.trailingComments; + if (ts.some(trailingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("postEmitNodeWithSynthesizedComments"); + } + ts.forEach(trailingComments, emitTrailingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); + } + } + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2) { + writer.writeLine(); + } + else { + writer.write(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.write(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { + if (emitFlags & 2048) { + disabled = true; + emitCallback(hint, node); + disabled = false; + } + else { + emitCallback(hint, node); + } + } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { if (extendedDiagnostics) { ts.performance.mark("preEmitBodyWithDetachedComments"); @@ -50078,14 +52222,13 @@ var ts; (function (ts) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers) { var compilerOptions = host.getCompilerOptions(); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var sourceMap = ts.createSourceMapWriter(host, writer); var currentSourceFile; @@ -50093,11 +52236,11 @@ var ts; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var transform = ts.transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, false); var printer = createPrinter(compilerOptions, { hasGlobalName: resolver.hasGlobalName, onEmitNode: transform.emitNodeWithNotification, - onSubstituteNode: transform.emitNodeWithSubstitution, + substituteNode: transform.substituteNode, onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, onEmitSourceMapOfPosition: sourceMap.emitPos, @@ -50107,10 +52250,7 @@ var ts; ts.performance.mark("beforePrint"); ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; - ts.disposeEmitNodes(sourceFile); - } + transform.dispose(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -50143,8 +52283,8 @@ var ts; } } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { - var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); if (bundle) { @@ -50180,7 +52320,7 @@ var ts; } function emitHelpers(node, writeLines) { var helpersEmitted = false; - var bundle = node.kind === 265 ? node : undefined; + var bundle = node.kind === 266 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -50219,9 +52359,8 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray; var newLine = ts.getNewLineCharacter(printerOptions); - var languageVersion = ts.getEmitScriptTarget(printerOptions); var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; var currentSourceFile; @@ -50254,8 +52393,8 @@ var ts; break; } switch (node.kind) { - case 264: return printFile(node); - case 265: return printBundle(node); + case 265: return printFile(node); + case 266: return printBundle(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -50278,6 +52417,8 @@ var ts; function writeBundle(bundle, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(bundle); + emitPrologueDirectivesIfNeeded(bundle); emitHelpersIndirect(bundle); for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { var sourceFile = _b[_a]; @@ -50289,6 +52430,8 @@ var ts; function writeFile(sourceFile, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(sourceFile); + emitPrologueDirectivesIfNeeded(sourceFile); print(0, sourceFile, sourceFile); reset(); writer = previousWriter; @@ -50325,9 +52468,8 @@ var ts; comments.reset(); setWriter(undefined); } - function emit(node, hint) { - if (hint === void 0) { hint = 3; } - pipelineEmitWithNotification(hint, node); + function emit(node) { + pipelineEmitWithNotification(3, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -50344,6 +52486,7 @@ var ts; } } function pipelineEmitWithComments(hint, node) { + node = trySubstituteNode(hint, node); if (emitNodeWithComments && hint !== 0) { emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); } @@ -50353,15 +52496,7 @@ var ts; } function pipelineEmitWithSourceMap(hint, node) { if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { - onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); - } - else { - pipelineEmitWithSubstitution(hint, node); - } - } - function pipelineEmitWithSubstitution(hint, node) { - if (onSubstituteNode) { - onSubstituteNode(hint, node, pipelineEmitWithHint); + onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); } else { pipelineEmitWithHint(hint, node); @@ -50390,200 +52525,204 @@ var ts; return; } switch (kind) { - case 13: case 14: case 15: + case 16: return emitLiteral(node); - case 70: + case 71: return emitIdentifier(node); - case 142: - return emitQualifiedName(node); case 143: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 144: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 145: - return emitParameter(node); + return emitTypeParameter(node); case 146: - return emitDecorator(node); + return emitParameter(node); case 147: - return emitPropertySignature(node); + return emitDecorator(node); case 148: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 149: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 150: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 151: - return emitConstructor(node); + return emitMethodDeclaration(node); case 152: + return emitConstructor(node); case 153: - return emitAccessorDeclaration(node); case 154: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 155: - return emitConstructSignature(node); + return emitCallSignature(node); case 156: - return emitIndexSignature(node); + return emitConstructSignature(node); case 157: - return emitTypePredicate(node); + return emitIndexSignature(node); case 158: - return emitTypeReference(node); + return emitTypePredicate(node); case 159: - return emitFunctionType(node); + return emitTypeReference(node); case 160: - return emitConstructorType(node); + return emitFunctionType(node); case 161: - return emitTypeQuery(node); + return emitConstructorType(node); case 162: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 163: - return emitArrayType(node); + return emitTypeLiteral(node); case 164: - return emitTupleType(node); + return emitArrayType(node); case 165: - return emitUnionType(node); + return emitTupleType(node); case 166: - return emitIntersectionType(node); + return emitUnionType(node); case 167: - return emitParenthesizedType(node); - case 200: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 168: - return emitThisType(); + return emitParenthesizedType(node); + case 201: + return emitExpressionWithTypeArguments(node); case 169: - return emitTypeOperator(node); + return emitThisType(); case 170: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 171: - return emitMappedType(node); + return emitIndexedAccessType(node); case 172: - return emitLiteralType(node); + return emitMappedType(node); case 173: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 174: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 175: + return emitArrayBindingPattern(node); + case 176: return emitBindingElement(node); - case 204: - return emitTemplateSpan(node); case 205: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 206: - return emitBlock(node); + return emitSemicolonClassElement(); case 207: - return emitVariableStatement(node); + return emitBlock(node); case 208: - return emitEmptyStatement(); + return emitVariableStatement(node); case 209: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 210: - return emitIfStatement(node); + return emitExpressionStatement(node); case 211: - return emitDoStatement(node); + return emitIfStatement(node); case 212: - return emitWhileStatement(node); + return emitDoStatement(node); case 213: - return emitForStatement(node); + return emitWhileStatement(node); case 214: - return emitForInStatement(node); + return emitForStatement(node); case 215: - return emitForOfStatement(node); + return emitForInStatement(node); case 216: - return emitContinueStatement(node); + return emitForOfStatement(node); case 217: - return emitBreakStatement(node); + return emitContinueStatement(node); case 218: - return emitReturnStatement(node); + return emitBreakStatement(node); case 219: - return emitWithStatement(node); + return emitReturnStatement(node); case 220: - return emitSwitchStatement(node); + return emitWithStatement(node); case 221: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 222: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 223: - return emitTryStatement(node); + return emitThrowStatement(node); case 224: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 225: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 226: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 227: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 228: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 229: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 230: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 231: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 232: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 233: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 234: + return emitModuleBlock(node); + case 235: return emitCaseBlock(node); - case 236: - return emitImportEqualsDeclaration(node); case 237: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 238: - return emitImportClause(node); + return emitImportDeclaration(node); case 239: - return emitNamespaceImport(node); + return emitImportClause(node); case 240: - return emitNamedImports(node); + return emitNamespaceImport(node); case 241: - return emitImportSpecifier(node); + return emitNamedImports(node); case 242: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 243: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 244: - return emitNamedExports(node); + return emitExportDeclaration(node); case 245: - return emitExportSpecifier(node); + return emitNamedExports(node); case 246: - return; + return emitExportSpecifier(node); case 247: + return; + case 248: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 250: - return emitJsxOpeningElement(node); case 251: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 252: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 253: - return emitJsxAttributes(node); + return emitJsxAttribute(node); case 254: - return emitJsxSpreadAttribute(node); + return emitJsxAttributes(node); case 255: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 256: - return emitCaseClause(node); + return emitJsxExpression(node); case 257: - return emitDefaultClause(node); + return emitCaseClause(node); case 258: - return emitHeritageClause(node); + return emitDefaultClause(node); case 259: - return emitCatchClause(node); + return emitHeritageClause(node); case 260: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 261: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 262: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 263: + return emitSpreadAssignment(node); + case 264: return emitEnumMember(node); } if (ts.isExpression(node)) { - return pipelineEmitWithSubstitution(1, node); + return pipelineEmitExpression(trySubstituteNode(1, node)); + } + if (ts.isToken(node)) { + writeTokenText(kind); + return; } } function pipelineEmitExpression(node) { @@ -50592,87 +52731,82 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 11: case 12: + case 13: return emitLiteral(node); - case 70: + case 71: return emitIdentifier(node); - case 85: - case 94: - case 96: - case 100: - case 98: + case 86: + case 95: + case 97: + case 101: + case 99: writeTokenText(kind); return; - case 176: - return emitArrayLiteralExpression(node); case 177: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 178: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 179: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 180: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 181: - return emitNewExpression(node); + return emitCallExpression(node); case 182: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 183: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 184: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 185: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 186: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 187: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 188: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 189: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 190: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 191: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 192: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 193: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 194: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 195: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 196: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 197: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 198: - return emitClassExpression(node); + return emitSpreadExpression(node); case 199: + return emitClassExpression(node); + case 200: return; - case 201: - return emitAsExpression(node); case 202: - return emitNonNullExpression(node); + return emitAsExpression(node); case 203: + return emitNonNullExpression(node); + case 204: return emitMetaProperty(node); - case 248: - return emitJsxElement(node); case 249: + return emitJsxElement(node); + case 250: return emitJsxSelfClosingElement(node); - case 298: + case 296: return emitPartiallyEmittedExpression(node); } } - function emitBodyIndirect(node, elements, emitCallback) { - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(node, elements, emitCallback); - } - else { - emitCallback(node); - } + function trySubstituteNode(hint, node) { + return node && substituteNode && substituteNode(hint, node) || node; } function emitHelpersIndirect(node) { if (onEmitHelpers) { @@ -50681,9 +52815,6 @@ var ts; } function emitNumericLiteral(node) { emitLiteral(node); - if (node.trailingComment) { - write(" /*" + node.trailingComment + "*/"); - } } function emitLiteral(node) { var text = getLiteralTextOfNode(node); @@ -50704,7 +52835,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -50726,8 +52857,8 @@ var ts; writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator) { write("@"); @@ -50774,7 +52905,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 152 ? "get " : "set "); + write(node.kind === 153 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -50935,12 +53066,12 @@ var ts; write("{}"); } else { - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = languageVersion >= 1 ? 32 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; emitList(node, properties, 978 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -50950,10 +53081,10 @@ var ts; function emitPropertyAccessExpression(node) { var indentBeforeDot = false; var indentAfterDot = false; - if (!(ts.getEmitFlags(node) & 65536)) { + if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 23, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -50966,11 +53097,11 @@ var ts; decreaseIndentIf(indentBeforeDot, indentAfterDot); } function needsDotDotForPropertyAccess(expression) { - if (expression.kind === 8) { + expression = ts.skipPartiallyEmittedExpressions(expression); + if (ts.isNumericLiteral(expression)) { var text = getLiteralTextOfNode(expression); - return ts.getNumericLiteralFlags(text, 15) === 0 - && !expression.isOctalLiteral - && text.indexOf(ts.tokenToString(22)) < 0; + return !expression.numericLiteralFlags + && text.indexOf(ts.tokenToString(23)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -51051,16 +53182,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 191 - && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) - || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); + return operand.kind === 192 + && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) + || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 25; + var isCommaOperator = node.operatorToken.kind !== 26; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -51128,17 +53259,17 @@ var ts; } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(16, node.pos, node); + writeToken(17, node.pos, node); write(" "); - writeToken(17, node.statements.end, node); + writeToken(18, node.statements.end, node); } else { - writeToken(16, node.pos, node); + writeToken(17, node.pos, node); emitBlockStatements(node); increaseIndent(); emitLeadingCommentsOfPosition(node.statements.end); decreaseIndent(); - writeToken(17, node.statements.end, node); + writeToken(18, node.statements.end, node); } } function emitBlockStatements(node) { @@ -51162,16 +53293,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(89, node.pos, node); + var openParenPos = writeToken(90, node.pos, node); write(" "); - writeToken(18, openParenPos, node); + writeToken(19, openParenPos, node); emitExpression(node.expression); - writeToken(19, node.expression.end, node); + writeToken(20, node.expression.end, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 210) { + writeToken(82, node.thenStatement.end, node); + if (node.elseStatement.kind === 211) { write(" "); emit(node.elseStatement); } @@ -51200,9 +53331,9 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos, node); + writeToken(19, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -51212,28 +53343,29 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos); + emitWithSuffix(node.awaitModifier, " "); + writeToken(19, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 226) { + if (node.kind === 227) { emit(node); } else { @@ -51242,17 +53374,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(71, node.pos); + writeToken(72, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(95, node.pos, node); + writeToken(96, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -51263,11 +53395,11 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(97, node.pos); + var openParenPos = writeToken(98, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); write(" "); emit(node.caseBlock); } @@ -51295,7 +53427,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(77, node.pos); + writeToken(78, node.pos); write(";"); } function emitVariableDeclaration(node) { @@ -51317,22 +53449,35 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint, body) { + emitBlockFunctionBody(body); + } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } - if (ts.getEmitFlags(node) & 262144) { + if (ts.getEmitFlags(node) & 524288) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } if (indentedFlag) { @@ -51385,9 +53530,14 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - emitBodyIndirect(body, body.statements, emitBlockFunctionBody); + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); + } + else { + emitBlockFunctionBody(body); + } decreaseIndent(); - writeToken(17, body.statements.end, body); + writeToken(18, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -51413,7 +53563,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } @@ -51464,7 +53614,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 232) { + while (body.kind === 233) { write("."); emit(body.name); body = body.body; @@ -51479,16 +53629,15 @@ var ts; else { pushNameGenerationScope(); write("{"); - increaseIndent(); emitBlockStatements(node); write("}"); popNameGenerationScope(); } } function emitCaseBlock(node) { - writeToken(16, node.pos); + writeToken(17, node.pos); emitList(node, node.clauses, 65); - writeToken(17, node.clauses.end); + writeToken(18, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -51499,7 +53648,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -51629,7 +53778,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -51666,11 +53815,11 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - var openParenPos = writeToken(73, node.pos); + var openParenPos = writeToken(74, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emit(node.variableDeclaration); - writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(20, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -51703,27 +53852,43 @@ var ts; } function emitSourceFile(node) { writeLine(); - emitShebang(); - emitBodyIndirect(node, node.statements, emitSourceFileWorker); + var statements = node.statements; + if (emitBodyWithDetachedComments) { + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; + } + } + emitSourceFileWorker(node); } function emitSourceFileWorker(node) { var statements = node.statements; - var statementOffset = emitPrologueDirectives(statements); pushNameGenerationScope(); emitHelpersIndirect(node); - emitList(node, statements, 1, statementOffset); + var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); + emitList(node, statements, 1, index === -1 ? statements.length : index); popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); } - function emitPrologueDirectives(statements, startWithNewLine) { + function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { for (var i = 0; i < statements.length; i++) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); + var statement = statements[i]; + if (ts.isPrologueDirective(statement)) { + var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; + if (shouldEmitPrologueDirective) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statement); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(statement.expression.text, statement.expression.text); + } } - emit(statements[i]); } else { return i; @@ -51731,11 +53896,36 @@ var ts; } return statements.length; } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - writeLine(); + function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + setSourceFile(sourceFileOrBundle); + emitPrologueDirectives(sourceFileOrBundle.statements); + } + else { + var seenPrologueDirectives = ts.createMap(); + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + setSourceFile(sourceFile); + emitPrologueDirectives(sourceFile.statements, true, seenPrologueDirectives); + } + } + } + function emitShebangIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + var shebang = ts.getShebang(sourceFileOrBundle.text); + if (shebang) { + write(shebang); + writeLine(); + return true; + } + } + else { + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + if (emitShebangIfNeeded(sourceFile)) { + break; + } + } } } function emitModifiers(node, modifiers) { @@ -51820,6 +54010,9 @@ var ts; if (format & 7680) { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } if (isEmpty) { if (format & 1) { writeLine(); @@ -51896,6 +54089,9 @@ var ts; write(" "); } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } if (format & 7680) { write(getClosingBracket(format)); } @@ -51957,7 +54153,7 @@ var ts; for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { var line = lines_1[_a]; for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) { if (indentation === undefined || i < indentation) { indentation = i; break; @@ -52080,7 +54276,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 184 && ts.nodeIsSynthesized(node)) { + while (node.kind === 185 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -52110,7 +54306,7 @@ var ts; return getLiteralTextOfNode(textSourceNode); } } - return ts.getLiteralText(node, currentSourceFile, languageVersion); + return ts.getLiteralText(node, currentSourceFile); } function pushNameGenerationScope() { tempFlagsStack.push(tempFlags); @@ -52208,23 +54404,23 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 70: + case 71: return makeUniqueName(getTextOfNode(node)); + case 233: case 232: - case 231: return generateNameForModuleOrEnum(node); - case 237: - case 243: + case 238: + case 244: return generateNameForImportOrExportDeclaration(node); - case 227: case 228: - case 242: + case 229: + case 243: return generateNameForExportDefault(); - case 198: + case 199: return generateNameForClassExpression(); - case 150: - case 152: + case 151: case 153: + case 154: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); @@ -52355,6 +54551,7 @@ var ts; var ts; (function (ts) { var emptyArray = []; + var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } while (true) { @@ -52414,7 +54611,6 @@ var ts; function getCanonicalFileName(fileName) { return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - var unsupportedFileEncodingErrorCode = -2147024809; function getSourceFile(fileName, languageVersion, onError) { var text; try { @@ -52425,9 +54621,7 @@ var ts; } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } @@ -52590,6 +54784,8 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; + var cachedSemanticDiagnosticsForFile = {}; + var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; @@ -52749,7 +54945,7 @@ var ts; : emptyArray; var j = 0; for (var i = 0; i < result.length; i++) { - if (result[i] == predictedToResolveToAmbientModuleMarker) { + if (result[i] === predictedToResolveToAmbientModuleMarker) { result[i] = undefined; } else { @@ -52900,13 +55096,13 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -52927,7 +55123,8 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -52988,16 +55185,45 @@ var ts; } } function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + var includeCheckDiagnostics = !ts.isSourceFileJavaScript(sourceFile) || ts.isCheckJsEnabledForFile(sourceFile, options); + var checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return ts.isSourceFileJavaScript(sourceFile) + ? ts.filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + function shouldReportDiagnostic(diagnostic) { + var file = diagnostic.file, start = diagnostic.start; + if (file) { + var lineStarts = ts.getLineStarts(file); + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + while (line > 0) { + var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + return true; + } + if (result[3]) { + return false; + } + line--; + } + } + return true; + } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; @@ -53006,57 +55232,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 145: - case 148: + case 146: + case 149: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: - case 227: - case 225: + case 228: + case 187: + case 228: + case 226: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 236: + case 237: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 242: + case 243: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 258: + case 259: var heritageClause = node; - if (heritageClause.token === 107) { + if (heritageClause.token === 108) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 232: + case 233: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 231: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 183: + case 184: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -53071,53 +55297,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, 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)); } switch (parent.kind) { - case 228: - case 150: - case 149: + case 229: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: - case 227: + case 228: + case 187: + case 228: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 207: + case 208: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 207); + return checkModifiers(nodes, parent.kind === 208); } break; - case 148: + case 149: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 114) { + if (modifier.kind !== 115) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 145: + case 146: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 180: case 181: - case 200: + case 182: + case 201: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; } break; } - for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { - var node = nodes_6[_b]; + for (var _b = 0, nodes_8 = nodes; _b < nodes_8.length; _b++) { + var node = nodes_8[_b]; walk(node); } } @@ -53125,21 +55351,21 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 75: + case 76: if (isConstValid) { continue; } - case 113: - case 111: + case 114: case 112: - case 130: - case 123: - case 116: + case 113: + case 131: + case 124: + case 117: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; - case 114: - case 83: - case 78: + case 115: + case 84: + case 79: } } } @@ -53153,11 +55379,33 @@ var ts; }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } + function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) { + var cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + if (cachedResult) { + return cachedResult; + } + var result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = ts.createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } @@ -53216,9 +55464,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 238: case 237: - case 236: - case 243: + case 244: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -53230,7 +55478,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 232: + case 233: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -53314,7 +55562,7 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); @@ -53472,8 +55720,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var file = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var file = sourceFiles_2[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -53484,8 +55732,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var sourceFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -53578,7 +55826,7 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } - if (options.noImplicitUseStrict && options.alwaysStrict) { + if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); } var languageVersion = options.target || 0; @@ -53618,6 +55866,9 @@ var ts; if (!options.noEmit && options.allowJs && options.declaration) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); @@ -53693,40 +55944,12 @@ var ts; (function (ts) { ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, }, { @@ -53734,215 +55957,52 @@ var ts; shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMapFromTemplate({ - "preserve": 1, - "react-native": 3, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMapFromTemplate({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMapFromTemplate({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, { name: "project", shortName: "p", type: "string", isFilePath: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { - name: "removeComments", + name: "pretty", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", + name: "watch", + shortName: "w", type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Watch_input_files, }, { name: "target", @@ -53956,133 +56016,27 @@ var ts; "es2017": 4, "esnext": 5, }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, paramType: ts.Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", + name: "module", + shortName: "m", type: ts.createMapFromTemplate({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - 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: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_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 - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -54096,6 +56050,7 @@ var ts; "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", "webworker": "lib.webworker.d.ts", @@ -54113,29 +56068,466 @@ var ts; "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1, + "react-native": 3, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + { + name: "noUnusedLocals", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + paramType: ts.Diagnostics.STRATEGY, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + { + name: "experimentalDecorators", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "jsxFactory", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + { + name: "out", + type: "string", + isFilePath: false, + category: ts.Diagnostics.Advanced_Options, + paramType: ts.Diagnostics.FILE, + description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0, + "lf": 1 + }), + paramType: ts.Diagnostics.NEWLINE, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, { name: "plugins", type: "list", @@ -54143,7 +56535,8 @@ var ts; element: { name: "plugin", type: "object" - } + }, + description: ts.Diagnostics.List_of_language_service_plugins } ]; ts.typeAcquisitionDeclarations = [ @@ -54175,8 +56568,7 @@ var ts; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1, - noImplicitAny: false, - sourceMap: false, + strict: true }; var optionNameMapCache; function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -54367,7 +56759,7 @@ var ts; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { + function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -54375,7 +56767,7 @@ var ts; if (fileNames && fileNames.length) { configurations.files = fileNames; } - return configurations; + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition) { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { return undefined; @@ -54399,41 +56791,110 @@ var ts; var optionsNameMap = getOptionNameMap().optionNameMap; for (var name in options) { if (ts.hasProperty(options, name)) { - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + continue; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return ts.arrayFrom(option.type.keys())[0]; + } + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + var categorizedOptions = ts.reduceLeft(ts.filter(ts.optionDeclarations, function (o) { return o.category !== ts.Diagnostics.Command_line_Options && o.category !== ts.Diagnostics.Advanced_Options; }), function (memo, value) { + if (value.category) { + var name = ts.getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, {}); + var marginLength = 0; + var seenKnownKeys = 0; + var nameColumn = []; + var descriptionColumn = []; + var knownKeysCount = ts.getOwnKeys(configurations.compilerOptions).length; + for (var category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push("/* " + category + " */"); + descriptionColumn.push(""); + for (var _i = 0, _a = categorizedOptions[category]; _i < _a.length; _i++) { + var option = _a[_i]; + var optionName = void 0; + if (ts.hasProperty(configurations.compilerOptions, option.name)) { + optionName = "\"" + option.name + "\": " + JSON.stringify(configurations.compilerOptions[option.name]) + ((seenKnownKeys += 1) === knownKeysCount ? "" : ","); + } + else { + optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + } + nameColumn.push(optionName); + descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + marginLength = Math.max(optionName.length, marginLength); + } + } + var tab = makePadding(2); + var result = []; + result.push("{"); + result.push(tab + "\"compilerOptions\": {"); + for (var i = 0; i < nameColumn.length; i++) { + var optionName = nameColumn[i]; + var description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(tab + "},"); + result.push(tab + "\"files\": ["); + for (var i = 0; i < configurations.files.length; i++) { + result.push("" + tab + tab + JSON.stringify(configurations.files[i]) + (i === configurations.files.length - 1 ? "" : ",")); + } + result.push(tab + "]"); + } + else { + result.push(tab + "}"); + } + result.push("}"); + return result.join(newLine); + } } ts.generateTSConfig = generateTSConfig; function removeComments(jsonText) { @@ -54474,10 +56935,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -54497,6 +56959,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -54534,7 +56999,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -54777,7 +57242,6 @@ var ts; } } } - ; } return wildcardDirectories; } @@ -54932,7 +57396,7 @@ var ts; ScriptElementKind.interfaceElement = "interface"; ScriptElementKind.typeElement = "type"; ScriptElementKind.enumElement = "enum"; - ScriptElementKind.enumMemberElement = "const"; + ScriptElementKind.enumMemberElement = "enum member"; ScriptElementKind.variableElement = "var"; ScriptElementKind.localVariableElement = "local var"; ScriptElementKind.functionElement = "function"; @@ -55038,34 +57502,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 145: - case 225: - case 175: - case 148: - case 147: - case 260: - case 261: - case 263: - case 150: + case 146: + case 226: + case 176: case 149: + case 148: + case 261: + case 262: + case 264: case 151: + case 150: case 152: case 153: - case 227: - case 185: - case 186: - case 259: - case 252: - return 1; - case 144: - case 229: - case 230: - case 162: - return 2; + case 154: case 228: + case 186: + case 187: + case 260: + case 253: + return 1; + case 145: + case 230: case 231: - return 1 | 2; + case 163: + return 2; + case 229: case 232: + return 1 | 2; + case 233: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -55075,24 +57539,24 @@ var ts; else { return 4; } - case 240: case 241: - case 236: - case 237: case 242: + case 237: + case 238: case 243: + case 244: return 1 | 2 | 4; - case 264: + case 265: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 264) { + if (node.kind === 265) { return 1; } - else if (node.parent.kind === 242) { + else if (node.parent.kind === 243) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -55113,16 +57577,16 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 142 && + ts.Debug.assert(node.kind === 71); + if (node.parent.kind === 143 && node.parent.right === node && - node.parent.parent.kind === 236) { + node.parent.parent.kind === 237) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 142) { + while (node.parent.kind === 143) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -55133,27 +57597,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 142) { - while (root.parent && root.parent.kind === 142) { + if (root.parent.kind === 143) { + while (root.parent && root.parent.kind === 143) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 158 && !isLastClause; + return root.parent.kind === 159 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 178) { - while (root.parent && root.parent.kind === 178) { + if (root.parent.kind === 179) { + while (root.parent && root.parent.kind === 179) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 200 && root.parent.parent.kind === 258) { + if (!isLastClause && root.parent.kind === 201 && root.parent.parent.kind === 259) { var decl = root.parent.parent.parent; - return (decl.kind === 228 && root.parent.parent.token === 107) || - (decl.kind === 229 && root.parent.parent.token === 84); + return (decl.kind === 229 && root.parent.parent.token === 108) || + (decl.kind === 230 && root.parent.parent.token === 85); } return false; } @@ -55161,17 +57625,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 158 || - (node.parent.kind === 200 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 168; + return node.parent.kind === 159 || + (node.parent.kind === 201 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 99 && !ts.isPartOfExpression(node)) || + node.kind === 169; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180); + return isCallOrNewExpressionTarget(node, 181); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 181); + return isCallOrNewExpressionTarget(node, 182); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -55184,7 +57648,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 221 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 222 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -55193,14 +57657,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 70 && - (node.parent.kind === 217 || node.parent.kind === 216) && + return node.kind === 71 && + (node.parent.kind === 218 || node.parent.kind === 217) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 70 && - node.parent.kind === 221 && + return node.kind === 71 && + node.parent.kind === 222 && node.parent.label === node; } function isLabelName(node) { @@ -55208,38 +57672,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 142 && node.parent.right === node; + return node.parent.kind === 143 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 178 && node.parent.name === node; + return node && node.parent && node.parent.kind === 179 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 232 && node.parent.name === node; + return node.parent.kind === 233 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 70 && + return node.kind === 71 && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 148: - case 147: - case 260: - case 263: - case 150: case 149: - case 152: + case 148: + case 261: + case 264: + case 151: + case 150: case 153: - case 232: + case 154: + case 233: return node.parent.name === node; - case 179: + case 180: return node.parent.argumentExpression === node; - case 143: + case 144: return true; } } @@ -55283,17 +57747,17 @@ var ts; return undefined; } switch (node.kind) { - case 264: + case 265: + case 151: case 150: - case 149: - case 227: - case 185: - case 152: - case 153: case 228: + case 186: + case 153: + case 154: case 229: - case 231: + case 230: case 232: + case 233: return node; } } @@ -55301,46 +57765,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 264: + case 265: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 232: + case 233: return ts.ScriptElementKind.moduleElement; - case 228: - case 198: + case 229: + case 199: return ts.ScriptElementKind.classElement; - case 229: return ts.ScriptElementKind.interfaceElement; - case 230: return ts.ScriptElementKind.typeElement; - case 231: return ts.ScriptElementKind.enumElement; - case 225: + case 230: return ts.ScriptElementKind.interfaceElement; + case 231: return ts.ScriptElementKind.typeElement; + case 232: return ts.ScriptElementKind.enumElement; + case 226: return getKindOfVariableDeclaration(node); - case 175: + case 176: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 187: + case 228: case 186: - case 227: - case 185: return ts.ScriptElementKind.functionElement; - case 152: return ts.ScriptElementKind.memberGetAccessorElement; - case 153: return ts.ScriptElementKind.memberSetAccessorElement; + case 153: return ts.ScriptElementKind.memberGetAccessorElement; + case 154: return ts.ScriptElementKind.memberSetAccessorElement; + case 151: case 150: - case 149: return ts.ScriptElementKind.memberFunctionElement; + case 149: case 148: - case 147: return ts.ScriptElementKind.memberVariableElement; - case 156: return ts.ScriptElementKind.indexSignatureElement; - case 155: return ts.ScriptElementKind.constructSignatureElement; - case 154: return ts.ScriptElementKind.callSignatureElement; - case 151: return ts.ScriptElementKind.constructorImplementationElement; - case 144: return ts.ScriptElementKind.typeParameterElement; - case 263: return ts.ScriptElementKind.enumMemberElement; - case 145: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 236: - case 241: - case 238: - case 245: + case 157: return ts.ScriptElementKind.indexSignatureElement; + case 156: return ts.ScriptElementKind.constructSignatureElement; + case 155: return ts.ScriptElementKind.callSignatureElement; + case 152: return ts.ScriptElementKind.constructorImplementationElement; + case 145: return ts.ScriptElementKind.typeParameterElement; + case 264: return ts.ScriptElementKind.enumMemberElement; + case 146: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 237: + case 242: case 239: + case 246: + case 240: return ts.ScriptElementKind.alias; - case 289: + case 290: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -55354,21 +57818,12 @@ var ts; } } ts.getNodeKind = getNodeKind; - function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 172 ? node.parent : node; - var type = typeChecker.getTypeAtLocation(searchNode); - if (type && type.flags & 32) { - return type; - } - return undefined; - } - ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 98: + case 99: return true; - case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 145; + case 71: + return ts.identifierIsThisKeyword(node) && node.parent.kind === 146; default: return false; } @@ -55376,7 +57831,7 @@ var ts; ts.isThis = isThis; var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= node.end) { + if (c.kind === 294 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -55587,7 +58042,7 @@ var ts; if (includeJsDocComment === void 0) { includeJsDocComment = false; } var current = sourceFile; outer: while (true) { - if (isToken(current)) { + if (ts.isToken(current)) { return current; } if (includeJsDocComment) { @@ -55635,7 +58090,7 @@ var ts; } function findTokenOnLeftOfPosition(file, position) { var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } return findPrecedingToken(position, file); @@ -55644,7 +58099,7 @@ var ts; function findNextToken(previousToken, parent) { return find(parent); function find(n) { - if (isToken(n) && n.pos === previousToken.end) { + if (ts.isToken(n) && n.pos === previousToken.end) { return n; } var children = n.getChildren(); @@ -55663,7 +58118,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -55671,7 +58126,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -55690,7 +58145,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 264); + ts.Debug.assert(startNode !== undefined || n.kind === 265); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -55732,16 +58187,16 @@ var ts; if (token.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 10) { + if (token.kind === 27 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 255) { + if (token.kind === 27 && token.parent.kind === 256) { return true; } - if (token && token.kind === 17 && token.parent.kind === 255) { + if (token && token.kind === 18 && token.parent.kind === 256) { return true; } - if (token.kind === 26 && token.parent.kind === 251) { + if (token.kind === 27 && token.parent.kind === 252) { return true; } return false; @@ -55758,10 +58213,10 @@ var ts; var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); return predicate ? ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end) && + (c.kind === 2 ? position <= c.end : position < c.end) && predicate(c); }) : ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end); }); + (c.kind === 2 ? position <= c.end : position < c.end); }); } return false; } @@ -55778,11 +58233,11 @@ var ts; ts.hasDocComment = hasDocComment; function getJsDocTagAtPosition(sourceFile, position) { var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { + if (ts.isToken(node)) { switch (node.kind) { - case 103: - case 109: - case 75: + case 104: + case 110: + case 76: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -55832,21 +58287,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 158 || node.kind === 180) { + if (node.kind === 159 || node.kind === 181) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 228 || node.kind === 229) { + if (ts.isFunctionLike(node) || node.kind === 229 || node.kind === 230) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 && n.kind <= 141; - } - ts.isToken = isToken; function isWord(kind) { - return kind === 70 || ts.isKeyword(kind); + return kind === 71 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -55858,7 +58309,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 11 + || kind === 12 || ts.isTemplateLiteralKind(kind)) { return true; } @@ -55866,7 +58317,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 16 <= kind && kind <= 69; + return 17 <= kind && kind <= 70; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -55876,9 +58327,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 113: - case 111: + case 114: case 112: + case 113: return true; } return false; @@ -55901,18 +58352,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 176 || - node.kind === 177) { - if (node.parent.kind === 193 && + if (node.kind === 177 || + node.kind === 178) { + if (node.parent.kind === 194 && node.parent.left === node && - node.parent.operatorToken.kind === 57) { + node.parent.operatorToken.kind === 58) { return true; } - if (node.parent.kind === 215 && + if (node.parent.kind === 216 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 261 ? node.parent.parent : node.parent)) { return true; } } @@ -55946,24 +58397,37 @@ var ts; ts.createTextSpanFromNode = createTextSpanFromNode; function isTypeKeyword(kind) { switch (kind) { - case 118: - case 121: - case 129: - case 132: + case 119: + case 122: + case 130: case 133: - case 135: + case 134: case 136: - case 104: + case 137: + case 105: return true; default: return false; } } ts.isTypeKeyword = isTypeKeyword; + function isExternalModuleSymbol(moduleSymbol) { + ts.Debug.assert(!!(moduleSymbol.flags & 1536)); + return moduleSymbol.name.charCodeAt(0) === 34; + } + ts.isExternalModuleSymbol = isExternalModuleSymbol; + function nodeSeenTracker() { + var seen = []; + return function (node) { + var id = ts.getNodeId(node); + return !seen[id] && (seen[id] = true); + }; + } + ts.nodeSeenTracker = nodeSeenTracker; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 146; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -56136,21 +58600,16 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; function getDeclaredName(typeChecker, symbol, location) { - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 143) { + if (isImportOrExportSpecifierName(location) || ts.isStringOrNumericLiteral(location) && location.parent.kind === 144) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; + return typeChecker.symbolToString(localExportDefaultSymbol || symbol); } ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 241 || location.parent.kind === 245) && + (location.parent.kind === 242 || location.parent.kind === 246) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -56161,7 +58620,6 @@ var ts; (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { return name.substring(1, length - 1); } - ; return name; } ts.stripQuotes = stripQuotes; @@ -56207,10 +58665,21 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); + function getFirstNonSpaceCharacterPosition(text, position) { + while (ts.isWhiteSpaceLike(text.charCodeAt(position))) { + position += 1; + } + return position; } - ts.getOpenBraceEnd = getOpenBraceEnd; + ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getOpenBrace(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile); + } + ts.getOpenBrace = getOpenBrace; + function getOpenBraceOfClassLike(declaration, sourceFile) { + return ts.getTokenAtPosition(sourceFile, declaration.members.pos - 1); + } + ts.getOpenBraceOfClassLike = getOpenBraceOfClassLike; })(ts || (ts = {})); var ts; (function (ts) { @@ -56259,176 +58728,176 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 207: + case 208: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 225: - case 148: - case 147: - return spanInVariableDeclaration(node); - case 145: - return spanInParameterDeclaration(node); - case 227: - case 150: + case 226: case 149: - case 152: - case 153: + case 148: + return spanInVariableDeclaration(node); + case 146: + return spanInParameterDeclaration(node); + case 228: case 151: - case 185: + case 150: + case 153: + case 154: + case 152: case 186: + case 187: return spanInFunctionDeclaration(node); - case 206: + case 207: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 233: + case 234: return spanInBlock(node); - case 259: + case 260: return spanInBlock(node.block); - case 209: - return textSpan(node.expression); - case 218: - return textSpan(node.getChildAt(0), node.expression); - case 212: - return textSpanEndingAtNextToken(node, node.expression); - case 211: - return spanInNode(node.statement); - case 224: - return textSpan(node.getChildAt(0)); case 210: - return textSpanEndingAtNextToken(node, node.expression); - case 221: - return spanInNode(node.statement); - case 217: - case 216: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 219: + return textSpan(node.getChildAt(0), node.expression); case 213: - return spanInForStatement(node); - case 214: return textSpanEndingAtNextToken(node, node.expression); - case 215: - return spanInInitializerOfForLike(node); - case 220: + case 212: + return spanInNode(node.statement); + case 225: + return textSpan(node.getChildAt(0)); + case 211: return textSpanEndingAtNextToken(node, node.expression); - case 256: - case 257: - return spanInNode(node.statements[0]); - case 223: - return spanInBlock(node.tryBlock); case 222: + return spanInNode(node.statement); + case 218: + case 217: + return textSpan(node.getChildAt(0), node.label); + case 214: + return spanInForStatement(node); + case 215: + return textSpanEndingAtNextToken(node, node.expression); + case 216: + return spanInInitializerOfForLike(node); + case 221: + return textSpanEndingAtNextToken(node, node.expression); + case 257: + case 258: + return spanInNode(node.statements[0]); + case 224: + return spanInBlock(node.tryBlock); + case 223: return textSpan(node, node.expression); - case 242: - return textSpan(node, node.expression); - case 236: - return textSpan(node, node.moduleReference); - case 237: - return textSpan(node, node.moduleSpecifier); case 243: + return textSpan(node, node.expression); + case 237: + return textSpan(node, node.moduleReference); + case 238: return textSpan(node, node.moduleSpecifier); - case 232: + case 244: + return textSpan(node, node.moduleSpecifier); + case 233: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 228: - case 231: - case 263: - case 175: - return textSpan(node); - case 219: - return spanInNode(node.statement); - case 146: - return spanInNodeArray(node.parent.decorators); - case 173: - case 174: - return spanInBindingPattern(node); case 229: + case 232: + case 264: + case 176: + return textSpan(node); + case 220: + return spanInNode(node.statement); + case 147: + return spanInNodeArray(node.parent.decorators); + case 174: + case 175: + return spanInBindingPattern(node); case 230: + case 231: return undefined; - case 24: + case 25: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 25: - return spanInPreviousNode(node); - case 16: - return spanInOpenBraceToken(node); - case 17: - return spanInCloseBraceToken(node); - case 21: - return spanInCloseBracketToken(node); - case 18: - return spanInOpenParenToken(node); - case 19: - return spanInCloseParenToken(node); - case 55: - return spanInColonToken(node); - case 28: case 26: + return spanInPreviousNode(node); + case 17: + return spanInOpenBraceToken(node); + case 18: + return spanInCloseBraceToken(node); + case 22: + return spanInCloseBracketToken(node); + case 19: + return spanInOpenParenToken(node); + case 20: + return spanInCloseParenToken(node); + case 56: + return spanInColonToken(node); + case 29: + case 27: return spanInGreaterThanOrLessThanToken(node); - case 105: + case 106: return spanInWhileKeyword(node); - case 81: - case 73: - case 86: + case 82: + case 74: + case 87: return spanInNextNode(node); - case 141: + case 142: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } - if ((node.kind === 70 || - node.kind == 197 || - node.kind === 260 || - node.kind === 261) && + if ((node.kind === 71 || + node.kind === 198 || + node.kind === 261 || + node.kind === 262) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 193) { + if (node.kind === 194) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 57 && + if (binaryExpression.operatorToken.kind === 58 && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { return textSpan(node); } - if (binaryExpression.operatorToken.kind === 25) { + if (binaryExpression.operatorToken.kind === 26) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 211: + case 212: return spanInPreviousNode(node); - case 146: + case 147: return spanInNode(node.parent); - case 213: - case 215: + case 214: + case 216: return textSpan(node); - case 193: - if (node.parent.operatorToken.kind === 25) { + case 194: + if (node.parent.operatorToken.kind === 26) { return textSpan(node); } break; - case 186: + case 187: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 260 && + if (node.parent.kind === 261 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 183 && node.parent.type === node) { + if (node.parent.kind === 184 && 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 === 225 || - node.parent.kind === 145)) { + if ((node.parent.kind === 226 || + node.parent.kind === 146)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -56436,7 +58905,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 193) { + if (node.parent.kind === 194) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -56448,8 +58917,8 @@ var ts; } } function textSpanFromVariableDeclaration(variableDeclaration) { - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { + if (variableDeclaration.parent.kind === 227 && + variableDeclaration.parent.declarations[0] === variableDeclaration) { return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); } else { @@ -56457,7 +58926,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 214) { + if (variableDeclaration.parent.parent.kind === 215) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -56465,11 +58934,11 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 215) { + variableDeclaration.parent.parent.kind === 216) { return textSpanFromVariableDeclaration(variableDeclaration); } - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { + if (variableDeclaration.parent.kind === 227 && + variableDeclaration.parent.declarations[0] !== variableDeclaration) { return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); } } @@ -56497,7 +58966,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 228 && functionDeclaration.kind !== 151); + (functionDeclaration.parent.kind === 229 && functionDeclaration.kind !== 152); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -56517,22 +58986,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 232: + case 233: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 212: - case 210: - case 214: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 213: + case 211: case 215: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 214: + case 216: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 226) { + if (forLikeStatement.initializer.kind === 227) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -56554,62 +59023,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 200 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 175) { + if (bindingPattern.parent.kind === 176) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 174 && node.kind !== 173); - var elements = node.kind === 176 ? + ts.Debug.assert(node.kind !== 175 && node.kind !== 174); + var elements = node.kind === 177 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 200 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 193 ? node.parent : node); + return textSpan(node.parent.kind === 194 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 231: + case 232: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 228: + case 229: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 234: + case 235: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 233: + case 234: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 231: - case 228: + case 232: + case 229: return textSpan(node); - case 206: + case 207: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 259: + case 260: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 234: + case 235: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 173: + case 174: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -56622,7 +59091,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 174: + case 175: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -56634,33 +59103,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 211 || - node.parent.kind === 180 || - node.parent.kind === 181) { + if (node.parent.kind === 212 || + node.parent.kind === 181 || + node.parent.kind === 182) { return spanInPreviousNode(node); } - if (node.parent.kind === 184) { + if (node.parent.kind === 185) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 185: - case 227: case 186: - case 150: - case 149: - case 152: - case 153: + case 228: + case 187: case 151: - case 212: - case 211: + case 150: + case 153: + case 154: + case 152: case 213: - case 215: - case 180: + case 212: + case 214: + case 216: case 181: - case 184: + case 182: + case 185: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -56668,26 +59137,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 260 || - node.parent.kind === 145) { + node.parent.kind === 261 || + node.parent.kind === 146) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 183) { + if (node.parent.kind === 184) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 211) { + if (node.parent.kind === 212) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 215) { + if (node.parent.kind === 216) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -56702,25 +59171,25 @@ var ts; function createClassifier() { var scanner = ts.createScanner(5, false); var noRegexTable = []; - noRegexTable[70] = true; + noRegexTable[71] = true; noRegexTable[9] = true; noRegexTable[8] = true; - noRegexTable[11] = true; - noRegexTable[98] = true; - noRegexTable[42] = true; + noRegexTable[12] = true; + noRegexTable[99] = true; noRegexTable[43] = true; - noRegexTable[19] = true; - noRegexTable[21] = true; - noRegexTable[17] = true; - noRegexTable[100] = true; - noRegexTable[85] = true; + noRegexTable[44] = true; + noRegexTable[20] = true; + noRegexTable[22] = true; + noRegexTable[18] = true; + noRegexTable[101] = true; + noRegexTable[86] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 124 || - keyword2 === 134 || - keyword2 === 122 || - keyword2 === 114) { + if (keyword2 === 125 || + keyword2 === 135 || + keyword2 === 123 || + keyword2 === 115) { return true; } return false; @@ -56733,7 +59202,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_4 = dense[i + 1]; + var length_5 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -56741,8 +59210,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_4, classification: convertClassification(type) }); - lastEnd = start + length_4; + entries.push({ length: length_5, classification: convertClassification(type) }); + lastEnd = start + length_5; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -56803,7 +59272,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(13); + templateStack.push(14); break; } scanner.setText(text); @@ -56815,55 +59284,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 40 || token === 62) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 11) { - token = 11; + if ((token === 41 || token === 63) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 12) { + token = 12; } } - else if (lastNonTriviaToken === 22 && isKeyword(token)) { - token = 70; + else if (lastNonTriviaToken === 23 && isKeyword(token)) { + token = 71; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 70; + token = 71; } - else if (lastNonTriviaToken === 70 && - token === 26) { + else if (lastNonTriviaToken === 71 && + token === 27) { angleBracketStack++; } - else if (token === 28 && angleBracketStack > 0) { + else if (token === 29 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 118 || - token === 135 || - token === 132 || - token === 121 || - token === 136) { + else if (token === 119 || + token === 136 || + token === 133 || + token === 122 || + token === 137) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 70; + token = 71; } } - else if (token === 13) { + else if (token === 14) { templateStack.push(token); } - else if (token === 16) { + else if (token === 17) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 17) { + else if (token === 18) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 13) { + if (lastTemplateStackToken === 14) { token = scanner.reScanTemplateToken(); - if (token === 15) { + if (token === 16) { templateStack.pop(); } else { - ts.Debug.assert(token === 14, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 15, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 16, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 17, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -56901,10 +59370,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 15) { + if (token === 16) { result.endOfLineState = 5; } - else if (token === 12) { + else if (token === 13) { result.endOfLineState = 4; } else { @@ -56912,7 +59381,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 14) { result.endOfLineState = 6; } } @@ -56936,43 +59405,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 38: - case 40: + case 39: case 41: - case 36: + case 42: case 37: - case 44: + case 38: case 45: case 46: - case 26: - case 28: + case 47: + case 27: case 29: case 30: - case 92: - case 91: - case 117: case 31: + case 93: + case 92: + case 118: case 32: case 33: case 34: - case 47: - case 49: + case 35: case 48: - case 52: + case 50: + case 49: case 53: - case 68: - case 67: + case 54: case 69: - case 64: + case 68: + case 70: case 65: case 66: - case 58: + case 67: case 59: case 60: - case 62: + case 61: case 63: - case 57: - case 25: + case 64: + case 58: + case 26: return true; default: return false; @@ -56980,19 +59449,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 42: case 43: + case 44: return true; default: return false; } } function isKeyword(token) { - return token >= 71 && token <= 141; + return token >= 72 && token <= 142; } function classFromKind(token) { if (isKeyword(token)) { @@ -57001,7 +59470,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 16 && token <= 69) { + else if (token >= 17 && token <= 70) { return 10; } switch (token) { @@ -57009,7 +59478,7 @@ var ts; return 4; case 9: return 6; - case 11: + case 12: return 7; case 7: case 3: @@ -57018,7 +59487,7 @@ var ts; case 5: case 4: return 8; - case 70: + case 71: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -57038,10 +59507,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 232: - case 228: + case 233: case 229: - case 227: + case 230: + case 228: cancellationToken.throwIfCancellationRequested(); } } @@ -57085,7 +59554,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 232 && + return declaration.kind === 233 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -57094,7 +59563,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 70 && !ts.nodeIsMissing(node)) { + if (kind === 71 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -57226,16 +59695,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 285: + case 286: processJSDocParameterTag(tag); break; - case 288: + case 289: processJSDocTemplateTag(tag); break; - case 287: + case 288: processElement(tag.typeExpression); break; - case 286: + case 287: processElement(tag.typeExpression); break; } @@ -57316,22 +59785,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 250: + case 251: if (token.parent.tagName === token) { return 19; } break; - case 251: + case 252: if (token.parent.tagName === token) { return 20; } break; - case 249: + case 250: if (token.parent.tagName === token) { return 21; } break; - case 252: + case 253: if (token.parent.name === token) { return 22; } @@ -57343,25 +59812,25 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 26 || tokenKind === 28) { + if (tokenKind === 27 || tokenKind === 29) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 57) { - if (token.parent.kind === 225 || - token.parent.kind === 148 || - token.parent.kind === 145 || - token.parent.kind === 252) { + if (tokenKind === 58) { + if (token.parent.kind === 226 || + token.parent.kind === 149 || + token.parent.kind === 146 || + token.parent.kind === 253) { return 5; } } - if (token.parent.kind === 193 || - token.parent.kind === 191 || + if (token.parent.kind === 194 || token.parent.kind === 192 || - token.parent.kind === 194) { + token.parent.kind === 193 || + token.parent.kind === 195) { return 5; } } @@ -57371,9 +59840,9 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 252 ? 24 : 6; + return token.parent.kind === 253 ? 24 : 6; } - else if (tokenKind === 11) { + else if (tokenKind === 12) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { @@ -57382,35 +59851,35 @@ var ts; else if (tokenKind === 10) { return 23; } - else if (tokenKind === 70) { + else if (tokenKind === 71) { if (token) { switch (token.parent.kind) { - case 228: + case 229: if (token.parent.name === token) { return 11; } return; - case 144: + case 145: if (token.parent.name === token) { return 15; } return; - case 229: + case 230: if (token.parent.name === token) { return 13; } return; - case 231: + case 232: if (token.parent.name === token) { return 12; } return; - case 232: + case 233: if (token.parent.name === token) { return 14; } return; - case 145: + case 146: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -57438,12 +59907,419 @@ var ts; ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); var ts; +(function (ts) { + var Completions; + (function (Completions) { + var PathCompletions; + (function (PathCompletions) { + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, false, span, host, scriptPath); + } + } + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + PathCompletions.getStringLiteralCompletionEntriesFromModuleNames = getStringLiteralCompletionEntriesFromModuleNames; + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + } + } + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_6 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_6))); + } + return result; + } + } + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } + } + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); + } + else { + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + } + } + return completionInfo; + } + PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); + } + } + } + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName: moduleName, + moduleDir: moduleDir + }); + } + } + } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; + } + } + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); + } + } + } + } + } + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } + var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); - } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; - } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir, host) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent = ts.getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); - } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { var symbols = completionData.symbols, location_1 = completionData.location; var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -58022,7 +60538,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -58039,7 +60556,8 @@ var ts; Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); - var isJsDocTagName = false; + var requestJsDocTagName = false; + var requestJsDocTag = false; var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (ts.timestamp() - start)); @@ -58047,19 +60565,25 @@ var ts; var insideComment = ts.isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); if (insideComment) { - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { - isJsDocTagName = true; + if (ts.hasDocComment(sourceFile, position)) { + if (sourceFile.text.charCodeAt(position - 1) === 64) { + requestJsDocTagName = true; + } + else { + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + requestJsDocTag = !(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); + } } var insideJsDocTagExpression = false; var tag = ts.getJsDocTagAtPosition(sourceFile, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; + requestJsDocTagName = true; } switch (tag.kind) { - case 287: - case 285: + case 288: case 286: + case 287: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -58067,8 +60591,8 @@ var ts; break; } } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + if (requestJsDocTagName || requestJsDocTag) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; } if (!insideJsDocTagExpression) { log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); @@ -58094,13 +60618,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent = contextToken.parent, kind = contextToken.kind; - if (kind === 22) { - if (parent.kind === 178) { + var parent = contextToken.parent; + if (contextToken.kind === 23) { + if (parent.kind === 179) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent.kind === 142) { + else if (parent.kind === 143) { node = contextToken.parent.left; isRightOfDot = true; } @@ -58109,21 +60633,25 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - switch (contextToken.parent.kind) { - case 251: - if (kind === 40) { + if (parent && parent.kind === 179) { + contextToken = parent; + parent = parent.parent; + } + switch (parent.kind) { + case 252: + if (contextToken.kind === 41) { isStartingCloseTag = true; location = contextToken; } break; - case 193: - if (!(contextToken.parent.left.flags & 32768)) { + case 194: + if (!(parent.left.flags & 32768)) { break; } - case 249: - case 248: case 250: - if (kind === 26) { + case 249: + case 251: + if (contextToken.kind === 27) { isRightOfOpenTag = true; location = contextToken; } @@ -58165,12 +60693,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; function getTypeScriptMemberSymbols() { isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 142 || node.kind === 178) { + if (node.kind === 71 || node.kind === 143 || node.kind === 179) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -58216,7 +60744,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 249) || (jsxContainer.kind === 250)) { + if ((jsxContainer.kind === 250) || (jsxContainer.kind === 251)) { attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); @@ -58237,9 +60765,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 264 || - scopeNode.kind === 195 || - scopeNode.kind === 255 || + scopeNode.kind === 265 || + scopeNode.kind === 196 || + scopeNode.kind === 256 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -58266,12 +60794,12 @@ var ts; if (contextToken.kind === 10) { return true; } - if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 250) { + if (contextToken.kind === 29 && contextToken.parent) { + if (contextToken.parent.kind === 251) { return true; } - if (contextToken.parent.kind === 251 || contextToken.parent.kind === 249) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 248; + if (contextToken.parent.kind === 252 || contextToken.parent.kind === 250) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 249; } } return false; @@ -58280,41 +60808,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 25: - return containingNodeKind === 180 - || containingNodeKind === 151 - || containingNodeKind === 181 - || containingNodeKind === 176 - || containingNodeKind === 193 - || containingNodeKind === 159; - case 18: - return containingNodeKind === 180 - || containingNodeKind === 151 - || containingNodeKind === 181 - || containingNodeKind === 184 - || containingNodeKind === 167; - case 20: - return containingNodeKind === 176 - || containingNodeKind === 156 - || containingNodeKind === 143; - case 127: + case 26: + return containingNodeKind === 181 + || containingNodeKind === 152 + || containingNodeKind === 182 + || containingNodeKind === 177 + || containingNodeKind === 194 + || containingNodeKind === 160; + case 19: + return containingNodeKind === 181 + || containingNodeKind === 152 + || containingNodeKind === 182 + || containingNodeKind === 185 + || containingNodeKind === 168; + case 21: + return containingNodeKind === 177 + || containingNodeKind === 157 + || containingNodeKind === 144; case 128: + case 129: return true; - case 22: - return containingNodeKind === 232; - case 16: - return containingNodeKind === 228; - case 57: - return containingNodeKind === 225 - || containingNodeKind === 193; - case 13: - return containingNodeKind === 195; + case 23: + return containingNodeKind === 233; + case 17: + return containingNodeKind === 229; + case 58: + return containingNodeKind === 226 + || containingNodeKind === 194; case 14: - return containingNodeKind === 204; - case 113: - case 111: + return containingNodeKind === 196; + case 15: + return containingNodeKind === 205; + case 114: case 112: - return containingNodeKind === 148; + case 113: + return containingNodeKind === 149; } switch (previousToken.getText()) { case "public": @@ -58327,7 +60855,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 11 + || contextToken.kind === 12 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -58336,7 +60864,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 11; + || contextToken.kind === 12; } } return false; @@ -58345,22 +60873,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 177) { + if (objectLikeContainer.kind === 178) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 173) { + else if (objectLikeContainer.kind === 174) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 145) { + if (!canGetType && rootDeclaration.kind === 146) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 150 || rootDeclaration.parent.kind === 153) { + else if (rootDeclaration.parent.kind === 151 || rootDeclaration.parent.kind === 154) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -58386,9 +60914,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 240 ? - 237 : - 243; + var declarationKind = namedImportsOrExports.kind === 241 ? + 238 : + 244; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -58408,10 +60936,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16: - case 25: + case 17: + case 26: var parent = contextToken.parent; - if (parent && (parent.kind === 177 || parent.kind === 173)) { + if (parent && (parent.kind === 178 || parent.kind === 174)) { return parent; } break; @@ -58422,11 +60950,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16: - case 25: + case 17: + case 26: switch (contextToken.parent.kind) { - case 240: - case 244: + case 241: + case 245: return contextToken.parent; } } @@ -58437,31 +60965,32 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 27: - case 40: - case 70: - case 253: - case 252: + case 28: + case 41: + case 71: + case 179: case 254: - if (parent && (parent.kind === 249 || parent.kind === 250)) { + case 253: + case 255: + if (parent && (parent.kind === 250 || parent.kind === 251)) { return parent; } - else if (parent.kind === 252) { + else if (parent.kind === 253) { return parent.parent.parent; } break; case 9: - if (parent && ((parent.kind === 252) || (parent.kind === 254))) { + if (parent && ((parent.kind === 253) || (parent.kind === 255))) { return parent.parent.parent; } break; - case 17: + case 18: if (parent && - parent.kind === 255 && - parent.parent && parent.parent.kind === 252) { + parent.kind === 256 && + parent.parent && parent.parent.kind === 253) { return parent.parent.parent.parent; } - if (parent && parent.kind === 254) { + if (parent && parent.kind === 255) { return parent.parent.parent; } break; @@ -58470,85 +60999,82 @@ var ts; return undefined; } function isFunction(kind) { + if (!ts.isFunctionLikeKind(kind)) { + return false; + } switch (kind) { - case 185: - case 186: - case 227: - case 150: - case 149: case 152: - case 153: - case 154: - case 155: - case 156: + case 161: + case 160: + return false; + default: return true; } - return false; } function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 25: - return containingNodeKind === 225 || - containingNodeKind === 226 || - containingNodeKind === 207 || - containingNodeKind === 231 || - isFunction(containingNodeKind) || - containingNodeKind === 228 || - containingNodeKind === 198 || - containingNodeKind === 229 || - containingNodeKind === 174 || - containingNodeKind === 230; - case 22: - return containingNodeKind === 174; - case 55: - return containingNodeKind === 175; - case 20: - return containingNodeKind === 174; - case 18: - return containingNodeKind === 259 || - isFunction(containingNodeKind); - case 16: - return containingNodeKind === 231 || - containingNodeKind === 229 || - containingNodeKind === 162; - case 24: - return containingNodeKind === 147 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 229 || - contextToken.parent.parent.kind === 162); case 26: - return containingNodeKind === 228 || - containingNodeKind === 198 || + return containingNodeKind === 226 || + containingNodeKind === 227 || + containingNodeKind === 208 || + containingNodeKind === 232 || + isFunction(containingNodeKind) || containingNodeKind === 229 || + containingNodeKind === 199 || containingNodeKind === 230 || - isFunction(containingNodeKind); - case 114: - return containingNodeKind === 148; + containingNodeKind === 175 || + containingNodeKind === 231; case 23: - return containingNodeKind === 145 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 174); - case 113: - case 111: - case 112: - return containingNodeKind === 145; - case 117: - return containingNodeKind === 241 || - containingNodeKind === 245 || - containingNodeKind === 239; - case 74: - case 82: - case 108: - case 88: - case 103: - case 124: - case 134: - case 90: - case 109: - case 75: + return containingNodeKind === 175; + case 56: + return containingNodeKind === 176; + case 21: + return containingNodeKind === 175; + case 19: + return containingNodeKind === 260 || + isFunction(containingNodeKind); + case 17: + return containingNodeKind === 232 || + containingNodeKind === 230 || + containingNodeKind === 163; + case 25: + return containingNodeKind === 148 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 230 || + contextToken.parent.parent.kind === 163); + case 27: + return containingNodeKind === 229 || + containingNodeKind === 199 || + containingNodeKind === 230 || + containingNodeKind === 231 || + isFunction(containingNodeKind); case 115: - case 137: + return containingNodeKind === 149; + case 24: + return containingNodeKind === 146 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 175); + case 114: + case 112: + case 113: + return containingNodeKind === 146; + case 118: + return containingNodeKind === 242 || + containingNodeKind === 246 || + containingNodeKind === 240; + case 75: + case 83: + case 109: + case 89: + case 104: + case 125: + case 135: + case 91: + case 110: + case 76: + case 116: + case 138: return true; } switch (contextToken.getText()) { @@ -58600,20 +61126,20 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 260 && - m.kind !== 261 && - m.kind !== 175 && - m.kind !== 150 && - m.kind !== 152 && - m.kind !== 153) { + if (m.kind !== 261 && + m.kind !== 262 && + m.kind !== 176 && + m.kind !== 151 && + m.kind !== 153 && + m.kind !== 154) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 175 && m.propertyName) { - if (m.propertyName.kind === 70) { + if (m.kind === 176 && m.propertyName) { + if (m.propertyName.kind === 71) { existingName = m.propertyName.text; } } @@ -58631,7 +61157,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 252) { + if (attr.kind === 253) { seenNames.set(attr.name.text, true); } } @@ -58664,7 +61190,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 141; i++) { + for (var i = 72; i <= 142; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -58672,46 +61198,14 @@ var ts; sortText: "0" }); } - var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105)) { + if (pushKeywordIf(keywords, loopTokens[i], 106)) { break; } } @@ -59072,7 +61560,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + pushKeywordIf(keywords, statement.getFirstToken(), 72, 77); } }); return keywords; @@ -59081,13 +61569,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 213: case 214: case 215: - case 211: + case 216: case 212: + case 213: return getLoopBreakContinueOccurrences(owner); - case 220: + case 221: return getSwitchCaseDefaultOccurrences(owner); } } @@ -59095,13 +61583,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 98); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + pushKeywordIf(keywords, clause.getFirstToken(), 73, 79); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71); + pushKeywordIf(keywords, statement.getFirstToken(), 72); } }); }); @@ -59109,13 +61597,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 102); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 87); } return keywords; } @@ -59126,50 +61614,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96); }); } return keywords; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 206))) { + if (!(func && hasKind(func.body, 207))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100); }); return keywords; } function getIfElseOccurrences(ifStatement, sourceFile) { var keywords = []; - while (hasKind(ifStatement.parent, 210) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 211) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89); + pushKeywordIf(keywords, children[0], 90); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81)) { + if (pushKeywordIf(keywords, children[i], 82)) { break; } } - if (!hasKind(ifStatement.elseStatement, 210)) { + if (!hasKind(ifStatement.elseStatement, 211)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 && i < keywords.length - 1) { + if (keywords[i].kind === 82 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -59194,7 +61682,7 @@ var ts; return result; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 221; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 222; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -59309,1034 +61797,1651 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { - var node = ts.getTouchingPropertyName(sourceFile, position, true); - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); + function createImportTracker(sourceFiles, checker, cancellationToken) { + var allDirectImports = getDirectImportsMap(sourceFiles, checker, cancellationToken); + return function (exportSymbol, exportInfo, isForRename) { + var _a = getImportersForExport(sourceFiles, allDirectImports, exportInfo, checker, cancellationToken), directImports = _a.directImports, indirectUsers = _a.indirectUsers; + return __assign({ indirectUsers: indirectUsers }, getSearchesFromDirectImports(directImports, exportSymbol, exportInfo.exportKind, checker, isForRename)); + }; } - FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function convertReferences(referenceSymbols) { - return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); - } - FindAllReferences.convertReferences = convertReferences; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { - if (!implementations) { - var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); - if (special) { - return special; + FindAllReferences.createImportTracker = createImportTracker; + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + })(ExportKind = FindAllReferences.ExportKind || (FindAllReferences.ExportKind = {})); + var ImportExport; + (function (ImportExport) { + ImportExport[ImportExport["Import"] = 0] = "Import"; + ImportExport[ImportExport["Export"] = 1] = "Export"; + })(ImportExport = FindAllReferences.ImportExport || (FindAllReferences.ImportExport = {})); + function getImportersForExport(sourceFiles, allDirectImports, _a, checker, cancellationToken) { + var exportingModuleSymbol = _a.exportingModuleSymbol, exportKind = _a.exportKind; + var markSeenDirectImport = ts.nodeSeenTracker(); + var markSeenIndirectUser = ts.nodeSeenTracker(); + var directImports = []; + var isAvailableThroughGlobal = !!exportingModuleSymbol.globalExports; + var indirectUserDeclarations = isAvailableThroughGlobal ? undefined : []; + handleDirectImports(exportingModuleSymbol); + return { directImports: directImports, indirectUsers: getIndirectUsers() }; + function getIndirectUsers() { + if (isAvailableThroughGlobal) { + return sourceFiles; } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - if (!implementations && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl)) { + addIndirectUser(decl); + } } - return undefined; + return indirectUserDeclarations.map(ts.getSourceFileOfNode); } - var declarations = symbol.declarations; - if (!declarations || !declarations.length) { - return undefined; + function handleDirectImports(exportingModuleSymbol) { + var theseDirectImports = getDirectImports(exportingModuleSymbol); + if (theseDirectImports) + for (var _i = 0, theseDirectImports_1 = theseDirectImports; _i < theseDirectImports_1.length; _i++) { + var direct = theseDirectImports_1[_i]; + if (!markSeenDirectImport(direct)) { + continue; + } + cancellationToken.throwIfCancellationRequested(); + switch (direct.kind) { + case 181: + if (!isAvailableThroughGlobal) { + var parent = direct.parent; + if (exportKind === 2 && parent.kind === 226) { + var name = parent.name; + if (name.kind === 71) { + directImports.push(name); + break; + } + } + addIndirectUser(direct.getSourceFile()); + } + break; + case 237: + handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1)); + break; + case 238: + var namedBindings = direct.importClause && direct.importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240) { + handleNamespaceImport(direct, namedBindings.name); + } + else { + directImports.push(direct); + } + break; + case 244: + if (!direct.exportClause) { + handleDirectImports(getContainingModuleSymbol(direct, checker)); + } + else { + directImports.push(direct); + } + break; + } + } } - var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; - symbol = aliasedSymbol; - var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); - if (shorthandModuleSymbol) { - searchSymbols.push(shorthandModuleSymbol); - } - var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); - var result = []; - var symbolToIndex = []; - var inheritsFromCache = ts.createMap(); - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var scope = getSymbolScope(symbol); - if (scope) { - getRefs(scope, declaredName); - } - else { - var isDefault = ts.isExportDefaultSymbol(symbol); - var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; - cancellationToken.throwIfCancellationRequested(); - var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || - (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); - if (searchName !== undefined) { - getRefs(sourceFile, searchName); + function handleNamespaceImport(importDeclaration, name, isReExport) { + if (exportKind === 2) { + directImports.push(importDeclaration); + } + else if (!isAvailableThroughGlobal) { + var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); + ts.Debug.assert(sourceFileLike.kind === 265 || sourceFileLike.kind === 233); + if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { + addIndirectUsers(sourceFileLike); + } + else { + addIndirectUser(sourceFileLike); } } } - return result; - function getRefs(scope, searchName) { - getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); + function addIndirectUser(sourceFileLike) { + ts.Debug.assert(!isAvailableThroughGlobal); + var isNew = markSeenIndirectUser(sourceFileLike); + if (isNew) { + indirectUserDeclarations.push(sourceFileLike); + } + return isNew; + } + function addIndirectUsers(sourceFileLike) { + if (!addIndirectUser(sourceFileLike)) { + return; + } + var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); + ts.Debug.assert(!!(moduleSymbol.flags & 1536)); + var directImports = getDirectImports(moduleSymbol); + if (directImports) + for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { + var directImport = directImports_1[_i]; + addIndirectUsers(getSourceFileLikeForImportDeclaration(directImport)); + } + } + function getDirectImports(moduleSymbol) { + return allDirectImports.get(ts.getSymbolId(moduleSymbol).toString()); } } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { - if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { + var exportName = exportSymbol.name; + var importSearches = []; + var singleReferences = []; + function addSearch(location, symbol) { + importSearches.push([location, symbol]); } - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); + if (directImports) + for (var _i = 0, directImports_2 = directImports; _i < directImports_2.length; _i++) { + var decl = directImports_2[_i]; + handleImport(decl); + } + return { importSearches: importSearches, singleReferences: singleReferences }; + function handleImport(decl) { + if (decl.kind === 237) { + if (isExternalModuleImportEquals(decl)) { + handleNamespaceImportLike(decl.name); + } + return; + } + if (decl.kind === 71) { + handleNamespaceImportLike(decl); + return; + } + if (decl.moduleSpecifier.kind !== 9) { + return; + } + if (decl.kind === 244) { + searchForNamedImport(decl.exportClause); + return; + } + var importClause = decl.importClause; + var namedBindings = importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240) { + handleNamespaceImportLike(namedBindings.name); + return; + } + if (exportKind === 0) { + searchForNamedImport(namedBindings); } else { - return getLabelReferencesInNode(node.parent, node, cancellationToken); + var name = importClause.name; + if (name && (!isForRename || name.text === symbolName(exportSymbol))) { + var defaultImportAlias = checker.getSymbolAtLocation(name); + addSearch(name, defaultImportAlias); + } + if (!isForRename && exportKind === 1) { + ts.Debug.assert(exportName === "default"); + searchForNamedImport(namedBindings); + } } } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + function handleNamespaceImportLike(importName) { + if (exportKind === 2 && (!isForRename || importName.text === exportName)) { + addSearch(importName, checker.getSymbolAtLocation(importName)); + } } - if (node.kind === 96) { - return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); - } - return undefined; - } - function followAliases(symbol, node, typeChecker, isForRename) { - while (true) { - if (isForRename && isImportDefaultSymbol(symbol)) { - return { symbol: symbol }; - } - var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); - if (!aliasedSymbol || !aliasedSymbol.declarations) { - return { symbol: symbol }; - } - if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { - return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; - } - symbol = aliasedSymbol; + function searchForNamedImport(namedBindings) { + if (namedBindings) + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if ((propertyName || name).text !== exportName) { + continue; + } + if (propertyName) { + singleReferences.push(propertyName); + if (!isForRename) { + addSearch(name, checker.getSymbolAtLocation(name)); + } + } + else { + var localSymbol = element.kind === 246 && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } + } } } - function sourceFileHasName(sourceFile, name) { - return ts.getNameTable(sourceFile).get(name) !== undefined; + function findNamespaceReExports(sourceFileLike, name, checker) { + var namespaceImportSymbol = checker.getSymbolAtLocation(name); + return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + if (statement.kind !== 244) + return; + var _a = statement, exportClause = _a.exportClause, moduleSpecifier = _a.moduleSpecifier; + if (moduleSpecifier || !exportClause) + return; + for (var _i = 0, _b = exportClause.elements; _i < _b.length; _i++) { + var element = _b[_i]; + if (checker.getExportSpecifierLocalTargetSymbol(element) === namespaceImportSymbol) { + return true; + } + } + }); } - function getDefaultImportName(symbol, sourceFile, checker) { - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importSpecifier = _a[_i]; - var importDecl = importSpecifier.parent; - ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); - var defaultName = importDecl.importClause.name; - var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); - if (symbol === defaultReferencedSymbol) { - return defaultName.text; + function getDirectImportsMap(sourceFiles, checker, cancellationToken) { + var map = ts.createMap(); + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; + cancellationToken.throwIfCancellationRequested(); + forEachImport(sourceFile, function (importDecl, moduleSpecifier) { + var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); + if (moduleSymbol) { + var id = ts.getSymbolId(moduleSymbol).toString(); + var imports = map.get(id); + if (!imports) { + map.set(id, imports = []); + } + imports.push(importDecl); + } + }); + } + return map; + } + function forEachPossibleImportOrExportStatement(sourceFileLike, action) { + return ts.forEach(sourceFileLike.kind === 265 ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); + }); + } + function forEachImport(sourceFile, action) { + if (sourceFile.externalModuleIndicator) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; + action(importerFromModuleSpecifier(moduleSpecifier), moduleSpecifier); + } + } + else { + forEachPossibleImportOrExportStatement(sourceFile, function (statement) { + switch (statement.kind) { + case 244: + case 238: { + var decl = statement; + if (decl.moduleSpecifier && decl.moduleSpecifier.kind === 9) { + action(decl, decl.moduleSpecifier); + } + break; + } + case 237: { + var decl = statement; + var moduleReference = decl.moduleReference; + if (moduleReference.kind === 248 && + moduleReference.expression.kind === 9) { + action(decl, moduleReference.expression); + } + break; + } + } + }); + if (sourceFile.flags & 65536) { + sourceFile.forEachChild(function recur(node) { + if (ts.isRequireCall(node, true)) { + action(node, node.arguments[0]); + } + else { + node.forEachChild(recur); + } + }); } } - return undefined; } - function getDefinition(symbol, node, typeChecker) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; - var name = displayParts.map(function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { + function importerFromModuleSpecifier(moduleSpecifier) { + var decl = moduleSpecifier.parent; + if (decl.kind === 238 || decl.kind === 244) { + return decl; + } + ts.Debug.assert(decl.kind === 248); + return decl.parent; + } + function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { + return comingFromExport ? getExport() : getExport() || getImport(); + function getExport() { + var parent = node.parent; + if (symbol.flags & 7340032) { + if (parent.kind === 179) { + return symbol.declarations.some(function (d) { return d === parent; }) && parent.parent.kind === 194 + ? getSpecialPropertyExport(parent.parent, false) + : undefined; + } + else { + var exportSymbol = symbol.exportSymbol; + ts.Debug.assert(!!exportSymbol); + return exportInfo(exportSymbol, getExportKindForDeclaration(parent)); + } + } + else { + var exportNode = getExportNode(parent); + if (exportNode && ts.hasModifier(exportNode, 1)) { + if (exportNode.kind === 237 && exportNode.moduleReference === node) { + if (comingFromExport) { + return undefined; + } + var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); + return { kind: 0, symbol: lhsSymbol, isNamedImport: false }; + } + else { + return exportInfo(symbol, getExportKindForDeclaration(exportNode)); + } + } + else if (parent.kind === 243) { + var exportingModuleSymbol = parent.symbol.parent; + ts.Debug.assert(!!exportingModuleSymbol); + return { kind: 1, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 } }; + } + else if (parent.kind === 194) { + return getSpecialPropertyExport(parent, true); + } + else if (parent.parent.kind === 194) { + return getSpecialPropertyExport(parent.parent, true); + } + } + function getSpecialPropertyExport(node, useLhsSymbol) { + var kind; + switch (ts.getSpecialPropertyAssignmentKind(node)) { + case 1: + kind = 0; + break; + case 2: + kind = 2; + break; + default: + return undefined; + } + var sym = useLhsSymbol ? checker.getSymbolAtLocation(node.left.name) : symbol; + return sym && exportInfo(sym, kind); + } + } + function getImport() { + var isImport = isNodeImport(node); + if (!isImport) + return; + var importedSymbol = checker.getImmediateAliasedSymbol(symbol); + if (importedSymbol) { + importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker); + if (importedSymbol.name === "export=") { + importedSymbol = checker.getImmediateAliasedSymbol(importedSymbol); + } + if (symbolName(importedSymbol) === symbol.name) { + return __assign({ kind: 0, symbol: importedSymbol }, isImport); + } + } + } + function exportInfo(symbol, kind) { + var exportInfo = getExportInfo(symbol, kind, checker); + return exportInfo && { kind: 1, symbol: symbol, exportInfo: exportInfo }; + } + function getExportKindForDeclaration(node) { + return ts.hasModifier(node, 512) ? 1 : 0; + } + } + FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; + function getExportNode(parent) { + if (parent.kind === 226) { + var p = parent; + return p.parent.kind === 260 ? undefined : p.parent.parent.kind === 208 ? p.parent.parent : undefined; + } + else { + return parent; + } + } + function isNodeImport(node) { + var parent = node.parent; + switch (parent.kind) { + case 237: + return parent.name === node && isExternalModuleImportEquals(parent) + ? { isNamedImport: false } + : undefined; + case 242: + return parent.propertyName ? undefined : { isNamedImport: true }; + case 239: + case 240: + ts.Debug.assert(parent.name === node); + return { isNamedImport: false }; + default: + return undefined; + } + } + function getExportInfo(exportSymbol, exportKind, checker) { + var exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); + return ts.isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } : undefined; + } + FindAllReferences.getExportInfo = getExportInfo; + function symbolName(symbol) { + if (symbol.name !== "default") { + return symbol.name; + } + var name = ts.forEach(symbol.declarations, function (_a) { + var name = _a.name; + return name && name.kind === 71 && name.text; + }); + ts.Debug.assert(!!name); + return name; + } + function skipExportSpecifierSymbol(symbol, checker) { + if (symbol.declarations) + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) { + return checker.getExportSpecifierLocalTargetSymbol(declaration); + } + } + return symbol; + } + function getContainingModuleSymbol(importer, checker) { + return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); + } + function getSourceFileLikeForImportDeclaration(node) { + if (node.kind === 181) { + return node.getSourceFile(); + } + var parent = node.parent; + if (parent.kind === 265) { + return parent; + } + ts.Debug.assert(parent.kind === 234 && isAmbientModuleDeclaration(parent.parent)); + return parent.parent; + } + function isAmbientModuleDeclaration(node) { + return node.kind === 233 && node.name.kind === 9; + } + function isExternalModuleImportEquals(_a) { + var moduleReference = _a.moduleReference; + return moduleReference.kind === 248 && moduleReference.expression.kind === 9; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + function nodeEntry(node, isInString) { + return { type: "node", node: node, isInString: isInString }; + } + FindAllReferences.nodeEntry = nodeEntry; + function findReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position) { + var referencedSymbols = findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position); + if (!referencedSymbols || !referencedSymbols.length) { return undefined; } + var out = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var _a = referencedSymbols_1[_i], definition = _a.definition, references = _a.references; + if (definition) { + out.push({ definition: definitionToReferencedSymbolDefinitionInfo(definition, checker), references: references.map(toReferenceEntry) }); + } + } + return out; + } + FindAllReferences.findReferencedSymbols = findReferencedSymbols; + function getImplementationsAtPosition(checker, cancellationToken, sourceFiles, sourceFile, position) { + var node = ts.getTouchingPropertyName(sourceFile, position); + var referenceEntries = getImplementationReferenceEntries(checker, cancellationToken, sourceFiles, node); + return ts.map(referenceEntries, function (entry) { return toImplementationLocation(entry, checker); }); + } + FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; + function getImplementationReferenceEntries(typeChecker, cancellationToken, sourceFiles, node) { + if (node.parent.kind === 262) { + var result_4 = []; + FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, function (node) { return result_4.push(nodeEntry(node)); }); + return result_4; + } + else if (node.kind === 97 || ts.isSuperProperty(node.parent)) { + var symbol = typeChecker.getSymbolAtLocation(node); + return symbol.valueDeclaration && [nodeEntry(symbol.valueDeclaration)]; + } + else { + return getReferenceEntriesForNode(node, sourceFiles, typeChecker, cancellationToken, { implementations: true }); + } + } + function findReferencedEntries(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var x = flattenEntries(findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options)); + return ts.map(x, toReferenceEntry); + } + FindAllReferences.findReferencedEntries = findReferencedEntries; + function getReferenceEntriesForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + return flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options)); + } + FindAllReferences.getReferenceEntriesForNode = getReferenceEntriesForNode; + function findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var node = ts.getTouchingPropertyName(sourceFile, position, true); + return FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options); + } + function flattenEntries(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + function definitionToReferencedSymbolDefinitionInfo(def, checker) { + var info = (function () { + switch (def.type) { + case "symbol": { + var symbol = def.symbol, node_2 = def.node; + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; + var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + } + case "label": { + var node_3 = def.node; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + } + case "keyword": { + var node_4 = def.node; + var name_4 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; + } + case "this": { + var node_5 = def.node; + var symbol = checker.getSymbolAtLocation(node_5); + var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; + } + case "string": { + var node_6 = def.node; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + } + } + })(); + if (!info) { + return undefined; + } + var node = info.node, name = info.name, kind = info.kind, displayParts = info.displayParts; + var sourceFile = node.getSourceFile(); return { containerKind: "", containerName: "", + fileName: sourceFile.fileName, + kind: kind, name: name, - kind: symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + textSpan: ts.createTextSpanFromNode(node, sourceFile), displayParts: displayParts }; } - function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { - if (!(symbol.flags & 8388608)) { - return undefined; - } - var defaultImport = ts.getDeclarationOfKind(symbol, 238); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 || - declaration.kind === 245) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 241 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + function getDefinitionKindAndDisplayParts(symbol, node, checker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + return { displayParts: displayParts, kind: symbolKind }; } - function followAliasIfNecessary(symbol, location, typeChecker) { - return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175); - return bindingElement && - bindingElement.parent.kind === 173 && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + function toReferenceEntry(entry) { + if (entry.type === "span") { + return { textSpan: entry.textSpan, fileName: entry.fileName, isWriteAccess: false, isDefinition: false }; } - return undefined; - } - function getInternedName(symbol, location) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.text; - } - return ts.stripQuotes(symbol.name); - } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 185 || valueDeclaration.kind === 198)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 228); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - if (symbol.parent || (symbol.flags & 134217728 && symbol.checkFlags & 2)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 264 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; - } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - if (position > end) - break; - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { - positions.push(position); - } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } - return positions; - } - function getLabelReferencesInNode(container, targetLabel, cancellationToken) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + var node = entry.node, isInString = entry.isInString; + return { + fileName: node.getSourceFile().fileName, + textSpan: getTextSpan(node), + isWriteAccess: isWriteAccess(node), + isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isInString: isInString }; - return [{ definition: definition, references: references }]; } - function isValidReferencePosition(node, searchSymbolName) { - switch (node && node.kind) { - case 70: - return node.getWidth() === searchSymbolName.length; - case 9: - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && - node.getWidth() === searchSymbolName.length + 2; - case 8: - return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; - default: - return false; - } - } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { - var name = ts.tokenToString(keywordKind); - var references = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); - } - if (!references.length) - return undefined; - var definition = { - containerKind: "", - containerName: "", - fileName: references[0].fileName, - kind: ts.ScriptElementKind.keyword, - name: name, - textSpan: references[0].textSpan, - displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] - }; - return [{ definition: definition, references: references }]; - } - function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (referenceLocation.kind === kind) { - references.push({ - textSpan: ts.createTextSpanFromNode(referenceLocation), - fileName: sourceFile.fileName, - isWriteAccess: false, - isDefinition: false, - }); - } - } - } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); - var parents = getParentSymbolsOfPropertyAccess(); - for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { - var position = possiblePositions_2[_i]; - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - continue; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - continue; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache, typeChecker); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 134217728) && ts.contains(searchSymbols, shorthandValueSymbol)) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol, searchLocation, typeChecker), - references: [] - }); - } - return result[index]; - } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references, typeChecker); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - function findOwnConstructorCalls(classSymbol, sourceFile) { - var result = []; - for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 122, sourceFile); - ts.Debug.assert(decl.kind === 151 && !!ctrKeyword); - result.push(ctrKeyword); - } - classSymbol.exports.forEach(function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 150) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor"); - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 151); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70) { - if (refNode.parent.kind === 261) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent = containingTypeReference.parent; - if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); - } - else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - if (parent.body.kind === 206) { - ts.forEachReturnStatement(parent.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); - } - } - else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); - } - } - } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 200 - && node.parent.kind === 258 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 || node.kind === 178) { - return getContainingClassIfInHeritageClause(node.parent); - } - } - return undefined; - } - function isImplementationExpression(node) { - switch (node.kind) { - case 184: - return isImplementationExpression(node.expression); - case 186: - case 185: - case 177: - case 198: - case 176: - return true; - default: - return false; - } - } - function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - var cached = cachedResults.get(key); - if (cached !== undefined) { - return cached; - } - cachedResults.set(key, false); - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 229) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults.set(key, inherits); - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { - return undefined; - } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 148: - case 147: - case 150: - case 149: - case 151: - case 152: - case 153: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - default: - return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { - var position = possiblePositions_3[_i]; - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96) { - continue; - } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - } - var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 150: - case 149: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; - } - case 148: - case 147: - case 151: - case 152: - case 153: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 264: - if (ts.isExternalModule(searchSpaceNode)) { - return undefined; - } - case 227: - case 185: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 264) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); + function toImplementationLocation(entry, checker) { + if (entry.type === "node") { + var node = entry.node; + return __assign({ textSpan: getTextSpan(node), fileName: node.getSourceFile().fileName }, implementationKindDisplayParts(node, checker)); } else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: thisOrSuperKeyword.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 185: - case 227: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 150: - case 149: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 198: - case 228: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 264: - if (container.kind === 264 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); + var textSpan = entry.textSpan, fileName = entry.fileName; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } - function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; + function implementationKindDisplayParts(node, checker) { + var symbol = checker.getSymbolAtLocation(ts.isDeclaration(node) && node.name ? node.name : node); + if (symbol) { + return getDefinitionKindAndDisplayParts(symbol, node, checker); } - var references = []; - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + else if (node.kind === 178) { + return { + kind: ts.ScriptElementKind.interfaceElement, + displayParts: [ts.punctuationPart(19), ts.textPart("object literal"), ts.punctuationPart(20)] + }; } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromNode(node), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { - var position = possiblePositions_4[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { - return; - } - var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_2 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } - } - } - } - function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { - var result = [symbol]; - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); - if (propertySymbol) { - result.push(propertySymbol); - } - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); - } - } - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { - if (!symbol) { - return; - } - if (previousIterationSymbolsCache.has(symbol.name)) { - return; - } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 229) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - previousIterationSymbolsCache.set(symbol.name, symbol); - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); - } - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); - if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { - return propertySymbol; - } - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); - if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (ts.contains(searchSymbols, rootSymbol)) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { - return undefined; - } - } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); - return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 143) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node, typeChecker) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_4 = []; - var symbol = contextualType.getProperty(name); - if (symbol) { - result_4.push(symbol); - } - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_4.push(symbol); - } - }); - } - return result_4; - } - return undefined; - } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - function isImplementation(node) { - if (!node) { - return false; - } - else if (ts.isVariableLike(node)) { - if (node.initializer) { - return true; - } - else if (node.kind === 225) { - var parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && ts.hasModifier(parentStatement, 2); - } - } - else if (ts.isFunctionLike(node)) { - return !!node.body || ts.hasModifier(node, 2); + else if (node.kind === 199) { + return { + kind: ts.ScriptElementKind.localClassElement, + displayParts: [ts.punctuationPart(19), ts.textPart("anonymous local class"), ts.punctuationPart(20)] + }; } else { - switch (node.kind) { - case 228: - case 198: - case 231: - case 232: - return true; - } - } - return false; - } - function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 207) { - ts.Debug.assert(node.parent.kind === 226); - return node.parent.parent; + return { kind: ts.getNodeKind(node), displayParts: [] }; } } - function getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result) { - var refSymbol = typeChecker.getSymbolAtLocation(node); - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); - if (shorthandSymbol) { - for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1) { - result.push(getReferenceEntryFromNode(declaration)); - } - } + function toHighlightSpan(entry) { + if (entry.type === "span") { + var fileName_1 = entry.fileName, textSpan = entry.textSpan; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; } + var node = entry.node, isInString = entry.isInString; + var fileName = entry.node.getSourceFile().fileName; + var writeAccess = isWriteAccess(node); + var span = { + textSpan: getTextSpan(node), + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, + isInString: isInString + }; + return { fileName: fileName, span: span }; } - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; - function getReferenceEntryFromNode(node) { + FindAllReferences.toHighlightSpan = toHighlightSpan; + function getTextSpan(node) { var start = node.getStart(); var end = node.getEnd(); if (node.kind === 9) { start += 1; end -= 1; } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - }; + return ts.createTextSpanFromBounds(start, end); } - FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; function isWriteAccess(node) { - if (node.kind === 70 && ts.isDeclarationName(node)) { + if (node.kind === 71 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 192 || parent.kind === 191) { + if (parent.kind === 193 || parent.kind === 192) { return true; } - else if (parent.kind === 193 && parent.left === node) { + else if (parent.kind === 194 && parent.left === node) { var operator = parent.operatorToken.kind; - return 57 <= operator && operator <= 69; + return 58 <= operator && operator <= 70; } } return false; } - function forEachDescendantOfKind(node, kind, action) { - ts.forEachChild(node, function (child) { - if (child.kind === kind) { - action(child); + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + var Core; + (function (Core) { + function getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + if (node.kind === 265) { + return undefined; } - forEachDescendantOfKind(child, kind, action); - }); - } - function tryGetClassByExtendingIdentifier(node) { - return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9) { - return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + if (!options.implementations) { + var special = getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken); + if (special) { + return special; + } + } + var symbol = checker.getSymbolAtLocation(node); + if (!symbol) { + if (!options.implementations && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles, cancellationToken); + } + return undefined; + } + if (!symbol.declarations || !symbol.declarations.length) { + return undefined; + } + return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options); } - return false; - } - function isImportDefaultSymbol(symbol) { - return symbol.declarations[0].kind === 238; - } + Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition); + } + else { + return getLabelReferencesInNode(node.parent, node); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); + } + if (node.kind === 97) { + return getReferencesForSuperKeyword(node); + } + return undefined; + } + function getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options) { + symbol = skipPastExportOrImportSpecifier(symbol, node, checker); + var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), symbol.declarations); + var result = []; + var state = createState(sourceFiles, node, checker, cancellationToken, searchMeaning, options, result); + var search = state.createSearch(node, symbol, undefined, { allSearchSymbols: populateSearchSymbolSet(symbol, node, checker, options.implementations) }); + var scope = getSymbolScope(symbol); + if (scope) { + getReferencesInContainer(scope, scope.getSourceFile(), search, state); + } + else { + for (var _i = 0, _a = state.sourceFiles; _i < _a.length; _i++) { + var sourceFile = _a[_i]; + state.cancellationToken.throwIfCancellationRequested(); + searchForName(sourceFile, search, state); + } + } + return result; + } + function skipPastExportOrImportSpecifier(symbol, node, checker) { + var parent = node.parent; + if (ts.isExportSpecifier(parent)) { + return getLocalSymbolForExportSpecifier(node, symbol, parent, checker); + } + if (ts.isImportSpecifier(parent) && parent.propertyName === node) { + return checker.getImmediateAliasedSymbol(symbol); + } + return symbol; + } + function createState(sourceFiles, originalLocation, checker, cancellationToken, searchMeaning, options, result) { + var symbolIdToReferences = []; + var inheritsFromCache = ts.createMap(); + var sourceFileToSeenSymbols = []; + var isForConstructor = originalLocation.kind === 123; + var importTracker; + return __assign({}, options, { sourceFiles: sourceFiles, isForConstructor: isForConstructor, checker: checker, cancellationToken: cancellationToken, searchMeaning: searchMeaning, inheritsFromCache: inheritsFromCache, getImportSearches: getImportSearches, createSearch: createSearch, referenceAdder: referenceAdder, addStringOrCommentReference: addStringOrCommentReference, + markSearchedSymbol: markSearchedSymbol, markSeenContainingTypeReference: ts.nodeSeenTracker(), markSeenReExportRHS: ts.nodeSeenTracker() }); + function getImportSearches(exportSymbol, exportInfo) { + if (!importTracker) + importTracker = FindAllReferences.createImportTracker(sourceFiles, checker, cancellationToken); + return importTracker(exportSymbol, exportInfo, options.isForRename); + } + function createSearch(location, symbol, comingFrom, searchOptions) { + if (searchOptions === void 0) { searchOptions = {}; } + var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.getDeclaredName(checker, symbol, location)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? undefined : _b; + var escapedText = ts.escapeIdentifier(text); + var parents = options.implementations && getParentSymbolsOfPropertyAccess(location, symbol, checker); + return { location: location, symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, includes: includes }; + function includes(referenceSymbol) { + return allSearchSymbols ? ts.contains(allSearchSymbols, referenceSymbol) : referenceSymbol === symbol; + } + } + function referenceAdder(referenceSymbol, searchLocation) { + var symbolId = ts.getSymbolId(referenceSymbol); + var references = symbolIdToReferences[symbolId]; + if (!references) { + references = symbolIdToReferences[symbolId] = []; + result.push({ definition: { type: "symbol", symbol: referenceSymbol, node: searchLocation }, references: references }); + } + return function (node) { return references.push(FindAllReferences.nodeEntry(node)); }; + } + function addStringOrCommentReference(fileName, textSpan) { + result.push({ + definition: undefined, + references: [{ type: "span", fileName: fileName, textSpan: textSpan }] + }); + } + function markSearchedSymbol(sourceFile, symbol) { + var sourceId = ts.getNodeId(sourceFile); + var symbolId = ts.getSymbolId(symbol); + var seenSymbols = sourceFileToSeenSymbols[sourceId] || (sourceFileToSeenSymbols[sourceId] = []); + return !seenSymbols[symbolId] && (seenSymbols[symbolId] = true); + } + } + function searchForImportsOfExport(exportLocation, exportSymbol, exportInfo, state) { + var _a = state.getImportSearches(exportSymbol, exportInfo), importSearches = _a.importSearches, singleReferences = _a.singleReferences, indirectUsers = _a.indirectUsers; + if (singleReferences.length) { + var addRef = state.referenceAdder(exportSymbol, exportLocation); + for (var _i = 0, singleReferences_1 = singleReferences; _i < singleReferences_1.length; _i++) { + var singleRef = singleReferences_1[_i]; + addRef(singleRef); + } + } + for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { + var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1), state); + } + if (indirectUsers.length) { + var indirectSearch = void 0; + switch (exportInfo.exportKind) { + case 0: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1); + break; + case 1: + indirectSearch = state.isForRename ? undefined : state.createSearch(exportLocation, exportSymbol, 1, { text: "default" }); + break; + case 2: + break; + } + if (indirectSearch) { + for (var _d = 0, indirectUsers_1 = indirectUsers; _d < indirectUsers_1.length; _d++) { + var indirectUser = indirectUsers_1[_d]; + searchForName(indirectUser, indirectSearch, state); + } + } + } + } + function searchForImportedSymbol(symbol, state) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + getReferencesInSourceFile(declaration.getSourceFile(), state.createSearch(declaration, symbol, 0), state); + } + } + function searchForName(sourceFile, search, state) { + if (ts.getNameTable(sourceFile).get(search.escapedText) !== undefined) { + getReferencesInSourceFile(sourceFile, search, state); + } + } + function getPropertySymbolOfDestructuringAssignment(location, checker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + checker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176); + return bindingElement && + bindingElement.parent.kind === 174 && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176); + var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getSymbolScope(symbol) { + var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 186 || valueDeclaration.kind === 199)) { + return valueDeclaration; + } + if (!declarations) { + return undefined; + } + if (flags & (4 | 8192)) { + var privateDeclaration = ts.find(declarations, function (d) { return !!(ts.getModifierFlags(d) & 8); }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 229); + } + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (parent && !((parent.flags & 1536) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { + return undefined; + } + if ((flags & 134217728 && symbol.checkFlags & 6)) { + return undefined; + } + var scope; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (scope && scope !== container) { + return undefined; + } + if (!container || container.kind === 265 && !ts.isExternalOrCommonJsModule(container)) { + return undefined; + } + scope = container; + } + return parent ? scope.getSourceFile() : scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + if (position > end) + break; + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + return positions; + } + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + continue; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(FindAllReferences.nodeEntry(node)); + } + } + return [{ definition: { type: "label", node: targetLabel }, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + switch (node && node.kind) { + case 71: + return node.getWidth() === searchSymbolName.length; + case 9: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + node.getWidth() === searchSymbolName.length + 2; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, ts.tokenToString(keywordKind), references); + } + return references.length ? [{ definition: { type: "keyword", node: references[0].node }, references: references }] : undefined; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd()); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push(FindAllReferences.nodeEntry(referenceLocation)); + } + } + } + function getReferencesInSourceFile(sourceFile, search, state) { + state.cancellationToken.throwIfCancellationRequested(); + return getReferencesInContainer(sourceFile, sourceFile, search, state); + } + function getReferencesInContainer(container, sourceFile, search, state) { + if (!state.markSearchedSymbol(sourceFile, search.symbol)) { + return; + } + var start = state.findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, search.text, start, container.getEnd()); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + getReferencesAtLocation(sourceFile, position, search, state); + } + } + function getReferencesAtLocation(sourceFile, position, search, state) { + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, search.text)) { + if (!state.implementations && (state.findInStrings && ts.isInString(sourceFile, position) || state.findInComments && ts.isInNonReferenceComment(sourceFile, position))) { + state.addStringOrCommentReference(sourceFile.fileName, ts.createTextSpan(position, search.text.length)); + } + return; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & state.searchMeaning)) { + return; + } + var referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation); + if (!referenceSymbol) { + return; + } + var parent = referenceLocation.parent; + if (ts.isImportSpecifier(parent) && parent.propertyName === referenceLocation) { + return; + } + if (ts.isExportSpecifier(parent)) { + ts.Debug.assert(referenceLocation.kind === 71); + getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state); + return; + } + var relatedSymbol = getRelatedSymbol(search, referenceSymbol, referenceLocation, state); + if (!relatedSymbol) { + getReferenceForShorthandProperty(referenceSymbol, search, state); + return; + } + if (state.isForConstructor) { + findConstructorReferences(referenceLocation, sourceFile, search, state); + } + else { + addReference(referenceLocation, relatedSymbol, search.location, state); + } + getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); + } + function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + var exportDeclaration = parent.parent; + var localSymbol = getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, state.checker); + if (!search.includes(localSymbol)) { + return; + } + if (!propertyName) { + addRef(); + } + else if (referenceLocation === propertyName) { + if (!exportDeclaration.moduleSpecifier) { + addRef(); + } + if (!state.isForRename && state.markSeenReExportRHS(name)) { + addReference(name, referenceSymbol, name, state); + } + } + else { + if (state.markSeenReExportRHS(referenceLocation)) { + addRef(); + } + } + if (!(referenceLocation === propertyName && state.isForRename)) { + var exportKind = referenceLocation.originalKeywordKind === 79 ? 1 : 0; + var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); + ts.Debug.assert(!!exportInfo); + searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); + } + if (search.comingFrom !== 1 && exportDeclaration.moduleSpecifier && !propertyName) { + searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state); + } + function addRef() { + addReference(referenceLocation, localSymbol, search.location, state); + } + } + function getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, checker) { + return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol; + } + function isExportSpecifierAlias(referenceLocation, exportSpecifier) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + ts.Debug.assert(propertyName === referenceLocation || name === referenceLocation); + if (propertyName) { + return propertyName === referenceLocation; + } + else { + return !parent.parent.moduleSpecifier; + } + } + function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1); + if (!importOrExport) + return; + var symbol = importOrExport.symbol; + if (importOrExport.kind === 0) { + if (!state.isForRename || importOrExport.isNamedImport) { + searchForImportedSymbol(symbol, state); + } + } + else { + searchForImportsOfExport(referenceLocation, symbol, importOrExport.exportInfo, state); + } + } + function getReferenceForShorthandProperty(_a, search, state) { + var flags = _a.flags, valueDeclaration = _a.valueDeclaration; + var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + if (!(flags & 134217728) && search.includes(shorthandValueSymbol)) { + addReference(valueDeclaration.name, shorthandValueSymbol, search.location, state); + } + } + function addReference(referenceLocation, relatedSymbol, searchLocation, state) { + var addRef = state.referenceAdder(relatedSymbol, searchLocation); + if (state.implementations) { + addImplementationReferences(referenceLocation, addRef, state); + } + else { + addRef(referenceLocation); + } + } + function findConstructorReferences(referenceLocation, sourceFile, search, state) { + if (ts.isNewExpressionTarget(referenceLocation)) { + addReference(referenceLocation, search.symbol, search.location, state); + } + var pusher = state.referenceAdder(search.symbol, search.location); + if (ts.isClassLike(referenceLocation.parent)) { + ts.Debug.assert(referenceLocation.parent.name === referenceLocation); + findOwnConstructorReferences(search.symbol, sourceFile, pusher); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending)) { + findSuperConstructorAccesses(classExtending, pusher); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 123, sourceFile); + ts.Debug.assert(decl.kind === 152 && !!ctrKeyword); + addNode(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 151) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 99, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + addNode(thisKeyword); + } + }); + } + } + }); + } + function findSuperConstructorAccesses(cls, addNode) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return; + } + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 152); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 97, function (node) { + if (ts.isCallExpressionTarget(node)) { + addNode(node); + } + }); + } + } + } + function addImplementationReferences(refNode, addReference, state) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + addReference(refNode.parent); + return; + } + if (refNode.kind !== 71) { + return; + } + if (refNode.parent.kind === 262) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + addReference(containingClass); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + addReference(parent.initializer); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 207) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + addReference(returnStatement.expression); + } + }); + } + else if (isImplementationExpression(parent.body)) { + addReference(parent.body); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + addReference(parent.expression); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 201 + && node.parent.kind === 259 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 71 || node.kind === 179) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + function isImplementationExpression(node) { + switch (node.kind) { + case 185: + return isImplementationExpression(node.expression); + case 187: + case 186: + case 178: + case 199: + case 177: + return true; + default: + return false; + } + } + function explicitlyInheritsFrom(child, parent, cachedResults, checker) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 230) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } + } + return false; + } + } + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { + return undefined; + } + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 149: + case 148: + case 151: + case 150: + case 152: + case 153: + case 154: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: + return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97) { + continue; + } + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(FindAllReferences.nodeEntry(node)); + } + } + return [{ definition: { type: "symbol", symbol: searchSpaceNode.symbol, node: superKeyword }, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 151: + case 150: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + case 149: + case 148: + case 152: + case 153: + case 154: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 265: + if (ts.isExternalModule(searchSpaceNode)) { + return undefined; + } + case 228: + case 186: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 265) { + ts.forEach(sourceFiles, function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + return [{ + definition: { type: "this", node: thisOrSuperKeyword }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || !ts.isThis(node)) { + return; + } + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 186: + case 228: + if (searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 151: + case 150: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 199: + case 229: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 265: + if (container.kind === 265 && !ts.isExternalModule(container)) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + } + }); + } + } + function getReferencesForStringLiteral(node, sourceFiles, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text, sourceFile.getStart(), sourceFile.getEnd()); + getReferencesForStringLiteralInFile(sourceFile, node.text, possiblePositions, references); + } + return [{ + definition: { type: "string", node: node }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchText, possiblePositions, references) { + for (var _i = 0, possiblePositions_5 = possiblePositions; _i < possiblePositions_5.length; _i++) { + var position = possiblePositions_5[_i]; + var node_7 = ts.getTouchingWord(sourceFile, position); + if (node_7 && node_7.kind === 9 && node_7.text === searchText) { + references.push(FindAllReferences.nodeEntry(node_7, true)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, checker, implementations) { + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement) { + if (containingObjectLiteralElement.kind !== 262) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker), function (contextualSymbol) { + ts.addRange(result, checker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 146 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, checker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), checker); + } + } + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, checker) { + if (!symbol) { + return; + } + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 230) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = checker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, checker.getRootSymbols(propertySymbol)); + } + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, checker); + } + } + } + } + function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { + if (search.includes(referenceSymbol)) { + return referenceSymbol; + } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, state.checker), function (contextualSymbol) { + return ts.find(state.checker.getRootSymbols(contextualSymbol), search.includes); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, state.checker); + if (propertySymbol && search.includes(propertySymbol)) { + return propertySymbol; + } + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); + if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (search.includes(rootSymbol)) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 144) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; + } + return undefined; + } + return node.name.text; + } + function getPropertySymbolsFromContextualType(node, checker) { + var objectLiteral = node.parent; + var contextualType = checker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_5 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + }); + } + return result_5; + } + return undefined; + } + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + function isImplementation(node) { + if (!node) { + return false; + } + else if (ts.isVariableLike(node)) { + if (node.initializer) { + return true; + } + else if (node.kind === 226) { + var parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && ts.hasModifier(parentStatement, 2); + } + } + else if (ts.isFunctionLike(node)) { + return !!node.body || ts.hasModifier(node, 2); + } + else { + switch (node.kind) { + case 229: + case 199: + case 232: + case 233: + return true; + } + } + return false; + } + function getParentStatementOfVariableDeclaration(node) { + if (node.parent && node.parent.parent && node.parent.parent.kind === 208) { + ts.Debug.assert(node.parent.kind === 227); + return node.parent.parent; + } + } + function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { + var refSymbol = checker.getSymbolAtLocation(node); + var shorthandSymbol = checker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + if (shorthandSymbol) { + for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.getMeaningFromDeclaration(declaration) & 1) { + addReference(declaration); + } + } + } + } + Core.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; + function forEachDescendantOfKind(node, kind, action) { + ts.forEachChild(node, function (child) { + if (child.kind === kind) { + action(child); + } + forEachDescendantOfKind(child, kind, action); + }); + } + function tryGetClassByExtendingIdentifier(node) { + return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9) { + return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + } + return false; + } + function getParentSymbolsOfPropertyAccess(location, symbol, checker) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(location); + if (!propertyAccessExpression) { + return undefined; + } + var localParentType = checker.getTypeAtLocation(propertyAccessExpression.expression); + if (!localParentType) { + return undefined; + } + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== symbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & 196608) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; @@ -60378,13 +63483,13 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 70 && + if (node.kind === 71 && (node.parent === declaration || - (declaration.kind === 241 && declaration.parent && declaration.parent.kind === 240))) { + (declaration.kind === 242 && declaration.parent && declaration.parent.kind === 241))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -60428,13 +63533,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_5 = []; + var result_6 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_5; + return result_6; } if (!type.symbol) { return undefined; @@ -60454,7 +63559,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (ts.isNewExpressionTarget(location) || location.kind === 122) { + if (ts.isNewExpressionTarget(location) || location.kind === 123) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -60474,11 +63579,14 @@ var ts; return false; } function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + if (!signatureDeclarations) { + return false; + } var declarations = []; var definition; for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { var d = signatureDeclarations_1[_i]; - if (selectConstructors ? d.kind === 151 : isSignatureDeclaration(d)) { + if (selectConstructors ? d.kind === 152 : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; @@ -60493,10 +63601,10 @@ var ts; } function isSignatureDeclaration(node) { switch (node.kind) { + case 152: + case 228: case 151: - case 227: case 150: - case 149: return true; default: return false; @@ -60568,34 +63676,6 @@ var ts; })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var GoToImplementation; - (function (GoToImplementation) { - function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 261) { - var result = []; - ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); - return result.length > 0 ? result : undefined; - } - else if (node.kind === 96 || ts.isSuperProperty(node.parent)) { - var symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; - } - else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, false, true); - var result = ts.flatMap(referencedSymbols, function (symbol) { - return ts.map(symbol.references, function (_a) { - var textSpan = _a.textSpan, fileName = _a.fileName; - return ({ textSpan: textSpan, fileName: fileName }); - }); - }); - return result && result.length > 0 ? result : undefined; - } - } - GoToImplementation.getImplementationAtPosition = getImplementationAtPosition; - })(GoToImplementation = ts.GoToImplementation || (ts.GoToImplementation = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var JsDoc; (function (JsDoc) { @@ -60641,7 +63721,8 @@ var ts; "prop", "version" ]; - var jsDocCompletionEntries; + var jsDocTagNameCompletionEntries; + var jsDocTagCompletionEntries; function getJsDocCommentsFromDeclarations(declarations) { var documentationComment = []; forEachUnique(declarations, function (declaration) { @@ -60662,6 +63743,29 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 284; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; function forEachUnique(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -60675,8 +63779,8 @@ var ts; } return undefined; } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + function getJSDocTagNameCompletions() { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, kind: ts.ScriptElementKind.keyword, @@ -60685,7 +63789,18 @@ var ts; }; })); } - JsDoc.getAllJsDocCompletionEntries = getAllJsDocCompletionEntries; + JsDoc.getJSDocTagNameCompletions = getJSDocTagNameCompletions; + function getJSDocTagCompletions() { + return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: "@" + tagName, + kind: ts.ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + JsDoc.getJSDocTagCompletions = getJSDocTagCompletions; function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; @@ -60698,16 +63813,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 227: - case 150: - case 151: case 228: - case 207: + case 151: + case 152: + case 229: + case 208: break findOwner; - case 264: + case 265: return undefined; - case 232: - if (commentOwner.parent.kind === 232) { + case 233: + if (commentOwner.parent.kind === 233) { return undefined; } break findOwner; @@ -60719,12 +63834,12 @@ var ts; var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 70 ? + var paramName = currentName.kind === 71 ? currentName.text : "param" + i; if (isJavaScriptFile) { @@ -60747,7 +63862,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 207) { + if (commentOwner.kind === 208) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -60757,17 +63872,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 184) { + while (rightHandSide.kind === 185) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 185: case 186: + case 187: return rightHandSide.parameters; - case 198: + case 199: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151) { + if (member.kind === 152) { return member.parameters; } } @@ -60781,8 +63896,6 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - ; - ; var safeList; var EmptySafeList = ts.createMap(); JsTyping.nodeCoreModuleList = [ @@ -60823,8 +63936,10 @@ var ts; getTypingNamesFromJson(packageJsonPath, filesToWatch); var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components"); + getTypingNamesFromPackagesFolder(bowerComponentsPath); var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); + getTypingNamesFromPackagesFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); if (unresolvedImports) { @@ -60900,16 +64015,18 @@ var ts; mergeTypings(["react"]); } } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { + function getTypingNamesFromPackagesFolder(packagesFolderPath) { + filesToWatch.push(packagesFolderPath); + if (!host.directoryExists(packagesFolderPath)) { return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + var fileNames = host.readDirectory(packagesFolderPath, [".json"], undefined, undefined, 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + var baseFileName = ts.getBaseFileName(normalizedFileName); + if (baseFileName !== "package.json" && baseFileName !== "bower.json") { continue; } var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); @@ -60917,7 +64034,7 @@ var ts; continue; } var packageJson = result.config; - if (packageJson._requiredBy && + if (baseFileName === "package.json" && packageJson._requiredBy && ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { continue; } @@ -60975,13 +64092,13 @@ var ts; } }); }; - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; _loop_4(sourceFile); } rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 238 || decl.kind === 241 || decl.kind === 236) { + if (decl.kind === 239 || decl.kind === 242 || decl.kind === 237) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -61008,7 +64125,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 || + if (node.kind === 71 || node.kind === 9 || node.kind === 8) { return node.text; @@ -61022,7 +64139,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 143) { + else if (declaration.name.kind === 144) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -61039,7 +64156,7 @@ var ts; } return true; } - if (expression.kind === 178) { + if (expression.kind === 179) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -61050,7 +64167,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 143) { + if (declaration.name.kind === 144) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -61104,21 +64221,41 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { + var whiteSpaceRegex = /\s+/g; + var curCancellationToken; + var curSourceFile; + var parentsStack = []; + var parent; + var emptyChildItemArray = []; + function getNavigationBarItems(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); - curSourceFile = undefined; - return result; + try { + return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + } + finally { + reset(); + } } NavigationBar.getNavigationBarItems = getNavigationBarItems; - function getNavigationTree(sourceFile) { + function getNavigationTree(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = convertToTree(rootNavigationBarNode(sourceFile)); - curSourceFile = undefined; - return result; + try { + return convertToTree(rootNavigationBarNode(sourceFile)); + } + finally { + reset(); + } } NavigationBar.getNavigationTree = getNavigationTree; - var curSourceFile; + function reset() { + curSourceFile = undefined; + curCancellationToken = undefined; + parentsStack = []; + parent = undefined; + emptyChildItemArray = []; + } function nodeText(node) { return node.getText(curSourceFile); } @@ -61133,8 +64270,6 @@ var ts; parent.children = [child]; } } - var parentsStack = []; - var parent; function rootNavigationBarNode(sourceFile) { ts.Debug.assert(!parentsStack.length); var root = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; @@ -61178,11 +64313,12 @@ var ts; endNode(); } function addChildrenRecursively(node) { + curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 151: + case 152: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -61192,28 +64328,28 @@ var ts; } } break; - case 150: - case 152: + case 151: case 153: - case 149: + case 154: + case 150: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 149: case 148: - case 147: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 238: + case 239: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 239) { + if (namedBindings.kind === 240) { addLeafNode(namedBindings); } else { @@ -61224,8 +64360,8 @@ var ts; } } break; - case 175: - case 225: + case 176: + case 226: var decl = node; var name = decl.name; if (ts.isBindingPattern(name)) { @@ -61238,12 +64374,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 187: + case 228: case 186: - case 227: - case 185: addNodeWithRecursiveChild(node, node.body); break; - case 231: + case 232: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -61253,9 +64389,9 @@ var ts; } endNode(); break; - case 228: - case 198: case 229: + case 199: + case 230: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -61263,21 +64399,21 @@ var ts; } endNode(); break; - case 232: + case 233: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 245: - case 236: - case 156: - case 154: + case 246: + case 237: + case 157: case 155: - case 230: + case 156: + case 231: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 289) { + if (tag.kind === 290) { addLeafNode(tag); } }); @@ -61325,12 +64461,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 232 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 233 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 232) { + if (a.body.kind !== 233) { return true; } return areSameModule(a.body, b.body); @@ -61364,7 +64500,7 @@ var ts; } } function tryGetName(node) { - if (node.kind === 232) { + if (node.kind === 233) { return getModuleName(node); } var decl = node; @@ -61372,18 +64508,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 185: case 186: - case 198: + case 187: + case 199: return getFunctionOrClassName(node); - case 289: + case 290: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 232) { + if (node.kind === 233) { return getModuleName(node); } var name = node.name; @@ -61394,29 +64530,29 @@ var ts; } } switch (node.kind) { - case 264: + case 265: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 186: - case 227: - case 185: + case 187: case 228: - case 198: + case 186: + case 229: + case 199: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 151: + case 152: return "constructor"; - case 155: - return "new()"; - case 154: - return "()"; case 156: + return "new()"; + case 155: + return "()"; + case 157: return "[]"; - case 289: + case 290: return getJSDocTypedefTagName(node); default: return ""; @@ -61428,10 +64564,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 207) { + if (parentNode && parentNode.kind === 208) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70) { + if (nameIdentifier.kind === 71) { return nameIdentifier.text; } } @@ -61456,24 +64592,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 228: - case 198: - case 231: case 229: + case 199: case 232: - case 264: case 230: - case 289: + case 233: + case 265: + case 231: + case 290: return true; - case 151: - case 150: case 152: + case 151: case 153: - case 225: + case 154: + case 226: return hasSomeImportantChild(item); + case 187: + case 228: case 186: - case 227: - case 185: return isTopLevelFunctionDeclaration(item); default: return false; @@ -61483,10 +64619,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 233: - case 264: - case 150: + case 234: + case 265: case 151: + case 152: return true; default: return hasSomeImportantChild(item); @@ -61495,12 +64631,11 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 225 && childKind !== 175; + return childKind !== 226 && childKind !== 176; }); } } } - var emptyChildItemArray = []; function convertToTree(n) { return { text: getItemName(n.node), @@ -61550,25 +64685,25 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 232) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 233) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 232 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 233 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 143; + return !member.name || member.name.kind === 144; } function getNodeSpan(node) { - return node.kind === 264 + return node.kind === 265 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 226) { node = node.parent; } return ts.getNodeModifiers(node); @@ -61577,14 +64712,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 225) { + else if (node.parent.kind === 226) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 193 && - node.parent.operatorToken.kind === 57) { + else if (node.parent.kind === 194 && + node.parent.operatorToken.kind === 58) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 260 && node.parent.name) { + else if (node.parent.kind === 261 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -61595,38 +64730,37 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 185 || node.kind === 186 || node.kind === 198; + return node.kind === 186 || node.kind === 187 || node.kind === 199; } - var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { - function collectElements(sourceFile) { + function collectElements(sourceFile, cancellationToken) { var elements = []; var collapseText = "..."; function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { if (hintSpanNode && startElement && endElement) { - var span_12 = { + var span_13 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_12); + elements.push(span_13); } } function addOutliningSpanComments(commentSpan, autoCollapse) { if (commentSpan) { - var span_13 = { + var span_14 = { textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_13); + elements.push(span_14); } } function addOutliningForLeadingCommentsForNode(n) { @@ -61638,6 +64772,7 @@ var ts; var singleLineCommentCount = 0; for (var _i = 0, comments_4 = comments; _i < comments_4.length; _i++) { var currentComment = comments_4[_i]; + cancellationToken.throwIfCancellationRequested(); if (currentComment.kind === 2) { if (isFirstSingleLineComment) { firstSingleLineCommentStart = currentComment.pos; @@ -61660,19 +64795,20 @@ var ts; function combineAndAddMultipleSingleLineComments(count, start, end) { if (count > 1) { var multipleSingleLineComments = { + kind: 2, pos: start, end: end, - kind: 2 }; addOutliningSpanComments(multipleSingleLineComments, false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 186; + return ts.isFunctionBlock(node) && node.parent.kind !== 187; } var depth = 0; var maxDepth = 20; function walk(n) { + cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } @@ -61680,64 +64816,64 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 206: + case 207: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 16, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent.kind === 211 || - parent.kind === 214 || + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); + if (parent.kind === 212 || parent.kind === 215 || + parent.kind === 216 || + parent.kind === 214 || + parent.kind === 211 || parent.kind === 213 || - parent.kind === 210 || - parent.kind === 212 || - parent.kind === 219 || - parent.kind === 259) { + parent.kind === 220 || + parent.kind === 260) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent.kind === 223) { + if (parent.kind === 224) { var tryStatement = parent; if (tryStatement.tryBlock === n) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; } } } - var span_14 = ts.createTextSpanFromNode(n); + var span_15 = ts.createTextSpanFromNode(n); elements.push({ - textSpan: span_14, - hintSpan: span_14, + textSpan: span_15, + hintSpan: span_15, bannerText: collapseText, autoCollapse: autoCollapse(n) }); break; } - case 233: { - var openBrace = ts.findChildOfKind(n, 16, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + case 234: { + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 228: case 229: - case 231: - case 177: - case 234: { - var openBrace = ts.findChildOfKind(n, 16, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + case 230: + case 232: + case 178: + case 235: { + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 176: - var openBracket = ts.findChildOfKind(n, 20, sourceFile); - var closeBracket = ts.findChildOfKind(n, 21, sourceFile); + case 177: + var openBracket = ts.findChildOfKind(n, 21, sourceFile); + var closeBracket = ts.findChildOfKind(n, 22, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -61833,9 +64969,9 @@ var ts; if (index > 0) { var wordSpans = getWordSpans(candidate); for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { - var span_15 = wordSpans_1[_i]; - if (partStartsWith(candidate, span_15, chunk.text, true)) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span_15, chunk.text, false)); + var span_16 = wordSpans_1[_i]; + if (partStartsWith(candidate, span_16, chunk.text, true)) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span_16, chunk.text, false)); } } } @@ -62175,10 +65311,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 16) { + if (token === 17) { braceNesting++; } - else if (token === 17) { + else if (token === 18) { braceNesting--; } return token; @@ -62226,9 +65362,9 @@ var ts; } function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 123) { + if (token === 124) { token = nextToken(); - if (token === 127) { + if (token === 128) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -62240,42 +65376,42 @@ var ts; } function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 90) { + if (token === 91) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } else { - if (token === 70 || ts.isKeyword(token)) { + if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } } - else if (token === 57) { + else if (token === 58) { if (tryConsumeRequireCall(true)) { return true; } } - else if (token === 25) { + else if (token === 26) { token = nextToken(); } else { return true; } } - if (token === 16) { + if (token === 17) { token = nextToken(); - while (token !== 17 && token !== 1) { + while (token !== 18 && token !== 1) { token = nextToken(); } - if (token === 17) { + if (token === 18) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62283,13 +65419,13 @@ var ts; } } } - else if (token === 38) { + else if (token === 39) { token = nextToken(); - if (token === 117) { + if (token === 118) { token = nextToken(); - if (token === 70 || ts.isKeyword(token)) { + if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62305,17 +65441,17 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 83) { + if (token === 84) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 16) { + if (token === 17) { token = nextToken(); - while (token !== 17 && token !== 1) { + while (token !== 18 && token !== 1) { token = nextToken(); } - if (token === 17) { + if (token === 18) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62323,20 +65459,20 @@ var ts; } } } - else if (token === 38) { + else if (token === 39) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); } } } - else if (token === 90) { + else if (token === 91) { token = nextToken(); - if (token === 70 || ts.isKeyword(token)) { + if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 57) { + if (token === 58) { if (tryConsumeRequireCall(true)) { return true; } @@ -62349,9 +65485,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 131) { + if (token === 132) { token = nextToken(); - if (token === 18) { + if (token === 19) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62363,27 +65499,27 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 70 && ts.scanner.getTokenValue() === "define") { + if (token === 71 && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 18) { + if (token !== 19) { return true; } token = nextToken(); if (token === 9) { token = nextToken(); - if (token === 25) { + if (token === 26) { token = nextToken(); } else { return true; } } - if (token !== 20) { + if (token !== 21) { return true; } token = nextToken(); var i = 0; - while (token !== 21 && token !== 1) { + while (token !== 22 && token !== 1) { if (token === 9) { recordModuleName(); i++; @@ -62476,20 +65612,22 @@ var ts; if (ts.some(declarations, isDefinedInLibraryFile)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + if (node.kind === 71 && + node.originalKeywordKind === 79 && + symbol.parent.flags & 1536) { + return undefined; + } var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; } } else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - var displayName = ts.stripQuotes(type.text); - return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + var displayName = ts.stripQuotes(node.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -62524,7 +65662,8 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 70 || node.kind === 9 || + return node.kind === 71 || + node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node); } @@ -62567,14 +65706,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 180) { + if (argumentInfo.invocation.kind !== 181) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 70 + var name = expression.kind === 71 ? expression - : expression.kind === 178 + : expression.kind === 179 ? expression.name : undefined; if (!name || !name.text) { @@ -62603,10 +65742,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 180 || node.parent.kind === 181) { + if (node.parent.kind === 181 || node.parent.kind === 182) { var callExpression = node.parent; - if (node.kind === 26 || - node.kind === 18) { + if (node.kind === 27 || + node.kind === 19) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -62635,24 +65774,24 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 182) { + else if (node.kind === 13 && node.parent.kind === 183) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 182) { + else if (node.kind === 14 && node.parent.parent.kind === 183) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195); + ts.Debug.assert(templateExpression.kind === 196); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 204 && node.parent.parent.parent.kind === 182) { + else if (node.parent.kind === 205 && node.parent.parent.parent.kind === 183) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195); - if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 196); + if (node.kind === 16 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -62681,7 +65820,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 25) { + if (child.kind !== 26) { argumentIndex++; } } @@ -62689,8 +65828,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 26; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 26) { argumentCount++; } return argumentCount; @@ -62706,7 +65845,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { - var argumentCount = tagExpression.template.kind === 12 + var argumentCount = tagExpression.template.kind === 13 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -62727,7 +65866,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 195) { + if (template.kind === 196) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -62736,7 +65875,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 264; n = n.parent) { + for (var n = node; n.kind !== 265; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -62789,10 +65928,10 @@ var ts; var isVariadic; if (isTypeParameterList) { isVariadic = false; - prefixDisplayParts.push(ts.punctuationPart(26)); + prefixDisplayParts.push(ts.punctuationPart(27)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(28)); + suffixDisplayParts.push(ts.punctuationPart(29)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -62804,10 +65943,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(18)); + prefixDisplayParts.push(ts.punctuationPart(19)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(19)); + suffixDisplayParts.push(ts.punctuationPart(20)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -62817,9 +65956,10 @@ var ts; isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(26), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -62866,9 +66006,9 @@ var ts; var SymbolDisplay; (function (SymbolDisplay) { function getSymbolKind(typeChecker, symbol, location) { - var flags = symbol.getFlags(); + var flags = symbol.flags; if (flags & 32) - return ts.getDeclarationOfKind(symbol, 198) ? + return ts.getDeclarationOfKind(symbol, 199) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -62878,12 +66018,12 @@ var ts; return ts.ScriptElementKind.interfaceElement; if (flags & 262144) return ts.ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); if (result === ts.ScriptElementKind.unknown) { if (flags & 262144) return ts.ScriptElementKind.typeParameterElement; if (flags & 8) - return ts.ScriptElementKind.variableElement; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608) return ts.ScriptElementKind.alias; if (flags & 1536) @@ -62892,16 +66032,17 @@ var ts; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 98 && ts.isExpression(location)) { + if (location.kind === 99 && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } + var flags = symbol.flags; if (flags & 3) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return ts.ScriptElementKind.parameterElement; @@ -62925,7 +66066,7 @@ var ts; if (flags & 16384) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { - if (flags & 134217728 && symbol.checkFlags & 2) { + if (flags & 134217728 && symbol.checkFlags & 6) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { @@ -62959,10 +66100,11 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 98 && ts.isExpression(location); + var isThisExpression = location.kind === 99 && ts.isExpression(location); var type; if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { @@ -62971,14 +66113,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 178) { + if (location.parent && location.parent.kind === 179) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpressionLike = void 0; - if (location.kind === 180 || location.kind === 181) { + if (location.kind === 181 || location.kind === 182) { callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -62993,7 +66135,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpressionLike.kind === 181 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96); + var useConstructSignatures = callExpressionLike.kind === 182 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -63008,7 +66150,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -63024,10 +66166,10 @@ var ts; case ts.ScriptElementKind.letElement: case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(55)); + displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { @@ -63042,21 +66184,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 151)) { + (location.kind === 123 && location.parent.kind === 152)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 151 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 152 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 151) { + if (functionDeclaration.kind === 152) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 155 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -63065,11 +66207,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 198)) { + if (ts.getDeclarationOfKind(symbol, 199)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(74)); + displayParts.push(ts.keywordPart(75)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -63077,45 +66219,45 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(108)); + displayParts.push(ts.keywordPart(109)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(137)); + displayParts.push(ts.keywordPart(138)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(75)); + displayParts.push(ts.keywordPart(76)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(82)); + displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 232); - var isNamespace = declaration && declaration.name && declaration.name.kind === 70; - displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); + var declaration = ts.getDeclarationOfKind(symbol, 233); + var isNamespace = declaration && declaration.name && declaration.name.kind === 71; + displayParts.push(ts.keywordPart(isNamespace ? 129 : 128)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(20)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -63124,25 +66266,25 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 144); + var declaration = ts.getDeclarationOfKind(symbol, 145); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 155) { - displayParts.push(ts.keywordPart(93)); + if (declaration.kind === 156) { + displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 154 && declaration.name) { + else if (declaration.kind !== 155 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 230) { + else if (declaration.kind === 231) { addInPrefix(); - displayParts.push(ts.keywordPart(137)); + displayParts.push(ts.keywordPart(138)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -63151,13 +66293,14 @@ var ts; } } if (symbolFlags & 8) { + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 263) { + if (declaration.kind === 264) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -63165,33 +66308,33 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 235) { - displayParts.push(ts.keywordPart(83)); + if (symbol.declarations[0].kind === 236) { + displayParts.push(ts.keywordPart(84)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(128)); + displayParts.push(ts.keywordPart(129)); } else { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(91)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 236) { + if (declaration.kind === 237) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(131)); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(20)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -63205,7 +66348,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(98)); + displayParts.push(ts.keywordPart(99)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -63215,7 +66358,7 @@ var ts; symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(55)); + displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -63244,11 +66387,12 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 265; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 193) { + if (!declaration.parent || declaration.parent.kind !== 194) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -63256,6 +66400,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -63263,7 +66408,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -63271,7 +66416,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbol, enclosingDeclaration) { @@ -63296,9 +66441,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(20)); return; } } @@ -63306,14 +66451,15 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.operatorPart(36)); + displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.operatorPart(37)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.punctuationPart(20)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -63328,14 +66474,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 185) { + if (declaration.kind === 186) { return true; } - if (declaration.kind !== 225 && declaration.kind !== 227) { + if (declaration.kind !== 226 && declaration.kind !== 228) { return false; } for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { - if (parent.kind === 264 || parent.kind === 233) { + if (parent.kind === 265 || parent.kind === 234) { return false; } } @@ -63439,6 +66585,7 @@ var ts; } return options; } + ts.fixupCompilerOptions = fixupCompilerOptions; })(ts || (ts = {})); var ts; (function (ts) { @@ -63456,10 +66603,10 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(sourceFile, startPos, endPos) { + function getFormattingScanner(text, languageVariant, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner = languageVariant === 1 ? jsxScanner : standardScanner; + scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; var leadingTrivia; @@ -63522,11 +66669,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 30: - case 65: + case 31: case 66: + case 67: + case 47: case 46: - case 45: return true; } } @@ -63535,11 +66682,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 253: + case 251: case 252: case 250: - case 251: - case 249: - return node.kind === 70; + return node.kind === 71; } } return false; @@ -63548,14 +66695,14 @@ var ts; return node && node.kind === 10; } function shouldRescanSlashToken(container) { - return container.kind === 11; + return container.kind === 12; } function shouldRescanTemplateToken(container) { - return container.kind === 14 || - container.kind === 15; + return container.kind === 15 || + container.kind === 16; } function startsWithSlashToken(t) { - return t === 40 || t === 62; + return t === 41 || t === 63; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -63586,7 +66733,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 28) { + if (expectedScanAction === 1 && currentToken === 29) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -63596,11 +66743,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 17) { + else if (expectedScanAction === 3 && currentToken === 18) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 70) { + else if (expectedScanAction === 4 && currentToken === 71) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -63647,8 +66794,8 @@ var ts; } function isOnToken() { ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); } function fixTokenKind(tokenInfo, container) { @@ -63734,8 +66881,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 16, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 17, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 17, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 18, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -63902,91 +67049,91 @@ 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, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 141, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, 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, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.FromRange(0, 142, [20])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(18, 82), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(18, 106), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.FromTokens([22, 26, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(23, 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, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(22, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70, 3, 74, 83, 90]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([71, 3, 75, 84, 91]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([20, 3, 81, 102, 87, 82]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(17, 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, 18), 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, 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, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103, 99, 93, 79, 95, 102, 120]), 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([109, 75]), 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, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 134]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(44, 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, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 44), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(44, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(38, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(38, 44), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104, 100, 94, 80, 96, 103, 121]), 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([110, 76]), 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(89, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(105, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(96, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([20, 81, 82, 73]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([102, 87]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 135]), 71), 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.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 134, 114, 137, 139, 126]), 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([84, 107, 139])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.FromTokens([19, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, 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, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.FromTokens([18, 20, 28, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, 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([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 134, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 38]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119, 88), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70, formatting.Shared.TokenRange.FromTokens([12, 13])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([128, 132]), 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([117, 75, 124, 79, 83, 84, 85, 125, 108, 91, 109, 128, 129, 112, 114, 113, 131, 135, 115, 138, 140, 127]), 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([85, 108, 140])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(36, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(24, 71), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.FromTokens([20, 26])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(20, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, 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, 29), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(29, formatting.Shared.TokenRange.FromTokens([19, 21, 29, 26])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(57, 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([117, 71, 84, 79, 75, 115, 114, 112, 113, 125, 135, 21, 39])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(89, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(39, formatting.Shared.TokenRange.FromTokens([71, 19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(116, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 39]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(120, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(120, 89), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(71, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 71), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(41, 29), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 58), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(58, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -64041,41 +67188,41 @@ var ts; this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 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, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, 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, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, 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, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), 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([13, 14]), 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([14, 15])), 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([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, 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, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, 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, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, 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, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(21, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, 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, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([14, 15]), 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([14, 15]), 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([15, 16])), 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([15, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -64087,36 +67234,36 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 213; + return context.contextNode.kind === 214; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 193: case 194: - case 201: - case 245: - case 241: - case 157: - case 165: + case 195: + case 202: + case 246: + case 242: + case 158: case 166: + case 167: return true; - case 175: - case 230: - case 236: - case 225: - case 145: - case 263: + case 176: + case 231: + case 237: + case 226: + case 146: + case 264: + case 149: case 148: - case 147: - return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 214: - case 144: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + return context.currentTokenSpan.kind === 58 || context.nextTokenSpan.kind === 58; case 215: - return context.currentTokenSpan.kind === 141 || context.nextTokenSpan.kind === 141; + case 145: + return context.currentTokenSpan.kind === 92 || context.nextTokenSpan.kind === 92; + case 216: + return context.currentTokenSpan.kind === 142 || context.nextTokenSpan.kind === 142; } return false; }; @@ -64124,13 +67271,13 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 194; + return context.contextNode.kind === 195; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 173 || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 174 || Rules.IsSingleLineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -64152,65 +67299,65 @@ var ts; return true; } switch (node.kind) { - case 206: + case 207: + case 235: + case 178: case 234: - case 177: - case 233: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 227: + case 228: + case 151: case 150: - case 149: - case 152: case 153: case 154: - case 185: - case 151: + case 155: case 186: - case 229: + case 152: + case 187: + case 230: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 227 || context.contextNode.kind === 185; + return context.contextNode.kind === 228 || context.contextNode.kind === 186; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 228: - case 198: case 229: - case 231: - case 162: + case 199: + case 230: case 232: - case 243: + case 163: + case 233: case 244: - case 237: - case 240: + case 245: + case 238: + case 241: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 228: - case 232: - case 231: - case 259: + case 229: case 233: - case 220: + case 232: + case 260: + case 234: + case 221: return true; - case 206: { + case 207: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 186 && - blockParent.kind !== 185) { + if (blockParent.kind !== 187 && + blockParent.kind !== 186) { return true; } } @@ -64219,59 +67366,59 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 210: - case 220: - case 213: + case 211: + case 221: case 214: case 215: + case 216: + case 213: + case 224: case 212: - case 223: - case 211: - case 219: - case 259: + case 220: + case 260: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 177; + return context.contextNode.kind === 178; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 182; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 25; + return context.currentTokenSpan.kind !== 26; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 21; + return context.nextTokenSpan.kind !== 22; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 186; + return context.contextNode.kind === 187; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 248; + return context.contextNode.kind !== 249; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 255; + return context.contextNode.kind === 256; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 252; + return context.nextTokenParent.kind === 253; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 253; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 249; + return context.contextNode.kind === 250; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -64286,42 +67433,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 146; + return node.kind === 147; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 226 && + return context.currentTokenParent.kind === 227 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 232; + return context.contextNode.kind === 233; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 162; + return context.contextNode.kind === 163; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 26 && token.kind !== 28) { + if (token.kind !== 27 && token.kind !== 29) { return false; } switch (parent.kind) { - case 158: - case 183: + case 159: + case 184: + case 231: + case 229: + case 199: case 230: case 228: - case 198: - case 229: - case 227: - case 185: case 186: + case 187: + case 151: case 150: - case 149: - case 154: case 155: - case 180: + case 156: case 181: - case 200: + case 182: + case 201: return true; default: return false; @@ -64332,16 +67479,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 183; + return context.contextNode.kind === 184; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 189; + return context.currentTokenSpan.kind === 105 && context.currentTokenParent.kind === 190; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 196 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 197 && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 202; + return context.contextNode.kind === 203; }; return Rules; }()); @@ -64363,7 +67510,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 141 + 1; + this.mapRowLength = 142 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -64376,7 +67523,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 141 && column <= 141, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 142 && column <= 142, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -64540,7 +67687,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 141; token++) { + for (var token = 0; token <= 142; token++) { result.push(token); } return result; @@ -64584,17 +67731,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 141); - TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 141, 117, 125]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.Keywords = TokenRange.FromRange(72, 142); + TokenRange.BinaryOperators = TokenRange.FromRange(27, 70); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([92, 93, 142, 118, 126]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([43, 44, 52, 51]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 71, 19, 21, 17, 99, 94]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([71, 19, 99, 94]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([71, 20, 22, 94]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([71, 19, 99, 94]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([71, 20, 22, 94]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 135, 121, 136, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([71, 133, 136, 122, 137, 105, 119]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -64616,6 +67763,9 @@ var ts; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; + RulesProvider.prototype.getFormatOptions = function () { + return this.options; + }; RulesProvider.prototype.ensureUpToDate = function (options) { if (!this.options || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); @@ -64766,11 +67916,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 24, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 25, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 17, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 18, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -64818,17 +67968,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 228: case 229: + case 230: return ts.rangeContainsRange(parent.members, node); - case 232: - var body = parent.body; - return body && body.kind === 233 && ts.rangeContainsRange(body.statements, node); - case 264: - case 206: case 233: + var body = parent.body; + return body && body.kind === 234 && ts.rangeContainsRange(body.statements, node); + case 265: + case 207: + case 234: return ts.rangeContainsRange(parent.statements, node); - case 259: + case 260: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -64907,12 +68057,17 @@ var ts; } return 0; } + function formatNode(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { + var range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1, function (_) { return false; }, sourceFileLike); + } + formatting.formatNode = formatNode; function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + } + function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var previousRangeHasError; var previousRange; var previousParent; @@ -64927,7 +68082,6 @@ var ts; if (enclosingNode.decorators) { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { @@ -64984,18 +68138,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 228: return 74; - case 229: return 108; - case 227: return 88; - case 231: return 231; - case 152: return 124; - case 153: return 134; - case 150: + case 229: return 75; + case 230: return 109; + case 228: return 89; + case 232: return 232; + case 153: return 125; + case 154: return 135; + case 151: if (node.asteriskToken) { - return 38; + return 39; } - case 148: - case 145: + case 149: + case 146: return node.name.kind; } } @@ -65003,9 +68157,9 @@ var ts; return { getIndentationForComment: function (kind, tokenIndentation, container) { switch (kind) { - case 17: - case 21: - case 19: + case 18: + case 22: + case 20: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 ? tokenIndentation : indentation; @@ -65017,26 +68171,26 @@ var ts; } } switch (kind) { - case 16: case 17: case 18: case 19: - case 81: - case 105: - case 56: + case 20: + case 82: + case 106: + case 57: return indentation; - case 40: - case 28: { - if (container.kind === 250 || - container.kind === 251 || - container.kind === 249) { + case 41: + case 29: { + if (container.kind === 251 || + container.kind === 252 || + container.kind === 250) { return indentation; } break; } - case 20: - case 21: { - if (container.kind !== 171) { + case 21: + case 22: { + if (container.kind !== 172) { return indentation; } break; @@ -65124,11 +68278,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 146 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 147 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 176 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 177 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -65444,41 +68598,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 151: - case 227: - case 185: - case 150: - case 149: + case 152: + case 228: case 186: + case 151: + case 150: + case 187: if (node.typeParameters === list) { - return 26; + return 27; } else if (node.parameters === list) { - return 18; + return 19; } break; - case 180: case 181: + case 182: if (node.typeArguments === list) { - return 26; + return 27; } else if (node.arguments === list) { - return 18; + return 19; } break; - case 158: + case 159: if (node.typeArguments === list) { - return 26; + return 27; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 18: - return 19; - case 26: - return 28; + case 19: + return 20; + case 27: + return 29; } return 0; } @@ -65543,7 +68697,8 @@ var ts; (function (Value) { Value[Value["Unknown"] = -1] = "Unknown"; })(Value || (Value = {})); - function getIndentation(position, sourceFile, options) { + function getIndentation(position, sourceFile, options, assumeNewLineBeforeCloseBrace) { + if (assumeNewLineBeforeCloseBrace === void 0) { assumeNewLineBeforeCloseBrace = false; } if (position > sourceFile.text.length) { return getBaseIndentation(options); } @@ -65563,7 +68718,7 @@ var ts; var current_1 = position; while (current_1 > 0) { var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char)) { + if (!ts.isWhiteSpaceLike(char)) { break; } current_1--; @@ -65571,7 +68726,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 193) { + if (precedingToken.kind === 26 && precedingToken.parent.kind !== 194) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -65584,8 +68739,9 @@ var ts; while (current) { if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== 0) { + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === 2 ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; @@ -65673,32 +68829,38 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 264 || !parentAndChildShareLine); + (parent.kind === 265 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } + var NextTokenKind; + (function (NextTokenKind) { + NextTokenKind[NextTokenKind["Unknown"] = 0] = "Unknown"; + NextTokenKind[NextTokenKind["OpenBrace"] = 1] = "OpenBrace"; + NextTokenKind[NextTokenKind["CloseBrace"] = 2] = "CloseBrace"; + })(NextTokenKind || (NextTokenKind = {})); function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current); if (!nextToken) { - return false; + return 0; } - if (nextToken.kind === 16) { - return true; + if (nextToken.kind === 17) { + return 1; } - else if (nextToken.kind === 17) { + else if (nextToken.kind === 18) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? 2 : 0; } - return false; + return 0; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 210 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); + if (parent.kind === 211 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 82, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -65706,53 +68868,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getListIfStartEndIsInListRange(list, start, end) { + return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; + } function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 158: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 177: + case 159: + return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd()); + case 178: return node.parent.properties; - case 176: + case 177: return node.parent.elements; - case 227: - case 185: + case 228: case 186: + case 187: + case 151: case 150: - case 149: - case 154: - case 155: { + case 155: + case 152: + case 161: + case 156: { var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.parameters, start, node.getEnd()); } - case 181: - case 180: { + case 229: + return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), node.getEnd()); + case 182: + case 181: { var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.arguments, start, node.getEnd()); } + case 227: + return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), node.getEnd()); + case 241: + case 245: + return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; } + SmartIndenter.getContainingList = getContainingList; function getActualIndentationForListItem(node, sourceFile, options) { var containingList = getContainingList(node, sourceFile); return containingList ? getActualIndentationFromList(containingList) : -1; @@ -65762,11 +68920,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 19) { + if (node.kind === 20) { return -1; } - if (node.parent && (node.parent.kind === 180 || - node.parent.kind === 181) && + if (node.parent && (node.parent.kind === 181 || + node.parent.kind === 182) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -65784,10 +68942,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 180: case 181: - case 178: + case 182: case 179: + case 180: node = node.expression; break; default: @@ -65801,7 +68959,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 25) { + if (list[i].kind === 26) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -65841,49 +68999,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 209: - case 228: - case 198: + case 210: case 229: - case 231: + case 199: case 230: - case 176: - case 206: - case 233: + case 232: + case 231: case 177: - case 162: - case 171: - case 164: - case 234: - case 257: - case 256: - case 184: - case 178: - case 180: - case 181: case 207: - case 225: - case 242: - case 218: - case 194: - case 174: - case 173: - case 250: - case 249: - case 255: - case 149: - case 154: - case 155: - case 145: - case 159: - case 160: - case 167: + case 234: + case 178: + case 163: + case 172: + case 165: + case 235: + case 258: + case 257: + case 185: + case 179: + case 181: case 182: - case 190: - case 244: - case 240: + case 208: + case 226: + case 243: + case 219: + case 195: + case 175: + case 174: + case 251: + case 250: + case 256: + case 150: + case 155: + case 156: + case 146: + case 160: + case 161: + case 168: + case 183: + case 191: case 245: case 241: + case 246: + case 242: return true; } return false; @@ -65891,27 +69049,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 211: case 212: - case 214: - case 215: case 213: - case 210: - case 227: - case 185: - case 150: + case 215: + case 216: + case 214: + case 211: + case 228: case 186: case 151: + case 187: case 152: case 153: - return childKind !== 206; - case 243: - return childKind !== 244; - case 237: - return childKind !== 238 || - (child.namedBindings && child.namedBindings.kind !== 240); - case 248: - return childKind !== 251; + case 154: + return childKind !== 207; + case 244: + return childKind !== 245; + case 238: + return childKind !== 239 || + (child.namedBindings && child.namedBindings.kind !== 241); + case 249: + return childKind !== 252; } return indentByDefault; } @@ -65924,6 +69082,499 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var textChanges; + (function (textChanges) { + function getPos(n) { + return n["__pos"]; + } + function setPos(n, pos) { + n["__pos"] = pos; + } + function getEnd(n) { + return n["__end"]; + } + function setEnd(n, end) { + n["__end"] = end; + } + var Position; + (function (Position) { + Position[Position["FullStart"] = 0] = "FullStart"; + Position[Position["Start"] = 1] = "Start"; + })(Position = textChanges.Position || (textChanges.Position = {})); + function skipWhitespacesAndLineBreaks(text, start) { + return ts.skipTrivia(text, start, false, true); + } + function hasCommentsBeforeLineBreak(text, start) { + var i = start; + while (i < text.length) { + var ch = text.charCodeAt(i); + if (ts.isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === 47; + } + return false; + } + function getSeparatorCharacter(separator) { + return ts.tokenToString(separator.kind); + } + textChanges.getSeparatorCharacter = getSeparatorCharacter; + function getAdjustedStartPosition(sourceFile, node, options, position) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + var fullStart = node.getFullStart(); + var start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + var fullStartLine = ts.getLineStartPositionForPosition(fullStart, sourceFile); + var startLine = ts.getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + return position === Position.Start ? start : fullStart; + } + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); + return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + textChanges.getAdjustedStartPosition = getAdjustedStartPosition; + function getAdjustedEndPosition(sourceFile, node, options) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + var end = node.getEnd(); + var newEnd = ts.skipTrivia(sourceFile.text, end, true); + return newEnd !== end && ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + textChanges.getAdjustedEndPosition = getAdjustedEndPosition; + function isSeparator(node, candidate) { + return candidate && node.parent && (candidate.kind === 26 || (candidate.kind === 25 && node.parent.kind === 178)); + } + function spaces(count) { + var s = ""; + for (var i = 0; i < count; i++) { + s += " "; + } + return s; + } + var ChangeTracker = (function () { + function ChangeTracker(newLine, rulesProvider, validator) { + this.newLine = newLine; + this.rulesProvider = rulesProvider; + this.validator = validator; + this.changes = []; + this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); + } + ChangeTracker.fromCodeFixContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 : 0, context.rulesProvider); + }; + ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ sourceFile: sourceFile, range: range }); + return this; + }; + ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { + var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + var nextToken = ts.getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), false, true); + var nextElement = containingList[index + 1]; + var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), false, true); + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + }; + ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + return this; + }; + ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + return this; + }; + ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { + if (options === void 0) { options = {}; } + if ((ts.isStatementButNotDeclaration(after)) || + after.kind === 149 || + after.kind === 148 || + after.kind === 150) { + if (sourceFile.text.charCodeAt(after.end - 1) !== 59) { + this.changes.push({ + sourceFile: sourceFile, + options: {}, + range: { pos: after.end, end: after.end }, + node: ts.createToken(25) + }); + } + } + var endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeInListAfter = function (sourceFile, after, newNode) { + var containingList = ts.formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(after); + if (index < 0) { + return this; + } + var end = after.getEnd(); + if (index !== containingList.length - 1) { + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); + var prefix = void 0; + var startPos = void 0; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix: prefix, + suffix: "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)) + } + }); + } + } + else { + var afterStart = after.getStart(sourceFile); + var afterStartLinePosition = ts.getLineStartPositionForPosition(afterStart, sourceFile); + var separator = void 0; + var multilineList = false; + if (containingList.length === 1) { + separator = 26; + } + else { + var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 26; + var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + multilineList = true; + } + if (multilineList) { + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: ts.createToken(separator), + options: {} + }); + var indentation = ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + var insertPos = ts.skipTrivia(sourceFile.text, end, true, false); + if (insertPos !== end && ts.isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos--; + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation: indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: newNode, + options: { prefix: ts.tokenToString(separator) + " " } + }); + } + } + return this; + }; + ChangeTracker.prototype.getChanges = function () { + var _this = this; + var changesPerFile = ts.createFileMap(); + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var c = _a[_i]; + var changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + } + changesInFile.push(c); + } + var fileChangesList = []; + changesPerFile.forEachValue(function (path) { + var changesInFile = changesPerFile.get(path); + var sourceFile = changesInFile[0].sourceFile; + var fileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (var _i = 0, _a = ChangeTracker.normalize(changesInFile); _i < _a.length; _i++) { + var c = _a[_i]; + fileTextChanges.textChanges.push({ + span: _this.computeSpan(c, sourceFile), + newText: _this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + return fileChangesList; + }; + ChangeTracker.prototype.computeSpan = function (change, _sourceFile) { + return ts.createTextSpanFromBounds(change.range.pos, change.range.end); + }; + ChangeTracker.prototype.computeNewText = function (change, sourceFile) { + if (!change.node) { + return ""; + } + var options = change.options || {}; + var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var pos = change.range.pos; + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = change.options.indentation !== undefined + ? change.options.indentation + : change.useIndentationFromFile + ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) + : 0; + var delta = change.options.delta !== undefined + ? change.options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); + }; + ChangeTracker.normalize = function (changes) { + var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); + for (var i = 0; i < normalized.length - 2; i++) { + ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); + } + return normalized; + }; + return ChangeTracker; + }()); + textChanges.ChangeTracker = ChangeTracker; + function getNonformattedText(node, sourceFile, newLine) { + var options = { newLine: newLine, target: sourceFile.languageVersion }; + var writer = new Writer(ts.getNewLineCharacter(options)); + var printer = ts.createPrinter(options, writer); + printer.writeNode(3, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + textChanges.getNonformattedText = getNonformattedText; + function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { + var lineMap = ts.computeLineStarts(nonFormattedText.text); + var file = { + text: nonFormattedText.text, + lineMap: lineMap, + getLineAndCharacterOfPosition: function (pos) { return ts.computeLineAndCharacterOfPosition(lineMap, pos); } + }; + var changes = ts.formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + textChanges.applyFormatting = applyFormatting; + function applyChanges(text, changes) { + for (var i = changes.length - 1; i >= 0; i--) { + var change = changes[i]; + text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + } + return text; + } + textChanges.applyChanges = applyChanges; + function isTrivia(s) { + return ts.skipTrivia(s, 0) === s.length; + } + var nullTransformationContext = { + enableEmitNotification: ts.noop, + enableSubstitution: ts.noop, + endLexicalEnvironment: function () { return undefined; }, + getCompilerOptions: ts.notImplemented, + getEmitHost: ts.notImplemented, + getEmitResolver: ts.notImplemented, + hoistFunctionDeclaration: ts.noop, + hoistVariableDeclaration: ts.noop, + isEmitNotificationEnabled: ts.notImplemented, + isSubstitutionEnabled: ts.notImplemented, + onEmitNode: ts.noop, + onSubstituteNode: ts.notImplemented, + readEmitHelpers: ts.notImplemented, + requestEmitHelper: ts.noop, + resumeLexicalEnvironment: ts.noop, + startLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop + }; + function assignPositionsToNode(node) { + var visited = ts.visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + var newNode = ts.nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new Proxy()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + function Proxy() { } + } + function assignPositionsToNodeArray(nodes, visitor, test, start, count) { + var visited = ts.visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + var nodeArray = visited === nodes ? ts.createNodeArray(visited.slice(0)) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + var Writer = (function () { + function Writer(newLine) { + var _this = this; + this.lastNonTriviaPosition = 0; + this.writer = ts.createTextWriter(newLine); + this.onEmitNode = function (hint, node, printCallback) { + if (node) { + setPos(node, _this.lastNonTriviaPosition); + } + printCallback(hint, node); + if (node) { + setEnd(node, _this.lastNonTriviaPosition); + } + }; + this.onBeforeEmitNodeArray = function (nodes) { + if (nodes) { + setPos(nodes, _this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = function (nodes) { + if (nodes) { + setEnd(nodes, _this.lastNonTriviaPosition); + } + }; + } + Writer.prototype.setLastNonTriviaPosition = function (s, force) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + var i = 0; + while (ts.isWhiteSpaceLike(s.charCodeAt(s.length - i - 1))) { + i++; + } + this.lastNonTriviaPosition -= i; + } + }; + Writer.prototype.write = function (s) { + this.writer.write(s); + this.setLastNonTriviaPosition(s, false); + }; + Writer.prototype.writeTextOfNode = function (text, node) { + this.writer.writeTextOfNode(text, node); + }; + Writer.prototype.writeLine = function () { + this.writer.writeLine(); + }; + Writer.prototype.increaseIndent = function () { + this.writer.increaseIndent(); + }; + Writer.prototype.decreaseIndent = function () { + this.writer.decreaseIndent(); + }; + Writer.prototype.getText = function () { + return this.writer.getText(); + }; + Writer.prototype.rawWrite = function (s) { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, false); + }; + Writer.prototype.writeLiteral = function (s) { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, true); + }; + Writer.prototype.getTextPos = function () { + return this.writer.getTextPos(); + }; + Writer.prototype.getLine = function () { + return this.writer.getLine(); + }; + Writer.prototype.getColumn = function () { + return this.writer.getColumn(); + }; + Writer.prototype.getIndent = function () { + return this.writer.getIndent(); + }; + Writer.prototype.isAtStartOfLine = function () { + return this.writer.isAtStartOfLine(); + }; + Writer.prototype.reset = function () { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + }; + return Writer; + }()); + })(textChanges = ts.textChanges || (ts.textChanges = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -65970,53 +69621,46 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); - var classDecl = ts.getContainingClass(token); - if (!classDecl) { + var classDeclaration = ts.getContainingClass(token); + if (!classDeclaration) { return undefined; } - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var classType = checker.getTypeAtLocation(classDeclaration); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDeclaration); var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); var result = []; for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { var implementedTypeNode = implementedTypeNodes_2[_i]; - var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); - var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); - insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); - insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var newNodes = []; + createAndAddMissingIndexSignatureDeclaration(implementedType, 1, hasNumericIndexSignature, newNodes); + createAndAddMissingIndexSignatureDeclaration(implementedType, 0, hasStringIndexSignature, newNodes); + newNodes = newNodes.concat(codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker)); var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); - if (insertion) { - pushAction(result, insertion, message); + if (newNodes.length > 0) { + pushAction(result, newNodes, message); } } return result; - function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { - if (!hasIndexSigOfKind) { - var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); - if (IndexInfoOfKind) { - var writer = ts.getSingleLineStringWriter(); - checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_6 = writer.string(); - ts.releaseStringWriter(writer); - return result_6; - } + function createAndAddMissingIndexSignatureDeclaration(type, kind, hasIndexSigOfKind, newNodes) { + if (hasIndexSigOfKind) { + return; } - return ""; + var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (!indexInfoOfKind) { + return; + } + var newIndexSignatureDeclaration = checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration); + newNodes.push(newIndexSignatureDeclaration); } - function pushAction(result, insertion, description) { + function pushAction(result, newNodes, description) { var newAction = { description: description, - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: codefix.newNodesToChanges(newNodes, openBrace, context) }; result.push(newAction); } @@ -66024,6 +69668,102 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Property_0_does_not_exist_on_type_1.code], + getCodeActions: getActionsForAddMissingMember + }); + function getActionsForAddMissingMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind !== 71) { + return undefined; + } + if (!ts.isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== 99) { + return undefined; + } + var classMemberDeclaration = ts.getThisContainer(token, false); + if (!ts.isClassElement(classMemberDeclaration)) { + return undefined; + } + var classDeclaration = classMemberDeclaration.parent; + if (!classDeclaration || !ts.isClassLike(classDeclaration)) { + return undefined; + } + var isStatic = ts.hasModifier(classMemberDeclaration, 32); + return ts.isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + function getActionsForAddMissingMemberInJavaScriptFile() { + var memberName = token.getText(); + if (isStatic) { + if (classDeclaration.kind === 199) { + return undefined; + } + var className = classDeclaration.name.getText(); + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classDeclaration.getEnd(), length: 0 }, + newText: "" + context.newLineCharacter + className + "." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + else { + var classConstructor = ts.getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classConstructor.body.getEnd() - 1, length: 0 }, + newText: "this." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + } + function getActionsForAddMissingMemberInTypeScriptFile() { + var typeNode; + if (token.parent.parent.kind === 194) { + var binaryExpression = token.parent.parent; + var checker = context.program.getTypeChecker(); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + } + typeNode = typeNode || ts.createKeywordTypeNode(119); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var property = ts.createProperty(undefined, isStatic ? [ts.createToken(115)] : undefined, token.getText(sourceFile), undefined, typeNode, undefined); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); + var actions = [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: propertyChangeTracker.getChanges() + }]; + if (!isStatic) { + var stringTypeNode = ts.createKeywordTypeNode(136); + var indexingParameter = ts.createParameter(undefined, undefined, undefined, "x", undefined, stringTypeNode, undefined); + var indexSignature = ts.createIndexSignatureDeclaration(undefined, undefined, [indexingParameter], typeNode); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); + actions.push({ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: indexSignatureChangeTracker.getChanges() + }); + } + return actions; + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -66041,23 +69781,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); if (ts.isClassLike(token.parent)) { - var classDecl = token.parent; - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var classDeclaration = token.parent; + var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); - var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); - if (insertion.length) { + var newNodes = codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); + var changes = codefix.newNodesToChanges(newNodes, ts.getOpenBraceOfClassLike(classDeclaration, sourceFile), context); + if (changes && changes.length > 0) { return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: changes }]; } } @@ -66080,7 +69814,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 98) { + if (token.kind !== 99) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -66088,7 +69822,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 180) { + if (superCall.expression && superCall.expression.kind === 181) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -66096,23 +69830,15 @@ var ts; } } } - var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); - var changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes: changes + changes: changeTracker.getChanges() }]; function findSuperCall(n) { - if (n.kind === 209 && ts.isSuperCall(n.expression)) { + if (n.kind === 210 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -66133,13 +69859,15 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { + if (token.kind !== 123) { return undefined; } - var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var superCall = ts.createStatement(ts.createCall(ts.createSuper(), undefined, ts.emptyArray)); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -66156,7 +69884,7 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var classDeclNode = ts.getContainingClass(token); - if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + if (!(token.kind === 71 && ts.isClassLike(classDeclNode))) { return undefined; } var heritageClauses = classDeclNode.heritageClauses; @@ -66164,26 +69892,20 @@ var ts; return undefined; } var extendsToken = heritageClauses[0].getFirstToken(); - if (!(extendsToken && extendsToken.kind === 84)) { + if (!(extendsToken && extendsToken.kind === 85)) { return undefined; } - var changeStart = extendsToken.getStart(sourceFile); - var changeEnd = extendsToken.getEnd(); - var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108)); for (var i = 1; i < heritageClauses.length; i++) { var keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, ts.createToken(26)); } } var result = [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; } @@ -66199,10 +69921,14 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - var start = token.getStart(sourceFile); + if (token.kind !== 71) { + return undefined; + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -66221,156 +69947,147 @@ var ts; var sourceFile = context.sourceFile; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { + if (token.kind === 21) { token = ts.getTokenAtPosition(sourceFile, start + 1); } switch (token.kind) { - case 70: + case 71: switch (token.parent.kind) { - case 225: + case 226: switch (token.parent.parent.parent.kind) { - case 213: + case 214: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } - case 215: + case 216: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 226) { + if (forOfStatement.initializer.kind === 227) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], ts.createObjectLiteral()); } break; - case 214: + case 215: return undefined; - case 259: + case 260: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } - case 144: + case 145: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== 27) { + return deleteRange(typeParameters); + } + var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== 29) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } - case 145: + case 146: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } - case 236: - var importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); - case 241: + case 237: + var importEquals = ts.getAncestor(token, 237); + return deleteNode(importEquals); + case 242: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + var importSpec = ts.getAncestor(token, 238); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); - } - case 238: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); - } - else { - var start_4 = importClause.name.getStart(); - var end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === 44) { - end = findFirstNonSpaceCharPosStarting(end + 1); - } - return createCodeFix("", start_4, end - start_4); + return deleteNodeInList(token.parent); } case 239: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = ts.getAncestor(importClause, 238); + return deleteNode(importDecl); } else { - var start_5 = namespaceImport.parent.name.end; - return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + var start_4 = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26) { + return deleteRange({ pos: start_4, end: ts.skipTrivia(sourceFile.text, nextToken.end, false, true) }); + } + else { + return deleteNode(importClause.name); + } + } + case 240: + var namespaceImport = token.parent; + if (namespaceImport.name === token && !namespaceImport.parent.name) { + var importDecl = ts.getAncestor(namespaceImport, 238); + return deleteNode(importDecl); + } + else { + var previousToken = ts.getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === 26) { + var startPosition = ts.textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, ts.textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; - case 148: - case 239: - return createCodeFixToRemoveNode(token.parent); + case 149: + case 240: + return deleteNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 237 && importDecl.parent) { - importDecl = importDecl.parent; - } - return importDecl; + function deleteNode(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node) { - var end = node.getEnd(); - var endCharCode = sourceFile.text.charCodeAt(end); - var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (ts.isLineBreak(endCharCode)) { - end += 1; - } - if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - var start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start) { - while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText, start, length) { + function deleteNodeRange(start, end) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + function replaceNode(n, newNode) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + function makeChange(changeTracker) { return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] + changes: changeTracker.getChanges() }]; } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); })(codefix = ts.codefix || (ts.codefix = {})); @@ -66476,21 +70193,21 @@ var ts; var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); var cachedImportDeclarations = []; - var cachedNewImportInsertPosition; + var lastImportDeclaration; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); return getCodeActionForImport(symbol, false, true); } - var allPotentialModules = checker.getAmbientModules(); + var candidateModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; if (otherSourceFile !== sourceFile && ts.isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { - var moduleSymbol = allPotentialModules_1[_a]; + for (var _a = 0, candidateModules_1 = candidateModules; _a < candidateModules_1.length; _a++) { + var moduleSymbol = candidateModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); var defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); if (defaultExport) { @@ -66526,10 +70243,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 237) { + if (node.kind === 238) { return node; } - if (node.kind === 236) { + if (node.kind === 237) { return node; } node = node.parent; @@ -66562,9 +70279,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { var declaration = declarations_14[_i]; - if (declaration.kind === 237) { + if (declaration.kind === 238) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 239) { + if (namedBindings && namedBindings.kind === 240) { namespaceImportDeclaration = declaration; } else { @@ -66582,81 +70299,67 @@ var ts; } if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { - var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + var fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); - actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], textChange.newText, textChange.span, sourceFile.fileName, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); + actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); } else { actions.push(getCodeActionForNewImport(existingModuleSpecifier)); } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 247) { + if (declaration.moduleReference && declaration.moduleReference.kind === 248) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); } function getTextChangeForImportClause(importClause) { - var newImportText = isDefault ? "default as " + name : name; var importList = importClause.namedBindings; - if (!importList && importClause.name) { - var start = importClause.name.getEnd(); - return { - newText: ", { " + newImportText + " }", - span: { start: start, length: 0 } - }; + var newImportSpecifier = ts.createImportSpecifier(undefined, ts.createIdentifier(name)); + if (!importList || importList.elements.length === 0) { + var newImportClause = ts.createImportClause(importClause.name, ts.createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - if (importList.elements.length === 0) { - var start = importList.getStart(); - return { - newText: "{ " + newImportText + " }", - span: { start: start, length: importList.getEnd() - start } - }; - } - var insertPoint = importList.elements[importList.elements.length - 1].getEnd(); - var startLine = ts.getLineOfLocalPosition(sourceFile, importList.getStart()); - var endLine = ts.getLineOfLocalPosition(sourceFile, importList.getEnd()); - var oneImportPerLine = endLine - startLine > importList.elements.length; - return { - newText: "," + (oneImportPerLine ? context.newLineCharacter : " ") + newImportText, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter(sourceFile, importList.elements[importList.elements.length - 1], newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 237) { + if (declaration.kind === 238) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { namespacePrefix = declaration.name.getText(); } namespacePrefix = ts.stripQuotes(namespacePrefix); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], namespacePrefix + ".", { start: token.getStart(), length: 0 }, sourceFile.fileName, "CodeChange"); + return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], createChangeTracker().replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange"); } } function getCodeActionForNewImport(moduleSpecifier) { - if (!cachedNewImportInsertPosition) { - var lastModuleSpecifierEnd = -1; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var moduleSpecifier_1 = _a[_i]; - var end = moduleSpecifier_1.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + if (!lastImportDeclaration) { + for (var i = sourceFile.statements.length - 1; i >= 0; i--) { + var statement = sourceFile.statements[i]; + if (statement.kind === 237 || statement.kind === 238) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - var importStatementText = isDefault - ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + var changeTracker = createChangeTracker(); + var importClause = isDefault + ? ts.createImportClause(ts.createIdentifier(name), undefined) : isNamespaceImport - ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; - var newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter - : "" + context.newLineCharacter + importStatementText + ";"; - return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); + ? ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(name))) + : ts.createImportClause(undefined, ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(name))])); + var importDecl = ts.createImportDeclaration(undefined, undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } + return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -66669,7 +70372,7 @@ var ts; tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 264) { + if (moduleSymbol.valueDeclaration.kind !== 265) { return moduleSymbol.name; } } @@ -66798,10 +70501,13 @@ var ts; } } } - function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { + function createChangeTracker() { + return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + } + function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { description: ts.formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName: fileName, textChanges: [{ newText: newText, span: span }] }], + changes: changes, kind: kind, moduleSpecifier: moduleSpecifier }; @@ -66814,128 +70520,227 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + codefix.registerCodeFix({ + errorCodes: getApplicableDiagnosticCodes(), + getCodeActions: getDisableJsDiagnosticsCodeActions + }); + function getApplicableDiagnosticCodes() { + var allDiagnostcs = ts.Diagnostics; + return Object.keys(allDiagnostcs) + .filter(function (d) { return allDiagnostcs[d] && allDiagnostcs[d].category === ts.DiagnosticCategory.Error; }) + .map(function (d) { return allDiagnostcs[d].code; }); + } + function getIgnoreCommentLocationForLocation(sourceFile, position, newLineCharacter) { + var line = ts.getLineAndCharacterOfPosition(sourceFile, position).line; + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var startPosition = ts.getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + if (!ts.isInComment(sourceFile, startPosition) && !ts.isInString(sourceFile, startPosition) && !ts.isInTemplateString(sourceFile, startPosition)) { + var token = ts.getTouchingToken(sourceFile, startPosition); + var tokenLeadingCommnets = ts.getLeadingCommentRangesOfNode(token, sourceFile); + if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { + return { + span: { start: startPosition, length: 0 }, + newText: "// @ts-ignore" + newLineCharacter + }; + } + } + return { + span: { start: position, length: 0 }, + newText: (position === startPosition ? "" : newLineCharacter) + "// @ts-ignore" + newLineCharacter + }; + } + function getDisableJsDiagnosticsCodeActions(context) { + var sourceFile = context.sourceFile, program = context.program, newLineCharacter = context.newLineCharacter, span = context.span; + if (!ts.isInJavaScriptFile(sourceFile) || !ts.isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { + return undefined; + } + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Ignore_this_error_message), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + }] + }, + { + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Disable_checking_for_this_file), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { + start: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.pos : 0, + length: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.end - sourceFile.checkJsDirective.pos : 0 + }, + newText: "// @ts-nocheck" + newLineCharacter + }] + }] + }]; + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function newNodesToChanges(newNodes, insertAfter, context) { + var sourceFile = context.sourceFile; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { + var newNode = newNodes_1[_i]; + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); + } + var changes = changeTracker.getChanges(); + if (!ts.some(changes)) { + return changes; + } + ts.Debug.assert(changes.length === 1); + var consolidatedChanges = [{ + fileName: changes[0].fileName, + textChanges: [{ + span: changes[0].textChanges[0].span, + newText: changes[0].textChanges.reduce(function (prev, cur) { return prev + cur.newText; }, "") + }] + }]; + return consolidatedChanges; + } + codefix.newNodesToChanges = newNodesToChanges; + function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, checker) { var classMembers = classDeclaration.symbol.members; var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); - var insertion = ""; + var newNodes = []; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; - insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + var newNode = createNewNodeForMemberSymbol(symbol, classDeclaration, checker); + if (newNode) { + if (Array.isArray(newNode)) { + newNodes = newNodes.concat(newNode); + } + else { + newNodes.push(newNode); + } + } } - return insertion; + return newNodes; } - codefix.getMissingMembersInsertion = getMissingMembersInsertion; - function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { - var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + codefix.createMissingMemberNodes = createMissingMemberNodes; + function createNewNodeForMemberSymbol(symbol, enclosingDeclaration, checker) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { - return ""; + return undefined; } var declaration = declarations[0]; - var name = declaration.name ? declaration.name.getText() : undefined; - var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + var name = ts.getSynthesizedClone(declaration.name); + var visibilityModifier = createVisibilityModifier(ts.getModifierFlags(declaration)); + var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; + var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); + var optional = !!(symbol.flags & 67108864); switch (declaration.kind) { - case 152: case 153: - case 147: + case 154: case 148: - var typeString = checker.typeToString(type, enclosingDeclaration, 0); - return "" + visibility + name + ": " + typeString + ";" + newlineChar; case 149: + var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); + var property = ts.createProperty(undefined, modifiers, name, optional ? ts.createToken(55) : undefined, typeNode, undefined); + return property; case 150: + case 151: var signatures = checker.getSignaturesOfType(type, 0); - if (!(signatures && signatures.length > 0)) { - return ""; + if (!ts.some(signatures)) { + return undefined; } if (declarations.length === 1) { ts.Debug.assert(signatures.length === 1); - var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); - return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + var signature = signatures[0]; + return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - var result = ""; + var signatureDeclarations = []; for (var i = 0; i < signatures.length; i++) { - var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); - result += "" + visibility + name + sigString_2 + ";" + newlineChar; + var signature = signatures[i]; + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } - var bodySig = undefined; if (declarations.length > signatures.length) { - bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } else { ts.Debug.assert(declarations.length === signatures.length); - bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + var methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, optional, modifiers); + signatureDeclarations.push(methodImplementingSignatures); } - var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); - result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); - return result; + return signatureDeclarations; default: - return ""; + return undefined; + } + function signatureToMethodDeclaration(signature, enclosingDeclaration, body) { + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 151, enclosingDeclaration); + if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? ts.createToken(55) : undefined; + signatureDeclaration.body = body; + } + return signatureDeclaration; } } - function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(154); - newSignatureDeclaration.parent = enclosingDeclaration; - newSignatureDeclaration.name = signatures[0].getDeclaration().name; - var maxNonRestArgs = -1; - var maxArgsIndex = 0; + function createMethodImplementingSignatures(signatures, name, optional, modifiers) { + var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; - var hasRestParameter = false; + var someSigHasRestParameter = false; for (var i = 0; i < signatures.length; i++) { var sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - hasRestParameter = hasRestParameter || sig.hasRestParameter; - var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength > maxNonRestArgs) { - maxNonRestArgs = nonRestLength; - maxArgsIndex = i; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + maxArgsSignature = sig; } } - var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); - var optionalToken = ts.createToken(54); - newSignatureDeclaration.parameters = ts.createNodeArray(); + var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.getName(); }); + var parameters = []; for (var i = 0; i < maxNonRestArgs; i++) { - var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); - newSignatureDeclaration.parameters.push(newParameter); + var anyType = ts.createKeywordTypeNode(119); + var newParameter = ts.createParameter(undefined, undefined, undefined, maxArgsParameterSymbolNames[i], i >= minArgumentCount ? ts.createToken(55) : undefined, anyType, undefined); + parameters.push(newParameter); } - if (hasRestParameter) { - var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); - restParameter.dotDotDotToken = ts.createToken(23); - newSignatureDeclaration.parameters.push(restParameter); - } - return checker.getSignatureFromDeclaration(newSignatureDeclaration); - function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(145); - newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); - newParameter.symbol.valueDeclaration = newParameter; - newParameter.symbol.declarations = [newParameter]; - newParameter.parent = enclosingSignatureDeclaration; - if (index >= minArgCount) { - newParameter.questionToken = optionalToken; - } - return newParameter; + if (someSigHasRestParameter) { + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119)); + var restParameter = ts.createParameter(undefined, undefined, ts.createToken(24), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", maxNonRestArgs >= minArgumentCount ? ts.createToken(55) : undefined, anyArrayType, undefined); + parameters.push(restParameter); } + return createStubbedMethod(modifiers, name, optional, undefined, parameters, undefined); } - function getMethodBodyStub(newLineChar) { - return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType) { + return ts.createMethodDeclaration(undefined, modifiers, undefined, name, optional ? ts.createToken(55) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody()); } - function getVisibilityPrefix(flags) { + codefix.createStubbedMethod = createStubbedMethod; + function createStubbedMethodBody() { + return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), undefined, [ts.createLiteral("Method not implemented.")]))], true); + } + function createVisibilityModifier(flags) { if (flags & 4) { - return "public "; + return ts.createToken(114); } else if (flags & 16) { - return "protected "; + return ts.createToken(113); } - return ""; + return undefined; } - var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 142 ? new NodeObject(kind, pos, end) : - kind === 70 ? new IdentifierObject(70, pos, end) : + var node = kind >= 143 ? new NodeObject(kind, pos, end) : + kind === 71 ? new IdentifierObject(71, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -66992,11 +70797,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(296, nodes.pos, nodes.end, this); + var list = createNode(294, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { - var node = nodes_7[_i]; + for (var _i = 0, nodes_9 = nodes; _i < nodes_9.length; _i++) { + var node = nodes_9[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -67011,11 +70816,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 142) { + if (this.kind >= 143) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 282 && this.kind <= 295; + var useJSDocScanner_1 = this.kind >= 283 && this.kind <= 293; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -67068,8 +70873,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 266 || kid.kind > 295; }); - return child.kind < 142 ? + var child = ts.find(children, function (kid) { return kid.kind < 267 || kid.kind > 293; }); + return child.kind < 143 ? child : child.getFirstToken(sourceFile); }; @@ -67079,7 +70884,10 @@ var ts; if (!child) { return undefined; } - return child.kind < 142 ? child : child.getLastToken(sourceFile); + return child.kind < 143 ? child : child.getLastToken(sourceFile); + }; + NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { + return ts.forEachChild(this, cbNode, cbNodeArray); }; return NodeObject; }()); @@ -67132,6 +70940,9 @@ var ts; TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; + TokenOrIdentifierObject.prototype.forEachChild = function () { + return undefined; + }; return TokenOrIdentifierObject; }()); var SymbolObject = (function () { @@ -67154,6 +70965,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -67172,7 +70989,7 @@ var ts; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 70; + IdentifierObject.prototype.kind = 71; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -67237,6 +71054,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -67298,9 +71121,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 143) { + if (declaration.name.kind === 144) { var expr = declaration.name.expression; - if (expr.kind === 178) { + if (expr.kind === 179) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -67310,7 +71133,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 || + if (node.kind === 71 || node.kind === 9 || node.kind === 8) { return node.text; @@ -67320,10 +71143,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 227: - case 185: + case 228: + case 186: + case 151: case 150: - case 149: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -67340,30 +71163,30 @@ var ts; } ts.forEachChild(node, visit); break; - case 228: - case 198: case 229: + case 199: case 230: case 231: case 232: - case 236: - case 245: - case 241: - case 236: - case 238: + case 233: + case 237: + case 246: + case 242: + case 237: case 239: - case 152: + case 240: case 153: - case 162: + case 154: + case 163: addDeclaration(node); ts.forEachChild(node, visit); break; - case 145: + case 146: if (!ts.hasModifier(node, 92)) { break; } - case 225: - case 175: { + case 226: + case 176: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -67372,24 +71195,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 263: + case 264: + case 149: case 148: - case 147: addDeclaration(node); break; - case 243: + case 244: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 237: + case 238: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239) { + if (importClause.namedBindings.kind === 240) { addDeclaration(importClause.namedBindings); } else { @@ -67615,6 +71438,30 @@ var ts; }; return CancellationTokenObject; }()); + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken, throttleWaitMilliseconds) { + if (throttleWaitMilliseconds === void 0) { throttleWaitMilliseconds = 20; } + this.hostCancellationToken = hostCancellationToken; + this.throttleWaitMilliseconds = throttleWaitMilliseconds; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return ThrottledCancellationToken; + }()); + ts.ThrottledCancellationToken = ThrottledCancellationToken; function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -67831,12 +71678,12 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { - case 70: - case 178: - case 142: - case 98: - case 168: - case 96: + case 71: + case 179: + case 143: + case 99: + case 169: + case 97: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -67844,7 +71691,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -67856,21 +71704,22 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } - function getImplementationAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); - } function getTypeDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); } + function getImplementationAtPosition(fileName, position) { + synchronizeHostData(); + return ts.FindAllReferences.getImplementationsAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); + } function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { @@ -67886,7 +71735,6 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program.getTypeChecker(), cancellationToken, sourceFile, position, sourceFilesToSearch); } function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); function convertDocumentHighlights(documentHighlights) { if (!documentHighlights) { @@ -67901,7 +71749,8 @@ var ts; fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, - isDefinition: false + isDefinition: false, + isInString: highlightSpan.isInString, }); } } @@ -67909,20 +71758,18 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, true); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position); + } + function getReferences(fileName, position, options) { + synchronizeHostData(); + return ts.FindAllReferences.findReferencedEntries(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); @@ -67940,7 +71787,8 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); + var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -67964,16 +71812,16 @@ var ts; return; } switch (node.kind) { - case 178: - case 142: + case 179: + case 143: case 9: - case 85: - case 100: - case 94: - case 96: - case 98: - case 168: - case 70: + case 86: + case 101: + case 95: + case 97: + case 99: + case 169: + case 71: break; default: return; @@ -67984,7 +71832,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 232 && + if (nodeForStartPos.parent.parent.kind === 233 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -68003,10 +71851,10 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName) { - return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName) { var kind = ts.getScriptKind(fileName, host); @@ -68034,7 +71882,7 @@ var ts; } function getOutliningSpans(fileName) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); + return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -68064,14 +71912,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 16: return 17; - case 18: return 19; - case 20: return 21; - case 26: return 28; - case 17: return 16; - case 19: return 18; - case 21: return 20; - case 28: return 26; + case 17: return 18; + case 19: return 20; + case 21: return 22; + case 27: return 29; + case 18: return 17; + case 20: return 19; + case 22: return 21; + case 29: return 27; } return undefined; } @@ -68110,7 +71958,7 @@ var ts; } return []; } - function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = { start: start, length: end - start }; @@ -68125,7 +71973,8 @@ var ts; program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; var fixes = ts.codefix.getFixes(context); if (fixes) { @@ -68276,13 +72125,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 70: + case 71: setNameTable(node.text, node); break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 247 || + node.parent.kind === 248 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { setNameTable(node.text, node); @@ -68304,13 +72153,13 @@ var ts; } function isObjectLiteralElement(node) { switch (node.kind) { - case 252: - case 254: - case 260: + case 253: + case 255: case 261: - case 150: - case 152: + case 262: + case 151: case 153: + case 154: return true; } return false; @@ -68319,12 +72168,12 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 143) { + if (node.parent.kind === 144) { return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } - case 70: + case 71: return isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 177 || node.parent.parent.kind === 253) && + (node.parent.parent.kind === 178 || node.parent.parent.kind === 254) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -68357,7 +72206,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 179 && + node.parent.kind === 180 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -68390,7 +72239,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { + if (encoded === null) { return null; } var decoded = JSON.parse(encoded); @@ -68458,7 +72307,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { + if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } var compilerOptions = JSON.parse(settingsJson); @@ -68486,7 +72335,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; } try { @@ -68499,7 +72348,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); + return new ts.ThrottledCancellationToken(hostCancellationToken); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -68523,22 +72372,6 @@ var ts; return LanguageServiceShimHostAdapter; }()); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); var CoreServicesShimHostAdapter = (function () { function CoreServicesShimHostAdapter(shimHost) { var _this = this; @@ -69062,7 +72895,7 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "2.3"; +var toolsVersion = "2.4"; var ts; (function (ts) { var server; @@ -69071,11 +72904,13 @@ var ts; server.ActionInvalidate = "action::invalidate"; server.EventBeginInstallTypes = "event::beginInstallTypes"; server.EventEndInstallTypes = "event::endInstallTypes"; + server.EventInitializationFailed = "event::initializationFailed"; var Arguments; (function (Arguments) { Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; Arguments.LogFile = "--logFile"; Arguments.EnableTelemetry = "--enableTelemetry"; + Arguments.TypingSafeListLocation = "--typingSafeListLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; @@ -69265,7 +73100,7 @@ var ts; this.logger = logger; } GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { + if (!this.host.gc || this.timerId !== undefined) { return; } this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); @@ -69491,10 +73326,24 @@ var ts; this.containingProjects.length = 0; }; ScriptInfo.prototype.getDefaultProject = function () { - if (this.containingProjects.length === 0) { - return server.Errors.ThrowNoProject(); + switch (this.containingProjects.length) { + case 0: + return server.Errors.ThrowNoProject(); + case 1: + return this.containingProjects[0]; + default: + var firstExternalProject = void 0; + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var project = _a[_i]; + if (project.projectKind === server.ProjectKind.Configured) { + return project; + } + else if (project.projectKind === server.ProjectKind.External && !firstExternalProject) { + firstExternalProject = project; + } + } + return firstExternalProject || this.containingProjects[0]; } - return this.containingProjects[0]; }; ScriptInfo.prototype.registerFileUpdate = function () { for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { @@ -69582,6 +73431,7 @@ var ts; this.cancellationToken = cancellationToken; this.resolvedModuleNames = ts.createFileMap(); this.resolvedTypeReferenceDirectives = ts.createFileMap(); + this.cancellationToken = new ts.ThrottledCancellationToken(cancellationToken, project.projectService.throttleWaitMilliseconds); this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); if (host.trace) { this.trace = function (s) { return host.trace(s); }; @@ -69800,7 +73650,7 @@ var ts; !setIsEqualTo(opt1.exclude, opt2.exclude); } function compilerOptionsChanged(opt1, opt2) { - return opt1.allowJs != opt2.allowJs; + return opt1.allowJs !== opt2.allowJs; } function unresolvedImportsChanged(imports1, imports2) { if (imports1 === imports2) { @@ -69877,7 +73727,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 232 || statement.name.kind !== 9) { + if (statement.kind !== 233 || statement.name.kind !== 9) { return false; } } @@ -69998,7 +73848,6 @@ var ts; var r = rf.scriptInfo.fileName; return (l < r ? -1 : (l > r ? 1 : 0)); }; - ; ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { if (array.length === 0) { array.push(fileInfo); @@ -70653,7 +74502,7 @@ var ts; var updatedFileNames = this.updatedFileNames; this.updatedFileNames = undefined; if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { - if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { + if (this.projectStructureVersion === this.lastReportedVersion && !updatedFileNames) { return { info: info, projectErrors: this.projectErrors }; } var lastReportedFileNames_1 = this.lastReportedFileNames; @@ -70812,7 +74661,6 @@ var ts; __extends(ConfiguredProject, _super); function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.configFileName = configFileName; _this.wildcardDirectories = wildcardDirectories; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.plugins = []; @@ -70825,28 +74673,46 @@ var ts; return this.getProjectName(); }; ConfiguredProject.prototype.enablePlugins = function () { - var _this = this; var host = this.projectService.host; var options = this.getCompilerOptions(); - var log = function (message) { - _this.projectService.logger.info(message); - }; - if (!(options.plugins && options.plugins.length)) { - this.projectService.logger.info("No plugins exist"); - return; - } if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; } - for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { - var pluginConfigEntry = _a[_i]; - var searchPath = ts.getDirectoryPath(this.configFileName); - var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); - if (resolvedModule) { - this.enableProxy(resolvedModule, pluginConfigEntry); + var searchPaths = [ts.combinePaths(host.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + if (options.plugins) { + for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { + var pluginConfigEntry = _a[_i]; + this.enablePlugin(pluginConfigEntry, searchPaths); } } + if (this.projectService.globalPlugins) { + var _loop_6 = function (globalPluginName) { + if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) + return "continue"; + this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths); + }; + var this_1 = this; + for (var _b = 0, _c = this.projectService.globalPlugins; _b < _c.length; _b++) { + var globalPluginName = _c[_b]; + _loop_6(globalPluginName); + } + } + }; + ConfiguredProject.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { + var _this = this; + var log = function (message) { + _this.projectService.logger.info(message); + }; + for (var _i = 0, searchPaths_1 = searchPaths; _i < searchPaths_1.length; _i++) { + var searchPath = searchPaths_1[_i]; + var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, this.projectService.host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + return; + } + } + this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name + " anywhere in paths: " + searchPaths.join(",")); }; ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { @@ -70976,6 +74842,7 @@ var ts; __extends(ExternalProject, _super); function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.externalProjectName = externalProjectName; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.projectFilePath = projectFilePath; return _this; @@ -71046,6 +74913,31 @@ var ts; "block": ts.IndentStyle.Block, "smart": ts.IndentStyle.Smart }); + var defaultTypeSafeList = { + "jquery": { + "match": /jquery(-(\.?\d+)+)?(\.intellisense)?(\.min)?\.js$/i, + "types": ["jquery"] + }, + "WinJS": { + "match": /^(.*\/winjs-[.\d]+)\/js\/base\.js$/i, + "exclude": [["^", 1, "/.*"]], + "types": ["winjs"] + }, + "Kendo": { + "match": /^(.*\/kendo)\/kendo\.all\.min\.js$/i, + "exclude": [["^", 1, "/.*"]], + "types": ["kendo-ui"] + }, + "Office Nuget": { + "match": /^(.*\/office\/1)\/excel-\d+\.debug\.js$/i, + "exclude": [["^", 1, "/.*"]], + "types": ["office"] + }, + "Minified files": { + "match": /^(.+\.min\.js)$/i, + "exclude": [["^", 1, "$"]] + } + }; function convertFormatOptions(protocolOptions) { if (typeof protocolOptions.indentStyle === "string") { protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); @@ -71138,7 +75030,7 @@ var ts; DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { var currentPath = ts.getDirectoryPath(fileName); var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { + while (currentPath !== parentPath) { if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info("Add watcher for: " + currentPath); this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); @@ -71155,24 +75047,27 @@ var ts; return DirectoryWatchers; }()); var ProjectService = (function () { - function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { - if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } - this.host = host; - this.logger = logger; - this.cancellationToken = cancellationToken; - this.useSingleInferredProject = useSingleInferredProject; - this.typingsInstaller = typingsInstaller; - this.eventHandler = eventHandler; + function ProjectService(opts) { this.filenameToScriptInfo = ts.createFileMap(); this.externalProjectToConfiguredProjectMap = ts.createMap(); this.externalProjects = []; this.inferredProjects = []; this.configuredProjects = []; this.openFiles = []; - ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); - this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.projectToSizeMap = ts.createMap(); + this.host = opts.host; + this.logger = opts.logger; + this.cancellationToken = opts.cancellationToken; + this.useSingleInferredProject = opts.useSingleInferredProject; + this.typingsInstaller = opts.typingsInstaller || server.nullTypingsInstaller; + this.throttleWaitMilliseconds = opts.throttleWaitMilliseconds; + this.eventHandler = opts.eventHandler; + this.globalPlugins = opts.globalPlugins || server.emptyArray; + this.pluginProbeLocations = opts.pluginProbeLocations || server.emptyArray; + ts.Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); + this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.directoryWatchers = new DirectoryWatchers(this); - this.throttledOperations = new server.ThrottledOperations(host); + this.throttledOperations = new server.ThrottledOperations(this.host); this.typingsInstaller.attach(this); this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { @@ -71180,7 +75075,7 @@ var ts; hostInfo: "Unknown host", extraFileExtensions: [] }; - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + this.documentRegistry = ts.createDocumentRegistry(this.host.useCaseSensitiveFileNames, this.host.getCurrentDirectory()); } ProjectService.prototype.getChangedFiles_TestOnly = function () { return this.changedFiles; @@ -71370,7 +75265,7 @@ var ts; this.refreshInferredProjects(); }; ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { + if (ts.getBaseFileName(fileName) !== "tsconfig.json") { this.logger.info(fileName + " is not tsconfig.json"); return; } @@ -71389,9 +75284,11 @@ var ts; switch (project.projectKind) { case server.ProjectKind.External: server.removeItemFromSet(this.externalProjects, project); + this.projectToSizeMap.delete(project.externalProjectName); break; case server.ProjectKind.Configured: server.removeItemFromSet(this.configuredProjects, project); + this.projectToSizeMap.delete(project.canonicalConfigFilePath); break; case server.ProjectKind.Inferred: server.removeItemFromSet(this.inferredProjects, project); @@ -71427,13 +75324,17 @@ var ts; if (!this.useSingleInferredProject) { for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { var f = _c[_b]; - if (f.containingProjects.length === 0) { + if (f.containingProjects.length === 0 || !inferredProject.containsScriptInfo(f)) { continue; } - var defaultProject = f.getDefaultProject(); - if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - this.removeProject(defaultProject); - f.attachToProject(inferredProject); + for (var _d = 0, _e = f.containingProjects; _d < _e.length; _d++) { + var fContainingProject = _e[_d]; + if (fContainingProject.projectKind === server.ProjectKind.Inferred && + fContainingProject.isRoot(f) && + fContainingProject !== inferredProject) { + this.removeProject(fContainingProject); + f.attachToProject(inferredProject); + } } } } @@ -71486,10 +75387,10 @@ var ts; this.filenameToScriptInfo.remove(info.path); } }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName, projectRootPath) { var searchPath = ts.getDirectoryPath(fileName); this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath), projectRootPath); if (!configFileName) { this.logger.info("No config files found."); return {}; @@ -71511,8 +75412,8 @@ var ts; } return { configFileName: configFileName }; }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { + ProjectService.prototype.findConfigFile = function (searchPath, projectRootPath) { + while (!projectRootPath || searchPath.indexOf(projectRootPath) >= 0) { var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); if (this.host.fileExists(tsconfigFileName)) { return tsconfigFileName; @@ -71598,10 +75499,13 @@ var ts; }; return { success: true, projectOptions: projectOptions, configFileErrors: errors }; }; - ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (name, options, fileNames, propertyReader) { if (options && options.disableSizeLimit || !this.host.getFileSize) { return false; } + var availableSpace = server.maxProgramSizeForNonTsFiles; + this.projectToSizeMap.set(name, 0); + this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); }); var totalNonTsFileSize = 0; for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { var f = fileNames_3[_i]; @@ -71614,11 +75518,15 @@ var ts; return true; } } + if (totalNonTsFileSize > availableSpace) { + return true; + } + this.projectToSizeMap.set(name, totalNonTsFileSize); return false; }; ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { var compilerOptions = convertCompilerOptions(options); - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); this.externalProjects.push(project); return project; @@ -71634,7 +75542,7 @@ var ts; }; ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { var _this = this; - var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); @@ -71660,7 +75568,7 @@ var ts; var scriptKind = propertyReader.getScriptKind(f); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName === rootFilename, undefined, scriptKind, hasMixedContent); project.addRoot(info); } else { @@ -71675,7 +75583,7 @@ var ts; var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); var projectOptions = conversionResult.success ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; + : { files: [], compilerOptions: {}, typeAcquisition: { enable: false } }; var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); return { success: conversionResult.success, @@ -71763,7 +75671,7 @@ var ts; this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); return configFileErrors; } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { project.setCompilerOptions(projectOptions.compilerOptions); if (!project.languageServiceEnabled) { return configFileErrors; @@ -71900,15 +75808,15 @@ var ts; } this.printProjects(); }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var configFileName; var configFileErrors; var project = this.findContainingExternalProject(fileName); if (!project) { - (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); + (_a = this.openOrUpdateConfiguredProjectForFile(fileName, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); } @@ -71930,13 +75838,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_6 = function (proj) { + var _loop_7 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_6(proj); + _loop_7(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -72035,12 +75943,95 @@ var ts; }); this.refreshInferredProjects(); }; + ProjectService.escapeFilenameForRegex = function (filename) { + return filename.replace(this.filenameEscapeRegexp, "\\$&"); + }; + ProjectService.prototype.resetSafeList = function () { + ProjectService.safelist = defaultTypeSafeList; + }; + ProjectService.prototype.loadSafeList = function (fileName) { + var raw = JSON.parse(this.host.readFile(fileName, "utf-8")); + for (var _i = 0, _a = Object.keys(raw); _i < _a.length; _i++) { + var k = _a[_i]; + raw[k].match = new RegExp(raw[k].match, "i"); + } + ProjectService.safelist = raw; + }; + ProjectService.prototype.applySafeList = function (proj) { + var _this = this; + var rootFiles = proj.rootFiles, typeAcquisition = proj.typeAcquisition; + var types = (typeAcquisition && typeAcquisition.include) || []; + var excludeRules = []; + var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); + var _loop_8 = function (name) { + var rule = ProjectService.safelist[name]; + for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { + var root = normalizedNames_1[_i]; + if (rule.match.test(root)) { + this_2.logger.info("Excluding files based on rule " + name); + if (rule.types) { + for (var _a = 0, _b = rule.types; _a < _b.length; _a++) { + var type = _b[_a]; + if (types.indexOf(type) < 0) { + types.push(type); + } + } + } + if (rule.exclude) { + var _loop_9 = function (exclude) { + var processedRule = root.replace(rule.match, function () { + var groups = []; + for (var _i = 0; _i < arguments.length; _i++) { + groups[_i] = arguments[_i]; + } + return exclude.map(function (groupNumberOrString) { + if (typeof groupNumberOrString === "number") { + if (typeof groups[groupNumberOrString] !== "string") { + _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + return "\\*"; + } + return ProjectService.escapeFilenameForRegex(groups[groupNumberOrString]); + } + return groupNumberOrString; + }).join(""); + }); + if (excludeRules.indexOf(processedRule) === -1) { + excludeRules.push(processedRule); + } + }; + for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { + var exclude = _d[_c]; + _loop_9(exclude); + } + } + else { + var escaped = ProjectService.escapeFilenameForRegex(root); + if (excludeRules.indexOf(escaped) < 0) { + excludeRules.push(escaped); + } + } + } + } + if (types.length > 0) { + proj.typeAcquisition = proj.typeAcquisition || {}; + proj.typeAcquisition.include = types; + } + }; + var this_2 = this; + for (var _i = 0, _a = Object.keys(ProjectService.safelist); _i < _a.length; _i++) { + var name = _a[_i]; + _loop_8(name); + } + var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); + proj.rootFiles = proj.rootFiles.filter(function (_file, index) { return !excludeRegexes.some(function (re) { return re.test(normalizedNames[index]); }); }); + }; ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } if (proj.typingOptions && !proj.typeAcquisition) { var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); proj.typeAcquisition = typeAcquisition; } + this.applySafeList(proj); var tsConfigFiles; var rootFiles = []; for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { @@ -72063,7 +76054,7 @@ var ts; if (externalProject) { if (!tsConfigFiles) { var compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { externalProject.disableLanguageService(); } else { @@ -72127,6 +76118,8 @@ var ts; }; return ProjectService; }()); + ProjectService.safelist = defaultTypeSafeList; + ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; server.ProjectService = ProjectService; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -72144,12 +76137,11 @@ var ts; var nanoseconds = time[1]; return ((1e9 * seconds) + nanoseconds) / 1000000.0; } - function shouldSkipSematicCheck(project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { - return true; + function isDeclarationFileInJSOnlyNonConfiguredProject(project, file) { + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && + project.isJsOnlyProject()) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + return scriptInfo && !scriptInfo.isJavaScript(); } return false; } @@ -72160,7 +76152,7 @@ var ts; if (a.file < b.file) { return -1; } - else if (a.file == b.file) { + else if (a.file === b.file) { var n = compareNumber(a.start.line, b.start.line); if (n === 0) { return compareNumber(a.start.offset, b.start.offset); @@ -72178,14 +76170,18 @@ var ts; start: scriptInfo.positionToLineOffset(diag.start), end: scriptInfo.positionToLineOffset(diag.start + diag.length), text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - code: diag.code + code: diag.code, + category: ts.DiagnosticCategory[diag.category].toLowerCase(), + source: diag.source }; } function formatConfigFileDiag(diag) { return { start: undefined, end: undefined, - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + category: ts.DiagnosticCategory[diag.category].toLowerCase(), + source: diag.source }; } function allEditsBeforePos(edits, pos) { @@ -72343,7 +76339,6 @@ var ts; } }; MultistepOperation.prototype.setTimerHandle = function (timerHandle) { - ; if (this.timerHandle !== undefined) { this.operationHost.getServerHost().clearTimeout(this.timerHandle); } @@ -72361,15 +76356,8 @@ var ts; return MultistepOperation; }()); var Session = (function () { - function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { + function Session(opts) { var _this = this; - this.host = host; - this.cancellationToken = cancellationToken; - this.typingsInstaller = typingsInstaller; - this.byteLength = byteLength; - this.hrtime = hrtime; - this.logger = logger; - this.canUseEvents = canUseEvents; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, _a[CommandNames.OpenExternalProject] = function (request) { @@ -72442,7 +76430,7 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { @@ -72609,8 +76597,16 @@ var ts; return _this.requiredResponse(_this.getSupportedCodeFixes()); }, _a)); - this.eventHander = canUseEvents - ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + this.host = opts.host; + this.cancellationToken = opts.cancellationToken; + this.typingsInstaller = opts.typingsInstaller; + this.byteLength = opts.byteLength; + this.hrtime = opts.hrtime; + this.logger = opts.logger; + this.canUseEvents = opts.canUseEvents; + var throttleWaitMilliseconds = opts.throttleWaitMilliseconds; + this.eventHandler = this.canUseEvents + ? opts.eventHandler || (function (event) { return _this.defaultEventHandler(event); }) : undefined; var multistepOperationHost = { executeWithRequestId: function (requestId, action) { return _this.executeWithRequestId(requestId, action); }, @@ -72618,11 +76614,22 @@ var ts; getServerHost: function () { return _this.host; }, logError: function (err, cmd) { return _this.logError(err, cmd); }, sendRequestCompletedEvent: function (requestId) { return _this.sendRequestCompletedEvent(requestId); }, - isCancellationRequested: function () { return cancellationToken.isCancellationRequested(); } + isCancellationRequested: function () { return _this.cancellationToken.isCancellationRequested(); } }; this.errorCheck = new MultistepOperation(multistepOperationHost); - this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); - this.gcTimer = new server.GcTimer(host, 7000, logger); + var settings = { + host: this.host, + logger: this.logger, + cancellationToken: this.cancellationToken, + useSingleInferredProject: opts.useSingleInferredProject, + typingsInstaller: this.typingsInstaller, + throttleWaitMilliseconds: throttleWaitMilliseconds, + eventHandler: this.eventHandler, + globalPlugins: opts.globalPlugins, + pluginProbeLocations: opts.pluginProbeLocations + }; + this.projectService = new server.ProjectService(settings); + this.gcTimer = new server.GcTimer(this.host, 7000, this.logger); var _a; } Session.prototype.sendRequestCompletedEvent = function (requestId) { @@ -72638,9 +76645,9 @@ var ts; var _this = this; switch (event.eventName) { case server.ContextEvent: - var _a = event.data, project_1 = _a.project, fileName_1 = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName_1); - this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_1, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); + var _a = event.data, project_1 = _a.project, fileName_2 = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName_2); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_2, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); break; case server.ConfigFileDiagEvent: var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; @@ -72717,7 +76724,7 @@ var ts; Session.prototype.semanticCheck = function (file, project) { try { var diags = []; - if (!shouldSkipSematicCheck(project)) { + if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); @@ -72814,13 +76821,14 @@ var ts; length: d.length, category: ts.DiagnosticCategory[d.category].toLowerCase(), code: d.code, + source: d.source, startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) }); }); }; Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (isSemantic && shouldSkipSematicCheck(project)) { + if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { return []; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -72899,16 +76907,20 @@ var ts; return undefined; } return occurrences.map(function (occurrence) { - var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; + var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString; var scriptInfo = project.getScriptInfo(fileName); var start = scriptInfo.positionToLineOffset(textSpan.start); var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { + var result = { start: start, end: end, file: fileName, isWriteAccess: isWriteAccess, }; + if (isInString) { + result.isInString = isInString; + } + return result; }); }; Session.prototype.getSyntacticDiagnosticsSync = function (args) { @@ -72985,13 +76997,23 @@ var ts; } return projects; }; + Session.prototype.getDefaultProject = function (args) { + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + return project; + } + } + var info = this.projectService.getScriptInfo(args.file); + return info.getDefaultProject(); + }; Session.prototype.getRenameLocations = function (args, simplifiedResult) { var file = server.toNormalizedPath(args.file); var info = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, info); var projects = this.getProjects(args); if (simplifiedResult) { - var defaultProject = projects[0]; + var defaultProject = this.getDefaultProject(args); var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); if (!renameInfo) { return undefined; @@ -73070,7 +77092,7 @@ var ts; Session.prototype.getReferences = function (args, simplifiedResult) { var file = server.toNormalizedPath(args.file); var projects = this.getProjects(args); - var defaultProject = projects[0]; + var defaultProject = this.getDefaultProject(args); var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); if (simplifiedResult) { @@ -73121,10 +77143,10 @@ var ts; return false; } }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (this.eventHander) { - this.eventHander({ + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, false, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHandler) { + this.eventHandler({ eventName: "configFileDiag", data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } }); @@ -73202,6 +77224,7 @@ var ts; end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, documentation: docString, + tags: quickInfo.tags || [] }; } else { @@ -73241,7 +77264,7 @@ var ts; var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); var formatOptions = this.projectService.getFormatCodeOptions(file); var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); - if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + if ((args.key === "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { var lineInfo = scriptInfo.getLineInfo(args.line); if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { var lineText = lineInfo.leaf.text; @@ -73250,10 +77273,10 @@ var ts; var hasIndent = 0; var i = void 0, len = void 0; for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { + if (lineText.charAt(i) === " ") { hasIndent++; } - else if (lineText.charAt(i) == "\t") { + else if (lineText.charAt(i) === "\t") { hasIndent += formatOptions.tabSize; } else { @@ -73357,12 +77380,12 @@ var ts; return undefined; } if (simplifiedResult) { - var span_16 = helpItems.applicableSpan; + var span_17 = helpItems.applicableSpan; return { items: helpItems.items, applicableSpan: { - start: scriptInfo.positionToLineOffset(span_16.start), - end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + start: scriptInfo.positionToLineOffset(span_17.start), + end: scriptInfo.positionToLineOffset(span_17.start + span_17.length) }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, @@ -73541,11 +77564,15 @@ var ts; }; Session.prototype.getCodeFixes = function (args, simplifiedResult) { var _this = this; + if (args.errorCodes.length === 0) { + return undefined; + } var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var startPosition = getStartPosition(); var endPosition = getEndPosition(); - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, formatOptions); if (!codeActions) { return undefined; } @@ -73606,7 +77633,7 @@ var ts; var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { var fileNameInProject = fileNamesInProject_1[_i]; - if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + if (this.getCanonicalFileName(fileNameInProject) === this.getCanonicalFileName(fileName)) highPriorityFiles.push(fileNameInProject); else { var info = this.projectService.getScriptInfo(fileNameInProject); @@ -73623,7 +77650,7 @@ var ts; fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay, 200, false); } }; Session.prototype.getCanonicalFileName = function (fileName) { @@ -73768,7 +77795,7 @@ var ts; var lm = LineIndex.linesFromText(insertedText); var lines = lm.lines; if (lines.length > 1) { - if (lines[lines.length - 1] == "") { + if (lines[lines.length - 1] === "") { lines.length--; } } @@ -74209,7 +78236,7 @@ var ts; } if (this.checkEdits) { var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + ts.Debug.assert(checkText === updatedText, "buffer edit mismatch"); } return walker.lineIndex; } @@ -74623,6 +78650,13 @@ var ts; this.seq = 0; this.inGroup = false; this.firstInGroup = true; + if (this.logFilename) { + try { + this.fd = fs.openSync(this.logFilename, "w"); + } + catch (_) { + } + } } Logger.padStringRight = function (str, padding) { return (str + padding).slice(0, padding.length); @@ -74658,11 +78692,6 @@ var ts; }; Logger.prototype.msg = function (s, type) { if (type === void 0) { type = server.Msg.Err; } - if (this.fd < 0) { - if (this.logFilename) { - this.fd = fs.openSync(this.logFilename, "w"); - } - } if (this.fd >= 0 || this.traceToConsole) { s = s + "\n"; var prefix = Logger.padStringRight(type + " " + this.seq.toString(), " "); @@ -74686,11 +78715,12 @@ var ts; return Logger; }()); var NodeTypingsInstaller = (function () { - function NodeTypingsInstaller(telemetryEnabled, logger, host, eventPort, globalTypingsCacheLocation, newLine) { + function NodeTypingsInstaller(telemetryEnabled, logger, host, eventPort, globalTypingsCacheLocation, typingSafeListLocation, newLine) { var _this = this; this.telemetryEnabled = telemetryEnabled; this.logger = logger; this.globalTypingsCacheLocation = globalTypingsCacheLocation; + this.typingSafeListLocation = typingSafeListLocation; this.newLine = newLine; this.installerPidReported = false; this.throttledOperations = new server.ThrottledOperations(host); @@ -74729,6 +78759,9 @@ var ts; if (this.logger.loggingEnabled() && this.logger.getLogFileName()) { args.push(server.Arguments.LogFile, ts.combinePaths(ts.getDirectoryPath(ts.normalizeSlashes(this.logger.getLogFileName())), "ti-" + process.pid + ".log")); } + if (this.typingSafeListLocation) { + args.push(server.Arguments.TypingSafeListLocation, this.typingSafeListLocation); + } var execArgv = []; { for (var _i = 0, _a = process.execArgv; _i < _a.length; _i++) { @@ -74772,6 +78805,17 @@ var ts; if (this.logger.hasLevel(server.LogLevel.verbose)) { this.logger.info("Received response: " + JSON.stringify(response)); } + if (response.kind === server.EventInitializationFailed) { + if (!this.eventSender) { + return; + } + var body = { + message: response.message + }; + var eventName = "typesInstallerInitializationFailed"; + this.eventSender.event(body, eventName); + return; + } if (response.kind === server.EventBeginInstallTypes) { if (!this.eventSender) { return; @@ -74810,7 +78854,7 @@ var ts; return; } this.projectService.updateTypingsForProject(response); - if (response.kind == server.ActionSet && this.socket) { + if (response.kind === server.ActionSet && this.socket) { this.sendEvent(0, "setTypings", response); } }; @@ -74818,12 +78862,24 @@ var ts; }()); var IOSession = (function (_super) { __extends(IOSession, _super); - function IOSession(host, cancellationToken, installerEventPort, canUseEvents, useSingleInferredProject, disableAutomaticTypingAcquisition, globalTypingsCacheLocation, telemetryEnabled, logger) { + function IOSession(options) { var _this = this; + var host = options.host, installerEventPort = options.installerEventPort, globalTypingsCacheLocation = options.globalTypingsCacheLocation, typingSafeListLocation = options.typingSafeListLocation, canUseEvents = options.canUseEvents; var typingsInstaller = disableAutomaticTypingAcquisition ? undefined - : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, host.newLine); - _this = _super.call(this, host, cancellationToken, useSingleInferredProject, typingsInstaller || server.nullTypingsInstaller, Buffer.byteLength, process.hrtime, logger, canUseEvents) || this; + : new NodeTypingsInstaller(telemetryEnabled, logger, host, installerEventPort, globalTypingsCacheLocation, typingSafeListLocation, host.newLine); + _this = _super.call(this, { + host: host, + cancellationToken: cancellationToken, + useSingleInferredProject: useSingleInferredProject, + typingsInstaller: typingsInstaller || server.nullTypingsInstaller, + byteLength: Buffer.byteLength, + hrtime: process.hrtime, + logger: logger, + canUseEvents: canUseEvents, + globalPlugins: options.globalPlugins, + pluginProbeLocations: options.pluginProbeLocations + }) || this; if (telemetryEnabled && typingsInstaller) { typingsInstaller.setTelemetrySender(_this); } @@ -74847,6 +78903,9 @@ var ts; return IOSession; }(server.Session)); function parseLoggingEnvironmentString(logEnvStr) { + if (!logEnvStr) { + return {}; + } var logEnv = { logToFile: true }; var args = logEnvStr.split(" "); var len = args.length - 1; @@ -74859,8 +78918,8 @@ var ts; logEnv.file = ts.stripQuotes(value); break; case "-level": - var level = server.LogLevel[value]; - logEnv.detailLevel = typeof level === "number" ? level : server.LogLevel.normal; + var level = getLogLevel(value); + logEnv.detailLevel = level !== undefined ? level : server.LogLevel.normal; break; case "-traceToConsole": logEnv.traceToConsole = value.toLowerCase() === "true"; @@ -74873,27 +78932,28 @@ var ts; } return logEnv; } - function createLoggerFromEnv() { - var fileName = undefined; - var detailLevel = server.LogLevel.normal; - var traceToConsole = false; - var logEnvStr = process.env["TSS_LOG"]; - if (logEnvStr) { - var logEnv = parseLoggingEnvironmentString(logEnvStr); - if (logEnv.logToFile) { - if (logEnv.file) { - fileName = logEnv.file; - } - else { - fileName = __dirname + "/.log" + process.pid.toString(); + function getLogLevel(level) { + if (level) { + var l = level.toLowerCase(); + for (var name in server.LogLevel) { + if (isNaN(+name) && l === name.toLowerCase()) { + return server.LogLevel[name]; } } - if (logEnv.detailLevel) { - detailLevel = logEnv.detailLevel; - } - traceToConsole = logEnv.traceToConsole; } - return new Logger(fileName, traceToConsole, detailLevel); + return undefined; + } + function createLogger() { + var cmdLineLogFileName = server.findArgument("--logFile"); + var cmdLineVerbosity = getLogLevel(server.findArgument("--logVerbosity")); + var envLogOptions = parseLoggingEnvironmentString(process.env["TSS_LOG"]); + var logFileName = cmdLineLogFileName + ? ts.stripQuotes(cmdLineLogFileName) + : envLogOptions.logToFile + ? envLogOptions.file || (__dirname + "/.log" + process.pid.toString()) + : undefined; + var logVerbosity = cmdLineVerbosity || envLogOptions.detailLevel; + return new Logger(logFileName, envLogOptions.traceToConsole, logVerbosity); } function createPollingWatchedFileSet(interval, chunkSize) { if (interval === void 0) { interval = 2500; } @@ -74962,7 +79022,6 @@ var ts; }; } var pollingWatchedFileSet = createPollingWatchedFileSet(); - var logger = createLoggerFromEnv(); var pending = []; var canWrite = true; function writeMessage(buf) { @@ -74980,7 +79039,73 @@ var ts; writeMessage(pending.shift()); } } + function extractWatchDirectoryCacheKey(path, currentDriveKey) { + path = ts.normalizeSlashes(path); + if (isUNCPath(path)) { + var firstSlash = path.indexOf(ts.directorySeparator, 2); + return firstSlash !== -1 ? path.substring(0, firstSlash).toLowerCase() : path; + } + var rootLength = ts.getRootLength(path); + if (rootLength === 0) { + return currentDriveKey; + } + if (path.charCodeAt(1) === 58 && path.charCodeAt(2) === 47) { + return path.charAt(0).toLowerCase(); + } + if (path.charCodeAt(0) === 47 && path.charCodeAt(1) !== 47) { + return currentDriveKey; + } + return undefined; + } + function isUNCPath(s) { + return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; + } + var logger = createLogger(); var sys = ts.sys; + var useWatchGuard = process.platform === "win32" && ts.getNodeMajorVersion() >= 4; + if (useWatchGuard) { + var currentDrive_1 = extractWatchDirectoryCacheKey(sys.resolvePath(sys.getCurrentDirectory()), undefined); + var statusCache_1 = ts.createMap(); + var originalWatchDirectory_1 = sys.watchDirectory; + sys.watchDirectory = function (path, callback, recursive) { + var cacheKey = extractWatchDirectoryCacheKey(path, currentDrive_1); + var status = cacheKey && statusCache_1.get(cacheKey); + if (status === undefined) { + if (logger.hasLevel(server.LogLevel.verbose)) { + logger.info(cacheKey + " for path " + path + " not found in cache..."); + } + try { + var args = [ts.combinePaths(__dirname, "watchGuard.js"), path]; + if (logger.hasLevel(server.LogLevel.verbose)) { + logger.info("Starting " + process.execPath + " with args " + JSON.stringify(args)); + } + childProcess.execFileSync(process.execPath, args, { stdio: "ignore", env: { "ELECTRON_RUN_AS_NODE": "1" } }); + status = true; + if (logger.hasLevel(server.LogLevel.verbose)) { + logger.info("WatchGuard for path " + path + " returned: OK"); + } + } + catch (e) { + status = false; + if (logger.hasLevel(server.LogLevel.verbose)) { + logger.info("WatchGuard for path " + path + " returned: " + e.message); + } + } + if (cacheKey) { + statusCache_1.set(cacheKey, status); + } + } + else if (logger.hasLevel(server.LogLevel.verbose)) { + logger.info("watchDirectory for " + path + " uses cached drive information."); + } + if (status) { + return originalWatchDirectory_1.call(sys, path, callback, recursive); + } + else { + return { close: function () { } }; + } + }; + } sys.write = function (s) { return writeMessage(new Buffer(s, "utf8")); }; sys.watchFile = function (fileName, callback) { var watchedFile = pollingWatchedFileSet.addFile(fileName, callback); @@ -75012,7 +79137,6 @@ var ts; catch (e) { cancellationToken = server.nullCancellationToken; } - ; var eventPort; { var str = server.findArgument("--eventPort"); @@ -75025,10 +79149,27 @@ var ts; if (localeStr) { ts.validateLocaleAndSetLanguage(localeStr, sys); } + var typingSafeListLocation = server.findArgument("--typingSafeListLocation"); + var globalPlugins = (server.findArgument("--globalPlugins") || "").split(","); + var pluginProbeLocations = (server.findArgument("--pluginProbeLocations") || "").split(","); var useSingleInferredProject = server.hasArgument("--useSingleInferredProject"); var disableAutomaticTypingAcquisition = server.hasArgument("--disableAutomaticTypingAcquisition"); var telemetryEnabled = server.hasArgument(server.Arguments.EnableTelemetry); - var ioSession = new IOSession(sys, cancellationToken, eventPort, eventPort === undefined, useSingleInferredProject, disableAutomaticTypingAcquisition, getGlobalTypingsCacheLocation(), telemetryEnabled, logger); + var options = { + host: sys, + cancellationToken: cancellationToken, + installerEventPort: eventPort, + canUseEvents: eventPort === undefined, + useSingleInferredProject: useSingleInferredProject, + disableAutomaticTypingAcquisition: disableAutomaticTypingAcquisition, + globalTypingsCacheLocation: getGlobalTypingsCacheLocation(), + typingSafeListLocation: typingSafeListLocation, + telemetryEnabled: telemetryEnabled, + logger: logger, + globalPlugins: globalPlugins, + pluginProbeLocations: pluginProbeLocations + }; + var ioSession = new IOSession(options); process.on("uncaughtException", function (err) { ioSession.logError(err, "unknown"); }); diff --git a/lib/tsserverlibrary.d.ts b/lib/tsserverlibrary.d.ts index 90350104cae..189883c63e6 100644 --- a/lib/tsserverlibrary.d.ts +++ b/lib/tsserverlibrary.d.ts @@ -18,7 +18,7 @@ declare namespace ts { [index: string]: T; } interface Map { - get(key: string): T; + get(key: string): T | undefined; has(key: string): boolean; set(key: string, value: T): this; delete(key: string): boolean; @@ -66,326 +66,324 @@ declare namespace ts { NumericLiteral = 8, StringLiteral = 9, JsxText = 10, - RegularExpressionLiteral = 11, - NoSubstitutionTemplateLiteral = 12, - TemplateHead = 13, - TemplateMiddle = 14, - TemplateTail = 15, - OpenBraceToken = 16, - CloseBraceToken = 17, - OpenParenToken = 18, - CloseParenToken = 19, - OpenBracketToken = 20, - CloseBracketToken = 21, - DotToken = 22, - DotDotDotToken = 23, - SemicolonToken = 24, - CommaToken = 25, - LessThanToken = 26, - LessThanSlashToken = 27, - GreaterThanToken = 28, - LessThanEqualsToken = 29, - GreaterThanEqualsToken = 30, - EqualsEqualsToken = 31, - ExclamationEqualsToken = 32, - EqualsEqualsEqualsToken = 33, - ExclamationEqualsEqualsToken = 34, - EqualsGreaterThanToken = 35, - PlusToken = 36, - MinusToken = 37, - AsteriskToken = 38, - AsteriskAsteriskToken = 39, - SlashToken = 40, - PercentToken = 41, - PlusPlusToken = 42, - MinusMinusToken = 43, - LessThanLessThanToken = 44, - GreaterThanGreaterThanToken = 45, - GreaterThanGreaterThanGreaterThanToken = 46, - AmpersandToken = 47, - BarToken = 48, - CaretToken = 49, - ExclamationToken = 50, - TildeToken = 51, - AmpersandAmpersandToken = 52, - BarBarToken = 53, - QuestionToken = 54, - ColonToken = 55, - AtToken = 56, - EqualsToken = 57, - PlusEqualsToken = 58, - MinusEqualsToken = 59, - AsteriskEqualsToken = 60, - AsteriskAsteriskEqualsToken = 61, - SlashEqualsToken = 62, - PercentEqualsToken = 63, - LessThanLessThanEqualsToken = 64, - GreaterThanGreaterThanEqualsToken = 65, - GreaterThanGreaterThanGreaterThanEqualsToken = 66, - AmpersandEqualsToken = 67, - BarEqualsToken = 68, - CaretEqualsToken = 69, - Identifier = 70, - BreakKeyword = 71, - CaseKeyword = 72, - CatchKeyword = 73, - ClassKeyword = 74, - ConstKeyword = 75, - ContinueKeyword = 76, - DebuggerKeyword = 77, - DefaultKeyword = 78, - DeleteKeyword = 79, - DoKeyword = 80, - ElseKeyword = 81, - EnumKeyword = 82, - ExportKeyword = 83, - ExtendsKeyword = 84, - FalseKeyword = 85, - FinallyKeyword = 86, - ForKeyword = 87, - FunctionKeyword = 88, - IfKeyword = 89, - ImportKeyword = 90, - InKeyword = 91, - InstanceOfKeyword = 92, - NewKeyword = 93, - NullKeyword = 94, - ReturnKeyword = 95, - SuperKeyword = 96, - SwitchKeyword = 97, - ThisKeyword = 98, - ThrowKeyword = 99, - TrueKeyword = 100, - TryKeyword = 101, - TypeOfKeyword = 102, - VarKeyword = 103, - VoidKeyword = 104, - WhileKeyword = 105, - WithKeyword = 106, - ImplementsKeyword = 107, - InterfaceKeyword = 108, - LetKeyword = 109, - PackageKeyword = 110, - PrivateKeyword = 111, - ProtectedKeyword = 112, - PublicKeyword = 113, - StaticKeyword = 114, - YieldKeyword = 115, - AbstractKeyword = 116, - AsKeyword = 117, - AnyKeyword = 118, - AsyncKeyword = 119, - AwaitKeyword = 120, - BooleanKeyword = 121, - ConstructorKeyword = 122, - DeclareKeyword = 123, - GetKeyword = 124, - IsKeyword = 125, - KeyOfKeyword = 126, - ModuleKeyword = 127, - NamespaceKeyword = 128, - NeverKeyword = 129, - ReadonlyKeyword = 130, - RequireKeyword = 131, - NumberKeyword = 132, - ObjectKeyword = 133, - SetKeyword = 134, - StringKeyword = 135, - SymbolKeyword = 136, - TypeKeyword = 137, - UndefinedKeyword = 138, - FromKeyword = 139, - GlobalKeyword = 140, - OfKeyword = 141, - QualifiedName = 142, - ComputedPropertyName = 143, - TypeParameter = 144, - Parameter = 145, - Decorator = 146, - PropertySignature = 147, - PropertyDeclaration = 148, - MethodSignature = 149, - MethodDeclaration = 150, - Constructor = 151, - GetAccessor = 152, - SetAccessor = 153, - CallSignature = 154, - ConstructSignature = 155, - IndexSignature = 156, - TypePredicate = 157, - TypeReference = 158, - FunctionType = 159, - ConstructorType = 160, - TypeQuery = 161, - TypeLiteral = 162, - ArrayType = 163, - TupleType = 164, - UnionType = 165, - IntersectionType = 166, - ParenthesizedType = 167, - ThisType = 168, - TypeOperator = 169, - IndexedAccessType = 170, - MappedType = 171, - LiteralType = 172, - ObjectBindingPattern = 173, - ArrayBindingPattern = 174, - BindingElement = 175, - ArrayLiteralExpression = 176, - ObjectLiteralExpression = 177, - PropertyAccessExpression = 178, - ElementAccessExpression = 179, - CallExpression = 180, - NewExpression = 181, - TaggedTemplateExpression = 182, - TypeAssertionExpression = 183, - ParenthesizedExpression = 184, - FunctionExpression = 185, - ArrowFunction = 186, - DeleteExpression = 187, - TypeOfExpression = 188, - VoidExpression = 189, - AwaitExpression = 190, - PrefixUnaryExpression = 191, - PostfixUnaryExpression = 192, - BinaryExpression = 193, - ConditionalExpression = 194, - TemplateExpression = 195, - YieldExpression = 196, - SpreadElement = 197, - ClassExpression = 198, - OmittedExpression = 199, - ExpressionWithTypeArguments = 200, - AsExpression = 201, - NonNullExpression = 202, - MetaProperty = 203, - TemplateSpan = 204, - SemicolonClassElement = 205, - Block = 206, - VariableStatement = 207, - EmptyStatement = 208, - ExpressionStatement = 209, - IfStatement = 210, - DoStatement = 211, - WhileStatement = 212, - ForStatement = 213, - ForInStatement = 214, - ForOfStatement = 215, - ContinueStatement = 216, - BreakStatement = 217, - ReturnStatement = 218, - WithStatement = 219, - SwitchStatement = 220, - LabeledStatement = 221, - ThrowStatement = 222, - TryStatement = 223, - DebuggerStatement = 224, - VariableDeclaration = 225, - VariableDeclarationList = 226, - FunctionDeclaration = 227, - ClassDeclaration = 228, - InterfaceDeclaration = 229, - TypeAliasDeclaration = 230, - EnumDeclaration = 231, - ModuleDeclaration = 232, - ModuleBlock = 233, - CaseBlock = 234, - NamespaceExportDeclaration = 235, - ImportEqualsDeclaration = 236, - ImportDeclaration = 237, - ImportClause = 238, - NamespaceImport = 239, - NamedImports = 240, - ImportSpecifier = 241, - ExportAssignment = 242, - ExportDeclaration = 243, - NamedExports = 244, - ExportSpecifier = 245, - MissingDeclaration = 246, - ExternalModuleReference = 247, - JsxElement = 248, - JsxSelfClosingElement = 249, - JsxOpeningElement = 250, - JsxClosingElement = 251, - JsxAttribute = 252, - JsxAttributes = 253, - JsxSpreadAttribute = 254, - JsxExpression = 255, - CaseClause = 256, - DefaultClause = 257, - HeritageClause = 258, - CatchClause = 259, - PropertyAssignment = 260, - ShorthandPropertyAssignment = 261, - SpreadAssignment = 262, - EnumMember = 263, - SourceFile = 264, - Bundle = 265, - JSDocTypeExpression = 266, - JSDocAllType = 267, - JSDocUnknownType = 268, - JSDocArrayType = 269, - JSDocUnionType = 270, - JSDocTupleType = 271, - JSDocNullableType = 272, - JSDocNonNullableType = 273, - JSDocRecordType = 274, - JSDocRecordMember = 275, - JSDocTypeReference = 276, - JSDocOptionalType = 277, - JSDocFunctionType = 278, - JSDocVariadicType = 279, - JSDocConstructorType = 280, - JSDocThisType = 281, - JSDocComment = 282, - JSDocTag = 283, - JSDocAugmentsTag = 284, - JSDocParameterTag = 285, - JSDocReturnTag = 286, - JSDocTypeTag = 287, - JSDocTemplateTag = 288, - JSDocTypedefTag = 289, - JSDocPropertyTag = 290, - JSDocTypeLiteral = 291, - JSDocLiteralType = 292, - JSDocNullKeyword = 293, - JSDocUndefinedKeyword = 294, - JSDocNeverKeyword = 295, - SyntaxList = 296, - NotEmittedStatement = 297, - PartiallyEmittedExpression = 298, - MergeDeclarationMarker = 299, - EndOfDeclarationMarker = 300, - Count = 301, - FirstAssignment = 57, - LastAssignment = 69, - FirstCompoundAssignment = 58, - LastCompoundAssignment = 69, - FirstReservedWord = 71, - LastReservedWord = 106, - FirstKeyword = 71, - LastKeyword = 141, - FirstFutureReservedWord = 107, - LastFutureReservedWord = 115, - FirstTypeNode = 157, - LastTypeNode = 172, - FirstPunctuation = 16, - LastPunctuation = 69, + JsxTextAllWhiteSpaces = 11, + RegularExpressionLiteral = 12, + NoSubstitutionTemplateLiteral = 13, + TemplateHead = 14, + TemplateMiddle = 15, + TemplateTail = 16, + OpenBraceToken = 17, + CloseBraceToken = 18, + OpenParenToken = 19, + CloseParenToken = 20, + OpenBracketToken = 21, + CloseBracketToken = 22, + DotToken = 23, + DotDotDotToken = 24, + SemicolonToken = 25, + CommaToken = 26, + LessThanToken = 27, + LessThanSlashToken = 28, + GreaterThanToken = 29, + LessThanEqualsToken = 30, + GreaterThanEqualsToken = 31, + EqualsEqualsToken = 32, + ExclamationEqualsToken = 33, + EqualsEqualsEqualsToken = 34, + ExclamationEqualsEqualsToken = 35, + EqualsGreaterThanToken = 36, + PlusToken = 37, + MinusToken = 38, + AsteriskToken = 39, + AsteriskAsteriskToken = 40, + SlashToken = 41, + PercentToken = 42, + PlusPlusToken = 43, + MinusMinusToken = 44, + LessThanLessThanToken = 45, + GreaterThanGreaterThanToken = 46, + GreaterThanGreaterThanGreaterThanToken = 47, + AmpersandToken = 48, + BarToken = 49, + CaretToken = 50, + ExclamationToken = 51, + TildeToken = 52, + AmpersandAmpersandToken = 53, + BarBarToken = 54, + QuestionToken = 55, + ColonToken = 56, + AtToken = 57, + EqualsToken = 58, + PlusEqualsToken = 59, + MinusEqualsToken = 60, + AsteriskEqualsToken = 61, + AsteriskAsteriskEqualsToken = 62, + SlashEqualsToken = 63, + PercentEqualsToken = 64, + LessThanLessThanEqualsToken = 65, + GreaterThanGreaterThanEqualsToken = 66, + GreaterThanGreaterThanGreaterThanEqualsToken = 67, + AmpersandEqualsToken = 68, + BarEqualsToken = 69, + CaretEqualsToken = 70, + Identifier = 71, + BreakKeyword = 72, + CaseKeyword = 73, + CatchKeyword = 74, + ClassKeyword = 75, + ConstKeyword = 76, + ContinueKeyword = 77, + DebuggerKeyword = 78, + DefaultKeyword = 79, + DeleteKeyword = 80, + DoKeyword = 81, + ElseKeyword = 82, + EnumKeyword = 83, + ExportKeyword = 84, + ExtendsKeyword = 85, + FalseKeyword = 86, + FinallyKeyword = 87, + ForKeyword = 88, + FunctionKeyword = 89, + IfKeyword = 90, + ImportKeyword = 91, + InKeyword = 92, + InstanceOfKeyword = 93, + NewKeyword = 94, + NullKeyword = 95, + ReturnKeyword = 96, + SuperKeyword = 97, + SwitchKeyword = 98, + ThisKeyword = 99, + ThrowKeyword = 100, + TrueKeyword = 101, + TryKeyword = 102, + TypeOfKeyword = 103, + VarKeyword = 104, + VoidKeyword = 105, + WhileKeyword = 106, + WithKeyword = 107, + ImplementsKeyword = 108, + InterfaceKeyword = 109, + LetKeyword = 110, + PackageKeyword = 111, + PrivateKeyword = 112, + ProtectedKeyword = 113, + PublicKeyword = 114, + StaticKeyword = 115, + YieldKeyword = 116, + AbstractKeyword = 117, + AsKeyword = 118, + AnyKeyword = 119, + AsyncKeyword = 120, + AwaitKeyword = 121, + BooleanKeyword = 122, + ConstructorKeyword = 123, + DeclareKeyword = 124, + GetKeyword = 125, + IsKeyword = 126, + KeyOfKeyword = 127, + ModuleKeyword = 128, + NamespaceKeyword = 129, + NeverKeyword = 130, + ReadonlyKeyword = 131, + RequireKeyword = 132, + NumberKeyword = 133, + ObjectKeyword = 134, + SetKeyword = 135, + StringKeyword = 136, + SymbolKeyword = 137, + TypeKeyword = 138, + UndefinedKeyword = 139, + FromKeyword = 140, + GlobalKeyword = 141, + OfKeyword = 142, + QualifiedName = 143, + ComputedPropertyName = 144, + TypeParameter = 145, + Parameter = 146, + Decorator = 147, + PropertySignature = 148, + PropertyDeclaration = 149, + MethodSignature = 150, + MethodDeclaration = 151, + Constructor = 152, + GetAccessor = 153, + SetAccessor = 154, + CallSignature = 155, + ConstructSignature = 156, + IndexSignature = 157, + TypePredicate = 158, + TypeReference = 159, + FunctionType = 160, + ConstructorType = 161, + TypeQuery = 162, + TypeLiteral = 163, + ArrayType = 164, + TupleType = 165, + UnionType = 166, + IntersectionType = 167, + ParenthesizedType = 168, + ThisType = 169, + TypeOperator = 170, + IndexedAccessType = 171, + MappedType = 172, + LiteralType = 173, + ObjectBindingPattern = 174, + ArrayBindingPattern = 175, + BindingElement = 176, + ArrayLiteralExpression = 177, + ObjectLiteralExpression = 178, + PropertyAccessExpression = 179, + ElementAccessExpression = 180, + CallExpression = 181, + NewExpression = 182, + TaggedTemplateExpression = 183, + TypeAssertionExpression = 184, + ParenthesizedExpression = 185, + FunctionExpression = 186, + ArrowFunction = 187, + DeleteExpression = 188, + TypeOfExpression = 189, + VoidExpression = 190, + AwaitExpression = 191, + PrefixUnaryExpression = 192, + PostfixUnaryExpression = 193, + BinaryExpression = 194, + ConditionalExpression = 195, + TemplateExpression = 196, + YieldExpression = 197, + SpreadElement = 198, + ClassExpression = 199, + OmittedExpression = 200, + ExpressionWithTypeArguments = 201, + AsExpression = 202, + NonNullExpression = 203, + MetaProperty = 204, + TemplateSpan = 205, + SemicolonClassElement = 206, + Block = 207, + VariableStatement = 208, + EmptyStatement = 209, + ExpressionStatement = 210, + IfStatement = 211, + DoStatement = 212, + WhileStatement = 213, + ForStatement = 214, + ForInStatement = 215, + ForOfStatement = 216, + ContinueStatement = 217, + BreakStatement = 218, + ReturnStatement = 219, + WithStatement = 220, + SwitchStatement = 221, + LabeledStatement = 222, + ThrowStatement = 223, + TryStatement = 224, + DebuggerStatement = 225, + VariableDeclaration = 226, + VariableDeclarationList = 227, + FunctionDeclaration = 228, + ClassDeclaration = 229, + InterfaceDeclaration = 230, + TypeAliasDeclaration = 231, + EnumDeclaration = 232, + ModuleDeclaration = 233, + ModuleBlock = 234, + CaseBlock = 235, + NamespaceExportDeclaration = 236, + ImportEqualsDeclaration = 237, + ImportDeclaration = 238, + ImportClause = 239, + NamespaceImport = 240, + NamedImports = 241, + ImportSpecifier = 242, + ExportAssignment = 243, + ExportDeclaration = 244, + NamedExports = 245, + ExportSpecifier = 246, + MissingDeclaration = 247, + ExternalModuleReference = 248, + JsxElement = 249, + JsxSelfClosingElement = 250, + JsxOpeningElement = 251, + JsxClosingElement = 252, + JsxAttribute = 253, + JsxAttributes = 254, + JsxSpreadAttribute = 255, + JsxExpression = 256, + CaseClause = 257, + DefaultClause = 258, + HeritageClause = 259, + CatchClause = 260, + PropertyAssignment = 261, + ShorthandPropertyAssignment = 262, + SpreadAssignment = 263, + EnumMember = 264, + SourceFile = 265, + Bundle = 266, + JSDocTypeExpression = 267, + JSDocAllType = 268, + JSDocUnknownType = 269, + JSDocArrayType = 270, + JSDocUnionType = 271, + JSDocTupleType = 272, + JSDocNullableType = 273, + JSDocNonNullableType = 274, + JSDocRecordType = 275, + JSDocRecordMember = 276, + JSDocTypeReference = 277, + JSDocOptionalType = 278, + JSDocFunctionType = 279, + JSDocVariadicType = 280, + JSDocConstructorType = 281, + JSDocThisType = 282, + JSDocComment = 283, + JSDocTag = 284, + JSDocAugmentsTag = 285, + JSDocParameterTag = 286, + JSDocReturnTag = 287, + JSDocTypeTag = 288, + JSDocTemplateTag = 289, + JSDocTypedefTag = 290, + JSDocPropertyTag = 291, + JSDocTypeLiteral = 292, + JSDocLiteralType = 293, + SyntaxList = 294, + NotEmittedStatement = 295, + PartiallyEmittedExpression = 296, + MergeDeclarationMarker = 297, + EndOfDeclarationMarker = 298, + Count = 299, + FirstAssignment = 58, + LastAssignment = 70, + FirstCompoundAssignment = 59, + LastCompoundAssignment = 70, + FirstReservedWord = 72, + LastReservedWord = 107, + FirstKeyword = 72, + LastKeyword = 142, + FirstFutureReservedWord = 108, + LastFutureReservedWord = 116, + FirstTypeNode = 158, + LastTypeNode = 173, + FirstPunctuation = 17, + LastPunctuation = 70, FirstToken = 0, - LastToken = 141, + LastToken = 142, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 12, - FirstTemplateToken = 12, - LastTemplateToken = 15, - FirstBinaryOperator = 26, - LastBinaryOperator = 69, - FirstNode = 142, - FirstJSDocNode = 266, - LastJSDocNode = 295, - FirstJSDocTagNode = 282, - LastJSDocTagNode = 295, + LastLiteralToken = 13, + FirstTemplateToken = 13, + LastTemplateToken = 16, + FirstBinaryOperator = 27, + LastBinaryOperator = 70, + FirstNode = 143, + FirstJSDocNode = 267, + LastJSDocNode = 293, + FirstJSDocTagNode = 283, + LastJSDocTagNode = 293, } const enum NodeFlags { None = 0, @@ -462,6 +460,7 @@ declare namespace ts { type EndOfFileToken = Token; type AtToken = Token; type ReadonlyToken = Token; + type AwaitKeywordToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { @@ -498,6 +497,7 @@ declare namespace ts { } interface TypeParameterDeclaration extends Declaration { kind: SyntaxKind.TypeParameter; + parent?: DeclarationWithTypeParameters; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -518,17 +518,19 @@ declare namespace ts { type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends Declaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList; + parent?: VariableDeclarationList | CatchClause; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; + parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } interface ParameterDeclaration extends Declaration { kind: SyntaxKind.Parameter; + parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; @@ -537,6 +539,7 @@ declare namespace ts { } interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; + parent?: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; @@ -560,7 +563,7 @@ declare namespace ts { _objectLiteralBrandBrand: any; name?: PropertyName; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -591,10 +594,12 @@ declare namespace ts { } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; @@ -621,41 +626,44 @@ declare namespace ts { } interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { kind: SyntaxKind.Constructor; + parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; } interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; + parent?: ClassDeclaration | ClassExpression; } interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.GetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.SetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; + parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; - } - interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + interface FunctionTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.ConstructorType; } interface TypeReferenceNode extends TypeNode { @@ -684,15 +692,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface UnionOrIntersectionTypeNode extends TypeNode { - kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; + type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + interface UnionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType; types: NodeArray; } - interface UnionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.UnionType; - } - interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; + types: NodeArray; } interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; @@ -710,6 +717,7 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; + parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -724,7 +732,6 @@ declare namespace ts { } interface Expression extends Node { _expressionBrand: any; - contextualType?: Type; } interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; @@ -760,13 +767,13 @@ declare namespace ts { interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression { + interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression { + interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression { + interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } interface SuperExpression extends PrimaryExpression { @@ -874,16 +881,18 @@ declare namespace ts { } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; - trailingComment?: string; } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; + parent?: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; + parent?: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; + parent?: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { @@ -893,6 +902,7 @@ declare namespace ts { } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; + parent?: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -914,7 +924,7 @@ declare namespace ts { interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, Declaration { kind: SyntaxKind.PropertyAccessExpression; @@ -948,6 +958,7 @@ declare namespace ts { } interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; + parent?: HeritageClause; expression: LeftHandSideExpression; typeArguments?: NodeArray; } @@ -955,7 +966,7 @@ declare namespace ts { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; - arguments: NodeArray; + arguments?: NodeArray; } interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; @@ -993,9 +1004,11 @@ declare namespace ts { type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase { + parent?: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; + parent?: JsxElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } @@ -1006,24 +1019,30 @@ declare namespace ts { } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; + parent?: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; + parent?: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; + parent?: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + parent?: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; + containsOnlyWhiteSpaces: boolean; + parent?: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { @@ -1086,6 +1105,7 @@ declare namespace ts { } interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; + awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } @@ -1115,15 +1135,18 @@ declare namespace ts { } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; + parent?: SwitchStatement; clauses: NodeArray; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; + parent?: CaseBlock; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; + parent?: CaseBlock; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; @@ -1144,6 +1167,7 @@ declare namespace ts { } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; + parent?: TryStatement; variableDeclaration: VariableDeclaration; block: Block; } @@ -1179,8 +1203,9 @@ declare namespace ts { } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; - token: SyntaxKind; - types?: NodeArray; + parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; + token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; + types: NodeArray; } interface TypeAliasDeclaration extends DeclarationStatement { kind: SyntaxKind.TypeAliasDeclaration; @@ -1190,6 +1215,7 @@ declare namespace ts { } interface EnumMember extends Declaration { kind: SyntaxKind.EnumMember; + parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } @@ -1202,8 +1228,9 @@ declare namespace ts { type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; - name: Identifier | StringLiteral; - body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; + parent?: ModuleBody | SourceFile; + name: ModuleName; + body?: ModuleBody | JSDocNamespaceDeclaration; } type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { @@ -1217,74 +1244,94 @@ declare namespace ts { } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; + parent?: ModuleDeclaration; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; + parent?: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; + parent?: ImportEqualsDeclaration; expression?: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; + parent?: SourceFile | ModuleBlock; importClause?: ImportClause; moduleSpecifier: Expression; } type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends Declaration { kind: SyntaxKind.ImportClause; + parent?: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends Declaration { kind: SyntaxKind.NamespaceImport; + parent?: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; - moduleReference: LiteralLikeNode; } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; + parent?: SourceFile | ModuleBlock; exportClause?: NamedExports; moduleSpecifier?: Expression; } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; + parent?: ImportClause; elements: NodeArray; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; + parent?: ExportDeclaration; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends Declaration { kind: SyntaxKind.ImportSpecifier; + parent?: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends Declaration { kind: SyntaxKind.ExportSpecifier; + parent?: NamedExports; propertyName?: Identifier; name: Identifier; } type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; + parent?: SourceFile; isExportEquals?: boolean; expression: Expression; } interface FileReference extends TextRange { fileName: string; } + interface CheckJsDirective extends TextRange { + enabled: boolean; + } + type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; - kind: SyntaxKind; + kind: CommentKind; + } + interface SynthesizedComment extends CommentRange { + text: string; + pos: -1; + end: -1; } interface JSDocTypeExpression extends Node { kind: SyntaxKind.JSDocTypeExpression; @@ -1482,7 +1529,6 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Token; fileName: string; - path: Path; text: string; amdDependencies: AmdDependency[]; moduleName: string; @@ -1521,7 +1567,7 @@ declare namespace ts { interface Program extends ScriptReferenceHost { getRootFileNames(): string[]; getSourceFiles(): SourceFile[]; - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -1529,6 +1575,10 @@ declare namespace ts { getDeclarationDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; getTypeChecker(): TypeChecker; } + interface CustomTransformers { + before?: TransformerFactory[]; + after?: TransformerFactory[]; + } interface SourceMapSpan { emittedLine: number; emittedColumn: number; @@ -1568,8 +1618,13 @@ declare namespace ts { getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): BaseType[]; + getBaseTypeOfLiteralType(type: Type): Type; + getWidenedType(type: Type): Type; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -1603,6 +1658,15 @@ declare namespace ts { tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; } + enum NodeBuilderFlags { + None = 0, + allowThisInObjectLiteral = 1, + allowQualifedNameInPlaceOfIdentifier = 2, + allowTypeParameterInQualifiedName = 4, + allowAnonymousIdentifier = 8, + allowEmptyUnionOrIntersection = 16, + allowEmptyTuple = 32, + } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; @@ -1811,7 +1875,6 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -1904,6 +1967,7 @@ declare namespace ts { messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; + source?: string; } enum DiagnosticCategory { Warning = 0, @@ -1926,9 +1990,11 @@ declare namespace ts { alwaysStrict?: boolean; baseUrl?: string; charset?: string; + checkJs?: boolean; declaration?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; @@ -1973,6 +2039,7 @@ declare namespace ts { skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strict?: boolean; strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; @@ -2128,13 +2195,15 @@ declare namespace ts { HelperName = 4096, ExportName = 8192, LocalName = 16384, - Indented = 32768, - NoIndentation = 65536, - AsyncFunctionBody = 131072, - ReuseTempVariableScope = 262144, - CustomPrologue = 524288, - NoHoisting = 1048576, - HasEndOfDeclarationMarker = 2097152, + InternalName = 32768, + Indented = 65536, + NoIndentation = 131072, + AsyncFunctionBody = 262144, + ReuseTempVariableScope = 524288, + CustomPrologue = 1048576, + NoHoisting = 2097152, + HasEndOfDeclarationMarker = 4194304, + Iterator = 8388608, } interface EmitHelper { readonly name: string; @@ -2148,6 +2217,34 @@ declare namespace ts { IdentifierName = 2, Unspecified = 3, } + interface TransformationContext { + getCompilerOptions(): CompilerOptions; + startLexicalEnvironment(): void; + suspendLexicalEnvironment(): void; + resumeLexicalEnvironment(): void; + endLexicalEnvironment(): Statement[]; + hoistFunctionDeclaration(node: FunctionDeclaration): void; + hoistVariableDeclaration(node: Identifier): void; + requestEmitHelper(helper: EmitHelper): void; + readEmitHelpers(): EmitHelper[] | undefined; + enableSubstitution(kind: SyntaxKind): void; + isSubstitutionEnabled(node: Node): boolean; + onSubstituteNode: (hint: EmitHint, node: Node) => Node; + enableEmitNotification(kind: SyntaxKind): void; + isEmitNotificationEnabled(node: Node): boolean; + onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; + } + interface TransformationResult { + transformed: T[]; + diagnostics?: Diagnostic[]; + substituteNode(hint: EmitHint, node: Node): Node; + emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + dispose(): void; + } + type TransformerFactory = (context: TransformationContext) => Transformer; + type Transformer = (node: T) => T; + type Visitor = (node: Node) => VisitResult; + type VisitResult = T | T[]; interface Printer { printNode(hint: EmitHint, node: Node, sourceFile: SourceFile): string; printFile(sourceFile: SourceFile): string; @@ -2156,10 +2253,9 @@ declare namespace ts { interface PrintHandlers { hasGlobalName?(name: string): boolean; onEmitNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; - onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + substituteNode?(hint: EmitHint, node: Node): Node; } interface PrinterOptions { - target?: ScriptTarget; removeComments?: boolean; newLine?: NewLineKind; } @@ -2176,7 +2272,7 @@ declare namespace ts { } } declare namespace ts { - const version = "2.3.0"; + const version = "2.4.0"; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -2221,6 +2317,7 @@ declare namespace ts { directoryName: string; referenceCount: number; } + function getNodeMajorVersion(): number; let sys: System; } declare namespace ts { @@ -2261,14 +2358,14 @@ declare namespace ts { function tokenToString(t: SyntaxKind): string; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; - function isWhiteSpace(ch: number): boolean; + function isWhiteSpaceLike(ch: number): boolean; function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; - function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; + function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getShebang(text: string): string; @@ -2287,7 +2384,7 @@ declare namespace ts { error?: Diagnostic; }; function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions?: CompilerOptions, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; @@ -2374,35 +2471,80 @@ declare namespace ts { function createUniqueName(text: string): Identifier; function getGeneratedNameForNode(node: Node): Identifier; function createToken(token: TKind): Token; - function createSuper(): PrimaryExpression; - function createThis(): PrimaryExpression; - function createNull(): PrimaryExpression; - function createTrue(): BooleanLiteral; - function createFalse(): BooleanLiteral; + function createSuper(): SuperExpression; + function createThis(): ThisExpression & Token; + function createNull(): NullLiteral & Token; + function createTrue(): BooleanLiteral & Token; + function createFalse(): BooleanLiteral & Token; function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; function createComputedPropertyName(expression: Expression): ComputedPropertyName; function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): SignatureDeclaration; + function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; + function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; + function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; + function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; + function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; + function createThisTypeNode(): ThisTypeNode; + function createLiteralTypeNode(literal: Expression): LiteralTypeNode; + function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode; + function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; + function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; + function createTypeQueryNode(exprName: EntityName): TypeQueryNode; + function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; + function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; + function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray): UnionOrIntersectionTypeNode; + function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; + function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; + function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode; + function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; + function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode; + function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode; + function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; + function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; + function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration; + function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; - function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; @@ -2411,20 +2553,20 @@ declare namespace ts { function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createCall(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -2446,11 +2588,11 @@ declare namespace ts { function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; - function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createClassExpression(modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; @@ -2462,33 +2604,33 @@ declare namespace ts { function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createBlock(statements: Statement[], multiLine?: boolean): Block; function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; - function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; function createEmptyStatement(): EmptyStatement; function createStatement(expression: Expression): ExpressionStatement; function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; - function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; function createWhile(expression: Expression, statement: Statement): WhileStatement; function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createFor(initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function createContinue(label?: string | Identifier): ContinueStatement; - function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; function createBreak(label?: string | Identifier): BreakStatement; - function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier | undefined): BreakStatement; function createReturn(expression?: Expression): ReturnStatement; - function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression | undefined): ReturnStatement; function createWith(expression: Expression, statement: Statement): WithStatement; function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; @@ -2497,40 +2639,40 @@ declare namespace ts { function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; function createThrow(expression: Expression): ThrowStatement; function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; - function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; + function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; function createModuleBlock(statements: Statement[]): ModuleBlock; function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined): ImportDeclaration; function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; function createNamedImports(elements: ImportSpecifier[]): NamedImports; function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; - function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; function createNamedExports(elements: ExportSpecifier[]): NamedExports; function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; - function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; @@ -2547,9 +2689,9 @@ declare namespace ts { function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; - function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; + function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; @@ -2559,9 +2701,9 @@ declare namespace ts { function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined): ShorthandPropertyAssignment; function createSpreadAssignment(expression: Expression): SpreadAssignment; - function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; @@ -2589,14 +2731,20 @@ declare namespace ts { function createExternalModuleExport(exportName: Identifier): ExportDeclaration; function disposeEmitNodes(sourceFile: SourceFile): void; function setTextRange(range: T, location: TextRange | undefined): T; - function getEmitFlags(node: Node): EmitFlags; + function getEmitFlags(node: Node): EmitFlags | undefined; function setEmitFlags(node: T, emitFlags: EmitFlags): T; function getSourceMapRange(node: Node): TextRange; - function setSourceMapRange(node: T, range: TextRange): T; - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + function setSourceMapRange(node: T, range: TextRange | undefined): T; + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange | undefined; + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange | undefined): T; function getCommentRange(node: Node): TextRange; function setCommentRange(node: T, range: TextRange): T; + function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined; + function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]): T; + function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; + function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; + function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; + function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; function getConstantValue(node: PropertyAccessExpression | ElementAccessExpression): number; function setConstantValue(node: PropertyAccessExpression | ElementAccessExpression, value: number): PropertyAccessExpression | ElementAccessExpression; function addEmitHelper(node: T, helper: EmitHelper): T; @@ -2604,7 +2752,7 @@ declare namespace ts { function removeEmitHelper(node: Node, helper: EmitHelper): boolean; function getEmitHelpers(node: Node): EmitHelper[] | undefined; function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function setOriginalNode(node: T, original: Node): T; + function setOriginalNode(node: T, original: Node | undefined): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2614,6 +2762,19 @@ declare namespace ts { function isExternalModule(file: SourceFile): boolean; function updateSourceFile(sourceFile: SourceFile, newText: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; } +declare namespace ts { + function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + function visitLexicalEnvironment(statements: NodeArray, visitor: Visitor, context: TransformationContext, start?: number, ensureUseStrict?: boolean): NodeArray; + function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + function visitFunctionBody(node: FunctionBody, visitor: Visitor, context: TransformationContext): FunctionBody; + function visitFunctionBody(node: FunctionBody | undefined, visitor: Visitor, context: TransformationContext): FunctionBody | undefined; + function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; + function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; +} declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } @@ -2647,12 +2808,14 @@ declare namespace ts { getText(sourceFile?: SourceFile): string; getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; + forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; } interface Symbol { getFlags(): SymbolFlags; getName(): string; getDeclarations(): Declaration[]; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -2669,10 +2832,11 @@ declare namespace ts { } interface Signature { getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; + getTypeParameters(): TypeParameter[]; getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -2681,6 +2845,9 @@ declare namespace ts { getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } + interface SourceFileLike { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } interface IScriptSnapshot { getText(start: number, end: number): string; getLength(): number; @@ -2724,6 +2891,7 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; getDirectories?(directoryName: string): string[]; + getCustomTransformers?(): CustomTransformers | undefined; } interface LanguageService { cleanupSemanticCache(): void; @@ -2762,7 +2930,7 @@ declare namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; dispose(): void; @@ -2817,19 +2985,20 @@ declare namespace ts { newText: string; caretOffset: number; } - interface RenameLocation { + interface DocumentSpan { textSpan: TextSpan; fileName: string; } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; + interface RenameLocation extends DocumentSpan { + } + interface ReferenceEntry extends DocumentSpan { isWriteAccess: boolean; isDefinition: boolean; + isInString?: true; } - interface ImplementationLocation { - textSpan: TextSpan; - fileName: string; + interface ImplementationLocation extends DocumentSpan { + kind: string; + displayParts: SymbolDisplayPart[]; } interface DocumentHighlights { fileName: string; @@ -2843,6 +3012,7 @@ declare namespace ts { } interface HighlightSpan { fileName?: string; + isInString?: true; textSpan: TextSpan; kind: string; } @@ -2955,12 +3125,17 @@ declare namespace ts { text: string; kind: string; } + interface JSDocTagInfo { + name: string; + text?: string; + } interface QuickInfo { kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; @@ -2984,6 +3159,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface SignatureHelpItems { items: SignatureHelpItem[]; @@ -3011,6 +3187,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface OutliningSpan { textSpan: TextSpan; @@ -3075,7 +3252,7 @@ declare namespace ts { const interfaceElement = "interface"; const typeElement = "type"; const enumElement = "enum"; - const enumMemberElement = "const"; + const enumMemberElement = "enum member"; const variableElement = "var"; const localVariableElement = "local var"; const functionElement = "function"; @@ -3259,8 +3436,13 @@ declare namespace ts.server { type ActionInvalidate = "action::invalidate"; type EventBeginInstallTypes = "event::beginInstallTypes"; type EventEndInstallTypes = "event::endInstallTypes"; + type EventInitializationFailed = "event::initializationFailed"; interface TypingInstallerResponse { - readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes; + readonly kind: ActionSet | ActionInvalidate | EventBeginInstallTypes | EventEndInstallTypes | EventInitializationFailed; + } + interface InitializationFailedResponse extends TypingInstallerResponse { + readonly kind: EventInitializationFailed; + readonly message: string; } interface ProjectResponse extends TypingInstallerResponse { readonly projectName: string; @@ -3294,10 +3476,12 @@ declare namespace ts.server { const ActionInvalidate: ActionInvalidate; const EventBeginInstallTypes: EventBeginInstallTypes; const EventEndInstallTypes: EventEndInstallTypes; + const EventInitializationFailed: EventInitializationFailed; namespace Arguments { const GlobalCacheLocation = "--globalTypingsCacheLocation"; const LogFile = "--logFile"; const EnableTelemetry = "--enableTelemetry"; + const TypingSafeListLocation = "--typingSafeListLocation"; } function hasArgument(argumentName: string): boolean; function findArgument(argumentName: string): string; @@ -3591,6 +3775,7 @@ declare namespace ts.server.protocol { } interface OccurrencesResponseItem extends FileSpan { isWriteAccess: boolean; + isInString?: true; } interface OccurrencesResponse extends Response { body?: OccurrencesResponseItem[]; @@ -3690,6 +3875,7 @@ declare namespace ts.server.protocol { interface OpenRequestArgs extends FileRequestArgs { fileContent?: string; scriptKindName?: ScriptKindName; + projectRootPath?: string; } type ScriptKindName = "TS" | "JS" | "TSX" | "JSX"; interface OpenRequest extends Request { @@ -3764,6 +3950,7 @@ declare namespace ts.server.protocol { end: Location; displayString: string; documentation: string; + tags: JSDocTagInfo[]; } interface QuickInfoResponse extends Response { body?: QuickInfoResponseBody; @@ -3835,6 +4022,7 @@ declare namespace ts.server.protocol { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface CompletionsResponse extends Response { body?: CompletionEntry[]; @@ -3855,6 +4043,7 @@ declare namespace ts.server.protocol { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface SignatureHelpItems { items: SignatureHelpItem[]; @@ -3920,7 +4109,9 @@ declare namespace ts.server.protocol { start: Location; end: Location; text: string; + category: string; code?: number; + source?: string; } interface DiagnosticEventBody { file: string; @@ -4031,6 +4222,14 @@ declare namespace ts.server.protocol { telemetryEventName: string; payload: any; } + type TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed"; + interface TypesInstallerInitializationFailedEvent extends Event { + event: TypesInstallerInitializationFailedEventName; + body: TypesInstallerInitializationFailedEventBody; + } + interface TypesInstallerInitializationFailedEventBody { + message: string; + } type TypingsInstalledTelemetryEventName = "typingsInstalled"; interface TypingsInstalledTelemetryEventBody extends TelemetryEventBody { telemetryEventName: TypingsInstalledTelemetryEventName; @@ -4089,6 +4288,7 @@ declare namespace ts.server.protocol { insertSpaceAfterFunctionKeywordForAnonymousFunctions?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis?: boolean; insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets?: boolean; + insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; insertSpaceBeforeFunctionParenthesis?: boolean; @@ -4100,15 +4300,19 @@ declare namespace ts.server.protocol { allowSyntheticDefaultImports?: boolean; allowUnreachableCode?: boolean; allowUnusedLabels?: boolean; + alwaysStrict?: boolean; baseUrl?: string; charset?: string; + checkJs?: boolean; declaration?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; forceConsistentCasingInFileNames?: boolean; + importHelpers?: boolean; inlineSourceMap?: boolean; inlineSources?: boolean; isolatedModules?: boolean; @@ -4148,6 +4352,7 @@ declare namespace ts.server.protocol { skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strict?: boolean; strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; @@ -4252,21 +4457,35 @@ declare namespace ts.server { const GetSupportedCodeFixes: protocol.CommandTypes.GetSupportedCodeFixes; } function formatMessage(msg: T, logger: server.Logger, byteLength: (s: string, encoding: string) => number, newLine: string): string; + interface SessionOptions { + host: ServerHost; + cancellationToken: ServerCancellationToken; + useSingleInferredProject: boolean; + typingsInstaller: ITypingsInstaller; + byteLength: (buf: string, encoding?: string) => number; + hrtime: (start?: number[]) => number[]; + logger: Logger; + canUseEvents: boolean; + eventHandler?: ProjectServiceEventHandler; + throttleWaitMilliseconds?: number; + globalPlugins?: string[]; + pluginProbeLocations?: string[]; + } class Session implements EventSender { + private readonly gcTimer; + protected projectService: ProjectService; + private changeSeq; + private currentRequestId; + private errorCheck; + private eventHandler; private host; private readonly cancellationToken; protected readonly typingsInstaller: ITypingsInstaller; private byteLength; private hrtime; protected logger: Logger; - protected readonly canUseEvents: boolean; - private readonly gcTimer; - protected projectService: ProjectService; - private changeSeq; - private currentRequestId; - private errorCheck; - private eventHander; - constructor(host: ServerHost, cancellationToken: ServerCancellationToken, useSingleInferredProject: boolean, typingsInstaller: ITypingsInstaller, byteLength: (buf: string, encoding?: string) => number, hrtime: (start?: number[]) => number[], logger: Logger, canUseEvents: boolean, eventHandler?: ProjectServiceEventHandler); + private canUseEvents; + constructor(opts: SessionOptions); private sendRequestCompletedEvent(requestId); private defaultEventHandler(event); logError(err: Error, cmd: string): void; @@ -4297,9 +4516,10 @@ declare namespace ts.server { private getProjectInfoWorker(uncheckedFileName, projectFileName, needFileNameList); private getRenameInfo(args); private getProjects(args); + private getDefaultProject(args); private getRenameLocations(args, simplifiedResult); private getReferences(args, simplifiedResult); - private openClientFile(fileName, fileContent?, scriptKind?); + private openClientFile(fileName, fileContent?, scriptKind?, projectRootPath?); private getPosition(args, scriptInfo); private getFileAndProject(args, errorOnMissingProject?); private getFileAndProjectWithoutRefreshingInferredProjects(args, errorOnMissingProject?); @@ -4723,7 +4943,6 @@ declare namespace ts.server { getTypeAcquisition(): TypeAcquisition; } class ConfiguredProject extends Project { - private configFileName; private wildcardDirectories; compileOnSaveEnabled: boolean; private typeAcquisition; @@ -4737,6 +4956,7 @@ declare namespace ts.server { constructor(configFileName: NormalizedPath, projectService: ProjectService, documentRegistry: ts.DocumentRegistry, hasExplicitListOfFiles: boolean, compilerOptions: CompilerOptions, wildcardDirectories: Map, languageServiceEnabled: boolean, compileOnSaveEnabled: boolean); getConfigFilePath(): string; enablePlugins(): void; + private enablePlugin(pluginConfigEntry, searchPaths); private enableProxy(pluginModuleFactory, configEntry); getProjectRootPath(): string; setProjectErrors(projectErrors: Diagnostic[]): void; @@ -4754,6 +4974,7 @@ declare namespace ts.server { getEffectiveTypeRoots(): string[]; } class ExternalProject extends Project { + externalProjectName: string; compileOnSaveEnabled: boolean; private readonly projectFilePath; private typeAcquisition; @@ -4795,6 +5016,13 @@ declare namespace ts.server { interface ProjectServiceEventHandler { (event: ProjectServiceEvent): void; } + interface SafeList { + [name: string]: { + match: RegExp; + exclude?: Array>; + types?: string[]; + }; + } function convertFormatOptions(protocolOptions: protocol.FormatCodeSettings): FormatCodeSettings; function convertCompilerOptions(protocolOptions: protocol.ExternalProjectCompilerOptions): CompilerOptions & protocol.CompileOnSaveMixin; function tryConvertScriptKindName(scriptKindName: protocol.ScriptKindName | ScriptKind): ScriptKind; @@ -4809,13 +5037,18 @@ declare namespace ts.server { configFileName?: NormalizedPath; configFileErrors?: Diagnostic[]; } + interface ProjectServiceOptions { + host: ServerHost; + logger: Logger; + cancellationToken: HostCancellationToken; + useSingleInferredProject: boolean; + typingsInstaller: ITypingsInstaller; + eventHandler?: ProjectServiceEventHandler; + throttleWaitMilliseconds?: number; + globalPlugins?: string[]; + pluginProbeLocations?: string[]; + } class ProjectService { - readonly host: ServerHost; - readonly logger: Logger; - readonly cancellationToken: HostCancellationToken; - readonly useSingleInferredProject: boolean; - readonly typingsInstaller: ITypingsInstaller; - private readonly eventHandler; readonly typingsCache: TypingsCache; private readonly documentRegistry; private readonly filenameToScriptInfo; @@ -4826,13 +5059,24 @@ declare namespace ts.server { readonly openFiles: ScriptInfo[]; private compilerOptionsForInferredProjects; private compileOnSaveForInferredProjects; + private readonly projectToSizeMap; private readonly directoryWatchers; private readonly throttledOperations; private readonly hostConfiguration; + private static safelist; private changedFiles; readonly toCanonicalFileName: (f: string) => string; lastDeletedFile: ScriptInfo; - constructor(host: ServerHost, logger: Logger, cancellationToken: HostCancellationToken, useSingleInferredProject: boolean, typingsInstaller?: ITypingsInstaller, eventHandler?: ProjectServiceEventHandler); + readonly host: ServerHost; + readonly logger: Logger; + readonly cancellationToken: HostCancellationToken; + readonly useSingleInferredProject: boolean; + readonly typingsInstaller: ITypingsInstaller; + readonly throttleWaitMilliseconds?: number; + private readonly eventHandler?; + readonly globalPlugins: ReadonlyArray; + readonly pluginProbeLocations: ReadonlyArray; + constructor(opts: ProjectServiceOptions); ensureInferredProjectsUpToDate_TestOnly(): void; getCompilerOptionsForInferredProjects(): CompilerOptions; onUpdateLanguageServiceStateForProject(project: Project, languageServiceEnabled: boolean): void; @@ -4856,13 +5100,13 @@ declare namespace ts.server { private removeProject(project); private assignScriptInfoToInferredProjectIfNecessary(info, addToListOfOpenFiles); private closeOpenFile(info); - private openOrUpdateConfiguredProjectForFile(fileName); - private findConfigFile(searchPath); + private openOrUpdateConfiguredProjectForFile(fileName, projectRootPath?); + private findConfigFile(searchPath, projectRootPath?); private printProjects(); private findConfiguredProjectByProjectName(configFileName); private findExternalProjectByProjectName(projectFileName); private convertConfigFileContentToProjectOptions(configFilename); - private exceededTotalSizeLimitForNonTsFiles(options, fileNames, propertyReader); + private exceededTotalSizeLimitForNonTsFiles(name, options, fileNames, propertyReader); private createAndAddExternalProject(projectFileName, files, options, typeAcquisition); private reportConfigFileDiagnostics(configFileName, diagnostics, triggerFile); private createAndAddConfiguredProject(configFileName, projectOptions, configFileErrors, clientFileName?); @@ -4881,13 +5125,18 @@ declare namespace ts.server { closeLog(): void; reloadProjects(): void; refreshInferredProjects(): void; - openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind): OpenConfiguredProjectResult; - openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean): OpenConfiguredProjectResult; + openClientFile(fileName: string, fileContent?: string, scriptKind?: ScriptKind, projectRootPath?: string): OpenConfiguredProjectResult; + openClientFileWithNormalizedPath(fileName: NormalizedPath, fileContent?: string, scriptKind?: ScriptKind, hasMixedContent?: boolean, projectRootPath?: NormalizedPath): OpenConfiguredProjectResult; closeClientFile(uncheckedFileName: string): void; private collectChanges(lastKnownProjectVersions, currentProjects, result); private closeConfiguredProject(configFile); closeExternalProject(uncheckedFileName: string, suppressRefresh?: boolean): void; openExternalProjects(projects: protocol.ExternalProject[]): void; + private static filenameEscapeRegexp; + private static escapeFilenameForRegex(filename); + resetSafeList(): void; + loadSafeList(fileName: string): void; + applySafeList(proj: protocol.ExternalProject): void; openExternalProject(proj: protocol.ExternalProject, suppressRefreshOfInferredProjects?: boolean): void; } } diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index 38fcfa5c6b5..52c8a2207c4 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -13,6 +13,14 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || @@ -38,326 +46,324 @@ var ts; SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; - SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; - SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; - SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; - SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; - SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; - SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; - SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; - SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; - SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; - SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; - SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; - SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; - SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; - SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 126] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 127] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 128] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 129] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 130] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 131] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 132] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 133] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 134] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 135] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 136] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 137] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 138] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 139] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 140] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 141] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 142] = "OfKeyword"; + SyntaxKind[SyntaxKind["QualifiedName"] = 143] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 144] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["TypeParameter"] = 145] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 146] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 147] = "Decorator"; + SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 149] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 151] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 152] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 153] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 154] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 155] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 156] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 157] = "IndexSignature"; + SyntaxKind[SyntaxKind["TypePredicate"] = 158] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 159] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 160] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 161] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 162] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 163] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 164] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 165] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 166] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 167] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 168] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 169] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 170] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 171] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 172] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 173] = "LiteralType"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 174] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 175] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 176] = "BindingElement"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 177] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 178] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 179] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 180] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 181] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 182] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 183] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 184] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 185] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 187] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 188] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 189] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 190] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 191] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 192] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 193] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 194] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 195] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 196] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 197] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 198] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 199] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 200] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 201] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 202] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 203] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 204] = "MetaProperty"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 205] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 206] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["Block"] = 207] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 208] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 209] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 210] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 211] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 212] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 213] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 214] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 215] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 216] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 217] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 218] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 219] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 220] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 221] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 222] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 223] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 224] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 225] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 226] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 227] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 228] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 229] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 230] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 231] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 232] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 233] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 234] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 235] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 236] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 237] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 238] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 239] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 240] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 241] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 242] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 243] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 244] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 245] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 246] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 247] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 248] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["JsxElement"] = 249] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 250] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 251] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 252] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 253] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 254] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 255] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 256] = "JsxExpression"; + SyntaxKind[SyntaxKind["CaseClause"] = 257] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 258] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 259] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 260] = "CatchClause"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 261] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 262] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 263] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["EnumMember"] = 264] = "EnumMember"; + SyntaxKind[SyntaxKind["SourceFile"] = 265] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 266] = "Bundle"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 267] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 268] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 269] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 270] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 271] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 272] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 273] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 274] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 275] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 276] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 277] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 278] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 279] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 280] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 281] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 282] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 283] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 284] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 285] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 286] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 287] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 288] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 289] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 290] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 291] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 293] = "JSDocLiteralType"; + SyntaxKind[SyntaxKind["SyntaxList"] = 294] = "SyntaxList"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 295] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 296] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 297] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 298] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["Count"] = 299] = "Count"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 142] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 158] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 173] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 142] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 143] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 267] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 293] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 283] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 293] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -429,6 +435,16 @@ var ts; GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 2] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["HexSpecifier"] = 8] = "HexSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinarySpecifier"] = 16] = "BinarySpecifier"; + NumericLiteralFlags[NumericLiteralFlags["OctalSpecifier"] = 32] = "OctalSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalSpecifier"] = 48] = "BinaryOrOctalSpecifier"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -459,6 +475,16 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + NodeBuilderFlags[NodeBuilderFlags["allowThisInObjectLiteral"] = 1] = "allowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["allowQualifedNameInPlaceOfIdentifier"] = 2] = "allowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowTypeParameterInQualifiedName"] = 4] = "allowTypeParameterInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["allowAnonymousIdentifier"] = 8] = "allowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyUnionOrIntersection"] = 16] = "allowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyTuple"] = 32] = "allowEmptyTuple"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); var TypeFormatFlags; (function (TypeFormatFlags) { TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; @@ -582,13 +608,15 @@ var ts; (function (CheckFlags) { CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; - CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; - CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; - CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; - CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; - CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; - CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; - CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod"; + CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 16] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; + CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); var NodeCheckFlags; (function (NodeCheckFlags) { @@ -674,7 +702,6 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -694,6 +721,7 @@ var ts; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ModuleExports"] = 2] = "ModuleExports"; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property"; })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -974,13 +1002,15 @@ var ts; EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; - EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; - EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName"; + EmitFlags[EmitFlags["Indented"] = 65536] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); var ExternalEmitHelpers; (function (ExternalEmitHelpers) { @@ -992,8 +1022,17 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values"; + ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read"; + ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 2048] = "AsyncGenerator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 4096] = "AsyncDelegator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 8192] = "AsyncValues"; + ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 8192] = "ForAwaitOfIncludes"; + ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes"; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; - ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 8192] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); var EmitHint; (function (EmitHint) { @@ -1064,7 +1103,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.3.0"; + ts.version = "2.4.0"; })(ts || (ts = {})); (function (ts) { var Ternary; @@ -1228,6 +1267,20 @@ var ts; return undefined; } ts.forEach = forEach; + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; function zipWith(arrayA, arrayB, callback) { Debug.assert(arrayA.length === arrayB.length); for (var i = 0; i < arrayA.length; i++) { @@ -1781,10 +1834,10 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function arrayFrom(iterator) { + function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { - result.push(value); + result.push(map ? map(value) : value); } return result; var _b; @@ -1837,10 +1890,10 @@ var ts; } for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { var arg = args_1[_a]; - for (var _b = 0, _c = getOwnKeys(arg); _b < _c.length; _b++) { - var p = _c[_b]; - t[p] = arg[p]; - } + for (var p in arg) + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } } return t; } @@ -2980,136 +3033,29 @@ var ts; } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; + function isCheckJsEnabledForFile(sourceFile, compilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; })(ts || (ts = {})); var ts; (function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var shell = new ActiveXObject("WScript.Shell"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function getDirectories(path) { - var folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - function getAccessibleFileSystemEntries(path) { - try { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - var directories = getNames(folder.subfolders); - return { files: files, directories: directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function readDirectory(path, extensions, excludes, includes) { - return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - var wscriptSystem = { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return shell.CurrentDirectory; - }, - getDirectories: getDirectories, - getEnvironmentVariable: function (name) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings("%" + name + "%"); - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; + function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; } + var version = process.version; + if (!version) { + return undefined; + } + var dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + ts.getNodeMajorVersion = getNodeMajorVersion; + ts.sys = (function () { function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); @@ -3173,9 +3119,8 @@ var ts; } } var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } + var nodeVersion = getNodeMajorVersion(); + var isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive() { if (platform === "win32" || platform === "win64") { return false; @@ -3314,10 +3259,10 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + if (!directoryExists(directoryName)) { return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { @@ -3327,11 +3272,7 @@ var ts; if (eventName === "rename") { callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName))); } - ; }); - function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; - } }, resolvePath: function (path) { return _path.resolve(path); @@ -3447,9 +3388,6 @@ var ts; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { sys = getNodeSystem(); } @@ -3518,11 +3456,11 @@ var ts; Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", message: "The return type of an async function must either be a valid promise or must not contain a callable 'then' member." }, + A_promise_must_have_a_then_method: { code: 1059, category: ts.DiagnosticCategory.Error, key: "A_promise_must_have_a_then_method_1059", message: "A promise must have a 'then' method." }, + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: { code: 1060, category: ts.DiagnosticCategory.Error, key: "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", message: "The first parameter of the 'then' method of a promise must be a callback." }, 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." }, + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "Type 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." }, @@ -3547,6 +3485,7 @@ var ts; Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: { code: 1103, category: ts.DiagnosticCategory.Error, key: "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", message: "A 'for-await-of' statement is only allowed within an async function or async generator." }, A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, @@ -3554,7 +3493,7 @@ var ts; Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'." }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, @@ -3586,9 +3525,9 @@ var ts; 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_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." }, - 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" }, + 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" }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized." }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, @@ -3637,8 +3576,8 @@ var ts; Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_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." }, @@ -3690,6 +3629,9 @@ var ts; A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1320, category: ts.DiagnosticCategory.Error, key: "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", message: "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1321, category: ts.DiagnosticCategory.Error, key: "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", message: "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1322, category: ts.DiagnosticCategory.Error, key: "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", message: "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -3751,13 +3693,13 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'." }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, @@ -3797,12 +3739,12 @@ var ts; The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class." }, The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - 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_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}'." }, 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}'." }, @@ -3811,19 +3753,19 @@ var ts; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, 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}'" }, + 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_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}'" }, + 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." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged." }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged." }, Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name." }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'." }, Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'." }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, @@ -3832,18 +3774,20 @@ 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." }, + Class_0_used_before_its_declaration: { code: 2449, category: ts.DiagnosticCategory.Error, key: "Class_0_used_before_its_declaration_2449", message: "Class '{0}' used before its declaration." }, + Enum_0_used_before_its_declaration: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Enum_0_used_before_its_declaration_2450", message: "Enum '{0}' used before its declaration." }, 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." }, Variable_0_is_used_before_being_assigned: { code: 2454, category: ts.DiagnosticCategory.Error, key: "Variable_0_is_used_before_being_assigned_2454", message: "Variable '{0}' is used before being assigned." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'." }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern." }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -3864,13 +3808,13 @@ var ts; let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, 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}'" }, + 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_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, 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." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause." }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, @@ -3882,6 +3826,7 @@ var ts; A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: { code: 2504, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", message: "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, @@ -3896,6 +3841,7 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, + An_async_iterator_must_have_a_next_method: { code: 2519, category: ts.DiagnosticCategory.Error, key: "An_async_iterator_must_have_a_next_method_2519", message: "An async iterator must have a 'next()' method." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", message: "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method." }, @@ -3923,25 +3869,29 @@ var ts; Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, + The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: { code: 2547, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", message: "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property." }, + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2548, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", message: "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2549, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", message: "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: { code: 2550, category: ts.DiagnosticCategory.Error, key: "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", message: "Generic type instantiation is excessively deep and possibly infinite." }, 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." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'." }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property." }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property." }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React." }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, - Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element." }, + Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'." }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", message: "Cannot export '{0}'. Only local declarations can be exported from a module." }, @@ -3973,7 +3923,6 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, - A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { code: 2693, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", message: "'{0}' only refers to a type, but is being used as a value here." }, @@ -3986,11 +3935,14 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, - The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference." }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property." }, An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, + Cannot_use_namespace_0_as_a_value: { code: 2708, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_value_2708", message: "Cannot use namespace '{0}' as a value." }, + Cannot_use_namespace_0_as_a_type: { code: 2709, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_type_2709", message: "Cannot use namespace '{0}' as a type." }, + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: { code: 2710, category: ts.DiagnosticCategory.Error, key: "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", message: "'{0}' are specified twice. The attribute named '{0}' will be overwritten." }, 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}'." }, @@ -4070,12 +4022,11 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { code: 5011, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011", message: "File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}." }, Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", message: "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, @@ -4084,12 +4035,12 @@ var ts; A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, 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}'" }, + 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}'." }, 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" }, + 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." }, Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." }, Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, @@ -4107,11 +4058,11 @@ var ts; Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'." }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -4131,7 +4082,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_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}" }, + Argument_for_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}." }, 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}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, @@ -4153,18 +4104,18 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context (experimental)." }, Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'." }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, 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}." }, 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." }, - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", message: "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit" }, Enable_tracing_of_the_name_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_name_resolution_process_6085", message: "Enable tracing of the name 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}'." }, @@ -4186,12 +4137,12 @@ var ts; 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_0_field_in_package_json_to_be_string_got_1: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", message: "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'." }, - 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" }, + 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." }, Enable_strict_null_checks: { code: 6113, category: ts.DiagnosticCategory.Message, key: "Enable_strict_null_checks_6113", message: "Enable strict null checks." }, Unknown_option_excludes_Did_you_mean_exclude: { code: 6114, category: ts.DiagnosticCategory.Error, key: "Unknown_option_excludes_Did_you_mean_exclude_6114", message: "Unknown option 'excludes'. Did you mean 'exclude'?" }, @@ -4201,26 +4152,26 @@ var ts; Resolving_from_node_modules_folder: { code: 6118, category: ts.DiagnosticCategory.Message, key: "Resolving_from_node_modules_folder_6118", message: "Resolving from node_modules folder..." }, Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { code: 6119, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", message: "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========" }, Type_reference_directive_0_was_not_resolved: { code: 6120, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_not_resolved_6120", message: "======== Type reference directive '{0}' was not resolved. ========" }, - Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'" }, + Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'." }, Root_directory_cannot_be_determined_skipping_primary_search_paths: { code: 6122, category: ts.DiagnosticCategory.Message, key: "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", message: "Root directory cannot be determined, skipping primary search paths." }, Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { code: 6123, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", message: "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========" }, Type_declaration_files_to_be_included_in_compilation: { code: 6124, category: ts.DiagnosticCategory.Message, key: "Type_declaration_files_to_be_included_in_compilation_6124", message: "Type declaration files to be included in compilation." }, - Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'" }, + Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'." }, Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { code: 6126, category: ts.DiagnosticCategory.Message, key: "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", message: "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { code: 6127, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", message: "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========" }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" }, The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." }, - Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, + Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'." }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, - File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it." }, _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files." }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file." }, Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, @@ -4228,6 +4179,40 @@ var ts; Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, + Show_diagnostic_information: { code: 6149, category: ts.DiagnosticCategory.Message, key: "Show_diagnostic_information_6149", message: "Show diagnostic information." }, + Show_verbose_diagnostic_information: { code: 6150, category: ts.DiagnosticCategory.Message, key: "Show_verbose_diagnostic_information_6150", message: "Show verbose diagnostic information." }, + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: { code: 6151, category: ts.DiagnosticCategory.Message, key: "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", message: "Emit a single file with source maps instead of having a separate file." }, + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: { code: 6152, category: ts.DiagnosticCategory.Message, key: "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", message: "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set." }, + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: { code: 6153, category: ts.DiagnosticCategory.Message, key: "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", message: "Transpile each file as a separate module (similar to 'ts.transpileModule')." }, + Print_names_of_generated_files_part_of_the_compilation: { code: 6154, category: ts.DiagnosticCategory.Message, key: "Print_names_of_generated_files_part_of_the_compilation_6154", message: "Print names of generated files part of the compilation." }, + Print_names_of_files_part_of_the_compilation: { code: 6155, category: ts.DiagnosticCategory.Message, key: "Print_names_of_files_part_of_the_compilation_6155", message: "Print names of files part of the compilation." }, + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: { code: 6156, category: ts.DiagnosticCategory.Message, key: "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", message: "The locale used when displaying messages to the user (e.g. 'en-us')" }, + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: { code: 6157, category: ts.DiagnosticCategory.Message, key: "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", message: "Do not generate custom helper functions like '__extends' in compiled output." }, + Do_not_include_the_default_library_file_lib_d_ts: { code: 6158, category: ts.DiagnosticCategory.Message, key: "Do_not_include_the_default_library_file_lib_d_ts_6158", message: "Do not include the default library file (lib.d.ts)." }, + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: { code: 6159, category: ts.DiagnosticCategory.Message, key: "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", message: "Do not add triple-slash references or imported modules to the list of compiled files." }, + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: { code: 6160, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", message: "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files." }, + List_of_folders_to_include_type_definitions_from: { code: 6161, category: ts.DiagnosticCategory.Message, key: "List_of_folders_to_include_type_definitions_from_6161", message: "List of folders to include type definitions from." }, + Disable_size_limitations_on_JavaScript_projects: { code: 6162, category: ts.DiagnosticCategory.Message, key: "Disable_size_limitations_on_JavaScript_projects_6162", message: "Disable size limitations on JavaScript projects." }, + The_character_set_of_the_input_files: { code: 6163, category: ts.DiagnosticCategory.Message, key: "The_character_set_of_the_input_files_6163", message: "The character set of the input files." }, + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: { code: 6164, category: ts.DiagnosticCategory.Message, key: "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", message: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." }, + Do_not_truncate_error_messages: { code: 6165, category: ts.DiagnosticCategory.Message, key: "Do_not_truncate_error_messages_6165", message: "Do not truncate error messages." }, + Output_directory_for_generated_declaration_files: { code: 6166, category: ts.DiagnosticCategory.Message, key: "Output_directory_for_generated_declaration_files_6166", message: "Output directory for generated declaration files." }, + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: { code: 6167, category: ts.DiagnosticCategory.Message, key: "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", message: "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'." }, + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: { code: 6168, category: ts.DiagnosticCategory.Message, key: "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", message: "List of root folders whose combined content represents the structure of the project at runtime." }, + Show_all_compiler_options: { code: 6169, category: ts.DiagnosticCategory.Message, key: "Show_all_compiler_options_6169", message: "Show all compiler options." }, + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: { code: 6170, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", message: "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file" }, + Command_line_Options: { code: 6171, category: ts.DiagnosticCategory.Message, key: "Command_line_Options_6171", message: "Command-line Options" }, + Basic_Options: { code: 6172, category: ts.DiagnosticCategory.Message, key: "Basic_Options_6172", message: "Basic Options" }, + Strict_Type_Checking_Options: { code: 6173, category: ts.DiagnosticCategory.Message, key: "Strict_Type_Checking_Options_6173", message: "Strict Type-Checking Options" }, + Module_Resolution_Options: { code: 6174, category: ts.DiagnosticCategory.Message, key: "Module_Resolution_Options_6174", message: "Module Resolution Options" }, + Source_Map_Options: { code: 6175, category: ts.DiagnosticCategory.Message, key: "Source_Map_Options_6175", message: "Source Map Options" }, + Additional_Checks: { code: 6176, category: ts.DiagnosticCategory.Message, key: "Additional_Checks_6176", message: "Additional Checks" }, + Experimental_Options: { code: 6177, category: ts.DiagnosticCategory.Message, key: "Experimental_Options_6177", message: "Experimental Options" }, + Advanced_Options: { code: 6178, category: ts.DiagnosticCategory.Message, key: "Advanced_Options_6178", message: "Advanced Options" }, + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: { code: 6179, category: ts.DiagnosticCategory.Message, key: "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", message: "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'." }, + Enable_all_strict_type_checking_options: { code: 6180, category: ts.DiagnosticCategory.Message, key: "Enable_all_strict_type_checking_options_6180", message: "Enable all strict type-checking options." }, + List_of_language_service_plugins: { code: 6181, category: ts.DiagnosticCategory.Message, key: "List_of_language_service_plugins_6181", message: "List of language service plugins." }, + Scoped_package_detected_looking_in_0: { code: 6182, category: ts.DiagnosticCategory.Message, key: "Scoped_package_detected_looking_in_0_6182", message: "Scoped package detected, looking in '{0}'" }, 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." }, @@ -4245,7 +4230,7 @@ var ts; _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists." }, Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, @@ -4254,6 +4239,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, + Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: { code: 7035, category: ts.DiagnosticCategory.Error, key: "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", message: "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4277,14 +4263,14 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + 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." }, 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." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" }, Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, @@ -4293,151 +4279,158 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: '{0}'." }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig." }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, - Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, - Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, - Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}." }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}." }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." }, + Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." }, + Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'." }, + Disable_checking_for_this_file: { code: 90018, category: ts.DiagnosticCategory.Message, key: "Disable_checking_for_this_file_90018", message: "Disable checking for this file." }, + Ignore_this_error_message: { code: 90019, category: ts.DiagnosticCategory.Message, key: "Ignore_this_error_message_90019", message: "Ignore this error message." }, + Initialize_property_0_in_the_constructor: { code: 90020, category: ts.DiagnosticCategory.Message, key: "Initialize_property_0_in_the_constructor_90020", message: "Initialize property '{0}' in the constructor." }, + Initialize_static_property_0: { code: 90021, category: ts.DiagnosticCategory.Message, key: "Initialize_static_property_0_90021", message: "Initialize static property '{0}'." }, Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, + Report_errors_in_js_files: { code: 8019, category: ts.DiagnosticCategory.Message, key: "Report_errors_in_js_files_8019", message: "Report errors in .js files." }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 70; + return token >= 71; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMapFromTemplate({ - "abstract": 116, - "any": 118, - "as": 117, - "boolean": 121, - "break": 71, - "case": 72, - "catch": 73, - "class": 74, - "continue": 76, - "const": 75, - "constructor": 122, - "debugger": 77, - "declare": 123, - "default": 78, - "delete": 79, - "do": 80, - "else": 81, - "enum": 82, - "export": 83, - "extends": 84, - "false": 85, - "finally": 86, - "for": 87, - "from": 139, - "function": 88, - "get": 124, - "if": 89, - "implements": 107, - "import": 90, - "in": 91, - "instanceof": 92, - "interface": 108, - "is": 125, - "keyof": 126, - "let": 109, - "module": 127, - "namespace": 128, - "never": 129, - "new": 93, - "null": 94, - "number": 132, - "object": 133, - "package": 110, - "private": 111, - "protected": 112, - "public": 113, - "readonly": 130, - "require": 131, - "global": 140, - "return": 95, - "set": 134, - "static": 114, - "string": 135, - "super": 96, - "switch": 97, - "symbol": 136, - "this": 98, - "throw": 99, - "true": 100, - "try": 101, - "type": 137, - "typeof": 102, - "undefined": 138, - "var": 103, - "void": 104, - "while": 105, - "with": 106, - "yield": 115, - "async": 119, - "await": 120, - "of": 141, - "{": 16, - "}": 17, - "(": 18, - ")": 19, - "[": 20, - "]": 21, - ".": 22, - "...": 23, - ";": 24, - ",": 25, - "<": 26, - ">": 28, - "<=": 29, - ">=": 30, - "==": 31, - "!=": 32, - "===": 33, - "!==": 34, - "=>": 35, - "+": 36, - "-": 37, - "**": 39, - "*": 38, - "/": 40, - "%": 41, - "++": 42, - "--": 43, - "<<": 44, - ">": 45, - ">>>": 46, - "&": 47, - "|": 48, - "^": 49, - "!": 50, - "~": 51, - "&&": 52, - "||": 53, - "?": 54, - ":": 55, - "=": 57, - "+=": 58, - "-=": 59, - "*=": 60, - "**=": 61, - "/=": 62, - "%=": 63, - "<<=": 64, - ">>=": 65, - ">>>=": 66, - "&=": 67, - "|=": 68, - "^=": 69, - "@": 56, + "abstract": 117, + "any": 119, + "as": 118, + "boolean": 122, + "break": 72, + "case": 73, + "catch": 74, + "class": 75, + "continue": 77, + "const": 76, + "constructor": 123, + "debugger": 78, + "declare": 124, + "default": 79, + "delete": 80, + "do": 81, + "else": 82, + "enum": 83, + "export": 84, + "extends": 85, + "false": 86, + "finally": 87, + "for": 88, + "from": 140, + "function": 89, + "get": 125, + "if": 90, + "implements": 108, + "import": 91, + "in": 92, + "instanceof": 93, + "interface": 109, + "is": 126, + "keyof": 127, + "let": 110, + "module": 128, + "namespace": 129, + "never": 130, + "new": 94, + "null": 95, + "number": 133, + "object": 134, + "package": 111, + "private": 112, + "protected": 113, + "public": 114, + "readonly": 131, + "require": 132, + "global": 141, + "return": 96, + "set": 135, + "static": 115, + "string": 136, + "super": 97, + "switch": 98, + "symbol": 137, + "this": 99, + "throw": 100, + "true": 101, + "try": 102, + "type": 138, + "typeof": 103, + "undefined": 139, + "var": 104, + "void": 105, + "while": 106, + "with": 107, + "yield": 116, + "async": 120, + "await": 121, + "of": 142, + "{": 17, + "}": 18, + "(": 19, + ")": 20, + "[": 21, + "]": 22, + ".": 23, + "...": 24, + ";": 25, + ",": 26, + "<": 27, + ">": 29, + "<=": 30, + ">=": 31, + "==": 32, + "!=": 33, + "===": 34, + "!==": 35, + "=>": 36, + "+": 37, + "-": 38, + "**": 40, + "*": 39, + "/": 41, + "%": 42, + "++": 43, + "--": 44, + "<<": 45, + ">": 46, + ">>>": 47, + "&": 48, + "|": 49, + "^": 50, + "!": 51, + "~": 52, + "&&": 53, + "||": 54, + "?": 55, + ":": 56, + "=": 58, + "+=": 59, + "-=": 60, + "*=": 61, + "**=": 62, + "/=": 63, + "%=": 64, + "<<=": 65, + ">>=": 66, + ">>>=": 67, + "&=": 68, + "|=": 69, + "^=": 70, + "@": 57, }); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -4549,10 +4542,10 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function isWhiteSpace(ch) { + function isWhiteSpaceLike(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - ts.isWhiteSpace = isWhiteSpace; + ts.isWhiteSpaceLike = isWhiteSpaceLike; function isWhiteSpaceSingleLine(ch) { return ch === 32 || ch === 9 || @@ -4668,7 +4661,7 @@ var ts; } break; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -4802,7 +4795,7 @@ var ts; } break scan; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -4837,7 +4830,7 @@ var ts; if (!comments) { comments = []; } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine }); return comments; } function getLeadingCommentRanges(text, pos) { @@ -4889,6 +4882,7 @@ var ts; var precedingLineBreak; var hasExtendedUnicodeEscape; var tokenIsUnterminated; + var numericLiteralFlags; setText(text, start, length); return { getStartPos: function () { return startPos; }, @@ -4899,9 +4893,10 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 70 || token > 106; }, - isReservedWord: function () { return token >= 71 && token <= 106; }, + isIdentifier: function () { return token === 71 || token > 107; }, + isReservedWord: function () { return token >= 72 && token <= 107; }, isUnterminated: function () { return tokenIsUnterminated; }, + getNumericLiteralFlags: function () { return numericLiteralFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, @@ -4938,6 +4933,7 @@ var ts; var end = pos; if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { pos++; + numericLiteralFlags = 2; if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++; if (isDigit(text.charCodeAt(pos))) { @@ -5036,20 +5032,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 13 : 14; + resultingToken = startedWithBacktick ? 14 : 15; break; } if (currChar === 92) { @@ -5214,7 +5210,7 @@ var ts; } } } - return token = 70; + return token = 71; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5240,6 +5236,7 @@ var ts; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -5289,12 +5286,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 34; + return pos += 3, token = 35; } - return pos += 2, token = 32; + return pos += 2, token = 33; } pos++; - return token = 50; + return token = 51; case 34: case 39: tokenValue = scanString(); @@ -5303,51 +5300,39 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } pos++; - return token = 41; + return token = 42; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 52; + return pos += 2, token = 53; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; - return token = 47; + return token = 48; case 40: pos++; - return token = 18; + return token = 19; case 41: pos++; - return token = 19; + return token = 20; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 61; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 62; } - return pos += 2, token = 39; + return pos += 2, token = 40; } pos++; - return token = 38; + return token = 39; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 44: - pos++; - return token = 25; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { @@ -5355,16 +5340,28 @@ var ts; } pos++; return token = 37; + case 44: + pos++; + return token = 26; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + pos++; + return token = 38; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 23; + return pos += 3, token = 24; } pos++; - return token = 22; + return token = 23; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -5408,10 +5405,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -5421,6 +5418,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 8; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { @@ -5431,6 +5429,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 16; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { @@ -5441,10 +5440,12 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 32; return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = 4; return token = 8; } case 49: @@ -5460,10 +5461,10 @@ var ts; return token = 8; case 58: pos++; - return token = 55; + return token = 56; case 59: pos++; - return token = 24; + return token = 25; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5476,20 +5477,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 64; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 29; + return pos += 2, token = 30; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 27; + return pos += 2, token = 28; } pos++; - return token = 26; + return token = 27; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5502,15 +5503,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 35; + return pos += 2, token = 36; } pos++; - return token = 57; + return token = 58; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -5522,43 +5523,43 @@ var ts; } } pos++; - return token = 28; + return token = 29; case 63: pos++; - return token = 54; + return token = 55; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 70; + } + pos++; + return token = 50; + case 123: + pos++; + return token = 17; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 54; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 69; } pos++; return token = 49; - case 123: - pos++; - return token = 16; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 53; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; case 125: pos++; - return token = 17; + return token = 18; case 126: pos++; - return token = 51; + return token = 52; case 64: pos++; - return token = 56; + return token = 57; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -5596,29 +5597,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 28) { + if (token === 29) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 66; + return pos += 3, token = 67; } - return pos += 2, token = 46; + return pos += 2, token = 47; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 66; } pos++; - return token = 45; + return token = 46; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 30; + return token = 31; } } return token; } function reScanSlashToken() { - if (token === 40 || token === 62) { + if (token === 41 || token === 63) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -5657,12 +5658,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 11; + token = 12; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 18, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -5679,23 +5680,37 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 27; + return token = 28; } pos++; - return token = 26; + return token = 27; } if (char === 123) { pos++; - return token = 16; + return token = 17; } + var firstNonWhitespace = 0; while (pos < end) { - pos++; char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { + if (char === 123) { break; } + if (char === 60) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = 7; + } + break; + } + if (isLineBreak(char) && firstNonWhitespace === 0) { + firstNonWhitespace = -1; + } + else if (!isWhiteSpaceLike(char)) { + firstNonWhitespace = pos; + } + pos++; } - return token = 10; + return firstNonWhitespace === -1 ? 11 : 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -5742,42 +5757,42 @@ var ts; return token = 5; case 64: pos++; - return token = 56; + return token = 57; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 38; + return token = 39; case 123: pos++; - return token = 16; + return token = 17; case 125: pos++; - return token = 17; + return token = 18; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 61: pos++; - return token = 57; + return token = 58; case 44: pos++; - return token = 25; + return token = 26; case 46: pos++; - return token = 22; + return token = 23; } if (isIdentifierStart(ch, 5)) { pos++; while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } - return token = 70; + return token = 71; } else { return pos += 1, token = 0; @@ -5865,40 +5880,12 @@ var ts; (function (ts) { ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, }, { @@ -5906,215 +5893,52 @@ var ts; shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMapFromTemplate({ - "preserve": 1, - "react-native": 3, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMapFromTemplate({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMapFromTemplate({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, { name: "project", shortName: "p", type: "string", isFilePath: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { - name: "removeComments", + name: "pretty", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", + name: "watch", + shortName: "w", type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Watch_input_files, }, { name: "target", @@ -6128,133 +5952,27 @@ var ts; "es2017": 4, "esnext": 5, }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, paramType: ts.Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", + name: "module", + shortName: "m", type: ts.createMapFromTemplate({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - 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: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_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 - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -6268,6 +5986,7 @@ var ts; "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", "webworker": "lib.webworker.d.ts", @@ -6285,29 +6004,466 @@ var ts; "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1, + "react-native": 3, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + { + name: "noUnusedLocals", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + paramType: ts.Diagnostics.STRATEGY, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + { + name: "experimentalDecorators", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "jsxFactory", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + { + name: "out", + type: "string", + isFilePath: false, + category: ts.Diagnostics.Advanced_Options, + paramType: ts.Diagnostics.FILE, + description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0, + "lf": 1 + }), + paramType: ts.Diagnostics.NEWLINE, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, { name: "plugins", type: "list", @@ -6315,7 +6471,8 @@ var ts; element: { name: "plugin", type: "object" - } + }, + description: ts.Diagnostics.List_of_language_service_plugins } ]; ts.typeAcquisitionDeclarations = [ @@ -6347,8 +6504,7 @@ var ts; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1, - noImplicitAny: false, - sourceMap: false, + strict: true }; var optionNameMapCache; function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -6539,7 +6695,7 @@ var ts; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { + function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -6547,7 +6703,7 @@ var ts; if (fileNames && fileNames.length) { configurations.files = fileNames; } - return configurations; + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition) { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { return undefined; @@ -6571,41 +6727,110 @@ var ts; var optionsNameMap = getOptionNameMap().optionNameMap; for (var name in options) { if (ts.hasProperty(options, name)) { - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + continue; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return ts.arrayFrom(option.type.keys())[0]; + } + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + var categorizedOptions = ts.reduceLeft(ts.filter(ts.optionDeclarations, function (o) { return o.category !== ts.Diagnostics.Command_line_Options && o.category !== ts.Diagnostics.Advanced_Options; }), function (memo, value) { + if (value.category) { + var name = ts.getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, {}); + var marginLength = 0; + var seenKnownKeys = 0; + var nameColumn = []; + var descriptionColumn = []; + var knownKeysCount = ts.getOwnKeys(configurations.compilerOptions).length; + for (var category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push("/* " + category + " */"); + descriptionColumn.push(""); + for (var _i = 0, _a = categorizedOptions[category]; _i < _a.length; _i++) { + var option = _a[_i]; + var optionName = void 0; + if (ts.hasProperty(configurations.compilerOptions, option.name)) { + optionName = "\"" + option.name + "\": " + JSON.stringify(configurations.compilerOptions[option.name]) + ((seenKnownKeys += 1) === knownKeysCount ? "" : ","); + } + else { + optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + } + nameColumn.push(optionName); + descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + marginLength = Math.max(optionName.length, marginLength); + } + } + var tab = makePadding(2); + var result = []; + result.push("{"); + result.push(tab + "\"compilerOptions\": {"); + for (var i = 0; i < nameColumn.length; i++) { + var optionName = nameColumn[i]; + var description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(tab + "},"); + result.push(tab + "\"files\": ["); + for (var i = 0; i < configurations.files.length; i++) { + result.push("" + tab + tab + JSON.stringify(configurations.files[i]) + (i === configurations.files.length - 1 ? "" : ",")); + } + result.push(tab + "]"); + } + else { + result.push(tab + "}"); + } + result.push("}"); + return result.join(newLine); + } } ts.generateTSConfig = generateTSConfig; function removeComments(jsonText) { @@ -6646,10 +6871,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -6669,6 +6895,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -6706,7 +6935,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -6949,7 +7178,6 @@ var ts; } } } - ; } return wildcardDirectories; } @@ -7082,7 +7310,7 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) { var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -7250,7 +7478,7 @@ var ts; } directoryPathMap.set(parent, result); current = parent; - if (current == commonPrefix) { + if (current === commonPrefix) { break; } } @@ -7672,9 +7900,22 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } + function mangleScopedPackage(moduleName, state) { + if (ts.startsWith(moduleName, "@")) { + var replaceSlash = moduleName.replace(ts.directorySeparator, "__"); + if (replaceSlash !== moduleName) { + var mangled = replaceSlash.slice(1); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled); + } + return mangled; + } + } + return moduleName; + } function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { var result = cache && cache.get(containingDirectory); if (result) { @@ -7878,7 +8119,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 264) { + while (node && node.kind !== 265) { node = node.parent; } return node; @@ -7886,11 +8127,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 206: - case 234: - case 213: + case 207: + case 235: case 214: case 215: + case 216: return true; } return false; @@ -7945,6 +8186,10 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isToken(n) { + return n.kind >= 0 && n.kind <= 142; + } + ts.isToken = isToken; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { if (nodeIsMissing(node)) { return node.pos; @@ -7955,18 +8200,18 @@ var ts; if (includeJsDoc && node.jsDoc && node.jsDoc.length > 0) { return getTokenPosOfNode(node.jsDoc[0]); } - if (node.kind === 296 && node._children.length > 0) { + if (node.kind === 294 && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 266 && node.kind <= 295; + return node.kind >= 267 && node.kind <= 293; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 282 && node.kind <= 295; + return node.kind >= 283 && node.kind <= 293; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -7997,27 +8242,20 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - if (languageVersion < 2 && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } + function getLiteralText(node, sourceFile) { if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; + return getSourceTextOfNodeFromSourceFile(sourceFile, node); } switch (node.kind) { case 9: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12: - return getQuotedEscapedLiteralText("`", node.text, "`"); case 13: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "`"); case 14: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return getQuotedEscapedLiteralText("`", node.text, "${"); case 15: + return getQuotedEscapedLiteralText("}", node.text, "${"); + case 16: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8: return node.text; @@ -8025,48 +8263,6 @@ var ts; ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - return node.kind === 8 - && (getNumericLiteralFlags(text, 6) & 6) !== 0; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - var NumericLiteralFlags; - (function (NumericLiteralFlags) { - NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; - NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; - NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; - NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; - })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); - function getNumericLiteralFlags(text, hint) { - if (text.length > 1) { - switch (text.charCodeAt(1)) { - case 98: - case 66: - return 2; - case 111: - case 79: - return 4; - case 120: - case 88: - return 1; - } - if (hint & 8) { - for (var i = text.length - 1; i >= 0; i--) { - switch (text.charCodeAt(i)) { - case 101: - case 69: - return 8; - } - } - } - } - return 0; - } - ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -8085,11 +8281,11 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 225 && node.parent.kind === 259; + return node.kind === 226 && node.parent.kind === 260; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 232 && + return node && node.kind === 233 && (node.name.kind === 9 || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; @@ -8098,11 +8294,11 @@ var ts; } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { - return node && node.kind === 232 && (!node.body); + return node && node.kind === 233 && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 264 || - node.kind === 232 || + return node.kind === 265 || + node.kind === 233 || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -8115,9 +8311,9 @@ var ts; return false; } switch (node.parent.kind) { - case 264: + case 265: return ts.isExternalModule(node.parent); - case 233: + case 234: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -8129,22 +8325,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 264: - case 234: - case 259: - case 232: - case 213: + case 265: + case 235: + case 260: + case 233: case 214: case 215: - case 151: - case 150: + case 216: case 152: + case 151: case 153: - case 227: - case 185: + case 154: + case 228: case 186: + case 187: return true; - case 206: + case 207: return parentNode && !isFunctionLike(parentNode); } return false; @@ -8164,14 +8360,18 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getNameFromIndexInfo(info) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } + ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 70: + case 71: return name.text; case 9: case 8: return name.text; - case 143: + case 144: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -8181,11 +8381,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 70: + case 71: return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); - case 142: + case 143: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 178: + case 179: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -8222,7 +8422,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 206) { + if (node.body && node.body.kind === 207) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -8234,29 +8434,29 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 264: + case 265: 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 225: - case 175: - case 228: - case 198: + case 226: + case 176: case 229: - case 232: - case 231: - case 263: - case 227: - case 185: - case 150: - case 152: - case 153: + case 199: case 230: + case 233: + case 232: + case 264: + case 228: + case 186: + case 151: + case 153: + case 154: + case 231: errorNode = node.name; break; - case 186: + case 187: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -8277,7 +8477,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 231 && isConst(node); + return node.kind === 232 && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -8290,11 +8490,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 180 && n.expression.kind === 96; + return n.kind === 181 && n.expression.kind === 97; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 209 + return node.kind === 210 && node.expression.kind === 9; } ts.isPrologueDirective = isPrologueDirective; @@ -8307,10 +8507,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 145 || - node.kind === 144 || - node.kind === 185 || - node.kind === 186) ? + var commentRanges = (node.kind === 146 || + node.kind === 145 || + node.kind === 186 || + node.kind === 187) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); return ts.filter(commentRanges, function (comment) { @@ -8324,69 +8524,69 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (157 <= node.kind && node.kind <= 172) { + if (158 <= node.kind && node.kind <= 173) { return true; } switch (node.kind) { - case 118: - case 132: - case 135: - case 121: + case 119: + case 133: case 136: - case 138: - case 129: + case 122: + case 137: + case 139: + case 130: return true; - case 104: - return node.parent.kind !== 189; - case 200: + case 105: + return node.parent.kind !== 190; + case 201: return !isExpressionWithTypeArgumentsInClassExtendsClause(node); - case 70: - if (node.parent.kind === 142 && node.parent.right === node) { + case 71: + if (node.parent.kind === 143 && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 178 && node.parent.name === node) { + else if (node.parent.kind === 179 && node.parent.name === node) { node = node.parent; } - ts.Debug.assert(node.kind === 70 || node.kind === 142 || node.kind === 178, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 142: - case 178: - case 98: + ts.Debug.assert(node.kind === 71 || node.kind === 143 || node.kind === 179, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + case 143: + case 179: + case 99: var parent = node.parent; - if (parent.kind === 161) { + if (parent.kind === 162) { return false; } - if (157 <= parent.kind && parent.kind <= 172) { + if (158 <= parent.kind && parent.kind <= 173) { return true; } switch (parent.kind) { - case 200: + case 201: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 144: - return node === parent.constraint; - case 148: - case 147: case 145: - case 225: + return node === parent.constraint; + case 149: + case 148: + case 146: + case 226: return node === parent.type; - case 227: - case 185: + case 228: case 186: + case 187: + case 152: case 151: case 150: - case 149: - case 152: case 153: - return node === parent.type; case 154: + return node === parent.type; case 155: case 156: + case 157: return node === parent.type; - case 183: + case 184: return node === parent.type; - case 180: case 181: - return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; case 182: + return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; + case 183: return false; } } @@ -8404,30 +8604,30 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 191; + return node.kind === 192; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; function forEachReturnStatement(body, visitor) { return traverse(body); function traverse(node) { switch (node.kind) { - case 218: + case 219: return visitor(node); - case 234: - case 206: - case 210: + case 235: + case 207: case 211: case 212: case 213: case 214: case 215: - case 219: + case 216: case 220: - case 256: - case 257: case 221: - case 223: - case 259: + case 257: + case 258: + case 222: + case 224: + case 260: return ts.forEachChild(node, traverse); } } @@ -8437,23 +8637,24 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 196: + case 197: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 231: - case 229: + return; case 232: case 230: - case 228: - case 198: + case 233: + case 231: + case 229: + case 199: return; default: if (isFunctionLike(node)) { var name = node.name; - if (name && name.kind === 143) { + if (name && name.kind === 144) { traverse(name.expression); return; } @@ -8466,10 +8667,10 @@ var ts; } ts.forEachYieldExpression = forEachYieldExpression; function getRestParameterElementType(node) { - if (node && node.kind === 163) { + if (node && node.kind === 164) { return node.elementType; } - else if (node && node.kind === 158) { + else if (node && node.kind === 159) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -8480,14 +8681,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 175: - case 263: - case 145: - case 260: - case 148: - case 147: + case 176: + case 264: + case 146: case 261: - case 225: + case 149: + case 148: + case 262: + case 226: return true; } } @@ -8495,11 +8696,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 152 || node.kind === 153); + return node && (node.kind === 153 || node.kind === 154); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 228 || node.kind === 198); + return node && (node.kind === 229 || node.kind === 199); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -8508,19 +8709,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 151: - case 185: - case 227: - case 186: - case 150: - case 149: case 152: + case 186: + case 228: + case 187: + case 151: + case 150: case 153: case 154: case 155: case 156: - case 159: + case 157: case 160: + case 161: return true; } return false; @@ -8528,13 +8729,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 227: - case 185: + case 154: + case 228: + case 186: return true; } return false; @@ -8542,42 +8743,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 213: case 214: case 215: - case 211: + case 216: case 212: + case 213: return true; - case 221: + case 222: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; - function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) { while (true) { if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 221) { + if (node.statement.kind !== 222) { return node.statement; } node = node.statement; } } - ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 206 && isFunctionLike(node.parent); + return node && node.kind === 207 && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 150 && node.parent.kind === 177; + return node && node.kind === 151 && node.parent.kind === 178; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 150 && - (node.parent.kind === 177 || - node.parent.kind === 198); + return node.kind === 151 && + (node.parent.kind === 178 || + node.parent.kind === 199); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -8613,39 +8814,39 @@ var ts; return undefined; } switch (node.kind) { - case 143: + case 144: if (isClassLike(node.parent.parent)) { return node; } node = node.parent; break; - case 146: - if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + case 147: + if (node.parent.kind === 146 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { node = node.parent; } break; - case 186: + case 187: if (!includeArrowFunctions) { continue; } - case 227: - case 185: - case 232: - case 148: - case 147: - case 150: + case 228: + case 186: + case 233: case 149: + case 148: case 151: + case 150: case 152: case 153: case 154: case 155: case 156: - case 231: - case 264: + case 157: + case 232: + case 265: return node; } } @@ -8655,9 +8856,9 @@ var ts; var container = getThisContainer(node, false); if (container) { switch (container.kind) { - case 151: - case 227: - case 185: + case 152: + case 228: + case 186: return container; } } @@ -8671,25 +8872,25 @@ var ts; return node; } switch (node.kind) { - case 143: + case 144: node = node.parent; break; - case 227: - case 185: + case 228: case 186: + case 187: if (!stopOnFunctions) { continue; } - case 148: - case 147: - case 150: case 149: + case 148: case 151: + case 150: case 152: case 153: + case 154: return node; - case 146: - if (node.parent.kind === 145 && isClassElement(node.parent.parent)) { + case 147: + if (node.parent.kind === 146 && isClassElement(node.parent.parent)) { node = node.parent.parent; } else if (isClassElement(node.parent)) { @@ -8701,14 +8902,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 185 || func.kind === 186) { + if (func.kind === 186 || func.kind === 187) { var prev = func; var parent = func.parent; - while (parent.kind === 184) { + while (parent.kind === 185) { prev = parent; parent = parent.parent; } - if (parent.kind === 180 && parent.expression === prev) { + if (parent.kind === 181 && parent.expression === prev) { return parent; } } @@ -8716,21 +8917,21 @@ var ts; ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression; function isSuperProperty(node) { var kind = node.kind; - return (kind === 178 || kind === 179) - && node.expression.kind === 96; + return (kind === 179 || kind === 180) + && node.expression.kind === 97; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 158: - case 276: + case 159: + case 277: return node.typeName; - case 200: + case 201: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 70: - case 142: + case 71: + case 143: return node; } return undefined; @@ -8738,12 +8939,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { + case 251: case 250: - case 249: - case 180: case 181: case 182: - case 146: + case 183: + case 147: return true; default: return false; @@ -8751,7 +8952,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 182) { + if (node.kind === 183) { return node.tag; } else if (isJsxOpeningLikeElement(node)) { @@ -8762,21 +8963,21 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 228: + case 229: return true; - case 148: - return node.parent.kind === 228; - case 152: + case 149: + return node.parent.kind === 229; case 153: - case 150: + case 154: + case 151: return node.body !== undefined - && node.parent.kind === 228; - case 145: + && node.parent.kind === 229; + case 146: return node.parent.body !== undefined - && (node.parent.kind === 151 - || node.parent.kind === 150 - || node.parent.kind === 153) - && node.parent.parent.kind === 228; + && (node.parent.kind === 152 + || node.parent.kind === 151 + || node.parent.kind === 154) + && node.parent.parent.kind === 229; } return false; } @@ -8792,19 +8993,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 228: + case 229: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 150: - case 153: + case 151: + case 154: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 250 || - parent.kind === 249 || - parent.kind === 251) { + if (parent.kind === 251 || + parent.kind === 250 || + parent.kind === 252) { return parent.tagName === node; } return false; @@ -8812,99 +9013,99 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 98: - case 96: - case 94: - case 100: - case 85: - case 11: - case 176: + case 99: + case 97: + case 95: + case 101: + case 86: + case 12: case 177: case 178: case 179: case 180: case 181: case 182: - case 201: case 183: case 202: case 184: + case 203: case 185: - case 198: case 186: - case 189: + case 199: case 187: + case 190: case 188: - case 191: + case 189: case 192: case 193: case 194: - case 197: case 195: - case 12: - case 199: - case 248: - case 249: + case 198: case 196: - case 190: - case 203: + case 13: + case 200: + case 249: + case 250: + case 197: + case 191: + case 204: return true; - case 142: - while (node.parent.kind === 142) { + case 143: + while (node.parent.kind === 143) { node = node.parent; } - return node.parent.kind === 161 || isJSXTagName(node); - case 70: - if (node.parent.kind === 161 || isJSXTagName(node)) { + return node.parent.kind === 162 || isJSXTagName(node); + case 71: + if (node.parent.kind === 162 || isJSXTagName(node)) { return true; } case 8: case 9: - case 98: + case 99: var parent = node.parent; switch (parent.kind) { - case 225: - case 145: + case 226: + case 146: + case 149: case 148: - case 147: - case 263: - case 260: - case 175: + case 264: + case 261: + case 176: return parent.initializer === node; - case 209: case 210: case 211: case 212: - case 218: + case 213: case 219: case 220: - case 256: - case 222: - case 220: + case 221: + case 257: + case 223: + case 221: return parent.expression === node; - case 213: + case 214: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 226) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 227) || forStatement.condition === node || forStatement.incrementor === node; - case 214: case 215: + case 216: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227) || forInStatement.expression === node; - case 183: - case 201: + case 184: + case 202: return node === parent.expression; - case 204: + case 205: return node === parent.expression; - case 143: + case 144: return node === parent.expression; - case 146: + case 147: + case 256: case 255: - case 254: - case 262: + case 263: return true; - case 200: + case 201: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: if (isPartOfExpression(parent)) { @@ -8922,7 +9123,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 && node.moduleReference.kind === 247; + return node.kind === 237 && node.moduleReference.kind === 248; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -8931,7 +9132,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 && node.moduleReference.kind !== 247; + return node.kind === 237 && node.moduleReference.kind !== 248; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -8942,39 +9143,58 @@ var ts; return node && !!(node.flags & 65536); } ts.isInJavaScriptFile = isInJavaScriptFile; - function isRequireCall(expression, checkArgumentIsStringLiteral) { - var isRequire = expression.kind === 180 && - expression.expression.kind === 70 && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9); + function isRequireCall(callExpression, checkArgumentIsStringLiteral) { + if (callExpression.kind !== 181) { + return false; + } + var _a = callExpression, expression = _a.expression, args = _a.arguments; + if (expression.kind !== 71 || expression.text !== "require") { + return false; + } + if (args.length !== 1) { + return false; + } + var arg = args[0]; + return !checkArgumentIsStringLiteral || arg.kind === 9 || arg.kind === 13; } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { return charCode === 39 || charCode === 34; } ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote; - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 225) { + function isDeclarationOfFunctionOrClassExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 226) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 185; + return declaration.initializer && (declaration.initializer.kind === 186 || declaration.initializer.kind === 199); } return false; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + ts.isDeclarationOfFunctionOrClassExpression = isDeclarationOfFunctionOrClassExpression; + function getRightMostAssignedExpression(node) { + while (isAssignmentExpression(node, true)) { + node = node.right; + } + return node; + } + ts.getRightMostAssignedExpression = getRightMostAssignedExpression; + function isExportsIdentifier(node) { + return isIdentifier(node) && node.text === "exports"; + } + ts.isExportsIdentifier = isExportsIdentifier; + function isModuleExportsPropertyAccessExpression(node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; function getSpecialPropertyAssignmentKind(expression) { if (!isInJavaScriptFile(expression)) { return 0; } - if (expression.kind !== 193) { - return 0; - } var expr = expression; - if (expr.operatorToken.kind !== 57 || expr.left.kind !== 178) { + if (expr.operatorToken.kind !== 58 || expr.left.kind !== 179) { return 0; } var lhs = expr.left; - if (lhs.expression.kind === 70) { + if (lhs.expression.kind === 71) { var lhsId = lhs.expression; if (lhsId.text === "exports") { return 1; @@ -8982,13 +9202,16 @@ var ts; else if (lhsId.text === "module" && lhs.name.text === "exports") { return 2; } + else { + return 5; + } } - else if (lhs.expression.kind === 98) { + else if (lhs.expression.kind === 99) { return 4; } - else if (lhs.expression.kind === 178) { + else if (lhs.expression.kind === 179) { var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70) { + if (innerPropertyAccess.expression.kind === 71) { var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { return 1; @@ -9002,35 +9225,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 237) { + if (node.kind === 238) { return node.moduleSpecifier; } - if (node.kind === 236) { + if (node.kind === 237) { var reference = node.moduleReference; - if (reference.kind === 247) { + if (reference.kind === 248) { return reference.expression; } } - if (node.kind === 243) { + if (node.kind === 244) { return node.moduleSpecifier; } - if (node.kind === 232 && node.name.kind === 9) { + if (node.kind === 233 && node.name.kind === 9) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 240) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 237 + return node.kind === 238 && node.importClause && !!node.importClause.name; } @@ -9038,13 +9261,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 145: + case 146: + case 151: case 150: - case 149: + case 262: case 261: - case 260: + case 149: case 148: - case 147: return node.questionToken !== undefined; } } @@ -9052,9 +9275,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 278 && + return node.kind === 279 && node.parameters.length > 0 && - node.parameters[0].type.kind === 280; + node.parameters[0].type.kind === 281; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -9062,7 +9285,7 @@ var ts; } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; function hasJSDocParameterTags(node) { - var parameterTags = getJSDocTags(node, 285); + var parameterTags = getJSDocTags(node, 286); return parameterTags && parameterTags.length > 0; } ts.hasJSDocParameterTags = hasJSDocParameterTags; @@ -9072,13 +9295,16 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 285) { + if (doc.kind === 286) { if (doc.kind === kind) { result.push(doc); } } else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + var tags = doc.tags; + if (tags) { + result.push.apply(result, ts.filter(tags, function (tag) { return tag.kind === kind; })); + } } } return result; @@ -9098,9 +9324,9 @@ var ts; var parent = node.parent; var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 207; + parent.parent.parent.kind === 208; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 207; + parent.parent.kind === 208; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -9108,19 +9334,19 @@ var ts; getJSDocsWorker(variableStatementNode); } var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 193 && - parent.operatorToken.kind === 57 && - parent.parent.kind === 209; + parent.kind === 194 && + parent.operatorToken.kind === 58 && + parent.parent.kind === 210; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 232 && - parent && parent.kind === 232; - var isPropertyAssignmentExpression = parent && parent.kind === 260; + var isModuleDeclaration = node.kind === 233 && + parent && parent.kind === 233; + var isPropertyAssignmentExpression = parent && parent.kind === 261; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } - if (node.kind === 145) { + if (node.kind === 146) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -9129,22 +9355,23 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 285); + var tags = getJSDocTags(func, 286); if (!param.name) { var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 286; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } - else if (param.name.kind === 70) { + else if (param.name.kind === 71) { var name_1 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 285 && tag.parameterName.text === name_1; }); + return ts.filter(tags, function (tag) { return tag.kind === 286 && tag.parameterName.text === name_1; }); } else { return undefined; @@ -9152,8 +9379,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 287); - if (!tag && node.kind === 145) { + var tag = getFirstJSDocTag(node, 288); + if (!tag && node.kind === 146) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -9163,15 +9390,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 284); + return getFirstJSDocTag(node, 285); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 286); + return getFirstJSDocTag(node, 287); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 288); + return getFirstJSDocTag(node, 289); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -9184,8 +9411,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536)) { - if (node.type && node.type.kind === 279 || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279; })) { + if (node.type && node.type.kind === 280 || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 280; })) { return true; } } @@ -9206,30 +9433,30 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 193: + case 194: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 ? 1 : 2 : + binaryOperator === 58 ? 1 : 2 : 0; - case 191: case 192: + case 193: var unaryOperator = parent.operator; - return unaryOperator === 42 || unaryOperator === 43 ? 2 : 0; - case 214: + return unaryOperator === 43 || unaryOperator === 44 ? 2 : 0; case 215: + case 216: return parent.initializer === node ? 1 : 0; - case 184: - case 176: - case 197: + case 185: + case 177: + case 198: node = parent; break; - case 261: + case 262: if (parent.name !== node) { return 0; } node = parent.parent; break; - case 260: + case 261: if (parent.name === node) { return 0; } @@ -9247,14 +9474,14 @@ var ts; } ts.isAssignmentTarget = isAssignmentTarget; function isDeleteTarget(node) { - if (node.kind !== 178 && node.kind !== 179) { + if (node.kind !== 179 && node.kind !== 180) { return false; } node = node.parent; - while (node && node.kind === 184) { + while (node && node.kind === 185) { node = node.parent; } - return node && node.kind === 187; + return node && node.kind === 188; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -9268,7 +9495,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2) || (node.kind === 264 && node.isDeclarationFile)) { + if (hasModifier(node, 2) || (node.kind === 265 && node.isDeclarationFile)) { return true; } node = node.parent; @@ -9277,11 +9504,11 @@ var ts; } ts.isInAmbientContext = isInAmbientContext; function isDeclarationName(name) { - if (name.kind !== 70 && name.kind !== 9 && name.kind !== 8) { + if (name.kind !== 71 && name.kind !== 9 && name.kind !== 8) { return false; } var parent = name.parent; - if (parent.kind === 241 || parent.kind === 245) { + if (parent.kind === 242 || parent.kind === 246) { if (parent.propertyName) { return true; } @@ -9294,48 +9521,48 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 || node.kind === 8) && - node.parent.kind === 143 && + node.parent.kind === 144 && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 148: - case 147: - case 150: case 149: - case 152: + case 148: + case 151: + case 150: case 153: - case 263: - case 260: - case 178: + case 154: + case 264: + case 261: + case 179: return parent.name === node; - case 142: + case 143: if (parent.right === node) { - while (parent.kind === 142) { + while (parent.kind === 143) { parent = parent.parent; } - return parent.kind === 161; + return parent.kind === 162; } return false; - case 175: - case 241: + case 176: + case 242: return parent.propertyName === node; - case 245: + case 246: return true; } return false; } ts.isIdentifierName = isIdentifierName; function isAliasSymbolDeclaration(node) { - return node.kind === 236 || - node.kind === 235 || - node.kind === 238 && !!node.name || - node.kind === 239 || - node.kind === 241 || - node.kind === 245 || - node.kind === 242 && exportAssignmentIsAlias(node); + return node.kind === 237 || + node.kind === 236 || + node.kind === 239 && !!node.name || + node.kind === 240 || + node.kind === 242 || + node.kind === 246 || + node.kind === 243 && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -9343,17 +9570,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); + var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107); + var heritageClause = getHeritageClause(node.heritageClauses, 108); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84); + var heritageClause = getHeritageClause(node.heritageClauses, 85); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -9421,17 +9648,61 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 <= token && token <= 141; + return 72 <= token && token <= 142; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 <= token && token <= 7; } ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256) && !isAccessor(node); + var FunctionFlags; + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal"; + FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator"; + FunctionFlags[FunctionFlags["Async"] = 2] = "Async"; + FunctionFlags[FunctionFlags["AsyncOrAsyncGenerator"] = 3] = "AsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid"; + FunctionFlags[FunctionFlags["InvalidAsyncOrAsyncGenerator"] = 7] = "InvalidAsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["InvalidGenerator"] = 5] = "InvalidGenerator"; + })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); + function getFunctionFlags(node) { + var flags = 0; + switch (node.kind) { + case 228: + case 186: + case 151: + if (node.asteriskToken) { + flags |= 1; + } + case 187: + if (hasModifier(node, 256)) { + flags |= 2; + } + break; + } + if (!node.body) { + flags |= 4; + } + return flags; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; + ts.getFunctionFlags = getFunctionFlags; + function isAsyncFunction(node) { + switch (node.kind) { + case 228: + case 186: + case 187: + case 151: + return node.body !== undefined + && node.asteriskToken === undefined + && hasModifier(node, 256); + } + return false; + } + ts.isAsyncFunction = isAsyncFunction; + function isNumericLiteral(node) { + return node.kind === 8; + } + ts.isNumericLiteral = isNumericLiteral; function isStringOrNumericLiteral(node) { var kind = node.kind; return kind === 9 @@ -9443,7 +9714,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 143 && + return name.kind === 144 && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -9453,10 +9724,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 || name.kind === 9 || name.kind === 8 || name.kind === 145) { + if (name.kind === 71 || name.kind === 9 || name.kind === 8 || name.kind === 146) { return name.text; } - if (name.kind === 143) { + if (name.kind === 144) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -9474,7 +9745,7 @@ var ts; } ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName; function isESSymbolIdentifier(node) { - return node.kind === 70 && node.text === "Symbol"; + return node.kind === 71 && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -9483,17 +9754,17 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 116: - case 119: - case 75: - case 123: - case 78: - case 83: - case 113: - case 111: - case 112: - case 130: + case 117: + case 120: + case 76: + case 124: + case 79: + case 84: case 114: + case 112: + case 113: + case 131: + case 115: return true; } return false; @@ -9501,11 +9772,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 145; + return root.kind === 146; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 175) { + while (node.kind === 176) { node = node.parent.parent; } return node; @@ -9513,15 +9784,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 151 - || kind === 185 - || kind === 227 + return kind === 152 || kind === 186 - || kind === 150 - || kind === 152 + || kind === 228 + || kind === 187 + || kind === 151 || kind === 153 - || kind === 232 - || kind === 264; + || kind === 154 + || kind === 233 + || kind === 265; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -9530,7 +9801,7 @@ var ts; } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFileOrBundle(sourceFileOrBundle) { - if (sourceFileOrBundle.kind === 265) { + if (sourceFileOrBundle.kind === 266) { return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } return getOriginalSourceFile(sourceFileOrBundle); @@ -9555,38 +9826,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 181: + case 182: return hasArguments ? 0 : 1; - case 191: - case 188: + case 192: case 189: - case 187: case 190: - case 194: - case 196: + case 188: + case 191: + case 195: + case 197: return 1; - case 193: + case 194: switch (operator) { - case 39: - case 57: + case 40: case 58: case 59: - case 61: case 60: case 62: + case 61: case 63: case 64: case 65: case 66: case 67: - case 69: case 68: + case 70: + case 69: return 1; } } @@ -9595,15 +9866,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 193) { + if (expression.kind === 194) { return expression.operatorToken.kind; } - else if (expression.kind === 191 || expression.kind === 192) { + else if (expression.kind === 192 || expression.kind === 193) { return expression.operator; } else { @@ -9613,106 +9884,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 98: - case 96: - case 70: - case 94: - case 100: - case 85: + case 99: + case 97: + case 71: + case 95: + case 101: + case 86: case 8: case 9: - case 176: case 177: - case 185: - case 186: - case 198: - case 248: - case 249: - case 11: - case 12: - case 195: - case 184: - case 199: - return 19; - case 182: case 178: - case 179: - return 18; - case 181: - return hasArguments ? 18 : 17; - case 180: - return 17; - case 192: - return 16; - case 191: - case 188: - case 189: + case 186: case 187: - case 190: - return 15; + case 199: + case 249: + case 250: + case 12: + case 13: + case 196: + case 185: + case 200: + return 19; + case 183: + case 179: + case 180: + return 18; + case 182: + return hasArguments ? 18 : 17; + case 181: + return 17; case 193: + return 16; + case 192: + case 189: + case 190: + case 188: + case 191: + return 15; + case 194: switch (operatorKind) { - case 50: case 51: + case 52: return 15; - case 39: - case 38: case 40: + case 39: case 41: + case 42: return 14; - case 36: case 37: + case 38: return 13; - case 44: case 45: case 46: + case 47: return 12; - case 26: - case 29: - case 28: + case 27: case 30: - case 91: - case 92: - return 11; + case 29: case 31: - case 33: + case 92: + case 93: + return 11; case 32: case 34: + case 33: + case 35: return 10; - case 47: - return 9; - case 49: - return 8; case 48: + return 9; + case 50: + return 8; + case 49: return 7; - case 52: - return 6; case 53: + return 6; + case 54: return 5; - case 57: case 58: case 59: - case 61: case 60: case 62: + case 61: case 63: case 64: case 65: case 66: case 67: - case 69: case 68: + case 70: + case 69: return 3; - case 25: + case 26: return 0; default: return -1; } - case 194: + case 195: return 4; - case 196: - return 2; case 197: + return 2; + case 198: return 1; default: return -1; @@ -9973,7 +10244,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -10028,7 +10299,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 151 && nodeIsPresent(member.body)) { + if (member.kind === 152 && nodeIsPresent(member.body)) { return member; } }); @@ -10055,11 +10326,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 70 && identifierIsThisKeyword(node); + return node && node.kind === 71 && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98; + return id.originalKeywordKind === 99; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -10069,10 +10340,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 152) { + if (accessor.kind === 153) { getAccessor = accessor; } - else if (accessor.kind === 153) { + else if (accessor.kind === 154) { setAccessor = accessor; } else { @@ -10081,7 +10352,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 152 || member.kind === 153) + if ((member.kind === 153 || member.kind === 154) && hasModifier(member, 32) === hasModifier(accessor, 32)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -10092,10 +10363,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 152 && !getAccessor) { + if (member.kind === 153 && !getAccessor) { getAccessor = member; } - if (member.kind === 153 && !setAccessor) { + if (member.kind === 154 && !setAccessor) { setAccessor = member; } } @@ -10278,7 +10549,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 || (node.kind === 70 && node.isInJSDocNamespace)) { + if (node.flags & 4 || (node.kind === 71 && node.isInJSDocNamespace)) { flags |= 1; } node.modifierFlagsCache = flags | 536870912; @@ -10287,34 +10558,34 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 114: return 32; - case 113: return 4; - case 112: return 16; - case 111: return 8; - case 116: return 128; - case 83: return 1; - case 123: return 2; - case 75: return 2048; - case 78: return 512; - case 119: return 256; - case 130: return 64; + case 115: return 32; + case 114: return 4; + case 113: return 16; + case 112: return 8; + case 117: return 128; + case 84: return 1; + case 124: return 2; + case 76: return 2048; + case 79: return 512; + case 120: return 256; + case 131: return 64; } return 0; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 53 - || token === 52 - || token === 50; + return token === 54 + || token === 53 + || token === 51; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 57 && token <= 69; + return token >= 58 && token <= 70; } ts.isAssignmentOperator = isAssignmentOperator; function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 200 && - node.parent.token === 84 && + if (node.kind === 201 && + node.parent.token === 85 && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -10323,7 +10594,7 @@ var ts; function isAssignmentExpression(node, excludeCompoundAssignment) { return isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 + ? node.operatorToken.kind === 58 : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left); } @@ -10331,8 +10602,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, true)) { var kind = node.left.kind; - return kind === 177 - || kind === 176; + return kind === 178 + || kind === 177; } return false; } @@ -10342,7 +10613,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70) { + if (node.kind === 71) { return true; } else if (isPropertyAccessExpression(node)) { @@ -10356,27 +10627,35 @@ var ts; return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isExpressionWithTypeArgumentsInClassImplementsClause(node) { + return node.kind === 201 + && isEntityNameExpression(node.expression) + && node.parent + && node.parent.token === 108 + && node.parent.parent + && isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassImplementsClause = isExpressionWithTypeArgumentsInClassImplementsClause; function isEntityNameExpression(node) { - return node.kind === 70 || - node.kind === 178 && isEntityNameExpression(node.expression); + return node.kind === 71 || + node.kind === 179 && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 142 && node.parent.right === node) || - (node.parent.kind === 178 && node.parent.name === node); + return (node.parent.kind === 143 && node.parent.right === node) || + (node.parent.kind === 179 && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 177) { - return expression.properties.length === 0; - } - if (kind === 176) { - return expression.elements.length === 0; - } - return false; + function isEmptyObjectLiteral(expression) { + return expression.kind === 178 && + expression.properties.length === 0; } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + ts.isEmptyObjectLiteral = isEmptyObjectLiteral; + function isEmptyArrayLiteral(expression) { + return expression.kind === 177 && + expression.elements.length === 0; + } + ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -10384,7 +10663,6 @@ var ts; function isExportDefaultSymbol(symbol) { return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512); } - ts.isExportDefaultSymbol = isExportDefaultSymbol; function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); } @@ -10466,49 +10744,49 @@ var ts; var kind = node.kind; if (kind === 9 || kind === 8 - || kind === 11 || kind === 12 - || kind === 70 - || kind === 98 - || kind === 96 - || kind === 100 - || kind === 85 - || kind === 94) { + || kind === 13 + || kind === 71 + || kind === 99 + || kind === 97 + || kind === 101 + || kind === 86 + || kind === 95) { return true; } - else if (kind === 178) { + else if (kind === 179) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 179) { + else if (kind === 180) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 191 - || kind === 192) { + else if (kind === 192 + || kind === 193) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 193) { - return node.operatorToken.kind !== 39 + else if (kind === 194) { + return node.operatorToken.kind !== 40 && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 194) { + else if (kind === 195) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 189 - || kind === 188 - || kind === 187) { + else if (kind === 190 + || kind === 189 + || kind === 188) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 176) { + else if (kind === 177) { return node.elements.length === 0; } - else if (kind === 177) { + else if (kind === 178) { return node.properties.length === 0; } - else if (kind === 180) { + else if (kind === 181) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -10629,8 +10907,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 231: case 232: + case 233: return parseNode === parseNode.parent.name; } } @@ -10648,7 +10926,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 && declaration !== node) { + if (declaration.kind === 229 && declaration !== node) { return true; } } @@ -10666,15 +10944,15 @@ var ts; } ts.isNodeArray = isNodeArray; function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12; + return node.kind === 13; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 <= kind && kind <= 12; + return 8 <= kind && kind <= 13; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 || kind === 12; + return kind === 9 || kind === 13; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -10682,25 +10960,25 @@ var ts; } ts.isLiteralExpression = isLiteralExpression; function isTemplateLiteralKind(kind) { - return 12 <= kind && kind <= 15; + return 13 <= kind && kind <= 16; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 13; + return node.kind === 14; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 14 - || kind === 15; + return kind === 15 + || kind === 16; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; function isIdentifier(node) { - return node.kind === 70; + return node.kind === 71; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 189; + return node.kind === 190; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -10712,131 +10990,135 @@ var ts; } ts.isModifier = isModifier; function isQualifiedName(node) { - return node.kind === 142; + return node.kind === 143; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 143; + return node.kind === 144; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 142 - || kind === 70; + return kind === 143 + || kind === 71; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 70 + return kind === 71 || kind === 9 || kind === 8 - || kind === 143; + || kind === 144; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 70 + return kind === 71 || kind === 9; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 70 - || kind === 173 - || kind === 174; + return kind === 71 + || kind === 174 + || kind === 175; } ts.isBindingName = isBindingName; function isTypeParameter(node) { - return node.kind === 144; + return node.kind === 145; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 145; + return node.kind === 146; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 146; + return node.kind === 147; } ts.isDecorator = isDecorator; function isMethodDeclaration(node) { - return node.kind === 150; + return node.kind === 151; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 151 - || kind === 148 - || kind === 150 - || kind === 152 + return kind === 152 + || kind === 149 + || kind === 151 || kind === 153 - || kind === 156 - || kind === 205; + || kind === 154 + || kind === 157 + || kind === 206; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 260 - || kind === 261 + return kind === 261 || kind === 262 - || kind === 150 - || kind === 152 + || kind === 263 + || kind === 151 || kind === 153 - || kind === 246; + || kind === 154 + || kind === 247; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; function isTypeNodeKind(kind) { - return (kind >= 157 && kind <= 172) - || kind === 118 - || kind === 132 - || kind === 121 - || kind === 135 + return (kind >= 158 && kind <= 173) + || kind === 119 + || kind === 133 + || kind === 134 + || kind === 122 || kind === 136 - || kind === 104 - || kind === 129 - || kind === 200; + || kind === 137 + || kind === 99 + || kind === 105 + || kind === 139 + || kind === 95 + || kind === 130 + || kind === 201; } function isTypeNode(node) { return isTypeNodeKind(node.kind); } ts.isTypeNode = isTypeNode; function isArrayBindingPattern(node) { - return node.kind === 174; + return node.kind === 175; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 173; + return node.kind === 174; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 174 - || kind === 173; + return kind === 175 + || kind === 174; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 176 - || kind === 177; + return kind === 177 + || kind === 178; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 175; + return node.kind === 176; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 175 - || kind === 199; + return kind === 176 + || kind === 200; } ts.isArrayBindingElement = isArrayBindingElement; function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 225: - case 145: - case 175: + case 226: + case 146: + case 176: return true; } return false; @@ -10849,8 +11131,8 @@ var ts; ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern; function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173: - case 177: + case 174: + case 178: return true; } return false; @@ -10858,94 +11140,100 @@ var ts; ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern; function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 174: - case 176: + case 175: + case 177: return true; } return false; } ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; function isArrayLiteralExpression(node) { - return node.kind === 176; + return node.kind === 177; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 177; + return node.kind === 178; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 178; + return node.kind === 179; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessOrQualifiedName(node) { + var kind = node.kind; + return kind === 179 + || kind === 143; + } + ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isElementAccessExpression(node) { - return node.kind === 179; + return node.kind === 180; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 193; + return node.kind === 194; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 194; + return node.kind === 195; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 180; + return node.kind === 181; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 195 - || kind === 12; + return kind === 196 + || kind === 13; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 197; + return node.kind === 198; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 200; + return node.kind === 201; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 178 - || kind === 179 - || kind === 181 + return kind === 179 || kind === 180 - || kind === 248 - || kind === 249 || kind === 182 - || kind === 176 - || kind === 184 + || kind === 181 + || kind === 249 + || kind === 250 + || kind === 183 || kind === 177 - || kind === 198 || kind === 185 - || kind === 70 - || kind === 11 + || kind === 178 + || kind === 199 + || kind === 186 + || kind === 71 + || kind === 12 || kind === 8 || kind === 9 - || kind === 12 - || kind === 195 - || kind === 85 - || kind === 94 - || kind === 98 - || kind === 100 - || kind === 96 - || kind === 202 - || kind === 203; + || kind === 13 + || kind === 196 + || kind === 86 + || kind === 95 + || kind === 99 + || kind === 101 + || kind === 97 + || kind === 203 + || kind === 204; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 191 - || kind === 192 - || kind === 187 + return kind === 192 + || kind === 193 || kind === 188 || kind === 189 || kind === 190 - || kind === 183 + || kind === 191 + || kind === 184 || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10953,13 +11241,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 194 - || kind === 196 - || kind === 186 - || kind === 193 + return kind === 195 || kind === 197 - || kind === 201 - || kind === 199 + || kind === 187 + || kind === 194 + || kind === 198 + || kind === 202 + || kind === 200 || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10968,16 +11256,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 183 - || kind === 201; + return kind === 184 + || kind === 202; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 298; + return node.kind === 296; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 297; + return node.kind === 295; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10986,15 +11274,15 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 199; + return node.kind === 200; } ts.isOmittedExpression = isOmittedExpression; function isTemplateSpan(node) { - return node.kind === 204; + return node.kind === 205; } ts.isTemplateSpan = isTemplateSpan; function isBlock(node) { - return node.kind === 206; + return node.kind === 207; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -11012,135 +11300,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 225; + return node.kind === 226; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 226; + return node.kind === 227; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 234; + return node.kind === 235; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 233 - || kind === 232 - || kind === 70; + return kind === 234 + || kind === 233 + || kind === 71; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 233 - || kind === 232; + return kind === 234 + || kind === 233; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 70 - || kind === 232; + return kind === 71 + || kind === 233; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 236; + return node.kind === 237; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 238; + return node.kind === 239; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 240 - || kind === 239; + return kind === 241 + || kind === 240; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 241; + return node.kind === 242; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 244; + return node.kind === 245; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 245; + return node.kind === 246; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 232 || node.kind === 231; + return node.kind === 233 || node.kind === 232; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 186 - || kind === 175 - || kind === 228 - || kind === 198 - || kind === 151 - || kind === 231 - || kind === 263 - || kind === 245 - || kind === 227 - || kind === 185 - || kind === 152 - || kind === 238 - || kind === 236 - || kind === 241 + return kind === 187 + || kind === 176 || kind === 229 - || kind === 252 - || kind === 150 - || kind === 149 + || kind === 199 + || kind === 152 || kind === 232 - || kind === 235 - || kind === 239 - || kind === 145 - || kind === 260 - || kind === 148 - || kind === 147 - || kind === 153 - || kind === 261 - || kind === 230 - || kind === 144 - || kind === 225 - || kind === 289; - } - function isDeclarationStatementKind(kind) { - return kind === 227 + || kind === 264 || kind === 246 || kind === 228 + || kind === 186 + || kind === 153 + || kind === 239 + || kind === 237 + || kind === 242 + || kind === 230 + || kind === 253 + || kind === 151 + || kind === 150 + || kind === 233 + || kind === 236 + || kind === 240 + || kind === 146 + || kind === 261 + || kind === 149 + || kind === 148 + || kind === 154 + || kind === 262 + || kind === 231 + || kind === 145 + || kind === 226 + || kind === 290; + } + function isDeclarationStatementKind(kind) { + return kind === 228 + || kind === 247 || kind === 229 || kind === 230 || kind === 231 || kind === 232 + || kind === 233 + || kind === 238 || kind === 237 - || kind === 236 + || kind === 244 || kind === 243 - || kind === 242 - || kind === 235; + || kind === 236; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 217 - || kind === 216 - || kind === 224 - || kind === 211 - || kind === 209 - || kind === 208 - || kind === 214 - || kind === 215 - || kind === 213 - || kind === 210 - || kind === 221 - || kind === 218 - || kind === 220 - || kind === 222 - || kind === 223 - || kind === 207 + return kind === 218 + || kind === 217 + || kind === 225 || kind === 212 + || kind === 210 + || kind === 209 + || kind === 215 + || kind === 216 + || kind === 214 + || kind === 211 + || kind === 222 || kind === 219 - || kind === 297 - || kind === 300 - || kind === 299; + || kind === 221 + || kind === 223 + || kind === 224 + || kind === 208 + || kind === 213 + || kind === 220 + || kind === 295 + || kind === 298 + || kind === 297; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -11158,96 +11446,98 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 206; + || kind === 207; } ts.isStatement = isStatement; function isModuleReference(node) { var kind = node.kind; - return kind === 247 - || kind === 142 - || kind === 70; + return kind === 248 + || kind === 143 + || kind === 71; } ts.isModuleReference = isModuleReference; function isJsxOpeningElement(node) { - return node.kind === 250; + return node.kind === 251; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 251; + return node.kind === 252; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 98 - || kind === 70 - || kind === 178; + return kind === 99 + || kind === 71 + || kind === 179; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 248 - || kind === 255 - || kind === 249 + return kind === 249 + || kind === 256 + || kind === 250 || kind === 10; } ts.isJsxChild = isJsxChild; function isJsxAttributes(node) { var kind = node.kind; - return kind === 253; + return kind === 254; } ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 252 - || kind === 254; + return kind === 253 + || kind === 255; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 254; + return node.kind === 255; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 252; + return node.kind === 253; } ts.isJsxAttribute = isJsxAttribute; - function isJsxOpeningLikeElement(node) { - return node.kind === 250 || node.kind === 249; - } - ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 - || kind === 255; + || kind === 256; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isJsxOpeningLikeElement(node) { + var kind = node.kind; + return kind === 251 + || kind === 250; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 256 - || kind === 257; + return kind === 257 + || kind === 258; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 258; + return node.kind === 259; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 259; + return node.kind === 260; } ts.isCatchClause = isCatchClause; function isPropertyAssignment(node) { - return node.kind === 260; + return node.kind === 261; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 261; + return node.kind === 262; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; function isEnumMember(node) { - return node.kind === 263; + return node.kind === 264; } ts.isEnumMember = isEnumMember; function isSourceFile(node) { - return node.kind === 264; + return node.kind === 265; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -11259,10 +11549,11 @@ var ts; function getDefaultLibFileName(options) { switch (options.target) { case 5: + return "lib.esnext.full.d.ts"; case 4: - return "lib.es2017.d.ts"; + return "lib.es2017.full.d.ts"; case 3: - return "lib.es2016.d.ts"; + return "lib.es2016.full.d.ts"; case 2: return "lib.es6.d.ts"; default: @@ -11386,9 +11677,9 @@ var ts; } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 144) { + if (d && d.kind === 145) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 230) { return current; } } @@ -11396,11 +11687,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92) && node.parent.kind === 151 && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92) && node.parent.kind === 152 && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 175 || ts.isBindingPattern(node))) { + while (node && (node.kind === 176 || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -11408,14 +11699,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 225) { + if (node.kind === 226) { node = node.parent; } - if (node && node.kind === 226) { + if (node && node.kind === 227) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 207) { + if (node && node.kind === 208) { flags |= ts.getModifierFlags(node); } return flags; @@ -11424,14 +11715,14 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 225) { + if (node.kind === 226) { node = node.parent; } - if (node && node.kind === 226) { + if (node && node.kind === 227) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 207) { + if (node && node.kind === 208) { flags |= node.flags; } return flags; @@ -11498,7 +11789,7 @@ var ts; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { + if (node === undefined || isParseTreeNode(node)) { return node; } node = getOriginalNode(node); @@ -11577,6 +11868,7 @@ var ts; function createNumericLiteral(value) { var node = createSynthesizedNode(8); node.text = value; + node.numericLiteralFlags = 0; return node; } ts.createNumericLiteral = createNumericLiteral; @@ -11591,7 +11883,7 @@ var ts; return node; } function createIdentifier(text) { - var node = createSynthesizedNode(70); + var node = createSynthesizedNode(71); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0; node.autoGenerateKind = 0; @@ -11641,27 +11933,27 @@ var ts; } ts.createToken = createToken; function createSuper() { - return createSynthesizedNode(96); + return createSynthesizedNode(97); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(98); + return createSynthesizedNode(99); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(94); + return createSynthesizedNode(95); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(100); + return createSynthesizedNode(101); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(85); + return createSynthesizedNode(86); } ts.createFalse = createFalse; function createQualifiedName(left, right) { - var node = createSynthesizedNode(142); + var node = createSynthesizedNode(143); node.left = left; node.right = asName(right); return node; @@ -11675,7 +11967,7 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function createComputedPropertyName(expression) { - var node = createSynthesizedNode(143); + var node = createSynthesizedNode(144); node.expression = expression; return node; } @@ -11686,8 +11978,285 @@ var ts; : node; } ts.updateComputedPropertyName = updateComputedPropertyName; + function createSignatureDeclaration(kind, typeParameters, parameters, type) { + var signatureDeclaration = createSynthesizedNode(kind); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + ts.createSignatureDeclaration = createSignatureDeclaration; + function updateSignatureDeclaration(node, typeParameters, parameters, type) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + function createFunctionTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(160, typeParameters, parameters, type); + } + ts.createFunctionTypeNode = createFunctionTypeNode; + function updateFunctionTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateFunctionTypeNode = updateFunctionTypeNode; + function createConstructorTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(161, typeParameters, parameters, type); + } + ts.createConstructorTypeNode = createConstructorTypeNode; + function updateConstructorTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructorTypeNode = updateConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(155, typeParameters, parameters, type); + } + ts.createCallSignatureDeclaration = createCallSignatureDeclaration; + function updateCallSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateCallSignatureDeclaration = updateCallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(156, typeParameters, parameters, type); + } + ts.createConstructSignatureDeclaration = createConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructSignatureDeclaration = updateConstructSignatureDeclaration; + function createMethodSignature(typeParameters, parameters, type, name, questionToken) { + var methodSignature = createSignatureDeclaration(150, typeParameters, parameters, type); + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + ts.createMethodSignature = createMethodSignature; + function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + ts.updateMethodSignature = updateMethodSignature; + function createKeywordTypeNode(kind) { + return createSynthesizedNode(kind); + } + ts.createKeywordTypeNode = createKeywordTypeNode; + function createThisTypeNode() { + return createSynthesizedNode(169); + } + ts.createThisTypeNode = createThisTypeNode; + function createLiteralTypeNode(literal) { + var literalTypeNode = createSynthesizedNode(173); + literalTypeNode.literal = literal; + return literalTypeNode; + } + ts.createLiteralTypeNode = createLiteralTypeNode; + function updateLiteralTypeNode(node, literal) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + ts.updateLiteralTypeNode = updateLiteralTypeNode; + function createTypeReferenceNode(typeName, typeArguments) { + var typeReference = createSynthesizedNode(159); + typeReference.typeName = asName(typeName); + typeReference.typeArguments = asNodeArray(typeArguments); + return typeReference; + } + ts.createTypeReferenceNode = createTypeReferenceNode; + function updateTypeReferenceNode(node, typeName, typeArguments) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + ts.updateTypeReferenceNode = updateTypeReferenceNode; + function createTypePredicateNode(parameterName, type) { + var typePredicateNode = createSynthesizedNode(158); + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + ts.createTypePredicateNode = createTypePredicateNode; + function updateTypePredicateNode(node, parameterName, type) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function createTypeQueryNode(exprName) { + var typeQueryNode = createSynthesizedNode(162); + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + ts.createTypeQueryNode = createTypeQueryNode; + function updateTypeQueryNode(node, exprName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; + } + ts.updateTypeQueryNode = updateTypeQueryNode; + function createArrayTypeNode(elementType) { + var arrayTypeNode = createSynthesizedNode(164); + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + ts.createArrayTypeNode = createArrayTypeNode; + function updateArrayTypeNode(node, elementType) { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + ts.updateArrayTypeNode = updateArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind, types) { + var unionTypeNode = createSynthesizedNode(kind); + unionTypeNode.types = createNodeArray(types); + return unionTypeNode; + } + ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node, types) { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + ts.updateUnionOrIntersectionTypeNode = updateUnionOrIntersectionTypeNode; + function createParenthesizedType(type) { + var node = createSynthesizedNode(168); + node.type = type; + return node; + } + ts.createParenthesizedType = createParenthesizedType; + function updateParenthesizedType(node, type) { + return node.type !== type + ? updateNode(createParenthesizedType(type), node) + : node; + } + ts.updateParenthesizedType = updateParenthesizedType; + function createTypeLiteralNode(members) { + var typeLiteralNode = createSynthesizedNode(163); + typeLiteralNode.members = createNodeArray(members); + return typeLiteralNode; + } + ts.createTypeLiteralNode = createTypeLiteralNode; + function updateTypeLiteralNode(node, members) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + ts.updateTypeLiteralNode = updateTypeLiteralNode; + function createTupleTypeNode(elementTypes) { + var tupleTypeNode = createSynthesizedNode(165); + tupleTypeNode.elementTypes = createNodeArray(elementTypes); + return tupleTypeNode; + } + ts.createTupleTypeNode = createTupleTypeNode; + function updateTypleTypeNode(node, elementTypes) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + ts.updateTypleTypeNode = updateTypleTypeNode; + function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { + var mappedTypeNode = createSynthesizedNode(172); + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + ts.createMappedTypeNode = createMappedTypeNode; + function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + ts.updateMappedTypeNode = updateMappedTypeNode; + function createTypeOperatorNode(type) { + var typeOperatorNode = createSynthesizedNode(170); + typeOperatorNode.operator = 127; + typeOperatorNode.type = type; + return typeOperatorNode; + } + ts.createTypeOperatorNode = createTypeOperatorNode; + function updateTypeOperatorNode(node, type) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + ts.updateTypeOperatorNode = updateTypeOperatorNode; + function createIndexedAccessTypeNode(objectType, indexType) { + var indexedAccessTypeNode = createSynthesizedNode(171); + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node, objectType, indexType) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; + function createTypeParameterDeclaration(name, constraint, defaultType) { + var typeParameter = createSynthesizedNode(145); + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultType; + return typeParameter; + } + ts.createTypeParameterDeclaration = createTypeParameterDeclaration; + function updateTypeParameterDeclaration(node, name, constraint, defaultType) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) + : node; + } + ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; + function createPropertySignature(name, questionToken, type, initializer) { + var propertySignature = createSynthesizedNode(148); + propertySignature.name = asName(name); + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + ts.createPropertySignature = createPropertySignature; + function updatePropertySignature(node, name, questionToken, type, initializer) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + ts.updatePropertySignature = updatePropertySignature; + function createIndexSignatureDeclaration(decorators, modifiers, parameters, type) { + var indexSignature = createSynthesizedNode(157); + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; + return indexSignature; + } + ts.createIndexSignatureDeclaration = createIndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node, decorators, modifiers, parameters, type) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) + : node; + } + ts.updateIndexSignatureDeclaration = updateIndexSignatureDeclaration; function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(145); + var node = createSynthesizedNode(146); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -11698,11 +12267,12 @@ var ts; return node; } ts.createParameter = createParameter; - function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { + function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -11710,7 +12280,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(146); + var node = createSynthesizedNode(147); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -11722,7 +12292,7 @@ var ts; } ts.updateDecorator = updateDecorator; function createProperty(decorators, modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148); + var node = createSynthesizedNode(149); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11742,33 +12312,35 @@ var ts; : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(150); + function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(151); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - ts.createMethod = createMethod; - function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + ts.createMethodDeclaration = createMethodDeclaration; + function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(151); + var node = createSynthesizedNode(152); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -11788,7 +12360,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(152); + var node = createSynthesizedNode(153); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11811,7 +12383,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(153); + var node = createSynthesizedNode(154); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11832,7 +12404,7 @@ var ts; } ts.updateSetAccessor = updateSetAccessor; function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(173); + var node = createSynthesizedNode(174); node.elements = createNodeArray(elements); return node; } @@ -11844,7 +12416,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(174); + var node = createSynthesizedNode(175); node.elements = createNodeArray(elements); return node; } @@ -11855,10 +12427,10 @@ var ts; : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer) { - var node = createSynthesizedNode(175); - node.propertyName = asName(propertyName); + function createBindingElement(dotDotDotToken, propertyName, name, initializer) { + var node = createSynthesizedNode(176); node.dotDotDotToken = dotDotDotToken; + node.propertyName = asName(propertyName); node.name = asName(name); node.initializer = initializer; return node; @@ -11869,12 +12441,12 @@ var ts; || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer - ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) : node; } ts.updateBindingElement = updateBindingElement; function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(176); + var node = createSynthesizedNode(177); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -11889,7 +12461,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(177); + var node = createSynthesizedNode(178); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11904,10 +12476,10 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(178); + var node = createSynthesizedNode(179); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); - setEmitFlags(node, 65536); + setEmitFlags(node, 131072); return node; } ts.createPropertyAccess = createPropertyAccess; @@ -11919,7 +12491,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(179); + var node = createSynthesizedNode(180); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -11933,7 +12505,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(180); + var node = createSynthesizedNode(181); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -11949,7 +12521,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(181); + var node = createSynthesizedNode(182); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -11965,7 +12537,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template) { - var node = createSynthesizedNode(182); + var node = createSynthesizedNode(183); node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; @@ -11979,7 +12551,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(183); + var node = createSynthesizedNode(184); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -11993,7 +12565,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(184); + var node = createSynthesizedNode(185); node.expression = expression; return node; } @@ -12005,7 +12577,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(185); + var node = createSynthesizedNode(186); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -12016,24 +12588,25 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.name !== name || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(186); + var node = createSynthesizedNode(187); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -12049,7 +12622,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(187); + var node = createSynthesizedNode(188); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -12061,7 +12634,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(188); + var node = createSynthesizedNode(189); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -12073,7 +12646,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(189); + var node = createSynthesizedNode(190); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -12085,7 +12658,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(190); + var node = createSynthesizedNode(191); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -12097,7 +12670,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(191); + var node = createSynthesizedNode(192); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -12110,7 +12683,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(192); + var node = createSynthesizedNode(193); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -12123,7 +12696,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(193); + var node = createSynthesizedNode(194); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, true, undefined); @@ -12140,11 +12713,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(194); + var node = createSynthesizedNode(195); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(55); + node.colonToken = whenFalse ? colonToken : createToken(56); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -12158,7 +12731,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(195); + var node = createSynthesizedNode(196); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -12172,20 +12745,21 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(196); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(197); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; - function updateYield(node, expression) { + function updateYield(node, asteriskToken, expression) { return node.expression !== expression - ? updateNode(createYield(node.asteriskToken, expression), node) + || node.asteriskToken !== asteriskToken + ? updateNode(createYield(asteriskToken, expression), node) : node; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(197); + var node = createSynthesizedNode(198); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -12197,7 +12771,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(198); + var node = createSynthesizedNode(199); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -12218,11 +12792,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(199); + return createSynthesizedNode(200); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(200); + var node = createSynthesizedNode(201); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -12236,7 +12810,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(201); + var node = createSynthesizedNode(202); node.expression = expression; node.type = type; return node; @@ -12250,7 +12824,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(202); + var node = createSynthesizedNode(203); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -12262,7 +12836,7 @@ var ts; } ts.updateNonNullExpression = updateNonNullExpression; function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(204); + var node = createSynthesizedNode(205); node.expression = expression; node.literal = literal; return node; @@ -12276,7 +12850,7 @@ var ts; } ts.updateTemplateSpan = updateTemplateSpan; function createBlock(statements, multiLine) { - var block = createSynthesizedNode(206); + var block = createSynthesizedNode(207); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -12290,7 +12864,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(207); + var node = createSynthesizedNode(208); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -12305,7 +12879,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(226); + var node = createSynthesizedNode(227); node.flags |= flags; node.declarations = createNodeArray(declarations); return node; @@ -12318,7 +12892,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(225); + var node = createSynthesizedNode(226); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -12334,11 +12908,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement() { - return createSynthesizedNode(208); + return createSynthesizedNode(209); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { - var node = createSynthesizedNode(209); + var node = createSynthesizedNode(210); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -12350,7 +12924,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(210); + var node = createSynthesizedNode(211); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -12366,7 +12940,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(211); + var node = createSynthesizedNode(212); node.statement = statement; node.expression = expression; return node; @@ -12380,7 +12954,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(212); + var node = createSynthesizedNode(213); node.expression = expression; node.statement = statement; return node; @@ -12394,7 +12968,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(213); + var node = createSynthesizedNode(214); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -12412,7 +12986,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(214); + var node = createSynthesizedNode(215); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -12427,24 +13001,26 @@ var ts; : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement) { - var node = createSynthesizedNode(215); + function createForOf(awaitModifier, initializer, expression, statement) { + var node = createSynthesizedNode(216); + node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; node.statement = statement; return node; } ts.createForOf = createForOf; - function updateForOf(node, initializer, expression, statement) { - return node.initializer !== initializer + function updateForOf(node, awaitModifier, initializer, expression, statement) { + return node.awaitModifier !== awaitModifier + || node.initializer !== initializer || node.expression !== expression || node.statement !== statement - ? updateNode(createForOf(initializer, expression, statement), node) + ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node) : node; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(216); + var node = createSynthesizedNode(217); node.label = asName(label); return node; } @@ -12456,7 +13032,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(217); + var node = createSynthesizedNode(218); node.label = asName(label); return node; } @@ -12468,7 +13044,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(218); + var node = createSynthesizedNode(219); node.expression = expression; return node; } @@ -12480,7 +13056,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(219); + var node = createSynthesizedNode(220); node.expression = expression; node.statement = statement; return node; @@ -12494,7 +13070,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(220); + var node = createSynthesizedNode(221); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -12508,7 +13084,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(221); + var node = createSynthesizedNode(222); node.label = asName(label); node.statement = statement; return node; @@ -12522,7 +13098,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(222); + var node = createSynthesizedNode(223); node.expression = expression; return node; } @@ -12534,7 +13110,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(223); + var node = createSynthesizedNode(224); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -12550,7 +13126,7 @@ var ts; } ts.updateTry = updateTry; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(227); + var node = createSynthesizedNode(228); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -12562,20 +13138,21 @@ var ts; return node; } ts.createFunctionDeclaration = createFunctionDeclaration; - function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(228); + var node = createSynthesizedNode(229); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -12597,7 +13174,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(231); + var node = createSynthesizedNode(232); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -12615,7 +13192,7 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(232); + var node = createSynthesizedNode(233); node.flags |= flags; node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -12646,7 +13223,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(234); + var node = createSynthesizedNode(235); node.clauses = createNodeArray(clauses); return node; } @@ -12658,7 +13235,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(236); + var node = createSynthesizedNode(237); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -12676,7 +13253,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(237); + var node = createSynthesizedNode(238); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -12693,7 +13270,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(238); + var node = createSynthesizedNode(239); node.name = name; node.namedBindings = namedBindings; return node; @@ -12707,7 +13284,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(239); + var node = createSynthesizedNode(240); node.name = name; return node; } @@ -12719,7 +13296,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(240); + var node = createSynthesizedNode(241); node.elements = createNodeArray(elements); return node; } @@ -12731,7 +13308,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(241); + var node = createSynthesizedNode(242); node.propertyName = propertyName; node.name = name; return node; @@ -12745,7 +13322,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(242); + var node = createSynthesizedNode(243); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -12762,7 +13339,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(243); + var node = createSynthesizedNode(244); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -12780,7 +13357,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(244); + var node = createSynthesizedNode(245); node.elements = createNodeArray(elements); return node; } @@ -12791,21 +13368,22 @@ var ts; : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName) { - var node = createSynthesizedNode(245); - node.name = asName(name); + function createExportSpecifier(propertyName, name) { + var node = createSynthesizedNode(246); node.propertyName = asName(propertyName); + node.name = asName(name); return node; } ts.createExportSpecifier = createExportSpecifier; - function updateExportSpecifier(node, name, propertyName) { - return node.name !== name || node.propertyName !== propertyName - ? updateNode(createExportSpecifier(name, propertyName), node) + function updateExportSpecifier(node, propertyName, name) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createExportSpecifier(propertyName, name), node) : node; } ts.updateExportSpecifier = updateExportSpecifier; function createExternalModuleReference(expression) { - var node = createSynthesizedNode(247); + var node = createSynthesizedNode(248); node.expression = expression; return node; } @@ -12817,7 +13395,7 @@ var ts; } ts.updateExternalModuleReference = updateExternalModuleReference; function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(248); + var node = createSynthesizedNode(249); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -12833,7 +13411,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes) { - var node = createSynthesizedNode(249); + var node = createSynthesizedNode(250); node.tagName = tagName; node.attributes = attributes; return node; @@ -12847,7 +13425,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes) { - var node = createSynthesizedNode(250); + var node = createSynthesizedNode(251); node.tagName = tagName; node.attributes = attributes; return node; @@ -12861,7 +13439,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(251); + var node = createSynthesizedNode(252); node.tagName = tagName; return node; } @@ -12873,7 +13451,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttributes(properties) { - var jsxAttributes = createSynthesizedNode(253); + var jsxAttributes = createSynthesizedNode(254); jsxAttributes.properties = createNodeArray(properties); return jsxAttributes; } @@ -12886,7 +13464,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(252); + var node = createSynthesizedNode(253); node.name = name; node.initializer = initializer; return node; @@ -12900,7 +13478,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(254); + var node = createSynthesizedNode(255); node.expression = expression; return node; } @@ -12911,8 +13489,8 @@ var ts; : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken) { - var node = createSynthesizedNode(255); + function createJsxExpression(dotDotDotToken, expression) { + var node = createSynthesizedNode(256); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -12920,12 +13498,12 @@ var ts; ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { return node.expression !== expression - ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node) : node; } ts.updateJsxExpression = updateJsxExpression; function createHeritageClause(token, types) { - var node = createSynthesizedNode(258); + var node = createSynthesizedNode(259); node.token = token; node.types = createNodeArray(types); return node; @@ -12939,7 +13517,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(256); + var node = createSynthesizedNode(257); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -12953,7 +13531,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(257); + var node = createSynthesizedNode(258); node.statements = createNodeArray(statements); return node; } @@ -12966,7 +13544,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(259); + var node = createSynthesizedNode(260); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -12980,7 +13558,7 @@ var ts; } ts.updateCatchClause = updateCatchClause; function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(260); + var node = createSynthesizedNode(261); node.name = asName(name); node.questionToken = undefined; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -12995,18 +13573,12 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(261); + var node = createSynthesizedNode(262); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression) { - var node = createSynthesizedNode(262); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; - return node; - } - ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); @@ -13014,6 +13586,12 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(263); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { return updateNode(createSpreadAssignment(expression), node); @@ -13022,7 +13600,7 @@ var ts; } ts.updateSpreadAssignment = updateSpreadAssignment; function createEnumMember(name, initializer) { - var node = createSynthesizedNode(263); + var node = createSynthesizedNode(264); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -13037,7 +13615,7 @@ var ts; ts.updateEnumMember = updateEnumMember; function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createSynthesizedNode(264); + var updated = createSynthesizedNode(265); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -13106,28 +13684,28 @@ var ts; } ts.getMutableClone = getMutableClone; function createNotEmittedStatement(original) { - var node = createSynthesizedNode(297); + var node = createSynthesizedNode(295); node.original = original; setTextRange(node, original); return node; } ts.createNotEmittedStatement = createNotEmittedStatement; function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(300); + var node = createSynthesizedNode(298); node.emitNode = {}; node.original = original; return node; } ts.createEndOfDeclarationMarker = createEndOfDeclarationMarker; function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(299); + var node = createSynthesizedNode(297); node.emitNode = {}; node.original = original; return node; } ts.createMergeDeclarationMarker = createMergeDeclarationMarker; function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(298); + var node = createSynthesizedNode(296); node.expression = expression; node.original = original; setTextRange(node, original); @@ -13142,7 +13720,7 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createBundle(sourceFiles) { - var node = ts.createNode(265); + var node = ts.createNode(266); node.sourceFiles = sourceFiles; return node; } @@ -13155,47 +13733,47 @@ var ts; } ts.updateBundle = updateBundle; function createComma(left, right) { - return createBinary(left, 25, right); + return createBinary(left, 26, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 26, right); + return createBinary(left, 27, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 57, right); + return createBinary(left, 58, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 33, right); + return createBinary(left, 34, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 34, right); + return createBinary(left, 35, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 36, right); + return createBinary(left, 37, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 37, right); + return createBinary(left, 38, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 42); + return createPostfix(operand, 43); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 52, right); + return createBinary(left, 53, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 53, right); + return createBinary(left, 54, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(50, operand); + return createPrefix(51, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -13207,7 +13785,7 @@ var ts; } ts.createExportDefault = createExportDefault; function createExternalModuleExport(exportName) { - return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(exportName)])); + return createExportDeclaration(undefined, undefined, createNamedExports([createExportSpecifier(undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; function asName(name) { @@ -13237,7 +13815,7 @@ var ts; function getOrCreateEmitNode(node) { if (!node.emitNode) { if (ts.isParseTreeNode(node)) { - if (node.kind === 264) { + if (node.kind === 265) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -13299,6 +13877,34 @@ var ts; return node; } ts.setCommentRange = setCommentRange; + function getSyntheticLeadingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.leadingComments; + } + ts.getSyntheticLeadingComments = getSyntheticLeadingComments; + function setSyntheticLeadingComments(node, comments) { + getOrCreateEmitNode(node).leadingComments = comments; + return node; + } + ts.setSyntheticLeadingComments = setSyntheticLeadingComments; + function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticLeadingComment = addSyntheticLeadingComment; + function getSyntheticTrailingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.trailingComments; + } + ts.getSyntheticTrailingComments = getSyntheticTrailingComments; + function setSyntheticTrailingComments(node, comments) { + getOrCreateEmitNode(node).trailingComments = comments; + return node; + } + ts.setSyntheticTrailingComments = setSyntheticTrailingComments; + function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticTrailingComment = addSyntheticTrailingComment; function getConstantValue(node) { var emitNode = node.emitNode; return emitNode && emitNode.constantValue; @@ -13392,9 +13998,13 @@ var ts; } ts.setOriginalNode = setOriginalNode; function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + var flags = sourceEmitNode.flags, leadingComments = sourceEmitNode.leadingComments, trailingComments = sourceEmitNode.trailingComments, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; if (!destEmitNode) destEmitNode = {}; + if (leadingComments) + destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) + destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; if (commentRange) @@ -13516,11 +14126,65 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 | 2); } ts.getHelperName = getHelperName; + var valuesHelper = { + name: "typescript:values", + scoped: false, + text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };\n " + }; + function createValuesHelper(context, expression, location) { + context.requestEmitHelper(valuesHelper); + return ts.setTextRange(ts.createCall(getHelperName("__values"), undefined, [expression]), location); + } + ts.createValuesHelper = createValuesHelper; + var readHelper = { + name: "typescript:read", + scoped: false, + text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };\n " + }; + function createReadHelper(context, iteratorRecord, count, location) { + context.requestEmitHelper(readHelper); + return ts.setTextRange(ts.createCall(getHelperName("__read"), undefined, count !== undefined + ? [iteratorRecord, ts.createLiteral(count)] + : [iteratorRecord]), location); + } + ts.createReadHelper = createReadHelper; + var spreadHelper = { + name: "typescript:spread", + scoped: false, + text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" + }; + function createSpreadHelper(context, argumentList, location) { + context.requestEmitHelper(readHelper); + context.requestEmitHelper(spreadHelper); + return ts.setTextRange(ts.createCall(getHelperName("__spread"), undefined, argumentList), location); + } + ts.createSpreadHelper = createSpreadHelper; + function createForOfBindingStatement(node, boundValue) { + if (ts.isVariableDeclarationList(node)) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, boundValue); + return ts.setTextRange(ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), node); + } + else { + var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), node); + return ts.setTextRange(ts.createStatement(updatedExpression), node); + } + } + ts.createForOfBindingStatement = createForOfBindingStatement; + function insertLeadingStatement(dest, source) { + if (ts.isBlock(dest)) { + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + } + else { + return ts.createBlock(ts.createNodeArray([dest, source]), true); + } + } + ts.insertLeadingStatement = insertLeadingStatement; function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 222 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -13532,19 +14196,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 70: + case 71: return cacheIdentifiers; - case 98: + case 99: case 8: case 9: return false; - case 176: + case 177: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 177: + case 178: return target.properties.length > 0; default: return true; @@ -13558,15 +14222,19 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 96) { + else if (callee.kind === 97) { thisArg = ts.createThis(); target = languageVersion < 2 ? ts.setTextRange(ts.createIdentifier("_super"), callee) : callee; } + else if (ts.getEmitFlags(callee) & 4096) { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(callee); + } else { switch (callee.kind) { - case 178: { + case 179: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createPropertyAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.name); @@ -13578,7 +14246,7 @@ var ts; } break; } - case 179: { + case 180: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { thisArg = ts.createTempVariable(recordTempVariable); target = ts.createElementAccess(ts.setTextRange(ts.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression); @@ -13629,14 +14297,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 152: case 153: + case 154: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 260: - return createExpressionForPropertyAssignment(property, receiver); case 261: + return createExpressionForPropertyAssignment(property, receiver); + case 262: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 150: + case 151: return createExpressionForMethodDeclaration(property, receiver); } } @@ -13679,6 +14347,14 @@ var ts; function createExpressionForMethodDeclaration(method, receiver) { return ts.aggregateTransformFlags(ts.setOriginalNode(ts.setTextRange(ts.createAssignment(createMemberAccessForPropertyName(receiver, method.name, method.name), ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(method.modifiers, method.asteriskToken, undefined, undefined, method.parameters, undefined, method.body), method), method)), method), method)); } + function getInternalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384 | 32768); + } + ts.getInternalName = getInternalName; + function isInternalName(node) { + return (ts.getEmitFlags(node) & 32768) !== 0; + } + ts.isInternalName = isInternalName; function getLocalName(node, allowComments, allowSourceMaps) { return getName(node, allowComments, allowSourceMaps, 16384); } @@ -13740,7 +14416,12 @@ var ts; function isUseStrictPrologue(node) { return node.expression.text === "use strict"; } - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + function addPrologue(target, source, ensureUseStrict, visitor) { + var offset = addStandardPrologue(target, source, ensureUseStrict); + return addCustomPrologue(target, source, offset, visitor); + } + ts.addPrologue = addPrologue; + function addStandardPrologue(target, source, ensureUseStrict) { ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; @@ -13761,9 +14442,14 @@ var ts; if (ensureUseStrict && !foundUseStrict) { target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } + return statementOffset; + } + ts.addStandardPrologue = addStandardPrologue; + function addCustomPrologue(target, source, statementOffset, visitor) { + var numStatements = source.length; while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 524288) { + if (ts.getEmitFlags(statement) & 1048576) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -13773,7 +14459,7 @@ var ts; } return statementOffset; } - ts.addPrologueDirectives = addPrologueDirectives; + ts.addCustomPrologue = addCustomPrologue; function startsWithUseStrict(statements) { var firstStatement = ts.firstOrUndefined(statements); return firstStatement !== undefined @@ -13803,9 +14489,19 @@ var ts; return statements; } ts.ensureUseStrict = ensureUseStrict; + function parenthesizeConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(195, 55); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeConditionalHead = parenthesizeConditionalHead; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); - if (skipped.kind === 184) { + if (skipped.kind === 185) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -13814,15 +14510,15 @@ var ts; } ts.parenthesizeBinaryOperand = parenthesizeBinaryOperand; function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { - var binaryOperatorPrecedence = ts.getOperatorPrecedence(193, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(193, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(194, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(194, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { case -1: if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 - && operand.kind === 196) { + && operand.kind === 197) { return false; } return true; @@ -13838,7 +14534,7 @@ var ts; if (operatorHasAssociativeProperty(binaryOperator)) { return false; } - if (binaryOperator === 36) { + if (binaryOperator === 37) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -13851,17 +14547,17 @@ var ts; } } function operatorHasAssociativeProperty(binaryOperator) { - return binaryOperator === 38 + return binaryOperator === 39 + || binaryOperator === 49 || binaryOperator === 48 - || binaryOperator === 47 - || binaryOperator === 49; + || binaryOperator === 50; } function getLiteralKindOfBinaryPlusOperand(node) { node = skipPartiallyEmittedExpressions(node); if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 193 && node.operatorToken.kind === 36) { + if (node.kind === 194 && node.operatorToken.kind === 37) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -13876,7 +14572,7 @@ var ts; return 0; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(194, 54); + var conditionalPrecedence = ts.getOperatorPrecedence(195, 55); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1) { @@ -13886,7 +14582,7 @@ var ts; } ts.parenthesizeForConditionalHead = parenthesizeForConditionalHead; function parenthesizeSubexpressionOfConditionalExpression(e) { - return e.kind === 193 && e.operatorToken.kind === 25 + return e.kind === 194 && e.operatorToken.kind === 26 ? ts.createParen(e) : e; } @@ -13894,9 +14590,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 180: - return ts.createParen(expression); case 181: + return ts.createParen(expression); + case 182: return emittedExpression.arguments ? expression : ts.createParen(expression); @@ -13907,8 +14603,7 @@ var ts; function parenthesizeForAccess(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 181 || emittedExpression.arguments) - && emittedExpression.kind !== 8) { + && (emittedExpression.kind !== 182 || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -13946,7 +14641,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(193, 25); + var commaPrecedence = ts.getOperatorPrecedence(194, 26); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -13957,7 +14652,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 185 || kind === 186) { + if (kind === 186 || kind === 187) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -13965,7 +14660,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 177 || leftmostExpressionKind === 185) { + if (leftmostExpressionKind === 178 || leftmostExpressionKind === 186) { return ts.setTextRange(ts.createParen(expression), expression); } } @@ -13983,21 +14678,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 192: + case 193: node = node.operand; continue; - case 193: + case 194: node = node.left; continue; - case 194: + case 195: node = node.condition; continue; + case 181: case 180: case 179: - case 178: node = node.expression; continue; - case 298: + case 296: node = node.expression; continue; } @@ -14005,8 +14700,7 @@ var ts; } } function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 177) { + if (!ts.isBlock(body) && getLeftmostExpression(body).kind === 178) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -14038,7 +14732,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 184) { + while (node.kind === 185) { node = node.expression; } return node; @@ -14052,7 +14746,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 298) { + while (node.kind === 296) { node = node.expression; } return node; @@ -14095,10 +14789,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 237 && node.importClause) { + if (node.kind === 238 && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 243 && node.moduleSpecifier) { + if (node.kind === 244 && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -14160,11 +14854,11 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 260: - return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 261: - return bindingElement.name; + return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); case 262: + return bindingElement.name; + case 263: return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } return undefined; @@ -14180,11 +14874,11 @@ var ts; ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement; function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 145: - case 175: + case 146: + case 176: return bindingElement.dotDotDotToken; - case 197: - case 262: + case 198: + case 263: return bindingElement; } return undefined; @@ -14192,7 +14886,7 @@ var ts; ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement; function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 175: + case 176: if (bindingElement.propertyName) { var propertyName = bindingElement.propertyName; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -14200,7 +14894,7 @@ var ts; : propertyName; } break; - case 260: + case 261: if (bindingElement.name) { var propertyName = bindingElement.name; return ts.isComputedPropertyName(propertyName) && ts.isStringOrNumericLiteral(propertyName.expression) @@ -14208,7 +14902,7 @@ var ts; : propertyName; } break; - case 262: + case 263: return bindingElement.name; } var target = getTargetOfBindingOrAssignmentElement(bindingElement); @@ -14222,11 +14916,11 @@ var ts; ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement; function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 173: case 174: - case 176: - return name.elements; + case 175: case 177: + return name.elements; + case 178: return name.properties; } } @@ -14265,11 +14959,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 174: - case 176: - return convertToArrayAssignmentPattern(node); - case 173: + case 175: case 177: + return convertToArrayAssignmentPattern(node); + case 174: + case 178: return convertToObjectAssignmentPattern(node); } } @@ -14315,15 +15009,15 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 237: + case 238: externalImports.push(node); break; - case 236: - if (node.moduleReference.kind === 247) { + case 237: + if (node.moduleReference.kind === 248) { externalImports.push(node); } break; - case 243: + case 244: if (node.moduleSpecifier) { if (!node.exportClause) { externalImports.push(node); @@ -14350,12 +15044,12 @@ var ts; } } break; - case 242: + case 243: if (node.isExportEquals && !exportEquals) { exportEquals = node; } break; - case 207: + case 208: if (ts.hasModifier(node, 1)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -14363,7 +15057,7 @@ var ts; } } break; - case 227: + case 228: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -14381,7 +15075,7 @@ var ts; } } break; - case 228: + case 229: if (ts.hasModifier(node, 1)) { if (ts.hasModifier(node, 512)) { if (!hasExportDefault) { @@ -14439,13 +15133,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 264) { + if (kind === 265) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 70) { + else if (kind === 71) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 142) { + else if (kind < 143) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -14481,29 +15175,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 142: + case 143: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 144: + case 145: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 261: + case 262: 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 262: + case 263: return visitNode(cbNode, node.expression); - case 145: + case 146: + case 149: case 148: - case 147: - case 260: - case 225: - case 175: + case 261: + case 226: + case 176: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -14512,24 +15206,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 159: case 160: - case 154: + case 161: case 155: case 156: + case 157: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: + case 228: + case 187: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14540,174 +15234,168 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 158: + case 159: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 157: + case 158: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 161: - return visitNode(cbNode, node.exprName); case 162: - return visitNodes(cbNodes, node.members); + return visitNode(cbNode, node.exprName); case 163: - return visitNode(cbNode, node.elementType); + return visitNodes(cbNodes, node.members); case 164: - return visitNodes(cbNodes, node.elementTypes); + return visitNode(cbNode, node.elementType); case 165: + return visitNodes(cbNodes, node.elementTypes); case 166: - return visitNodes(cbNodes, node.types); case 167: - case 169: - return visitNode(cbNode, node.type); + return visitNodes(cbNodes, node.types); + case 168: case 170: + return visitNode(cbNode, node.type); + case 171: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 171: + case 172: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 172: - return visitNode(cbNode, node.literal); case 173: + return visitNode(cbNode, node.literal); case 174: - return visitNodes(cbNodes, node.elements); - case 176: + case 175: return visitNodes(cbNodes, node.elements); case 177: - return visitNodes(cbNodes, node.properties); + return visitNodes(cbNodes, node.elements); case 178: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.name); + return visitNodes(cbNodes, node.properties); case 179: return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.argumentExpression); + visitNode(cbNode, node.name); case 180: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.argumentExpression); case 181: + case 182: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 182: + case 183: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 183: + case 184: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 184: - return visitNode(cbNode, node.expression); - case 187: + case 185: return visitNode(cbNode, node.expression); case 188: return visitNode(cbNode, node.expression); case 189: return visitNode(cbNode, node.expression); - case 191: - return visitNode(cbNode, node.operand); - case 196: - return visitNode(cbNode, node.asteriskToken) || - visitNode(cbNode, node.expression); case 190: return visitNode(cbNode, node.expression); case 192: return visitNode(cbNode, node.operand); + case 197: + return visitNode(cbNode, node.asteriskToken) || + visitNode(cbNode, node.expression); + case 191: + return visitNode(cbNode, node.expression); case 193: + return visitNode(cbNode, node.operand); + case 194: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 201: + case 202: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 202: - return visitNode(cbNode, node.expression); case 203: + return visitNode(cbNode, node.expression); + case 204: return visitNode(cbNode, node.name); - case 194: + case 195: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 197: + case 198: return visitNode(cbNode, node.expression); - case 206: - case 233: + case 207: + case 234: return visitNodes(cbNodes, node.statements); - case 264: + case 265: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 207: + case 208: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 226: + case 227: return visitNodes(cbNodes, node.declarations); - case 209: - return visitNode(cbNode, node.expression); case 210: + return visitNode(cbNode, node.expression); + case 211: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 211: + case 212: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 212: - return visitNode(cbNode, node.expression) || - visitNode(cbNode, node.statement); case 213: - return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.condition) || - visitNode(cbNode, node.incrementor) || + return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 214: return visitNode(cbNode, node.initializer) || - visitNode(cbNode, node.expression) || + visitNode(cbNode, node.condition) || + visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); case 215: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); case 216: - case 217: - return visitNode(cbNode, node.label); - case 218: - return visitNode(cbNode, node.expression); - case 219: - return visitNode(cbNode, node.expression) || + return visitNode(cbNode, node.awaitModifier) || + visitNode(cbNode, node.initializer) || + visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); + case 217: + case 218: + return visitNode(cbNode, node.label); + case 219: + return visitNode(cbNode, node.expression); case 220: + return visitNode(cbNode, node.expression) || + visitNode(cbNode, node.statement); + case 221: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 234: + case 235: return visitNodes(cbNodes, node.clauses); - case 256: + case 257: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 257: + case 258: return visitNodes(cbNodes, node.statements); - case 221: + case 222: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 222: - return visitNode(cbNode, node.expression); case 223: + return visitNode(cbNode, node.expression); + case 224: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 259: + case 260: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 146: + case 147: return visitNode(cbNode, node.expression); - case 228: - case 198: - 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 229: + case 199: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || @@ -14719,146 +15407,153 @@ 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 231: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || - visitNodes(cbNodes, node.members); - case 263: - return visitNode(cbNode, node.name) || - visitNode(cbNode, node.initializer); + visitNodes(cbNodes, node.typeParameters) || + visitNode(cbNode, node.type); case 232: + return visitNodes(cbNodes, node.decorators) || + visitNodes(cbNodes, node.modifiers) || + visitNode(cbNode, node.name) || + visitNodes(cbNodes, node.members); + case 264: + return visitNode(cbNode, node.name) || + visitNode(cbNode, node.initializer); + case 233: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 236: + case 237: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 237: + case 238: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 238: + case 239: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 235: - return visitNode(cbNode, node.name); - case 239: + case 236: return visitNode(cbNode, node.name); case 240: - case 244: + return visitNode(cbNode, node.name); + case 241: + case 245: return visitNodes(cbNodes, node.elements); - case 243: + case 244: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 241: - case 245: + case 242: + case 246: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 242: + case 243: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 195: + case 196: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 204: + case 205: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 143: + case 144: return visitNode(cbNode, node.expression); - case 258: + case 259: return visitNodes(cbNodes, node.types); - case 200: + case 201: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 247: - return visitNode(cbNode, node.expression); - case 246: - return visitNodes(cbNodes, node.decorators); case 248: + return visitNode(cbNode, node.expression); + case 247: + return visitNodes(cbNodes, node.decorators); + case 249: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 249: case 250: + case 251: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.attributes); - case 253: + case 254: return visitNodes(cbNodes, node.properties); - case 252: + case 253: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 254: - return visitNode(cbNode, node.expression); case 255: + return visitNode(cbNode, node.expression); + case 256: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 251: + case 252: return visitNode(cbNode, node.tagName); - case 266: + case 267: return visitNode(cbNode, node.type); - case 270: - return visitNodes(cbNodes, node.types); case 271: return visitNodes(cbNodes, node.types); - case 269: + case 272: + return visitNodes(cbNodes, node.types); + case 270: return visitNode(cbNode, node.elementType); + case 274: + return visitNode(cbNode, node.type); case 273: return visitNode(cbNode, node.type); - case 272: - return visitNode(cbNode, node.type); - case 274: + case 275: return visitNode(cbNode, node.literal); - case 276: + case 277: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 277: - return visitNode(cbNode, node.type); case 278: + return visitNode(cbNode, node.type); + case 279: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 279: - return visitNode(cbNode, node.type); case 280: return visitNode(cbNode, node.type); case 281: return visitNode(cbNode, node.type); - case 275: + case 282: + return visitNode(cbNode, node.type); + case 276: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 282: + case 283: return visitNodes(cbNodes, node.tags); - case 285: + case 286: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 286: - return visitNode(cbNode, node.typeExpression); case 287: return visitNode(cbNode, node.typeExpression); - case 284: - return visitNode(cbNode, node.typeExpression); case 288: - return visitNodes(cbNodes, node.typeParameters); + return visitNode(cbNode, node.typeExpression); + case 285: + return visitNode(cbNode, node.typeExpression); case 289: + return visitNodes(cbNodes, node.typeParameters); + case 290: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 291: + case 292: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 290: + case 291: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 298: + case 296: return visitNode(cbNode, node.expression); - case 292: + case 293: return visitNode(cbNode, node.literal); } } @@ -15022,7 +15717,7 @@ var ts; } Parser.fixupParentReferences = fixupParentReferences; function createSourceFile(fileName, languageVersion, scriptKind) { - var sourceFile = new SourceFileConstructor(264, 0, sourceText.length); + var sourceFile = new SourceFileConstructor(265, 0, sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15178,16 +15873,16 @@ var ts; return speculationHelper(callback, false); } function isIdentifier() { - if (token() === 70) { + if (token() === 71) { return true; } - if (token() === 115 && inYieldContext()) { + if (token() === 116 && inYieldContext()) { return false; } - if (token() === 120 && inAwaitContext()) { + if (token() === 121 && inAwaitContext()) { return false; } - return token() > 106; + return token() > 107; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -15228,20 +15923,20 @@ var ts; return finishNode(node); } function canParseSemicolon() { - if (token() === 24) { + if (token() === 25) { return true; } - return token() === 17 || token() === 1 || scanner.hasPrecedingLineBreak(); + return token() === 18 || token() === 1 || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 24) { + if (token() === 25) { nextToken(); } return true; } else { - return parseExpected(24); + return parseExpected(25); } } function createNode(kind, pos) { @@ -15249,8 +15944,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 142 ? new NodeConstructor(kind, pos, pos) : - kind === 70 ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 143 ? new NodeConstructor(kind, pos, pos) : + kind === 71 ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -15295,15 +15990,15 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(70); - if (token() !== 70) { + var node = createNode(71); + if (token() !== 71) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(70, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(71, false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -15320,7 +16015,7 @@ var ts; if (token() === 9 || token() === 8) { return parseLiteralNode(true); } - if (allowComputedPropertyNames && token() === 20) { + if (allowComputedPropertyNames && token() === 21) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -15335,10 +16030,10 @@ var ts; return token() === 9 || token() === 8 || ts.tokenIsIdentifierOrKeyword(token()); } function parseComputedPropertyName() { - var node = createNode(143); - parseExpected(20); - node.expression = allowInAnd(parseExpression); + var node = createNode(144); parseExpected(21); + node.expression = allowInAnd(parseExpression); + parseExpected(22); return finishNode(node); } function parseContextualModifier(t) { @@ -15352,20 +16047,20 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 75) { - return nextToken() === 82; + if (token() === 76) { + return nextToken() === 83; } - if (token() === 83) { + if (token() === 84) { nextToken(); - if (token() === 78) { + if (token() === 79) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 38 && token() !== 117 && token() !== 16 && canFollowModifier(); + return token() !== 39 && token() !== 118 && token() !== 17 && canFollowModifier(); } - if (token() === 78) { + if (token() === 79) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 114) { + if (token() === 115) { nextToken(); return canFollowModifier(); } @@ -15375,16 +16070,17 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 20 - || token() === 16 - || token() === 38 - || token() === 23 + return token() === 21 + || token() === 17 + || token() === 39 + || token() === 24 || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 74 || token() === 88 || - (token() === 119 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 75 || token() === 89 || + (token() === 117 && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 120 && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } function isListElement(parsingContext, inErrorRecovery) { var node = currentNode(parsingContext); @@ -15395,23 +16091,23 @@ var ts; case 0: case 1: case 3: - return !(token() === 24 && inErrorRecovery) && isStartOfStatement(); + return !(token() === 25 && inErrorRecovery) && isStartOfStatement(); case 2: - return token() === 72 || token() === 78; + return token() === 73 || token() === 79; case 4: return lookAhead(isTypeMemberStart); case 5: - return lookAhead(isClassMemberStart) || (token() === 24 && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 25 && !inErrorRecovery); case 6: - return token() === 20 || isLiteralPropertyName(); + return token() === 21 || isLiteralPropertyName(); case 12: - return token() === 20 || token() === 38 || token() === 23 || isLiteralPropertyName(); + return token() === 21 || token() === 39 || token() === 24 || isLiteralPropertyName(); case 17: return isLiteralPropertyName(); case 9: - return token() === 20 || token() === 23 || isLiteralPropertyName(); + return token() === 21 || token() === 24 || isLiteralPropertyName(); case 7: - if (token() === 16) { + if (token() === 17) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -15423,23 +16119,23 @@ var ts; case 8: return isIdentifierOrPattern(); case 10: - return token() === 25 || token() === 23 || isIdentifierOrPattern(); + return token() === 26 || token() === 24 || isIdentifierOrPattern(); case 18: return isIdentifier(); case 11: case 15: - return token() === 25 || token() === 23 || isStartOfExpression(); + return token() === 26 || token() === 24 || isStartOfExpression(); case 16: return isStartOfParameter(); case 19: case 20: - return token() === 25 || isStartOfType(); + return token() === 26 || isStartOfType(); case 21: return isHeritageClause(); case 22: return ts.tokenIsIdentifierOrKeyword(token()); case 13: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17; case 14: return true; case 23: @@ -15452,10 +16148,10 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 16); - if (nextToken() === 17) { + ts.Debug.assert(token() === 17); + if (nextToken() === 18) { var next = nextToken(); - return next === 25 || next === 16 || next === 84 || next === 107; + return next === 26 || next === 17 || next === 85 || next === 108; } return true; } @@ -15468,8 +16164,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 107 || - token() === 84) { + if (token() === 108 || + token() === 85) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -15491,40 +16187,40 @@ var ts; case 12: case 9: case 22: - return token() === 17; + return token() === 18; case 3: - return token() === 17 || token() === 72 || token() === 78; + return token() === 18 || token() === 73 || token() === 79; case 7: - return token() === 16 || token() === 84 || token() === 107; + return token() === 17 || token() === 85 || token() === 108; case 8: return isVariableDeclaratorListTerminator(); case 18: - return token() === 28 || token() === 18 || token() === 16 || token() === 84 || token() === 107; + return token() === 29 || token() === 19 || token() === 17 || token() === 85 || token() === 108; case 11: - return token() === 19 || token() === 24; + return token() === 20 || token() === 25; case 15: case 20: case 10: - return token() === 21; + return token() === 22; case 16: case 17: - return token() === 19 || token() === 21; + return token() === 20 || token() === 22; case 19: - return token() !== 25; + return token() !== 26; case 21: - return token() === 16 || token() === 17; + return token() === 17 || token() === 18; case 13: - return token() === 28 || token() === 40; + return token() === 29 || token() === 41; case 14: - return token() === 26 && lookAhead(nextTokenIsSlash); + return token() === 27 && lookAhead(nextTokenIsSlash); case 23: - return token() === 19 || token() === 55 || token() === 17; + return token() === 20 || token() === 56 || token() === 18; case 24: - return token() === 28 || token() === 17; + return token() === 29 || token() === 18; case 26: - return token() === 21 || token() === 17; + return token() === 22 || token() === 18; case 25: - return token() === 17; + return token() === 18; } } function isVariableDeclaratorListTerminator() { @@ -15534,7 +16230,7 @@ var ts; if (isInOrOfKeyword(token())) { return true; } - if (token() === 35) { + if (token() === 36) { return true; } return false; @@ -15640,17 +16336,17 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 151: - case 156: case 152: + case 157: case 153: - case 148: - case 205: + case 154: + case 149: + case 206: return true; - case 150: + case 151: var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 70 && - methodDeclaration.name.originalKeywordKind === 122; + var nameIsConstructor = methodDeclaration.name.kind === 71 && + methodDeclaration.name.originalKeywordKind === 123; return !nameIsConstructor; } } @@ -15659,8 +16355,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 256: case 257: + case 258: return true; } } @@ -15669,65 +16365,65 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 227: + case 228: + case 208: case 207: - case 206: + case 211: case 210: - case 209: - case 222: + case 223: + case 219: + case 221: case 218: - case 220: case 217: + case 215: case 216: case 214: - case 215: case 213: - case 212: - case 219: - case 208: - case 223: - case 221: - case 211: + case 220: + case 209: case 224: + case 222: + case 212: + case 225: + case 238: case 237: - case 236: + case 244: case 243: - case 242: - case 232: - case 228: + case 233: case 229: - case 231: case 230: + case 232: + case 231: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 263; + return node.kind === 264; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 155: - case 149: case 156: - case 147: - case 154: + case 150: + case 157: + case 148: + case 155: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 225) { + if (node.kind !== 226) { return false; } var variableDeclarator = node; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 145) { + if (node.kind !== 146) { return false; } var parameter = node; @@ -15772,7 +16468,6 @@ var ts; case 25: return ts.Diagnostics.Property_assignment_expected; } } - ; function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; parsingContext |= 1 << kind; @@ -15782,15 +16477,15 @@ var ts; if (isListElement(kind, false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(25)) { + if (parseOptional(26)) { continue; } commaStart = -1; if (isListTerminator(kind)) { break; } - parseExpected(25); - if (considerSemicolonAsDelimiter && token() === 24 && !scanner.hasPrecedingLineBreak()) { + parseExpected(26); + if (considerSemicolonAsDelimiter && token() === 25 && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -15822,8 +16517,8 @@ var ts; } function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(22)) { - var node = createNode(142, entity.pos); + while (parseOptional(23)) { + var node = createNode(143, entity.pos); node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15834,33 +16529,33 @@ var ts; if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) { var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); if (matchesPattern) { - return createMissingNode(70, true, ts.Diagnostics.Identifier_expected); + return createMissingNode(71, true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(195); + var template = createNode(196); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 13, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 14, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 14); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 15); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(204); + var span = createNode(205); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 17) { + if (token() === 18) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(15, false, ts.Diagnostics._0_expected, ts.tokenToString(17)); + literal = parseExpectedToken(16, false, ts.Diagnostics._0_expected, ts.tokenToString(18)); } span.literal = literal; return finishNode(span); @@ -15870,12 +16565,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 13, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 14, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), false); - ts.Debug.assert(fragment.kind === 14 || fragment.kind === 15, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 || fragment.kind === 16, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -15888,47 +16583,43 @@ var ts; if (scanner.isUnterminated()) { node.isUnterminated = true; } - var tokenPos = scanner.getTokenPos(); + if (node.kind === 8) { + node.numericLiteralFlags = scanner.getNumericLiteralFlags(); + } nextToken(); finishNode(node); - if (node.kind === 8 - && sourceText.charCodeAt(tokenPos) === 48 - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.isOctalLiteral = true; - } return node; } function parseTypeReference() { - var typeName = parseEntityName(false, ts.Diagnostics.Type_expected); - var node = createNode(158, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 26) { - node.typeArguments = parseBracketedList(19, parseType, 26, 28); + var node = createNode(159); + node.typeName = parseEntityName(false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token() === 27) { + node.typeArguments = parseBracketedList(19, parseType, 27, 29); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(157, lhs.pos); + var node = createNode(158, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(168); + var node = createNode(169); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(161); - parseExpected(102); + var node = createNode(162); + parseExpected(103); node.exprName = parseEntityName(true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(144); + var node = createNode(145); node.name = parseIdentifier(); - if (parseOptional(84)) { + if (parseOptional(85)) { if (isStartOfType() || !isStartOfExpression()) { node.constraint = parseType(); } @@ -15936,40 +16627,40 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(57)) { + if (parseOptional(58)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 26) { - return parseBracketedList(18, parseTypeParameter, 26, 28); + if (token() === 27) { + return parseBracketedList(18, parseTypeParameter, 27, 29); } } function parseParameterType() { - if (parseOptional(55)) { + if (parseOptional(56)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 23 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 || token() === 98; + return token() === 24 || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 57 || token() === 99; } function parseParameter() { - var node = createNode(145); - if (token() === 98) { - node.name = createIdentifier(true, undefined); + var node = createNode(146); + if (token() === 99) { + node.name = createIdentifier(true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(23); + node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); if (ts.getFullWidth(node.name) === 0 && !ts.hasModifiers(node) && ts.isModifierKind(token())) { nextToken(); } - node.questionToken = parseOptionalToken(54); + node.questionToken = parseOptionalToken(55); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(true); return addJSDocComment(finishNode(node)); @@ -15981,7 +16672,7 @@ var ts; return parseInitializer(true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 35; + var returnTokenRequired = returnToken === 36; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -15993,7 +16684,7 @@ var ts; } } function parseParameterList(yieldContext, awaitContext, requireCompleteParameterList) { - if (parseExpected(18)) { + if (parseExpected(19)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -16001,7 +16692,7 @@ var ts; var result = parseDelimitedList(16, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(19) && requireCompleteParameterList) { + if (!parseExpected(20) && requireCompleteParameterList) { return undefined; } return result; @@ -16009,29 +16700,29 @@ var ts; return requireCompleteParameterList ? undefined : createMissingList(); } function parseTypeMemberSemicolon() { - if (parseOptional(25)) { + if (parseOptional(26)) { return; } parseSemicolon(); } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 155) { - parseExpected(93); + if (kind === 156) { + parseExpected(94); } - fillSignature(55, false, false, false, node); + fillSignature(56, false, false, false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 20) { + if (token() !== 21) { return false; } return lookAhead(isUnambiguouslyIndexSignature); } function isUnambiguouslyIndexSignature() { nextToken(); - if (token() === 23 || token() === 21) { + if (token() === 24 || token() === 22) { return true; } if (ts.isModifierKind(token())) { @@ -16046,43 +16737,43 @@ var ts; else { nextToken(); } - if (token() === 55 || token() === 25) { + if (token() === 56 || token() === 26) { return true; } - if (token() !== 54) { + if (token() !== 55) { return false; } nextToken(); - return token() === 55 || token() === 25 || token() === 21; + return token() === 56 || token() === 26 || token() === 22; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(156, fullStart); + var node = createNode(157, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16, parseParameter, 20, 21); + node.parameters = parseBracketedList(16, parseParameter, 21, 22); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (token() === 18 || token() === 26) { - var method = createNode(149, fullStart); + var questionToken = parseOptionalToken(55); + if (token() === 19 || token() === 27) { + var method = createNode(150, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; - fillSignature(55, false, false, false, method); + fillSignature(56, false, false, false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(147, fullStart); + var property = createNode(148, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 57) { + if (token() === 58) { property.initializer = parseNonParameterInitializer(); } parseTypeMemberSemicolon(); @@ -16090,38 +16781,38 @@ var ts; } } function isTypeMemberStart() { - var idToken; - if (token() === 18 || token() === 26) { + if (token() === 19 || token() === 27) { return true; } + var idToken; while (ts.isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } - if (token() === 20) { + if (token() === 21) { return true; } if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } if (idToken) { - return token() === 18 || - token() === 26 || - token() === 54 || + return token() === 19 || + token() === 27 || token() === 55 || - token() === 25 || + token() === 56 || + token() === 26 || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 18 || token() === 26) { - return parseSignatureMember(154); - } - if (token() === 93 && lookAhead(isStartOfConstructSignature)) { + if (token() === 19 || token() === 27) { return parseSignatureMember(155); } + if (token() === 94 && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(156); + } var fullStart = getNodePos(); var modifiers = parseModifiers(); if (isIndexSignature()) { @@ -16131,18 +16822,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 18 || token() === 26; + return token() === 19 || token() === 27; } function parseTypeLiteral() { - var node = createNode(162); + var node = createNode(163); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(16)) { + if (parseExpected(17)) { members = parseList(4, parseTypeMember); - parseExpected(17); + parseExpected(18); } else { members = createMissingList(); @@ -16151,57 +16842,57 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 130) { + if (token() === 131) { nextToken(); } - return token() === 20 && nextTokenIsIdentifier() && nextToken() === 91; + return token() === 21 && nextTokenIsIdentifier() && nextToken() === 92; } function parseMappedTypeParameter() { - var node = createNode(144); + var node = createNode(145); node.name = parseIdentifier(); - parseExpected(91); + parseExpected(92); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(171); - parseExpected(16); - node.readonlyToken = parseOptionalToken(130); - parseExpected(20); - node.typeParameter = parseMappedTypeParameter(); + var node = createNode(172); + parseExpected(17); + node.readonlyToken = parseOptionalToken(131); parseExpected(21); - node.questionToken = parseOptionalToken(54); + node.typeParameter = parseMappedTypeParameter(); + parseExpected(22); + node.questionToken = parseOptionalToken(55); node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(17); + parseExpected(18); return finishNode(node); } function parseTupleType() { - var node = createNode(164); - node.elementTypes = parseBracketedList(20, parseType, 20, 21); + var node = createNode(165); + node.elementTypes = parseBracketedList(20, parseType, 21, 22); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(167); - parseExpected(18); - node.type = parseType(); + var node = createNode(168); parseExpected(19); + node.type = parseType(); + parseExpected(20); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 160) { - parseExpected(93); + if (kind === 161) { + parseExpected(94); } - fillSignature(35, false, false, false, node); + fillSignature(36, false, false, false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 22 ? undefined : node; + return token() === 23 ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(172); + var node = createNode(173); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16211,42 +16902,42 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: - case 138: - case 129: case 133: + case 122: + case 137: + case 139: + case 130: + case 134: var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9: case 8: - case 100: - case 85: + case 101: + case 86: return parseLiteralTypeNode(); - case 37: + case 38: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 104: - case 94: + case 105: + case 95: return parseTokenNode(); - case 98: { + case 99: { var thisKeyword = parseThisTypeNode(); - if (token() === 125 && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 102: + case 103: return parseTypeQuery(); - case 16: + case 17: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 20: + case 21: return parseTupleType(); - case 18: + case 19: return parseParenthesizedType(); default: return parseTypeReference(); @@ -16254,32 +16945,32 @@ var ts; } function isStartOfType() { switch (token()) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: - case 104: - case 138: - case 94: - case 98: - case 102: - case 129: - case 16: - case 20: - case 26: + case 133: + case 122: + case 137: + case 105: + case 139: + case 95: + case 99: + case 103: + case 130: + case 17: + case 21: + case 27: + case 49: case 48: - case 47: - case 93: + case 94: case 9: case 8: - case 100: - case 85: - case 133: + case 101: + case 86: + case 134: return true; - case 37: + case 38: return lookAhead(nextTokenIsNumericLiteral); - case 18: + case 19: return lookAhead(isStartOfParenthesizedOrFunctionType); default: return isIdentifier(); @@ -16287,29 +16978,29 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 19 || isStartOfParameter() || isStartOfType(); + return token() === 20 || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(20)) { + while (!scanner.hasPrecedingLineBreak() && parseOptional(21)) { if (isStartOfType()) { - var node = createNode(170, type.pos); + var node = createNode(171, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(21); + parseExpected(22); type = finishNode(node); } else { - var node = createNode(163, type.pos); + var node = createNode(164, type.pos); node.elementType = type; - parseExpected(21); + parseExpected(22); type = finishNode(node); } } return type; } function parseTypeOperator(operator) { - var node = createNode(169); + var node = createNode(170); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16317,8 +17008,8 @@ var ts; } function parseTypeOperatorOrHigher() { switch (token()) { - case 126: - return parseTypeOperator(126); + case 127: + return parseTypeOperator(127); } return parseArrayTypeOrHigher(); } @@ -16338,26 +17029,26 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(166, parseTypeOperatorOrHigher, 47); + return parseUnionOrIntersectionType(167, parseTypeOperatorOrHigher, 48); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(165, parseIntersectionTypeOrHigher, 48); + return parseUnionOrIntersectionType(166, parseIntersectionTypeOrHigher, 49); } function isStartOfFunctionType() { - if (token() === 26) { + if (token() === 27) { return true; } - return token() === 18 && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 19 && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { parseModifiers(); } - if (isIdentifier() || token() === 98) { + if (isIdentifier() || token() === 99) { nextToken(); return true; } - if (token() === 20 || token() === 16) { + if (token() === 21 || token() === 17) { var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); return previousErrorCount === parseDiagnostics.length; @@ -16366,17 +17057,17 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 19 || token() === 23) { + if (token() === 20 || token() === 24) { return true; } if (skipParameterStart()) { - if (token() === 55 || token() === 25 || - token() === 54 || token() === 57) { + if (token() === 56 || token() === 26 || + token() === 55 || token() === 58) { return true; } - if (token() === 19) { + if (token() === 20) { nextToken(); - if (token() === 35) { + if (token() === 36) { return true; } } @@ -16387,7 +17078,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(157, typePredicateVariable.pos); + var node = createNode(158, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16398,7 +17089,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 125 && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -16408,36 +17099,36 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(159); - } - if (token() === 93) { return parseFunctionOrConstructorType(160); } + if (token() === 94) { + return parseFunctionOrConstructorType(161); + } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(55) ? parseType() : undefined; + return parseOptional(56) ? parseType() : undefined; } function isStartOfLeftHandSideExpression() { switch (token()) { - case 98: - case 96: - case 94: - case 100: - case 85: + case 99: + case 97: + case 95: + case 101: + case 86: case 8: case 9: - case 12: case 13: - case 18: - case 20: - case 16: - case 88: - case 74: - case 93: - case 40: - case 62: - case 70: + case 14: + case 19: + case 21: + case 17: + case 89: + case 75: + case 94: + case 41: + case 63: + case 71: return true; default: return isIdentifier(); @@ -16448,18 +17139,18 @@ var ts; return true; } switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 79: - case 102: - case 104: - case 42: + case 80: + case 103: + case 105: case 43: - case 26: - case 120: - case 115: + case 44: + case 27: + case 121: + case 116: return true; default: if (isBinaryOperator()) { @@ -16469,10 +17160,10 @@ var ts; } } function isStartOfExpressionStatement() { - return token() !== 16 && - token() !== 88 && - token() !== 74 && - token() !== 56 && + return token() !== 17 && + token() !== 89 && + token() !== 75 && + token() !== 57 && isStartOfExpression(); } function parseExpression() { @@ -16482,7 +17173,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(25))) { + while ((operatorToken = parseOptionalToken(26))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -16491,12 +17182,12 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 57) { - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16) || !isStartOfExpression()) { + if (token() !== 58) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17) || !isStartOfExpression()) { return undefined; } } - parseExpected(57); + parseExpected(58); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -16508,7 +17199,7 @@ var ts; return arrowExpression; } var expr = parseBinaryExpressionOrHigher(0); - if (expr.kind === 70 && token() === 35) { + if (expr.kind === 71 && token() === 36) { return parseSimpleArrowFunctionExpression(expr); } if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) { @@ -16517,7 +17208,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 115) { + if (token() === 116) { if (inYieldContext()) { return true; } @@ -16530,11 +17221,11 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(196); + var node = createNode(197); nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 38 || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(38); + (token() === 39 || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(39); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -16543,21 +17234,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 35, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 36, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(186, asyncModifier.pos); + node = createNode(187, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(186, identifier.pos); + node = createNode(187, identifier.pos); } - var parameter = createNode(145, identifier.pos); + var parameter = createNode(146, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(!!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -16574,78 +17265,78 @@ var ts; } var isAsync = !!(ts.getModifierFlags(arrowFunction) & 256); var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(35, false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 35 || lastToken === 16) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(36, false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 36 || lastToken === 17) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); } function isParenthesizedArrowFunctionExpression() { - if (token() === 18 || token() === 26 || token() === 119) { + if (token() === 19 || token() === 27 || token() === 120) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 35) { + if (token() === 36) { return 1; } return 0; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 119) { + if (token() === 120) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0; } - if (token() !== 18 && token() !== 26) { + if (token() !== 19 && token() !== 27) { return 0; } } var first = token(); var second = nextToken(); - if (first === 18) { - if (second === 19) { + if (first === 19) { + if (second === 20) { var third = nextToken(); switch (third) { - case 35: - case 55: - case 16: + case 36: + case 56: + case 17: return 1; default: return 0; } } - if (second === 20 || second === 16) { + if (second === 21 || second === 17) { return 2; } - if (second === 23) { + if (second === 24) { return 1; } if (!isIdentifier()) { return 0; } - if (nextToken() === 55) { + if (nextToken() === 56) { return 1; } return 2; } else { - ts.Debug.assert(first === 26); + ts.Debug.assert(first === 27); if (!isIdentifier()) { return 0; } if (sourceFile.languageVariant === 1) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 84) { + if (third === 85) { var fourth = nextToken(); switch (fourth) { - case 57: - case 28: + case 58: + case 29: return false; default: return true; } } - else if (third === 25) { + else if (third === 26) { return true; } return false; @@ -16662,7 +17353,7 @@ var ts; return parseParenthesizedArrowFunctionExpressionHead(false); } function tryParseAsyncSimpleArrowFunctionExpression() { - if (token() === 119) { + if (token() === 120) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1) { var asyncModifier = parseModifiersForArrowFunction(); @@ -16673,38 +17364,38 @@ var ts; return undefined; } function isUnParenthesizedAsyncArrowFunctionWorker() { - if (token() === 119) { + if (token() === 120) { nextToken(); - if (scanner.hasPrecedingLineBreak() || token() === 35) { + if (scanner.hasPrecedingLineBreak() || token() === 36) { return 0; } var expr = parseBinaryExpressionOrHigher(0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 && token() === 35) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 && token() === 36) { return 1; } } return 0; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(186); + var node = createNode(187); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256); - fillSignature(55, false, isAsync, !allowAmbiguity, node); + fillSignature(56, false, isAsync, !allowAmbiguity, node); if (!node.parameters) { return undefined; } - if (!allowAmbiguity && token() !== 35 && token() !== 16) { + if (!allowAmbiguity && token() !== 36 && token() !== 17) { return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 16) { + if (token() === 17) { return parseFunctionBlock(false, isAsync, false); } - if (token() !== 24 && - token() !== 88 && - token() !== 74 && + if (token() !== 25 && + token() !== 89 && + token() !== 75 && isStartOfStatement() && !isStartOfExpressionStatement()) { return parseFunctionBlock(false, isAsync, true); @@ -16714,15 +17405,15 @@ var ts; : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher); } function parseConditionalExpressionRest(leftOperand) { - var questionToken = parseOptionalToken(54); + var questionToken = parseOptionalToken(55); if (!questionToken) { return leftOperand; } - var node = createNode(194, leftOperand.pos); + var node = createNode(195, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(55, false, ts.Diagnostics._0_expected, ts.tokenToString(55)); + node.colonToken = parseExpectedToken(56, false, ts.Diagnostics._0_expected, ts.tokenToString(56)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -16731,22 +17422,22 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 || t === 141; + return t === 92 || t === 142; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { reScanGreaterToken(); var newPrecedence = getBinaryOperatorPrecedence(); - var consumeCurrentOperator = token() === 39 ? + var consumeCurrentOperator = token() === 40 ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 91 && inDisallowInContext()) { + if (token() === 92 && inDisallowInContext()) { break; } - if (token() === 117) { + if (token() === 118) { if (scanner.hasPrecedingLineBreak()) { break; } @@ -16762,92 +17453,92 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 91) { + if (inDisallowInContext() && token() === 92) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 53: + case 54: return 1; - case 52: + case 53: return 2; - case 48: - return 3; case 49: + return 3; + case 50: return 4; - case 47: + case 48: return 5; - case 31: case 32: case 33: case 34: + case 35: return 6; - case 26: - case 28: + case 27: case 29: case 30: + case 31: + case 93: case 92: - case 91: - case 117: + case 118: return 7; - case 44: case 45: case 46: + case 47: return 8; - case 36: case 37: - return 9; case 38: - case 40: - case 41: - return 10; + return 9; case 39: + case 41: + case 42: + return 10; + case 40: return 11; } return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(193, left.pos); + var node = createNode(194, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(201, left.pos); + var node = createNode(202, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(191); + var node = createNode(192); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(187); - nextToken(); - node.expression = parseSimpleUnaryExpression(); - return finishNode(node); - } - function parseTypeOfExpression() { var node = createNode(188); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } - function parseVoidExpression() { + function parseTypeOfExpression() { var node = createNode(189); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } + function parseVoidExpression() { + var node = createNode(190); + nextToken(); + node.expression = parseSimpleUnaryExpression(); + return finishNode(node); + } function isAwaitExpression() { - if (token() === 120) { + if (token() === 121) { if (inAwaitContext()) { return true; } @@ -16856,7 +17547,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(190); + var node = createNode(191); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -16864,15 +17555,15 @@ var ts; function parseUnaryExpressionOrHigher() { if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 39 ? + return token() === 40 ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 39) { + if (token() === 40) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 183) { + if (simpleUnaryExpression.kind === 184) { 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 { @@ -16883,20 +17574,20 @@ var ts; } function parseSimpleUnaryExpression() { switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: return parsePrefixUnaryExpression(); - case 79: + case 80: return parseDeleteExpression(); - case 102: + case 103: return parseTypeOfExpression(); - case 104: + case 105: return parseVoidExpression(); - case 26: + case 27: return parseTypeAssertion(); - case 120: + case 121: if (isAwaitExpression()) { return parseAwaitExpression(); } @@ -16906,16 +17597,16 @@ var ts; } function isUpdateExpression() { switch (token()) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 79: - case 102: - case 104: - case 120: + case 80: + case 103: + case 105: + case 121: return false; - case 26: + case 27: if (sourceFile.languageVariant !== 1) { return false; } @@ -16924,20 +17615,20 @@ var ts; } } function parseIncrementExpression() { - if (token() === 42 || token() === 43) { - var node = createNode(191); + if (token() === 43 || token() === 44) { + var node = createNode(192); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 && token() === 26 && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 && token() === 27 && lookAhead(nextTokenIsIdentifierOrKeyword)) { return parseJsxElementOrSelfClosingElement(true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 42 || token() === 43) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(192, expression.pos); + if ((token() === 43 || token() === 44) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(193, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -16946,7 +17637,7 @@ var ts; return expression; } function parseLeftHandSideExpressionOrHigher() { - var expression = token() === 96 + var expression = token() === 97 ? parseSuperExpression() : parseMemberExpressionOrHigher(); return parseCallExpressionRest(expression); @@ -16957,12 +17648,12 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 18 || token() === 22 || token() === 20) { + if (token() === 19 || token() === 23 || token() === 21) { return expression; } - var node = createNode(178, expression.pos); + var node = createNode(179, expression.pos); node.expression = expression; - parseExpectedToken(22, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(23, false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(true); return finishNode(node); } @@ -16970,10 +17661,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 70) { + if (lhs.kind === 71) { return lhs.text === rhs.text; } - if (lhs.kind === 98) { + if (lhs.kind === 99) { return true; } return lhs.name.text === rhs.name.text && @@ -16982,8 +17673,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 250) { - var node = createNode(248, opening.pos); + if (opening.kind === 251) { + var node = createNode(249, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -16993,18 +17684,18 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 249); + ts.Debug.assert(opening.kind === 250); result = opening; } - if (inExpressionContext && token() === 26) { + if (inExpressionContext && token() === 27) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(193, result.pos); + var badNode = createNode(194, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(25, false, undefined); + badNode.operatorToken = createMissingNode(26, false, undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -17013,16 +17704,18 @@ var ts; } function parseJsxText() { var node = createNode(10, scanner.getStartPos()); + node.containsOnlyWhiteSpaces = currentToken === 11; currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { case 10: + case 11: return parseJsxText(); - case 16: + case 17: return parseJsxExpression(false); - case 26: + case 27: return parseJsxElementOrSelfClosingElement(false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -17033,44 +17726,50 @@ var ts; parsingContext |= 1 << 14; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 27) { + if (token() === 28) { break; } else if (token() === 1) { parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } - result.push(parseJsxChild()); + else if (token() === 7) { + break; + } + var child = parseJsxChild(); + if (child) { + result.push(child); + } } result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; return result; } function parseJsxAttributes() { - var jsxAttributes = createNode(253); + var jsxAttributes = createNode(254); jsxAttributes.properties = parseList(13, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(26); + parseExpected(27); var tagName = parseJsxElementName(); var attributes = parseJsxAttributes(); var node; - if (token() === 28) { - node = createNode(250, fullStart); + if (token() === 29) { + node = createNode(251, fullStart); scanJsxText(); } else { - parseExpected(40); + parseExpected(41); if (inExpressionContext) { - parseExpected(28); + parseExpected(29); } else { - parseExpected(28, undefined, false); + parseExpected(29, undefined, false); scanJsxText(); } - node = createNode(249, fullStart); + node = createNode(250, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17078,10 +17777,10 @@ var ts; } function parseJsxElementName() { scanJsxIdentifier(); - var expression = token() === 98 ? + var expression = token() === 99 ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(22)) { - var propertyAccess = createNode(178, expression.pos); + while (parseOptional(23)) { + var propertyAccess = createNode(179, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); @@ -17089,29 +17788,29 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(255); - parseExpected(16); - if (token() !== 17) { - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(256); + parseExpected(17); + if (token() !== 18) { + node.dotDotDotToken = parseOptionalToken(24); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(17); + parseExpected(18); } else { - parseExpected(17, undefined, false); + parseExpected(18, undefined, false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 16) { + if (token() === 17) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(252); + var node = createNode(253); node.name = parseIdentifierName(); - if (token() === 57) { + if (token() === 58) { switch (scanJsxAttributeValue()) { case 9: node.initializer = parseLiteralNode(); @@ -17124,69 +17823,69 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(254); - parseExpected(16); - parseExpected(23); - node.expression = parseExpression(); + var node = createNode(255); parseExpected(17); + parseExpected(24); + node.expression = parseExpression(); + parseExpected(18); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(251); - parseExpected(27); + var node = createNode(252); + parseExpected(28); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(28); + parseExpected(29); } else { - parseExpected(28, undefined, false); + parseExpected(29, undefined, false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(183); - parseExpected(26); + var node = createNode(184); + parseExpected(27); node.type = parseType(); - parseExpected(28); + parseExpected(29); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(22); + var dotToken = parseOptionalToken(23); if (dotToken) { - var propertyAccess = createNode(178, expression.pos); + var propertyAccess = createNode(179, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(true); expression = finishNode(propertyAccess); continue; } - if (token() === 50 && !scanner.hasPrecedingLineBreak()) { + if (token() === 51 && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(202, expression.pos); + var nonNullExpression = createNode(203, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } - if (!inDecoratorContext() && parseOptional(20)) { - var indexedAccess = createNode(179, expression.pos); + if (!inDecoratorContext() && parseOptional(21)) { + var indexedAccess = createNode(180, expression.pos); indexedAccess.expression = expression; - if (token() !== 21) { + if (token() !== 22) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 || indexedAccess.argumentExpression.kind === 8) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(21); + parseExpected(22); expression = finishNode(indexedAccess); continue; } - if (token() === 12 || token() === 13) { - var tagExpression = createNode(182, expression.pos); + if (token() === 13 || token() === 14) { + var tagExpression = createNode(183, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 12 + tagExpression.template = token() === 13 ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -17198,20 +17897,20 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 26) { + if (token() === 27) { var typeArguments = tryParse(parseTypeArgumentsInExpression); if (!typeArguments) { return expression; } - var callExpr = createNode(180, expression.pos); + var callExpr = createNode(181, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 18) { - var callExpr = createNode(180, expression.pos); + else if (token() === 19) { + var callExpr = createNode(181, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17221,17 +17920,17 @@ var ts; } } function parseArgumentList() { - parseExpected(18); - var result = parseDelimitedList(11, parseArgumentExpression); parseExpected(19); + var result = parseDelimitedList(11, parseArgumentExpression); + parseExpected(20); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(26)) { + if (!parseOptional(27)) { return undefined; } var typeArguments = parseDelimitedList(19, parseType); - if (!parseExpected(28)) { + if (!parseExpected(29)) { return undefined; } return typeArguments && canFollowTypeArgumentsInExpression() @@ -17240,27 +17939,27 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 18: - case 22: case 19: - case 21: + case 23: + case 20: + case 22: + case 56: + case 25: case 55: - case 24: - case 54: - case 31: - case 33: case 32: case 34: - case 52: + case 33: + case 35: case 53: - case 49: - case 47: + case 54: + case 50: case 48: - case 17: + case 49: + case 18: case 1: return true; - case 25: - case 16: + case 26: + case 17: default: return false; } @@ -17269,87 +17968,87 @@ var ts; switch (token()) { case 8: case 9: - case 12: + case 13: return parseLiteralNode(); - case 98: - case 96: - case 94: - case 100: - case 85: + case 99: + case 97: + case 95: + case 101: + case 86: return parseTokenNode(); - case 18: + case 19: return parseParenthesizedExpression(); - case 20: + case 21: return parseArrayLiteralExpression(); - case 16: + case 17: return parseObjectLiteralExpression(); - case 119: + case 120: if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) { break; } return parseFunctionExpression(); - case 74: + case 75: return parseClassExpression(); - case 88: + case 89: return parseFunctionExpression(); - case 93: + case 94: return parseNewExpression(); - case 40: - case 62: - if (reScanSlashToken() === 11) { + case 41: + case 63: + if (reScanSlashToken() === 12) { return parseLiteralNode(); } break; - case 13: + case 14: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(184); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(185); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); return finishNode(node); } function parseSpreadElement() { - var node = createNode(197); - parseExpected(23); + var node = createNode(198); + parseExpected(24); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 23 ? parseSpreadElement() : - token() === 25 ? createNode(199) : + return token() === 24 ? parseSpreadElement() : + token() === 26 ? createNode(200) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(176); - parseExpected(20); + var node = createNode(177); + parseExpected(21); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement); - parseExpected(21); + parseExpected(22); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(124)) { - return parseAccessorDeclaration(152, fullStart, decorators, modifiers); - } - else if (parseContextualModifier(134)) { + if (parseContextualModifier(125)) { return parseAccessorDeclaration(153, fullStart, decorators, modifiers); } + else if (parseContextualModifier(135)) { + return parseAccessorDeclaration(154, fullStart, decorators, modifiers); + } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); - var dotDotDotToken = parseOptionalToken(23); + var dotDotDotToken = parseOptionalToken(24); if (dotDotDotToken) { - var spreadElement = createNode(262, fullStart); + var spreadElement = createNode(263, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17359,19 +18058,19 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(38); + var asteriskToken = parseOptionalToken(39); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (asteriskToken || token() === 18 || token() === 26) { + var questionToken = parseOptionalToken(55); + if (asteriskToken || token() === 19 || token() === 27) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 || token() === 17 || token() === 57); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 || token() === 18 || token() === 58); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(261, fullStart); + var shorthandDeclaration = createNode(262, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(57); + var equalsToken = parseOptionalToken(58); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -17379,23 +18078,23 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(260, fullStart); + var propertyAssignment = createNode(261, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(55); + parseExpected(56); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(177); - parseExpected(16); + var node = createNode(178); + parseExpected(17); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12, parseObjectLiteralElement, true); - parseExpected(17); + parseExpected(18); return finishNode(node); } function parseFunctionExpression() { @@ -17403,10 +18102,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(false); } - var node = createNode(185); + var node = createNode(186); node.modifiers = parseModifiers(); - parseExpected(88); - node.asteriskToken = parseOptionalToken(38); + parseExpected(89); + node.asteriskToken = parseOptionalToken(39); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256); node.name = @@ -17414,7 +18113,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(55, isGenerator, isAsync, false, node); + fillSignature(56, isGenerator, isAsync, false, node); node.body = parseFunctionBlock(isGenerator, isAsync, false); if (saveDecoratorContext) { setDecoratorContext(true); @@ -17426,29 +18125,29 @@ var ts; } function parseNewExpression() { var fullStart = scanner.getStartPos(); - parseExpected(93); - if (parseOptional(22)) { - var node_1 = createNode(203, fullStart); - node_1.keywordToken = 93; + parseExpected(94); + if (parseOptional(23)) { + var node_1 = createNode(204, fullStart); + node_1.keywordToken = 94; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(181, fullStart); + var node = createNode(182, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 18) { + if (node.typeArguments || token() === 19) { node.arguments = parseArgumentList(); } return finishNode(node); } function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(206); - if (parseExpected(16, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(207); + if (parseExpected(17, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1, parseStatement); - parseExpected(17); + parseExpected(18); } else { node.statements = createMissingList(); @@ -17473,47 +18172,48 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(208); - parseExpected(24); + var node = createNode(209); + parseExpected(25); return finishNode(node); } function parseIfStatement() { - var node = createNode(210); - parseExpected(89); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(211); + parseExpected(90); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(81) ? parseStatement() : undefined; + node.elseStatement = parseOptional(82) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(211); - parseExpected(80); + var node = createNode(212); + parseExpected(81); node.statement = parseStatement(); - parseExpected(105); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + parseExpected(106); parseExpected(19); - parseOptional(24); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + parseOptional(25); return finishNode(node); } function parseWhileStatement() { - var node = createNode(212); - parseExpected(105); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(213); + parseExpected(106); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(87); - parseExpected(18); + parseExpected(88); + var awaitToken = parseOptionalToken(121); + parseExpected(19); var initializer = undefined; - if (token() !== 24) { - if (token() === 103 || token() === 109 || token() === 75) { + if (token() !== 25) { + if (token() === 104 || token() === 110 || token() === 76) { initializer = parseVariableDeclarationList(true); } else { @@ -17521,32 +18221,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(91)) { - var forInStatement = createNode(214, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(19); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(141)) { - var forOfStatement = createNode(215, pos); + if (awaitToken ? parseExpected(142) : parseOptional(142)) { + var forOfStatement = createNode(216, pos); + forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(19); + parseExpected(20); forOrForInOrForOfStatement = forOfStatement; } + else if (parseOptional(92)) { + var forInStatement = createNode(215, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(20); + forOrForInOrForOfStatement = forInStatement; + } else { - var forStatement = createNode(213, pos); + var forStatement = createNode(214, pos); forStatement.initializer = initializer; - parseExpected(24); - if (token() !== 24 && token() !== 19) { + parseExpected(25); + if (token() !== 25 && token() !== 20) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(24); - if (token() !== 19) { + parseExpected(25); + if (token() !== 20) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(19); + parseExpected(20); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -17554,7 +18255,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 217 ? 71 : 76); + parseExpected(kind === 218 ? 72 : 77); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -17562,8 +18263,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(218); - parseExpected(95); + var node = createNode(219); + parseExpected(96); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -17571,90 +18272,90 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(219); - parseExpected(106); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(220); + parseExpected(107); parseExpected(19); + node.expression = allowInAnd(parseExpression); + parseExpected(20); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(256); - parseExpected(72); + var node = createNode(257); + parseExpected(73); node.expression = allowInAnd(parseExpression); - parseExpected(55); + parseExpected(56); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(257); - parseExpected(78); - parseExpected(55); + var node = createNode(258); + parseExpected(79); + parseExpected(56); node.statements = parseList(3, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 72 ? parseCaseClause() : parseDefaultClause(); + return token() === 73 ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(220); - parseExpected(97); - parseExpected(18); - node.expression = allowInAnd(parseExpression); + var node = createNode(221); + parseExpected(98); parseExpected(19); - var caseBlock = createNode(234, scanner.getStartPos()); - parseExpected(16); - caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + node.expression = allowInAnd(parseExpression); + parseExpected(20); + var caseBlock = createNode(235, scanner.getStartPos()); parseExpected(17); + caseBlock.clauses = parseList(2, parseCaseOrDefaultClause); + parseExpected(18); node.caseBlock = finishNode(caseBlock); return finishNode(node); } function parseThrowStatement() { - var node = createNode(222); - parseExpected(99); + var node = createNode(223); + parseExpected(100); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } function parseTryStatement() { - var node = createNode(223); - parseExpected(101); + var node = createNode(224); + parseExpected(102); node.tryBlock = parseBlock(false); - node.catchClause = token() === 73 ? parseCatchClause() : undefined; - if (!node.catchClause || token() === 86) { - parseExpected(86); + node.catchClause = token() === 74 ? parseCatchClause() : undefined; + if (!node.catchClause || token() === 87) { + parseExpected(87); node.finallyBlock = parseBlock(false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(259); - parseExpected(73); - if (parseExpected(18)) { + var result = createNode(260); + parseExpected(74); + if (parseExpected(19)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(19); + parseExpected(20); result.block = parseBlock(false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(224); - parseExpected(77); + var node = createNode(225); + parseExpected(78); parseSemicolon(); return finishNode(node); } function parseExpressionOrLabeledStatement() { var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 70 && parseOptional(55)) { - var labeledStatement = createNode(221, fullStart); + if (expression.kind === 71 && parseOptional(56)) { + var labeledStatement = createNode(222, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(209, fullStart); + var expressionStatement = createNode(210, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -17664,9 +18365,13 @@ var ts; nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsClassKeywordOnSameLine() { + nextToken(); + return token() === 75 && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 88 && !scanner.hasPrecedingLineBreak(); + return token() === 89 && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -17675,47 +18380,47 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 103: - case 109: + case 104: + case 110: + case 76: + case 89: case 75: - case 88: - case 74: - case 82: + case 83: return true; - case 108: - case 137: + case 109: + case 138: return nextTokenIsIdentifierOnSameLine(); - case 127: case 128: + case 129: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116: - case 119: - case 123: - case 111: + case 117: + case 120: + case 124: case 112: case 113: - case 130: + case 114: + case 131: nextToken(); if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 140: + case 141: nextToken(); - return token() === 16 || token() === 70 || token() === 83; - case 90: + return token() === 17 || token() === 71 || token() === 84; + case 91: nextToken(); - return token() === 9 || token() === 38 || - token() === 16 || ts.tokenIsIdentifierOrKeyword(token()); - case 83: + return token() === 9 || token() === 39 || + token() === 17 || ts.tokenIsIdentifierOrKeyword(token()); + case 84: nextToken(); - if (token() === 57 || token() === 38 || - token() === 16 || token() === 78 || - token() === 117) { + if (token() === 58 || token() === 39 || + token() === 17 || token() === 79 || + token() === 118) { return true; } continue; - case 114: + case 115: nextToken(); continue; default: @@ -17728,46 +18433,46 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 56: - case 24: - case 16: - case 103: - case 109: - case 88: - case 74: - case 82: + case 57: + case 25: + case 17: + case 104: + case 110: case 89: - case 80: - case 105: - case 87: - case 76: - case 71: - case 95: - case 106: - case 97: - case 99: - case 101: - case 77: - case 73: - case 86: - return true; case 75: case 83: case 90: - return isStartOfDeclaration(); - case 119: - case 123: - case 108: - case 127: - case 128: - case 137: - case 140: + case 81: + case 106: + case 88: + case 77: + case 72: + case 96: + case 107: + case 98: + case 100: + case 102: + case 78: + case 74: + case 87: + return true; + case 76: + case 84: + case 91: + return isStartOfDeclaration(); + case 120: + case 124: + case 109: + case 128: + case 129: + case 138: + case 141: return true; - case 113: - case 111: - case 112: case 114: - case 130: + case 112: + case 113: + case 115: + case 131: return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine); default: return isStartOfExpression(); @@ -17775,73 +18480,73 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 16 || token() === 20; + return isIdentifier() || token() === 17 || token() === 21; } function isLetDeclaration() { return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring); } function parseStatement() { switch (token()) { - case 24: + case 25: return parseEmptyStatement(); - case 16: + case 17: return parseBlock(false); - case 103: + case 104: return parseVariableStatement(scanner.getStartPos(), undefined, undefined); - case 109: + case 110: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), undefined, undefined); } break; - case 88: - return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); - case 74: - return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 89: - return parseIfStatement(); - case 80: - return parseDoStatement(); - case 105: - return parseWhileStatement(); - case 87: - return parseForOrForInOrForOfStatement(); - case 76: - return parseBreakOrContinueStatement(216); - case 71: - return parseBreakOrContinueStatement(217); - case 95: - return parseReturnStatement(); - case 106: - return parseWithStatement(); - case 97: - return parseSwitchStatement(); - case 99: - return parseThrowStatement(); - case 101: - case 73: - case 86: - return parseTryStatement(); - case 77: - return parseDebuggerStatement(); - case 56: - return parseDeclaration(); - case 119: - case 108: - case 137: - case 127: - case 128: - case 123: + return parseFunctionDeclaration(scanner.getStartPos(), undefined, undefined); case 75: - case 82: - case 83: + return parseClassDeclaration(scanner.getStartPos(), undefined, undefined); case 90: - case 111: + return parseIfStatement(); + case 81: + return parseDoStatement(); + case 106: + return parseWhileStatement(); + case 88: + return parseForOrForInOrForOfStatement(); + case 77: + return parseBreakOrContinueStatement(217); + case 72: + return parseBreakOrContinueStatement(218); + case 96: + return parseReturnStatement(); + case 107: + return parseWithStatement(); + case 98: + return parseSwitchStatement(); + case 100: + return parseThrowStatement(); + case 102: + case 74: + case 87: + return parseTryStatement(); + case 78: + return parseDebuggerStatement(); + case 57: + return parseDeclaration(); + case 120: + case 109: + case 138: + case 128: + case 129: + case 124: + case 76: + case 83: + case 84: + case 91: case 112: case 113: - case 116: case 114: - case 130: - case 140: + case 117: + case 115: + case 131: + case 141: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -17854,40 +18559,40 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 103: - case 109: - case 75: + case 104: + case 110: + case 76: return parseVariableStatement(fullStart, decorators, modifiers); - case 88: + case 89: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 74: + case 75: return parseClassDeclaration(fullStart, decorators, modifiers); - case 108: + case 109: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 137: + case 138: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 82: - return parseEnumDeclaration(fullStart, decorators, modifiers); - case 140: - case 127: - case 128: - return parseModuleDeclaration(fullStart, decorators, modifiers); - case 90: - return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); case 83: + return parseEnumDeclaration(fullStart, decorators, modifiers); + case 141: + case 128: + case 129: + return parseModuleDeclaration(fullStart, decorators, modifiers); + case 91: + return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); + case 84: nextToken(); switch (token()) { - case 78: - case 57: + case 79: + case 58: return parseExportAssignment(fullStart, decorators, modifiers); - case 117: + case 118: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); } default: if (decorators || modifiers) { - var node = createMissingNode(246, true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(247, true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -17900,32 +18605,32 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 16 && canParseSemicolon()) { + if (token() !== 17 && canParseSemicolon()) { parseSemicolon(); return; } return parseFunctionBlock(isGenerator, isAsync, false, diagnosticMessage); } function parseArrayBindingElement() { - if (token() === 25) { - return createNode(199); + if (token() === 26) { + return createNode(200); } - var node = createNode(175); - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(176); + node.dotDotDotToken = parseOptionalToken(24); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(175); - node.dotDotDotToken = parseOptionalToken(23); + var node = createNode(176); + node.dotDotDotToken = parseOptionalToken(24); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 55) { + if (tokenIsIdentifier && token() !== 56) { node.name = propertyName; } else { - parseExpected(55); + parseExpected(56); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -17933,33 +18638,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(173); - parseExpected(16); - node.elements = parseDelimitedList(9, parseObjectBindingElement); + var node = createNode(174); parseExpected(17); + node.elements = parseDelimitedList(9, parseObjectBindingElement); + parseExpected(18); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(174); - parseExpected(20); - node.elements = parseDelimitedList(10, parseArrayBindingElement); + var node = createNode(175); parseExpected(21); + node.elements = parseDelimitedList(10, parseArrayBindingElement); + parseExpected(22); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 16 || token() === 20 || isIdentifier(); + return token() === 17 || token() === 21 || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 20) { + if (token() === 21) { return parseArrayBindingPattern(); } - if (token() === 16) { + if (token() === 17) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(225); + var node = createNode(226); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -17968,21 +18673,21 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(226); + var node = createNode(227); switch (token()) { - case 103: + case 104: break; - case 109: + case 110: node.flags |= 1; break; - case 75: + case 76: node.flags |= 2; break; default: ts.Debug.fail(); } nextToken(); - if (token() === 141 && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 142 && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -17994,10 +18699,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 19; + return nextTokenIsIdentifier() && nextToken() === 20; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(207, fullStart); + var node = createNode(208, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(false); @@ -18005,29 +18710,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227, fullStart); + var node = createNode(228, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(88); - node.asteriskToken = parseOptionalToken(38); + parseExpected(89); + node.asteriskToken = parseOptionalToken(39); node.name = ts.hasModifier(node, 512) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256); - fillSignature(55, isGenerator, isAsync, false, node); + fillSignature(56, isGenerator, isAsync, false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(151, pos); + var node = createNode(152, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(122); - fillSignature(55, false, false, false, node); + parseExpected(123); + fillSignature(56, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(150, fullStart); + var method = createNode(151, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18035,12 +18740,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256); - fillSignature(55, isGenerator, isAsync, false, method); + fillSignature(56, isGenerator, isAsync, false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(148, fullStart); + var property = createNode(149, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18053,10 +18758,10 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(38); + var asteriskToken = parseOptionalToken(39); var name = parsePropertyName(); - var questionToken = parseOptionalToken(54); - if (asteriskToken || token() === 18 || token() === 26) { + var questionToken = parseOptionalToken(55); + if (asteriskToken || token() === 19 || token() === 27) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -18071,17 +18776,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(55, false, false, false, node); + fillSignature(56, false, false, false, node); node.body = parseFunctionBlockOrSemicolon(false, false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 113: - case 111: - case 112: case 114: - case 130: + case 112: + case 113: + case 115: + case 131: return true; default: return false; @@ -18089,7 +18794,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 56) { + if (token() === 57) { return true; } while (ts.isModifierKind(token())) { @@ -18099,26 +18804,26 @@ var ts; } nextToken(); } - if (token() === 38) { + if (token() === 39) { return true; } if (isLiteralPropertyName()) { idToken = token(); nextToken(); } - if (token() === 20) { + if (token() === 21) { return true; } if (idToken !== undefined) { - if (!ts.isKeyword(idToken) || idToken === 134 || idToken === 124) { + if (!ts.isKeyword(idToken) || idToken === 135 || idToken === 125) { return true; } switch (token()) { - case 18: - case 26: + case 19: + case 27: + case 56: + case 58: case 55: - case 57: - case 54: return true; default: return canParseSemicolon(); @@ -18130,10 +18835,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(56)) { + if (!parseOptional(57)) { break; } - var decorator = createNode(146, decoratorStart); + var decorator = createNode(147, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18153,7 +18858,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 75 && permitInvalidConstAsModifier) { + if (token() === 76 && permitInvalidConstAsModifier) { if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { break; } @@ -18178,7 +18883,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 119) { + if (token() === 120) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -18189,8 +18894,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 24) { - var result = createNode(205); + if (token() === 25) { + var result = createNode(206); nextToken(); return finishNode(result); } @@ -18201,7 +18906,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 122) { + if (token() === 123) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -18210,33 +18915,33 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 || token() === 8 || - token() === 38 || - token() === 20) { + token() === 39 || + token() === 21) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { - var name = createMissingNode(70, true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(71, true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, undefined); } ts.Debug.fail("Should not have attempted to parse class member declaration."); } function parseClassExpression() { - return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 198); + return parseClassDeclarationOrExpression(scanner.getStartPos(), undefined, undefined, 199); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 229); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(74); + parseExpected(75); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(16)) { + if (parseExpected(17)) { node.members = parseClassMembers(); - parseExpected(17); + parseExpected(18); } else { node.members = createMissingList(); @@ -18249,7 +18954,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 107 && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 108 && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { if (isHeritageClause()) { @@ -18258,9 +18963,10 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 84 || token() === 107) { - var node = createNode(258); - node.token = token(); + var tok = token(); + if (tok === 85 || tok === 108) { + var node = createNode(259); + node.token = tok; nextToken(); node.types = parseDelimitedList(7, parseExpressionWithTypeArguments); return finishNode(node); @@ -18268,24 +18974,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(200); + var node = createNode(201); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 26) { - node.typeArguments = parseBracketedList(19, parseType, 26, 28); + if (token() === 27) { + node.typeArguments = parseBracketedList(19, parseType, 27, 29); } return finishNode(node); } function isHeritageClause() { - return token() === 84 || token() === 107; + return token() === 85 || token() === 108; } function parseClassMembers() { return parseList(5, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229, fullStart); + var node = createNode(230, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(108); + parseExpected(109); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -18293,32 +18999,32 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230, fullStart); + var node = createNode(231, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(137); + parseExpected(138); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(57); + parseExpected(58); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); } function parseEnumMember() { - var node = createNode(263, scanner.getStartPos()); + var node = createNode(264, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231, fullStart); + var node = createNode(232, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(82); + parseExpected(83); node.name = parseIdentifier(); - if (parseExpected(16)) { + if (parseExpected(17)) { node.members = parseDelimitedList(6, parseEnumMember); - parseExpected(17); + parseExpected(18); } else { node.members = createMissingList(); @@ -18326,10 +19032,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(233, scanner.getStartPos()); - if (parseExpected(16)) { + var node = createNode(234, scanner.getStartPos()); + if (parseExpected(17)) { node.statements = parseList(1, parseStatement); - parseExpected(17); + parseExpected(18); } else { node.statements = createMissingList(); @@ -18337,29 +19043,29 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(232, fullStart); + var node = createNode(233, fullStart); var namespaceFlag = flags & 16; node.decorators = decorators; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(22) + node.body = parseOptional(23) ? parseModuleOrNamespaceDeclaration(getNodePos(), undefined, undefined, 4 | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(232, fullStart); + var node = createNode(233, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 140) { + if (token() === 141) { node.name = parseIdentifier(); node.flags |= 512; } else { node.name = parseLiteralNode(true); } - if (token() === 16) { + if (token() === 17) { node.body = parseModuleBlock(); } else { @@ -18369,14 +19075,14 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 140) { + if (token() === 141) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(128)) { + else if (parseOptional(129)) { flags |= 16; } else { - parseExpected(127); + parseExpected(128); if (token() === 9) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -18384,63 +19090,66 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 131 && + return token() === 132 && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 18; + return nextToken() === 19; } function nextTokenIsSlash() { - return nextToken() === 40; + return nextToken() === 41; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(235, fullStart); + var exportDeclaration = createNode(236, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(117); - parseExpected(128); + parseExpected(118); + parseExpected(129); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(90); + parseExpected(91); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 && token() !== 139) { - var importEqualsDeclaration = createNode(236, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(57); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + if (token() !== 26 && token() !== 140) { + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } - var importDeclaration = createNode(237, fullStart); + var importDeclaration = createNode(238, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; if (identifier || - token() === 38 || - token() === 16) { + token() === 39 || + token() === 17) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(139); + parseExpected(140); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier) { + var importEqualsDeclaration = createNode(237, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(58); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } function parseImportClause(identifier, fullStart) { - var importClause = createNode(238, fullStart); + var importClause = createNode(239, fullStart); if (identifier) { importClause.name = identifier; } if (!importClause.name || - parseOptional(25)) { - importClause.namedBindings = token() === 38 ? parseNamespaceImport() : parseNamedImportsOrExports(240); + parseOptional(26)) { + importClause.namedBindings = token() === 39 ? parseNamespaceImport() : parseNamedImportsOrExports(241); } return finishNode(importClause); } @@ -18450,11 +19159,11 @@ var ts; : parseEntityName(false); } function parseExternalModuleReference() { - var node = createNode(247); - parseExpected(131); - parseExpected(18); - node.expression = parseModuleSpecifier(); + var node = createNode(248); + parseExpected(132); parseExpected(19); + node.expression = parseModuleSpecifier(); + parseExpected(20); return finishNode(node); } function parseModuleSpecifier() { @@ -18468,22 +19177,22 @@ var ts; } } function parseNamespaceImport() { - var namespaceImport = createNode(239); - parseExpected(38); - parseExpected(117); + var namespaceImport = createNode(240); + parseExpected(39); + parseExpected(118); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } function parseNamedImportsOrExports(kind) { var node = createNode(kind); - node.elements = parseBracketedList(22, kind === 240 ? parseImportSpecifier : parseExportSpecifier, 16, 17); + node.elements = parseBracketedList(22, kind === 241 ? parseImportSpecifier : parseExportSpecifier, 17, 18); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(245); + return parseImportOrExportSpecifier(246); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(241); + return parseImportOrExportSpecifier(242); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -18491,9 +19200,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 117) { + if (token() === 118) { node.propertyName = identifierName; - parseExpected(117); + parseExpected(118); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -18502,23 +19211,23 @@ var ts; else { node.name = identifierName; } - if (kind === 241 && checkIdentifierIsKeyword) { + if (kind === 242 && checkIdentifierIsKeyword) { parseErrorAtPosition(checkIdentifierStart, checkIdentifierEnd - checkIdentifierStart, ts.Diagnostics.Identifier_expected); } return finishNode(node); } function parseExportDeclaration(fullStart, decorators, modifiers) { - var node = createNode(243, fullStart); + var node = createNode(244, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(38)) { - parseExpected(139); + if (parseOptional(39)) { + parseExpected(140); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(244); - if (token() === 139 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { - parseExpected(139); + node.exportClause = parseNamedImportsOrExports(245); + if (token() === 140 || (token() === 9 && !scanner.hasPrecedingLineBreak())) { + parseExpected(140); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -18526,14 +19235,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(242, fullStart); + var node = createNode(243, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(57)) { + if (parseOptional(58)) { node.isExportEquals = true; } else { - parseExpected(78); + parseExpected(79); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -18545,6 +19254,7 @@ var ts; var typeReferenceDirectives = []; var amdDependencies = []; var amdModuleName; + var checkJsDirective = undefined; while (true) { var kind = triviaScanner.scan(); if (kind !== 2) { @@ -18555,7 +19265,11 @@ var ts; break; } } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var range = { + kind: triviaScanner.getToken(), + pos: triviaScanner.getTokenPos(), + end: triviaScanner.getTextPos(), + }; var comment = sourceText.substring(range.pos, range.end); var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { @@ -18595,20 +19309,30 @@ var ts; amdDependencies.push(amdDependency); } } + var checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; + var checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: ts.compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", true) === 0, + end: range.end, + pos: range.pos + }; + } } } sourceFile.referencedFiles = referencedFiles; sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1) - || node.kind === 236 && node.moduleReference.kind === 247 - || node.kind === 237 - || node.kind === 242 + || node.kind === 237 && node.moduleReference.kind === 248 + || node.kind === 238 || node.kind === 243 + || node.kind === 244 ? node : undefined; }); @@ -18654,16 +19378,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 38: - case 54: - case 18: - case 20: - case 50: - case 16: - case 88: - case 23: - case 93: - case 98: + case 39: + case 55: + case 19: + case 21: + case 51: + case 17: + case 89: + case 24: + case 94: + case 99: return true; } return ts.tokenIsIdentifierOrKeyword(token()); @@ -18681,23 +19405,23 @@ var ts; } JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests; function parseJSDocTypeExpression() { - var result = createNode(266, scanner.getTokenPos()); - parseExpected(16); - result.type = parseJSDocTopLevelType(); + var result = createNode(267, scanner.getTokenPos()); parseExpected(17); + result.type = parseJSDocTopLevelType(); + parseExpected(18); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 48) { - var unionType = createNode(270, type.pos); + if (token() === 49) { + var unionType = createNode(271, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 57) { - var optionalType = createNode(277, type.pos); + if (token() === 58) { + var optionalType = createNode(278, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -18707,21 +19431,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 20) { - var arrayType = createNode(269, type.pos); + if (token() === 21) { + var arrayType = createNode(270, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(21); + parseExpected(22); type = finishNode(arrayType); } - else if (token() === 54) { - var nullableType = createNode(272, type.pos); + else if (token() === 55) { + var nullableType = createNode(273, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 50) { - var nonNullableType = createNode(273, type.pos); + else if (token() === 51) { + var nonNullableType = createNode(274, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -18734,95 +19458,95 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 38: + case 39: return parseJSDocAllType(); - case 54: + case 55: return parseJSDocUnknownOrNullableType(); - case 18: + case 19: return parseJSDocUnionType(); - case 20: + case 21: return parseJSDocTupleType(); - case 50: + case 51: return parseJSDocNonNullableType(); - case 16: + case 17: return parseJSDocRecordType(); - case 88: + case 89: return parseJSDocFunctionType(); - case 23: + case 24: return parseJSDocVariadicType(); - case 93: - return parseJSDocConstructorType(); - case 98: - return parseJSDocThisType(); - case 118: - case 135: - case 132: - case 121: - case 136: - case 104: case 94: - case 138: - case 129: + return parseJSDocConstructorType(); + case 99: + return parseJSDocThisType(); + case 119: + case 136: case 133: + case 122: + case 137: + case 105: + case 95: + case 139: + case 130: + case 134: return parseTokenNode(); case 9: case 8: - case 100: - case 85: + case 101: + case 86: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(281); + var result = createNode(282); nextToken(); - parseExpected(55); + parseExpected(56); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(280); + var result = createNode(281); nextToken(); - parseExpected(55); + parseExpected(56); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(279); + var result = createNode(280); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(278); + var result = createNode(279); nextToken(); - parseExpected(18); + parseExpected(19); result.parameters = parseDelimitedList(23, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(19); - if (token() === 55) { + parseExpected(20); + if (token() === 56) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(145); + var parameter = createNode(146); parameter.type = parseJSDocType(); - if (parseOptional(57)) { - parameter.questionToken = createNode(57); + if (parseOptional(58)) { + parameter.questionToken = createNode(58); } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(276); + var result = createNode(277); result.name = parseSimplePropertyName(); - if (token() === 26) { + if (token() === 27) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(22)) { - if (token() === 26) { + while (parseOptional(23)) { + if (token() === 27) { result.typeArguments = parseTypeArguments(); break; } @@ -18838,7 +19562,7 @@ var ts; var typeArguments = parseDelimitedList(24, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(28); + parseExpected(29); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -18849,28 +19573,28 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(142, left.pos); + var result = createNode(143, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(274); + var result = createNode(275); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(273); + var result = createNode(274); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(271); + var result = createNode(272); nextToken(); result.types = parseDelimitedList(26, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(21); + parseExpected(22); return finishNode(result); } function checkForTrailingComma(list) { @@ -18880,45 +19604,45 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(270); + var result = createNode(271); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(19); + parseExpected(20); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(48)) { + while (parseOptional(49)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(267); + var result = createNode(268); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(292); + var result = createNode(293); result.literal = parseLiteralTypeNode(); return finishNode(result); } function parseJSDocUnknownOrNullableType() { var pos = scanner.getStartPos(); nextToken(); - if (token() === 25 || - token() === 17 || - token() === 19 || - token() === 28 || - token() === 57 || - token() === 48) { - var result = createNode(268, pos); + if (token() === 26 || + token() === 18 || + token() === 20 || + token() === 29 || + token() === 58 || + token() === 49) { + var result = createNode(269, pos); return finishNode(result); } else { - var result = createNode(272, pos); + var result = createNode(273, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -18989,7 +19713,7 @@ var ts; } while (token() !== 1) { switch (token()) { - case 56: + case 57: if (state === 0 || state === 1) { removeTrailingNewlines(comments); parseTag(indent); @@ -19007,7 +19731,7 @@ var ts; state = 0; indent = 0; break; - case 38: + case 39: var asterisk = scanner.getTokenText(); if (state === 1 || state === 2) { state = 2; @@ -19018,7 +19742,7 @@ var ts; indent += asterisk.length; } break; - case 70: + case 71: pushComment(scanner.getTokenText()); state = 2; break; @@ -19068,7 +19792,7 @@ var ts; content.charCodeAt(start + 3) !== 42; } function createJSDocComment() { - var result = createNode(282, start); + var result = createNode(283, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19079,8 +19803,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 56); - var atToken = createNode(56, scanner.getTokenPos()); + ts.Debug.assert(token() === 57); + var atToken = createNode(57, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -19125,7 +19849,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1; + var state = 0; var margin; function pushComment(text) { if (!margin) { @@ -19134,7 +19858,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 56 && token() !== 1) { + while (token() !== 57 && token() !== 1) { switch (token()) { case 4: if (state >= 1) { @@ -19143,7 +19867,7 @@ var ts; } indent = 0; break; - case 56: + case 57: break; case 5: if (state === 2) { @@ -19157,7 +19881,7 @@ var ts; indent += whitespace.length; } break; - case 38: + case 39: if (state === 0) { state = 1; indent += scanner.getTokenText().length; @@ -19168,7 +19892,7 @@ var ts; pushComment(scanner.getTokenText()); break; } - if (token() === 56) { + if (token() === 57) { break; } nextJSDocToken(); @@ -19178,7 +19902,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(283, atToken.pos); + var result = createNode(284, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -19196,7 +19920,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 16) { + if (token() !== 17) { return undefined; } return parseJSDocTypeExpression(); @@ -19207,14 +19931,14 @@ var ts; skipWhitespace(); var name; var isBracketed; - if (parseOptionalToken(20)) { + if (parseOptionalToken(21)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; - if (parseOptionalToken(57)) { + if (parseOptionalToken(58)) { parseExpression(); } - parseExpected(21); + parseExpected(22); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -19233,7 +19957,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(285, atToken.pos); + var result = createNode(286, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -19244,20 +19968,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 286; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(286, atToken.pos); + var result = createNode(287, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 287; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(287, atToken.pos); + var result = createNode(288, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -19272,7 +19996,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(290, atToken.pos); + var result = createNode(291, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -19281,7 +20005,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(284, atToken.pos); + var result = createNode(285, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -19290,15 +20014,15 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(289, atToken.pos); + var typedefTag = createNode(290, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; while (true) { - if (rightNode.kind === 70 || !rightNode.body) { - typedefTag.name = rightNode.kind === 70 ? rightNode : rightNode.name; + if (rightNode.kind === 71 || !rightNode.body) { + typedefTag.name = rightNode.kind === 71 ? rightNode : rightNode.name; break; } rightNode = rightNode.body; @@ -19307,9 +20031,9 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 276) { + if (typeExpression.type.kind === 277) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 70) { + if (jsDocTypeReference.name.kind === 71) { var name = jsDocTypeReference.name; if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -19325,7 +20049,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(291, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(292, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -19333,7 +20057,7 @@ var ts; while (token() !== 1 && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 56: + case 57: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -19347,14 +20071,15 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 38: + case 39: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 70: + case 71: canParseTag = false; + break; case 1: break; } @@ -19365,8 +20090,8 @@ var ts; function parseJSDocTypeNameWithNamespace(flags) { var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (typeNameOrNamespaceName && parseOptional(22)) { - var jsDocNamespaceNode = createNode(232, pos); + if (typeNameOrNamespaceName && parseOptional(23)) { + var jsDocNamespaceNode = createNode(233, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4); @@ -19379,8 +20104,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 56); - var atToken = createNode(56, scanner.getStartPos()); + ts.Debug.assert(token() === 57); + var atToken = createNode(57, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -19410,7 +20135,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 288; })) { + if (ts.forEach(tags, function (t) { return t.kind === 289; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } var typeParameters = createNodeArray(); @@ -19421,11 +20146,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(144, name.pos); + var typeParameter = createNode(145, name.pos); typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 25) { + if (token() === 26) { nextJSDocToken(); skipWhitespace(); } @@ -19433,7 +20158,7 @@ var ts; break; } } - var result = createNode(288, atToken.pos); + var result = createNode(289, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -19454,7 +20179,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(70, pos); + var result = createNode(71, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -19535,7 +20260,7 @@ var ts; switch (node.kind) { case 9: case 8: - case 70: + case 71: return true; } return false; @@ -19762,16 +20487,16 @@ var ts; ModuleInstanceState[ModuleInstanceState["ConstEnumOnly"] = 2] = "ConstEnumOnly"; })(ModuleInstanceState = ts.ModuleInstanceState || (ts.ModuleInstanceState = {})); function getModuleInstanceState(node) { - if (node.kind === 229 || node.kind === 230) { + if (node.kind === 230 || node.kind === 231) { return 0; } else if (ts.isConstEnumDeclaration(node)) { return 2; } - else if ((node.kind === 237 || node.kind === 236) && !(ts.hasModifier(node, 1))) { + else if ((node.kind === 238 || node.kind === 237) && !(ts.hasModifier(node, 1))) { return 0; } - else if (node.kind === 233) { + else if (node.kind === 234) { var state_1 = 0; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -19787,11 +20512,11 @@ var ts; }); return state_1; } - else if (node.kind === 232) { + else if (node.kind === 233) { var body = node.body; return body ? getModuleInstanceState(body) : 1; } - else if (node.kind === 70 && node.isInJSDocNamespace) { + else if (node.kind === 71 && node.isInJSDocNamespace) { return 0; } else { @@ -19881,7 +20606,7 @@ var ts; } return bindSourceFile; function bindInStrictMode(file, opts) { - if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !ts.isDeclarationFile(file)) { return true; } else { @@ -19908,7 +20633,7 @@ var ts; if (symbolFlags & 107455) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 233)) { symbol.valueDeclaration = node; } } @@ -19918,7 +20643,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 143) { + if (node.name.kind === 144) { var nameExpression = node.name.expression; if (ts.isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -19929,49 +20654,50 @@ var ts; return node.name.text; } switch (node.kind) { - case 151: + case 152: return "__constructor"; - case 159: - case 154: - return "__call"; case 160: case 155: - return "__new"; + return "__call"; + case 161: case 156: + return "__new"; + case 157: return "__index"; - case 243: + case 244: return "__export"; - case 242: + case 243: return node.isExportEquals ? "export=" : "default"; - case 193: + case 194: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2: return "export="; case 1: case 4: + case 5: return node.left.name.text; case 3: return node.left.expression.name.text; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 227: case 228: + case 229: return ts.hasModifier(node, 512) ? "default" : undefined; - case 278: + case 279: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 145: - ts.Debug.assert(node.parent.kind === 278); + case 146: + ts.Debug.assert(node.parent.kind === 279); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 289: + case 290: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 207) { + if (parentNode && parentNode.kind === 208) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70) { + if (nameIdentifier.kind === 71) { nameFromParentNode = nameIdentifier.text; } } @@ -20015,7 +20741,7 @@ var ts; } else { if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 242 && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 243 && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -20035,7 +20761,7 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1; if (symbolFlags & 8388608) { - if (node.kind === 245 || (node.kind === 236 && hasExportModifier)) { + if (node.kind === 246 || (node.kind === 237 && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { @@ -20043,9 +20769,9 @@ var ts; } } else { - var isJSDocTypedefInJSDocNamespace = node.kind === 289 && + var isJSDocTypedefInJSDocNamespace = node.kind === 290 && node.name && - node.name.kind === 70 && + node.name.kind === 71 && node.name.isInJSDocNamespace; if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 ? 1048576 : 0) | @@ -20104,7 +20830,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256; } - if (node.kind === 264) { + if (node.kind === 265) { node.flags |= emitFlags; } if (isIIFE) { @@ -20180,66 +20906,72 @@ var ts; return; } switch (node.kind) { - case 212: + case 213: bindWhileStatement(node); break; - case 211: + case 212: bindDoStatement(node); break; - case 213: + case 214: bindForStatement(node); break; - case 214: case 215: + case 216: bindForInOrForOfStatement(node); break; - case 210: + case 211: bindIfStatement(node); break; - case 218: - case 222: + case 219: + case 223: bindReturnOrThrow(node); break; + case 218: case 217: - case 216: bindBreakOrContinueStatement(node); break; - case 223: + case 224: bindTryStatement(node); break; - case 220: + case 221: bindSwitchStatement(node); break; - case 234: + case 235: bindCaseBlock(node); break; - case 256: + case 257: bindCaseClause(node); break; - case 221: + case 222: bindLabeledStatement(node); break; - case 191: + case 192: bindPrefixUnaryExpressionFlow(node); break; - case 192: + case 193: bindPostfixUnaryExpressionFlow(node); break; - case 193: + case 194: bindBinaryExpressionFlow(node); break; - case 187: + case 188: bindDeleteExpressionFlow(node); break; - case 194: + case 195: bindConditionalExpressionFlow(node); break; - case 225: + case 226: bindVariableDeclarationFlow(node); break; - case 180: + case 181: bindCallExpressionFlow(node); break; + case 283: + bindJSDocComment(node); + break; + case 290: + bindJSDocTypedefTag(node); + break; default: bindEachChild(node); break; @@ -20247,25 +20979,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 70: - case 98: - case 178: + case 71: + case 99: + case 179: return isNarrowableReference(expr); - case 180: + case 181: return hasNarrowableArgument(expr); - case 184: + case 185: return isNarrowingExpression(expr.expression); - case 193: + case 194: return isNarrowingBinaryExpression(expr); - case 191: - return expr.operator === 50 && isNarrowingExpression(expr.operand); + case 192: + return expr.operator === 51 && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 70 || - expr.kind === 98 || - expr.kind === 178 && isNarrowableReference(expr.expression); + return expr.kind === 71 || + expr.kind === 99 || + expr.kind === 97 || + expr.kind === 179 && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -20276,41 +21009,41 @@ var ts; } } } - if (expr.expression.kind === 178 && + if (expr.expression.kind === 179 && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 188 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; + return expr1.kind === 189 && isNarrowableOperand(expr1.expression) && expr2.kind === 9; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 57: + case 58: return isNarrowableReference(expr.left); - case 31: case 32: case 33: case 34: + case 35: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 92: + case 93: return isNarrowableOperand(expr.left); - case 25: + case 26: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 184: + case 185: return isNarrowableOperand(expr.expression); - case 193: + case 194: switch (expr.operatorToken.kind) { - case 57: + case 58: return isNarrowableOperand(expr.left); - case 25: + case 26: return isNarrowableOperand(expr.right); } } @@ -20344,8 +21077,8 @@ var ts; if (!expression) { return flags & 32 ? antecedent : unreachableFlow; } - if (expression.kind === 100 && flags & 64 || - expression.kind === 85 && flags & 32) { + if (expression.kind === 101 && flags & 64 || + expression.kind === 86 && flags & 32) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -20400,34 +21133,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 210: - case 212: case 211: - return parent.expression === node; case 213: - case 194: + case 212: + return parent.expression === node; + case 214: + case 195: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 184) { + if (node.kind === 185) { node = node.expression; } - else if (node.kind === 191 && node.operator === 50) { + else if (node.kind === 192 && node.operator === 51) { node = node.operand; } else { - return node.kind === 193 && (node.operatorToken.kind === 52 || - node.operatorToken.kind === 53); + return node.kind === 194 && (node.operatorToken.kind === 53 || + node.operatorToken.kind === 54); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 184 || - node.parent.kind === 191 && - node.parent.operator === 50) { + while (node.parent.kind === 185 || + node.parent.kind === 192 && + node.parent.operator === 51) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -20468,7 +21201,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 221 + var enclosingLabeledStatement = node.parent.kind === 222 ? ts.lastOrUndefined(activeLabels) : undefined; var preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement.continueTarget : createBranchLabel(); @@ -20500,10 +21233,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; + if (node.kind === 216) { + bind(node.awaitModifier); + } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 226) { + if (node.initializer.kind !== 227) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -20525,7 +21261,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 218) { + if (node.kind === 219) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -20545,7 +21281,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 217 ? breakTarget : continueTarget; + var flowLabel = node.kind === 218 ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -20608,7 +21344,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 258; }); node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; if (!hasDefault) { addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0)); @@ -20673,13 +21409,13 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 211) { + if (!node.statement || node.statement.kind !== 212) { addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 193 && node.operatorToken.kind === 57) { + if (node.kind === 194 && node.operatorToken.kind === 58) { bindAssignmentTargetFlow(node.left); } else { @@ -20690,10 +21426,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 176) { + else if (node.kind === 177) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 197) { + if (e.kind === 198) { bindAssignmentTargetFlow(e.expression); } else { @@ -20701,16 +21437,16 @@ var ts; } } } - else if (node.kind === 177) { + else if (node.kind === 178) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 260) { + if (p.kind === 261) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 261) { + else if (p.kind === 262) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 262) { + else if (p.kind === 263) { bindAssignmentTargetFlow(p.expression); } } @@ -20718,7 +21454,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 52) { + if (node.operatorToken.kind === 53) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -20729,7 +21465,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 50) { + if (node.operator === 51) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -20739,20 +21475,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 52 || operator === 53) { + if (operator === 53 || operator === 54) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -20766,7 +21502,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 && node.left.kind === 179) { + if (operator === 58 && node.left.kind === 180) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20777,7 +21513,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 178) { + if (node.expression.kind === 179) { bindAssignmentTargetFlow(node.expression); } } @@ -20810,16 +21546,31 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 214 || node.parent.parent.kind === 215) { + if (node.initializer || node.parent.parent.kind === 215 || node.parent.parent.kind === 216) { bindInitializedVariableFlow(node); } } + function bindJSDocComment(node) { + ts.forEachChild(node, function (n) { + if (n.kind !== 290) { + bind(n); + } + }); + } + function bindJSDocTypedefTag(node) { + ts.forEachChild(node, function (n) { + if (node.fullName && n === node.name && node.fullName.kind !== 71) { + return; + } + bind(n); + }); + } function bindCallExpressionFlow(node) { var expr = node.expression; - while (expr.kind === 184) { + while (expr.kind === 185) { expr = expr.expression; } - if (expr.kind === 185 || expr.kind === 186) { + if (expr.kind === 186 || expr.kind === 187) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -20827,7 +21578,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 178) { + if (node.expression.kind === 179) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -20836,53 +21587,53 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 198: - case 228: - case 231: - case 177: - case 162: - case 291: - case 274: - case 253: - return 1; + case 199: case 229: - return 1 | 64; - case 278: case 232: + case 178: + case 163: + case 292: + case 275: + case 254: + return 1; case 230: - case 171: + return 1 | 64; + case 279: + case 233: + case 231: + case 172: return 1 | 32; - case 264: + case 265: return 1 | 4 | 32; - case 150: + case 151: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 | 4 | 32 | 8 | 128; } - case 151: - case 227: - case 149: case 152: + case 228: + case 150: case 153: case 154: case 155: case 156: - case 159: + case 157: case 160: + case 161: return 1 | 4 | 32 | 8; - case 185: case 186: + case 187: return 1 | 4 | 32 | 8 | 16; - case 233: + case 234: return 4; - case 148: + case 149: return node.initializer ? 4 : 0; - case 259: - case 213: + case 260: case 214: case 215: - case 234: + case 216: + case 235: return 2; - case 206: + case 207: return ts.isFunctionLike(node.parent) ? 0 : 2; } return 0; @@ -20898,38 +21649,38 @@ var ts; } function declareSymbolAndAddToSymbolTableWorker(node, symbolFlags, symbolExcludes) { switch (container.kind) { - case 232: + case 233: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 264: + case 265: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 198: - case 228: - return declareClassMember(node, symbolFlags, symbolExcludes); - case 231: - return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 162: - case 177: + case 199: case 229: - case 274: - case 291: - case 253: + return declareClassMember(node, symbolFlags, symbolExcludes); + case 232: + return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); + case 163: + case 178: + case 230: + case 275: + case 292: + case 254: return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes); - case 159: case 160: - case 154: + case 161: case 155: case 156: - case 150: - case 149: + case 157: case 151: + case 150: case 152: case 153: - case 227: - case 185: + case 154: + case 228: case 186: - case 278: - case 230: - case 171: + case 187: + case 279: + case 231: + case 172: return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); } } @@ -20944,11 +21695,11 @@ var ts; : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 264 ? node : node.body; - if (body && (body.kind === 264 || body.kind === 233)) { + var body = node.kind === 265 ? node : node.body; + if (body && (body.kind === 265 || body.kind === 234)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 243 || stat.kind === 242) { + if (stat.kind === 244 || stat.kind === 243) { return true; } } @@ -21031,11 +21782,11 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 || prop.name.kind !== 70) { + if (prop.kind === 263 || prop.name.kind !== 71) { continue; } var identifier = prop.name; - var currentKind = prop.kind === 260 || prop.kind === 261 || prop.kind === 150 + var currentKind = prop.kind === 261 || prop.kind === 262 || prop.kind === 151 ? 1 : 2; var existingKind = seen.get(identifier.text); @@ -21063,10 +21814,10 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 232: + case 233: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 264: + case 265: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; @@ -21084,8 +21835,8 @@ var ts; } function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 107 && - node.originalKeywordKind <= 115 && + node.originalKeywordKind >= 108 && + node.originalKeywordKind <= 116 && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { if (!file.parseDiagnostics.length) { @@ -21113,17 +21864,17 @@ var ts; } } function checkStrictModeDeleteExpression(node) { - if (inStrictMode && node.expression.kind === 70) { + if (inStrictMode && node.expression.kind === 71) { var span_2 = ts.getErrorSpanForNode(file, node.expression); file.bindDiagnostics.push(ts.createFileDiagnostic(file, span_2.start, span_2.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode)); } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 70 && + return node.kind === 71 && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 70) { + if (name && name.kind === 71) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { var span_3 = ts.getErrorSpanForNode(file, name); @@ -21156,8 +21907,8 @@ var ts; } function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2) { - if (blockScopeContainer.kind !== 264 && - blockScopeContainer.kind !== 232 && + if (blockScopeContainer.kind !== 265 && + blockScopeContainer.kind !== 233 && !ts.isFunctionLike(blockScopeContainer)) { var errorSpan = ts.getErrorSpanForNode(file, node); file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node))); @@ -21165,7 +21916,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.isOctalLiteral) { + if (inStrictMode && node.numericLiteralFlags & 4) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -21176,7 +21927,7 @@ var ts; } function checkStrictModePrefixUnaryExpression(node) { if (inStrictMode) { - if (node.operator === 42 || node.operator === 43) { + if (node.operator === 43 || node.operator === 44) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -21199,8 +21950,11 @@ var ts; } node.parent = parent; var saveInStrictMode = inStrictMode; + if (ts.isInJavaScriptFile(node)) { + bindJSDocTypedefTagIfAny(node); + } bindWorker(node); - if (node.kind > 141) { + if (node.kind > 142) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -21217,6 +21971,26 @@ var ts; } inStrictMode = saveInStrictMode; } + function bindJSDocTypedefTagIfAny(node) { + if (!node.jsDoc) { + return; + } + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + if (!jsDoc.tags) { + continue; + } + for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) { + var tag = _c[_b]; + if (tag.kind === 290) { + var savedParent = parent; + parent = jsDoc; + bind(tag); + parent = savedParent; + } + } + } + } function updateStrictModeStatementList(statements) { if (!inStrictMode) { for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { @@ -21237,91 +22011,92 @@ var ts; } function bindWorker(node) { switch (node.kind) { - case 70: + case 71: if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 289) { + while (parentNode && parentNode.kind !== 290) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288, 793064); break; } - case 98: - if (currentFlow && (ts.isExpression(node) || parent.kind === 261)) { + case 99: + if (currentFlow && (ts.isExpression(node) || parent.kind === 262)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 178: + case 179: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 193: - if (ts.isInJavaScriptFile(node)) { - var specialKind = ts.getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case 1: - bindExportsPropertyAssignment(node); - break; - case 2: - bindModuleExportsAssignment(node); - break; - case 3: - bindPrototypePropertyAssignment(node); - break; - case 4: - bindThisPropertyAssignment(node); - break; - case 0: - break; - default: - ts.Debug.fail("Unknown special property assignment kind"); - } + case 194: + var specialKind = ts.getSpecialPropertyAssignmentKind(node); + switch (specialKind) { + case 1: + bindExportsPropertyAssignment(node); + break; + case 2: + bindModuleExportsAssignment(node); + break; + case 3: + bindPrototypePropertyAssignment(node); + break; + case 4: + bindThisPropertyAssignment(node); + break; + case 5: + bindStaticPropertyAssignment(node); + break; + case 0: + break; + default: + ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 259: + case 260: return checkStrictModeCatchClause(node); - case 187: + case 188: return checkStrictModeDeleteExpression(node); case 8: return checkStrictModeNumericLiteral(node); - case 192: + case 193: return checkStrictModePostfixUnaryExpression(node); - case 191: + case 192: return checkStrictModePrefixUnaryExpression(node); - case 219: + case 220: return checkStrictModeWithStatement(node); - case 168: + case 169: seenThisKeyword = true; return; - case 157: + case 158: return checkTypePredicate(node); - case 144: - return declareSymbolAndAddToSymbolTable(node, 262144, 530920); case 145: + return declareSymbolAndAddToSymbolTable(node, 262144, 530920); + case 146: return bindParameter(node); - case 225: - case 175: + case 226: + case 176: return bindVariableDeclarationOrBindingElement(node); + case 149: case 148: - case 147: - case 275: + case 276: return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 67108864 : 0), 0); - case 290: + case 291: return bindJSDocProperty(node); - case 260: case 261: - return bindPropertyOrMethodOrAccessor(node, 4, 0); - case 263: - return bindPropertyOrMethodOrAccessor(node, 8, 900095); case 262: - case 254: + return bindPropertyOrMethodOrAccessor(node, 4, 0); + case 264: + return bindPropertyOrMethodOrAccessor(node, 8, 900095); + case 263: + case 255: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 177 && - root.parent.kind === 193 && - root.parent.operatorToken.kind === 57 && + if (root.kind === 178 && + root.parent.kind === 194 && + root.parent.operatorToken.kind === 58 && root.parent.left === root) { hasRest = true; break; @@ -21329,91 +22104,91 @@ var ts; root = root.parent; } return; - case 154: case 155: case 156: + case 157: return declareSymbolAndAddToSymbolTable(node, 131072, 0); - case 150: - case 149: - return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); - case 227: - return bindFunctionDeclaration(node); case 151: - return declareSymbolAndAddToSymbolTable(node, 16384, 0); + case 150: + return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 67108864 : 0), ts.isObjectLiteralMethod(node) ? 0 : 99263); + case 228: + return bindFunctionDeclaration(node); case 152: - return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + return declareSymbolAndAddToSymbolTable(node, 16384, 0); case 153: + return bindPropertyOrMethodOrAccessor(node, 32768, 41919); + case 154: return bindPropertyOrMethodOrAccessor(node, 65536, 74687); - case 159: case 160: - case 278: + case 161: + case 279: return bindFunctionOrConstructorType(node); - case 162: - case 171: - case 291: - case 274: + case 163: + case 172: + case 292: + case 275: return bindAnonymousDeclaration(node, 2048, "__type"); - case 177: + case 178: return bindObjectLiteralExpression(node); - case 185: case 186: + case 187: return bindFunctionExpression(node); - case 180: + case 181: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; - case 198: - case 228: + case 199: + case 229: inStrictMode = true; return bindClassLikeDeclaration(node); - case 229: + case 230: return bindBlockScopedDeclaration(node, 64, 792968); - case 289: - if (!node.fullName || node.fullName.kind === 70) { + case 290: + if (!node.fullName || node.fullName.kind === 71) { return bindBlockScopedDeclaration(node, 524288, 793064); } break; - case 230: - return bindBlockScopedDeclaration(node, 524288, 793064); case 231: - return bindEnumDeclaration(node); + return bindBlockScopedDeclaration(node, 524288, 793064); case 232: + return bindEnumDeclaration(node); + case 233: return bindModuleDeclaration(node); - case 253: + case 254: return bindJsxAttributes(node); - case 252: + case 253: return bindJsxAttribute(node, 4, 0); - case 236: - case 239: - case 241: - case 245: - return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); - case 235: - return bindNamespaceExportDeclaration(node); - case 238: - return bindImportClause(node); - case 243: - return bindExportDeclaration(node); + case 237: + case 240: case 242: + case 246: + return declareSymbolAndAddToSymbolTable(node, 8388608, 8388608); + case 236: + return bindNamespaceExportDeclaration(node); + case 239: + return bindImportClause(node); + case 244: + return bindExportDeclaration(node); + case 243: return bindExportAssignment(node); - case 264: + case 265: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 206: + case 207: if (!ts.isFunctionLike(node.parent)) { return; } - case 233: + case 234: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 70) { + if (parameterName && parameterName.kind === 71) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 168) { + if (parameterName && parameterName.kind === 169) { seenThisKeyword = true; } bind(type); @@ -21432,7 +22207,7 @@ var ts; bindAnonymousDeclaration(node, 8388608, getDeclarationName(node)); } else { - var flags = node.kind === 242 && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 243 && ts.exportAssignmentIsAlias(node) ? 8388608 : 4; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 | 8388608 | 32 | 16); @@ -21442,7 +22217,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 264) { + if (node.parent.kind !== 265) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -21485,24 +22260,56 @@ var ts; setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node.left, 4 | 7340032, 0); } + function isExportsOrModuleExportsOrAlias(node) { + return ts.isExportsIdentifier(node) || + ts.isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + function isNameOfExportsOrModuleExportsAliasDeclaration(node) { + if (node.kind === 71) { + var symbol = lookupSymbolForName(node.text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === 226) { + var declaration = symbol.valueDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + function isExportsOrModuleExportsOrAliasOrAssignemnt(node) { + return isExportsOrModuleExportsOrAlias(node) || + (ts.isAssignmentExpression(node, true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } function bindModuleExportsAssignment(node) { + var assignedExpression = ts.getRightMostAssignedExpression(node.right); + if (ts.isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + setCommonJsModuleIndicator(node); + return; + } setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, 4 | 7340032 | 512, 0); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - if (container.kind === 227 || container.kind === 185) { - container.symbol.members = container.symbol.members || ts.createMap(); - declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); - } - else if (container.kind === 151) { - var saveContainer = container; - container = container.parent; - var symbol = bindPropertyOrMethodOrAccessor(node, 4, 0); - if (symbol) { - symbol.isReplaceableByMethod = true; - } - container = saveContainer; + var container = ts.getThisContainer(node, false); + switch (container.kind) { + case 228: + case 186: + container.symbol.members = container.symbol.members || ts.createMap(); + declareSymbol(container.symbol.members, container.symbol, node, 4, 0 & ~4); + break; + case 152: + case 149: + case 151: + case 153: + case 154: + var containingClass = container.parent; + var symbol = declareSymbol(ts.hasModifier(container, 32) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, 4, 0); + if (symbol) { + symbol.isReplaceableByMethod = true; + } + break; } } function bindPrototypePropertyAssignment(node) { @@ -21512,14 +22319,35 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals.get(constructorFunction.text); - if (!funcSymbol || !(funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, true); + } + function bindStaticPropertyAssignment(node) { + var leftSideOfAssignment = node.left; + var target = leftSideOfAssignment.expression; + leftSideOfAssignment.parent = node; + target.parent = leftSideOfAssignment; + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, false); + } + } + function lookupSymbolForName(name) { + return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name)); + } + function bindPropertyAssignment(functionName, propertyAccessExpression, isPrototypeProperty) { + var targetSymbol = lookupSymbolForName(functionName); + if (targetSymbol && ts.isDeclarationOfFunctionOrClassExpression(targetSymbol)) { + targetSymbol = targetSymbol.valueDeclaration.initializer.symbol; + } + if (!targetSymbol || !(targetSymbol.flags & (16 | 32))) { return; } - if (!funcSymbol.members) { - funcSymbol.members = ts.createMap(); - } - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4, 0); + var symbolTable = isPrototypeProperty ? + (targetSymbol.members || (targetSymbol.members = ts.createMap())) : + (targetSymbol.exports || (targetSymbol.exports = ts.createMap())); + declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, 4, 0); } function bindCallExpression(node) { if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) { @@ -21527,7 +22355,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 228) { + if (node.kind === 229) { bindBlockScopedDeclaration(node, 32, 899519); } else { @@ -21587,7 +22415,7 @@ var ts; } function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -21602,7 +22430,7 @@ var ts; } function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -21615,7 +22443,7 @@ var ts; } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024; } } @@ -21638,15 +22466,15 @@ var ts; return false; } if (currentFlow === unreachableFlow) { - var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 208) || - node.kind === 228 || - (node.kind === 232 && shouldReportErrorOnModuleDeclaration(node)) || - (node.kind === 231 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 209) || + node.kind === 229 || + (node.kind === 233 && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 232 && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 207 || + (node.kind !== 208 || ts.getCombinedNodeFlags(node.declarationList) & 3 || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -21660,56 +22488,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 180: - return computeCallExpression(node, subtreeFlags); case 181: + return computeCallExpression(node, subtreeFlags); + case 182: return computeNewExpression(node, subtreeFlags); - case 232: + case 233: return computeModuleDeclaration(node, subtreeFlags); - case 184: - return computeParenthesizedExpression(node, subtreeFlags); - case 193: - return computeBinaryExpression(node, subtreeFlags); - case 209: - return computeExpressionStatement(node, subtreeFlags); - case 145: - return computeParameter(node, subtreeFlags); - case 186: - return computeArrowFunction(node, subtreeFlags); case 185: + return computeParenthesizedExpression(node, subtreeFlags); + case 194: + return computeBinaryExpression(node, subtreeFlags); + case 210: + return computeExpressionStatement(node, subtreeFlags); + case 146: + return computeParameter(node, subtreeFlags); + case 187: + return computeArrowFunction(node, subtreeFlags); + case 186: return computeFunctionExpression(node, subtreeFlags); - case 227: - return computeFunctionDeclaration(node, subtreeFlags); - case 225: - return computeVariableDeclaration(node, subtreeFlags); - case 226: - return computeVariableDeclarationList(node, subtreeFlags); - case 207: - return computeVariableStatement(node, subtreeFlags); - case 221: - return computeLabeledStatement(node, subtreeFlags); case 228: + return computeFunctionDeclaration(node, subtreeFlags); + case 226: + return computeVariableDeclaration(node, subtreeFlags); + case 227: + return computeVariableDeclarationList(node, subtreeFlags); + case 208: + return computeVariableStatement(node, subtreeFlags); + case 222: + return computeLabeledStatement(node, subtreeFlags); + case 229: return computeClassDeclaration(node, subtreeFlags); - case 198: + case 199: return computeClassExpression(node, subtreeFlags); - case 258: - return computeHeritageClause(node, subtreeFlags); case 259: + return computeHeritageClause(node, subtreeFlags); + case 260: return computeCatchClause(node, subtreeFlags); - case 200: + case 201: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 151: - return computeConstructor(node, subtreeFlags); - case 148: - return computePropertyDeclaration(node, subtreeFlags); - case 150: - return computeMethod(node, subtreeFlags); case 152: + return computeConstructor(node, subtreeFlags); + case 149: + return computePropertyDeclaration(node, subtreeFlags); + case 151: + return computeMethod(node, subtreeFlags); case 153: + case 154: return computeAccessor(node, subtreeFlags); - case 236: + case 237: return computeImportEquals(node, subtreeFlags); - case 178: + case 179: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -21732,13 +22560,13 @@ var ts; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 96: + case 97: return true; - case 178: case 179: + case 180: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 96; + return expressionKind === 97; } return false; } @@ -21757,14 +22585,14 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 && leftKind === 177) { + if (operatorTokenKind === 58 && leftKind === 178) { transformFlags |= 8 | 192 | 3072; } - else if (operatorTokenKind === 57 && leftKind === 176) { + else if (operatorTokenKind === 58 && leftKind === 177) { transformFlags |= 192 | 3072; } - else if (operatorTokenKind === 39 - || operatorTokenKind === 61) { + else if (operatorTokenKind === 40 + || operatorTokenKind === 62) { transformFlags |= 32; } node.transformFlags = transformFlags | 536870912; @@ -21799,8 +22627,8 @@ var ts; var expression = node.expression; var expressionKind = expression.kind; var expressionTransformFlags = expression.transformFlags; - if (expressionKind === 201 - || expressionKind === 183) { + if (expressionKind === 202 + || expressionKind === 184) { transformFlags |= 3; } if (expressionTransformFlags & 1024) { @@ -21843,10 +22671,10 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 84: + case 85: transformFlags |= 192; break; - case 107: + case 108: transformFlags |= 3; break; default: @@ -21897,9 +22725,9 @@ var ts; transformFlags |= 8; } if (ts.hasModifier(node, 256)) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; @@ -21942,7 +22770,7 @@ var ts; transformFlags |= 3; } if (modifierFlags & 256) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } if (subtreeFlags & 1048576) { transformFlags |= 8; @@ -21950,7 +22778,7 @@ var ts; if (subtreeFlags & 163840) { transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } } @@ -21965,7 +22793,7 @@ var ts; transformFlags |= 3; } if (ts.hasModifier(node, 256)) { - transformFlags |= 16; + transformFlags |= node.asteriskToken ? 8 : 16; } if (subtreeFlags & 1048576) { transformFlags |= 8; @@ -21973,7 +22801,7 @@ var ts; if (subtreeFlags & 163840) { transformFlags |= 192; } - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { transformFlags |= 768; } node.transformFlags = transformFlags | 536870912; @@ -22002,7 +22830,7 @@ var ts; var transformFlags = subtreeFlags; var expression = node.expression; var expressionKind = expression.kind; - if (expressionKind === 96) { + if (expressionKind === 97) { transformFlags |= 16384; } node.transformFlags = transformFlags | 536870912; @@ -22085,63 +22913,76 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536872257; switch (kind) { - case 119: - case 190: - transformFlags |= 16; + case 120: + case 191: + transformFlags |= 8 | 16; break; - case 113: - case 111: + case 114: case 112: - case 116: - case 123: - case 75: - case 231: - case 263: - case 183: - case 201: + case 113: + case 117: + case 124: + case 76: + case 232: + case 264: + case 184: case 202: - case 130: + case 203: + case 131: transformFlags |= 3; break; - case 248: case 249: case 250: - case 10: case 251: + case 10: case 252: case 253: case 254: case 255: + case 256: transformFlags |= 4; break; - case 215: - transformFlags |= 8; - case 12: case 13: case 14: case 15: - case 195: - case 182: - case 261: - case 114: - case 203: + case 16: + case 196: + case 183: + case 262: + case 115: + case 204: transformFlags |= 192; break; - case 196: - transformFlags |= 192 | 16777216; + case 9: + if (node.hasExtendedUnicodeEscape) { + transformFlags |= 192; + } break; - case 118: - case 132: - case 129: + case 8: + if (node.numericLiteralFlags & 48) { + transformFlags |= 192; + } + break; + case 216: + if (node.awaitModifier) { + transformFlags |= 8; + } + transformFlags |= 192; + break; + case 197: + transformFlags |= 8 | 192 | 16777216; + break; + case 119: case 133: - case 135: - case 121: + case 130: + case 134: case 136: - case 104: - case 144: - case 147: - case 149: - case 154: + case 122: + case 137: + case 105: + case 145: + case 148: + case 150: case 155: case 156: case 157: @@ -22155,55 +22996,56 @@ var ts; case 165: case 166: case 167: - case 229: - case 230: case 168: + case 230: + case 231: case 169: case 170: case 171: case 172: + case 173: transformFlags = 3; excludeFlags = -3; break; - case 143: + case 144: transformFlags |= 2097152; if (subtreeFlags & 16384) { transformFlags |= 65536; } break; - case 197: + case 198: transformFlags |= 192 | 524288; break; - case 262: + case 263: transformFlags |= 8 | 1048576; break; - case 96: + case 97: transformFlags |= 192; break; - case 98: + case 99: transformFlags |= 16384; break; - case 173: + case 174: transformFlags |= 192 | 8388608; if (subtreeFlags & 524288) { transformFlags |= 8 | 1048576; } excludeFlags = 537396545; break; - case 174: + case 175: transformFlags |= 192 | 8388608; excludeFlags = 537396545; break; - case 175: + case 176: transformFlags |= 192; if (node.dotDotDotToken) { transformFlags |= 524288; } break; - case 146: + case 147: transformFlags |= 3 | 4096; break; - case 177: + case 178: excludeFlags = 540087617; if (subtreeFlags & 2097152) { transformFlags |= 192; @@ -22215,29 +23057,29 @@ var ts; transformFlags |= 8; } break; - case 176: - case 181: + case 177: + case 182: excludeFlags = 537396545; if (subtreeFlags & 524288) { transformFlags |= 192; } break; - case 211: case 212: case 213: case 214: + case 215: if (subtreeFlags & 4194304) { transformFlags |= 192; } break; - case 264: + case 265: if (subtreeFlags & 32768) { transformFlags |= 192; } break; - case 218: - case 216: + case 219: case 217: + case 218: transformFlags |= 33554432; break; } @@ -22245,57 +23087,57 @@ var ts; return transformFlags & ~excludeFlags; } function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 157 && kind <= 172) { + if (kind >= 158 && kind <= 173) { return -3; } switch (kind) { - case 180: case 181: - case 176: + case 182: + case 177: return 537396545; - case 232: + case 233: return 574674241; - case 145: + case 146: return 536872257; - case 186: + case 187: return 601249089; - case 185: - case 227: - return 601281857; - case 226: - return 546309441; + case 186: case 228: - case 198: + return 601281857; + case 227: + return 546309441; + case 229: + case 199: return 539358529; - case 151: - return 601015617; - case 150: case 152: - case 153: return 601015617; - case 118: - case 132: - case 129: - case 135: - case 133: - case 121: - case 136: - case 104: - case 144: - case 147: - case 149: + case 151: + case 153: case 154: + return 601015617; + case 119: + case 133: + case 130: + case 136: + case 134: + case 122: + case 137: + case 105: + case 145: + case 148: + case 150: case 155: case 156: - case 229: + case 157: case 230: + case 231: return -3; - case 177: + case 178: return 540087617; - case 259: + case 260: return 537920833; - case 173: case 174: + case 175: return 537396545; default: return 536872257; @@ -22335,15 +23177,19 @@ var ts; var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; var symbolCount = 0; + var symbolInstantiationDepth = 0; var emptyArray = []; var emptySymbols = ts.createMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0; + var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); var noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; - var strictNullChecks = compilerOptions.strictNullChecks; + var strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks; + var noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny; + var noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; var emitResolver = createResolver(); + var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4, "undefined"); undefinedSymbol.declarations = []; var argumentsSymbol = createSymbol(4, "arguments"); @@ -22355,10 +23201,18 @@ var ts; isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, + getMergedSymbol: getMergedSymbol, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, - getSymbolsOfParameterPropertyDeclaration: getSymbolsOfParameterPropertyDeclaration, + getTypeOfSymbolAtLocation: function (symbol, location) { + location = ts.getParseTreeNode(location); + return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + }, + getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { + parameter = ts.getParseTreeNode(parameter, ts.isParameter); + ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + return getSymbolsOfParameterPropertyDeclaration(parameter, parameterName); + }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -22366,37 +23220,103 @@ var ts; getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, - getTypeFromTypeNode: getTypeFromTypeNode, + getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, + getWidenedType: getWidenedType, + getTypeFromTypeNode: function (node) { + node = ts.getParseTreeNode(node, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : unknownType; + }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, - getTypeAtLocation: getTypeOfNode, - getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, - signatureToString: signatureToString, - typeToString: typeToString, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, + getSymbolsInScope: function (location, meaning) { + location = ts.getParseTreeNode(location); + return location ? getSymbolsInScope(location, meaning) : []; + }, + getSymbolAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getSymbolAtLocation(node) : undefined; + }, + getShorthandAssignmentValueSymbol: function (node) { + node = ts.getParseTreeNode(node); + return node ? getShorthandAssignmentValueSymbol(node) : undefined; + }, + getExportSpecifierLocalTargetSymbol: function (node) { + node = ts.getParseTreeNode(node, ts.isExportSpecifier); + return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; + }, + getTypeAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getTypeOfNode(node) : unknownType; + }, + getPropertySymbolOfDestructuringAssignment: function (location) { + location = ts.getParseTreeNode(location, ts.isIdentifier); + return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; + }, + signatureToString: function (signature, enclosingDeclaration, flags, kind) { + return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind); + }, + typeToString: function (type, enclosingDeclaration, flags) { + return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags); + }, getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, + symbolToString: function (symbol, enclosingDeclaration, meaning) { + return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning); + }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: getContextualType, + getContextualType: function (node) { + node = ts.getParseTreeNode(node, ts.isExpression); + return node ? getContextualType(node) : undefined; + }, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, + getResolvedSignature: function (node, candidatesOutArray) { + node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + return node ? getResolvedSignature(node, candidatesOutArray) : undefined; + }, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, + isValidPropertyAccess: function (node, propertyName) { + node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedName); + return node ? isValidPropertyAccess(node, propertyName) : false; + }, + getSignatureFromDeclaration: function (declaration) { + declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + return declaration ? getSignatureFromDeclaration(declaration) : undefined; + }, + isImplementationOfOverload: function (node) { + node = ts.getParseTreeNode(node, ts.isFunctionLike); + return node ? isImplementationOfOverload(node) : undefined; + }, + getImmediateAliasedSymbol: function (symbol) { + ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.immediateTarget) { + var node = getDeclarationOfAliasSymbol(symbol); + ts.Debug.assert(!!node); + links.immediateTarget = getTargetOfAliasDeclaration(node, true); + } + return links.immediateTarget; + }, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, + getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { + node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; + }, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter, + isOptionalParameter: function (node) { + node = ts.getParseTreeNode(node, ts.isParameter); + return node ? isOptionalParameter(node) : false; + }, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { return tryFindAmbientModule(moduleName, false); @@ -22444,11 +23364,9 @@ var ts; var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, undefined, 0, false, false); var silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, undefined, 0, false, false); var enumNumberIndexInfo = createIndexInfo(stringType, true); + var jsObjectLiteralIndexInfo = createIndexInfo(anyType, false); var globals = ts.createMap(); var patternAmbientModules; - var getGlobalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var tryGetGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -22457,26 +23375,26 @@ var ts; var globalNumberType; var globalBooleanType; var globalRegExpType; + var globalThisType; var anyArrayType; var autoArrayType; var anyReadonlyArrayType; - var getGlobalTemplateStringsArrayType; - var getGlobalESSymbolType; - var getGlobalIterableType; - var getGlobalIteratorType; - var getGlobalIterableIteratorType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var jsxElementClassType; + var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolType; + var deferredGlobalTypedPropertyDescriptorType; + var deferredGlobalPromiseType; + var deferredGlobalPromiseConstructorSymbol; + var deferredGlobalPromiseConstructorLikeType; + var deferredGlobalIterableType; + var deferredGlobalIteratorType; + var deferredGlobalIterableIteratorType; + var deferredGlobalAsyncIterableType; + var deferredGlobalAsyncIteratorType; + var deferredGlobalAsyncIterableIteratorType; + var deferredGlobalTemplateStringsArrayType; + var deferredJsxElementClassType; + var deferredJsxElementType; + var deferredJsxStatelessElementType; var deferredNodes; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; @@ -22586,15 +23504,19 @@ var ts; "undefined": undefinedType }); var typeofType = createTypeofType(); - var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; + var _jsxElementPropertiesName; + var _hasComputedJsxElementPropertiesName = false; + var _jsxElementChildrenPropertyName; + var _hasComputedJsxElementChildrenPropertyName = false; var jsxTypes = ts.createMap(); var JsxNames = { JSX: "JSX", IntrinsicElements: "IntrinsicElements", ElementClass: "ElementClass", ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + ElementChildrenAttributeNameContainer: "ElementChildrenAttribute", Element: "Element", IntrinsicAttributes: "IntrinsicAttributes", IntrinsicClassAttributes: "IntrinsicClassAttributes" @@ -22612,12 +23534,18 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["SkipContextSensitive"] = 1] = "SkipContextSensitive"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createMap(); builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { - if (_jsxNamespace === undefined) { + if (!_jsxNamespace) { _jsxNamespace = "React"; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); @@ -22647,6 +23575,9 @@ var ts; symbol.checkFlags = 0; return symbol; } + function isTransientSymbol(symbol) { + return (symbol.flags & 134217728) !== 0; + } function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2) @@ -22713,7 +23644,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 232 && source.valueDeclaration.kind !== 232))) { + (target.valueDeclaration.kind === 233 && source.valueDeclaration.kind !== 233))) { target.valueDeclaration = source.valueDeclaration; } ts.addRange(target.declarations, source.declarations); @@ -22730,7 +23661,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 || source.flags & 2 @@ -22816,7 +23747,7 @@ var ts; return symbol.flags & 134217728 ? symbol.checkFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 264 && !ts.isExternalOrCommonJsModule(node); + return node.kind === 265 && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -22853,77 +23784,76 @@ var ts; (!compilerOptions.outFile && !compilerOptions.out)) { return true; } - if (isUsedInFunctionOrInstanceProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { return true; } var sourceFiles = host.getSourceFiles(); return ts.indexOf(sourceFiles, declarationFile) <= ts.indexOf(sourceFiles, useFile); } if (declaration.pos <= usage.pos) { - if (declaration.kind === 175) { - var errorBindingElement = ts.getAncestor(usage, 175); + if (declaration.kind === 176) { + var errorBindingElement = ts.getAncestor(usage, 176); if (errorBindingElement) { - return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 226), usage); } - else if (declaration.kind === 225) { + else if (declaration.kind === 226) { return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } + if (usage.parent.kind === 246) { + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); - var isInstanceProperty = declaration.kind === 148 && !(ts.getModifierFlags(declaration) & 32); - return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); + return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 207: - case 213: - case 215: + case 208: + case 214: + case 216: if (isSameScopeDescendentOf(usage, declaration, container)) { return true; } break; } switch (declaration.parent.parent.kind) { - case 214: case 215: + case 216: if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; } } return false; } - function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { - var current = usage; - while (current) { + function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { + return !!ts.findAncestor(usage, function (current) { if (current === container) { - return false; + return "quit"; } if (ts.isFunctionLike(current)) { return true; } - var initializerOfInstanceProperty = current.parent && - current.parent.kind === 148 && - (ts.getModifierFlags(current.parent) & 32) === 0 && + var initializerOfProperty = current.parent && + current.parent.kind === 149 && current.parent.initializer === current; - if (initializerOfInstanceProperty) { - return !isDeclarationInstanceProperty; + if (initializerOfProperty) { + if (ts.getModifierFlags(current.parent) & 32) { + if (declaration.kind === 151) { + return true; + } + } + else { + var isDeclarationInstanceProperty = declaration.kind === 149 && !(ts.getModifierFlags(declaration) & 32); + if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { + return true; + } + } } - current = current.parent; - } - return false; - } - function getAncestorBindingPattern(node) { - while (node) { - if (ts.isBindingPattern(node)) { - return node; - } - node = node.parent; - } - return undefined; + }); } } function resolveName(location, name, meaning, nameNotFoundMessage, nameArg) { @@ -22938,18 +23868,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 & 793064 && lastLocation.kind !== 282) { + if (meaning & result.flags & 793064 && lastLocation.kind !== 283) { useResult = result.flags & 262144 ? lastLocation === location.type || - lastLocation.kind === 145 || - lastLocation.kind === 144 + lastLocation.kind === 146 || + lastLocation.kind === 145 : false; } if (meaning & 107455 && result.flags & 1) { useResult = - lastLocation.kind === 145 || + lastLocation.kind === 146 || (lastLocation === location.type && - result.valueDeclaration.kind === 145); + result.valueDeclaration.kind === 146); } } if (useResult) { @@ -22961,13 +23891,13 @@ var ts; } } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 232: + case 233: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 264 || ts.isAmbientModule(location)) { + if (location.kind === 265 || ts.isAmbientModule(location)) { if (result = moduleExports.get("default")) { var localSymbol = ts.getLocalSymbolForExportDefault(result); if (localSymbol && (result.flags & meaning) && localSymbol.name === name) { @@ -22978,7 +23908,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 8388608 && - ts.getDeclarationOfKind(moduleExport, 245)) { + ts.getDeclarationOfKind(moduleExport, 246)) { break; } } @@ -22986,13 +23916,13 @@ var ts; break loop; } break; - case 231: + case 232: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8)) { break loop; } break; + case 149: case 148: - case 147: if (ts.isClassLike(location.parent) && !(ts.getModifierFlags(location) & 32)) { var ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { @@ -23002,9 +23932,9 @@ var ts; } } break; - case 228: - case 198: case 229: + case 199: + case 230: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { result = undefined; @@ -23016,7 +23946,7 @@ var ts; } break loop; } - if (location.kind === 198 && meaning & 32) { + if (location.kind === 199 && meaning & 32) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -23024,28 +23954,28 @@ var ts; } } break; - case 143: + case 144: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 229) { + if (ts.isClassLike(grandparent) || grandparent.kind === 230) { if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } } break; - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 227: - case 186: + case 154: + case 228: + case 187: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 185: + case 186: if (meaning & 3 && name === "arguments") { result = argumentsSymbol; break loop; @@ -23058,8 +23988,8 @@ var ts; } } break; - case 146: - if (location.parent && location.parent.kind === 145) { + case 147: + if (location.parent && location.parent.kind === 146) { location = location.parent; } if (location.parent && ts.isClassElement(location.parent)) { @@ -23082,7 +24012,8 @@ var ts; !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); } } @@ -23094,15 +24025,16 @@ var ts; error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); return undefined; } - if (meaning & 2) { + if (meaning & 2 || + ((meaning & 32 || meaning & 384) && (meaning & 107455) === 107455)) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2) { + if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } if (result && isInExternalModule && (meaning & 107455) === 107455) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 235) { + if (decls && decls.length === 1 && decls[0].kind === 236) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -23112,14 +24044,14 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 144 && decl.parent === container) { + if (decl.kind === 145 && decl.parent === container) { return true; } } return false; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 70 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 71 && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, true); @@ -23157,10 +24089,10 @@ var ts; } function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 70: - case 178: + case 71: + case 179: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 200: + case 201: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -23187,46 +24119,60 @@ var ts; } return false; } - function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2) !== 0); - var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) ? d : undefined; }); - ts.Debug.assert(declaration !== undefined, "Block-scoped variable declaration is undefined"); - if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { + if (meaning & (107455 & ~1024 & ~793064)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~107455, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, name); + return true; + } } - } - function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { + else if (meaning & (793064 & ~1024 & ~107455)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~793064, undefined, undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, name); return true; } } return false; } + function checkResolvedBlockScopedVariable(result, errorLocation) { + ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384)); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 232) ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); + if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { + if (result.flags & 2) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 32) { + error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 384) { + error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + } + } + function isSameScopeDescendentOf(initial, parent, stopAt) { + return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); + } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 236) { + if (node.kind === 237) { return node; } - while (node && node.kind !== 237) { - node = node.parent; - } - return node; + return ts.findAncestor(node, function (n) { return n.kind === 238; }); } } function getDeclarationOfAliasSymbol(symbol) { return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 247) { + function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { + if (node.moduleReference.kind === 248) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); } - function getTargetOfImportClause(node) { + function getTargetOfImportClause(node, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -23237,20 +24183,20 @@ var ts; var exportValue = moduleSymbol.exports.get("export="); exportDefaultSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") - : resolveSymbol(moduleSymbol.exports.get("default")); + : resolveSymbol(moduleSymbol.exports.get("default"), dontResolveAlias); } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } return exportDefaultSymbol; } } - function getTargetOfNamespaceImport(node) { + function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); } function combineValueAndTypeSymbols(valueSymbol, typeSymbol) { if (valueSymbol.flags & (793064 | 1920)) { @@ -23267,12 +24213,9 @@ var ts; result.exports = valueSymbol.exports; return result; } - function getExportOfModule(symbol, name) { + function getExportOfModule(symbol, name, dontResolveAlias) { if (symbol.flags & 1536) { - var exportedSymbol = getExportsOfSymbol(symbol).get(name); - if (exportedSymbol) { - return resolveSymbol(exportedSymbol); - } + return resolveSymbol(getExportsOfSymbol(symbol).get(name), dontResolveAlias); } } function getPropertyOfVariable(symbol, name) { @@ -23283,9 +24226,9 @@ var ts; } } } - function getExternalModuleMember(node, specifier) { + function getExternalModuleMember(node, specifier, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; if (name.text) { @@ -23299,10 +24242,10 @@ var ts; else { symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } - symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name.text); + symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); + var symbolFromModule = getExportOfModule(targetSymbol, name.text, dontResolveAlias); if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { - symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : @@ -23314,40 +24257,41 @@ var ts; } } } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); + function getTargetOfImportSpecifier(node, dontResolveAlias) { + return getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); } - function getTargetOfNamespaceExportDeclaration(node) { - return resolveExternalModuleSymbol(node.parent.symbol); + function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) { + return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); } - function getTargetOfExportSpecifier(node) { + function getTargetOfExportSpecifier(node, dontResolveAlias) { return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 | 793064 | 1920); + getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : + resolveEntityName(node.propertyName || node.name, 107455 | 793064 | 1920, false, dontResolveAlias); } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 | 793064 | 1920); + function getTargetOfExportAssignment(node, dontResolveAlias) { + return resolveEntityName(node.expression, 107455 | 793064 | 1920, false, dontResolveAlias); } - function getTargetOfAliasDeclaration(node) { + function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { switch (node.kind) { - case 236: - return getTargetOfImportEqualsDeclaration(node); - case 238: - return getTargetOfImportClause(node); + case 237: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); case 239: - return getTargetOfNamespaceImport(node); - case 241: - return getTargetOfImportSpecifier(node); - case 245: - return getTargetOfExportSpecifier(node); + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 240: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); case 242: - return getTargetOfExportAssignment(node); - case 235: - return getTargetOfNamespaceExportDeclaration(node); + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 246: + return getTargetOfExportSpecifier(node, dontRecursivelyResolve); + case 243: + return getTargetOfExportAssignment(node, dontRecursivelyResolve); + case 236: + return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); } } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793064 | 1920)) ? resolveAlias(symbol) : symbol; + function resolveSymbol(symbol, dontResolveAlias) { + var shouldResolve = !dontResolveAlias && symbol && symbol.flags & 8388608 && !(symbol.flags & (107455 | 793064 | 1920)); + return shouldResolve ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608) !== 0, "Should only get Alias here."); @@ -23386,10 +24330,10 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 242) { + if (node.kind === 243) { checkExpressionCached(node.expression); } - else if (node.kind === 245) { + else if (node.kind === 246) { checkExpressionCached(node.propertyName || node.name); } else if (ts.isInternalModuleImportEqualsDeclaration(node)) { @@ -23398,14 +24342,14 @@ var ts; } } function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) { - if (entityName.kind === 70 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 71 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } - if (entityName.kind === 70 || entityName.parent.kind === 142) { + if (entityName.kind === 71 || entityName.parent.kind === 143) { return resolveEntityName(entityName, 1920, false, dontResolveAlias); } else { - ts.Debug.assert(entityName.parent.kind === 236); + ts.Debug.assert(entityName.parent.kind === 237); return resolveEntityName(entityName, 107455 | 793064 | 1920, false, dontResolveAlias); } } @@ -23417,16 +24361,26 @@ var ts; return undefined; } var symbol; - if (name.kind === 70) { + if (name.kind === 71) { var message = meaning === 1920 ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 142 || name.kind === 178) { - var left = name.kind === 142 ? name.left : name.expression; - var right = name.kind === 142 ? name.right : name.name; + else if (name.kind === 143 || name.kind === 179) { + var left = void 0; + if (name.kind === 143) { + left = name.left; + } + else if (name.kind === 179 && + (name.expression.kind === 185 || ts.isEntityNameExpression(name.expression))) { + left = name.expression; + } + else { + return undefined; + } + var right = name.kind === 143 ? name.right : name.name; var namespace = resolveEntityName(left, 1920, ignoreErrors, false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -23442,6 +24396,11 @@ var ts; return undefined; } } + else if (name.kind === 185) { + return ts.isEntityNameExpression(name.expression) ? + resolveEntityName(name.expression, meaning, ignoreErrors, dontResolveAlias, location) : + undefined; + } else { ts.Debug.fail("Unknown entity name kind."); } @@ -23453,7 +24412,7 @@ var ts; } function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReferenceExpression.kind !== 9) { + if (moduleReferenceExpression.kind !== 9 && moduleReferenceExpression.kind !== 13) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -23493,8 +24452,10 @@ var ts; var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } - else if (compilerOptions.noImplicitAny && moduleNotFoundError) { - error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + else if (noImplicitAny && moduleNotFoundError) { + var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } return undefined; } @@ -23515,12 +24476,12 @@ var ts; } return undefined; } - function resolveExternalModuleSymbol(moduleSymbol) { - return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; + function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || moduleSymbol; } - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 | 3))) { + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression, dontResolveAlias) { + var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); + if (!dontResolveAlias && symbol && !(symbol.flags & (1536 | 3))) { error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } @@ -23634,7 +24595,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 === 151 && ts.nodeIsPresent(member.body)) { + if (member.kind === 152 && ts.nodeIsPresent(member.body)) { return member; } } @@ -23707,11 +24668,11 @@ var ts; } } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232: + case 233: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -23755,7 +24716,7 @@ var ts; return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) { if (!useOnlyExternalAliasing || ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable); @@ -23787,7 +24748,7 @@ var ts; if (symbolFromSymbolTable === symbol) { return true; } - symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -23801,10 +24762,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 148: - case 150: - case 152: + case 149: + case 151: case 153: + case 154: continue; default: return false; @@ -23852,15 +24813,12 @@ var ts; } return { accessibility: 0 }; function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } + var node = ts.findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 264 && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 265 && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -23894,11 +24852,11 @@ var ts; } function isEntityNameVisible(entityName, enclosingDeclaration) { var meaning; - if (entityName.parent.kind === 161 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 162 || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning = 107455 | 1048576; } - else if (entityName.kind === 142 || entityName.kind === 178 || - entityName.parent.kind === 236) { + else if (entityName.kind === 143 || entityName.kind === 179 || + entityName.parent.kind === 237) { meaning = 1920; } else { @@ -23946,6 +24904,483 @@ var ts; } return result; } + function createNodeBuilder() { + var context; + return { + typeToTypeNode: function (type, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = typeToTypeNodeHelper(type); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + } + }; + function createNodeBuilderContext(enclosingDeclaration, flags) { + return { + enclosingDeclaration: enclosingDeclaration, + flags: flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + function typeToTypeNodeHelper(type) { + if (!type) { + context.encounteredError = true; + return undefined; + } + if (type.flags & 1) { + return ts.createKeywordTypeNode(119); + } + if (type.flags & 2) { + return ts.createKeywordTypeNode(136); + } + if (type.flags & 4) { + return ts.createKeywordTypeNode(133); + } + if (type.flags & 8) { + return ts.createKeywordTypeNode(122); + } + if (type.flags & 16) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & (32)) { + return ts.createLiteralTypeNode((ts.createLiteral(type.text))); + } + if (type.flags & (64)) { + return ts.createLiteralTypeNode((ts.createNumericLiteral(type.text))); + } + if (type.flags & 128) { + return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); + } + if (type.flags & 256) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & 1024) { + return ts.createKeywordTypeNode(105); + } + if (type.flags & 2048) { + return ts.createKeywordTypeNode(139); + } + if (type.flags & 4096) { + return ts.createKeywordTypeNode(95); + } + if (type.flags & 8192) { + return ts.createKeywordTypeNode(130); + } + if (type.flags & 512) { + return ts.createKeywordTypeNode(137); + } + if (type.flags & 16777216) { + return ts.createKeywordTypeNode(134); + } + if (type.flags & 16384 && type.isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return ts.createThis(); + } + var objectFlags = getObjectFlags(type); + if (objectFlags & 4) { + ts.Debug.assert(!!(type.flags & 32768)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & 3) { + ts.Debug.assert(!!(type.flags & 32768)); + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (type.flags & 16384) { + var name = symbolToName(type.symbol, false); + return ts.createTypeReferenceNode(name, undefined); + } + if (context.checkAlias && type.aliasSymbol) { + var name = symbolToName(type.aliasSymbol, false); + var typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return ts.createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + if (type.flags & 65536) { + var formattedUnionTypes = formatUnionTypes(type.types); + var unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return ts.createUnionOrIntersectionTypeNode(166, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } + return undefined; + } + } + if (type.flags & 131072) { + return ts.createUnionOrIntersectionTypeNode(167, mapToTypeNodeArray(type.types)); + } + if (objectFlags & (16 | 32)) { + ts.Debug.assert(!!(type.flags & 32768)); + return createAnonymousTypeNode(type); + } + if (type.flags & 262144) { + var indexedType = type.type; + var indexTypeNode = typeToTypeNodeHelper(indexedType); + return ts.createTypeOperatorNode(indexTypeNode); + } + if (type.flags & 524288) { + var objectTypeNode = typeToTypeNodeHelper(type.objectType); + var indexTypeNode = typeToTypeNodeHelper(type.indexType); + return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + ts.Debug.fail("Should be unreachable."); + function mapToTypeNodeArray(types) { + var result = []; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type_1 = types_1[_i]; + var typeNode = typeToTypeNodeHelper(type_1); + if (typeNode) { + result.push(typeNode); + } + } + return result; + } + function createMappedTypeNodeFromType(type) { + ts.Debug.assert(!!(type.flags & 32768)); + var typeParameter = getTypeParameterFromMappedType(type); + var typeParameterNode = typeParameterToDeclaration(typeParameter); + var templateType = getTemplateTypeFromMappedType(type); + var templateTypeNode = typeToTypeNodeHelper(templateType); + var readonlyToken = type.declaration && type.declaration.readonlyToken ? ts.createToken(131) : undefined; + var questionToken = type.declaration && type.declaration.questionToken ? ts.createToken(55) : undefined; + return ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + function createAnonymousTypeNode(type) { + var symbol = type.symbol; + if (symbol) { + if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 | 512) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromSymbol(symbol); + } + else if (ts.contains(context.symbolStack, symbol)) { + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + var entityName = symbolToName(typeAlias, false); + return ts.createTypeReferenceNode(entityName, undefined); + } + else { + return ts.createKeywordTypeNode(119); + } + } + else { + if (!context.symbolStack) { + context.symbolStack = []; + } + context.symbolStack.push(symbol); + var result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + return createTypeNodeFromObjectType(type); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 && + ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 265 || declaration.parent.kind === 234; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + return ts.contains(context.symbolStack, symbol); + } + } + } + function createTypeNodeFromObjectType(type) { + if (type.objectFlags & 32) { + if (getConstraintTypeFromMappedType(type).flags & (16384 | 262144)) { + return createMappedTypeNodeFromType(type); + } + } + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return ts.createTypeLiteralNode(undefined); + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + var signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 160); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + var signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 161); + } + } + var saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + var members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return ts.createTypeLiteralNode(members); + } + function createTypeQueryNodeFromSymbol(symbol) { + var entityName = symbolToName(symbol, false); + return ts.createTypeQueryNode(entityName); + } + function typeReferenceToTypeNode(type) { + var typeArguments = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + var elementType = typeToTypeNodeHelper(typeArguments[0]); + return ts.createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & 8) { + if (typeArguments.length > 0) { + var tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return ts.createTupleTypeNode(tupleConstituentNodes); + } + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; + } + return undefined; + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + var qualifiedName = undefined; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + var start = i; + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { + var qualifiedNamePart = symbolToName(parent, true); + if (!qualifiedName) { + qualifiedName = ts.createQualifiedName(qualifiedNamePart, undefined); + } + else { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = ts.createQualifiedName(qualifiedName, undefined); + } + } + } + } + var entityName = undefined; + var nameIdentifier = symbolToName(type.symbol, true); + if (qualifiedName) { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + var typeArgumentNodes = ts.some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return ts.createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + function createTypeNodesFromResolvedType(resolvedType) { + var typeElements = []; + for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 155)); + } + for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 156)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1)); + } + var properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + for (var _d = 0, properties_2 = properties; _d < properties_2.length; _d++) { + var propertySymbol = properties_2[_d]; + var propertyType = getTypeOfSymbol(propertySymbol); + var oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0]; + if (!oldDeclaration) { + return; + } + var propertyName = oldDeclaration.name; + var optionalToken = propertySymbol.flags & 67108864 ? ts.createToken(55) : undefined; + if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length) { + var signatures = getSignaturesOfType(propertyType, 0); + for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { + var signature = signatures_1[_e]; + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 150); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : ts.createKeywordTypeNode(119); + typeElements.push(ts.createPropertySignature(propertyName, optionalToken, propertyTypeNode, undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind) { + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 ? 136 : 133); + var name = ts.getNameFromIndexInfo(indexInfo); + var indexingParameter = ts.createParameter(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined); + var typeNode = typeToTypeNodeHelper(indexInfo.type); + return ts.createIndexSignatureDeclaration(undefined, indexInfo.isReadonly ? [ts.createToken(131)] : undefined, [indexingParameter], typeNode); + } + function signatureToSignatureDeclarationHelper(signature, kind) { + var typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter); }); + var returnTypeNode; + if (signature.typePredicate) { + var typePredicate = signature.typePredicate; + var parameterName = typePredicate.kind === 1 ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(); + var typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + } + else { + var returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } + var returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== 119 ? returnTypeNode : undefined; + return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + } + function typeParameterToDeclaration(type) { + var constraint = getConstraintFromTypeParameter(type); + var constraintNode = constraint && typeToTypeNodeHelper(constraint); + var defaultParameter = getDefaultFromTypeParameter(type); + var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + var name = symbolToName(type.symbol, true); + return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); + } + function symbolToParameterDeclaration(parameterSymbol) { + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 146); + var parameterType = getTypeOfSymbol(parameterSymbol); + var parameterTypeNode = typeToTypeNodeHelper(parameterType); + var parameterNode = ts.createParameter(parameterDeclaration.decorators, parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && ts.createToken(24), ts.getSynthesizedClone(parameterDeclaration.name), parameterDeclaration.questionToken && ts.createToken(55), parameterTypeNode, parameterDeclaration.initializer); + return parameterNode; + } + function symbolToName(symbol, expectsIdentifier) { + var chain; + var isTypeParameter = symbol.flags & 262144; + if (!isTypeParameter && context.enclosingDeclaration) { + chain = getSymbolChain(symbol, 0, true); + ts.Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & ts.NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); + function createEntityNameFromSymbolChain(chain, index) { + ts.Debug.assert(chain && 0 <= index && index < chain.length); + var symbol = chain[index]; + var typeParameterString = ""; + if (index > 0) { + var parentSymbol = chain[index - 1]; + var typeParameters = void 0; + if (getCheckFlags(symbol) & 1) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + var targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (32 | 64 | 524288)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if (typeParameters && typeParameters.length > 0) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } + var writer = ts.getSingleLineStringWriter(); + var displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); + typeParameterString = writer.string(); + ts.releaseStringWriter(writer); + } + } + var symbolName = getNameOfSymbol(symbol); + var symbolNameWithTypeParameters = typeParameterString.length > 0 ? symbolName + "<" + typeParameterString + ">" : symbolName; + var identifier = ts.createIdentifier(symbolNameWithTypeParameters); + return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + function getSymbolChain(symbol, meaning, endOfChain) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, false); + var parentSymbol; + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false); + if (parentChain) { + parentSymbol = parent; + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + if (endOfChain || + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + !(symbol.flags & (2048 | 4096))) { + return [symbol]; + } + } + function getNameOfSymbol(symbol) { + var declaration = ts.firstOrUndefined(symbol.declarations); + if (declaration) { + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === 226) { + return ts.declarationNameToString(declaration.parent.name); + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case 199: + return "(Anonymous class)"; + case 186: + case 187: + return "(Anonymous function)"; + } + } + return symbol.name; + } + } + } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -23989,11 +25424,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 167) { - node = node.parent; - } - if (node.kind === 230) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 168; }); + if (node.kind === 231) { return getSymbolOfNode(node); } } @@ -24001,7 +25433,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 233 && + node.parent.kind === 234 && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -24013,11 +25445,14 @@ var ts; if (declaration.name) { return ts.declarationNameToString(declaration.name); } + if (declaration.parent && declaration.parent.kind === 226) { + return ts.declarationNameToString(declaration.parent.name); + } switch (declaration.kind) { - case 198: + case 199: return "(Anonymous class)"; - case 185: case 186: + case 187: return "(Anonymous function)"; } } @@ -24032,17 +25467,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 20); + writePunctuation(writer, 21); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 21); + writePunctuation(writer, 22); } else { - writePunctuation(writer, 22); + writePunctuation(writer, 23); writer.writeSymbol(symbolName, symbol); } } @@ -24118,7 +25553,7 @@ var ts; } else if (type.flags & 256) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064, 0, nextFlags); - writePunctuation(writer, 22); + writePunctuation(writer, 23); appendSymbolNameOnly(type.symbol, writer); } else if (getObjectFlags(type) & 3 || type.flags & (16 | 16384)) { @@ -24145,28 +25580,28 @@ var ts; } else if (type.flags & 524288) { writeType(type.objectType, 64); - writePunctuation(writer, 20); - writeType(type.indexType, 0); writePunctuation(writer, 21); + writeType(type.indexType, 0); + writePunctuation(writer, 22); } else { - writePunctuation(writer, 16); - writeSpace(writer); - writePunctuation(writer, 23); - writeSpace(writer); writePunctuation(writer, 17); + writeSpace(writer); + writePunctuation(writer, 24); + writeSpace(writer); + writePunctuation(writer, 18); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 25) { + if (delimiter !== 26) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 25 ? 0 : 64); + writeType(types[i], delimiter === 26 ? 0 : 64); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -24174,44 +25609,44 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064, 0, flags); } if (pos < end) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); writeType(typeArguments[pos], 256); pos++; while (pos < end) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); writeType(typeArguments[pos], 0); pos++; } - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1)) { writeType(typeArguments[0], 64); - writePunctuation(writer, 20); writePunctuation(writer, 21); + writePunctuation(writer, 22); } else if (type.target.objectFlags & 8) { - writePunctuation(writer, 20); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25); writePunctuation(writer, 21); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 26); + writePunctuation(writer, 22); } else { var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) { writeSymbolTypeReference(parent, typeArguments, start, i, flags); - writePunctuation(writer, 22); + writePunctuation(writer, 23); } } } @@ -24221,16 +25656,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } if (type.flags & 65536) { - writeTypeList(formatUnionTypes(type.types), 48); + writeTypeList(formatUnionTypes(type.types), 49); } else { - writeTypeList(type.types, 47); + writeTypeList(type.types, 48); } if (flags & 64) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } } function writeAnonymousType(type, flags) { @@ -24249,7 +25684,7 @@ var ts; buildSymbolDisplay(typeAlias, writer, enclosingDeclaration, 793064, 0, flags); } else { - writeKeyword(writer, 118); + writeKeyword(writer, 119); } } else { @@ -24270,7 +25705,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 264 || declaration.parent.kind === 233; + return declaration.parent.kind === 265 || declaration.parent.kind === 234; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { return !!(flags & 2) || @@ -24279,18 +25714,18 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 102); + writeKeyword(writer, 103); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455, 0, typeFormatFlags); } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 67108864) { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -24314,55 +25749,55 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 16); writePunctuation(writer, 17); + writePunctuation(writer, 18); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); } - writeKeyword(writer, 93); + writeKeyword(writer, 94); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8, undefined, symbolStack); if (flags & 64) { - writePunctuation(writer, 19); + writePunctuation(writer, 20); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 16); + writePunctuation(writer, 17); writer.writeLine(); writer.increaseIndent(); writeObjectLiteralType(resolved); writer.decreaseIndent(); - writePunctuation(writer, 17); + writePunctuation(writer, 18); inObjectTypeLiteral = saveInObjectTypeLiteral; } function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0, enclosingDeclaration, globalFlags, symbolStack); @@ -24372,49 +25807,49 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 | 8192) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0); - for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { - var signature = signatures_1[_f]; + for (var _f = 0, signatures_2 = signatures; _f < signatures_2.length; _f++) { + var signature = signatures_2[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, undefined, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); writeType(t, 0); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } } function writeMappedType(type) { - writePunctuation(writer, 16); + writePunctuation(writer, 17); writer.writeLine(); writer.increaseIndent(); if (type.declaration.readonlyToken) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); writeSpace(writer); - writeKeyword(writer, 91); + writeKeyword(writer, 92); writeSpace(writer); writeType(getConstraintTypeFromMappedType(type), 0); - writePunctuation(writer, 21); + writePunctuation(writer, 22); if (type.declaration.questionToken) { - writePunctuation(writer, 54); + writePunctuation(writer, 55); } - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); writeType(getTemplateTypeFromMappedType(type), 0); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); writer.decreaseIndent(); - writePunctuation(writer, 17); + writePunctuation(writer, 18); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -24428,64 +25863,64 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 84); + writeKeyword(writer, 85); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } var defaultType = getDefaultFromTypeParameter(tp); if (defaultType) { writeSpace(writer); - writePunctuation(writer, 57); + writePunctuation(writer, 58); writeSpace(writer); buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 23); + if (parameterNode ? ts.isRestParameter(parameterNode) : isTransientSymbol(p) && p.isRestParameter) { + writePunctuation(writer, 24); } - if (ts.isBindingPattern(parameterNode.name)) { + if (parameterNode && ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); } else { appendSymbolNameOnly(p, writer); } - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 54); + if (parameterNode && isOptionalParameter(parameterNode)) { + writePunctuation(writer, 55); } - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); var type = getTypeOfSymbol(p); - if (isRequiredInitializedParameter(parameterNode)) { + if (parameterNode && isRequiredInitializedParameter(parameterNode)) { type = includeFalsyTypes(type, 2048); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { - if (bindingPattern.kind === 173) { - writePunctuation(writer, 16); - buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + if (bindingPattern.kind === 174) { writePunctuation(writer, 17); + buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); + writePunctuation(writer, 18); } - else if (bindingPattern.kind === 174) { - writePunctuation(writer, 20); + else if (bindingPattern.kind === 175) { + writePunctuation(writer, 21); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); } - writePunctuation(writer, 21); + writePunctuation(writer, 22); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 175); + ts.Debug.assert(bindingElement.kind === 176); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -24493,22 +25928,22 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 23); + writePunctuation(writer, 24); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); } action(list[i]); @@ -24516,42 +25951,42 @@ var ts; } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26); + writePunctuation(writer, 27); var flags = 256; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); flags = 0; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 28); + writePunctuation(writer, 29); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 18); + writePunctuation(writer, 19); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 25); + writePunctuation(writer, 26); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 19); + writePunctuation(writer, 20); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 98); + writeKeyword(writer, 99); } writeSpace(writer); - writeKeyword(writer, 125); + writeKeyword(writer, 126); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } @@ -24562,10 +25997,10 @@ var ts; } if (flags & 8) { writeSpace(writer); - writePunctuation(writer, 35); + writePunctuation(writer, 36); } else { - writePunctuation(writer, 55); + writePunctuation(writer, 56); } writeSpace(writer); if (signature.typePredicate) { @@ -24577,7 +26012,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1) { - writeKeyword(writer, 93); + writeKeyword(writer, 94); writeSpace(writer); } if (signature.target && (flags & 32)) { @@ -24592,26 +26027,26 @@ var ts; function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 130); + writeKeyword(writer, 131); writeSpace(writer); } - writePunctuation(writer, 20); + writePunctuation(writer, 21); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55); + writePunctuation(writer, 56); writeSpace(writer); switch (kind) { case 1: - writeKeyword(writer, 132); + writeKeyword(writer, 133); break; case 0: - writeKeyword(writer, 135); + writeKeyword(writer, 136); break; } - writePunctuation(writer, 21); - writePunctuation(writer, 55); + writePunctuation(writer, 22); + writePunctuation(writer, 56); writeSpace(writer); buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); - writePunctuation(writer, 24); + writePunctuation(writer, 25); writer.writeLine(); } } @@ -24640,64 +26075,64 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 175: + case 176: return isDeclarationVisible(node.parent.parent); - case 225: + case 226: if (ts.isBindingPattern(node.name) && !node.name.elements.length) { return false; } - case 232: - case 228: + case 233: case 229: case 230: - case 227: case 231: - case 236: + case 228: + case 232: + case 237: if (ts.isExternalModuleAugmentation(node)) { return true; } var parent = getDeclarationContainer(node); if (!(ts.getCombinedModifierFlags(node) & 1) && - !(node.kind !== 236 && parent.kind !== 264 && ts.isInAmbientContext(parent))) { + !(node.kind !== 237 && parent.kind !== 265 && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent); } return isDeclarationVisible(parent); - case 148: - case 147: - case 152: - case 153: - case 150: case 149: + case 148: + case 153: + case 154: + case 151: + case 150: if (ts.getModifierFlags(node) & (8 | 16)) { return false; } - case 151: - case 155: - case 154: + case 152: case 156: - case 145: - case 233: - case 159: + case 155: + case 157: + case 146: + case 234: case 160: - case 162: - case 158: + case 161: case 163: + case 159: case 164: case 165: case 166: case 167: + case 168: return isDeclarationVisible(node.parent); - case 238: case 239: - case 241: - return false; - case 144: - case 264: - case 235: - return true; + case 240: case 242: return false; + case 145: + case 265: + case 236: + return true; + case 243: + return false; default: return false; } @@ -24705,10 +26140,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 242) { + if (node.parent && node.parent.kind === 243) { exportSymbol = resolveName(node.parent, node.text, 107455 | 793064 | 1920 | 8388608, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 245) { + else if (node.parent.kind === 246) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -24740,8 +26175,8 @@ var ts; function pushTypeResolution(target, propertyName) { var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -24783,21 +26218,20 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - while (node) { + node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 225: case 226: + case 227: + case 242: case 241: case 240: case 239: - case 238: - node = node.parent; - break; + return false; default: - return node.parent; + return true; } - } + }); + return node && node.parent; } function getTypeOfPrototypeProperty(prototype) { var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype)); @@ -24815,7 +26249,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false); } function isComputedNonLiteralName(name) { - return name.kind === 143 && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 144 && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144); }); @@ -24827,8 +26261,8 @@ var ts; } var members = ts.createMap(); var names = ts.createMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var name = properties_3[_i]; names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { @@ -24857,7 +26291,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 173) { + if (pattern.kind === 174) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -24891,7 +26325,7 @@ var ts; } } else { - var elementType = checkIteratedTypeOrElementType(parentType, pattern, false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, false, false); if (declaration.dotDotDotToken) { type = createArrayType(elementType); } @@ -24927,23 +26361,15 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 94 || expr.kind === 70 && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 95 || expr.kind === 71 && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 176 && expr.elements.length === 0; + return expr.kind === 177 && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048) : type; } - function removeOptionalityFromAnnotation(annotatedType, declaration) { - var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 145 && - declaration.initializer && - getFalsyFlags(annotatedType) & 2048 && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536) { var type = getTypeForDeclarationFromJSDocComment(declaration); @@ -24951,22 +26377,23 @@ var ts; return type; } } - if (declaration.parent.parent.kind === 214) { + if (declaration.parent.parent.kind === 215) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 | 262144) ? indexType : stringType; } - if (declaration.parent.parent.kind === 215) { - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + if (declaration.parent.parent.kind === 216) { + var forOfStatement = declaration.parent.parent; + return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } if (declaration.type) { - var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + var declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 65536) && - declaration.kind === 225 && !ts.isBindingPattern(declaration.name) && + if ((noImplicitAny || declaration.flags & 65536) && + declaration.kind === 226 && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1) && !ts.isInAmbientContext(declaration)) { if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; @@ -24975,10 +26402,10 @@ var ts; return autoArrayType; } } - if (declaration.kind === 145) { + if (declaration.kind === 146) { var func = declaration.parent; - if (func.kind === 153 && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152); + if (func.kind === 154 && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 153); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -25007,7 +26434,7 @@ var ts; if (ts.isJsxAttribute(declaration)) { return trueType; } - if (declaration.kind === 261) { + if (declaration.kind === 262) { return checkIdentifier(declaration.name); } if (ts.isBindingPattern(declaration.name)) { @@ -25015,20 +26442,36 @@ var ts; } return undefined; } - function getTypeForJSSpecialPropertyDeclaration(declaration) { - var expression = declaration.kind === 193 ? declaration : - declaration.kind === 178 ? ts.getAncestor(declaration, 193) : - undefined; - if (!expression) { - return unknownType; - } - if (expression.flags & 65536) { - var type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol) { + var types = []; + var definedInConstructor = false; + var definedInMethod = false; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = declaration.kind === 194 ? declaration : + declaration.kind === 179 ? ts.getAncestor(declaration, 194) : + undefined; + if (!expression) { + return unknownType; } + if (ts.isPropertyAccessExpression(expression.left) && expression.left.expression.kind === 99) { + if (ts.getThisContainer(expression, false).kind === 152) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (expression.flags & 65536) { + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, true), definedInMethod && !definedInConstructor)); } function getTypeFromBindingElement(element, includePatternInType, reportErrors) { if (element.initializer) { @@ -25037,7 +26480,7 @@ var ts; if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -25087,7 +26530,7 @@ var ts; return result; } function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) { - return pattern.kind === 173 + return pattern.kind === 174 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -25097,13 +26540,13 @@ var ts; if (reportErrors) { reportErrorsFromWidening(declaration, type); } - if (declaration.kind === 260) { + if (declaration.kind === 261) { return type; } return getWidenedType(type); } type = declaration.dotDotDotToken ? anyArrayType : anyType; - if (reportErrors && compilerOptions.noImplicitAny) { + if (reportErrors && noImplicitAny) { if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } @@ -25112,7 +26555,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 145 ? root.parent : root; + var memberDeclaration = root.kind === 146 ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -25125,19 +26568,19 @@ var ts; if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) { return links.type = anyType; } - if (declaration.kind === 242) { + if (declaration.kind === 243) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 && declaration.kind === 290 && declaration.typeExpression) { + if (declaration.flags & 65536 && declaration.kind === 291 && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } if (!pushTypeResolution(symbol, 0)) { return unknownType; } var type = void 0; - if (declaration.kind === 193 || - declaration.kind === 178 && declaration.parent.kind === 193) { - type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), true)); + if (declaration.kind === 194 || + declaration.kind === 179 && declaration.parent.kind === 194) { + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, true); @@ -25151,7 +26594,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 152) { + if (accessor.kind === 153) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -25171,8 +26614,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 152); - var setter = ts.getDeclarationOfKind(symbol, 153); + var getter = ts.getDeclarationOfKind(symbol, 153); + var setter = ts.getDeclarationOfKind(symbol, 154); if (getter && getter.flags & 65536) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -25197,7 +26640,7 @@ var ts; type = getReturnTypeFromBody(getter); } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { if (setter) { error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } @@ -25212,8 +26655,8 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 152); + if (noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 153); 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)); } } @@ -25264,14 +26707,22 @@ var ts; function getTypeOfInstantiatedSymbol(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0)) { - return unknownType; + if (symbolInstantiationDepth === 100) { + error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); + links.type = unknownType; } - var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - if (!popTypeResolution()) { - type = reportCircularityError(symbol); + else { + if (!pushTypeResolution(symbol, 0)) { + return unknownType; + } + symbolInstantiationDepth++; + var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + symbolInstantiationDepth--; + if (!popTypeResolution()) { + type = reportCircularityError(symbol); + } + links.type = type; } - links.type = type; } return links.type; } @@ -25280,7 +26731,7 @@ var ts; error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol)); return unknownType; } - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -25306,6 +26757,12 @@ var ts; } return unknownType; } + function isReferenceToType(type, target) { + return type !== undefined + && target !== undefined + && (getObjectFlags(type) & 4) !== 0 + && type.target === target; + } function getTargetType(type) { return getObjectFlags(type) & 4 ? type.target : type; } @@ -25340,9 +26797,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 228 || node.kind === 198 || - node.kind === 227 || node.kind === 185 || - node.kind === 150 || node.kind === 186) { + if (node.kind === 229 || node.kind === 199 || + node.kind === 228 || node.kind === 186 || + node.kind === 151 || node.kind === 187) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -25351,15 +26808,15 @@ var ts; } } function getOuterTypeParametersOfClassOrInterface(symbol) { - var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 229); + var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230); 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 === 229 || node.kind === 228 || - node.kind === 198 || node.kind === 230) { + if (node.kind === 230 || node.kind === 229 || + node.kind === 199 || node.kind === 231) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -25385,19 +26842,20 @@ var ts; } if (type.flags & 540672) { var constraint = getBaseConstraintOfType(type); - return isValidBaseType(constraint) && isMixinConstructorType(constraint); + return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { + function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); - return ts.filter(getSignaturesOfType(type, 1), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); + var isJavaScript = ts.isInJavaScriptFile(location); + return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); @@ -25421,7 +26879,7 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = unknownType; } - if (baseConstructorType !== unknownType && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); return type.resolvedBaseConstructorType = unknownType; } @@ -25451,7 +26909,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (32768 | 131072))) { + if (!(baseConstructorType.flags & (32768 | 131072 | 1))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -25461,8 +26919,11 @@ var ts; areAllOuterTypeParametersApplied(originalBaseType)) { baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } + else if (baseConstructorType.flags & 1) { + baseType = baseConstructorType; + } else { - var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -25504,14 +26965,14 @@ var ts; return true; } function isValidBaseType(type) { - return type.flags & (32768 | 16777216) && !isGenericMappedType(type) || + return type.flags & (32768 | 16777216 | 1) && !isGenericMappedType(type) || type.flags & 131072 && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 230 && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -25540,7 +27001,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229) { + if (declaration.kind === 230) { if (declaration.flags & 64) { return false; } @@ -25590,7 +27051,7 @@ var ts; if (!pushTypeResolution(symbol, 2)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 289); + var declaration = ts.getDeclarationOfKind(symbol, 290); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -25601,7 +27062,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 230); + declaration = ts.getDeclarationOfKind(symbol, 231); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -25626,14 +27087,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 || - expr.kind === 191 && expr.operator === 37 && + expr.kind === 192 && expr.operator === 38 && expr.operand.kind === 8 || - expr.kind === 70 && !!symbol.exports.get(expr.text); + expr.kind === 71 && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231) { + if (declaration.kind === 232) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -25661,7 +27122,7 @@ var ts; var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231) { + if (declaration.kind === 232) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -25744,21 +27205,21 @@ var ts; } function isIndependentType(node) { switch (node.kind) { - case 118: - case 135: - case 132: - case 121: + case 119: case 136: case 133: - case 104: - case 138: - case 94: - case 129: - case 172: + case 122: + case 137: + case 134: + case 105: + case 139: + case 95: + case 130: + case 173: return true; - case 163: + case 164: return isIndependentType(node.elementType); - case 158: + case 159: return isIndependentTypeReference(node); } return false; @@ -25767,7 +27228,7 @@ var ts; return node.type && isIndependentType(node.type) || !node.type && !node.initializer; } function isIndependentFunctionLikeDeclaration(node) { - if (node.kind !== 151 && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 152 && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -25783,12 +27244,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 148: - case 147: - return isIndependentVariableLikeDeclaration(declaration); - case 150: case 149: + case 148: + return isIndependentVariableLikeDeclaration(declaration); case 151: + case 150: + case 152: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -25878,7 +27339,11 @@ var ts; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1)); - stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0); + if (!stringIndexInfo) { + stringIndexInfo = instantiatedBaseType === anyType ? + createIndexInfo(anyType, false) : + getIndexInfoOfType(instantiatedBaseType, 0); + } numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1); } } @@ -25917,6 +27382,7 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, undefined, 0, false, false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); + var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = ts.length(typeArguments); var result = []; @@ -25924,8 +27390,8 @@ var ts; var baseSig = baseSignatures_1[_i]; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -25994,8 +27460,8 @@ var ts; 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]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type = types_2[_i]; var indexInfo = getIndexInfoOfType(type, kind); if (!indexInfo) { return undefined; @@ -26083,7 +27549,8 @@ var ts; else { var members = emptySymbols; var constructSignatures = emptyArray; - if (symbol.flags & 1952) { + var stringIndexInfo = undefined; + if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32) { @@ -26097,9 +27564,12 @@ var ts; members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } + else if (baseConstructorType === anyType) { + stringIndexInfo = createIndexInfo(anyType, false); + } } var numberIndexInfo = symbol.flags & 384 ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, stringIndexInfo, numberIndexInfo); if (symbol.flags & (16 | 8192)) { type.callSignatures = getSignaturesOfSymbol(symbol); } @@ -26115,7 +27585,7 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 169) { + if (type.declaration.typeParameter.constraint.kind === 170) { for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var propertySymbol = _a[_i]; addMemberForKeyType(getLiteralTypeFromPropertyName(propertySymbol), propertySymbol); @@ -26139,10 +27609,10 @@ var ts; var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864); var prop = createSymbol(4 | (isOptional ? 67108864 : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 : 0; + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 8 : 0; prop.type = propType; if (propertySymbol) { - prop.mappedTypeOrigin = propertySymbol; + prop.syntheticOrigin = propertySymbol; } members.set(propName, prop); } @@ -26168,7 +27638,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 169) { + if (constraintDeclaration.kind === 170) { type.modifiersType = instantiateType(getTypeFromTypeNode(constraintDeclaration.type), type.mapper || identityMapper); } else { @@ -26256,14 +27726,29 @@ var ts; getPropertiesOfObjectType(type); } function getConstraintOfType(type) { - return type.flags & 16384 ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + return type.flags & 16384 ? getConstraintOfTypeParameter(type) : + type.flags & 524288 ? getConstraintOfIndexedAccess(type) : + getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } + function getConstraintOfIndexedAccess(type) { + var baseObjectType = getBaseConstraintOfType(type.objectType); + var baseIndexType = getBaseConstraintOfType(type.indexType); + return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; + } function getBaseConstraintOfType(type) { - var constraint = getResolvedBaseConstraint(type); - return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + if (type.flags & (540672 | 196608)) { + var constraint = getResolvedBaseConstraint(type); + if (constraint !== noConstraintType && constraint !== circularConstraintType) { + return constraint; + } + } + else if (type.flags & 262144) { + return stringType; + } + return undefined; } function hasNonCircularBaseConstraint(type) { return getResolvedBaseConstraint(type) !== circularConstraintType; @@ -26296,9 +27781,9 @@ var ts; if (t.flags & 196608) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_1 = types_2[_i]; - var baseType = getBaseConstraint(type_1); + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; + var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); } @@ -26341,7 +27826,7 @@ var ts; t.flags & 262178 ? globalStringType : t.flags & 340 ? globalNumberType : t.flags & 136 ? globalBooleanType : - t.flags & 512 ? getGlobalESSymbolType() : + t.flags & 512 ? getGlobalESSymbolType(languageVersion >= 2) : t.flags & 16777216 ? emptyObjectType : t; } @@ -26351,9 +27836,10 @@ var ts; var isUnion = containingType.flags & 65536; var excludeModifiers = isUnion ? 24 : 0; var commonFlags = isUnion ? 0 : 67108864; - var checkFlags = 2; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + var syntheticFlag = 4; + var checkFlags = 0; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); @@ -26366,21 +27852,24 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - checkFlags |= (isReadonlySymbol(prop) ? 4 : 0) | - (!(modifiers & 24) ? 32 : 0) | - (modifiers & 16 ? 64 : 0) | - (modifiers & 8 ? 128 : 0) | - (modifiers & 32 ? 256 : 0); + checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) | + (!(modifiers & 24) ? 64 : 0) | + (modifiers & 16 ? 128 : 0) | + (modifiers & 8 ? 256 : 0) | + (modifiers & 32 ? 512 : 0); + if (!isMethodLike(prop)) { + syntheticFlag = 2; + } } else if (isUnion) { - checkFlags |= 8; + checkFlags |= 16; } } } if (!props) { return undefined; } - if (props.length === 1 && !(checkFlags & 8)) { + if (props.length === 1 && !(checkFlags & 16)) { return props[0]; } var propTypes = []; @@ -26396,12 +27885,12 @@ var ts; commonType = type; } else if (type !== commonType) { - checkFlags |= 16; + checkFlags |= 32; } propTypes.push(type); } var result = createSymbol(4 | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -26420,7 +27909,7 @@ var ts; } function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); - return property && !(getCheckFlags(property) & 8) ? property : undefined; + return property && !(getCheckFlags(property) & 16) ? property : undefined; } function getPropertyOfType(type, name) { type = getApparentType(type); @@ -26514,7 +28003,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536) { - if (node.type && node.type.kind === 277) { + if (node.type && node.type.kind === 278) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -26525,7 +28014,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 277; + return paramTag.typeExpression.type.kind === 278; } } } @@ -26558,7 +28047,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 70) { + if (node.parameterName.kind === 71) { var parameterName = node.parameterName; return { kind: 1, @@ -26585,21 +28074,22 @@ var ts; } return minTypeArgumentCount; } - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + var isJavaScript = ts.isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (var i = numTypeArguments; i < numTypeParameters; i++) { var mapper = createTypeMapper(typeParameters, typeArguments); var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -26630,7 +28120,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 172) { + if (param.type && param.type.kind === 173) { hasLiteralTypes = true; } var isOptionalParameter_1 = param.initializer || param.questionToken || param.dotDotDotToken || @@ -26641,23 +28131,23 @@ var ts; minArgumentCount = parameters.length; } } - if ((declaration.kind === 152 || declaration.kind === 153) && + if ((declaration.kind === 153 || declaration.kind === 154) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 152 ? 153 : 152; + var otherKind = declaration.kind === 153 ? 154 : 153; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 151 ? + var classType = declaration.kind === 152 ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 157 ? + var typePredicate = declaration.type && declaration.type.kind === 158 ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -26680,14 +28170,42 @@ var ts; return type; } } - if (declaration.kind === 152 && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 153); + if (declaration.kind === 153 && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 154); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { return anyType; } } + function containsArgumentsReference(declaration) { + var links = getNodeLinks(declaration); + if (links.containsArgumentsReference === undefined) { + if (links.flags & 8192) { + links.containsArgumentsReference = true; + } + else { + links.containsArgumentsReference = traverse(declaration.body); + } + } + return links.containsArgumentsReference; + function traverse(node) { + if (!node) + return false; + switch (node.kind) { + case 71: + return node.text === "arguments" && ts.isPartOfExpression(node); + case 149: + case 151: + case 153: + case 154: + return node.name.kind === 144 + && traverse(node.name); + default: + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + } + } + } function getSignaturesOfSymbol(symbol) { if (!symbol) return emptyArray; @@ -26695,20 +28213,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 159: case 160: - case 227: - case 150: - case 149: + case 161: + case 228: case 151: - case 154: + case 150: + case 152: case 155: case 156: - case 152: + case 157: case 153: - case 185: + case 154: case 186: - case 278: + case 187: + case 279: if (i > 0 && node.body) { var previous = symbol.declarations[i - 1]; if (node.parent === previous.parent && node.kind === previous.kind && node.pos === previous.end) { @@ -26752,7 +28270,7 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { var declaration = signature.declaration; if (declaration.name) { error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name)); @@ -26798,7 +28316,7 @@ var ts; } function getOrCreateTypeFromSignature(signature) { if (!signature.isolatedSignatureType) { - var isConstructor = signature.declaration.kind === 151 || signature.declaration.kind === 155; + var isConstructor = signature.declaration.kind === 152 || signature.declaration.kind === 156; var type = createObjectType(16); type.members = emptySymbols; type.properties = emptyArray; @@ -26812,7 +28330,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 ? 132 : 135; + var syntaxKind = kind === 1 ? 133 : 136; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -26839,7 +28357,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 144).constraint; + return ts.getDeclarationOfKind(type.symbol, 145).constraint; } function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { @@ -26855,17 +28373,17 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 145).parent); } function getTypeListId(types) { var result = ""; if (types) { - var length_3 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_3) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_3 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -26882,8 +28400,8 @@ var ts; } function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -26919,13 +28437,13 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, undefined, 1), minTypeArgumentCount, typeParameters.length); return unknownType; } - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -26975,11 +28493,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 158: + case 159: return node.typeName; - case 276: + case 277: return node.name; - case 200: + case 201: var expr = node.expression; if (ts.isEntityNameExpression(expr)) { return expr; @@ -27003,23 +28521,58 @@ var ts; if (symbol.flags & 524288) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 && node.kind === 276) { + if (symbol.flags & 107455 && node.kind === 277) { return getTypeOfSymbol(symbol); } return getTypeFromNonGenericTypeReference(node, symbol); } + function getPrimitiveTypeFromJSDocTypeReference(node) { + if (ts.isIdentifier(node.name)) { + switch (node.name.text) { + case "String": + return stringType; + case "Number": + return numberType; + case "Boolean": + return booleanType; + case "Void": + return voidType; + case "Undefined": + return undefinedType; + case "Null": + return nullType; + case "Object": + return anyType; + case "Function": + return anyFunctionType; + case "Array": + case "array": + return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + case "Promise": + case "promise": + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + } + } + } + function getTypeFromJSDocNullableTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getUnionType([type, nullType]) : type; + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 276) { - var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(typeReferenceName); - type = getTypeReferenceType(node, symbol); + if (node.kind === 277) { + type = getPrimitiveTypeFromJSDocTypeReference(node); + if (!type) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(typeReferenceName); + type = getTypeReferenceType(node, symbol); + } } else { - var typeNameOrExpression = node.kind === 158 + var typeNameOrExpression = node.kind === 159 ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -27048,9 +28601,9 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var declaration = declarations_4[_i]; switch (declaration.kind) { - case 228: case 229: - case 231: + case 230: + case 232: return declaration; } } @@ -27069,38 +28622,85 @@ var ts; } return type; } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455, ts.Diagnostics.Cannot_find_global_value_0); + function getGlobalValueSymbol(name, reportErrors) { + return getGlobalSymbol(name, 107455, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793064, ts.Diagnostics.Cannot_find_global_type_0); + function getGlobalTypeSymbol(name, reportErrors) { + return getGlobalSymbol(name, 793064, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name, arity) { + function getGlobalType(name, arity, reportErrors) { + var symbol = getGlobalTypeSymbol(name, reportErrors); + return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; + } + function getGlobalTypedPropertyDescriptorType() { + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType; + } + function getGlobalTemplateStringsArrayType() { + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType; + } + function getGlobalESSymbolConstructorSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); + } + function getGlobalESSymbolType(reportErrors) { + return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType; + } + function getGlobalPromiseType(reportErrors) { + return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType; + } + function getGlobalPromiseConstructorSymbol(reportErrors) { + return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); + } + function getGlobalPromiseConstructorLikeType(reportErrors) { + return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType; + } + function getGlobalAsyncIterableType(reportErrors) { + return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIteratorType(reportErrors) { + return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIterableIteratorType(reportErrors) { + return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableType(reportErrors) { + return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIteratorType(reportErrors) { + return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableIteratorType(reportErrors) { + return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType; + } + function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + var symbol = getGlobalSymbol(name, 793064, undefined); + return symbol && getTypeOfGlobalSymbol(symbol, arity); } function getExportedTypeFromNamespace(namespace, name) { var namespaceSymbol = getGlobalSymbol(namespace, 1920, undefined); var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793064); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableType(), [elementType]); + function createTypedPropertyDescriptorType(propertyType) { + return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); + function createAsyncIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(true), [iteratedType]); + } + function createAsyncIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(true), [iteratedType]); + } + function createIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]); + } + function createIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(true), [iteratedType]); } function createArrayType(elementType) { return createTypeFromGenericGlobalType(globalArrayType, [elementType]); @@ -27209,14 +28809,14 @@ var ts; } } function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -27224,8 +28824,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -27329,7 +28929,13 @@ var ts; else if (type.flags & 1) { typeSet.containsAny = true; } + else if (getObjectFlags(type) & 16 && isEmptyObjectType(type)) { + typeSet.containsEmptyObject = true; + } else if (!(type.flags & 8192) && (strictNullChecks || !(type.flags & 6144)) && !ts.contains(typeSet, type)) { + if (type.flags & 32768) { + typeSet.containsObjectType = true; + } if (type.flags & 65536 && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } @@ -27340,8 +28946,8 @@ var ts; } } function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -27354,6 +28960,9 @@ var ts; if (typeSet.containsAny) { return anyType; } + if (typeSet.containsEmptyObject && !typeSet.containsObjectType) { + typeSet.push(emptyObjectType); + } if (typeSet.length === 1) { return typeSet[0]; } @@ -27420,7 +29029,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; var propName = indexType.flags & (32 | 64 | 256) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ? @@ -27456,7 +29065,7 @@ var ts; return indexInfo.type; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, 1)) { error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } @@ -27468,7 +29077,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 179 ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 180 ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 | 64)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -27478,11 +29087,12 @@ var ts; else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } + return unknownType; } - return unknownType; + return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 179 ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; @@ -27493,7 +29103,7 @@ var ts; } function getIndexedAccessType(objectType, indexType, accessNode) { if (maybeTypeOfKind(indexType, 540672 | 262144) || - maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 179) || + maybeTypeOfKind(objectType, 540672) && !(accessNode && accessNode.kind === 180) || isGenericMappedType(objectType)) { if (objectType.flags & 1) { return objectType; @@ -27559,7 +29169,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 230 ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 231 ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -27605,7 +29215,7 @@ var ts; skippedPrivateMembers.set(rightProp.name, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.name, rightProp); + members.set(rightProp.name, getNonReadonlySymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -27622,7 +29232,6 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 | (leftProp.flags & 67108864); var result = createSymbol(flags, leftProp.name); - result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072)]); result.leftSpread = leftProp; result.rightSpread = rightProp; @@ -27631,11 +29240,22 @@ var ts; } } else { - members.set(leftProp.name, leftProp); + members.set(leftProp.name, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function getNonReadonlySymbol(prop) { + if (!isReadonlySymbol(prop)) { + return prop; + } + var flags = 4 | (prop.flags & 67108864); + var result = createSymbol(flags, prop.name); + result.type = getTypeOfSymbol(prop); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + return result; + } function isClassMethod(prop) { return prop.flags & 8192 && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); } @@ -27692,9 +29312,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 229)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 230)) { if (!(ts.getModifierFlags(container) & 32) && - (container.kind !== 151 || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 152 || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -27710,88 +29330,83 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 118: - case 267: + case 119: case 268: - return anyType; - case 135: - return stringType; - case 132: - return numberType; - case 121: - return booleanType; - case 136: - return esSymbolType; - case 104: - return voidType; - case 138: - return undefinedType; - case 94: - return nullType; - case 129: - return neverType; - case 133: - return nonPrimitiveType; - case 293: - return nullType; - case 294: - return undefinedType; - case 295: - return neverType; - case 168: - case 98: - return getTypeFromThisTypeNode(node); - case 172: - return getTypeFromLiteralTypeNode(node); - case 292: - return getTypeFromLiteralTypeNode(node.literal); - case 158: - case 276: - return getTypeFromTypeReference(node); - case 157: - return booleanType; - case 200: - return getTypeFromTypeReference(node); - case 161: - return getTypeFromTypeQueryNode(node); - case 163: case 269: - return getTypeFromArrayTypeNode(node); - case 164: - return getTypeFromTupleTypeNode(node); - case 165: - case 270: - return getTypeFromUnionTypeNode(node); - case 166: - return getTypeFromIntersectionTypeNode(node); - case 167: - case 272: - case 273: - case 280: - case 281: - case 277: - return getTypeFromTypeNode(node.type); - case 274: - return getTypeFromTypeNode(node.literal); - case 159: - case 160: - case 162: - case 291: - case 278: - return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); + return anyType; + case 136: + return stringType; + case 133: + return numberType; + case 122: + return booleanType; + case 137: + return esSymbolType; + case 105: + return voidType; + case 139: + return undefinedType; + case 95: + return nullType; + case 130: + return neverType; + case 134: + return nonPrimitiveType; case 169: - return getTypeFromTypeOperatorNode(node); + case 99: + return getTypeFromThisTypeNode(node); + case 173: + return getTypeFromLiteralTypeNode(node); + case 293: + return getTypeFromLiteralTypeNode(node.literal); + case 159: + case 277: + return getTypeFromTypeReference(node); + case 158: + return booleanType; + case 201: + return getTypeFromTypeReference(node); + case 162: + return getTypeFromTypeQueryNode(node); + case 164: + case 270: + return getTypeFromArrayTypeNode(node); + case 165: + return getTypeFromTupleTypeNode(node); + case 166: + case 271: + return getTypeFromUnionTypeNode(node); + case 167: + return getTypeFromIntersectionTypeNode(node); + case 273: + return getTypeFromJSDocNullableTypeNode(node); + case 168: + case 274: + case 281: + case 282: + case 278: + return getTypeFromTypeNode(node.type); + case 275: + return getTypeFromTypeNode(node.literal); + case 160: + case 161: + case 163: + case 292: + case 279: + return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); case 170: - return getTypeFromIndexedAccessTypeNode(node); + return getTypeFromTypeOperatorNode(node); case 171: + return getTypeFromIndexedAccessTypeNode(node); + case 172: return getTypeFromMappedTypeNode(node); - case 70: - case 142: + case 71: + case 143: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 271: + case 272: return getTypeFromJSDocTupleType(node); - case 279: + case 280: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -27980,26 +29595,28 @@ var ts; return false; } var mappedTypes = mapper.mappedTypes; - var node = symbol.declarations[0]; - while (node) { + return !!ts.findAncestor(symbol.declarations[0], function (node) { + if (node.kind === 233 || node.kind === 265) { + return "quit"; + } switch (node.kind) { - case 159: case 160: - case 227: - case 150: - case 149: + case 161: + case 228: case 151: - case 154: + case 150: + case 152: case 155: case 156: - case 152: + case 157: case 153: - case 185: + case 154: case 186: - case 228: - case 198: + case 187: case 229: + case 199: case 230: + case 231: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -28009,19 +29626,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 229) { + if (ts.isClassLike(node) || node.kind === 230) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 171: + case 172: if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { return true; } break; - case 278: + case 279: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -28030,18 +29647,13 @@ var ts; } } break; - case 232: - case 264: - return false; } - node = node.parent; - } - return false; + }); } function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 264 || parentKind === 233; + return parentKind === 265 || parentKind === 234; } return false; } @@ -28093,33 +29705,33 @@ var ts; return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration); } function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 185: case 186: + case 187: return isContextSensitiveFunctionLikeDeclaration(node); - case 177: + case 178: return ts.forEach(node.properties, isContextSensitive); - case 176: + case 177: return ts.forEach(node.elements, isContextSensitive); - case 194: + case 195: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 193: - return node.operatorToken.kind === 53 && + case 194: + return node.operatorToken.kind === 54 && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 260: + case 261: return isContextSensitive(node.initializer); + case 151: case 150: - case 149: return isContextSensitiveFunctionLikeDeclaration(node); - case 184: + case 185: return isContextSensitive(node.expression); - case 253: + case 254: return ts.forEach(node.properties, isContextSensitive); - case 252: + case 253: return node.initializer && isContextSensitive(node.initializer); - case 255: + case 256: return node.expression && isContextSensitive(node.expression); } return false; @@ -28131,7 +29743,7 @@ var ts; if (ts.forEach(node.parameters, function (p) { return !p.type; })) { return true; } - if (node.kind === 186) { + if (node.kind === 187) { return false; } var parameter = ts.firstOrUndefined(node.parameters); @@ -28191,9 +29803,9 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; + return compareSignaturesRelated(source, target, false, ignoreReturnTypes, false, undefined, compareTypesAssignable) !== 0; } - function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { if (source === target) { return -1; } @@ -28224,9 +29836,15 @@ var ts; var sourceParams = source.parameters; var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - var related = compareTypes(s, t, false) || compareTypes(t, s, reportErrors); + var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); + var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var sourceSig = getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = getSingleCallSignature(getNonNullableType(targetType)); + var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate && + (getFalsyFlags(sourceType) & 6144) === (getFalsyFlags(targetType) & 6144); + var related = callbacks ? + compareSignaturesRelated(targetSig, sourceSig, true, false, reportErrors, errorReporter, compareTypes) : + !checkAsCallback && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); @@ -28253,7 +29871,8 @@ var ts; } } else { - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, false) || + compareTypes(sourceReturnType, targetReturnType, reportErrors); } } return result; @@ -28316,6 +29935,19 @@ var ts; sourceNonRestParamCount; } } + function isEmptyResolvedType(t) { + return t.properties.length === 0 && + t.callSignatures.length === 0 && + t.constructSignatures.length === 0 && + !t.stringIndexInfo && + !t.numberIndexInfo; + } + function isEmptyObjectType(type) { + return type.flags & 32768 ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 65536 ? ts.forEach(type.types, isEmptyObjectType) : + type.flags & 131072 ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + false; + } function isEnumTypeRelatedTo(source, target, errorReporter) { if (source === target) { return true; @@ -28406,7 +30038,7 @@ var ts; } } if (source.flags & 1032192 || target.flags & 1032192) { - return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); + return checkTypeRelatedTo(source, target, relation, undefined); } return false; } @@ -28460,7 +30092,7 @@ var ts; if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType() === source && esSymbolType === target)) { + (getGlobalESSymbolType(false) === source && esSymbolType === target)) { reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -28519,102 +30151,24 @@ var ts; return result; } } - else if (target.flags & 65536) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { - return result; - } - } - else if (target.flags & 131072) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & 131072) { - if (result = someTypeRelatedToType(source, target, false)) { - return result; - } - } - else if (target.flags & 16384) { - if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!source.declaration.questionToken) { - var templateType = getTemplateTypeFromMappedType(source); - var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { - return result; - } - } - } - } - else if (target.flags & 262144) { - if (source.flags & 262144) { - if (result = isRelatedTo(target.type, source.type, false)) { - return result; - } - } - var constraint = getConstraintOfType(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } - } - } - else if (target.flags & 524288) { - if (source.flags & 524288 && source.indexType === target.indexType) { - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - return result; - } - } - var constraint = getBaseConstraintOfType(target); - if (constraint) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (source.flags & 16384) { - if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { - var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); - var templateType = getTemplateTypeFromMappedType(target); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - var constraint = getConstraintOfTypeParameter(source); - if (constraint || !(target.flags & 16777216)) { - if (!constraint || constraint.flags & 1) { - constraint = emptyObjectType; - } - constraint = getTypeWithThisArgument(constraint, source); - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - } - else if (source.flags & 524288) { - var constraint = getBaseConstraintOfType(source); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } else { - if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + if (target.flags & 65536) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190) && !(target.flags & 8190))) { return result; } } - var apparentSource = getApparentType(source); - if (apparentSource.flags & (32768 | 131072) && target.flags & 32768) { - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + else if (target.flags & 131072) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072) { + if (result = someTypeRelatedToType(source, target, false)) { + return result; + } + } + if (source.flags & 1032192 || target.flags & 1032192) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -28634,12 +30188,7 @@ var ts; function isIdenticalTo(source, target) { var result; if (source.flags & 32768 && target.flags & 32768) { - if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { - if (result = typeArgumentsRelatedTo(source, target, false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, false); + return recursiveTypeRelatedTo(source, target, false); } if (source.flags & 65536 && target.flags & 65536 || source.flags & 131072 && target.flags & 131072) { @@ -28654,14 +30203,8 @@ var ts; function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && - (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { - return true; - } - else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { - return true; - } - else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { return true; } } @@ -28675,25 +30218,19 @@ var ts; } return false; } - function isEmptyResolvedType(t) { - return t.properties.length === 0 && - t.callSignatures.length === 0 && - t.constructSignatures.length === 0 && - !t.stringIndexInfo && - !t.numberIndexInfo; - } - function isEmptyObjectType(type) { - return type.flags & 32768 && isEmptyResolvedType(resolveStructuredTypeMembers(type)); - } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768) && !(getObjectFlags(target) & 512)) { var isComparingJsxAttributes = !!(source.flags & 33554432); + if ((relation === assignableRelation || relation === comparableRelation) && + (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { + return false; + } for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { if (reportErrors) { ts.Debug.assert(!!errorNode); - if (ts.isJsxAttributes(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); } else { @@ -28813,7 +30350,7 @@ var ts; } return result; } - function objectTypeRelatedTo(source, originalSource, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0; } @@ -28850,32 +30387,11 @@ var ts; maybeStack[depth].set(id, 1); depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1; - } - else if (isGenericMappedType(source) || isGenericMappedType(target)) { - result = mappedTypeRelatedTo(source, target, reportErrors); - } - else { - result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 0, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 1, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 0, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 1, reportErrors); - } - } - } - } - } + var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -28888,6 +30404,118 @@ var ts; } return result; } + function structuredTypeRelatedTo(source, target, reportErrors) { + var result; + var saveErrorInfo = errorInfo; + if (target.flags & 16384) { + if (getObjectFlags(source) & 32 && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!source.declaration.questionToken) { + var templateType = getTemplateTypeFromMappedType(source); + var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + } + else if (target.flags & 262144) { + if (source.flags & 262144) { + if (result = isRelatedTo(target.type, source.type, false)) { + return result; + } + } + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } + else if (target.flags & 524288) { + var constraint = getConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (source.flags & 16384) { + if (getObjectFlags(target) & 32 && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + var templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + var constraint = getConstraintOfTypeParameter(source); + if (constraint || !(target.flags & 16777216)) { + if (!constraint || constraint.flags & 1) { + constraint = emptyObjectType; + } + constraint = getTypeWithThisArgument(constraint, source); + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + } + else if (source.flags & 524288) { + var constraint = getConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (target.flags & 524288 && source.indexType === target.indexType) { + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + return result; + } + } + } + else { + if (getObjectFlags(source) & 4 && getObjectFlags(target) & 4 && source.target === target.target) { + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + var sourceIsPrimitive = !!(source.flags & 8190); + if (relation !== identityRelation) { + source = getApparentType(source); + } + if (source.flags & (32768 | 131072) && target.flags & 32768) { + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportStructuralErrors); + } + else { + result = propertiesRelatedTo(source, target, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors); + } + } + } + } + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + return 0; + } function mappedTypeRelatedTo(source, target, reportErrors) { if (isGenericMappedType(target)) { if (isGenericMappedType(source)) { @@ -28925,8 +30553,8 @@ var ts; var result = -1; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -28941,7 +30569,7 @@ var ts; var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 || targetPropFlags & 8) { - if (getCheckFlags(sourceProp) & 128) { + if (getCheckFlags(sourceProp) & 256) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); } @@ -29059,7 +30687,7 @@ var ts; return result; } function signatureRelatedTo(source, target, reportErrors) { - return compareSignaturesRelated(source, target, false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, false, false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -29101,12 +30729,12 @@ var ts; } return related; } - function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors) { if (relation === identityRelation) { return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || ((targetInfo.type.flags & 1) && !(originalSource.flags & 8190))) { + if (!targetInfo || targetInfo.type.flags & 1 && !sourceIsPrimitive) { return -1; } var sourceInfo = getIndexInfoOfType(source, kind) || @@ -29165,7 +30793,7 @@ var ts; } } function forEachProperty(prop, callback) { - if (getCheckFlags(prop) & 2) { + if (getCheckFlags(prop) & 6) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.name); @@ -29207,16 +30835,18 @@ var ts; } return false; } - function isDeeplyNestedGeneric(type, stack, depth) { - if (getObjectFlags(type) & (4 | 64) && depth >= 5) { + function isDeeplyNestedType(type, stack, depth) { + if (depth >= 5 && type.flags & 32768) { var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (getObjectFlags(t) & (4 | 64) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; + if (symbol) { + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & 32768 && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } } } } @@ -29308,8 +30938,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -29317,8 +30947,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -29409,8 +31039,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -29473,7 +31103,6 @@ var ts; var updated = f(original); members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } - ; return members; } function getRegularTypeOfObjectLiteral(type) { @@ -29492,11 +31121,17 @@ var ts; type.regularType = regularNew; return regularNew; } + function getWidenedProperty(prop) { + var original = getTypeOfSymbol(prop); + var widened = getWidenedType(original); + return widened === original ? prop : createSymbolWithType(prop, widened); + } function getWidenedTypeOfObjectLiteral(type) { - var members = transformTypeOfMembers(type, function (prop) { - var widened = getWidenedType(prop); - return prop === widened ? prop : widened; - }); + var members = ts.createMap(); + for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + members.set(prop.name, prop.flags & 4 ? getWidenedProperty(prop) : prop); + } 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)); @@ -29557,25 +31192,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { + case 149: case 148: - case 147: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 145: + case 146: diagnostic = declaration.dotDotDotToken ? ts.Diagnostics.Rest_parameter_0_implicitly_has_an_any_type : ts.Diagnostics.Parameter_0_implicitly_has_an_1_type; break; - case 175: + case 176: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 227: + case 228: + case 151: case 150: - case 149: - case 152: case 153: - case 185: + case 154: case 186: + case 187: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -29588,7 +31223,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152) { + if (produceDiagnostics && noImplicitAny && type.flags & 2097152) { if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); } @@ -29614,13 +31249,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, inferUnionTypes) { + function createInferenceContext(signature, inferUnionTypes, useAnyForNoInferences) { var inferences = ts.map(signature.typeParameters, createTypeInferencesObject); return { signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences: useAnyForNoInferences }; } function createTypeInferencesObject() { @@ -29662,14 +31298,14 @@ var ts; var readonlyMask = target.declaration.readonlyToken ? false : true; var optionalMask = target.declaration.questionToken ? 0 : 67108864; var members = createSymbolTable(properties); - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var prop = properties_5[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (!inferredPropType) { return undefined; } var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.name); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 : 0; + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 8 : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; members.set(prop.name, inferredProp); @@ -29811,7 +31447,7 @@ var ts; if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } var key = source.id + "," + target.id; @@ -29859,8 +31495,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -29910,8 +31546,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -29957,7 +31593,7 @@ var ts; inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; } @@ -29991,29 +31627,17 @@ var ts; return links.resolvedSymbol; } function isInTypeQuery(node) { - while (node) { - switch (node.kind) { - case 161: - return true; - case 70: - case 142: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); + return !!ts.findAncestor(node, function (n) { return n.kind === 162 ? true : n.kind === 71 || n.kind === 143 ? false : "quit"; }); } function getFlowCacheKey(node) { - if (node.kind === 70) { + if (node.kind === 71) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 98) { + if (node.kind === 99) { return "0"; } - if (node.kind === 178) { + if (node.kind === 179) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -30021,31 +31645,33 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 70: - case 98: + case 71: + case 99: return node; - case 178: + case 179: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 70: - return target.kind === 70 && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 225 || target.kind === 175) && + case 71: + return target.kind === 71 && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 226 || target.kind === 176) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 98: - return target.kind === 98; - case 178: - return target.kind === 178 && + case 99: + return target.kind === 99; + case 97: + return target.kind === 97; + case 179: + return target.kind === 179 && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 178) { + while (source.kind === 179) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -30054,15 +31680,15 @@ var ts; return false; } function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 178 && + return target.kind === 179 && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 70) { + if (expr.kind === 71) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 178) { + if (expr.kind === 179) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -30073,7 +31699,7 @@ var ts; var prop = getUnionOrIntersectionProperty(type, name); if (prop && getCheckFlags(prop) & 2) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 16 && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 32 && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -30092,7 +31718,7 @@ var ts; } } } - if (callExpression.expression.kind === 178 && + if (callExpression.expression.kind === 179 && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -30131,8 +31757,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -30186,9 +31812,8 @@ var ts; if (flags & 16777216) { return strictNullChecks ? 6166480 : 8378320; } - if (flags & 16384) { - var constraint = getConstraintOfTypeParameter(type); - return getTypeFacts(constraint || emptyObjectType); + if (flags & 540672) { + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & 196608) { return getTypeFactsOfTypes(type.types); @@ -30214,22 +31839,22 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, undefined, false) || + checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, undefined, false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, undefined, false, false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 176 && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 260 && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 177 && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 261 && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 193 && parent.parent.left === parent || - parent.parent.kind === 215 && parent.parent.initializer === parent; + return parent.parent.kind === 194 && parent.parent.left === parent || + parent.parent.kind === 216 && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); @@ -30246,21 +31871,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 214: - return stringType; case 215: - return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 193: + return stringType; + case 216: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; + case 194: return getAssignedTypeOfBinaryExpression(parent); - case 187: + case 188: return undefinedType; - case 176: + case 177: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 197: + case 198: return getAssignedTypeOfSpreadExpression(parent); - case 260: - return getAssignedTypeOfPropertyAssignment(parent); case 261: + return getAssignedTypeOfPropertyAssignment(parent); + case 262: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -30268,7 +31893,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 173 ? + var type = pattern.kind === 174 ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -30283,39 +31908,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 214) { + if (node.parent.parent.kind === 215) { return stringType; } - if (node.parent.parent.kind === 215) { - return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; + if (node.parent.parent.kind === 216) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 225 ? + return node.kind === 226 ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 225 || node.kind === 175 ? + return node.kind === 226 || node.kind === 176 ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 225 && node.initializer && + return node.kind === 226 && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 175 && node.parent.kind === 193 && + node.kind !== 176 && node.parent.kind === 194 && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 184: + case 185: return getReferenceCandidate(node.expression); - case 193: + case 194: switch (node.operatorToken.kind) { - case 57: + case 58: return getReferenceCandidate(node.left); - case 25: + case 26: return getReferenceCandidate(node.right); } } @@ -30323,13 +31948,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 184 || - parent.kind === 193 && parent.operatorToken.kind === 57 && parent.left === node || - parent.kind === 193 && parent.operatorToken.kind === 25 && parent.right === node ? + return parent.kind === 185 || + parent.kind === 194 && parent.operatorToken.kind === 58 && parent.left === node || + parent.kind === 194 && parent.operatorToken.kind === 26 && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 256) { + if (clause.kind === 257) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -30375,8 +32000,29 @@ var ts; } return f(type) ? type : neverType; } - function mapType(type, f) { - return type.flags & 65536 ? getUnionType(ts.map(type.types, f)) : f(type); + function mapType(type, mapper) { + if (!(type.flags & 65536)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -30410,7 +32056,7 @@ var ts; return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType)); } function addEvolvingArrayElementType(evolvingArrayType, node) { - var elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node)); + var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { @@ -30431,8 +32077,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!(t.flags & 8192)) { if (!(getObjectFlags(t) & 256)) { return false; @@ -30450,12 +32096,12 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 178 && (parent.name.text === "length" || - parent.parent.kind === 180 && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 179 && + var isLengthPushOrUnshift = parent.kind === 179 && (parent.name.text === "length" || + parent.parent.kind === 181 && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 180 && parent.expression === root && - parent.parent.kind === 193 && - parent.parent.operatorToken.kind === 57 && + parent.parent.kind === 194 && + parent.parent.operatorToken.kind === 58 && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 340 | 2048); @@ -30469,7 +32115,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 96) { + if (node.expression.kind !== 97) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -30481,19 +32127,17 @@ var ts; } return false; } - function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { + function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { + if (initialType === void 0) { initialType = declaredType; } var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810431)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, 2048); var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; var resultType = getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 202 && getTypeWithFacts(resultType, 524288).flags & 8192) { + if (reference.parent.kind === 203 && getTypeWithFacts(resultType, 524288).flags & 8192) { return declaredType; } return resultType; @@ -30547,7 +32191,7 @@ var ts; } else if (flow.flags & 2) { var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 178) { + if (container && container !== flowContainer && reference.kind !== 179 && reference.kind !== 99) { flow = container.flowNode; continue; } @@ -30590,7 +32234,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 180 ? + var expr = node.kind === 181 ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -30598,7 +32242,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256) { var evolvedType_1 = type; - if (node.kind === 180) { + if (node.kind === 181) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -30722,7 +32366,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 178 && + return expr.kind === 179 && declaredType.flags & 65536 && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -30747,19 +32391,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 57: + case 58: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 31: case 32: case 33: case 34: + case 35: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 188 && right_1.kind === 9) { + if (left_1.kind === 189 && right_1.kind === 9) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 188 && left_1.kind === 9) { + if (right_1.kind === 189 && left_1.kind === 9) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -30778,9 +32422,9 @@ var ts; return declaredType; } break; - case 92: + case 93: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 25: + case 26: return narrowType(type, expr.right, assumeTrue); } return type; @@ -30789,7 +32433,7 @@ var ts; if (type.flags & 1) { return type; } - if (operator === 32 || operator === 34) { + if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); @@ -30797,10 +32441,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 31 || operator === 32; + var doubleEquals = operator === 32 || operator === 33; var facts = doubleEquals ? assumeTrue ? 65536 : 524288 : - value.kind === 94 ? + value.kind === 95 ? assumeTrue ? 32768 : 262144 : assumeTrue ? 16384 : 131072; return getTypeWithFacts(type, facts); @@ -30826,13 +32470,21 @@ var ts; } return type; } - if (operator === 32 || operator === 34) { + if (operator === 33 || operator === 35) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536)) { var targetType = typeofTypesByName.get(literal.text); - if (targetType && isTypeSubtypeOf(targetType, type)) { - return targetType; + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 540672) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } } } var facts = assumeTrue ? @@ -30906,10 +32558,9 @@ var ts; return assignableType; } } - var targetType = type.flags & 16384 ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, targetType) ? candidate : + isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { @@ -30925,7 +32576,7 @@ var ts; return type; } if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + var predicateArgument = callExpression.arguments[predicate.parameterIndex - (signature.thisParameter ? 1 : 0)]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -30937,7 +32588,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 179 || invokedExpression.kind === 178) { + if (invokedExpression.kind === 180 || invokedExpression.kind === 179) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -30952,18 +32603,19 @@ var ts; } function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 70: - case 98: - case 178: + case 71: + case 99: + case 97: + case 179: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 180: + case 181: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 184: + case 185: return narrowType(type, expr.expression, assumeTrue); - case 193: + case 194: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 191: - if (expr.operator === 50) { + case 192: + if (expr.operator === 51) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -30972,7 +32624,7 @@ var ts; } } function getTypeOfSymbolAtLocation(symbol, location) { - if (location.kind === 70) { + if (location.kind === 71) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -30986,15 +32638,12 @@ var ts; return getTypeOfSymbol(symbol); } function getControlFlowContainer(node) { - while (true) { - node = node.parent; - if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 233 || - node.kind === 264 || - node.kind === 148) { - return node; - } - } + return ts.findAncestor(node.parent, function (node) { + return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || + node.kind === 234 || + node.kind === 265 || + node.kind === 149; + }); } function isParameterAssigned(symbol) { var func = ts.getRootDeclaration(symbol.valueDeclaration).parent; @@ -31008,21 +32657,13 @@ var ts; return symbol.isAssigned || false; } function hasParentWithAssignmentsMarked(node) { - while (true) { - node = node.parent; - if (!node) { - return false; - } - if (ts.isFunctionLike(node) && getNodeLinks(node).flags & 4194304) { - return true; - } - } + return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 4194304); }); } function markParameterAssignments(node) { - if (node.kind === 70) { + if (node.kind === 71) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 146) { symbol.isAssigned = true; } } @@ -31034,6 +32675,14 @@ var ts; function isConstVariable(symbol) { return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + function removeOptionalityFromDeclaredType(declaredType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 146 && + declaration.initializer && + getFalsyFlags(declaredType) & 2048 && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072) : declaredType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -31042,16 +32691,14 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2) { - if (container.kind === 186) { + if (container.kind === 187) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 16384) { - getNodeLinks(container).flags |= 8192; - } + getNodeLinks(container).flags |= 8192; return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -31060,7 +32707,7 @@ var ts; var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol); if (localOrExportSymbol.flags & 32) { var declaration_1 = localOrExportSymbol.valueDeclaration; - if (declaration_1.kind === 228 + if (declaration_1.kind === 229 && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -31072,11 +32719,11 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 198) { + else if (declaration_1.kind === 199) { var container = ts.getThisContainer(node, false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 148 && ts.hasModifier(container, 32)) { + if (container.kind === 149 && ts.hasModifier(container, 32)) { getNodeLinks(declaration_1).flags |= 8388608; getNodeLinks(node).flags |= 16777216; } @@ -31106,22 +32753,25 @@ var ts; if (!(localOrExportSymbol.flags & 3) || assignmentKind === 1 || !declaration) { return type; } - var isParameter = ts.getRootDeclaration(declaration).kind === 145; + var isParameter = ts.getRootDeclaration(declaration).kind === 146; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; - while (flowContainer !== declarationContainer && (flowContainer.kind === 185 || - flowContainer.kind === 186 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 186 || + flowContainer.kind === 187 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node)) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1) !== 0 || isInTypeQuery(node) || node.parent.kind === 246) || ts.isInAmbientContext(declaration); - var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, ts.getRootDeclaration(declaration)) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, 2048); + var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } @@ -31135,19 +32785,12 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; + return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 || (symbol.flags & (2 | 32)) === 0 || - symbol.valueDeclaration.parent.kind === 259) { + symbol.valueDeclaration.parent.kind === 260) { return; } var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); @@ -31165,8 +32808,8 @@ var ts; if (usedInFunction) { getNodeLinks(current).flags |= 65536; } - if (container.kind === 213 && - ts.getAncestor(symbol.valueDeclaration, 226).parent === container && + if (container.kind === 214 && + ts.getAncestor(symbol.valueDeclaration, 227).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152; } @@ -31178,33 +32821,25 @@ var ts; } function isAssignedInBodyOfForStatement(node, container) { var current = node; - while (current.parent.kind === 184) { + while (current.parent.kind === 185) { current = current.parent; } var isAssigned = false; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 191 || current.parent.kind === 192)) { + else if ((current.parent.kind === 192 || current.parent.kind === 193)) { var expr = current.parent; - isAssigned = expr.operator === 42 || expr.operator === 43; + isAssigned = expr.operator === 43 || expr.operator === 44; } if (!isAssigned) { return false; } - while (current !== container) { - if (current === container.statement) { - return true; - } - else { - current = current.parent; - } - } - return false; + return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2; - if (container.kind === 148 || container.kind === 151) { + if (container.kind === 149 || container.kind === 152) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4; } @@ -31248,32 +32883,32 @@ var ts; function checkThisExpression(node) { var container = ts.getThisContainer(node, true); var needToCaptureLexicalThis = false; - if (container.kind === 151) { + if (container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class); } - if (container.kind === 186) { + if (container.kind === 187) { container = ts.getThisContainer(container, false); needToCaptureLexicalThis = (languageVersion < 2); } switch (container.kind) { - case 232: + case 233: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body); break; - case 231: + case 232: error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location); break; - case 151: + case 152: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); } break; + case 149: case 148: - case 147: if (ts.getModifierFlags(container) & 32) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); } break; - case 143: + case 144: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -31282,8 +32917,8 @@ var ts; } if (ts.isFunctionLike(container) && (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) { - if (container.kind === 185 && - ts.isInJavaScriptFile(container.parent) && + if (container.kind === 186 && + container.parent.kind === 194 && ts.getSpecialPropertyAssignmentKind(container.parent) === 3) { var className = container.parent .left @@ -31302,7 +32937,7 @@ var ts; if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); var type = ts.hasModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - return getFlowTypeOfReference(node, type, true, undefined); + return getFlowTypeOfReference(node, type); } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); @@ -31310,34 +32945,29 @@ var ts; return type; } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } return anyType; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 278) { + if (jsdocType && jsdocType.kind === 279) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 282) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 145) { - return true; - } - } - return false; + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 146; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 180 && node.parent.expression === node; + var isCallExpression = node.parent.kind === 181 && node.parent.expression === node; var container = ts.getSuperContainer(node, true); var needToCaptureLexicalThis = false; if (!isCallExpression) { - while (container && container.kind === 186) { + while (container && container.kind === 187) { container = ts.getSuperContainer(container, true); needToCaptureLexicalThis = languageVersion < 2; } @@ -31345,17 +32975,14 @@ var ts; var canUseSuperExpression = isLegalUsageOfSuperExpression(container); var nodeCheckFlag = 0; if (!canUseSuperExpression) { - var current = node; - while (current && current !== container && current.kind !== 143) { - current = current.parent; - } - if (current && current.kind === 143) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 144; }); + if (current && current.kind === 144) { 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 === 177)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 178)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -31363,7 +32990,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 151) { + if (!isCallExpression && container.kind === 152) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32) || isCallExpression) { @@ -31373,7 +33000,7 @@ var ts; nodeCheckFlag = 256; } getNodeLinks(node).flags |= nodeCheckFlag; - if (container.kind === 150 && ts.getModifierFlags(container) & 256) { + if (container.kind === 151 && ts.getModifierFlags(container) & 256) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096; } @@ -31384,7 +33011,7 @@ var ts; if (needToCaptureLexicalThis) { captureLexicalThis(node.parent, container); } - if (container.parent.kind === 177) { + if (container.parent.kind === 178) { 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; @@ -31402,7 +33029,7 @@ var ts; } return unknownType; } - if (container.kind === 151 && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 152 && isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments); return unknownType; } @@ -31414,32 +33041,50 @@ var ts; return false; } if (isCallExpression) { - return container.kind === 151; + return container.kind === 152; } else { - if (ts.isClassLike(container.parent) || container.parent.kind === 177) { + if (ts.isClassLike(container.parent) || container.parent.kind === 178) { if (ts.getModifierFlags(container) & 32) { - return container.kind === 150 || - container.kind === 149 || - container.kind === 152 || - container.kind === 153; + return container.kind === 151 || + container.kind === 150 || + container.kind === 153 || + container.kind === 154; } else { - return container.kind === 150 || - container.kind === 149 || - container.kind === 152 || + return container.kind === 151 || + container.kind === 150 || container.kind === 153 || + container.kind === 154 || + container.kind === 149 || container.kind === 148 || - container.kind === 147 || - container.kind === 151; + container.kind === 152; } } } return false; } } + function getContainingObjectLiteral(func) { + return (func.kind === 151 || + func.kind === 153 || + func.kind === 154) && func.parent.kind === 178 ? func.parent : + func.kind === 186 && func.parent.kind === 261 ? func.parent.parent : + undefined; + } + function getThisTypeArgument(type) { + return getObjectFlags(type) & 4 && type.target === globalThisType ? type.typeArguments[0] : undefined; + } + function getThisTypeFromContextualType(type) { + return mapType(type, function (t) { + return t.flags & 131072 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + }); + } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186) { + if (func.kind === 187) { + return undefined; + } + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -31448,6 +33093,32 @@ var ts; } } } + if (noImplicitThis) { + var containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + var contextualType = getApparentTypeOfContextualType(containingLiteral); + var literal = containingLiteral; + var type = contextualType; + while (type) { + var thisType = getThisTypeFromContextualType(type); + if (thisType) { + return instantiateType(thisType, getContextualMapper(containingLiteral)); + } + if (literal.parent.kind !== 261) { + break; + } + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); + } + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); + } + if (func.parent.kind === 194 && func.parent.operatorToken.kind === 58) { + var target = func.parent.left; + if (target.kind === 179 || target.kind === 180) { + return checkExpressionCached(target.expression); + } + } + } return undefined; } function getContextuallyTypedParameterType(parameter) { @@ -31495,7 +33166,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 145) { + if (declaration.kind === 146) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -31507,7 +33178,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (ts.isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== 176 && parentDeclaration.type && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -31521,33 +33192,34 @@ var ts; } function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); - if (ts.isAsyncFunctionLike(func)) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getPromisedType(contextualReturnType); + if (func) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1) { + return undefined; } - return undefined; - } - if (func && !func.asteriskToken) { - return getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func); + return functionFlags & 2 + ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) + : contextualReturnType; } return undefined; } function getContextualTypeForYieldOperand(node) { var func = ts.getContainingFunction(node); if (func) { + var functionFlags = ts.getFunctionFlags(func); var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); + : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & 2) !== 0); } } return undefined; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 145 && node.parent.initializer === node) { + if (node.parent.kind === 146 && node.parent.initializer === node) { return true; } node = node.parent; @@ -31556,8 +33228,8 @@ var ts; } function getContextualReturnType(functionDecl) { if (functionDecl.type || - functionDecl.kind === 151 || - functionDecl.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153))) { + functionDecl.kind === 152 || + functionDecl.kind === 153 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 154))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl); @@ -31576,7 +33248,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 182) { + if (template.parent.kind === 183) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -31584,7 +33256,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 57 && operator <= 69) { + if (operator >= 58 && operator <= 70) { if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0) { return undefined; } @@ -31592,52 +33264,28 @@ var ts; return getTypeOfExpression(binaryExpression.left); } } - else if (operator === 53) { + else if (operator === 54) { var type = getContextualType(binaryExpression); if (!type && node === binaryExpression.right) { type = getTypeOfExpression(binaryExpression.left); } return type; } - else if (operator === 52 || operator === 25) { + else if (operator === 53 || operator === 26) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } } return undefined; } - function applyToContextualType(type, mapper) { - if (!(type.flags & 65536)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { + return mapType(type, function (t) { var prop = t.flags & 229376 ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } function contextualTypeIsTupleLikeType(type) { return !!(type.flags & 65536 ? ts.forEach(type.types, isTupleLikeType) : isTupleLikeType(type)); @@ -31672,7 +33320,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1) - || (languageVersion >= 2 ? getElementTypeOfIterable(type, undefined) : undefined); + || getIteratedTypeOrElementType(type, undefined, false, false, false); } return undefined; } @@ -31680,6 +33328,25 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(node) { + var jsxAttributes = ts.isJsxAttributeLike(node.parent) ? + node.parent.parent : + node.parent.openingElement.attributes; + var attributesType = getContextualType(jsxAttributes); + if (!attributesType || isTypeAny(attributesType)) { + return undefined; + } + if (ts.isJsxAttribute(node.parent)) { + return getTypeOfPropertyOfType(attributesType, node.parent.name.text); + } + else if (node.parent.kind === 249) { + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + } + else { + return attributesType; + } + } function getContextualTypeForJsxAttribute(attribute) { var attributesType = getContextualType(attribute.parent); if (ts.isJsxAttribute(attribute)) { @@ -31705,48 +33372,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 225: - case 145: + case 226: + case 146: + case 149: case 148: - case 147: - case 175: - return getContextualTypeForInitializerExpression(node); - case 186: - case 218: - return getContextualTypeForReturnExpression(node); - case 196: - return getContextualTypeForYieldOperand(parent); - case 180: - case 181: - return getContextualTypeForArgument(parent, node); - case 183: - case 201: - return getTypeFromTypeNode(parent.type); - case 193: - return getContextualTypeForBinaryOperand(node); - case 260: - case 261: - return getContextualTypeForObjectLiteralElement(parent); case 176: - return getContextualTypeForElementExpression(node); - case 194: - return getContextualTypeForConditionalOperand(node); - case 204: - ts.Debug.assert(parent.parent.kind === 195); - return getContextualTypeForSubstitutionExpression(parent.parent, node); + return getContextualTypeForInitializerExpression(node); + case 187: + case 219: + return getContextualTypeForReturnExpression(node); + case 197: + return getContextualTypeForYieldOperand(parent); + case 181: + case 182: + return getContextualTypeForArgument(parent, node); case 184: + case 202: + return getTypeFromTypeNode(parent.type); + case 194: + return getContextualTypeForBinaryOperand(node); + case 261: + case 262: + return getContextualTypeForObjectLiteralElement(parent); + case 263: + return getApparentTypeOfContextualType(parent.parent); + case 177: + return getContextualTypeForElementExpression(node); + case 195: + return getContextualTypeForConditionalOperand(node); + case 205: + ts.Debug.assert(parent.parent.kind === 196); + return getContextualTypeForSubstitutionExpression(parent.parent, node); + case 185: return getContextualType(parent); + case 256: + return getContextualTypeForJsxExpression(parent); + case 253: case 255: - return getContextualType(parent); - case 252: - case 254: return getContextualTypeForJsxAttribute(parent); + case 251: case 250: - case 249: return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } + function getContextualMapper(node) { + node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return node ? node.contextualMapper : identityMapper; + } function getNonGenericSignature(type, node) { var signatures = getSignaturesOfStructuredType(type, 0); if (signatures.length === 1) { @@ -31771,7 +33444,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 185 || node.kind === 186; + return node.kind === 186 || node.kind === 187; } function getContextualSignatureForFunctionLikeDeclaration(node) { return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node) @@ -31784,7 +33457,7 @@ var ts; getApparentTypeOfContextualType(node); } function getContextualSignature(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -31794,8 +33467,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var current = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var current = types_17[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -31817,37 +33490,37 @@ var ts; } return result; } - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function checkSpreadExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpression(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false); + function checkSpreadExpression(node, checkMode) { + if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 1536); + } + var arrayOrIterableType = checkExpression(node.expression, checkMode); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, false, false); } function hasDefaultValue(node) { - return (node.kind === 175 && !!node.initializer) || - (node.kind === 193 && node.operatorToken.kind === 57); + return (node.kind === 176 && !!node.initializer) || + (node.kind === 194 && node.operatorToken.kind === 58); } - function checkArrayLiteral(node, contextualMapper) { + function checkArrayLiteral(node, checkMode) { var elements = node.elements; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 197) { - var restArrayType = checkExpression(e.expression, contextualMapper); + if (inDestructuringPattern && e.kind === 198) { + var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1) || - (languageVersion >= 2 ? getElementTypeOfIterable(restArrayType, undefined) : undefined); + getIteratedTypeOrElementType(restArrayType, undefined, false, false, false); if (restElementType) { elementTypes.push(restElementType); } } else { - var type = checkExpressionForMutableLocation(e, contextualMapper); + var type = checkExpressionForMutableLocation(e, checkMode); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 197; + hasSpreadElement = hasSpreadElement || e.kind === 198; } if (!hasSpreadElement) { if (inDestructuringPattern && elementTypes.length) { @@ -31858,7 +33531,7 @@ var ts; var contextualType = getApparentTypeOfContextualType(node); if (contextualType && contextualTypeIsTupleLikeType(contextualType)) { var pattern = contextualType.pattern; - if (pattern && (pattern.kind === 174 || pattern.kind === 176)) { + if (pattern && (pattern.kind === 175 || pattern.kind === 177)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -31866,7 +33539,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 199) { + if (patternElement.kind !== 200) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -31883,7 +33556,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 143 ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 144 ? isNumericComputedName(name) : isNumericLiteralName(name.text); } function isNumericComputedName(name) { return isTypeAnyOrAllConstituentTypesHaveKind(checkComputedPropertyName(name), 340); @@ -31920,7 +33593,7 @@ var ts; var unionType = propTypes.length ? getUnionType(propTypes, true) : undefinedType; return createIndexInfo(unionType, false); } - function checkObjectLiteral(node, contextualMapper) { + function checkObjectLiteral(node, checkMode) { var inDestructuringPattern = ts.isAssignmentTarget(node); checkGrammarObjectLiteralExpression(node, inDestructuringPattern); var propertiesTable = ts.createMap(); @@ -31929,7 +33602,8 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 173 || contextualType.pattern.kind === 177); + (contextualType.pattern.kind === 174 || contextualType.pattern.kind === 178); + var isJSObjectLiteral = !contextualType && ts.isInJavaScriptFile(node); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -31938,25 +33612,25 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 260 || - memberDecl.kind === 261 || + if (memberDecl.kind === 261 || + memberDecl.kind === 262 || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 260) { - type = checkPropertyAssignment(memberDecl, contextualMapper); + if (memberDecl.kind === 261) { + type = checkPropertyAssignment(memberDecl, checkMode); } - else if (memberDecl.kind === 150) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); + else if (memberDecl.kind === 151) { + type = checkObjectLiteralMethod(memberDecl, checkMode); } else { - ts.Debug.assert(memberDecl.kind === 261); - type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 262); + type = checkExpressionForMutableLocation(memberDecl.name, checkMode); } typeFlags |= type.flags; var prop = createSymbol(4 | member.flags, member.name); if (inDestructuringPattern) { - var isOptional = (memberDecl.kind === 260 && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 261 && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 261 && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 262 && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 67108864; } @@ -31982,7 +33656,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 262) { + else if (memberDecl.kind === 263) { if (languageVersion < 2) { checkExternalEmitHelpers(memberDecl, 2); } @@ -32004,8 +33678,8 @@ var ts; continue; } else { - ts.Debug.assert(memberDecl.kind === 152 || memberDecl.kind === 153); - checkAccessorDeclaration(memberDecl); + ts.Debug.assert(memberDecl.kind === 153 || memberDecl.kind === 154); + checkNodeDeferred(memberDecl); } if (ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { @@ -32044,8 +33718,8 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; + var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0) : undefined; + var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576; result.flags |= 4194304 | freshObjectLiteralFlag | (typeFlags & 14680064); @@ -32069,7 +33743,7 @@ var ts; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function checkJsxElement(node) { checkJsxOpeningLikeElement(node.openingElement); @@ -32079,34 +33753,20 @@ var ts; else { checkExpression(node.closingElement.tagName); } - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 255: - checkJsxExpression(child); - break; - case 248: - checkJsxElement(child); - break; - case 249: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function isUnhyphenatedJsxName(name) { return name.indexOf("-") < 0; } function isJsxIntrinsicIdentifier(tagName) { - if (tagName.kind === 178 || tagName.kind === 98) { + if (tagName.kind === 179 || tagName.kind === 99) { return false; } else { return ts.isIntrinsicJsxName(tagName.text); } } - function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createMap(); var spread = emptyObjectType; @@ -32116,7 +33776,7 @@ var ts; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = attributeDecl.initializer ? - checkExpression(attributeDecl.initializer, contextualMapper) : + checkExpression(attributeDecl.initializer, checkMode) : trueType; var attributeSymbol = createSymbol(4 | 134217728 | member.flags, member.name); attributeSymbol.declarations = member.declarations; @@ -32130,14 +33790,14 @@ var ts; attributesArray.push(attributeSymbol); } else { - ts.Debug.assert(attributeDecl.kind === 254); + ts.Debug.assert(attributeDecl.kind === 255); if (attributesArray.length > 0) { spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = ts.createMap(); } var exprType = checkExpression(attributeDecl.expression); - if (!(exprType.flags & (32768 | 1))) { + if (!isValidSpreadType(exprType)) { error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return anyType; } @@ -32163,6 +33823,32 @@ var ts; } }); } + var parent = openingLikeElement.parent.kind === 249 ? openingLikeElement.parent : undefined; + if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { + var childrenTypes = []; + for (var _b = 0, _c = parent.children; _b < _c.length; _b++) { + var child = _c[_b]; + if (child.kind === 10) { + if (!child.containsOnlyWhiteSpaces) { + childrenTypes.push(stringType); + } + } + else { + childrenTypes.push(checkExpression(child, checkMode)); + } + } + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { + if (attributesTable.has(jsxChildrenPropertyName)) { + error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); + } + var childrenPropSymbol = createSymbol(4 | 134217728, jsxChildrenPropertyName); + childrenPropSymbol.type = childrenTypes.length === 1 ? + childrenTypes[0] : + createArrayType(getUnionType(childrenTypes, false)); + attributesTable.set(jsxChildrenPropertyName, childrenPropSymbol); + } + } return createJsxAttributesType(attributes.symbol, attributesTable); function createJsxAttributesType(symbol, attributesTable) { var result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, undefined, undefined); @@ -32172,8 +33858,8 @@ var ts; return result; } } - function checkJsxAttributes(node, contextualMapper) { - return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, contextualMapper); + function checkJsxAttributes(node, checkMode) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, undefined, checkMode); } function getJsxType(name) { var jsxType = jsxTypes.get(name); @@ -32201,7 +33887,7 @@ var ts; return links.resolvedSymbol = unknownSymbol; } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } return links.resolvedSymbol = unknownSymbol; @@ -32224,36 +33910,48 @@ var ts; } return getUnionType(ts.map(signatures, getReturnTypeOfSignature), true); } - function getJsxElementPropertiesName() { + function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer) { var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920, undefined); - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793064); - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - var attribProperties = attribPropType && getPropertiesOfType(attribPropType); - if (attribProperties) { - if (attribProperties.length === 0) { + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 793064); + var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); + var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); + if (propertiesOfJsxElementAttribPropInterface) { + if (propertiesOfJsxElementAttribPropInterface.length === 0) { return ""; } - else if (attribProperties.length === 1) { - return attribProperties[0].name; + else if (propertiesOfJsxElementAttribPropInterface.length === 1) { + return propertiesOfJsxElementAttribPropInterface[0].name; } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; + else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, nameOfAttribPropContainer); } } - else { - return undefined; + return undefined; + } + function getJsxElementPropertiesName() { + if (!_hasComputedJsxElementPropertiesName) { + _hasComputedJsxElementPropertiesName = true; + _jsxElementPropertiesName = getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer); } + return _jsxElementPropertiesName; + } + function getJsxElementChildrenPropertyname() { + if (!_hasComputedJsxElementChildrenPropertyName) { + _hasComputedJsxElementChildrenPropertyName = true; + _jsxElementChildrenPropertyName = getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer); + } + return _jsxElementChildrenPropertyName; } function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, undefined); if (callSignature !== unknownSignature) { var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { paramType = intersectTypes(intrinsicAttributes, paramType); @@ -32268,7 +33966,8 @@ var ts; function tryGetAllJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { var candidatesOutArray = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); var result = void 0; @@ -32277,7 +33976,7 @@ var ts; var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var shouldBeCandidate = true; for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { var attribute = _b[_a]; @@ -32363,10 +34062,6 @@ var ts; else if (isTypeAny(attributesType) || (attributesType === unknownType)) { return attributesType; } - else if (attributesType.flags & 65536) { - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); - return anyType; - } else { var apparentAttributesType = attributesType; var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes); @@ -32436,10 +34131,25 @@ var ts; return prop || unknownSymbol; } function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + if (!deferredJsxElementClassType) { + deferredJsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } - return jsxElementClassType; + return deferredJsxElementClassType; + } + function getJsxGlobalElementType() { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + function getJsxGlobalStatelessElementType() { + if (!deferredJsxStatelessElementType) { + var jsxElementType = getJsxGlobalElementType(); + if (jsxElementType) { + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; } function getJsxIntrinsicTagNames() { var intrinsics = getJsxType(JsxNames.IntrinsicElements); @@ -32449,8 +34159,8 @@ var ts; if ((compilerOptions.jsx || 0) === 0) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { + if (getJsxGlobalElementType() === undefined) { + if (noImplicitAny) { error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -32483,9 +34193,9 @@ var ts; checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node, contextualMapper) { + function checkJsxExpression(node, checkMode) { if (node.expression) { - var type = checkExpression(node.expression, contextualMapper); + var type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -32496,19 +34206,19 @@ var ts; } } function getDeclarationKindFromSymbol(s) { - return s.valueDeclaration ? s.valueDeclaration.kind : 148; + return s.valueDeclaration ? s.valueDeclaration.kind : 149; } function getDeclarationModifierFlagsFromSymbol(s) { if (s.valueDeclaration) { var flags = ts.getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & 32 ? flags : flags & ~28; } - if (getCheckFlags(s) & 2) { + if (getCheckFlags(s) & 6) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 128 ? 8 : - checkFlags & 32 ? 4 : + var accessModifier = checkFlags & 256 ? 8 : + checkFlags & 64 ? 4 : 16; - var staticModifier = checkFlags & 256 ? 32 : 0; + var staticModifier = checkFlags & 512 ? 32 : 0; return accessModifier | staticModifier; } if (s.flags & 16777216) { @@ -32519,19 +34229,25 @@ var ts; function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol) { + return !!(symbol.flags & 8192 || getCheckFlags(symbol) & 4); + } function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 178 || node.kind === 225 ? + var errorNode = node.kind === 179 || node.kind === 226 ? node.name : node.right; - if (getCheckFlags(prop) & 128) { + if (getCheckFlags(prop) & 256) { error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; } - if (left.kind === 96) { + if (left.kind === 97) { if (languageVersion < 2) { - var propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== 150 && propKind !== 149) { + var hasNonMethodDeclaration = forEachProperty(prop, function (p) { + var propKind = getDeclarationKindFromSymbol(p); + return propKind !== 151 && propKind !== 150; + }); + if (hasNonMethodDeclaration) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -32552,7 +34268,7 @@ var ts; } return true; } - if (left.kind === 96) { + if (left.kind === 97) { return true; } var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) { @@ -32625,7 +34341,7 @@ var ts; } function isInPropertyInitializer(node) { while (node) { - if (node.parent && node.parent.kind === 148 && node.parent.initializer === node) { + if (node.parent && node.parent.kind === 149 && node.parent.initializer === node) { return true; } node = node.parent; @@ -32652,10 +34368,17 @@ var ts; } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === 229 && + node.parent && node.parent.kind !== 159 && + !ts.isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; @@ -32668,16 +34391,16 @@ var ts; return unknownType; } } - if (node.kind !== 178 || assignmentKind === 1 || + if (node.kind !== 179 || assignmentKind === 1 || !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 65536)) { return propType; } - var flowType = getFlowTypeOfReference(node, propType, true, undefined); + var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 178 + var left = node.kind === 179 ? node.expression : node.left; var type = checkExpression(left); @@ -32691,13 +34414,13 @@ var ts; } function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 226) { + if (initializer.kind === 227) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 70) { + else if (initializer.kind === 71) { return getResolvedSymbol(initializer); } return undefined; @@ -32707,13 +34430,13 @@ var ts; } function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 70) { + if (e.kind === 71) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 214 && + if (node.kind === 215 && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -32731,7 +34454,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 181 && node.parent.expression === node) { + if (node.parent.kind === 182 && 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); @@ -32771,7 +34494,7 @@ var ts; if (!leftHandSideSymbol) { return false; } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + var globalESSymbol = getGlobalESSymbolConstructorSymbol(true); if (!globalESSymbol) { return false; } @@ -32784,10 +34507,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 182) { + if (node.kind === 183) { checkExpression(node.template); } - else if (node.kind !== 146) { + else if (node.kind !== 147) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -32806,8 +34529,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var signature = signatures_2[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -32838,7 +34561,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 197) { + if (arg && arg.kind === 198) { return i; } } @@ -32854,11 +34577,11 @@ var ts; if (ts.isJsxOpeningLikeElement(node)) { return true; } - if (node.kind === 182) { + if (node.kind === 183) { var tagExpression = node; argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 195) { + if (tagExpression.template.kind === 196) { var templateExpression = tagExpression.template; var lastSpan = ts.lastOrUndefined(templateExpression.templateSpans); ts.Debug.assert(lastSpan !== undefined); @@ -32866,11 +34589,11 @@ var ts; } else { var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 12); + ts.Debug.assert(templateLiteral.kind === 13); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 146) { + else if (node.kind === 147) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, undefined, signature); @@ -32878,7 +34601,7 @@ var ts; else { var callExpression = node; if (!callExpression.arguments) { - ts.Debug.assert(callExpression.kind === 181); + ts.Debug.assert(callExpression.kind === 182); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -32913,7 +34636,7 @@ var ts; return undefined; } function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, true); + var context = createInferenceContext(signature, true, false); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { inferTypesWithContext(context, instantiateType(source, contextualMapper), target); }); @@ -32939,7 +34662,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 !== 199) { + if (arg === undefined || arg.kind !== 200) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -33006,7 +34729,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 181) { + if (thisType && thisType !== voidType && node.kind !== 182) { var thisArgumentNode = getThisArgumentOfCall(node); var thisArgumentType = thisArgumentNode ? checkExpression(thisArgumentNode) : voidType; var errorNode = reportErrors ? (thisArgumentNode || node) : undefined; @@ -33019,7 +34742,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 !== 199) { + if (arg === undefined || arg.kind !== 200) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); if (argType === undefined) { @@ -33034,28 +34757,28 @@ var ts; return true; } function getThisArgumentOfCall(node) { - if (node.kind === 180) { + if (node.kind === 181) { var callee = node.expression; - if (callee.kind === 178) { + if (callee.kind === 179) { return callee.expression; } - else if (callee.kind === 179) { + else if (callee.kind === 180) { return callee.expression; } } } function getEffectiveCallArguments(node) { var args; - if (node.kind === 182) { + if (node.kind === 183) { var template = node.template; args = [undefined]; - if (template.kind === 195) { + if (template.kind === 196) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 146) { + else if (node.kind === 147) { return undefined; } else if (ts.isJsxOpeningLikeElement(node)) { @@ -33067,21 +34790,21 @@ var ts; return args; } function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 146) { + if (node.kind === 147) { switch (node.parent.kind) { - case 228: - case 198: + case 229: + case 199: return 1; - case 148: + case 149: return 2; - case 150: - case 152: + case 151: case 153: + case 154: if (languageVersion === 0) { return 2; } return signature.parameters.length >= 3 ? 3 : 2; - case 145: + case 146: return 3; } } @@ -33090,48 +34813,48 @@ var ts; } } function getEffectiveDecoratorFirstArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } - if (node.kind === 145) { + if (node.kind === 146) { node = node.parent; - if (node.kind === 151) { + if (node.kind === 152) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 153 || + node.kind === 154) { return getParentTypeOfClassElement(node); } ts.Debug.fail("Unsupported decorator target."); return unknownType; } function getEffectiveDecoratorSecondArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 145) { + if (node.kind === 146) { node = node.parent; - if (node.kind === 151) { + if (node.kind === 152) { return anyType; } } - if (node.kind === 148 || - node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 149 || + node.kind === 151 || + node.kind === 153 || + node.kind === 154) { var element = node; switch (element.name.kind) { - case 70: + case 71: case 8: case 9: return getLiteralTypeForText(32, element.name.text); - case 143: + case 144: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512)) { return nameType; @@ -33148,20 +34871,20 @@ var ts; return unknownType; } function getEffectiveDecoratorThirdArgumentType(node) { - if (node.kind === 228) { + if (node.kind === 229) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 145) { + if (node.kind === 146) { return numberType; } - if (node.kind === 148) { + if (node.kind === 149) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 150 || - node.kind === 152 || - node.kind === 153) { + if (node.kind === 151 || + node.kind === 153 || + node.kind === 154) { var propertyType = getTypeOfNode(node); return createTypedPropertyDescriptorType(propertyType); } @@ -33182,26 +34905,26 @@ var ts; return unknownType; } function getEffectiveArgumentType(node, argIndex) { - if (node.kind === 146) { + if (node.kind === 147) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 182) { + else if (argIndex === 0 && node.kind === 183) { return getGlobalTemplateStringsArrayType(); } return undefined; } function getEffectiveArgument(node, args, argIndex) { - if (node.kind === 146 || - (argIndex === 0 && node.kind === 182)) { + if (node.kind === 147 || + (argIndex === 0 && node.kind === 183)) { return undefined; } return args[argIndex]; } function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 146) { + if (node.kind === 147) { return node.expression; } - else if (argIndex === 0 && node.kind === 182) { + else if (argIndex === 0 && node.kind === 183) { return node.template; } else { @@ -33209,16 +34932,30 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 182; - var isDecorator = node.kind === 146; + var isTaggedTemplate = node.kind === 183; + var isDecorator = node.kind === 147; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; - if (node.expression.kind !== 96) { + if (node.expression.kind !== 97) { ts.forEach(typeArguments, checkSourceElement); } } + if (signatures.length === 1) { + var declaration = signatures[0].declaration; + if (declaration && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration)) { + if (containsArgumentsReference(declaration)) { + var signatureWithRest = cloneSignature(signatures[0]); + var syntheticArgsSymbol = createSymbol(3, "args"); + syntheticArgsSymbol.type = anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + signatureWithRest.parameters = ts.concatenate(signatureWithRest.parameters, [syntheticArgsSymbol]); + signatureWithRest.hasRestParameter = true; + signatures = [signatureWithRest]; + } + } + } var candidates = candidatesOutArray || []; reorderCandidates(signatures, candidates); if (!candidates.length) { @@ -33241,7 +34978,7 @@ var ts; var candidateForTypeArgumentError; var resultOfFailedInference; var result; - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 181 && node.arguments.hasTrailingComma; if (candidates.length > 1) { result = chooseOverload(candidates, subtypeRelation, signatureHelpTrailingComma); } @@ -33309,7 +35046,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, false) + ? createInferenceContext(originalCandidate, false, ts.isInJavaScriptFile(node)) : undefined; while (true) { candidate = originalCandidate; @@ -33359,12 +35096,12 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -33513,16 +35250,16 @@ var ts; } function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 228: - case 198: + case 229: + case 199: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 145: + case 146: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 148: + case 149: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 150: - case 152: + case 151: case 153: + case 154: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } @@ -33556,8 +35293,8 @@ var ts; if (elementType.flags & 65536) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var type = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var type = types_18[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -33572,16 +35309,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 180: - return resolveCallExpression(node, candidatesOutArray); case 181: - return resolveNewExpression(node, candidatesOutArray); + return resolveCallExpression(node, candidatesOutArray); case 182: + return resolveNewExpression(node, candidatesOutArray); + case 183: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 146: + case 147: return resolveDecorator(node, candidatesOutArray); + case 251: case 250: - case 249: return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } ts.Debug.fail("Branch in 'resolveSignature' should be unreachable."); @@ -33610,23 +35347,26 @@ var ts; function checkCallExpression(node) { checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { return voidType; } - if (node.kind === 181) { + if (node.kind === 182) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 151 && - declaration.kind !== 155 && - declaration.kind !== 160 && + declaration.kind !== 152 && + declaration.kind !== 156 && + declaration.kind !== 161 && !ts.isJSDocConstructSignature(declaration)) { - var funcSymbol = node.expression.kind === 70 ? + var funcSymbol = node.expression.kind === 71 ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { + funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + } + if (funcSymbol && funcSymbol.members && funcSymbol.flags & 16) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -33649,9 +35389,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 - ? 227 + ? 228 : resolvedRequire.flags & 3 - ? 225 + ? 226 : 0; if (targetDeclarationKind !== 0) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -33679,13 +35419,12 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - ts.Debug.assert(node.keywordToken === 93 && node.name.text === "target", "Unrecognized meta-property."); var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 151) { + else if (container.kind === 152) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -33709,9 +35448,12 @@ var ts; pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; } - function assignContextualParameterTypes(signature, context, mapper) { + function getTypeOfFirstParameterOfSignature(signature) { + return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + } + function assignContextualParameterTypes(signature, context, mapper, checkMode) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - if (isInferentialContext(mapper)) { + if (checkMode === 2) { for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -33725,21 +35467,21 @@ var ts; if (!parameter) { signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper, checkMode); } } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } } @@ -33748,7 +35490,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 70) { + if (element.name.kind === 71) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -33756,18 +35498,18 @@ var ts; } } } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper, checkMode) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 173 || - parameter.valueDeclaration.name.kind === 174)) { + (parameter.valueDeclaration.name.kind === 174 || + parameter.valueDeclaration.name.kind === 175)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); } - else if (isInferentialContext(mapper)) { + else if (checkMode === 2) { inferTypesWithContext(mapper.context, links.type, instantiateType(contextualType, mapper)); } } @@ -33779,9 +35521,9 @@ var ts; return undefined; } function createPromiseType(promisedType) { - var globalPromiseType = getGlobalPromiseType(); + var globalPromiseType = getGlobalPromiseType(true); if (globalPromiseType !== emptyGenericType) { - promisedType = getAwaitedType(promisedType); + promisedType = getAwaitedType(promisedType) || emptyObjectType; return createTypeReference(globalPromiseType, [promisedType]); } return emptyObjectType; @@ -33792,49 +35534,56 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } - else if (!getGlobalPromiseConstructorSymbol()) { + else if (!getGlobalPromiseConstructorSymbol(true)) { error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } return promiseType; } - function getReturnTypeFromBody(func, contextualMapper) { + function getReturnTypeFromBody(func, checkMode) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } - var isAsync = ts.isAsyncFunctionLike(func); + var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 206) { - 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); + if (func.body.kind !== 207) { + type = checkExpressionCached(func.body, checkMode); + if (functionFlags & 2) { + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } } else { var types = void 0; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { + if (functionFlags & 1) { + types = ts.concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode)); + if (!types || types.length === 0) { + var iterableIteratorAny = functionFlags & 2 + ? createAsyncIterableIteratorType(anyType) + : createIterableIteratorType(anyType); + if (noImplicitAny) { error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); } return iterableIteratorAny; } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { - return isAsync ? createPromiseReturnType(func, neverType) : neverType; + return functionFlags & 2 + ? createPromiseReturnType(func, neverType) + : neverType; } if (types.length === 0) { - return isAsync ? createPromiseReturnType(func, voidType) : voidType; + return functionFlags & 2 + ? createPromiseReturnType(func, voidType) + : voidType; } } type = getUnionType(types, true); - if (funcIsGenerator) { - type = createIterableIteratorType(type); + if (functionFlags & 1) { + type = functionFlags & 2 + ? createAsyncIterableIteratorType(type) + : createIterableIteratorType(type); } } if (!contextualSignature) { @@ -33846,16 +35595,24 @@ var ts; type = getWidenedLiteralType(type); } var widenedType = getWidenedType(type); - return isAsync ? createPromiseReturnType(func, widenedType) : widenedType; + return (functionFlags & 3) === 2 + ? createPromiseReturnType(func, widenedType) + : widenedType; } - function checkAndAggregateYieldOperandTypes(func, contextualMapper) { + function checkAndAggregateYieldOperandTypes(func, checkMode) { var aggregatedTypes = []; + var functionFlags = ts.getFunctionFlags(func); ts.forEachYieldExpression(func.body, function (yieldExpression) { var expr = yieldExpression.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); + var type = checkExpressionCached(expr, checkMode); if (yieldExpression.asteriskToken) { - type = checkElementTypeOfIterable(type, yieldExpression.expression); + type = checkIteratedTypeOrElementType(type, yieldExpression.expression, false, (functionFlags & 2) !== 0); + } + if (functionFlags & 2) { + type = checkAwaitedType(type, expr, yieldExpression.asteriskToken + ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); @@ -33883,22 +35640,22 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 220 && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 221 && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; } - function checkAndAggregateReturnExpressionTypes(func, contextualMapper) { - var isAsync = ts.isAsyncFunctionLike(func); + function checkAndAggregateReturnExpressionTypes(func, checkMode) { + var functionFlags = ts.getFunctionFlags(func); var aggregatedTypes = []; var hasReturnWithNoExpression = functionHasImplicitReturn(func); var hasReturnOfTypeNever = false; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + var type = checkExpressionCached(expr, checkMode); + if (functionFlags & 2) { + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (type.flags & 8192) { hasReturnOfTypeNever = true; @@ -33912,7 +35669,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 185 || func.kind === 186)) { + func.kind === 186 || func.kind === 187)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -33929,7 +35686,7 @@ var ts; if (returnType && maybeTypeOfKind(returnType, 1 | 1024)) { return; } - if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 207 || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256; @@ -33955,20 +35712,20 @@ var ts; error(func.type || func, ts.Diagnostics.Not_all_code_paths_return_a_value); } } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); + function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 185) { + if (!hasGrammarError && node.kind === 186) { checkGrammarForGenerator(node); } - if (contextualMapper === identityMapper && isContextSensitive(node)) { + if (checkMode === 1 && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + var mightFixTypeParameters = contextSensitive && checkMode === 2; if (mightFixTypeParameters || !(links.flags & 1024)) { var contextualSignature = getContextualSignature(node); var contextChecked = !!(links.flags & 1024); @@ -33977,10 +35734,10 @@ var ts; if (contextualSignature) { var signature = getSignaturesOfType(type, 0)[0]; if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + assignContextualParameterTypes(signature, contextualSignature, getContextualMapper(node), checkMode); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); + var returnType = getReturnTypeFromBody(node, checkMode); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -33992,7 +35749,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 150) { + if (produceDiagnostics && node.kind !== 151) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -34000,24 +35757,27 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 150 || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { + ts.Debug.assert(node.kind !== 151 || ts.isObjectLiteralMethod(node)); + var functionFlags = ts.getFunctionFlags(node); + var returnOrPromisedType = node.type && + ((functionFlags & 3) === 2 ? + checkAsyncFunctionReturnType(node) : + getTypeFromTypeNode(node.type)); + if ((functionFlags & 1) === 0) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (node.body) { if (!node.type) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 206) { + if (node.body.kind === 207) { checkSourceElement(node.body); } else { var exprType = checkExpression(node.body); if (returnOrPromisedType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + if ((functionFlags & 3) === 2) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } else { @@ -34036,7 +35796,7 @@ var ts; return true; } function isReadonlySymbol(symbol) { - return !!(getCheckFlags(symbol) & 4 || + return !!(getCheckFlags(symbol) & 8 || symbol.flags & 4 && getDeclarationModifierFlagsFromSymbol(symbol) & 64 || symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 || symbol.flags & 98304 && !(symbol.flags & 65536) || @@ -34045,10 +35805,10 @@ var ts; function isReferenceToReadonlyEntity(expr, symbol) { if (isReadonlySymbol(symbol)) { if (symbol.flags & 4 && - (expr.kind === 178 || expr.kind === 179) && - expr.expression.kind === 98) { + (expr.kind === 179 || expr.kind === 180) && + expr.expression.kind === 99) { var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 151)) + if (!(func && func.kind === 152)) return true; return !(func.parent === symbol.valueDeclaration.parent || func === symbol.valueDeclaration.parent); } @@ -34057,13 +35817,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 178 || expr.kind === 179) { + if (expr.kind === 179 || expr.kind === 180) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 70) { + if (node.kind === 71) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 239; + return declaration && declaration.kind === 240; } } } @@ -34071,7 +35831,7 @@ var ts; } function checkReferenceExpression(expr, invalidReferenceMessage) { var node = ts.skipParentheses(expr); - if (node.kind !== 70 && node.kind !== 178 && node.kind !== 179) { + if (node.kind !== 71 && node.kind !== 179 && node.kind !== 180) { error(expr, invalidReferenceMessage); return false; } @@ -34080,7 +35840,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 178 && expr.kind !== 179) { + if (expr.kind !== 179 && expr.kind !== 180) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -34109,32 +35869,32 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); + return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 37 && node.operand.kind === 8) { + if (node.operator === 38 && node.operand.kind === 8) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64, "" + -node.operand.text)); } switch (node.operator) { - case 36: case 37: - case 51: + case 38: + case 52: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 50: + case 51: var facts = getTypeFacts(operandType) & (1048576 | 2097152); return facts === 1048576 ? falseType : facts === 2097152 ? trueType : booleanType; - case 42: case 43: + case 44: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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_or_a_property_access); @@ -34160,8 +35920,8 @@ var ts; } if (type.flags & 196608) { var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -34175,8 +35935,8 @@ var ts; } if (type.flags & 65536) { var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -34185,8 +35945,8 @@ var ts; } if (type.flags & 131072) { var types = type.types; - for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { - var t = types_20[_a]; + for (var _a = 0, types_21 = types; _a < types_21.length; _a++) { + var t = types_21[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -34224,23 +35984,23 @@ var ts; if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 | 512))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 260 || property.kind === 261) { + if (property.kind === 261 || property.kind === 262) { var name = property.name; - if (name.kind === 143) { + if (name.kind === 144) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -34253,7 +36013,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1) || getIndexTypeOfType(objectLiteralType, 0); if (type) { - if (property.kind === 261) { + if (property.kind === 262) { return checkDestructuringAssignment(property, type); } else { @@ -34264,7 +36024,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 262) { + else if (property.kind === 263) { if (languageVersion < 5) { checkExternalEmitHelpers(property, 4); } @@ -34281,19 +36041,22 @@ var ts; error(property, ts.Diagnostics.Property_assignment_expected); } } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { - var elementType = checkIteratedTypeOrElementType(sourceType, node, false) || unknownType; + function checkArrayLiteralAssignment(node, sourceType, checkMode) { + if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512); + } + var elementType = checkIteratedTypeOrElementType(sourceType, node, false, false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } return sourceType; } - function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { + function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 199) { - if (element.kind !== 197) { + if (element.kind !== 200) { + if (element.kind !== 198) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -34301,7 +36064,7 @@ var ts; ? getTypeOfPropertyOfType(sourceType, propName) : elementType; if (type) { - return checkDestructuringAssignment(element, type, contextualMapper); + return checkDestructuringAssignment(element, type, checkMode); } else { checkExpression(element); @@ -34319,48 +36082,48 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 193 && restExpression.operatorToken.kind === 57) { + if (restExpression.kind === 194 && restExpression.operatorToken.kind === 58) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { - return checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); } } } } return undefined; } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 261) { + if (exprOrAssignment.kind === 262) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { if (strictNullChecks && !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 2048)) { sourceType = getTypeWithFacts(sourceType, 131072); } - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } target = exprOrAssignment.name; } else { target = exprOrAssignment; } - if (target.kind === 193 && target.operatorToken.kind === 57) { - checkBinaryExpression(target, contextualMapper); + if (target.kind === 194 && target.operatorToken.kind === 58) { + checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 177) { + if (target.kind === 178) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 176) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 177) { + return checkArrayLiteralAssignment(target, sourceType, checkMode); } - return checkReferenceAssignment(target, sourceType, contextualMapper); + return checkReferenceAssignment(target, sourceType, checkMode); } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 262 ? + function checkReferenceAssignment(target, sourceType, checkMode) { + var targetType = checkExpression(target, checkMode); + var error = target.parent.kind === 263 ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -34371,49 +36134,49 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 70: + case 71: case 9: - case 11: - case 182: - case 195: case 12: + case 183: + case 196: + case 13: case 8: - case 100: - case 85: - case 94: - case 138: - case 185: - case 198: + case 101: + case 86: + case 95: + case 139: case 186: - case 176: + case 199: + case 187: case 177: - case 188: - case 202: + case 178: + case 189: + case 203: + case 250: case 249: - case 248: return true; - case 194: + case 195: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 193: + case 194: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 191: case 192: + case 193: switch (node.operator) { - case 50: - case 36: - case 37: case 51: + case 37: + case 38: + case 52: return true; } return false; - case 189: - case 183: - case 201: + case 190: + case 184: + case 202: default: return false; } @@ -34428,39 +36191,39 @@ var ts; firstAssignableToSecond && !secondAssignableToFirst ? type2 : getUnionType([type1, type2], true); } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + function checkBinaryExpression(node, checkMode) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 57 && (left.kind === 177 || left.kind === 176)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + if (operator === 58 && (left.kind === 178 || left.kind === 177)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); + var leftType = checkExpression(left, checkMode); + var rightType = checkExpression(right, checkMode); switch (operator) { - case 38: case 39: - case 60: - case 61: case 40: + case 61: case 62: case 41: case 63: - case 37: - case 59: - case 44: + case 42: case 64: + case 38: + case 60: case 45: case 65: case 46: case 66: - case 48: - case 68: - case 49: - case 69: case 47: case 67: + case 49: + case 69: + case 50: + case 70: + case 48: + case 68: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -34480,8 +36243,8 @@ var ts; } } return numberType; - case 36: - case 58: + case 37: + case 59: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -34508,14 +36271,14 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 58) { + if (operator === 59) { checkAssignmentOperator(resultType); } return resultType; - case 26: - case 28: + case 27: case 29: case 30: + case 31: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -34524,10 +36287,10 @@ var ts; } } return booleanType; - case 31: case 32: case 33: case 34: + case 35: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -34538,27 +36301,30 @@ var ts; reportOperatorError(); } return booleanType; - case 92: + case 93: return checkInstanceOfExpression(left, right, leftType, rightType); - case 91: + case 92: return checkInExpression(left, right, leftType, rightType); - case 52: + case 53: return getTypeFacts(leftType) & 1048576 ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 53: + case 54: return getTypeFacts(leftType) & 2097152 ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 57: + case 58: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 25: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { + case 26: + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; } + function isEvalNode(node) { + return node.kind === 71 && node.text === "eval"; + } function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 512) ? left : maybeTypeOfKind(rightType, 512) ? right : @@ -34571,21 +36337,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { + case 49: + case 69: + return 54; + case 50: + case 70: + return 35; case 48: case 68: return 53; - case 49: - case 69: - return 34; - case 47: - case 67: - return 52; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 57 && operator <= 69) { + if (produceDiagnostics && operator >= 58 && operator <= 70) { if (checkReferenceExpression(left, ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access)) { checkTypeAssignableTo(valueType, leftType, left, undefined); } @@ -34621,30 +36387,45 @@ var ts; } if (node.expression) { var func = ts.getContainingFunction(node); - if (func && func.asteriskToken) { + var functionFlags = func && ts.getFunctionFlags(func); + if (node.asteriskToken) { + if (functionFlags & 2) { + if (languageVersion < 4) { + checkExternalEmitHelpers(node, 4096); + } + } + else if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256); + } + } + if (functionFlags & 1) { var expressionType = checkExpressionCached(node.expression, undefined); var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + expressionElementType = checkIteratedTypeOrElementType(expressionType, node.expression, false, (functionFlags & 2) !== 0); } if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(func.type), (functionFlags & 2) !== 0) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(functionFlags & 2 + ? getAwaitedType(expressionElementType, node.expression, ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionElementType, signatureElementType, node.expression, undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, undefined); + checkTypeAssignableTo(functionFlags & 2 + ? getAwaitedType(expressionType, node.expression, ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionType, signatureElementType, node.expression, undefined); } } } } return anyType; } - function checkConditionalExpression(node, contextualMapper) { + function checkConditionalExpression(node, checkMode) { checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); + var type1 = checkExpression(node.whenTrue, checkMode); + var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { @@ -34656,9 +36437,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32, node.text)); case 8: return getFreshTypeOfLiteralType(getLiteralTypeForText(64, node.text)); - case 100: + case 101: return trueType; - case 85: + case 86: return falseType; } } @@ -34670,27 +36451,32 @@ var ts; } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; + var saveContextualMapper = node.contextualMapper; node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); + node.contextualMapper = contextualMapper; + var checkMode = contextualMapper === identityMapper ? 1 : + contextualMapper ? 2 : 0; + var result = checkExpression(node, checkMode); node.contextualType = saveContextualType; + node.contextualMapper = saveContextualMapper; return result; } - function checkExpressionCached(node, contextualMapper) { + function checkExpressionCached(node, checkMode) { var links = getNodeLinks(node); if (!links.resolvedType) { var saveFlowLoopStart = flowLoopStart; flowLoopStart = flowLoopCount; - links.resolvedType = checkExpression(node, contextualMapper); + links.resolvedType = checkExpression(node, checkMode); flowLoopStart = saveFlowLoopStart; } return links.resolvedType; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 183 || node.kind === 201; + return node.kind === 184 || node.kind === 202; } function checkDeclarationInitializer(declaration) { - var type = checkExpressionCached(declaration.initializer); + var type = getTypeOfExpression(declaration.initializer, true); return ts.getCombinedNodeFlags(declaration) & 2 || ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -34708,147 +36494,154 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, contextualMapper) { - var type = checkExpression(node, contextualMapper); + function checkExpressionForMutableLocation(node, checkMode) { + var type = checkExpression(node, checkMode); return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } - function checkPropertyAssignment(node, contextualMapper) { - if (node.name.kind === 143) { + function checkPropertyAssignment(node, checkMode) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } - return checkExpressionForMutableLocation(node.initializer, contextualMapper); + return checkExpressionForMutableLocation(node.initializer, checkMode); } - function checkObjectLiteralMethod(node, contextualMapper) { + function checkObjectLiteralMethod(node, checkMode) { checkGrammarMethod(node); - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { + function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { + if (checkMode === 2) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getApparentTypeOfContextualType(node); if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, getContextualMapper(node))); } } } } return type; } - function getTypeOfExpression(node) { - if (node.kind === 180 && node.expression.kind !== 96) { + function getTypeOfExpression(node, cache) { + if (node.kind === 181 && node.expression.kind !== 97 && !ts.isRequireCall(node, true)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { return getReturnTypeOfSignature(signature); } } - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); } - function checkExpression(node, contextualMapper) { + function getContextFreeTypeOfExpression(node) { + var saveContextualType = node.contextualType; + node.contextualType = anyType; + var type = getTypeOfExpression(node); + node.contextualType = saveContextualType; + return type; + } + function checkExpression(node, checkMode) { var type; - if (node.kind === 142) { + if (node.kind === 143) { type = checkQualifiedName(node); } else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkExpressionWorker(node, checkMode); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { - var ok = (node.parent.kind === 178 && node.parent.expression === node) || - (node.parent.kind === 179 && node.parent.expression === node) || - ((node.kind === 70 || node.kind === 142) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 179 && node.parent.expression === node) || + (node.parent.kind === 180 && node.parent.expression === node) || + ((node.kind === 71 || node.kind === 143) && 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); } } return type; } - function checkExpressionWorker(node, contextualMapper) { + function checkExpressionWorker(node, checkMode) { switch (node.kind) { - case 70: + case 71: return checkIdentifier(node); - case 98: + case 99: return checkThisExpression(node); - case 96: + case 97: return checkSuperExpression(node); - case 94: + case 95: return nullWideningType; case 9: case 8: - case 100: - case 85: + case 101: + case 86: return checkLiteralExpression(node); - case 195: - return checkTemplateExpression(node); - case 12: - return stringType; - case 11: - return globalRegExpType; - case 176: - return checkArrayLiteral(node, contextualMapper); - case 177: - return checkObjectLiteral(node, contextualMapper); - case 178: - return checkPropertyAccessExpression(node); - case 179: - return checkIndexedAccess(node); - case 180: - case 181: - return checkCallExpression(node); - case 182: - return checkTaggedTemplateExpression(node); - case 184: - return checkExpression(node.expression, contextualMapper); - case 198: - return checkClassExpression(node); - case 185: - case 186: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 188: - return checkTypeOfExpression(node); - case 183: - case 201: - return checkAssertion(node); - case 202: - return checkNonNullAssertion(node); - case 203: - return checkMetaProperty(node); - case 187: - return checkDeleteExpression(node); - case 189: - return checkVoidExpression(node); - case 190: - return checkAwaitExpression(node); - case 191: - return checkPrefixUnaryExpression(node); - case 192: - return checkPostfixUnaryExpression(node); - case 193: - return checkBinaryExpression(node, contextualMapper); - case 194: - return checkConditionalExpression(node, contextualMapper); - case 197: - return checkSpreadExpression(node, contextualMapper); - case 199: - return undefinedWideningType; case 196: + return checkTemplateExpression(node); + case 13: + return stringType; + case 12: + return globalRegExpType; + case 177: + return checkArrayLiteral(node, checkMode); + case 178: + return checkObjectLiteral(node, checkMode); + case 179: + return checkPropertyAccessExpression(node); + case 180: + return checkIndexedAccess(node); + case 181: + case 182: + return checkCallExpression(node); + case 183: + return checkTaggedTemplateExpression(node); + case 185: + return checkExpression(node.expression, checkMode); + case 199: + return checkClassExpression(node); + case 186: + case 187: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 189: + return checkTypeOfExpression(node); + case 184: + case 202: + return checkAssertion(node); + case 203: + return checkNonNullAssertion(node); + case 204: + return checkMetaProperty(node); + case 188: + return checkDeleteExpression(node); + case 190: + return checkVoidExpression(node); + case 191: + return checkAwaitExpression(node); + case 192: + return checkPrefixUnaryExpression(node); + case 193: + return checkPostfixUnaryExpression(node); + case 194: + return checkBinaryExpression(node, checkMode); + case 195: + return checkConditionalExpression(node, checkMode); + case 198: + return checkSpreadExpression(node, checkMode); + case 200: + return undefinedWideningType; + case 197: return checkYieldExpression(node); - case 255: - return checkJsxExpression(node, contextualMapper); - case 248: - return checkJsxElement(node); + case 256: + return checkJsxExpression(node, checkMode); case 249: - return checkJsxSelfClosingElement(node); - case 253: - return checkJsxAttributes(node, contextualMapper); + return checkJsxElement(node); case 250: + return checkJsxSelfClosingElement(node); + case 254: + return checkJsxAttributes(node, checkMode); + case 251: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -34878,7 +36671,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92) { func = ts.getContainingFunction(node); - if (!(func.kind === 151 && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 152 && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -34889,7 +36682,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 151 || func.kind === 155 || func.kind === 160) { + if (func.kind === 152 || func.kind === 156 || func.kind === 161) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -34897,19 +36690,11 @@ var ts; error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 150 || - node.kind === 227 || - node.kind === 185; - } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 70 && + if (param.name.kind === 71 && param.name.text === parameter.text) { return i; } @@ -34959,13 +36744,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { + case 187: + case 155: + case 228: case 186: - case 154: - case 227: - case 185: - case 159: + case 160: + case 151: case 150: - case 149: var parent = node.parent; if (node === parent.type) { return parent; @@ -34979,13 +36764,13 @@ var ts; continue; } var name = element.name; - if (name.kind === 70 && + if (name.kind === 71 && name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 174 || - name.kind === 173) { + else if (name.kind === 175 || + name.kind === 174) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -34993,20 +36778,29 @@ var ts; } } function checkSignatureDeclaration(node) { - if (node.kind === 156) { + if (node.kind === 157) { checkGrammarIndexSignature(node); } - else if (node.kind === 159 || node.kind === 227 || node.kind === 160 || - node.kind === 154 || node.kind === 151 || - node.kind === 155) { + else if (node.kind === 160 || node.kind === 228 || node.kind === 161 || + node.kind === 155 || node.kind === 152 || + node.kind === 156) { checkGrammarFunctionLikeDeclaration(node); } - if (ts.isAsyncFunctionLike(node) && languageVersion < 4) { + var functionFlags = ts.getFunctionFlags(node); + if ((functionFlags & 7) === 2 && languageVersion < 4) { checkExternalEmitHelpers(node, 64); if (languageVersion < 2) { checkExternalEmitHelpers(node, 128); } } + if ((functionFlags & 5) === 1) { + if (functionFlags & 2 && languageVersion < 4) { + checkExternalEmitHelpers(node, 2048); + } + else if (languageVersion < 2) { + checkExternalEmitHelpers(node, 128); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -35014,29 +36808,32 @@ var ts; } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { + if (noImplicitAny && !node.type) { switch (node.kind) { - case 155: + case 156: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 154: + case 155: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 && isSyntacticallyValidGenerator(node)) { + var functionFlags_1 = ts.getFunctionFlags(node); + if ((functionFlags_1 & 5) === 1) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + var generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags_1 & 2) !== 0) || anyType; + var iterableIteratorInstantiation = functionFlags_1 & 2 + ? createAsyncIterableIteratorType(generatorElementType) + : createIterableIteratorType(generatorElementType); checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if (ts.isAsyncFunctionLike(node)) { + else if ((functionFlags_1 & 3) === 2) { checkAsyncFunctionReturnType(node); } } @@ -35057,7 +36854,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151) { + if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -35071,16 +36868,16 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 152: + case 153: addName(names, member.name, memberName, 1); break; - case 153: + case 154: addName(names, member.name, memberName, 2); break; - case 148: + case 149: addName(names, member.name, memberName, 3); break; - case 150: + case 151: addName(names, member.name, memberName, 4); break; } @@ -35132,12 +36929,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 147) { + if (member.kind === 148) { var memberName = void 0; switch (member.name.kind) { case 9: case 8: - case 70: + case 71: memberName = member.name.text; break; default: @@ -35154,7 +36951,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 229) { + if (node.kind === 230) { var nodeSymbol = getSymbolOfNode(node); if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) { return; @@ -35169,7 +36966,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 135: + case 136: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -35177,7 +36974,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 132: + case 133: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -35233,15 +37030,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 98) { + if (n.kind === 99) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 185 && n.kind !== 227) { + else if (n.kind !== 186 && n.kind !== 228) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 148 && + return n.kind === 149 && !(ts.getModifierFlags(n) & 32) && !!n.initializer; } @@ -35261,7 +37058,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -35284,18 +37081,18 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 152) { + if (node.kind === 153) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128)) { if (!(node.flags & 256)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); } } } - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { - var otherKind = node.kind === 152 ? 153 : 152; + var otherKind = node.kind === 153 ? 154 : 153; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28) !== (ts.getModifierFlags(otherAccessor) & 28)) { @@ -35309,17 +37106,12 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 152) { + if (node.kind === 153) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 177) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - else { - checkNodeDeferred(node); - } + checkSourceElement(node.body); + registerForUnusedIdentifiersCheck(node); } function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { var firstType = getAnnotatedType(first); @@ -35328,10 +37120,6 @@ var ts; error(first, message); } } - function checkAccessorDeferred(node) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } function checkMissingDeclaration(node) { checkDecorators(node); } @@ -35428,9 +37216,9 @@ var ts; } function getEffectiveDeclarationFlags(n, flagsToCheck) { var flags = ts.getCombinedModifierFlags(n); - if (n.parent.kind !== 229 && - n.parent.kind !== 228 && - n.parent.kind !== 198 && + if (n.parent.kind !== 230 && + n.parent.kind !== 229 && + n.parent.kind !== 199 && ts.isInAmbientContext(n)) { if (!(flags & 2)) { flags |= 1; @@ -35507,7 +37295,7 @@ var ts; if (subsequentNode.kind === node.kind) { var errorNode_1 = subsequentNode.name || subsequentNode; if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 150 || node.kind === 149) && + var reportError = (node.kind === 151 || node.kind === 150) && (ts.getModifierFlags(node) & 32) !== (ts.getModifierFlags(subsequentNode) & 32); if (reportError) { var diagnostic = ts.getModifierFlags(node) & 32 ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static; @@ -35540,11 +37328,11 @@ var ts; var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 229 || node.parent.kind === 162 || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 230 || node.parent.kind === 163 || inAmbientContext; if (inAmbientContextOrInterface) { previousDeclaration = undefined; } - if (node.kind === 227 || node.kind === 150 || node.kind === 149 || node.kind === 151) { + if (node.kind === 228 || node.kind === 151 || node.kind === 150 || node.kind === 152) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -35595,8 +37383,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; + for (var _a = 0, signatures_4 = signatures; _a < signatures_4.length; _a++) { + var signature = signatures_4[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -35655,16 +37443,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 229: + case 230: return 2097152; - case 232: + case 233: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 ? 4194304 | 1048576 : 4194304; - case 228: - case 231: + case 229: + case 232: return 2097152 | 1048576; - case 236: + case 237: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -35674,40 +37462,30 @@ var ts; } } } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - var apparentType = getApparentType(type); - if ((apparentType.flags & (1 | 8192)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; + function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage) { + var promisedType = getPromisedTypeOfPromise(type, errorNode); + return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage); } - function getPromisedType(promise) { + function getPromisedTypeOfPromise(promise, errorNode) { if (isTypeAny(promise)) { return undefined; } - if (getObjectFlags(promise) & 4) { - if (promise.target === tryGetGlobalPromiseType() - || promise.target === getGlobalPromiseLikeType()) { - return promise.typeArguments[0]; - } + var typeAsPromise = promise; + if (typeAsPromise.promisedTypeOfPromise) { + return typeAsPromise.promisedTypeOfPromise; } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; + if (isReferenceToType(promise, getGlobalPromiseType(false))) { + return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (!thenFunction || isTypeAny(thenFunction)) { + if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = getSignaturesOfType(thenFunction, 0); + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : emptyArray; if (thenSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); + } return undefined; } var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288); @@ -35716,46 +37494,60 @@ var ts; } var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0); if (onfulfilledParameterSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); + } return undefined; } - return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), true); + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), true); } - function getTypeOfFirstParameterOfSignature(signature) { - return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + function checkAwaitedType(type, errorNode, diagnosticMessage) { + return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; } - function getAwaitedType(type) { - return checkAwaitedType(type, undefined, undefined); - } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 65536) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types, true); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } + function getAwaitedType(type, errorNode, diagnosticMessage) { + var typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } + if (isTypeAny(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + if (type.flags & 65536) { + var types = void 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types = ts.append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage)); + } + if (!types) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, true); + } + var promisedType = getPromisedTypeOfPromise(type); + if (promisedType) { + if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } + awaitedTypeStack.push(type.id); + var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage); + awaitedTypeStack.pop(); + if (!awaitedType) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = awaitedType; + } + var thenFunction = getTypeOfPropertyOfType(type, "then"); + if (thenFunction && getSignaturesOfType(thenFunction, 0).length > 0) { + if (errorNode) { + ts.Debug.assert(!!diagnosticMessage); + error(errorNode, diagnosticMessage); + } + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = type; } function checkAsyncFunctionReturnType(node) { var returnType = getTypeFromTypeNode(node.type); @@ -35763,8 +37555,8 @@ var ts; if (returnType === unknownType) { return unknownType; } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + var globalPromiseType = getGlobalPromiseType(true); + if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { error(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); return unknownType; } @@ -35782,7 +37574,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455, true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - if (promiseConstructorName.kind === 70 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + if (promiseConstructorName.kind === 71 && promiseConstructorName.text === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) { error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -35790,7 +37582,7 @@ var ts; } return unknownType; } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true); if (globalPromiseConstructorLikeType === emptyObjectType) { error(node.type, ts.Diagnostics.Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value, ts.entityNameToString(promiseConstructorName)); return unknownType; @@ -35805,7 +37597,7 @@ var ts; return unknownType; } } - return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkDecorator(node) { var signature = getResolvedSignature(node); @@ -35817,22 +37609,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 228: + case 229: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 145: + case 146: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any); break; - case 148: + case 149: expectedReturnType = voidType; errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any); break; - case 150: - case 152: + case 151: case 153: + case 154: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -35843,7 +37635,7 @@ var ts; function markTypeNodeAsReferenced(node) { var typeName = node && ts.getEntityNameFromTypeNode(node); var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 ? 793064 : 1920) | 8388608, undefined, undefined); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 71 ? 793064 : 1920) | 8388608, undefined, undefined); if (rootSymbol && rootSymbol.flags & 8388608 && symbolIsValue(rootSymbol) @@ -35866,13 +37658,13 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8); - if (node.kind === 145) { + if (node.kind === 146) { checkExternalEmitHelpers(firstDecorator, 32); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16); switch (node.kind) { - case 228: + case 229: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -35881,19 +37673,19 @@ var ts; } } break; - case 150: - case 152: + case 151: case 153: + case 154: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 148: + case 149: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 145: + case 146: markTypeNodeAsReferenced(node.type); break; } @@ -35913,8 +37705,8 @@ var ts; function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); - if (node.name && node.name.kind === 143) { + var functionFlags = ts.getFunctionFlags(node); + if (node.name && node.name.kind === 144) { checkComputedPropertyName(node.name); } if (!ts.hasDynamicName(node)) { @@ -35932,15 +37724,17 @@ var ts; } } checkSourceElement(node.body); - if (!node.asteriskToken) { - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if ((functionFlags & 1) === 0) { + var returnOrPromisedType = node.type && (functionFlags & 2 + ? checkAsyncFunctionReturnType(node) + : getTypeFromTypeNode(node.type)); checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (produceDiagnostics && !node.type) { - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + if (functionFlags & 1 && ts.nodeIsPresent(node.body)) { getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } } @@ -35956,55 +37750,54 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 264: - case 232: + case 265: + case 233: checkUnusedModuleMembers(node); break; - case 228: - case 198: + case 229: + case 199: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 229: + case 230: checkUnusedTypeParameters(node); break; - case 206: - case 234: - case 213: + case 207: + case 235: case 214: case 215: + case 216: checkUnusedLocalsAndParameters(node); break; - case 151: - case 185: - case 227: - case 186: - case 150: case 152: + case 186: + case 228: + case 187: + case 151: case 153: + case 154: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 149: - case 154: + case 150: case 155: case 156: - case 159: + case 157: case 160: + case 161: checkUnusedTypeParameters(node); break; } - ; } } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 229 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 230 && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 146) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -36030,13 +37823,13 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 225 && - (declaration.parent.parent.kind === 214 || - declaration.parent.parent.kind === 215)) { + if (declaration.kind === 226 && + (declaration.parent.parent.kind === 215 || + declaration.parent.parent.kind === 216)) { return; } } - if (!isRemovedPropertyFromObjectSpread(node.kind === 70 ? node.parent : node)) { + if (!isRemovedPropertyFromObjectSpread(node.kind === 71 ? node.parent : node)) { error(node, ts.Diagnostics._0_is_declared_but_never_used, name); } } @@ -36044,19 +37837,19 @@ var ts; return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); } function isIdentifierThatStartsWithUnderScore(node) { - return node.kind === 70 && node.text.charCodeAt(0) === 95; + return node.kind === 71 && node.text.charCodeAt(0) === 95; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 || member.kind === 148) { + if (member.kind === 151 || member.kind === 149) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 151) { + else if (member.kind === 152) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8) { @@ -36100,7 +37893,7 @@ var ts; } } function checkBlock(node) { - if (node.kind === 206) { + if (node.kind === 207) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -36122,19 +37915,19 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 148 || - node.kind === 147 || + if (node.kind === 149 || + node.kind === 148 || + node.kind === 151 || node.kind === 150 || - node.kind === 149 || - node.kind === 152 || - node.kind === 153) { + node.kind === 153 || + node.kind === 154) { return false; } if (ts.isInAmbientContext(node)) { return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 145 && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 146 && ts.nodeIsMissing(root.parent.body)) { return false; } return true; @@ -36150,36 +37943,32 @@ var ts; } } function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4) { - var isDeclaration_1 = node.kind !== 70; + var isDeclaration_1 = node.kind !== 71; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8) { - var isDeclaration_2 = node.kind !== 70; + var isDeclaration_2 = node.kind !== 71; if (isDeclaration_2) { error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { @@ -36190,7 +37979,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_3 = node.kind !== 70; + var isDeclaration_3 = node.kind !== 71; if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -36206,11 +37995,11 @@ var ts; if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) { return; } - if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 233 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 265 && 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)); } } @@ -36218,11 +38007,11 @@ var ts; if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) { return; } - if (node.kind === 232 && ts.getModuleInstanceState(node) !== 1) { + if (node.kind === 233 && ts.getModuleInstanceState(node) !== 1) { return; } var parent = getDeclarationContainer(node); - if (parent.kind === 264 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { + if (parent.kind === 265 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024) { 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)); } } @@ -36230,7 +38019,7 @@ var ts; if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) { return; } - if (node.kind === 225 && !node.initializer) { + if (node.kind === 226 && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -36240,15 +38029,15 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226); - var container = varDeclList.parent.kind === 207 && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 227); + var container = varDeclList.parent.kind === 208 && varDeclList.parent.parent ? varDeclList.parent.parent : undefined; var namesShareScope = container && - (container.kind === 206 && ts.isFunctionLike(container.parent) || + (container.kind === 207 && ts.isFunctionLike(container.parent) || + container.kind === 234 || container.kind === 233 || - container.kind === 232 || - container.kind === 264); + container.kind === 265); if (!namesShareScope) { var name = symbolToString(localDeclarationSymbol); error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name); @@ -36258,7 +38047,7 @@ var ts; } } function checkParameterInitializer(node) { - if (ts.getRootDeclaration(node).kind !== 145) { + if (ts.getRootDeclaration(node).kind !== 146) { return; } var func = ts.getContainingFunction(node); @@ -36267,10 +38056,10 @@ var ts; if (ts.isTypeNode(n) || ts.isDeclarationName(n)) { return; } - if (n.kind === 178) { + if (n.kind === 179) { return visit(n.expression); } - else if (n.kind === 70) { + else if (n.kind === 71) { var symbol = resolveName(n, n.text, 107455 | 8388608, undefined, undefined); if (!symbol || symbol === unknownSymbol || !symbol.valueDeclaration) { return; @@ -36281,22 +38070,21 @@ var ts; } var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 145 || - symbol.valueDeclaration.kind === 175) { + if (symbol.valueDeclaration.kind === 146 || + symbol.valueDeclaration.kind === 176) { if (symbol.valueDeclaration.pos < node.pos) { return; } - var current = n; - while (current !== node.initializer) { - if (ts.isFunctionLike(current.parent)) { - return; + if (ts.findAncestor(n, function (current) { + if (current === node.initializer) { + return "quit"; } - if (current.parent.kind === 148 && - !(ts.hasModifier(current.parent, 32)) && - ts.isClassLike(current.parent.parent)) { - return; - } - current = current.parent; + return ts.isFunctionLike(current.parent) || + (current.parent.kind === 149 && + !(ts.hasModifier(current.parent, 32)) && + ts.isClassLike(current.parent.parent)); + })) { + return; } } error(n, ts.Diagnostics.Initializer_of_parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(node.name), ts.declarationNameToString(n)); @@ -36313,17 +38101,17 @@ var ts; function checkVariableLikeDeclaration(node) { checkDecorators(node); checkSourceElement(node.type); - if (node.name.kind === 143) { + if (node.name.kind === 144) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 175) { - if (node.parent.kind === 173 && languageVersion < 5 && !ts.isInAmbientContext(node)) { + if (node.kind === 176) { + if (node.parent.kind === 174 && languageVersion < 5) { checkExternalEmitHelpers(node, 4); } - if (node.propertyName && node.propertyName.kind === 143) { + if (node.propertyName && node.propertyName.kind === 144) { checkComputedPropertyName(node.propertyName); } var parent = node.parent.parent; @@ -36336,14 +38124,17 @@ var ts; } } if (ts.isBindingPattern(node.name)) { + if (node.name.kind === 175 && languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512); + } ts.forEach(node.name.elements, checkSourceElement); } - if (node.initializer && ts.getRootDeclaration(node).kind === 145 && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 146 && 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 !== 214) { + if (node.initializer && node.parent.parent.kind !== 215) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, undefined); checkParameterInitializer(node); } @@ -36352,7 +38143,7 @@ var ts; var symbol = getSymbolOfNode(node); var type = convertAutoToAny(getTypeOfVariableOrParameterOrProperty(symbol)); if (node === symbol.valueDeclaration) { - if (node.initializer && node.parent.parent.kind !== 214) { + if (node.initializer && node.parent.parent.kind !== 215) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, undefined); checkParameterInitializer(node); } @@ -36370,9 +38161,9 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 148 && node.kind !== 147) { + if (node.kind !== 149 && node.kind !== 148) { checkExportsOnMergedDeclarations(node); - if (node.kind === 225 || node.kind === 175) { + if (node.kind === 226 || node.kind === 176) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -36383,8 +38174,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 145 && right.kind === 225) || - (left.kind === 225 && right.kind === 145)) { + if ((left.kind === 146 && right.kind === 226) || + (left.kind === 226 && right.kind === 146)) { return true; } if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) { @@ -36411,8 +38202,8 @@ var ts; ts.forEach(node.declarationList.declarations, checkSourceElement); } function checkGrammarDisallowedModifiersOnObjectLiteralExpressionMethod(node) { - if (node.modifiers && node.parent.kind === 177) { - if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers && node.parent.kind === 178) { + if (ts.getFunctionFlags(node) & 2) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -36430,7 +38221,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 208) { + if (node.thenStatement.kind === 209) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -36447,12 +38238,12 @@ var ts; } function checkForStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 226) { + if (node.initializer && node.initializer.kind === 227) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 226) { + if (node.initializer.kind === 227) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -36470,13 +38261,23 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); - if (node.initializer.kind === 226) { + if (node.kind === 216) { + if (node.awaitModifier) { + if (languageVersion < 4) { + checkExternalEmitHelpers(node, 8192); + } + } + else if (languageVersion < 2 && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256); + } + } + if (node.initializer.kind === 227) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); - if (varExpr.kind === 176 || varExpr.kind === 177) { + var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); + if (varExpr.kind === 177 || varExpr.kind === 178) { checkDestructuringAssignment(varExpr, iteratedType || unknownType); } else { @@ -36495,7 +38296,7 @@ var ts; function checkForInStatement(node) { checkGrammarForInOrForOfStatement(node); var rightType = checkNonNullExpression(node.expression); - if (node.initializer.kind === 226) { + if (node.initializer.kind === 227) { 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); @@ -36505,7 +38306,7 @@ var ts; else { var varExpr = node.initializer; var leftType = checkExpression(varExpr); - if (varExpr.kind === 176 || varExpr.kind === 177) { + if (varExpr.kind === 177 || varExpr.kind === 178) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -36515,7 +38316,7 @@ var ts; checkReferenceExpression(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access); } } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 | 540672 | 16777216)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -36530,146 +38331,67 @@ var ts; checkVariableDeclaration(decl); } } - function checkRightHandSideOfForOf(rhsExpression) { + function checkRightHandSideOfForOf(rhsExpression, awaitModifier) { var expressionType = checkNonNullExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable) { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1); - if (indexType) { - return indexType; - } - } - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - } - return unknownType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, true) || anyType; } - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); - } - return elementType || anyType; - } - function getElementTypeOfIterable(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableType()) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature), true), errorNode); + function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, checkAssignability) { + var uplevelIteration = languageVersion >= 2; + var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + var iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + if (iteratedType || uplevelIteration) { + return iteratedType; } } - return typeAsIterable.iterableElementType; - } - function getElementTypeOfIterator(type, errorNode) { - if (isTypeAny(type)) { - return undefined; - } - var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - if ((getObjectFlags(type) & 4) && type.target === getGlobalIteratorType()) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature), true); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } - } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { - return undefined; - } - if ((getObjectFlags(type) & 4) && type.target === getGlobalIterableIteratorType()) { - return type.typeArguments[0]; - } - return getElementTypeOfIterable(type, undefined) || - getElementTypeOfIterator(type, undefined); - } - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2); - var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 65536) { - var arrayTypes = arrayOrStringType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); - if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, true); - } - } - else if (arrayOrStringType.flags & 262178) { - arrayType = neverType; - } - var hasStringConstituent = arrayOrStringType !== arrayType; + var arrayType = inputType; var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; + var hasStringConstituent = false; + if (allowStringInput) { + if (arrayType.flags & 65536) { + var arrayTypes = inputType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, true); + } } - if (arrayType.flags & 8192) { - return stringType; + else if (arrayType.flags & 262178) { + arrayType = neverType; + } + hasStringConstituent = arrayType !== inputType; + if (hasStringConstituent) { + if (languageVersion < 1) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + } + if (arrayType.flags & 8192) { + return stringType; + } } } if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + if (errorNode && !reportedError) { + var diagnostic = !allowStringInput || hasStringConstituent + ? downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type + : downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; error(errorNode, diagnostic, typeToString(arrayType)); } - return hasStringConstituent ? stringType : unknownType; + return hasStringConstituent ? stringType : undefined; } - var arrayElementType = getIndexTypeOfType(arrayType, 1) || unknownType; - if (hasStringConstituent) { + var arrayElementType = getIndexTypeOfType(arrayType, 1); + if (hasStringConstituent && arrayElementType) { if (arrayElementType.flags & 262178) { return stringType; } @@ -36677,14 +38399,131 @@ var ts; } return arrayElementType; } + function getIteratedTypeOfIterable(type, errorNode, isAsyncIterable, allowNonAsyncIterables, checkAssignability) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterable = type; + if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { + return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; + } + if (isAsyncIterable) { + if (isReferenceToType(type, getGlobalAsyncIterableType(false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0]; + } + } + if (!isAsyncIterable || allowNonAsyncIterables) { + if (isReferenceToType(type, getGlobalIterableType(false)) || + isReferenceToType(type, getGlobalIterableIteratorType(false))) { + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0] + : typeAsIterable.iteratedTypeOfIterable = type.typeArguments[0]; + } + } + var iteratorMethodSignatures; + var isNonAsyncIterable = false; + if (isAsyncIterable) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); + } + if (!isAsyncIterable || (allowNonAsyncIterables && !ts.some(iteratorMethodSignatures))) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0); + isNonAsyncIterable = true; + } + if (ts.some(iteratorMethodSignatures)) { + var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), true); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, !isNonAsyncIterable); + if (checkAssignability && errorNode && iteratedType) { + checkTypeAssignableTo(type, isNonAsyncIterable + ? createIterableType(iteratedType) + : createAsyncIterableType(iteratedType), errorNode); + } + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType + : typeAsIterable.iteratedTypeOfIterable = iteratedType; + } + if (errorNode) { + error(errorNode, isAsyncIterable + ? ts.Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; + } + function getIteratedTypeOfIterator(type, errorNode, isAsyncIterator) { + if (isTypeAny(type)) { + return undefined; + } + var typeAsIterator = type; + if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { + return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; + } + var getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; + if (isReferenceToType(type, getIteratorType(false))) { + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = type.typeArguments[0] + : typeAsIterator.iteratedTypeOfIterator = type.typeArguments[0]; + } + var nextMethod = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(nextMethod)) { + return undefined; + } + var nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, 0) : emptyArray; + if (nextMethodSignatures.length === 0) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.An_async_iterator_must_have_a_next_method + : ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; + } + var nextResult = getUnionType(ts.map(nextMethodSignatures, getReturnTypeOfSignature), true); + if (isTypeAny(nextResult)) { + return undefined; + } + if (isAsyncIterator) { + nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); + if (isTypeAny(nextResult)) { + return undefined; + } + } + var nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value"); + if (!nextValue) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue + : typeAsIterator.iteratedTypeOfIterator = nextValue; + } + function getIteratedTypeOfGenerator(returnType, isAsyncGenerator) { + if (isTypeAny(returnType)) { + return undefined; + } + return getIteratedTypeOfIterable(returnType, undefined, isAsyncGenerator, false, false) + || getIteratedTypeOfIterator(returnType, undefined, isAsyncGenerator); + } function checkBreakOrContinueStatement(node) { checkGrammarStatementInAmbientContext(node) || checkGrammarBreakOrContinueStatement(node); } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 152 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153))); + return !!(node.kind === 153 && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 154))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { - var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; + var unwrappedReturnType = (ts.getFunctionFlags(func) & 3) === 2 + ? getPromisedTypeOfPromise(returnType) + : returnType; return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 1024 | 1); } function checkReturnStatement(node) { @@ -36700,23 +38539,24 @@ var ts; var returnType = getReturnTypeOfSignature(signature); if (strictNullChecks || node.expression || returnType.flags & 8192) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.asteriskToken) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1) { return; } - if (func.kind === 153) { + if (func.kind === 154) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 151) { + else if (func.kind === 152) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (functionFlags & 2) { + var promisedType = getPromisedTypeOfPromise(returnType); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); if (promisedType) { checkTypeAssignableTo(awaitedType, promisedType, node); } @@ -36726,7 +38566,7 @@ var ts; } } } - else if (func.kind !== 151 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 152 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } } @@ -36752,7 +38592,7 @@ var ts; var expressionType = checkExpression(node.expression); var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { - if (clause.kind === 257 && !hasDuplicateDefaultClause) { + if (clause.kind === 258 && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -36764,7 +38604,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 256) { + if (produceDiagnostics && clause.kind === 257) { var caseClause = clause; var caseType = checkExpression(caseClause.expression); var caseIsLiteral = isLiteralType(caseType); @@ -36785,18 +38625,16 @@ var ts; } function checkLabeledStatement(node) { if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { + ts.findAncestor(node.parent, function (current) { if (ts.isFunctionLike(current)) { - break; + return "quit"; } - if (current.kind === 221 && current.label.text === node.label.text) { + if (current.kind === 222 && 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; + return true; } - current = current.parent; - } + }); } checkSourceElement(node.statement); } @@ -36883,7 +38721,7 @@ var ts; return; } var errorNode; - if (propDeclaration && (propDeclaration.name.kind === 143 || prop.parent === containingType.symbol)) { + if (propDeclaration && (propDeclaration.name.kind === 144 || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { @@ -37004,7 +38842,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); @@ -37026,7 +38864,7 @@ var ts; } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (languageVersion < 2 && !ts.isInAmbientContext(node)) { + if (languageVersion < 2) { checkExternalEmitHelpers(baseTypeNode.parent, 1); } var baseTypes = getBaseTypes(type); @@ -37038,7 +38876,7 @@ var ts; checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { var constructor = _a[_i]; if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; @@ -37050,15 +38888,8 @@ var ts; if (baseConstructorType.flags & 540672 && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && - !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 228) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { - error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 540672)) { - var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); 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); } @@ -37112,7 +38943,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 228 || d.kind === 229; + return d.kind === 229 || d.kind === 230; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -37130,7 +38961,7 @@ var ts; if (derived === base) { var derivedClassDecl = getClassLikeDeclarationOfSymbol(type.symbol); if (baseDeclarationFlags & 128 && (!derivedClassDecl || !(ts.getModifierFlags(derivedClassDecl) & 128))) { - if (derivedClassDecl.kind === 198) { + if (derivedClassDecl.kind === 199) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -37140,41 +38971,37 @@ var ts; } else { var derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 8) || (derivedDeclarationFlags & 8)) { + if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) { continue; } if ((baseDeclarationFlags & 32) !== (derivedDeclarationFlags & 32)) { continue; } - if ((base.flags & derived.flags & 8192) || ((base.flags & 98308) && (derived.flags & 98308))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & 98308 && derived.flags & 98308) { continue; } var errorMessage = void 0; - if (base.flags & 8192) { + if (isMethodLike(base)) { if (derived.flags & 98304) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert((derived.flags & 4) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4) { - ts.Debug.assert((derived.flags & 8192) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304) !== 0); - ts.Debug.assert((derived.flags & 8192) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } } function isAccessor(kind) { - return kind === 152 || kind === 153; + return kind === 153 || kind === 154; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -37187,8 +39014,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.name); if (!existing) { seen.set(prop.name, { prop: prop, containingType: base }); @@ -37216,7 +39043,7 @@ var ts; checkExportsOnMergedDeclarations(node); var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 230); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -37312,18 +39139,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 191: + case 192: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 36: return value_1; - case 37: return -value_1; - case 51: return ~value_1; + case 37: return value_1; + case 38: return -value_1; + case 52: return ~value_1; } return undefined; - case 193: + case 194: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -37333,38 +39160,38 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 48: return left | right; - case 47: return left & right; - case 45: return left >> right; - case 46: return left >>> right; - case 44: return left << right; - case 49: return left ^ right; - case 38: return left * right; - case 40: return left / right; - case 36: return left + right; - case 37: return left - right; - case 41: return left % right; + case 49: return left | right; + case 48: return left & right; + case 46: return left >> right; + case 47: return left >>> right; + case 45: return left << right; + case 50: return left ^ right; + case 39: return left * right; + case 41: return left / right; + case 37: return left + right; + case 38: return left - right; + case 42: return left % right; } return undefined; case 8: checkGrammarNumericLiteral(e); return +e.text; - case 184: + case 185: return evalConstant(e.expression); - case 70: + case 71: + case 180: case 179: - case 178: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 70) { + if (e.kind === 71) { enumType_1 = currentType; propertyName = e.text; } else { var expression = void 0; - if (e.kind === 179) { + if (e.kind === 180) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9) { return undefined; @@ -37378,10 +39205,10 @@ var ts; } var current = expression; while (current) { - if (current.kind === 70) { + if (current.kind === 71) { break; } - else if (current.kind === 178) { + else if (current.kind === 179) { current = current.expression; } else { @@ -37442,7 +39269,7 @@ var ts; } var seenEnumMissingInitialInitializer_1 = false; ts.forEach(enumSymbol.declarations, function (declaration) { - if (declaration.kind !== 231) { + if (declaration.kind !== 232) { return false; } var enumDeclaration = declaration; @@ -37465,8 +39292,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 228 || - (declaration.kind === 227 && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 229 || + (declaration.kind === 228 && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -37525,7 +39352,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, 228); + var mergedClass = ts.getDeclarationOfKind(symbol, 229); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768; @@ -37568,22 +39395,22 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 207: + case 208: for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { var decl = _a[_i]; checkModuleAugmentationElement(decl, isGlobalAugmentation); } break; - case 242: case 243: + case 244: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 236: case 237: + case 238: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 175: - case 225: + case 176: + case 226: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -37592,12 +39419,12 @@ var ts; } break; } - case 228: - case 231: - case 227: case 229: case 232: + case 228: case 230: + case 233: + case 231: if (isGlobalAugmentation) { return; } @@ -37613,17 +39440,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 70: + case 71: return node; - case 142: + case 143: do { node = node.left; - } while (node.kind !== 70); + } while (node.kind !== 71); return node; - case 178: + case 179: do { node = node.expression; - } while (node.kind !== 70); + } while (node.kind !== 71); return node; } } @@ -37633,9 +39460,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 264 && !inAmbientExternalModule) { - error(moduleName, node.kind === 243 ? + var inAmbientExternalModule = node.parent.kind === 234 && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 265 && !inAmbientExternalModule) { + error(moduleName, node.kind === 244 ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -37656,7 +39483,7 @@ var ts; (symbol.flags & 793064 ? 793064 : 0) | (symbol.flags & 1920 ? 1920 : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 245 ? + var message = node.kind === 246 ? 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)); @@ -37683,7 +39510,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239) { + if (importClause.namedBindings.kind === 240) { checkImportBinding(importClause.namedBindings); } else { @@ -37734,10 +39561,10 @@ var ts; if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) { if (node.exportClause) { ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 233 && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 && + var inAmbientExternalModule = node.parent.kind === 234 && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 234 && !node.moduleSpecifier && ts.isInAmbientContext(node); - if (node.parent.kind !== 264 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 265 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -37750,7 +39577,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 264 || node.parent.kind === 233 || node.parent.kind === 232; + var isInAppropriateContext = node.parent.kind === 265 || node.parent.kind === 234 || node.parent.kind === 233; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -37773,8 +39600,8 @@ var ts; if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) { return; } - var container = node.parent.kind === 264 ? node.parent : node.parent.parent; - if (container.kind === 232 && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 265 ? node.parent : node.parent.parent; + if (container.kind === 233 && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -37786,7 +39613,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { markExportAsReferenced(node); } else { @@ -37816,8 +39643,8 @@ var ts; error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements); } } - var exports_1 = getExportsOfModule(moduleSymbol); - exports_1 && exports_1.forEach(function (_a, id) { + var exports = getExportsOfModule(moduleSymbol); + exports && exports.forEach(function (_a, id) { var declarations = _a.declarations, flags = _a.flags; if (id === "__export") { return; @@ -37841,7 +39668,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 227 && declaration.kind !== 150) || + return (declaration.kind !== 228 && declaration.kind !== 151) || !!declaration.body; } } @@ -37852,123 +39679,123 @@ var ts; var kind = node.kind; if (cancellationToken) { switch (kind) { - case 232: - case 228: + case 233: case 229: - case 227: + case 230: + case 228: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 144: - return checkTypeParameter(node); case 145: + return checkTypeParameter(node); + case 146: return checkParameter(node); + case 149: case 148: - case 147: return checkPropertyDeclaration(node); - case 159: case 160: - case 154: + case 161: case 155: - return checkSignatureDeclaration(node); case 156: return checkSignatureDeclaration(node); - case 150: - case 149: - return checkMethodDeclaration(node); - case 151: - return checkConstructorDeclaration(node); - case 152: - case 153: - return checkAccessorDeclaration(node); - case 158: - return checkTypeReferenceNode(node); case 157: + return checkSignatureDeclaration(node); + case 151: + case 150: + return checkMethodDeclaration(node); + case 152: + return checkConstructorDeclaration(node); + case 153: + case 154: + return checkAccessorDeclaration(node); + case 159: + return checkTypeReferenceNode(node); + case 158: return checkTypePredicate(node); - case 161: - return checkTypeQuery(node); case 162: - return checkTypeLiteral(node); + return checkTypeQuery(node); case 163: - return checkArrayType(node); + return checkTypeLiteral(node); case 164: - return checkTupleType(node); + return checkArrayType(node); case 165: + return checkTupleType(node); case 166: - return checkUnionOrIntersectionType(node); case 167: - case 169: - return checkSourceElement(node.type); + return checkUnionOrIntersectionType(node); + case 168: case 170: - return checkIndexedAccessType(node); + return checkSourceElement(node.type); case 171: + return checkIndexedAccessType(node); + case 172: return checkMappedType(node); - case 227: - return checkFunctionDeclaration(node); - case 206: - case 233: - return checkBlock(node); - case 207: - return checkVariableStatement(node); - case 209: - return checkExpressionStatement(node); - case 210: - return checkIfStatement(node); - case 211: - return checkDoStatement(node); - case 212: - return checkWhileStatement(node); - case 213: - return checkForStatement(node); - case 214: - return checkForInStatement(node); - case 215: - return checkForOfStatement(node); - case 216: - case 217: - return checkBreakOrContinueStatement(node); - case 218: - return checkReturnStatement(node); - case 219: - return checkWithStatement(node); - case 220: - return checkSwitchStatement(node); - case 221: - return checkLabeledStatement(node); - case 222: - return checkThrowStatement(node); - case 223: - return checkTryStatement(node); - case 225: - return checkVariableDeclaration(node); - case 175: - return checkBindingElement(node); case 228: - return checkClassDeclaration(node); - case 229: - return checkInterfaceDeclaration(node); - case 230: - return checkTypeAliasDeclaration(node); - case 231: - return checkEnumDeclaration(node); - case 232: - return checkModuleDeclaration(node); - case 237: - return checkImportDeclaration(node); - case 236: - return checkImportEqualsDeclaration(node); - case 243: - return checkExportDeclaration(node); - case 242: - return checkExportAssignment(node); + return checkFunctionDeclaration(node); + case 207: + case 234: + return checkBlock(node); case 208: - checkGrammarStatementInAmbientContext(node); - return; + return checkVariableStatement(node); + case 210: + return checkExpressionStatement(node); + case 211: + return checkIfStatement(node); + case 212: + return checkDoStatement(node); + case 213: + return checkWhileStatement(node); + case 214: + return checkForStatement(node); + case 215: + return checkForInStatement(node); + case 216: + return checkForOfStatement(node); + case 217: + case 218: + return checkBreakOrContinueStatement(node); + case 219: + return checkReturnStatement(node); + case 220: + return checkWithStatement(node); + case 221: + return checkSwitchStatement(node); + case 222: + return checkLabeledStatement(node); + case 223: + return checkThrowStatement(node); case 224: + return checkTryStatement(node); + case 226: + return checkVariableDeclaration(node); + case 176: + return checkBindingElement(node); + case 229: + return checkClassDeclaration(node); + case 230: + return checkInterfaceDeclaration(node); + case 231: + return checkTypeAliasDeclaration(node); + case 232: + return checkEnumDeclaration(node); + case 233: + return checkModuleDeclaration(node); + case 238: + return checkImportDeclaration(node); + case 237: + return checkImportEqualsDeclaration(node); + case 244: + return checkExportDeclaration(node); + case 243: + return checkExportAssignment(node); + case 209: checkGrammarStatementInAmbientContext(node); return; - case 246: + case 225: + checkGrammarStatementInAmbientContext(node); + return; + case 247: return checkMissingDeclaration(node); } } @@ -37981,17 +39808,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 185: case 186: + case 187: + case 151: case 150: - case 149: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 152: case 153: - checkAccessorDeferred(node); + case 154: + checkAccessorDeclaration(node); break; - case 198: + case 199: checkClassExpressionDeferred(node); break; } @@ -38079,7 +39906,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 219 && node.parent.statement === node) { + if (node.parent.kind === 220 && node.parent.statement === node) { return true; } node = node.parent; @@ -38088,11 +39915,11 @@ var ts; return false; } function getSymbolsInScope(location, meaning) { - var symbols = ts.createMap(); - var memberFlags = 0; if (isInsideWithStatementBody(location)) { return []; } + var symbols = ts.createMap(); + var memberFlags = 0; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -38101,28 +39928,28 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 264: + case 265: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232: + case 233: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931); break; - case 231: + case 232: copySymbols(getSymbolOfNode(location).exports, meaning & 8); break; - case 198: + case 199: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - case 228: case 229: + case 230: if (!(memberFlags & 32)) { copySymbols(getSymbolOfNode(location).members, meaning & 793064); } break; - case 185: + case 186: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -38154,33 +39981,33 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 70 && + return name.kind === 71 && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 144: - case 228: + case 145: case 229: case 230: case 231: + case 232: return true; } } function isTypeReferenceIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 142) { + while (node.parent && node.parent.kind === 143) { node = node.parent; } - return node.parent && (node.parent.kind === 158 || node.parent.kind === 276); + return node.parent && (node.parent.kind === 159 || node.parent.kind === 277); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 178) { + while (node.parent && node.parent.kind === 179) { node = node.parent; } - return node.parent && node.parent.kind === 200; + return node.parent && node.parent.kind === 201; } function forEachEnclosingClass(node, callback) { var result; @@ -38197,13 +40024,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 142) { + while (nodeOnRightSide.parent.kind === 143) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236) { + if (nodeOnRightSide.parent.kind === 237) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242) { + if (nodeOnRightSide.parent.kind === 243) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -38211,27 +40038,35 @@ var ts; function isInRightSideOfImportOrExportAssignment(node) { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } + function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { + var specialPropertyAssignmentKind = ts.getSpecialPropertyAssignmentKind(entityName.parent.parent); + switch (specialPropertyAssignmentKind) { + case 1: + case 3: + return getSymbolOfNode(entityName.parent); + case 4: + case 2: + case 5: + return getSymbolOfNode(entityName.parent.parent); + } + } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178) { - 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 (ts.isInJavaScriptFile(entityName) && + entityName.parent.kind === 179 && + entityName.parent === entityName.parent.parent.left) { + var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); + if (specialPropertyAssignmentSymbol) { + return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 242 && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 243 && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, 107455 | 793064 | 1920 | 8388608); } - if (entityName.kind !== 178 && isInRightSideOfImportOrExportAssignment(entityName)) { - var importEqualsDeclaration = ts.getAncestor(entityName, 236); + if (entityName.kind !== 179 && isInRightSideOfImportOrExportAssignment(entityName)) { + var importEqualsDeclaration = ts.getAncestor(entityName, 237); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, true); } @@ -38240,7 +40075,7 @@ var ts; } if (isHeritageClauseElementIdentifier(entityName)) { var meaning = 0; - if (entityName.parent.kind === 200) { + if (entityName.parent.kind === 201) { meaning = 793064; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { meaning |= 107455; @@ -38250,26 +40085,29 @@ var ts; meaning = 1920; } meaning |= 8388608; - return resolveEntityName(entityName, meaning); + var entityNameSymbol = resolveEntityName(entityName, meaning); + if (entityNameSymbol) { + return entityNameSymbol; + } } - else if (ts.isPartOfExpression(entityName)) { + if (ts.isPartOfExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { return undefined; } - if (entityName.kind === 70) { + if (entityName.kind === 71) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455, false, true); } - else if (entityName.kind === 178) { + else if (entityName.kind === 179) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 142) { + else if (entityName.kind === 143) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -38278,19 +40116,19 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 158 || entityName.parent.kind === 276) ? 793064 : 1920; + var meaning = (entityName.parent.kind === 159 || entityName.parent.kind === 277) ? 793064 : 1920; return resolveEntityName(entityName, meaning, false, true); } - else if (entityName.parent.kind === 252) { + else if (entityName.parent.kind === 253) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 157) { + if (entityName.parent.kind === 158) { return resolveEntityName(entityName, 1); } return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 264) { + if (node.kind === 265) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -38302,12 +40140,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 70) { + if (node.kind === 71) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 175 && - node.parent.parent.kind === 173 && + else if (node.parent.kind === 176 && + node.parent.parent.kind === 174 && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -38317,11 +40155,11 @@ var ts; } } switch (node.kind) { - case 70: - case 178: - case 142: + case 71: + case 179: + case 143: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 98: + case 99: var container = ts.getThisContainer(node, false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -38329,21 +40167,21 @@ var ts; return sig.thisParameter; } } - case 96: + case 97: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 168: + case 169: return getTypeFromTypeNode(node).symbol; - case 122: + case 123: var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 151) { + if (constructorDeclaration && constructorDeclaration.kind === 152) { return constructorDeclaration.parent.symbol; } return undefined; case 9: if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 237 || node.parent.kind === 243) && + ((node.parent.kind === 238 || node.parent.kind === 244) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } @@ -38351,7 +40189,7 @@ var ts; return resolveExternalModuleName(node, node); } case 8: - if (node.parent.kind === 179 && node.parent.argumentExpression === node) { + if (node.parent.kind === 180 && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -38365,7 +40203,7 @@ var ts; return undefined; } function getShorthandAssignmentValueSymbol(location) { - if (location && location.kind === 261) { + if (location && location.kind === 262) { return resolveEntityName(location.name, 107455 | 8388608); } return undefined; @@ -38380,13 +40218,22 @@ var ts; return unknownType; } if (ts.isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + var typeFromTypeNode = getTypeFromTypeNode(node); + if (typeFromTypeNode && ts.isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + var containingClass = ts.getContainingClass(node); + var classType = getTypeOfNode(containingClass); + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + return typeFromTypeNode; } if (ts.isPartOfExpression(node)) { return getRegularTypeOfExpression(node); } if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + var classNode = ts.getContainingClass(node); + var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)); + var baseType = getBaseTypes(classType)[0]; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { var symbol = getSymbolOfNode(node); @@ -38415,22 +40262,22 @@ var ts; return unknownType; } function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 177 || expr.kind === 176); - if (expr.parent.kind === 215) { - var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); + ts.Debug.assert(expr.kind === 178 || expr.kind === 177); + if (expr.parent.kind === 216) { + var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 193) { + if (expr.parent.kind === 194) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } - if (expr.parent.kind === 260) { + if (expr.parent.kind === 261) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } - ts.Debug.assert(expr.parent.kind === 176); + ts.Debug.assert(expr.parent.kind === 177); var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false) || unknownType; + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, false, false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); } function getPropertySymbolOfDestructuringAssignment(location) { @@ -38462,7 +40309,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (getCheckFlags(symbol) & 2) { + if (getCheckFlags(symbol) & 6) { var symbols_3 = []; var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { @@ -38476,10 +40323,10 @@ var ts; else if (symbol.flags & 134217728) { if (symbol.leftSpread) { var links = symbol; - return [links.leftSpread, links.rightSpread]; + return getRootSymbols(links.leftSpread).concat(getRootSymbols(links.rightSpread)); } - if (symbol.mappedTypeOrigin) { - return getRootSymbols(symbol.mappedTypeOrigin); + if (symbol.syntheticOrigin) { + return getRootSymbols(symbol.syntheticOrigin); } var target = void 0; var next = symbol; @@ -38496,7 +40343,7 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 178 && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 179 && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -38537,19 +40384,15 @@ var ts; } symbol = exportSymbol; } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 && parentSymbol.valueDeclaration.kind === 264) { - var symbolFile = parentSymbol.valueDeclaration; + var parentSymbol_1 = getParentOfSymbol(symbol); + if (parentSymbol_1) { + if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 265) { + var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); var symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - for (var n = node.parent; n; n = n.parent) { - if (ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } + return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; }); } } } @@ -38577,7 +40420,7 @@ var ts; else if (nodeLinks_1.flags & 131072) { var isDeclaredInLoop = nodeLinks_1.flags & 262144; var inLoopInitializer = ts.isIterationStatement(container, false); - var inLoopBodyBlock = container.kind === 206 && ts.isIterationStatement(container.parent, false); + var inLoopBodyBlock = container.kind === 207 && ts.isIterationStatement(container.parent, false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -38612,23 +40455,19 @@ var ts; return false; } function isValueAliasDeclaration(node) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - return true; - } switch (node.kind) { - case 236: - case 238: + case 237: case 239: - case 241: - case 245: + case 240: + case 242: + case 246: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 243: + case 244: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 242: + case 243: return node.expression - && node.expression.kind === 70 + && node.expression.kind === 71 ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -38636,7 +40475,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 264 || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 265 || !ts.isInternalModuleImportEqualsDeclaration(node)) { return false; } var isValue = isAliasResolvedToValue(getSymbolOfNode(node)); @@ -38654,10 +40493,6 @@ var ts; return isConstEnumSymbol(s) || s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - return true; - } if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (symbol && getSymbolLinks(symbol).referenced) { @@ -38685,15 +40520,23 @@ var ts; !(ts.getModifierFlags(parameter) & 92); } function getNodeCheckFlags(node) { - node = ts.getParseTreeNode(node); - return node ? getNodeLinks(node).flags : undefined; + return getNodeLinks(node).flags; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function canHaveConstantValue(node) { + switch (node.kind) { + case 264: + case 179: + case 180: + return true; + } + return false; + } function getConstantValue(node) { - if (node.kind === 263) { + if (node.kind === 264) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -38711,7 +40554,7 @@ var ts; var valueSymbol = resolveEntityName(typeName, 107455, true, false, location); var typeSymbol = resolveEntityName(typeName, 793064, true, false, location); if (valueSymbol && valueSymbol === typeSymbol) { - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { return ts.TypeReferenceSerializationKind.Promise; } @@ -38843,10 +40686,19 @@ var ts; getReferencedImportDeclaration: getReferencedImportDeclaration, getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, isDeclarationWithCollidingName: isDeclarationWithCollidingName, - isValueAliasDeclaration: isValueAliasDeclaration, + isValueAliasDeclaration: function (node) { + node = ts.getParseTreeNode(node); + return node ? isValueAliasDeclaration(node) : true; + }, hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, + isReferencedAliasDeclaration: function (node, checkChildren) { + node = ts.getParseTreeNode(node); + return node ? isReferencedAliasDeclaration(node, checkChildren) : true; + }, + getNodeCheckFlags: function (node) { + node = ts.getParseTreeNode(node); + return node ? getNodeCheckFlags(node) : undefined; + }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, @@ -38857,7 +40709,10 @@ var ts; writeBaseConstructorTypeOfClass: writeBaseConstructorTypeOfClass, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, collectLinkedAliases: collectLinkedAliases, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, @@ -38875,7 +40730,7 @@ var ts; if (!fileToDirective) { return undefined; } - var meaning = (node.kind === 178) || (node.kind === 70 && isInTypeQuery(node)) + var meaning = (node.kind === 179) || (node.kind === 71 && isInTypeQuery(node)) ? 107455 | 1048576 : 793064 | 1920; var symbol = resolveEntityName(node, meaning, true); @@ -38918,7 +40773,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 264 && current.flags & 512) { + if (current.valueDeclaration && current.valueDeclaration.kind === 265 && current.flags & 512) { return false; } for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { @@ -38937,7 +40792,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 264); + return ts.getDeclarationOfKind(moduleSymbol, 265); } function initializeTypeChecker() { for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) { @@ -38976,57 +40831,29 @@ var ts; } addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true); getSymbolLinks(unknownSymbol).type = unknownType; - globalArrayType = getGlobalType("Array", 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", 1); }); - getGlobalESSymbolConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Symbol"); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793064, undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - tryGetGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalSymbol("Promise", 107455, undefined) && getGlobalPromiseConstructorSymbol(); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2) { - getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); - getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", 1); }); - getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", 1); }); - getGlobalIterableIteratorType = ts.memoize(function () { return getGlobalType("IterableIterator", 1); }); - } - else { - getGlobalESSymbolType = ts.memoize(function () { return emptyObjectType; }); - getGlobalIterableType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIteratorType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); - } + globalArrayType = getGlobalType("Array", 1, true); + globalObjectType = getGlobalType("Object", 0, true); + globalFunctionType = getGlobalType("Function", 0, true); + globalStringType = getGlobalType("String", 0, true); + globalNumberType = getGlobalType("Number", 0, true); + globalBooleanType = getGlobalType("Boolean", 0, true); + globalRegExpType = getGlobalType("RegExp", 0, true); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); - var symbol = getGlobalSymbol("ReadonlyArray", 793064, undefined); - globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, 1); + globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; + globalThisType = getGlobalTypeOrUndefined("ThisType", 1); } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !ts.isInAmbientContext(location)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1; helper <= 128; helper <<= 1) { + for (var helper = 1; helper <= 8192; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455); @@ -39050,6 +40877,13 @@ var ts; case 32: return "__param"; case 64: return "__awaiter"; case 128: return "__generator"; + case 256: return "__values"; + case 512: return "__read"; + case 1024: return "__spread"; + case 2048: return "__asyncGenerator"; + case 4096: return "__asyncDelegator"; + case 8192: return "__asyncValues"; + default: ts.Debug.fail("Unrecognized helper."); } } function resolveHelpersModule(node, errorNode) { @@ -39058,36 +40892,19 @@ var ts; } return externalHelpersModule; } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - var thenPropertySymbol = createSymbol(4, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(16); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } function checkGrammarDecorators(node) { if (!node.decorators) { return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 150 && !ts.nodeIsPresent(node.body)) { + if (node.kind === 151 && !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 === 152 || node.kind === 153) { + else if (node.kind === 153 || node.kind === 154) { 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); @@ -39104,28 +40921,28 @@ var ts; var flags = 0; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 130) { - if (node.kind === 147 || node.kind === 149) { + if (modifier.kind !== 131) { + if (node.kind === 148 || node.kind === 150) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 156) { + if (node.kind === 157) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 75: - if (node.kind !== 231 && node.parent.kind === 228) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75)); + case 76: + if (node.kind !== 232 && node.parent.kind === 229) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76)); } break; + case 114: case 113: case 112: - case 111: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 112) { + if (modifier.kind === 113) { lastProtected = modifier; } - else if (modifier.kind === 111) { + else if (modifier.kind === 112) { lastPrivate = modifier; } if (flags & 28) { @@ -39140,11 +40957,11 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 233 || node.parent.kind === 264) { + else if (node.parent.kind === 234 || node.parent.kind === 265) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text); } else if (flags & 128) { - if (modifier.kind === 111) { + if (modifier.kind === 112) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -39153,7 +40970,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 114: + case 115: if (flags & 32) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -39163,10 +40980,10 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 233 || node.parent.kind === 264) { + else if (node.parent.kind === 234 || node.parent.kind === 265) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128) { @@ -39175,17 +40992,17 @@ var ts; flags |= 32; lastStatic = modifier; break; - case 130: + case 131: if (flags & 64) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 148 && node.kind !== 147 && node.kind !== 156 && node.kind !== 145) { + else if (node.kind !== 149 && node.kind !== 148 && node.kind !== 157 && node.kind !== 146) { return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64; lastReadonly = modifier; break; - case 83: + case 84: if (flags & 1) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -39198,45 +41015,45 @@ var ts; else if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async"); } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1; break; - case 123: + case 124: 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 === 228) { + else if (node.parent.kind === 229) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 234) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2; lastDeclare = modifier; break; - case 116: + case 117: if (flags & 128) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 228) { - if (node.kind !== 150 && - node.kind !== 148 && - node.kind !== 152 && - node.kind !== 153) { + if (node.kind !== 229) { + if (node.kind !== 151 && + node.kind !== 149 && + node.kind !== 153 && + node.kind !== 154) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 228 && ts.getModifierFlags(node.parent) & 128)) { + if (!(node.parent.kind === 229 && ts.getModifierFlags(node.parent) & 128)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32) { @@ -39248,14 +41065,14 @@ var ts; } flags |= 128; break; - case 119: + case 120: if (flags & 256) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 145) { + else if (node.kind === 146) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256; @@ -39263,7 +41080,7 @@ var ts; break; } } - if (node.kind === 151) { + if (node.kind === 152) { if (flags & 32) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -39278,13 +41095,13 @@ var ts; } return; } - else if ((node.kind === 237 || node.kind === 236) && flags & 2) { + else if ((node.kind === 238 || node.kind === 237) && flags & 2) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 145 && (flags & 92) && ts.isBindingPattern(node.name)) { + else if (node.kind === 146 && (flags & 92) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 145 && (flags & 92) && node.dotDotDotToken) { + else if (node.kind === 146 && (flags & 92) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256) { @@ -39300,38 +41117,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 152: case 153: - case 151: - case 148: - case 147: - case 150: + case 154: + case 152: case 149: - case 156: - case 232: + case 148: + case 151: + case 150: + case 157: + case 233: + case 238: case 237: - case 236: + case 244: case 243: - case 242: - case 185: case 186: - case 145: + case 187: + case 146: return false; default: - if (node.parent.kind === 233 || node.parent.kind === 264) { + if (node.parent.kind === 234 || node.parent.kind === 265) { return false; } switch (node.kind) { - case 227: - return nodeHasAnyModifiersExcept(node, 119); case 228: - return nodeHasAnyModifiersExcept(node, 116); + return nodeHasAnyModifiersExcept(node, 120); case 229: - case 207: + return nodeHasAnyModifiersExcept(node, 117); case 230: - return true; + case 208: case 231: - return nodeHasAnyModifiersExcept(node, 75); + return true; + case 232: + return nodeHasAnyModifiersExcept(node, 76); default: ts.Debug.fail(); return false; @@ -39343,14 +41160,11 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 150: - case 227: - case 185: + case 151: + case 228: case 186: - if (!node.asteriskToken) { - return false; - } - break; + case 187: + return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } @@ -39407,8 +41221,12 @@ var ts; return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } function checkGrammarArrowFunction(node, file) { - if (node.kind === 186) { + if (node.kind === 187) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -39443,7 +41261,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 135 && parameter.type.kind !== 132) { + if (parameter.type.kind !== 136 && parameter.type.kind !== 133) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -39470,7 +41288,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 199) { + if (arg.kind === 200) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -39496,7 +41314,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84) { + if (heritageClause.token === 85) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -39509,7 +41327,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107); + ts.Debug.assert(heritageClause.token === 108); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -39524,14 +41342,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84) { + if (heritageClause.token === 85) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107); + ts.Debug.assert(heritageClause.token === 108); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } checkGrammarHeritageClause(heritageClause); @@ -39540,28 +41358,25 @@ var ts; return false; } function checkGrammarComputedPropertyName(node) { - if (node.kind !== 143) { + if (node.kind !== 144) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 193 && computedPropertyName.expression.operatorToken.kind === 25) { + if (computedPropertyName.expression.kind === 194 && computedPropertyName.expression.operatorToken.kind === 26) { 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 === 227 || - node.kind === 185 || - node.kind === 150); + ts.Debug.assert(node.kind === 228 || + node.kind === 186 || + node.kind === 151); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); - } } } function checkGrammarForInvalidQuestionMark(questionToken, message) { @@ -39577,39 +41392,39 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262) { + if (prop.kind === 263) { continue; } var name = prop.name; - if (name.kind === 143) { + if (name.kind === 144) { checkGrammarComputedPropertyName(name); } - if (prop.kind === 261 && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 262 && !inDestructuring && prop.objectAssignmentInitializer) { return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); } if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 || prop.kind !== 150) { + if (mod.kind !== 120 || prop.kind !== 151) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } } var currentKind = void 0; - if (prop.kind === 260 || prop.kind === 261) { + if (prop.kind === 261 || prop.kind === 262) { checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8) { checkGrammarNumericLiteral(name); } currentKind = Property; } - else if (prop.kind === 150) { + else if (prop.kind === 151) { currentKind = Property; } - else if (prop.kind === 152) { + else if (prop.kind === 153) { currentKind = GetAccessor; } - else if (prop.kind === 153) { + else if (prop.kind === 154) { currentKind = SetAccessor; } else { @@ -39645,7 +41460,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 254) { + if (attr.kind === 255) { continue; } var jsxAttr = attr; @@ -39657,7 +41472,7 @@ var ts; return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 255 && !initializer.expression) { + if (initializer && initializer.kind === 256 && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -39666,7 +41481,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 226) { + if (forInOrOfStatement.kind === 216 && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 16384) === 0) { + return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + } + } + if (forInOrOfStatement.initializer.kind === 227) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -39674,20 +41494,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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 === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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 === 214 + var diagnostic = forInOrOfStatement.kind === 215 ? 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); @@ -39714,11 +41534,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 152 ? + return grammarErrorOnNode(accessor.name, kind === 153 ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 153) { + else if (kind === 154) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -39737,10 +41557,10 @@ var ts; } } function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 153 ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 152 ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 153 ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -39755,7 +41575,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 177) { + if (node.parent.kind === 178) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -39771,10 +41591,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 === 229) { + else if (node.parent.kind === 230) { 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 === 162) { + else if (node.parent.kind === 163) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -39785,9 +41605,9 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 221: + case 222: if (node.label && current.label.text === node.label.text) { - var isMisplacedContinueLabel = node.kind === 216 + var isMisplacedContinueLabel = node.kind === 217 && !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); @@ -39795,8 +41615,8 @@ var ts; return false; } break; - case 220: - if (node.kind === 217 && !node.label) { + case 221: + if (node.kind === 218 && !node.label) { return false; } break; @@ -39809,13 +41629,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 217 + var message = node.kind === 218 ? 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 === 217 + var message = node.kind === 218 ? 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); @@ -39827,7 +41647,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 174 || node.name.kind === 173) { + if (node.name.kind === 175 || node.name.kind === 174) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -39837,11 +41657,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 || expr.kind === 8 || - expr.kind === 191 && expr.operator === 37 && + expr.kind === 192 && expr.operator === 38 && expr.operand.kind === 8; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 214 && node.parent.parent.kind !== 215) { + if (node.parent.parent.kind !== 215 && node.parent.parent.kind !== 216) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -39876,7 +41696,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 70) { + if (name.kind === 71) { if (ts.unescapeIdentifier(name.text) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -39892,8 +41712,8 @@ var ts; } } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 70) { - if (name.originalKeywordKind === 109) { + if (name.kind === 71) { + if (name.originalKeywordKind === 110) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -39918,15 +41738,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 210: case 211: case 212: - case 219: case 213: + case 220: case 214: case 215: + case 216: return false; - case 221: + case 222: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -39942,9 +41762,9 @@ var ts; } } function checkGrammarMetaProperty(node) { - if (node.keywordToken === 93) { + if (node.keywordToken === 94) { if (node.name.text !== "target") { - return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, ts.tokenToString(node.keywordToken), "target"); } } } @@ -39988,7 +41808,7 @@ var ts; return true; } } - else if (node.parent.kind === 229) { + else if (node.parent.kind === 230) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -39996,7 +41816,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 162) { + else if (node.parent.kind === 163) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -40009,13 +41829,13 @@ var ts; } } function checkGrammarTopLevelElementForRequiredDeclareModifier(node) { - if (node.kind === 229 || - node.kind === 230 || + if (node.kind === 230 || + node.kind === 231 || + node.kind === 238 || node.kind === 237 || - node.kind === 236 || + node.kind === 244 || node.kind === 243 || - node.kind === 242 || - node.kind === 235 || + node.kind === 236 || ts.getModifierFlags(node) & (2 | 1 | 512)) { return false; } @@ -40024,7 +41844,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 === 207) { + if (ts.isDeclaration(decl) || decl.kind === 208) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -40043,7 +41863,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 === 206 || node.parent.kind === 233 || node.parent.kind === 264) { + if (node.parent.kind === 207 || node.parent.kind === 234 || node.parent.kind === 265) { 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); @@ -40054,19 +41874,19 @@ var ts; } } function checkGrammarNumericLiteral(node) { - if (node.isOctalLiteral) { + if (node.numericLiteralFlags & 4) { var diagnosticMessage = void 0; if (languageVersion >= 1) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 172)) { + else if (ts.isChildOfNodeWithKind(node, 173)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 263)) { + else if (ts.isChildOfNodeWithKind(node, 264)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 38; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -40094,407 +41914,17 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - function reduceNode(node, f, initial) { - return node ? f(initial, node) : initial; - } - function reduceNodeArray(nodes, f, initial) { - return nodes ? f(initial, nodes) : initial; - } - function reduceEachChild(node, initial, cbNode, cbNodeArray) { - if (node === undefined) { - return initial; - } - var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; - var cbNodes = cbNodeArray || cbNode; - var kind = node.kind; - if ((kind > 0 && kind <= 141)) { - return initial; - } - if ((kind >= 157 && kind <= 172)) { - return initial; - } - var result = initial; - switch (node.kind) { - case 205: - case 208: - case 199: - case 224: - case 297: - break; - case 142: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 143: - result = reduceNode(node.expression, cbNode, result); - break; - case 145: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 146: - result = reduceNode(node.expression, cbNode, result); - break; - case 148: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 150: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 151: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 152: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 153: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 173: - case 174: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 175: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 176: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 177: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 178: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 179: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); - break; - case 180: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 181: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 182: - result = reduceNode(node.tag, cbNode, result); - result = reduceNode(node.template, cbNode, result); - break; - case 183: - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 185: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 186: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 184: - case 187: - case 188: - case 189: - case 190: - case 196: - case 197: - case 202: - result = reduceNode(node.expression, cbNode, result); - break; - case 191: - case 192: - result = reduceNode(node.operand, cbNode, result); - break; - case 193: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 194: - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.whenTrue, cbNode, result); - result = reduceNode(node.whenFalse, cbNode, result); - break; - case 195: - result = reduceNode(node.head, cbNode, result); - result = reduceNodes(node.templateSpans, cbNodes, result); - break; - case 198: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 200: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - break; - case 201: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.type, cbNode, result); - break; - case 202: - result = reduceNode(node.expression, cbNode, result); - break; - case 204: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.literal, cbNode, result); - break; - case 206: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 207: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.declarationList, cbNode, result); - break; - case 209: - result = reduceNode(node.expression, cbNode, result); - break; - case 210: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.thenStatement, cbNode, result); - result = reduceNode(node.elseStatement, cbNode, result); - break; - case 211: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 212: - case 219: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 213: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.incrementor, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 214: - case 215: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 218: - case 222: - result = reduceNode(node.expression, cbNode, result); - break; - case 220: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.caseBlock, cbNode, result); - break; - case 221: - result = reduceNode(node.label, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 223: - result = reduceNode(node.tryBlock, cbNode, result); - result = reduceNode(node.catchClause, cbNode, result); - result = reduceNode(node.finallyBlock, cbNode, result); - break; - case 225: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 226: - result = reduceNodes(node.declarations, cbNodes, result); - break; - case 227: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 228: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 231: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 232: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 233: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 234: - result = reduceNodes(node.clauses, cbNodes, result); - break; - case 236: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.moduleReference, cbNode, result); - break; - case 237: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.importClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 238: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.namedBindings, cbNode, result); - break; - case 239: - result = reduceNode(node.name, cbNode, result); - break; - case 240: - case 244: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 241: - case 245: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 242: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 243: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.exportClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 247: - result = reduceNode(node.expression, cbNode, result); - break; - case 248: - result = reduceNode(node.openingElement, cbNode, result); - result = ts.reduceLeft(node.children, cbNode, result); - result = reduceNode(node.closingElement, cbNode, result); - break; - case 249: - case 250: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNode(node.attributes, cbNode, result); - break; - case 251: - result = reduceNode(node.tagName, cbNode, result); - break; - case 253: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 252: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 254: - result = reduceNode(node.expression, cbNode, result); - break; - case 255: - result = reduceNode(node.expression, cbNode, result); - break; - case 256: - result = reduceNode(node.expression, cbNode, result); - case 257: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 258: - result = reduceNodes(node.types, cbNodes, result); - break; - case 259: - result = reduceNode(node.variableDeclaration, cbNode, result); - result = reduceNode(node.block, cbNode, result); - break; - case 260: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 261: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); - break; - case 262: - result = reduceNode(node.expression, cbNode, result); - break; - case 263: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - case 264: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 298: - result = reduceNode(node.expression, cbNode, result); - break; - default: - break; - } - return result; - } - ts.reduceEachChild = reduceEachChild; - function visitNode(node, visitor, test, optional, lift) { + function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; } - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; } var visitedNode; if (visited === undefined) { - if (!optional) { - Debug.failNotOptional(); - } return undefined; } else if (ts.isArray(visited)) { @@ -40503,14 +41933,14 @@ var ts; else { visitedNode = visited; } - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; function visitNodes(nodes, visitor, test, start, count) { - if (nodes === undefined) { - return undefined; + if (nodes === undefined || visitor === undefined) { + return nodes; } var updated; var length = nodes.length; @@ -40525,7 +41955,7 @@ var ts; } for (var i = 0; i < count; i++) { var node = nodes[i + start]; - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -40536,14 +41966,14 @@ var ts; if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - Debug.assertNode(visited, test); - aggregateTransformFlags(visited); + ts.Debug.assertNode(visited, test); + ts.aggregateTransformFlags(visited); updated.push(visited); } } @@ -40562,9 +41992,10 @@ var ts; return ts.setTextRange(ts.createNodeArray(ts.concatenate(statements, declarations)), statements); } ts.visitLexicalEnvironment = visitLexicalEnvironment; - function visitParameterList(nodes, visitor, context) { + function visitParameterList(nodes, visitor, context, nodesVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } context.startLexicalEnvironment(); - var updated = visitNodes(nodes, visitor, ts.isParameterDeclaration); + var updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -40575,220 +42006,655 @@ var ts; var declarations = context.endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(updated); - var statements = mergeLexicalEnvironment(block.statements, declarations); + var statements = ts.mergeLexicalEnvironment(block.statements, declarations); return ts.updateBlock(block, statements); } return updated; } ts.visitFunctionBody = visitFunctionBody; - function visitEachChild(node, visitor, context) { + function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (node === undefined) { return undefined; } var kind = node.kind; - if ((kind > 0 && kind <= 141)) { - return node; - } - if ((kind >= 157 && kind <= 172)) { + if ((kind > 0 && kind <= 142) || kind === 169) { return node; } switch (node.kind) { - case 205: - case 208: - case 199: - case 224: - return node; - case 142: - return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 143: - return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - case 145: - return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 146: - return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - case 148: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 150: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 151: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 152: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 153: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 173: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 174: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 175: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 176: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 177: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 178: - return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 179: - return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 180: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 182: - return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183: - return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 184: - return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 186: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 187: - return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188: - return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189: - return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 190: - return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193: - return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 191: - return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 192: - return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 194: - return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 195: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 196: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197: - return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 200: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 201: - return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 202: - return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 204: - return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); case 206: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 207: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); case 209: - return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, true, liftToBlock)); - case 211: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 212: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 213: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 214: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 215: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 216: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 217: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, true)); - case 218: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, true)); - case 219: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 220: - return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 221: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, false, liftToBlock)); - case 222: - return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, true), visitNode(node.finallyBlock, visitor, ts.isBlock, true)); + case 200: case 225: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, true), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 226: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 227: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, true), visitFunctionBody(node.body, visitor, context)); - case 228: - return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 231: - return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); - case 232: - return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 233: - return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 234: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236: - return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 237: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 238: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, true)); - case 239: - return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 240: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 241: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 242: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 243: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, true)); - case 244: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 245: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, true), visitNode(node.name, visitor, ts.isIdentifier)); - case 247: - return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); - case 248: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 253: - return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); - case 249: - return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 250: - return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 251: - return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 252: - return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 254: - return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 255: - return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); - case 256: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 257: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 258: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 259: - return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); - case 260: - return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 261: - return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 262: - return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); - case 263: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, true)); - case 264: - return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); case 298: + case 247: + return node; + case 143: + return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); + case 144: + return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); + case 160: + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 161: + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 155: + return ts.updateCallSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 156: + return ts.updateConstructSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 150: + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + case 157: + return ts.updateIndexSignatureDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 146: + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 147: + return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); + case 159: + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + case 158: + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 162: + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + case 163: + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor)); + case 164: + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + case 165: + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 166: + case 167: + return ts.updateUnionOrIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 168: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 172: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameter), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 173: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + case 145: + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + case 148: + return ts.updatePropertySignature(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 149: + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 151: + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 152: + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 153: + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 154: + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 174: + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + case 175: + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + case 176: + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); + case 177: + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + case 178: + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 179: + return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); + case 180: + return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); + case 181: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 182: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 183: + return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); + case 184: + return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 185: + return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); + case 186: + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 187: + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 188: + return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); + case 189: + return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); + case 190: + return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); + case 191: + return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); + case 194: + return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); + case 192: + return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 193: + return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); + case 195: + return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); + case 196: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + case 197: + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 198: + return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); + case 199: + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 201: + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202: + return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); + case 203: + return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 205: + return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); + case 207: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 208: + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 210: + return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); + case 211: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + case 212: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 213: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 214: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 215: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 216: + return ts.updateForOf(node, node.awaitModifier, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 217: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 218: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 219: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 221: + return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); + case 222: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 223: + return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); + case 224: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + case 226: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 227: + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + case 228: + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 229: + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 232: + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + case 233: + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 234: + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 235: + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + case 237: + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 238: + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 239: + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + case 240: + return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); + case 241: + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + case 242: + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 243: + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 244: + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 245: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 246: + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 248: + return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); + case 249: + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + case 254: + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + case 250: + return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 251: + return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); + case 252: + return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); + case 253: + return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); + case 255: + return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); + case 256: + return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); + case 257: + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + case 258: + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 259: + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 260: + return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); + case 261: + return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 262: + return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); + case 263: + return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); + case 264: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); + case 265: + return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); + case 296: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: return node; } } ts.visitEachChild = visitEachChild; + function extractSingleNode(nodes) { + ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output."); + return ts.singleOrUndefined(nodes); + } +})(ts || (ts = {})); +(function (ts) { + function reduceNode(node, f, initial) { + return node ? f(initial, node) : initial; + } + function reduceNodeArray(nodes, f, initial) { + return nodes ? f(initial, nodes) : initial; + } + function reduceEachChild(node, initial, cbNode, cbNodeArray) { + if (node === undefined) { + return initial; + } + var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; + var cbNodes = cbNodeArray || cbNode; + var kind = node.kind; + if ((kind > 0 && kind <= 142)) { + return initial; + } + if ((kind >= 158 && kind <= 173)) { + return initial; + } + var result = initial; + switch (node.kind) { + case 206: + case 209: + case 200: + case 225: + case 295: + break; + case 143: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 144: + result = reduceNode(node.expression, cbNode, result); + break; + case 146: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 147: + result = reduceNode(node.expression, cbNode, result); + break; + case 149: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 151: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 152: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 154: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 174: + case 175: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 176: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 177: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 178: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 179: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 180: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 181: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 183: + result = reduceNode(node.tag, cbNode, result); + result = reduceNode(node.template, cbNode, result); + break; + case 184: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 186: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 187: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 185: + case 188: + case 189: + case 190: + case 191: + case 197: + case 198: + case 203: + result = reduceNode(node.expression, cbNode, result); + break; + case 192: + case 193: + result = reduceNode(node.operand, cbNode, result); + break; + case 194: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 195: + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.whenTrue, cbNode, result); + result = reduceNode(node.whenFalse, cbNode, result); + break; + case 196: + result = reduceNode(node.head, cbNode, result); + result = reduceNodes(node.templateSpans, cbNodes, result); + break; + case 199: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 201: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + break; + case 202: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 203: + result = reduceNode(node.expression, cbNode, result); + break; + case 205: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.literal, cbNode, result); + break; + case 207: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 208: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.declarationList, cbNode, result); + break; + case 210: + result = reduceNode(node.expression, cbNode, result); + break; + case 211: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.thenStatement, cbNode, result); + result = reduceNode(node.elseStatement, cbNode, result); + break; + case 212: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 213: + case 220: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 214: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.incrementor, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 215: + case 216: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 219: + case 223: + result = reduceNode(node.expression, cbNode, result); + break; + case 221: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.caseBlock, cbNode, result); + break; + case 222: + result = reduceNode(node.label, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 224: + result = reduceNode(node.tryBlock, cbNode, result); + result = reduceNode(node.catchClause, cbNode, result); + result = reduceNode(node.finallyBlock, cbNode, result); + break; + case 226: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 227: + result = reduceNodes(node.declarations, cbNodes, result); + break; + case 228: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 229: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 233: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 234: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 235: + result = reduceNodes(node.clauses, cbNodes, result); + break; + case 237: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 238: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.importClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 239: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); + break; + case 240: + result = reduceNode(node.name, cbNode, result); + break; + case 241: + case 245: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 242: + case 246: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 243: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 244: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.exportClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 248: + result = reduceNode(node.expression, cbNode, result); + break; + case 249: + result = reduceNode(node.openingElement, cbNode, result); + result = ts.reduceLeft(node.children, cbNode, result); + result = reduceNode(node.closingElement, cbNode, result); + break; + case 250: + case 251: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 254: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252: + result = reduceNode(node.tagName, cbNode, result); + break; + case 253: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 255: + result = reduceNode(node.expression, cbNode, result); + break; + case 256: + result = reduceNode(node.expression, cbNode, result); + break; + case 257: + result = reduceNode(node.expression, cbNode, result); + case 258: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 259: + result = reduceNodes(node.types, cbNodes, result); + break; + case 260: + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); + break; + case 261: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 262: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); + break; + case 263: + result = reduceNode(node.expression, cbNode, result); + break; + case 264: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 265: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 296: + result = reduceNode(node.expression, cbNode, result); + break; + default: + break; + } + return result; + } + ts.reduceEachChild = reduceEachChild; function mergeLexicalEnvironment(statements, declarations) { if (!ts.some(declarations)) { return statements; @@ -40798,27 +42664,11 @@ var ts; : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; - function mergeFunctionBodyLexicalEnvironment(body, declarations) { - if (body && declarations !== undefined && declarations.length > 0) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); - } - else { - return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), true), body); - } - } - return body; - } - ts.mergeFunctionBodyLexicalEnvironment = mergeFunctionBodyLexicalEnvironment; function liftToBlock(nodes) { Debug.assert(ts.every(nodes, ts.isStatement), "Cannot lift nodes to a Block."); return ts.singleOrUndefined(nodes) || ts.createBlock(nodes); } ts.liftToBlock = liftToBlock; - function extractSingleNode(nodes) { - Debug.assert(nodes.length <= 1, "Too many nodes written to output."); - return ts.singleOrUndefined(nodes); - } function aggregateTransformFlags(node) { aggregateTransformFlagsForNode(node); return node; @@ -40849,7 +42699,7 @@ var ts; return subtreeFlags; } function aggregateTransformFlagsForSubtree(node) { - if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 200)) { + if (ts.hasModifier(node, 2) || (ts.isTypeNode(node) && node.kind !== 201)) { return 0; } return reduceEachChild(node, 0, aggregateTransformFlagsForChildNode, aggregateTransformFlagsForChildNodes); @@ -40862,9 +42712,6 @@ var ts; } var Debug; (function (Debug) { - Debug.failNotOptional = Debug.shouldAssert(1) - ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : ts.noop; @@ -40910,7 +42757,7 @@ var ts; var value; if (ts.isDestructuringAssignment(node)) { value = node.right; - while (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) { if (ts.isDestructuringAssignment(value)) { location = node = value; value = node.right; @@ -40924,6 +42771,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -40971,6 +42819,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -41088,7 +42937,12 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { + if (flattenContext.level < 1 && flattenContext.downlevelIteration) { + value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) + ? undefined + : numElements, location), false, location); + } + else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)) { var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0; value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location); } @@ -41233,8 +43087,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178); context.enableSubstitution(179); + context.enableSubstitution(180); var currentSourceFile; var currentNamespace; var currentNamespaceContainerName; @@ -41267,15 +43121,15 @@ var ts; } function onBeforeVisitNode(node) { switch (node.kind) { - case 264: + case 265: + case 235: case 234: - case 233: - case 206: + case 207: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; + case 229: case 228: - case 227: if (ts.hasModifier(node, 2)) { break; } @@ -41300,13 +43154,13 @@ var ts; } function sourceElementVisitorWorker(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 242: - return visitExportAssignment(node); case 243: + return visitExportAssignment(node); + case 244: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -41316,11 +43170,11 @@ var ts; return saveStateAndInvoke(node, namespaceElementVisitorWorker); } function namespaceElementVisitorWorker(node) { - if (node.kind === 243 || - node.kind === 237 || + if (node.kind === 244 || node.kind === 238 || - (node.kind === 236 && - node.moduleReference.kind === 247)) { + node.kind === 239 || + (node.kind === 237 && + node.moduleReference.kind === 248)) { return undefined; } else if (node.transformFlags & 1 || ts.hasModifier(node, 1)) { @@ -41336,15 +43190,15 @@ var ts; } function classElementVisitorWorker(node) { switch (node.kind) { - case 151: - return undefined; - case 148: - case 156: case 152: + return undefined; + case 149: + case 157: case 153: - case 150: + case 154: + case 151: return visitorWorker(node); - case 205: + case 206: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -41355,7 +43209,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270) { return undefined; } - else if (currentNamespace && node.kind === 83) { + else if (currentNamespace && node.kind === 84) { return undefined; } return node; @@ -41365,33 +43219,32 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return currentNamespace ? undefined : node; - case 113: - case 111: + case 114: case 112: - case 116: - case 75: - case 123: - case 130: - case 163: + case 113: + case 117: + case 76: + case 124: + case 131: case 164: - case 162: - case 157: - case 144: - case 118: - case 121: - case 135: - case 132: - case 129: - case 104: - case 136: - case 160: - case 159: - case 161: - case 158: case 165: + case 163: + case 158: + case 145: + case 119: + case 122: + case 136: + case 133: + case 130: + case 105: + case 137: + case 161: + case 160: + case 162: + case 159: case 166: case 167: case 168: @@ -41399,57 +43252,58 @@ var ts; case 170: case 171: case 172: - case 156: - case 146: - case 230: - case 148: - return undefined; - case 151: - return visitConstructor(node); - case 229: - return ts.createNotEmittedStatement(node); - case 228: - return visitClassDeclaration(node); - case 198: - return visitClassExpression(node); - case 258: - return visitHeritageClause(node); - case 200: - return visitExpressionWithTypeArguments(node); - case 150: - return visitMethodDeclaration(node); - case 152: - return visitGetAccessor(node); - case 153: - return visitSetAccessor(node); - case 227: - return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); - case 186: - return visitArrowFunction(node); - case 145: - return visitParameter(node); - case 184: - return visitParenthesizedExpression(node); - case 183: - case 201: - return visitAssertionExpression(node); - case 180: - return visitCallExpression(node); - case 181: - return visitNewExpression(node); - case 202: - return visitNonNullExpression(node); + case 173: + case 157: + case 147: case 231: - return visitEnumDeclaration(node); - case 207: - return visitVariableStatement(node); - case 225: - return visitVariableDeclaration(node); + case 149: + return undefined; + case 152: + return visitConstructor(node); + case 230: + return ts.createNotEmittedStatement(node); + case 229: + return visitClassDeclaration(node); + case 199: + return visitClassExpression(node); + case 259: + return visitHeritageClause(node); + case 201: + return visitExpressionWithTypeArguments(node); + case 151: + return visitMethodDeclaration(node); + case 153: + return visitGetAccessor(node); + case 154: + return visitSetAccessor(node); + case 228: + return visitFunctionDeclaration(node); + case 186: + return visitFunctionExpression(node); + case 187: + return visitArrowFunction(node); + case 146: + return visitParameter(node); + case 185: + return visitParenthesizedExpression(node); + case 184: + case 202: + return visitAssertionExpression(node); + case 181: + return visitCallExpression(node); + case 182: + return visitNewExpression(node); + case 203: + return visitNonNullExpression(node); case 232: + return visitEnumDeclaration(node); + case 208: + return visitVariableStatement(node); + case 226: + return visitVariableDeclaration(node); + case 233: return visitModuleDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); default: ts.Debug.failBadSyntaxKind(node); @@ -41457,7 +43311,8 @@ var ts; } } function visitSourceFile(node) { - var alwaysStrict = compilerOptions.alwaysStrict && !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && + !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict)); } function shouldEmitDecorateCallForClass(node) { @@ -41478,7 +43333,7 @@ var ts; var hasExtendsClause = ts.getClassExtendsHeritageClauseElement(node) !== undefined; var isDecoratedClass = shouldEmitDecorateCallForClass(node); var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -41504,7 +43359,7 @@ var ts; } if (statements.length > 1) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 2097152); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304); } return ts.singleOrMany(statements); } @@ -41539,7 +43394,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85; })); var classExpression = ts.createClassExpression(undefined, node.name, undefined, heritageClauses, members); ts.setOriginalNode(classExpression, node); ts.setTextRange(classExpression, node); @@ -41550,7 +43405,7 @@ var ts; enableSubstitutionForClassAliases(); classAliases[ts.getOriginalNodeId(node)] = ts.getSynthesizedClone(temp); } - ts.setEmitFlags(classExpression, 32768 | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -41599,18 +43454,18 @@ var ts; if (constructor) { ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } - ts.addRange(statements, endLexicalEnvironment()); + statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined); } function addPrologueDirectivesAndInitialSuperCall(ctor, result) { if (ctor.body) { var statements = ctor.body.statements; - var index = ts.addPrologueDirectives(result, statements, false, visitor); + var index = ts.addPrologue(result, statements, false, visitor); if (index === statements.length) { return index; } var statement = statements[index]; - if (statement.kind === 209 && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -41644,13 +43499,13 @@ var ts; return isInitializedProperty(member, false); } function isInitializedProperty(member, isStatic) { - return member.kind === 148 + return member.kind === 149 && isStatic === ts.hasModifier(member, 32) && member.initializer !== undefined; } function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { - var property = properties_8[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -41659,8 +43514,8 @@ var ts; } function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -41717,12 +43572,12 @@ var ts; } function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 152: case 153: + case 154: return getAllDecoratorsOfAccessors(node, member); - case 150: + case 151: return getAllDecoratorsOfMethod(member); - case 148: + case 149: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -41801,7 +43656,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, true); var descriptor = languageVersion > 0 - ? member.kind === 148 + ? member.kind === 149 ? ts.createVoidZero() : ts.createNull() : undefined; @@ -41870,13 +43725,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(35), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(undefined, undefined, [], undefined, ts.createToken(36), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, true))); @@ -41885,37 +43740,37 @@ var ts; } function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 150 - || kind === 152 + return kind === 151 || kind === 153 - || kind === 148; + || kind === 154 + || kind === 149; } function shouldAddReturnTypeMetadata(node) { - return node.kind === 150; + return node.kind === 151; } function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 228: - case 198: + case 229: + case 199: return ts.getFirstConstructorWithBody(node) !== undefined; - case 150: - case 152: + case 151: case 153: + case 154: return true; } return false; } function serializeTypeOfNode(node) { switch (node.kind) { - case 148: - case 145: - case 152: - return serializeTypeNode(node.type); + case 149: + case 146: case 153: + return serializeTypeNode(node.type); + case 154: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 228: - case 198: - case 150: + case 229: + case 199: + case 151: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -41947,7 +43802,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 152) { + if (container && node.kind === 153) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -41959,7 +43814,7 @@ var ts; if (ts.isFunctionLike(node) && node.type) { return serializeTypeNode(node.type); } - else if (ts.isAsyncFunctionLike(node)) { + else if (ts.isAsyncFunction(node)) { return ts.createIdentifier("Promise"); } return ts.createVoidZero(); @@ -41969,56 +43824,58 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 104: - case 138: - case 94: - case 129: + case 105: + case 139: + case 95: + case 130: return ts.createVoidZero(); - case 167: + case 168: return serializeTypeNode(node.type); - case 159: case 160: + case 161: return ts.createIdentifier("Function"); - case 163: case 164: + case 165: return ts.createIdentifier("Array"); - case 157: - case 121: + case 158: + case 122: return ts.createIdentifier("Boolean"); - case 135: + case 136: return ts.createIdentifier("String"); - case 172: + case 134: + return ts.createIdentifier("Object"); + case 173: switch (node.literal.kind) { case 9: return ts.createIdentifier("String"); case 8: return ts.createIdentifier("Number"); - case 100: - case 85: + case 101: + case 86: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 132: + case 133: return ts.createIdentifier("Number"); - case 136: + case 137: return languageVersion < 2 ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 158: + case 159: return serializeTypeReferenceNode(node); + case 167: case 166: - case 165: return serializeUnionOrIntersectionType(node); - case 161: - case 169: + case 162: case 170: case 171: - case 162: - case 118: - case 168: + case 172: + case 163: + case 119: + case 169: break; default: ts.Debug.failBadSyntaxKind(node); @@ -42085,7 +43942,7 @@ var ts; } function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 70: + case 71: var name = ts.getMutableClone(node); name.flags &= ~8; name.original = undefined; @@ -42094,13 +43951,13 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 142: + case 143: return serializeQualifiedNameAsExpression(node, useFallback); } } function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 70) { + if (node.left.kind === 71) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -42145,9 +44002,9 @@ var ts; } } function visitHeritageClause(node) { - if (node.token === 84) { + if (node.token === 85) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(84, types), node); + return ts.setTextRange(ts.createHeritageClause(85, types), node); } return undefined; } @@ -42161,13 +44018,13 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - return ts.visitEachChild(node, visitor, context); + return ts.updateConstructor(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context)); } function visitMethodDeclaration(node) { if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); if (updated !== node) { ts.setCommentRange(updated, node); ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node)); @@ -42203,7 +44060,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createNotEmittedStatement(node); } - var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); + var updated = ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); if (isNamespaceExport(node)) { var statements = [updated]; addExportMemberAssignment(statements, node); @@ -42212,10 +44069,10 @@ var ts; return updated; } function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { + if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createOmittedExpression(); } - var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context)); + var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); return updated; } function visitArrowFunction(node) { @@ -42379,20 +44236,20 @@ var ts; ts.setOriginalNode(statement, node); recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { - if (node.kind === 231) { + if (node.kind === 232) { ts.setSourceMapRange(statement.declarationList, node); } else { ts.setSourceMapRange(statement, node); } ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 1024 | 2097152); + ts.setEmitFlags(statement, 1024 | 4194304); statements.push(statement); return true; } else { var mergeMarker = ts.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 | 2097152); + ts.setEmitFlags(mergeMarker, 1536 | 4194304); statements.push(mergeMarker); return false; } @@ -42440,7 +44297,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 233) { + if (body.kind === 234) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -42464,13 +44321,13 @@ var ts; currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName; var block = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true); ts.setTextRange(block, blockLocation); - if (body.kind !== 233) { + if (body.kind !== 234) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 232) { + if (moduleDeclaration.body.kind === 233) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -42479,18 +44336,18 @@ var ts; if (!node.importClause) { return node; } - var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, true); + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause ? ts.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier) : undefined; } function visitImportClause(node) { var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; - var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, true); + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings); return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } function visitNamedImportBindings(node) { - if (node.kind === 239) { + if (node.kind === 240) { return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } else { @@ -42513,7 +44370,7 @@ var ts; if (!resolver.isValueAliasDeclaration(node)) { return undefined; } - var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, true); + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports); return exportClause ? ts.updateExportDeclaration(node, undefined, undefined, exportClause, node.moduleSpecifier) : undefined; @@ -42611,32 +44468,36 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8) === 0) { enabledSubstitutions |= 8; - context.enableSubstitution(70); + context.enableSubstitution(71); } } function enableSubstitutionForClassAliases() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(70); + context.enableSubstitution(71); classAliases = []; } } function enableSubstitutionForNamespaceExports() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(70); - context.enableSubstitution(261); - context.enableEmitNotification(232); + context.enableSubstitution(71); + context.enableSubstitution(262); + context.enableEmitNotification(233); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 232; + return ts.getOriginalNode(node).kind === 233; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 231; + return ts.getOriginalNode(node).kind === 232; } function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSourceFile = currentSourceFile; + if (ts.isSourceFile(node)) { + currentSourceFile = node; + } if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2; } @@ -42645,6 +44506,7 @@ var ts; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; + currentSourceFile = savedCurrentSourceFile; } function onSubstituteNode(hint, node) { node = previousOnSubstituteNode(hint, node); @@ -42672,11 +44534,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 178: - return substitutePropertyAccessExpression(node); case 179: + return substitutePropertyAccessExpression(node); + case 180: return substituteElementAccessExpression(node); } return node; @@ -42706,9 +44568,9 @@ var ts; function trySubstituteNamespaceExportedName(node) { if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var container = resolver.getReferencedExportContainer(node, false); - if (container && container.kind !== 264) { - var substitute = (applicableSubstitutions & 2 && container.kind === 232) || - (applicableSubstitutions & 8 && container.kind === 231); + if (container && container.kind !== 265) { + var substitute = (applicableSubstitutions & 2 && container.kind === 233) || + (applicableSubstitutions & 8 && container.kind === 232); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), node); } @@ -42725,16 +44587,14 @@ var ts; function substituteConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { + ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); - ts.setSourceMapRange(substitute, node); - ts.setCommentRange(substitute, node); if (!compilerOptions.removeComments) { var propertyName = ts.isPropertyAccessExpression(node) ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - substitute.trailingComment = " " + propertyName + " "; + ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " "); } - ts.setConstantValue(node, constantValue); return substitute; } return node; @@ -42749,40 +44609,7 @@ var ts; } } ts.transformTypeScript = transformTypeScript; - var paramHelper = { - name: "typescript:param", - scoped: false, - priority: 4, - text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" - }; - function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ - ts.createLiteral(parameterOffset), - expression - ]), location); - } - var metadataHelper = { - name: "typescript:metadata", - scoped: false, - priority: 3, - text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" - }; - function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), undefined, [ - ts.createLiteral(metadataKey), - metadataValue - ]); - } - var decorateHelper = { - name: "typescript:decorate", - scoped: false, - priority: 2, - text: "\n var __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 };" - }; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { - context.requestEmitHelper(decorateHelper); var argumentsArray = []; argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, true)); argumentsArray.push(target); @@ -42792,13 +44619,305 @@ var ts; argumentsArray.push(descriptor); } } + context.requestEmitHelper(decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), undefined, argumentsArray), location); } + var decorateHelper = { + name: "typescript:decorate", + scoped: false, + priority: 2, + text: "\n var __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 };" + }; + function createMetadataHelper(context, metadataKey, metadataValue) { + context.requestEmitHelper(metadataHelper); + return ts.createCall(ts.getHelperName("__metadata"), undefined, [ + ts.createLiteral(metadataKey), + metadataValue + ]); + } + var metadataHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" + }; + function createParamHelper(context, expression, parameterOffset, location) { + context.requestEmitHelper(paramHelper); + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), undefined, [ + ts.createLiteral(parameterOffset), + expression + ]), location); + } + var paramHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" + }; })(ts || (ts = {})); var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + function transformES2017(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var currentSourceFile; + var enabledSubstitutions; + var enclosingSuperContainerFlags = 0; + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; + } + function visitor(node) { + if ((node.transformFlags & 16) === 0) { + return node; + } + switch (node.kind) { + case 120: + return undefined; + case 191: + return visitAwaitExpression(node); + case 151: + return visitMethodDeclaration(node); + case 228: + return visitFunctionDeclaration(node); + case 186: + return visitFunctionExpression(node); + case 187: + return visitArrowFunction(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); + } + function visitMethodDeclaration(node) { + return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitFunctionDeclaration(node) { + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitFunctionExpression(node) { + return ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function visitArrowFunction(node) { + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.getFunctionFlags(node) & 2 + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function transformAsyncFunctionBody(node) { + resumeLexicalEnvironment(); + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; + var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 187; + var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); + statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(statements, true); + ts.setTextRange(block, node.body); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; + } + else { + var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); + var declarations = endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(expression); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); + } + return expression; + } + } + function transformFunctionBodyWorker(body, start) { + if (ts.isBlock(body)) { + return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); + } + else { + startLexicalEnvironment(); + var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); + var declarations = endLexicalEnvironment(); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); + } + } + function getPromiseConstructor(type) { + var typeName = type && ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(181); + context.enableSubstitution(179); + context.enableSubstitution(180); + context.enableEmitNotification(229); + context.enableEmitNotification(151); + context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(152); + } + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179: + return substitutePropertyAccessExpression(node); + case 180: + return substituteElementAccessExpression(node); + case 181: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 + || kind === 152 + || kind === 151 + || kind === 153 + || kind === 154; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); + } + } + } + ts.transformES2017 = transformES2017; + var awaiterHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: "\n var __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 };" + }; + function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + context.requestEmitHelper(awaiterHelper); + var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(39), undefined, undefined, [], undefined, body); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; + return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ + ts.createThis(), + hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), + promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), + generatorFunc + ]); + } + ts.asyncSuperHelper = { + name: "typescript:async-super", + scoped: true, + text: "\n const _super = name => super[name];\n " + }; + ts.advancedAsyncSuperHelper = { + name: "typescript:advanced-async-super", + scoped: true, + text: "\n const _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);\n " + }; +})(ts || (ts = {})); +var ts; +(function (ts) { + var ESNextSubstitutionFlags; + (function (ESNextSubstitutionFlags) { + ESNextSubstitutionFlags[ESNextSubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ESNextSubstitutionFlags || (ESNextSubstitutionFlags = {})); function transformESNext(context) { - var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + var enabledSubstitutions; + var enclosingFunctionFlags; + var enclosingSuperContainerFlags = 0; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -42814,53 +44933,93 @@ var ts; function visitorNoDestructuringValue(node) { return visitorWorker(node, true); } + function visitorNoAsyncModifier(node) { + if (node.kind === 120) { + return undefined; + } + return node; + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 8) === 0) { return node; } switch (node.kind) { - case 177: + case 191: + return visitAwaitExpression(node); + case 197: + return visitYieldExpression(node); + case 222: + return visitLabeledStatement(node); + case 178: return visitObjectLiteralExpression(node); - case 193: + case 194: return visitBinaryExpression(node, noDestructuringValue); - case 225: + case 226: return visitVariableDeclaration(node); - case 215: - return visitForOfStatement(node); - case 213: + case 216: + return visitForOfStatement(node, undefined); + case 214: return visitForStatement(node); - case 189: + case 190: return visitVoidExpression(node); - case 151: - return visitConstructorDeclaration(node); - case 150: - return visitMethodDeclaration(node); case 152: - return visitGetAccessorDeclaration(node); + return visitConstructorDeclaration(node); + case 151: + return visitMethodDeclaration(node); case 153: + return visitGetAccessorDeclaration(node); + case 154: return visitSetAccessorDeclaration(node); - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); case 186: + return visitFunctionExpression(node); + case 187: return visitArrowFunction(node); - case 145: + case 146: return visitParameter(node); - case 209: + case 210: return visitExpressionStatement(node); - case 184: + case 185: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); } } + function visitAwaitExpression(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.createArrayLiteral([ts.createLiteral("await"), expression])), node), node); + } + return ts.visitEachChild(node, visitor, context); + } + function visitYieldExpression(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.updateYield(node, node.asteriskToken, node.asteriskToken + ? createAsyncDelegatorHelper(context, expression, expression) + : ts.createArrayLiteral(expression + ? [ts.createLiteral("yield"), expression] + : [ts.createLiteral("yield")])); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) { + var statement = ts.unwrapInnermostStatementOfLabel(node); + if (statement.kind === 216 && statement.awaitModifier) { + return visitForOfStatement(statement, node); + } + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), node); + } + return ts.visitEachChild(node, visitor, context); + } function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 262) { + if (e.kind === 263) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -42872,7 +45031,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 260) { + if (e.kind === 261) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -42889,7 +45048,7 @@ var ts; function visitObjectLiteralExpression(node) { if (node.transformFlags & 1048576) { var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 177) { + if (objects.length && objects[0].kind !== 178) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -42906,7 +45065,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576) { return ts.flattenDestructuringAssignment(node, visitor, context, 1, !noDestructuringValue); } - else if (node.operatorToken.kind === 25) { + else if (node.operatorToken.kind === 26) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -42923,69 +45082,202 @@ var ts; function visitVoidExpression(node) { return ts.visitEachChild(node, visitorNoDestructuringValue, context); } - function visitForOfStatement(node) { - var leadingStatements; - var temp; - var initializer = ts.skipParentheses(node.initializer); - if (initializer.transformFlags & 1048576) { - if (ts.isVariableDeclarationList(initializer)) { - temp = ts.createTempVariable(undefined); - var firstDeclaration = ts.firstOrUndefined(initializer.declarations); - var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1, temp, false, true); - if (ts.some(declarations)) { - var statement = ts.createVariableStatement(undefined, ts.updateVariableDeclarationList(initializer, declarations)); - ts.setTextRange(statement, initializer); - leadingStatements = ts.append(leadingStatements, statement); - } - } - else if (ts.isAssignmentPattern(initializer)) { - temp = ts.createTempVariable(undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1); - leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); - } + function visitForOfStatement(node, outermostLabeledStatement) { + if (node.initializer.transformFlags & 1048576) { + node = transformForOfStatementWithObjectRest(node); } - if (temp) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) - : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), true), statement); - return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + if (node.awaitModifier) { + return transformForAwaitOfStatement(node, outermostLabeledStatement); + } + else { + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); + } + } + function transformForOfStatementWithObjectRest(node) { + var initializerWithoutParens = ts.skipParentheses(node.initializer); + if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) { + var bodyLocation = void 0; + var statementsLocation = void 0; + var temp = ts.createTempVariable(undefined); + var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)]; + if (ts.isBlock(node.statement)) { + ts.addRange(statements, node.statement.statements); + bodyLocation = node.statement; + statementsLocation = node.statement.statements; + } + return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) - ], 1), node.initializer), expression, block); + ], 1), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation)); } - return ts.visitEachChild(node, visitor, context); + return node; + } + function convertForOfStatementHead(node, boundValue) { + var binding = ts.createForOfBindingStatement(node.initializer, boundValue); + var bodyLocation; + var statementsLocation; + var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384); + } + function transformForAwaitOfStatement(node, outermostLabeledStatement) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(undefined); + var values = createAsyncValuesHelper(context, expression, node.expression); + var next = ts.createYield(undefined, enclosingFunctionFlags & 1 + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []) + ]) + : ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, [])); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression), + ts.createVariableDeclaration(result, undefined, next) + ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"))), node), 256); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1)), ts.createBlock([ + ts.createTry(ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createYield(undefined, enclosingFunctionFlags & 1 + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createFunctionCall(returnMethod, iterator, []) + ]) + : ts.createFunctionCall(returnMethod, iterator, [])))), 1) + ]), undefined, ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) + ]), 1)) + ])); } function visitParameter(node) { if (node.transformFlags & 1048576) { - return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); + return ts.updateParameter(node, undefined, undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } function visitConstructorDeclaration(node) { - return ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateConstructor(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitGetAccessorDeclaration(node) { - return ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateGetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitSetAccessorDeclaration(node) { - return ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0; + var updated = ts.updateSetAccessor(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitMethodDeclaration(node) { - return ts.updateMethod(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateMethod(node, undefined, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(undefined, visitor, ts.isToken), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, node.modifiers, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node)); + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1 + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 + ? undefined + : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1 + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; + } + function transformAsyncGeneratorFunctionBody(node) { + resumeLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, false, visitor); + appendObjectRestAssignmentsIfNeeded(statements, node); + statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression(undefined, ts.createToken(39), node.name && ts.getGeneratedNameForNode(node.name), undefined, [], undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.updateBlock(node.body, statements); + if (languageVersion >= 2) { + if (resolver.getNodeCheckFlags(node) & 4096) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; } function transformFunctionBody(node) { resumeLexicalEnvironment(); - var leadingStatements; + var statementOffset = 0; + var statements = []; + var body = ts.visitNode(node.body, visitor, ts.isConciseBody); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologue(statements, body.statements, false, visitor); + } + ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node)); + var trailingStatements = endLexicalEnvironment(); + if (statementOffset > 0 || ts.some(statements) || ts.some(trailingStatements)) { + var block = ts.convertToFunctionBody(body, true); + ts.addRange(statements, block.statements.slice(statementOffset)); + ts.addRange(statements, trailingStatements); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); + } + return body; + } + function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; if (parameter.transformFlags & 1048576) { @@ -42993,18 +45285,96 @@ var ts; var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true); if (ts.some(declarations)) { var statement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList(declarations)); - ts.setEmitFlags(statement, 524288); - leadingStatements = ts.append(leadingStatements, statement); + ts.setEmitFlags(statement, 1048576); + statements = ts.append(statements, statement); } } } - var body = ts.visitNode(node.body, visitor, ts.isConciseBody); - var trailingStatements = endLexicalEnvironment(); - if (ts.some(leadingStatements) || ts.some(trailingStatements)) { - var block = ts.convertToFunctionBody(body, true); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); + return statements; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1) === 0) { + enabledSubstitutions |= 1; + context.enableSubstitution(181); + context.enableSubstitution(179); + context.enableSubstitution(180); + context.enableEmitNotification(229); + context.enableEmitNotification(151); + context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(152); + } + } + function onEmitNode(hint, node, emitCallback) { + if (enabledSubstitutions & 1 && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179: + return substitutePropertyAccessExpression(node); + case 180: + return substituteElementAccessExpression(node); + case 181: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 + || kind === 152 + || kind === 151 + || kind === 153 + || kind === 154; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); } - return body; } } ts.transformESNext = transformESNext; @@ -43022,21 +45392,51 @@ var ts; return ts.createCall(ts.getHelperName("__assign"), undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; + var asyncGeneratorHelper = { + name: "typescript:asyncGenerator", + scoped: false, + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + }; + function createAsyncGeneratorHelper(context, generatorFunc) { + context.requestEmitHelper(asyncGeneratorHelper); + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144; + return ts.createCall(ts.getHelperName("__asyncGenerator"), undefined, [ + ts.createThis(), + ts.createIdentifier("arguments"), + generatorFunc + ]); + } + var asyncDelegator = { + name: "typescript:asyncDelegator", + scoped: false, + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " + }; + function createAsyncDelegatorHelper(context, expression, location) { + context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), undefined, [expression]), location); + } + var asyncValues = { + name: "typescript:asyncValues", + scoped: false, + text: "\n var __asyncValues = (this && this.__asyncIterator) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator];\n return m ? m.call(o) : typeof __values === \"function\" ? __values(o) : o[Symbol.iterator]();\n };\n " + }; + function createAsyncValuesHelper(context, expression, location) { + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), undefined, [expression]), location); + } })(ts || (ts = {})); var ts; (function (ts) { function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -43049,11 +45449,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 248: - return visitJsxElement(node, false); case 249: + return visitJsxElement(node, false); + case 250: return visitJsxSelfClosingElement(node, false); - case 255: + case 256: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43063,11 +45463,11 @@ var ts; switch (node.kind) { case 10: return visitJsxText(node); - case 255: + case 256: return visitJsxExpression(node); - case 248: - return visitJsxElement(node, true); case 249: + return visitJsxElement(node, true); + case 250: return visitJsxSelfClosingElement(node, true); default: ts.Debug.failBadSyntaxKind(node); @@ -43121,7 +45521,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 255) { + else if (node.kind === 256) { if (node.expression === undefined) { return ts.createTrue(); } @@ -43181,7 +45581,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 248) { + if (node.kind === 249) { return getTagName(node.openingElement); } else { @@ -43465,268 +45865,6 @@ var ts; }); })(ts || (ts = {})); var ts; -(function (ts) { - var ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); - function transformES2017(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var resolver = context.getEmitResolver(); - var compilerOptions = context.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - var currentSourceFile; - var enabledSubstitutions; - var currentSuperContainer; - var previousOnEmitNode = context.onEmitNode; - var previousOnSubstituteNode = context.onSubstituteNode; - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - var visited = ts.visitEachChild(node, visitor, context); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; - return visited; - } - function visitor(node) { - if ((node.transformFlags & 16) === 0) { - return node; - } - switch (node.kind) { - case 119: - return undefined; - case 190: - return visitAwaitExpression(node); - case 150: - return visitMethodDeclaration(node); - case 227: - return visitFunctionDeclaration(node); - case 185: - return visitFunctionExpression(node); - case 186: - return visitArrowFunction(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.setTextRange(ts.createYield(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); - } - function visitMethodDeclaration(node) { - return ts.updateMethod(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { - return ts.createOmittedExpression(); - } - return ts.updateFunctionExpression(node, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function transformAsyncFunctionBody(node) { - resumeLexicalEnvironment(); - var original = ts.getOriginalNode(node, ts.isFunctionLike); - var nodeType = original.type; - var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 186; - var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0; - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, true); - ts.setTextRange(block, node.body); - if (languageVersion >= 2) { - if (resolver.getNodeCheckFlags(node) & 4096) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, advancedAsyncSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & 2048) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, asyncSuperHelper); - } - } - return block; - } - else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); - var declarations = endLexicalEnvironment(); - if (ts.some(declarations)) { - var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); - } - return expression; - } - } - function transformFunctionBodyWorker(body, start) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); - } - else { - startLexicalEnvironment(); - var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); - var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); - } - } - function getPromiseConstructor(type) { - var typeName = type && ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1) === 0) { - enabledSubstitutions |= 1; - context.enableSubstitution(180); - context.enableSubstitution(178); - context.enableSubstitution(179); - context.enableEmitNotification(228); - context.enableEmitNotification(150); - context.enableEmitNotification(152); - context.enableEmitNotification(153); - context.enableEmitNotification(151); - } - } - function substituteExpression(node) { - switch (node.kind) { - case 178: - return substitutePropertyAccessExpression(node); - case 179: - return substituteElementAccessExpression(node); - case 180: - if (enabledSubstitutions & 1) { - return substituteCallExpression(node); - } - break; - } - return node; - } - function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 1 && node.expression.kind === 96) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } - return node; - } - function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 1 && node.expression.kind === 96) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } - return node; - } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 228 - || kind === 151 - || kind === 150 - || kind === 152 - || kind === 153; - } - function onEmitNode(hint, node, emitCallback) { - if (enabledSubstitutions & 1 && isSuperContainer(node)) { - var savedCurrentSuperContainer = currentSuperContainer; - currentSuperContainer = node; - previousOnEmitNode(hint, node, emitCallback); - currentSuperContainer = savedCurrentSuperContainer; - } - else { - previousOnEmitNode(hint, node, emitCallback); - } - } - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (hint === 1) { - return substituteExpression(node); - } - return node; - } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096) { - return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), "value"), location); - } - else { - return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), undefined, [argumentExpression]), location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 | 4096); - } - } - ts.transformES2017 = transformES2017; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); - var generatorFunc = ts.createFunctionExpression(undefined, ts.createToken(38), undefined, undefined, [], undefined, body); - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 131072; - return ts.createCall(ts.getHelperName("__awaiter"), undefined, [ - ts.createThis(), - hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), - promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), - generatorFunc - ]); - } - var awaiterHelper = { - name: "typescript:awaiter", - scoped: false, - priority: 5, - text: "\n var __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 asyncSuperHelper = { - name: "typescript:async-super", - scoped: true, - text: "\n const _super = name => super[name];" - }; - var advancedAsyncSuperHelper = { - name: "typescript:advanced-async-super", - scoped: true, - text: "\n const _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);" - }; -})(ts || (ts = {})); -var ts; (function (ts) { function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; @@ -43742,7 +45880,7 @@ var ts; return node; } switch (node.kind) { - case 193: + case 194: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43750,9 +45888,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 61: + case 62: return visitExponentiationAssignmentExpression(node); - case 39: + case 40: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -43861,6 +45999,7 @@ var ts; })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -43895,7 +46034,7 @@ var ts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 - && node.kind === 218 + && node.kind === 219 && !node.expression; } function shouldVisitNode(node) { @@ -43919,100 +46058,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 96) { + if (node.kind === 97) { return visitSuperKeyword(true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 114: + case 115: return undefined; - case 228: + case 229: return visitClassDeclaration(node); - case 198: + case 199: return visitClassExpression(node); - case 145: + case 146: return visitParameter(node); - case 227: + case 228: return visitFunctionDeclaration(node); - case 186: + case 187: return visitArrowFunction(node); - case 185: + case 186: return visitFunctionExpression(node); - case 225: - return visitVariableDeclaration(node); - case 70: - return visitIdentifier(node); case 226: + return visitVariableDeclaration(node); + case 71: + return visitIdentifier(node); + case 227: return visitVariableDeclarationList(node); - case 220: - return visitSwitchStatement(node); - case 234: - return visitCaseBlock(node); - case 206: - return visitBlock(node, false); - case 217: - case 216: - return visitBreakOrContinueStatement(node); case 221: + return visitSwitchStatement(node); + case 235: + return visitCaseBlock(node); + case 207: + return visitBlock(node, false); + case 218: + case 217: + return visitBreakOrContinueStatement(node); + case 222: return visitLabeledStatement(node); - case 211: case 212: - return visitDoOrWhileStatement(node, undefined); case 213: - return visitForStatement(node, undefined); + return visitDoOrWhileStatement(node, undefined); case 214: - return visitForInStatement(node, undefined); + return visitForStatement(node, undefined); case 215: + return visitForInStatement(node, undefined); + case 216: return visitForOfStatement(node, undefined); - case 209: + case 210: return visitExpressionStatement(node); - case 177: + case 178: return visitObjectLiteralExpression(node); - case 259: + case 260: return visitCatchClause(node); - case 261: + case 262: return visitShorthandPropertyAssignment(node); - case 143: + case 144: return visitComputedPropertyName(node); - case 176: + case 177: return visitArrayLiteralExpression(node); - case 180: - return visitCallExpression(node); case 181: + return visitCallExpression(node); + case 182: return visitNewExpression(node); - case 184: + case 185: return visitParenthesizedExpression(node, true); - case 193: + case 194: return visitBinaryExpression(node, true); - case 12: case 13: case 14: case 15: + case 16: return visitTemplateLiteral(node); - case 182: + case 9: + return visitStringLiteral(node); + case 8: + return visitNumericLiteral(node); + case 183: return visitTaggedTemplateExpression(node); - case 195: - return visitTemplateExpression(node); case 196: - return visitYieldExpression(node); + return visitTemplateExpression(node); case 197: + return visitYieldExpression(node); + case 198: return visitSpreadElement(node); - case 96: + case 97: return visitSuperKeyword(false); - case 98: + case 99: return visitThisKeyword(node); - case 203: + case 204: return visitMetaProperty(node); - case 150: + case 151: return visitMethodDeclaration(node); - case 152: case 153: + case 154: return visitAccessorDeclaration(node); - case 207: + case 208: return visitVariableStatement(node); - case 218: + case 219: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -44022,8 +46165,9 @@ var ts; var ancestorFacts = enterSubtree(3968, 64); var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, false, visitor); + var statementOffset = ts.addStandardPrologue(statements, node.statements, false); addCaptureThisForNodeIfNeeded(statements, node); + statementOffset = ts.addCustomPrologue(statements, node.statements, statementOffset, visitor); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0, 0); @@ -44089,13 +46233,13 @@ var ts; } function visitBreakOrContinueStatement(node) { if (convertedLoopState) { - var jump = node.kind === 217 ? 2 : 4; + var jump = node.kind === 218 ? 2 : 4; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 217) { + if (node.kind === 218) { convertedLoopState.nonLocalJumps |= 2; labelMarker = "break"; } @@ -44105,7 +46249,7 @@ var ts; } } else { - if (node.kind === 217) { + if (node.kind === 218) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, true, node.label.text, labelMarker); } @@ -44124,10 +46268,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 25, copyExpr); + expr = ts.createBinary(expr, 26, copyExpr); } } - returnExpression = ts.createBinary(expr, 25, returnExpression); + returnExpression = ts.createBinary(expr, 26, returnExpression); } return ts.createReturn(returnExpression); } @@ -44151,9 +46295,9 @@ var ts; statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 2097152) === 0) { + if ((emitFlags & 4194304) === 0) { statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 2097152); + ts.setEmitFlags(statement, emitFlags | 4194304); } return ts.singleOrMany(statements); } @@ -44166,8 +46310,8 @@ var ts; } var extendsClauseElement = ts.getClassExtendsHeritageClauseElement(node); var classFunction = ts.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [ts.createParameter(undefined, undefined, undefined, "_super")] : [], undefined, transformClassBody(node, extendsClauseElement)); - if (ts.getEmitFlags(node) & 32768) { - ts.setEmitFlags(classFunction, 32768); + if (ts.getEmitFlags(node) & 65536) { + ts.setEmitFlags(classFunction, 65536); } var inner = ts.createPartiallyEmittedExpression(classFunction); inner.end = node.end; @@ -44185,8 +46329,8 @@ var ts; addExtendsHelperIfNeeded(statements, node, extendsClauseElement); addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17); - var localName = ts.getLocalName(node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18); + var localName = ts.getInternalName(node); var outer = ts.createPartiallyEmittedExpression(localName); outer.end = closingBraceLocation.end; ts.setEmitFlags(outer, 1536); @@ -44210,7 +46354,7 @@ var ts; var ancestorFacts = enterSubtree(16278, 73); var constructor = ts.getFirstConstructorWithBody(node); var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); - var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getDeclarationName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); + var constructorFunction = ts.createFunctionDeclaration(undefined, undefined, undefined, ts.getInternalName(node), undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); if (extendsClauseElement) { ts.setEmitFlags(constructorFunction, 8); @@ -44231,14 +46375,17 @@ var ts; statementOffset = 0; } else if (constructor) { - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, false, visitor); + statementOffset = ts.addStandardPrologue(statements, constructor.body.statements, false); } if (constructor) { addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + if (!hasSynthesizedSuper) { + statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor); + } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94; + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); if (superCaptureStatus === 1 || superCaptureStatus === 2) { statementOffset++; @@ -44266,17 +46413,17 @@ var ts; return block; } function isSufficientlyCoveredByReturnStatements(statement) { - if (statement.kind === 218) { + if (statement.kind === 219) { return true; } - else if (statement.kind === 210) { + else if (statement.kind === 211) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 206) { + else if (statement.kind === 207) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -44305,7 +46452,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 209 && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 210 && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -44313,8 +46460,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 | 32768))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 193 - || superCallExpression.left.kind !== 180) { + if (superCallExpression.kind !== 194 + || superCallExpression.left.kind !== 181) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } ts.setCommentRange(returnStatement, ts.getCommentRange(ts.setEmitFlags(superCallExpression.left, 1536))); @@ -44371,10 +46518,10 @@ var ts; function addDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) { var temp = ts.getGeneratedNameForNode(parameter); if (name.elements.length > 0) { - statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 524288)); + statements.push(ts.setEmitFlags(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, temp))), 1048576)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 524288)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576)); } } function addDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) { @@ -44384,11 +46531,11 @@ var ts; ]), parameter), 1 | 32 | 384)); statement.startsOnNewLine = true; ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 | 32 | 524288); + ts.setEmitFlags(statement, 384 | 32 | 1048576); statements.push(statement); } function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 71 && !inConstructorWithSynthesizedSuper; } function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) { var parameter = ts.lastOrUndefined(node.parameters); @@ -44402,7 +46549,7 @@ var ts; var temp = ts.createLoopVariable(); statements.push(ts.setEmitFlags(ts.setTextRange(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration(declarationName, undefined, ts.createArrayLiteral([])) - ])), parameter), 524288)); + ])), parameter), 1048576)); var forStatement = ts.createFor(ts.setTextRange(ts.createVariableDeclarationList([ ts.createVariableDeclaration(temp, undefined, ts.createLiteral(restIndex)) ]), parameter), ts.setTextRange(ts.createLessThan(temp, ts.createPropertyAccess(ts.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(ts.createPostfixIncrement(temp), parameter), ts.createBlock([ @@ -44410,12 +46557,12 @@ var ts; ? temp : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), parameter)) ])); - ts.setEmitFlags(forStatement, 524288); + ts.setEmitFlags(forStatement, 1048576); ts.startOnNewLine(forStatement); statements.push(forStatement); } function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 && node.kind !== 186) { + if (node.transformFlags & 32768 && node.kind !== 187) { captureThisForNode(statements, node, ts.createThis()); } } @@ -44424,7 +46571,7 @@ var ts; var captureThisStatement = ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("_this", undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 | 524288); + ts.setEmitFlags(captureThisStatement, 1536 | 1048576); ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); @@ -44433,19 +46580,19 @@ var ts; if (hierarchyFacts & 16384) { var newTarget = void 0; switch (node.kind) { - case 186: + case 187: return statements; - case 150: - case 152: + case 151: case 153: + case 154: newTarget = ts.createVoidZero(); break; - case 151: + case 152: newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"); break; - case 227: - case 185: - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 92, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); + case 228: + case 186: + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4), 93, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4), "constructor"), ts.createVoidZero()); break; default: ts.Debug.failBadSyntaxKind(node); @@ -44465,20 +46612,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 205: + case 206: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 150: + case 151: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 152: case 153: + case 154: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 151: + case 152: break; default: ts.Debug.failBadSyntaxKind(node); @@ -44564,7 +46711,7 @@ var ts; return func; } function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 131072 + var ancestorFacts = ts.getEmitFlags(node) & 262144 ? enterSubtree(16278, 69) : enterSubtree(16286, 65); var savedConvertedLoopState = convertedLoopState; @@ -44578,7 +46725,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.updateFunctionExpression(node, undefined, name, undefined, parameters, undefined, body); + return ts.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body); } function visitFunctionDeclaration(node) { var savedConvertedLoopState = convertedLoopState; @@ -44593,7 +46740,7 @@ var ts; : node.name; exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; - return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, undefined, parameters, undefined, body); + return ts.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body); } function transformFunctionLikeToExpression(node, location, name, container) { var savedConvertedLoopState = convertedLoopState; @@ -44603,7 +46750,7 @@ var ts; : enterSubtree(16286, 65); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 && !name && (node.kind === 227 || node.kind === 185)) { + if (hierarchyFacts & 16384 && !name && (node.kind === 228 || node.kind === 186)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152, 0); @@ -44620,7 +46767,7 @@ var ts; var statementOffset; resumeLexicalEnvironment(); if (ts.isBlock(body)) { - statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + statementOffset = ts.addStandardPrologue(statements, body.statements, false); } addCaptureThisForNodeIfNeeded(statements, node); addDefaultValueAssignmentsIfNeeded(statements, node); @@ -44629,6 +46776,7 @@ var ts; multiLine = true; } if (ts.isBlock(body)) { + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor); statementsLocation = body.statements; ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); if (!multiLine && body.multiLine) { @@ -44636,7 +46784,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 186); + ts.Debug.assert(node.kind === 187); statementsLocation = ts.moveRangeEnd(body, -1); var equalsGreaterThanToken = node.equalsGreaterThanToken; if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) { @@ -44666,7 +46814,7 @@ var ts; ts.setEmitFlags(block, 1); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17, closeBraceLocation); + ts.setTokenSourceMapRange(block, 18, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -44688,9 +46836,9 @@ var ts; } function visitExpressionStatement(node) { switch (node.expression.kind) { - case 184: + case 185: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, false)); - case 193: + case 194: return ts.updateStatement(node, visitBinaryExpression(node.expression, false)); } return ts.visitEachChild(node, visitor, context); @@ -44698,9 +46846,9 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { if (!needsDestructuringValue) { switch (node.expression.kind) { - case 184: + case 185: return ts.updateParen(node, visitParenthesizedExpression(node.expression, false)); - case 193: + case 194: return ts.updateParen(node, visitBinaryExpression(node.expression, false)); } } @@ -44726,13 +46874,13 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0); } else { - assignment = ts.createBinary(decl.name, 57, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 58, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } - (assignments || (assignments = [])).push(assignment); + assignments = ts.append(assignments, assignment); } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25, acc); })), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 26, acc); })), node); } else { updated = undefined; @@ -44817,11 +46965,24 @@ var ts; if (convertedLoopState && !convertedLoopState.labels) { convertedLoopState.labels = ts.createMap(); } - var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); - return ts.isIterationStatement(statement, false) && shouldConvertIterationStatementBody(statement) + var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, false) ? visitIterationStatement(statement, node) : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 212: + case 213: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 214: + return visitForStatement(node, outermostLabeledStatement); + case 215: + return visitForInStatement(node, outermostLabeledStatement); + case 216: + return visitForOfStatement(node, outermostLabeledStatement); + } + } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); @@ -44838,27 +46999,19 @@ var ts; return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, convertForOfToFor); + return visitIterationStatementWithFacts(1984, 2304, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } - function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; + function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { var statements = []; - var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 - ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) - : ts.createTempVariable(undefined); - var elementAccess = ts.createElementAccess(rhsReference, counter); - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3) { + if (ts.isVariableDeclarationList(node.initializer)) { + if (node.initializer.flags & 3) { enableSubstitutionsForBlockScopedBindings(); } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); + var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations); - ts.setOriginalNode(declarationList, initializer); - ts.setTextRange(declarationList, initializer); + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue); + var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); + ts.setOriginalNode(declarationList, node.initializer); var firstDeclaration = declarations[0]; var lastDeclaration = ts.lastOrUndefined(declarations); ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); @@ -44866,18 +47019,19 @@ var ts; } else { statements.push(ts.setTextRange(ts.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, ts.createElementAccess(rhsReference, counter)) - ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(undefined), undefined, boundValue) + ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); } } else { - var assignment = ts.createAssignment(initializer, elementAccess); + var assignment = ts.createAssignment(node.initializer, boundValue); if (ts.isDestructuringAssignment(assignment)) { - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(assignment, visitor, context, 0))); + ts.aggregateTransformFlags(assignment); + statements.push(ts.createStatement(visitBinaryExpression(assignment, false))); } else { - assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); + assignment.end = node.initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); } } var bodyLocation; @@ -44886,7 +47040,7 @@ var ts; ts.addRange(statements, convertedLoopBodyStatements); } else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); if (ts.isBlock(statement)) { ts.addRange(statements, statement.statements); bodyLocation = statement; @@ -44896,30 +47050,49 @@ var ts; statements.push(statement); } } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384); + } + function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var counter = ts.createLoopVariable(); + var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression)); - var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation)); - ts.setTextRange(body, bodyLocation); - ts.setEmitFlags(body, 48 | 384); - var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + var forStatement = ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(counter, undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(ts.createVariableDeclaration(rhsReference, undefined, expression), node.expression) - ]), node.expression), 1048576), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); + ]), node.expression), 2097152), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), convertForOfStatementHead(node, ts.createElementAccess(rhsReference, counter), convertedLoopBodyStatements)), node); ts.setEmitFlags(forStatement, 256); ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } - function visitIterationStatement(node, outermostLabeledStatement) { - switch (node.kind) { - case 211: - case 212: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 213: - return visitForStatement(node, outermostLabeledStatement); - case 214: - return visitForInStatement(node, outermostLabeledStatement); - case 215: - return visitForOfStatement(node, outermostLabeledStatement); - } + function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(undefined); + var values = ts.createValuesHelper(context, expression, node.expression); + var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), undefined, []); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, undefined, values), node.expression), + ts.createVariableDeclaration(result, undefined, next) + ]), node.expression), 2097152), ts.createLogicalNot(ts.createPropertyAccess(result, "done")), ts.createAssignment(result, next), convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), node), 256); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1)), ts.createBlock([ + ts.createTry(ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1), + ]), undefined, ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1) + ]), 1)) + ])); } function visitObjectLiteralExpression(node) { var properties = node.properties; @@ -44932,7 +47105,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 143) { + if (property.name.kind === 144) { numInitialProperties = i; break; } @@ -44943,7 +47116,7 @@ var ts; } var temp = ts.createTempVariable(hoistVariableDeclaration); var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -44963,7 +47136,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 70) { + if (node.kind === 71) { state.hoistedLocalVariables.push(node); } else { @@ -44994,11 +47167,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 213: case 214: case 215: + case 216: var initializer = node.initializer; - if (initializer && initializer.kind === 226) { + if (initializer && initializer.kind === 227) { loopInitializer = initializer; } break; @@ -45025,7 +47198,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -45043,18 +47216,18 @@ var ts; else { loopBody = ts.createBlock([loopBody], true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 - && (node.statement.transformFlags & 16777216) !== 0; + var containsYield = (node.statement.transformFlags & 16777216) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8; } if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 131072; + loopBodyFlags |= 262144; } var convertedLoopVariable = ts.createVariableStatement(undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, isAsyncBlockContainingAwait ? ts.createToken(38) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) - ]), 1048576)); + ts.createVariableDeclaration(functionName, undefined, ts.setEmitFlags(ts.createFunctionExpression(undefined, containsYield ? ts.createToken(39) : undefined, undefined, undefined, loopParameters, undefined, loopBody), loopBodyFlags)) + ]), 2097152)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; if (currentState.argumentsName) { @@ -45099,7 +47272,7 @@ var ts; if (extraVariableDeclarations) { statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -45119,7 +47292,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 57, source); + return ts.createBinary(target, 58, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -45134,7 +47307,9 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38), call) : call; + var callResult = isAsyncBlockContainingAwait + ? ts.createYield(ts.createToken(39), ts.setEmitFlags(call, 8388608)) + : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0, statements); @@ -45153,10 +47328,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 33, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 34, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -45222,20 +47397,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 152: case 153: + case 154: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 150: + case 151: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 260: + case 261: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 261: + case 262: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -45304,7 +47479,20 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16286, 65); - var updated = ts.visitEachChild(node, visitor, context); + var updated; + if (node.transformFlags & 32768) { + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (node.kind === 153) { + updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + } + else { + updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body); + } + } + else { + updated = ts.visitEachChild(node, visitor, context); + } exitSubtree(ancestorFacts, 49152, 0); convertedLoopState = savedConvertedLoopState; return updated; @@ -45338,7 +47526,7 @@ var ts; } function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) { var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { ts.setEmitFlags(thisArg, 4); } var resultingCall; @@ -45348,7 +47536,7 @@ var ts; else { resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), node); } - if (node.expression.kind === 96) { + if (node.expression.kind === 97) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -45370,13 +47558,27 @@ var ts; var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 - ? ts.createArraySlice(segments[0]) - : segments[0]; + if (compilerOptions.downlevelIteration) { + if (segments.length === 1) { + var firstSegment = segments[0]; + if (ts.isCallExpression(firstSegment) + && ts.isIdentifier(firstSegment.expression) + && (ts.getEmitFlags(firstSegment.expression) & 4096) + && firstSegment.expression.text === "___spread") { + return segments[0]; + } + } + return ts.createSpreadHelper(context, segments); + } + else { + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 177 + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + return ts.createArrayConcat(segments.shift(), segments); } - return ts.createArrayConcat(segments.shift(), segments); } function partitionSpread(node) { return ts.isSpreadExpression(node) @@ -45398,6 +47600,18 @@ var ts; function visitTemplateLiteral(node) { return ts.setTextRange(ts.createLiteral(node.text), node); } + function visitStringLiteral(node) { + if (node.hasExtendedUnicodeEscape) { + return ts.setTextRange(ts.createLiteral(node.text), node); + } + return node; + } + function visitNumericLiteral(node) { + if (node.numericLiteralFlags & 48) { + return ts.setTextRange(ts.createNumericLiteral(node.text), node); + } + return node; + } function visitTaggedTemplateExpression(node) { var tag = ts.visitNode(node.tag, visitor, ts.isExpression); var temp = ts.createTempVariable(hoistVariableDeclaration); @@ -45427,7 +47641,7 @@ var ts; } function getRawLiteral(node) { var text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node); - var isLast = node.kind === 12 || node.kind === 15; + var isLast = node.kind === 13 || node.kind === 16; text = text.substring(1, text.length - (isLast ? 1 : 2)); text = text.replace(/\r\n?/g, "\n"); return ts.setTextRange(ts.createLiteral(text), node); @@ -45469,7 +47683,7 @@ var ts; : ts.createIdentifier("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 93 && node.name.text === "target") { + if (node.keywordToken === 94 && node.name.text === "target") { if (hierarchyFacts & 8192) { hierarchyFacts |= 32768; } @@ -45494,20 +47708,20 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2) === 0) { enabledSubstitutions |= 2; - context.enableSubstitution(70); + context.enableSubstitution(71); } } function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1) === 0) { enabledSubstitutions |= 1; - context.enableSubstitution(98); - context.enableEmitNotification(151); - context.enableEmitNotification(150); + context.enableSubstitution(99); context.enableEmitNotification(152); + context.enableEmitNotification(151); context.enableEmitNotification(153); + context.enableEmitNotification(154); + context.enableEmitNotification(187); context.enableEmitNotification(186); - context.enableEmitNotification(185); - context.enableEmitNotification(227); + context.enableEmitNotification(228); } } function onSubstituteNode(hint, node) { @@ -45521,10 +47735,10 @@ var ts; return node; } function substituteIdentifier(node) { - if (enabledSubstitutions & 2) { + if (enabledSubstitutions & 2 && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + return ts.setTextRange(ts.getGeneratedNameForNode(original), node); } } return node; @@ -45532,10 +47746,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 175: - case 228: - case 231: - case 225: + case 176: + case 229: + case 232: + case 226: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -45543,22 +47757,40 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 98: + case 99: return substituteThisKeyword(node); } return node; } function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2) { + if (enabledSubstitutions & 2 && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { + return ts.setTextRange(ts.getGeneratedNameForNode(declaration.name), node); } } return node; } + function isPartOfClassBody(declaration, node) { + var currentNode = ts.getParseTreeNode(node); + if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) { + return false; + } + var blockScope = ts.getEnclosingBlockScopeContainer(declaration); + while (currentNode) { + if (currentNode === blockScope || currentNode === declaration) { + return false; + } + if (ts.isClassElement(currentNode) && currentNode.parent === declaration) { + return currentNode.kind !== 149 + || (ts.getModifierFlags(currentNode) & 32) === 0; + } + currentNode = currentNode.parent; + } + return false; + } function substituteThisKeyword(node) { if (enabledSubstitutions & 1 && hierarchyFacts & 16) { @@ -45567,8 +47799,9 @@ var ts; return node; } function getClassMemberPrefix(node, member) { - var expression = ts.getLocalName(node); - return ts.hasModifier(member, 32) ? expression : ts.createPropertyAccess(expression, "prototype"); + return ts.hasModifier(member, 32) + ? ts.getInternalName(node) + : ts.createPropertyAccess(ts.getInternalName(node), "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { if (!constructor || !hasExtendsClause) { @@ -45578,19 +47811,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 210) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 181) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 198) { return false; } var expression = callArgument.expression; @@ -45733,13 +47966,13 @@ var ts; } function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 211: - return visitDoStatement(node); case 212: + return visitDoStatement(node); + case 213: return visitWhileStatement(node); - case 220: - return visitSwitchStatement(node); case 221: + return visitSwitchStatement(node); + case 222: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -45747,24 +47980,24 @@ var ts; } function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: + case 186: return visitFunctionExpression(node); - case 152: case 153: + case 154: return visitAccessorDeclaration(node); - case 207: + case 208: return visitVariableStatement(node); - case 213: - return visitForStatement(node); case 214: + return visitForStatement(node); + case 215: return visitForInStatement(node); - case 217: - return visitBreakStatement(node); - case 216: - return visitContinueStatement(node); case 218: + return visitBreakStatement(node); + case 217: + return visitContinueStatement(node); + case 219: return visitReturnStatement(node); default: if (node.transformFlags & 16777216) { @@ -45780,21 +48013,21 @@ var ts; } function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 193: - return visitBinaryExpression(node); case 194: + return visitBinaryExpression(node); + case 195: return visitConditionalExpression(node); - case 196: + case 197: return visitYieldExpression(node); - case 176: - return visitArrayLiteralExpression(node); case 177: + return visitArrayLiteralExpression(node); + case 178: return visitObjectLiteralExpression(node); - case 179: - return visitElementAccessExpression(node); case 180: - return visitCallExpression(node); + return visitElementAccessExpression(node); case 181: + return visitCallExpression(node); + case 182: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -45802,9 +48035,9 @@ var ts; } function visitGenerator(node) { switch (node.kind) { - case 227: + case 228: return visitFunctionDeclaration(node); - case 185: + case 186: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -45812,7 +48045,7 @@ var ts; } } function visitFunctionDeclaration(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration(undefined, node.modifiers, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { @@ -45833,7 +48066,7 @@ var ts; } } function visitFunctionExpression(node) { - if (node.asteriskToken && ts.getEmitFlags(node) & 131072) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node); } else { @@ -45886,7 +48119,7 @@ var ts; operationLocations = undefined; state = ts.createTempVariable(undefined); resumeLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, body.statements, false, visitor); + var statementOffset = ts.addPrologue(statements, body.statements, false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); ts.addRange(statements, endLexicalEnvironment()); @@ -45912,7 +48145,7 @@ var ts; return undefined; } else { - if (ts.getEmitFlags(node) & 524288) { + if (ts.getEmitFlags(node) & 1048576) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -45937,23 +48170,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 58 - && kind <= 69; + return kind >= 59 + && kind <= 70; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 58: return 36; case 59: return 37; case 60: return 38; case 61: return 39; case 62: return 40; case 63: return 41; - case 64: return 44; + case 64: return 42; case 65: return 45; case 66: return 46; case 67: return 47; case 68: return 48; case 69: return 49; + case 70: return 50; } } function visitRightAssociativeBinaryExpression(node) { @@ -45961,10 +48194,10 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 178: + case 179: target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 179: + case 180: target = ts.updateElementAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression))); break; default: @@ -45986,7 +48219,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 25) { + else if (node.operatorToken.kind === 26) { return visitCommaExpression(node); } var clone_5 = ts.getMutableClone(node); @@ -46000,7 +48233,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left); - if (node.operatorToken.kind === 52) { + if (node.operatorToken.kind === 53) { emitBreakWhenFalse(resultLabel, resultLocal, node.left); } else { @@ -46016,7 +48249,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26) { visit(node.left); visit(node.right); } @@ -46048,7 +48281,10 @@ var ts; var resumeLabel = defineLabel(); var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { - emitYieldStar(expression, node); + var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0 + ? ts.createValuesHelper(context, expression, node) + : expression; + emitYieldStar(iterator, node); } else { emitYield(expression, node); @@ -46061,25 +48297,27 @@ var ts; } function visitElements(elements, leadingElement, location, multiLine) { var numInitialElements = countInitialNodesWithoutYield(elements); - var temp = declareLocal(); - var hasAssignedTemp = false; + var temp; if (numInitialElements > 0) { + temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement ? [leadingElement].concat(initialElements) : initialElements)); leadingElement = undefined; - hasAssignedTemp = true; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); - return hasAssignedTemp + return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { + var hasAssignedTemp = temp !== undefined; + if (!temp) { + temp = declareLocal(); + } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); - hasAssignedTemp = true; leadingElement = undefined; expressions = []; } @@ -46160,38 +48398,38 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 206: + case 207: return transformAndEmitBlock(node); - case 209: - return transformAndEmitExpressionStatement(node); case 210: - return transformAndEmitIfStatement(node); + return transformAndEmitExpressionStatement(node); case 211: - return transformAndEmitDoStatement(node); + return transformAndEmitIfStatement(node); case 212: - return transformAndEmitWhileStatement(node); + return transformAndEmitDoStatement(node); case 213: - return transformAndEmitForStatement(node); + return transformAndEmitWhileStatement(node); case 214: + return transformAndEmitForStatement(node); + case 215: return transformAndEmitForInStatement(node); - case 216: - return transformAndEmitContinueStatement(node); case 217: - return transformAndEmitBreakStatement(node); + return transformAndEmitContinueStatement(node); case 218: - return transformAndEmitReturnStatement(node); + return transformAndEmitBreakStatement(node); case 219: - return transformAndEmitWithStatement(node); + return transformAndEmitReturnStatement(node); case 220: - return transformAndEmitSwitchStatement(node); + return transformAndEmitWithStatement(node); case 221: - return transformAndEmitLabeledStatement(node); + return transformAndEmitSwitchStatement(node); case 222: - return transformAndEmitThrowStatement(node); + return transformAndEmitLabeledStatement(node); case 223: + return transformAndEmitThrowStatement(node); + case 224: return transformAndEmitTryStatement(node); default: - return emitStatement(ts.visitNode(node, visitor, ts.isStatement, true)); + return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); } } function transformAndEmitBlock(node) { @@ -46343,7 +48581,7 @@ var ts; beginScriptLoopBlock(); } var initializer = node.initializer; - if (ts.isVariableDeclarationList(initializer)) { + if (initializer && ts.isVariableDeclarationList(initializer)) { for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { var variable = _a[_i]; hoistVariableDeclaration(variable.name); @@ -46351,7 +48589,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = ts.updateFor(node, variables.length > 0 ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression, true), ts.visitNode(node.incrementor, visitor, ts.isExpression, true), ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -46409,7 +48647,7 @@ var ts; var variable = _a[_i]; hoistVariableDeclaration(variable.name); } - node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -46448,10 +48686,10 @@ var ts; return ts.visitEachChild(node, visitor, context); } function transformAndEmitReturnStatement(node) { - emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression, true), node); + emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node); } function visitReturnStatement(node) { - return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression, true), node); + return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node); } function transformAndEmitWithStatement(node) { if (containsYield(node)) { @@ -46474,7 +48712,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 257 && defaultClauseIndex === -1) { + if (clause.kind === 258 && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -46484,7 +48722,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 256) { + if (clause.kind === 257) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -46600,7 +48838,7 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { + if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); @@ -46619,7 +48857,7 @@ var ts; } function cacheExpression(node) { var temp; - if (ts.isGeneratedIdentifier(node)) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) { return node; } temp = ts.createTempVariable(hoistVariableDeclaration); @@ -46711,15 +48949,22 @@ var ts; } function beginCatchBlock(variable) { ts.Debug.assert(peekBlockKind() === 0); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = []; - context.enableSubstitution(70); + var name; + if (ts.isGeneratedIdentifier(variable.name)) { + name = variable.name; + hoistVariableDeclaration(variable.name); + } + else { + var text = variable.name.text; + name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = []; + context.enableSubstitution(71); + } + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } - renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1); var endLabel = exception.endLabel; @@ -46919,7 +49164,7 @@ var ts; } function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = getInstructionName(instruction); + ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction)); return literal; } function createInlineBreak(label, location) { @@ -47001,7 +49246,7 @@ var ts; currentExceptionBlock = undefined; withBlockStack = undefined; var buildResult = buildStatements(); - return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 262144)); + return createGeneratorHelper(context, ts.setEmitFlags(ts.createFunctionExpression(undefined, undefined, undefined, undefined, [ts.createParameter(undefined, undefined, undefined, state)], undefined, ts.createBlock(buildResult, buildResult.length > 0)), 524288)); } function buildStatements() { if (operations) { @@ -47272,7 +49517,7 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); var ts; @@ -47284,24 +49529,24 @@ var ts; if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(250); context.enableEmitNotification(251); - context.enableEmitNotification(249); + context.enableEmitNotification(252); + context.enableEmitNotification(250); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178); - context.enableSubstitution(260); + context.enableSubstitution(179); + context.enableSubstitution(261); return transformSourceFile; function transformSourceFile(node) { return node; } function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 250: case 251: - case 249: + case 252: + case 250: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -47337,7 +49582,7 @@ var ts; } function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 && token <= 106) { + if (token >= 72 && token <= 107) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -47365,12 +49610,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(193); - context.enableSubstitution(191); + context.enableSubstitution(71); + context.enableSubstitution(194); context.enableSubstitution(192); - context.enableSubstitution(261); - context.enableEmitNotification(264); + context.enableSubstitution(193); + context.enableSubstitution(262); + context.enableEmitNotification(265); var moduleInfoMap = []; var deferredExports = []; var currentSourceFile; @@ -47378,9 +49623,7 @@ var ts; var noSubstitution; return transformSourceFile; function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (ts.isDeclarationFile(node) || !(ts.isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } currentSourceFile = node; @@ -47392,17 +49635,24 @@ var ts; currentModuleInfo = undefined; return ts.aggregateTransformFlags(updated); } + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) { + return true; + } + return false; + } function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, false); + ts.addRange(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(updated, exportStarHelper); @@ -47474,13 +49724,15 @@ var ts; var importNode = _c[_b]; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - ts.setEmitFlags(importAliasName, 4); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); + if (externalModuleName) { + if (includeNonAmdDependencies && importAliasName) { + ts.setEmitFlags(importAliasName, 4); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(undefined, undefined, undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; @@ -47488,14 +49740,14 @@ var ts; function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var statementOffset = ts.addPrologue(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, true); + ts.addRange(statements, endLexicalEnvironment()); var body = ts.createBlock(statements, true); if (currentModuleInfo.hasExportStarsToExportValues) { ts.addEmitHelper(body, exportStarHelper); @@ -47520,23 +49772,23 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 243: + case 244: return visitExportDeclaration(node); - case 242: + case 243: return visitExportAssignment(node); - case 207: + case 208: return visitVariableStatement(node); - case 227: - return visitFunctionDeclaration(node); case 228: + return visitFunctionDeclaration(node); + case 229: return visitClassDeclaration(node); - case 299: + case 297: return visitMergeDeclarationMarker(node); - case 300: + case 298: return visitEndOfDeclarationMarker(node); default: return node; @@ -47734,14 +49986,14 @@ var ts; } } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; + return (ts.getEmitFlags(node) & 4194304) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -47766,10 +50018,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239: + case 240: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240: + case 241: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -47854,7 +50106,7 @@ var ts; ]) ])); } - ts.setEmitFlags(statement, 524288); + ts.setEmitFlags(statement, 1048576); return statement; } function createExportStatement(name, value, location, allowComments) { @@ -47870,14 +50122,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264) { + if (node.kind === 265) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -47917,12 +50169,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 193: + case 194: return substituteBinaryExpression(node); + case 193: case 192: - case 191: return substituteUnaryExpression(node); } return node; @@ -47937,7 +50189,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 264) { + if (exportContainer && exportContainer.kind === 265) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), node); } var importDeclaration = resolver.getReferencedImportDeclaration(node); @@ -47973,15 +50225,15 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) + if ((node.operator === 43 || node.operator === 44) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 ? 58 : 59), ts.createLiteral(1)), node) + var expression = node.kind === 193 + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 ? 59 : 60), ts.createLiteral(1)), node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { var exportName = exportedNames_2[_i]; @@ -48022,11 +50274,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70); - context.enableSubstitution(193); - context.enableSubstitution(191); + context.enableSubstitution(71); + context.enableSubstitution(194); context.enableSubstitution(192); - context.enableEmitNotification(264); + context.enableSubstitution(193); + context.enableEmitNotification(265); var moduleInfoMap = []; var deferredExports = []; var exportFunctionsMap = []; @@ -48086,17 +50338,19 @@ var ts; for (var i = 0; i < externalImports.length; i++) { var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - var groupIndex = groupIndices.get(text); - if (groupIndex !== undefined) { - dependencyGroups[groupIndex].externalImports.push(externalImport); - } - else { - groupIndices.set(text, dependencyGroups.length); - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); + if (externalModuleName) { + var text = externalModuleName.text; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices.set(text, dependencyGroups.length); + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } } return dependencyGroups; @@ -48104,11 +50358,12 @@ var ts; function createSystemModuleBody(node, dependencyGroups) { var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); statements.push(ts.createVariableStatement(undefined, ts.createVariableDeclarationList([ ts.createVariableDeclaration("__moduleName", undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) ]))); - ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, true); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset); ts.addRange(statements, hoistedStatements); ts.addRange(statements, endLexicalEnvironment()); @@ -48129,7 +50384,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 243 && externalImport.exportClause) { + if (externalImport.kind === 244 && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -48152,7 +50407,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 243) { + if (externalImport.kind !== 244) { continue; } var exportDecl = externalImport; @@ -48204,15 +50459,15 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 237: + case 238: if (!entry.importClause) { break; } - case 236: + case 237: ts.Debug.assert(importVariableName !== undefined); statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 243: + case 244: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { var properties = []; @@ -48234,13 +50489,13 @@ var ts; } function sourceElementVisitor(node) { switch (node.kind) { - case 237: + case 238: return visitImportDeclaration(node); - case 236: + case 237: return visitImportEqualsDeclaration(node); - case 243: + case 244: return undefined; - case 242: + case 243: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -48289,7 +50544,7 @@ var ts; } function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1)) { - hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, true, true), undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); } else { hoistedStatements = ts.append(hoistedStatements, node); @@ -48360,8 +50615,8 @@ var ts; } } function shouldHoistVariableDeclarationList(node) { - return (ts.getEmitFlags(node) & 1048576) === 0 - && (enclosingBlockScopedContainer.kind === 264 + return (ts.getEmitFlags(node) & 2097152) === 0 + && (enclosingBlockScopedContainer.kind === 265 || (ts.getOriginalNode(node).flags & 3) === 0); } function transformInitializedVariable(node, isExportedDeclaration) { @@ -48383,7 +50638,7 @@ var ts; : preventSubstitution(ts.setTextRange(ts.createAssignment(name, value), location)); } function visitMergeDeclarationMarker(node) { - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -48391,7 +50646,7 @@ var ts; return node; } function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152) !== 0; + return (ts.getEmitFlags(node) & 4194304) !== 0; } function visitEndOfDeclarationMarker(node) { var id = ts.getOriginalNodeId(node); @@ -48416,10 +50671,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239: + case 240: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240: + case 241: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -48518,43 +50773,43 @@ var ts; } function nestedElementVisitor(node) { switch (node.kind) { - case 207: + case 208: return visitVariableStatement(node); - case 227: - return visitFunctionDeclaration(node); case 228: + return visitFunctionDeclaration(node); + case 229: return visitClassDeclaration(node); - case 213: - return visitForStatement(node); case 214: - return visitForInStatement(node); + return visitForStatement(node); case 215: + return visitForInStatement(node); + case 216: return visitForOfStatement(node); - case 211: - return visitDoStatement(node); case 212: + return visitDoStatement(node); + case 213: return visitWhileStatement(node); - case 221: + case 222: return visitLabeledStatement(node); - case 219: - return visitWithStatement(node); case 220: + return visitWithStatement(node); + case 221: return visitSwitchStatement(node); - case 234: + case 235: return visitCaseBlock(node); - case 256: - return visitCaseClause(node); case 257: + return visitCaseClause(node); + case 258: return visitDefaultClause(node); - case 223: + case 224: return visitTryStatement(node); - case 259: + case 260: return visitCatchClause(node); - case 206: + case 207: return visitBlock(node); - case 299: + case 297: return visitMergeDeclarationMarker(node); - case 300: + case 298: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -48563,21 +50818,21 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + node = ts.updateForOf(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -48586,6 +50841,9 @@ var ts; && shouldHoistVariableDeclarationList(node); } function visitForInitializer(node) { + if (!node) { + return node; + } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -48599,16 +50857,16 @@ var ts; } } function visitDoStatement(node) { - return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); } function visitWhileStatement(node) { - return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitLabeledStatement(node) { - return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitWithStatement(node) { - return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, false, ts.liftToBlock)); + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } function visitSwitchStatement(node) { return ts.updateSwitch(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock)); @@ -48645,7 +50903,7 @@ var ts; } function destructuringVisitor(node) { if (node.transformFlags & 1024 - && node.kind === 193) { + && node.kind === 194) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048) { @@ -48662,7 +50920,7 @@ var ts; return ts.visitEachChild(node, destructuringVisitor, context); } function hasExportedReferenceInDestructuringTarget(node) { - if (ts.isAssignmentExpression(node)) { + if (ts.isAssignmentExpression(node, true)) { return hasExportedReferenceInDestructuringTarget(node.left); } else if (ts.isSpreadExpression(node)) { @@ -48682,7 +50940,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 264; + return container !== undefined && container.kind === 265; } else { return false; @@ -48690,14 +50948,14 @@ var ts; } function modifierVisitor(node) { switch (node.kind) { - case 83: - case 78: + case 84: + case 79: return undefined; } return node; } function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264) { + if (node.kind === 265) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -48728,12 +50986,12 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70: + case 71: return substituteExpressionIdentifier(node); - case 193: + case 194: return substituteBinaryExpression(node); - case 191: case 192: + case 193: return substituteUnaryExpression(node); } return node; @@ -48778,22 +51036,22 @@ var ts; return node; } function substituteUnaryExpression(node) { - if ((node.operator === 42 || node.operator === 43) + if ((node.operator === 43 || node.operator === 44) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 + var expression = node.kind === 193 ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 192) { - expression = node.operator === 42 + if (node.kind === 193) { + expression = node.operator === 43 ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -48809,7 +51067,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, false); - if (exportContainer && exportContainer.kind === 264) { + if (exportContainer && exportContainer.kind === 265) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -48837,8 +51095,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(264); - context.enableSubstitution(70); + context.enableEmitNotification(265); + context.enableSubstitution(71); var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { @@ -48849,7 +51107,7 @@ var ts; var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); if (externalHelpersModuleName) { var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); + var statementOffset = ts.addPrologue(statements, node.statements); ts.append(statements, ts.createImportDeclaration(undefined, undefined, ts.createImportClause(undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); return ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); @@ -48862,9 +51120,9 @@ var ts; } function visitor(node) { switch (node.kind) { - case 236: + case 237: return undefined; - case 242: + case 243: return visitExportAssignment(node); } return node; @@ -48913,16 +51171,24 @@ var ts; return ts.transformModule; } } + var TransformationState; + (function (TransformationState) { + TransformationState[TransformationState["Uninitialized"] = 0] = "Uninitialized"; + TransformationState[TransformationState["Initialized"] = 1] = "Initialized"; + TransformationState[TransformationState["Completed"] = 2] = "Completed"; + TransformationState[TransformationState["Disposed"] = 3] = "Disposed"; + })(TransformationState || (TransformationState = {})); var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); - function getTransformers(compilerOptions) { + function getTransformers(compilerOptions, customTransformers) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; + ts.addRange(transformers, customTransformers && customTransformers.before); transformers.push(ts.transformTypeScript); if (jsx === 2) { transformers.push(ts.transformJsx); @@ -48944,12 +51210,12 @@ var ts; if (languageVersion < 1) { transformers.push(ts.transformES5); } + ts.addRange(transformers, customTransformers && customTransformers.after); return transformers; } ts.getTransformers = getTransformers; - function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(301); - var lexicalEnvironmentDisabled = false; + function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { + var enabledSyntaxKindFeatures = new Array(299); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -48957,8 +51223,11 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; + var onSubstituteNode = function (_, node) { return node; }; + var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var state = 0; var context = { - getCompilerOptions: function () { return host.getCompilerOptions(); }, + getCompilerOptions: function () { return options; }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, startLexicalEnvironment: startLexicalEnvironment, @@ -48969,46 +51238,57 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, - isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, - isEmitNotificationEnabled: isEmitNotificationEnabled + isSubstitutionEnabled: isSubstitutionEnabled, + isEmitNotificationEnabled: isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode; }, + set onSubstituteNode(value) { + ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode; }, + set onEmitNode(value) { + ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + } }; + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } ts.performance.mark("beforeTransform"); var transformation = ts.chain.apply(void 0, transformers)(context); - var transformed = ts.map(sourceFiles, transformSourceFile); - lexicalEnvironmentDisabled = true; + state = 1; + var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot); + state = 2; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, - emitNodeWithSubstitution: emitNodeWithSubstitution, - emitNodeWithNotification: emitNodeWithNotification + substituteNode: substituteNode, + emitNodeWithNotification: emitNodeWithNotification, + dispose: dispose }; - function transformSourceFile(sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return sourceFile; - } - return transformation(sourceFile); + function transformRoot(node) { + return node && (!ts.isSourceFile(node) || !ts.isDeclarationFile(node)) ? transformation(node) : node; } function enableSubstitution(kind) { + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 1; } function isSubstitutionEnabled(node) { return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0 && (ts.getEmitFlags(node) & 4) === 0; } - function emitNodeWithSubstitution(hint, node, emitCallback) { - if (node) { - if (isSubstitutionEnabled(node)) { - node = context.onSubstituteNode(hint, node) || node; - } - emitCallback(hint, node); - } + function substituteNode(hint, node) { + ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } function enableEmitNotification(kind) { + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 2; } function isEmitNotificationEnabled(node) { @@ -49016,9 +51296,10 @@ var ts; || (ts.getEmitFlags(node) & 2) !== 0; } function emitNodeWithNotification(hint, node, emitCallback) { + ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(hint, node, emitCallback); + onEmitNode(hint, node, emitCallback); } else { emitCallback(hint, node); @@ -49026,7 +51307,8 @@ var ts; } } function hoistVariableDeclaration(name) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); var decl = ts.createVariableDeclaration(name); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; @@ -49036,7 +51318,8 @@ var ts; } } function hoistFunctionDeclaration(func) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -49045,7 +51328,8 @@ var ts; } } function startLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations; lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations; @@ -49054,17 +51338,20 @@ var ts; lexicalEnvironmentFunctionDeclarations = undefined; } function suspendLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } function resumeLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } function endLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { @@ -49091,18 +51378,36 @@ var ts; return statements; } function requestEmitHelper(helper) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } + function dispose() { + if (state < 3) { + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentVariableDeclarationsStack = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentFunctionDeclarationsStack = undefined; + onSubstituteNode = undefined; + onEmitNode = undefined; + emitHelpers = undefined; + state = 3; + } + } } - ts.transformFiles = transformFiles; + ts.transformNodes = transformNodes; })(ts || (ts = {})); var ts; (function (ts) { @@ -49117,8 +51422,8 @@ var ts; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { - var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; - var isBundledEmit = sourceFileOrBundle.kind === 265; + var sourceFiles = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 266; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -49180,7 +51485,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 237); + ts.Debug.assert(aliasEmitInfo.node.kind === 238); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -49253,10 +51558,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 225) { + if (declaration.kind === 226) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 240 || declaration.kind === 241 || declaration.kind === 238) { + else if (declaration.kind === 241 || declaration.kind === 242 || declaration.kind === 239) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -49267,7 +51572,7 @@ var ts; moduleElementEmitInfo = ts.forEach(asynchronousSubModuleDeclarationEmitInfo, function (declEmitInfo) { return declEmitInfo.node === nodeToCheck ? declEmitInfo : undefined; }); } if (moduleElementEmitInfo) { - if (moduleElementEmitInfo.node.kind === 237) { + if (moduleElementEmitInfo.node.kind === 238) { moduleElementEmitInfo.isVisible = true; } else { @@ -49275,12 +51580,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 232) { + if (nodeToCheck.kind === 233) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 232) { + if (nodeToCheck.kind === 233) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -49342,7 +51647,7 @@ var ts; function writeTypeOfDeclaration(declaration, type, getSymbolAccessibilityDiagnostic) { writer.getSymbolAccessibilityDiagnostic = getSymbolAccessibilityDiagnostic; write(": "); - var shouldUseResolverType = declaration.kind === 145 && + var shouldUseResolverType = declaration.kind === 146 && resolver.isRequiredInitializedParameter(declaration); if (type && !shouldUseResolverType) { emitType(type); @@ -49368,15 +51673,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var node = nodes_6[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { - var node = nodes_5[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -49402,74 +51707,74 @@ var ts; } function emitType(type) { switch (type.kind) { - case 118: - case 135: - case 132: - case 121: - case 133: + case 119: case 136: - case 104: - case 138: - case 94: - case 129: - case 168: - case 172: - return writeTextOfNode(currentText, type); - case 200: - return emitExpressionWithTypeArguments(type); - case 158: - return emitTypeReference(type); - case 161: - return emitTypeQuery(type); - case 163: - return emitArrayType(type); - case 164: - return emitTupleType(type); - case 165: - return emitUnionType(type); - case 166: - return emitIntersectionType(type); - case 167: - return emitParenType(type); + case 133: + case 122: + case 134: + case 137: + case 105: + case 139: + case 95: + case 130: case 169: - return emitTypeOperator(type); - case 170: - return emitIndexedAccessType(type); - case 171: - return emitMappedType(type); + case 173: + return writeTextOfNode(currentText, type); + case 201: + return emitExpressionWithTypeArguments(type); case 159: - case 160: - return emitSignatureDeclarationWithJsDocComments(type); + return emitTypeReference(type); case 162: + return emitTypeQuery(type); + case 164: + return emitArrayType(type); + case 165: + return emitTupleType(type); + case 166: + return emitUnionType(type); + case 167: + return emitIntersectionType(type); + case 168: + return emitParenType(type); + case 170: + return emitTypeOperator(type); + case 171: + return emitIndexedAccessType(type); + case 172: + return emitMappedType(type); + case 160: + case 161: + return emitSignatureDeclarationWithJsDocComments(type); + case 163: return emitTypeLiteral(type); - case 70: + case 71: return emitEntityName(type); - case 142: + case 143: return emitEntityName(type); - case 157: + case 158: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 70) { + if (entityName.kind === 71) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 142 ? entityName.left : entityName.expression; - var right = entityName.kind === 142 ? entityName.right : entityName.name; + var left = entityName.kind === 143 ? entityName.left : entityName.expression; + var right = entityName.kind === 143 ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); } } function emitEntityName(entityName) { - var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 236 ? entityName.parent : enclosingDeclaration); + var visibilityResult = resolver.isEntityNameVisible(entityName, entityName.parent.kind === 237 ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 || node.expression.kind === 178); + ts.Debug.assert(node.expression.kind === 71 || node.expression.kind === 179); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -49586,7 +51891,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -49607,7 +51912,7 @@ var ts; } write(";"); writeLine(); - if (node.expression.kind === 70) { + if (node.expression.kind === 71) { var nodes = resolver.collectLinkedAliases(node.expression); writeAsynchronousModuleElements(nodes); } @@ -49625,10 +51930,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 236 || - (node.parent.kind === 264 && isCurrentFileExternalModule)) { + else if (node.kind === 237 || + (node.parent.kind === 265 && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 265) { asynchronousSubModuleDeclarationEmitInfo.push({ node: node, outputPos: writer.getTextPos(), @@ -49637,7 +51942,7 @@ var ts; }); } else { - if (node.kind === 237) { + if (node.kind === 238) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -49655,30 +51960,30 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 227: - return writeFunctionDeclaration(node); - case 207: - return writeVariableStatement(node); - case 229: - return writeInterfaceDeclaration(node); case 228: - return writeClassDeclaration(node); + return writeFunctionDeclaration(node); + case 208: + return writeVariableStatement(node); case 230: - return writeTypeAliasDeclaration(node); + return writeInterfaceDeclaration(node); + case 229: + return writeClassDeclaration(node); case 231: - return writeEnumDeclaration(node); + return writeTypeAliasDeclaration(node); case 232: + return writeEnumDeclaration(node); + case 233: return writeModuleDeclaration(node); - case 236: - return writeImportEqualsDeclaration(node); case 237: + return writeImportEqualsDeclaration(node); + case 238: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); } } function emitModuleElementDeclarationFlags(node) { - if (node.parent.kind === 264) { + if (node.parent.kind === 265) { var modifiers = ts.getModifierFlags(node); if (modifiers & 1) { write("export "); @@ -49686,7 +51991,7 @@ var ts; if (modifiers & 512) { write("default "); } - else if (node.kind !== 229 && !noDeclare) { + else if (node.kind !== 230 && !noDeclare) { write("declare "); } } @@ -49736,7 +52041,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 239) { + if (namedBindings.kind === 240) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -49759,7 +52064,7 @@ var ts; if (currentWriterPos !== writer.getTextPos()) { write(", "); } - if (node.importClause.namedBindings.kind === 239) { + if (node.importClause.namedBindings.kind === 240) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -49776,13 +52081,13 @@ var ts; writer.writeLine(); } function emitExternalModuleSpecifier(parent) { - resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 232; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 233; var moduleSpecifier; - if (parent.kind === 236) { + if (parent.kind === 237) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 232) { + else if (parent.kind === 233) { moduleSpecifier = parent.name; } else { @@ -49850,7 +52155,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 233) { + while (node.body && node.body.kind !== 234) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -49920,7 +52225,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 150 && ts.hasModifier(node.parent, 8); + return node.parent.kind === 151 && ts.hasModifier(node.parent, 8); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -49930,15 +52235,15 @@ var ts; writeTextOfNode(currentText, node.name); if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - (node.parent.parent && node.parent.parent.kind === 162)) { - ts.Debug.assert(node.parent.kind === 150 || - node.parent.kind === 149 || - node.parent.kind === 159 || + if (node.parent.kind === 160 || + node.parent.kind === 161 || + (node.parent.parent && node.parent.parent.kind === 163)) { + ts.Debug.assert(node.parent.kind === 151 || + node.parent.kind === 150 || node.parent.kind === 160 || - node.parent.kind === 154 || - node.parent.kind === 155); + node.parent.kind === 161 || + node.parent.kind === 155 || + node.parent.kind === 156); emitType(node.constraint); } else { @@ -49947,15 +52252,15 @@ var ts; } if (node.default && !isPrivateMethodTypeParameter(node)) { write(" = "); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - (node.parent.parent && node.parent.parent.kind === 162)) { - ts.Debug.assert(node.parent.kind === 150 || - node.parent.kind === 149 || - node.parent.kind === 159 || + if (node.parent.kind === 160 || + node.parent.kind === 161 || + (node.parent.parent && node.parent.parent.kind === 163)) { + ts.Debug.assert(node.parent.kind === 151 || + node.parent.kind === 150 || node.parent.kind === 160 || - node.parent.kind === 154 || - node.parent.kind === 155); + node.parent.kind === 161 || + node.parent.kind === 155 || + node.parent.kind === 156); emitType(node.default); } else { @@ -49965,34 +52270,34 @@ var ts; function getTypeParameterConstraintVisibilityError() { var diagnosticMessage; switch (node.parent.kind) { - case 228: + case 229: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 229: + case 230: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 155: + case 156: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154: + case 155: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; + case 151: case 150: - case 149: if (ts.hasModifier(node.parent, 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 === 228) { + else if (node.parent.parent.kind === 229) { 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 227: + case 228: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 230: + case 231: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -50020,7 +52325,7 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 94) { + else if (!isImplementsList && node.expression.kind === 95) { write("null"); } else { @@ -50031,7 +52336,7 @@ var ts; } function getHeritageClauseVisibilityError() { var diagnosticMessage; - if (node.parent.parent.kind === 228) { + if (node.parent.parent.kind === 229) { 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; @@ -50115,17 +52420,17 @@ var ts; writeLine(); } function emitVariableDeclaration(node) { - if (node.kind !== 225 || resolver.isDeclarationVisible(node)) { + if (node.kind !== 226 || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } else { writeTextOfNode(currentText, node.name); - if ((node.kind === 148 || node.kind === 147 || - (node.kind === 145 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 149 || node.kind === 148 || + (node.kind === 146 && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 148 || node.kind === 147) && node.parent.kind === 162) { + if ((node.kind === 149 || node.kind === 148) && node.parent.kind === 163) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -50138,14 +52443,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 225) { + if (node.kind === 226) { 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 === 148 || node.kind === 147) { + else if (node.kind === 149 || node.kind === 148) { if (ts.hasModifier(node, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -50153,7 +52458,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { 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 : @@ -50179,7 +52484,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 199) { + if (element.kind !== 200) { elements.push(element); } } @@ -50245,7 +52550,7 @@ var ts; accessorWithTypeAnnotation = node; var type = getTypeAnnotationFromAccessor(node); if (!type) { - var anotherAccessor = node.kind === 152 ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 153 ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -50258,7 +52563,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 152 + return accessor.kind === 153 ? accessor.type : accessor.parameters.length > 0 ? accessor.parameters[0].type @@ -50267,7 +52572,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 153) { + if (accessorWithTypeAnnotation.kind === 154) { if (ts.hasModifier(accessorWithTypeAnnotation.parent, 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 : @@ -50313,17 +52618,17 @@ var ts; } if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 227) { + if (node.kind === 228) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 150 || node.kind === 151) { + else if (node.kind === 151 || node.kind === 152) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 227) { + if (node.kind === 228) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 151) { + else if (node.kind === 152) { write("constructor"); } else { @@ -50343,15 +52648,15 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 156) { + if (node.kind === 157) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { - if (node.kind === 155 || node.kind === 160) { + if (node.kind === 156 || node.kind === 161) { write("new "); } - else if (node.kind === 159) { + else if (node.kind === 160) { var currentOutput = writer.getText(); if (node.typeParameters && currentOutput.charAt(currentOutput.length - 1) === "<") { closeParenthesizedFunctionType = true; @@ -50362,20 +52667,20 @@ var ts; write("("); } emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 156) { + if (node.kind === 157) { write("]"); } else { write(")"); } - var isFunctionTypeOrConstructorType = node.kind === 159 || node.kind === 160; - if (isFunctionTypeOrConstructorType || node.parent.kind === 162) { + var isFunctionTypeOrConstructorType = node.kind === 160 || node.kind === 161; + if (isFunctionTypeOrConstructorType || node.parent.kind === 163) { if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 151 && !ts.hasModifier(node, 8)) { + else if (node.kind !== 152 && !ts.hasModifier(node, 8)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -50389,23 +52694,23 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 155: + case 156: 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 154: + case 155: 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 156: + case 157: 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 151: case 150: - case 149: if (ts.hasModifier(node, 32)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -50413,7 +52718,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 228) { + else if (node.parent.kind === 229) { 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 : @@ -50426,7 +52731,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 227: + case 228: 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 : @@ -50458,9 +52763,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 159 || - node.parent.kind === 160 || - node.parent.parent.kind === 162) { + if (node.parent.kind === 160 || + node.parent.kind === 161 || + node.parent.parent.kind === 163) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8)) { @@ -50476,26 +52781,26 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 151: + case 152: 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 155: + case 156: 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 154: + case 155: 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 156: + case 157: return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; + case 151: case 150: - case 149: if (ts.hasModifier(node.parent, 32)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 ? @@ -50503,7 +52808,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 228) { + else if (node.parent.parent.kind === 229) { 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 : @@ -50515,7 +52820,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 227: + case 228: 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 : @@ -50526,12 +52831,12 @@ var ts; } } function emitBindingPattern(bindingPattern) { - if (bindingPattern.kind === 173) { + if (bindingPattern.kind === 174) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 174) { + else if (bindingPattern.kind === 175) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -50542,10 +52847,10 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 199) { + if (bindingElement.kind === 200) { write(" "); } - else if (bindingElement.kind === 175) { + else if (bindingElement.kind === 176) { if (bindingElement.propertyName) { writeTextOfNode(currentText, bindingElement.propertyName); write(": "); @@ -50555,7 +52860,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 70); + ts.Debug.assert(bindingElement.name.kind === 71); if (bindingElement.dotDotDotToken) { write("..."); } @@ -50567,39 +52872,39 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 227: - case 232: - case 236: - case 229: case 228: - case 230: - case 231: - return emitModuleElement(node, isModuleElementVisible(node)); - case 207: - return emitModuleElement(node, isVariableStatementVisible(node)); + case 233: case 237: + case 230: + case 229: + case 231: + case 232: + return emitModuleElement(node, isModuleElementVisible(node)); + case 208: + return emitModuleElement(node, isVariableStatementVisible(node)); + case 238: return emitModuleElement(node, !node.importClause); - case 243: + case 244: return emitExportDeclaration(node); + case 152: case 151: case 150: - case 149: return writeFunctionDeclaration(node); - case 155: - case 154: case 156: + case 155: + case 157: return emitSignatureDeclarationWithJsDocComments(node); - case 152: case 153: + case 154: return emitAccessorDeclaration(node); + case 149: case 148: - case 147: return emitPropertyDeclaration(node); - case 263: - return emitEnumMemberDeclaration(node); - case 242: - return emitExportAssignment(node); case 264: + return emitEnumMemberDeclaration(node); + case 243: + return emitExportAssignment(node); + case 265: return emitSourceFile(node); } } @@ -50618,7 +52923,7 @@ var ts; } return addedBundledEmitReference; function getDeclFileName(emitFileNames, sourceFileOrBundle) { - var isBundledEmit = sourceFileOrBundle.kind === 265; + var isBundledEmit = sourceFileOrBundle.kind === 266; if (isBundledEmit && !addBundledFileReference) { return; } @@ -50632,7 +52937,7 @@ var ts; var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { - var sourceFiles = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var sourceFiles = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -50717,7 +53022,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 264) { + if (sourceFileOrBundle.kind === 265) { sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); } if (!ts.isRootedDiskPath(sourceMapDir) && !ts.isUrl(sourceMapDir)) { @@ -50817,7 +53122,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 297 + if (node.kind !== 295 && (emitFlags & 16) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -50830,7 +53135,7 @@ var ts; else { emitCallback(hint, node); } - if (node.kind !== 297 + if (node.kind !== 295 && (emitFlags & 32) === 0 && end >= 0) { emitPos(end); @@ -50959,23 +53264,18 @@ var ts; return; } if (node) { - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var emitFlags = ts.getEmitFlags(node); + hasWrittenComment = false; + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 297; + var isEmittedNode = node.kind !== 295; var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0; if (!skipLeadingComments) { @@ -50989,23 +53289,16 @@ var ts; } if (!skipTrailingComments) { containerEnd = end; - if (node.kind === 226) { + if (node.kind === 227) { declarationListContainerEnd = end; } } if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & 2048) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); if (extendedDiagnostics) { - ts.performance.mark("beginEmitNodeWithComment"); + ts.performance.mark("postEmitNodeWithComment"); } containerPos = savedContainerPos; containerEnd = savedContainerEnd; @@ -51014,11 +53307,75 @@ var ts; emitTrailingComments(end); } if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitNodeWithComment"); + ts.performance.measure("commentTime", "postEmitNodeWithComment"); } } } } + function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { + var leadingComments = emitNode && emitNode.leadingComments; + if (ts.some(leadingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("preEmitNodeWithSynthesizedComments"); + } + ts.forEach(leadingComments, emitLeadingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); + } + } + emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); + var trailingComments = emitNode && emitNode.trailingComments; + if (ts.some(trailingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("postEmitNodeWithSynthesizedComments"); + } + ts.forEach(trailingComments, emitTrailingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); + } + } + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2) { + writer.writeLine(); + } + else { + writer.write(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.write(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { + if (emitFlags & 2048) { + disabled = true; + emitCallback(hint, node); + disabled = false; + } + else { + emitCallback(hint, node); + } + } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { if (extendedDiagnostics) { ts.performance.mark("preEmitBodyWithDetachedComments"); @@ -51211,14 +53568,13 @@ var ts; (function (ts) { var delimiters = createDelimiterMap(); var brackets = createBracketsMap(); - function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers) { var compilerOptions = host.getCompilerOptions(); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var sourceMap = ts.createSourceMapWriter(host, writer); var currentSourceFile; @@ -51226,11 +53582,11 @@ var ts; var isOwnFileEmit; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); - var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var transform = ts.transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, false); var printer = createPrinter(compilerOptions, { hasGlobalName: resolver.hasGlobalName, onEmitNode: transform.emitNodeWithNotification, - onSubstituteNode: transform.emitNodeWithSubstitution, + substituteNode: transform.substituteNode, onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, onEmitSourceMapOfPosition: sourceMap.emitPos, @@ -51240,10 +53596,7 @@ var ts; ts.performance.mark("beforePrint"); ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; - ts.disposeEmitNodes(sourceFile); - } + transform.dispose(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -51276,8 +53629,8 @@ var ts; } } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { - var bundle = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 264 ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 266 ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 265 ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); if (bundle) { @@ -51313,7 +53666,7 @@ var ts; } function emitHelpers(node, writeLines) { var helpersEmitted = false; - var bundle = node.kind === 265 ? node : undefined; + var bundle = node.kind === 266 ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -51352,9 +53705,8 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray; var newLine = ts.getNewLineCharacter(printerOptions); - var languageVersion = ts.getEmitScriptTarget(printerOptions); var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; var currentSourceFile; @@ -51387,8 +53739,8 @@ var ts; break; } switch (node.kind) { - case 264: return printFile(node); - case 265: return printBundle(node); + case 265: return printFile(node); + case 266: return printBundle(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -51411,6 +53763,8 @@ var ts; function writeBundle(bundle, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(bundle); + emitPrologueDirectivesIfNeeded(bundle); emitHelpersIndirect(bundle); for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { var sourceFile = _b[_a]; @@ -51422,6 +53776,8 @@ var ts; function writeFile(sourceFile, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(sourceFile); + emitPrologueDirectivesIfNeeded(sourceFile); print(0, sourceFile, sourceFile); reset(); writer = previousWriter; @@ -51458,9 +53814,8 @@ var ts; comments.reset(); setWriter(undefined); } - function emit(node, hint) { - if (hint === void 0) { hint = 3; } - pipelineEmitWithNotification(hint, node); + function emit(node) { + pipelineEmitWithNotification(3, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2, node); @@ -51477,6 +53832,7 @@ var ts; } } function pipelineEmitWithComments(hint, node) { + node = trySubstituteNode(hint, node); if (emitNodeWithComments && hint !== 0) { emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); } @@ -51486,15 +53842,7 @@ var ts; } function pipelineEmitWithSourceMap(hint, node) { if (onEmitSourceMapOfNode && hint !== 0 && hint !== 2) { - onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); - } - else { - pipelineEmitWithSubstitution(hint, node); - } - } - function pipelineEmitWithSubstitution(hint, node) { - if (onSubstituteNode) { - onSubstituteNode(hint, node, pipelineEmitWithHint); + onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); } else { pipelineEmitWithHint(hint, node); @@ -51523,200 +53871,204 @@ var ts; return; } switch (kind) { - case 13: case 14: case 15: + case 16: return emitLiteral(node); - case 70: + case 71: return emitIdentifier(node); - case 142: - return emitQualifiedName(node); case 143: - return emitComputedPropertyName(node); + return emitQualifiedName(node); case 144: - return emitTypeParameter(node); + return emitComputedPropertyName(node); case 145: - return emitParameter(node); + return emitTypeParameter(node); case 146: - return emitDecorator(node); + return emitParameter(node); case 147: - return emitPropertySignature(node); + return emitDecorator(node); case 148: - return emitPropertyDeclaration(node); + return emitPropertySignature(node); case 149: - return emitMethodSignature(node); + return emitPropertyDeclaration(node); case 150: - return emitMethodDeclaration(node); + return emitMethodSignature(node); case 151: - return emitConstructor(node); + return emitMethodDeclaration(node); case 152: + return emitConstructor(node); case 153: - return emitAccessorDeclaration(node); case 154: - return emitCallSignature(node); + return emitAccessorDeclaration(node); case 155: - return emitConstructSignature(node); + return emitCallSignature(node); case 156: - return emitIndexSignature(node); + return emitConstructSignature(node); case 157: - return emitTypePredicate(node); + return emitIndexSignature(node); case 158: - return emitTypeReference(node); + return emitTypePredicate(node); case 159: - return emitFunctionType(node); + return emitTypeReference(node); case 160: - return emitConstructorType(node); + return emitFunctionType(node); case 161: - return emitTypeQuery(node); + return emitConstructorType(node); case 162: - return emitTypeLiteral(node); + return emitTypeQuery(node); case 163: - return emitArrayType(node); + return emitTypeLiteral(node); case 164: - return emitTupleType(node); + return emitArrayType(node); case 165: - return emitUnionType(node); + return emitTupleType(node); case 166: - return emitIntersectionType(node); + return emitUnionType(node); case 167: - return emitParenthesizedType(node); - case 200: - return emitExpressionWithTypeArguments(node); + return emitIntersectionType(node); case 168: - return emitThisType(); + return emitParenthesizedType(node); + case 201: + return emitExpressionWithTypeArguments(node); case 169: - return emitTypeOperator(node); + return emitThisType(); case 170: - return emitIndexedAccessType(node); + return emitTypeOperator(node); case 171: - return emitMappedType(node); + return emitIndexedAccessType(node); case 172: - return emitLiteralType(node); + return emitMappedType(node); case 173: - return emitObjectBindingPattern(node); + return emitLiteralType(node); case 174: - return emitArrayBindingPattern(node); + return emitObjectBindingPattern(node); case 175: + return emitArrayBindingPattern(node); + case 176: return emitBindingElement(node); - case 204: - return emitTemplateSpan(node); case 205: - return emitSemicolonClassElement(); + return emitTemplateSpan(node); case 206: - return emitBlock(node); + return emitSemicolonClassElement(); case 207: - return emitVariableStatement(node); + return emitBlock(node); case 208: - return emitEmptyStatement(); + return emitVariableStatement(node); case 209: - return emitExpressionStatement(node); + return emitEmptyStatement(); case 210: - return emitIfStatement(node); + return emitExpressionStatement(node); case 211: - return emitDoStatement(node); + return emitIfStatement(node); case 212: - return emitWhileStatement(node); + return emitDoStatement(node); case 213: - return emitForStatement(node); + return emitWhileStatement(node); case 214: - return emitForInStatement(node); + return emitForStatement(node); case 215: - return emitForOfStatement(node); + return emitForInStatement(node); case 216: - return emitContinueStatement(node); + return emitForOfStatement(node); case 217: - return emitBreakStatement(node); + return emitContinueStatement(node); case 218: - return emitReturnStatement(node); + return emitBreakStatement(node); case 219: - return emitWithStatement(node); + return emitReturnStatement(node); case 220: - return emitSwitchStatement(node); + return emitWithStatement(node); case 221: - return emitLabeledStatement(node); + return emitSwitchStatement(node); case 222: - return emitThrowStatement(node); + return emitLabeledStatement(node); case 223: - return emitTryStatement(node); + return emitThrowStatement(node); case 224: - return emitDebuggerStatement(node); + return emitTryStatement(node); case 225: - return emitVariableDeclaration(node); + return emitDebuggerStatement(node); case 226: - return emitVariableDeclarationList(node); + return emitVariableDeclaration(node); case 227: - return emitFunctionDeclaration(node); + return emitVariableDeclarationList(node); case 228: - return emitClassDeclaration(node); + return emitFunctionDeclaration(node); case 229: - return emitInterfaceDeclaration(node); + return emitClassDeclaration(node); case 230: - return emitTypeAliasDeclaration(node); + return emitInterfaceDeclaration(node); case 231: - return emitEnumDeclaration(node); + return emitTypeAliasDeclaration(node); case 232: - return emitModuleDeclaration(node); + return emitEnumDeclaration(node); case 233: - return emitModuleBlock(node); + return emitModuleDeclaration(node); case 234: + return emitModuleBlock(node); + case 235: return emitCaseBlock(node); - case 236: - return emitImportEqualsDeclaration(node); case 237: - return emitImportDeclaration(node); + return emitImportEqualsDeclaration(node); case 238: - return emitImportClause(node); + return emitImportDeclaration(node); case 239: - return emitNamespaceImport(node); + return emitImportClause(node); case 240: - return emitNamedImports(node); + return emitNamespaceImport(node); case 241: - return emitImportSpecifier(node); + return emitNamedImports(node); case 242: - return emitExportAssignment(node); + return emitImportSpecifier(node); case 243: - return emitExportDeclaration(node); + return emitExportAssignment(node); case 244: - return emitNamedExports(node); + return emitExportDeclaration(node); case 245: - return emitExportSpecifier(node); + return emitNamedExports(node); case 246: - return; + return emitExportSpecifier(node); case 247: + return; + case 248: return emitExternalModuleReference(node); case 10: return emitJsxText(node); - case 250: - return emitJsxOpeningElement(node); case 251: - return emitJsxClosingElement(node); + return emitJsxOpeningElement(node); case 252: - return emitJsxAttribute(node); + return emitJsxClosingElement(node); case 253: - return emitJsxAttributes(node); + return emitJsxAttribute(node); case 254: - return emitJsxSpreadAttribute(node); + return emitJsxAttributes(node); case 255: - return emitJsxExpression(node); + return emitJsxSpreadAttribute(node); case 256: - return emitCaseClause(node); + return emitJsxExpression(node); case 257: - return emitDefaultClause(node); + return emitCaseClause(node); case 258: - return emitHeritageClause(node); + return emitDefaultClause(node); case 259: - return emitCatchClause(node); + return emitHeritageClause(node); case 260: - return emitPropertyAssignment(node); + return emitCatchClause(node); case 261: - return emitShorthandPropertyAssignment(node); + return emitPropertyAssignment(node); case 262: - return emitSpreadAssignment(node); + return emitShorthandPropertyAssignment(node); case 263: + return emitSpreadAssignment(node); + case 264: return emitEnumMember(node); } if (ts.isExpression(node)) { - return pipelineEmitWithSubstitution(1, node); + return pipelineEmitExpression(trySubstituteNode(1, node)); + } + if (ts.isToken(node)) { + writeTokenText(kind); + return; } } function pipelineEmitExpression(node) { @@ -51725,87 +54077,82 @@ var ts; case 8: return emitNumericLiteral(node); case 9: - case 11: case 12: + case 13: return emitLiteral(node); - case 70: + case 71: return emitIdentifier(node); - case 85: - case 94: - case 96: - case 100: - case 98: + case 86: + case 95: + case 97: + case 101: + case 99: writeTokenText(kind); return; - case 176: - return emitArrayLiteralExpression(node); case 177: - return emitObjectLiteralExpression(node); + return emitArrayLiteralExpression(node); case 178: - return emitPropertyAccessExpression(node); + return emitObjectLiteralExpression(node); case 179: - return emitElementAccessExpression(node); + return emitPropertyAccessExpression(node); case 180: - return emitCallExpression(node); + return emitElementAccessExpression(node); case 181: - return emitNewExpression(node); + return emitCallExpression(node); case 182: - return emitTaggedTemplateExpression(node); + return emitNewExpression(node); case 183: - return emitTypeAssertionExpression(node); + return emitTaggedTemplateExpression(node); case 184: - return emitParenthesizedExpression(node); + return emitTypeAssertionExpression(node); case 185: - return emitFunctionExpression(node); + return emitParenthesizedExpression(node); case 186: - return emitArrowFunction(node); + return emitFunctionExpression(node); case 187: - return emitDeleteExpression(node); + return emitArrowFunction(node); case 188: - return emitTypeOfExpression(node); + return emitDeleteExpression(node); case 189: - return emitVoidExpression(node); + return emitTypeOfExpression(node); case 190: - return emitAwaitExpression(node); + return emitVoidExpression(node); case 191: - return emitPrefixUnaryExpression(node); + return emitAwaitExpression(node); case 192: - return emitPostfixUnaryExpression(node); + return emitPrefixUnaryExpression(node); case 193: - return emitBinaryExpression(node); + return emitPostfixUnaryExpression(node); case 194: - return emitConditionalExpression(node); + return emitBinaryExpression(node); case 195: - return emitTemplateExpression(node); + return emitConditionalExpression(node); case 196: - return emitYieldExpression(node); + return emitTemplateExpression(node); case 197: - return emitSpreadExpression(node); + return emitYieldExpression(node); case 198: - return emitClassExpression(node); + return emitSpreadExpression(node); case 199: + return emitClassExpression(node); + case 200: return; - case 201: - return emitAsExpression(node); case 202: - return emitNonNullExpression(node); + return emitAsExpression(node); case 203: + return emitNonNullExpression(node); + case 204: return emitMetaProperty(node); - case 248: - return emitJsxElement(node); case 249: + return emitJsxElement(node); + case 250: return emitJsxSelfClosingElement(node); - case 298: + case 296: return emitPartiallyEmittedExpression(node); } } - function emitBodyIndirect(node, elements, emitCallback) { - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(node, elements, emitCallback); - } - else { - emitCallback(node); - } + function trySubstituteNode(hint, node) { + return node && substituteNode && substituteNode(hint, node) || node; } function emitHelpersIndirect(node) { if (onEmitHelpers) { @@ -51814,9 +54161,6 @@ var ts; } function emitNumericLiteral(node) { emitLiteral(node); - if (node.trailingComment) { - write(" /*" + node.trailingComment + "*/"); - } } function emitLiteral(node) { var text = getLiteralTextOfNode(node); @@ -51837,7 +54181,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -51859,8 +54203,8 @@ var ts; writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator) { write("@"); @@ -51907,7 +54251,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 152 ? "get " : "set "); + write(node.kind === 153 ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -52068,12 +54412,12 @@ var ts; write("{}"); } else { - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } var preferNewLine = node.multiLine ? 32768 : 0; - var allowTrailingComma = languageVersion >= 1 ? 32 : 0; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 ? 32 : 0; emitList(node, properties, 978 | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -52083,10 +54427,10 @@ var ts; function emitPropertyAccessExpression(node) { var indentBeforeDot = false; var indentAfterDot = false; - if (!(ts.getEmitFlags(node) & 65536)) { + if (!(ts.getEmitFlags(node) & 131072)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 22, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 23, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -52099,11 +54443,11 @@ var ts; decreaseIndentIf(indentBeforeDot, indentAfterDot); } function needsDotDotForPropertyAccess(expression) { - if (expression.kind === 8) { + expression = ts.skipPartiallyEmittedExpressions(expression); + if (ts.isNumericLiteral(expression)) { var text = getLiteralTextOfNode(expression); - return ts.getNumericLiteralFlags(text, 15) === 0 - && !expression.isOctalLiteral - && text.indexOf(ts.tokenToString(22)) < 0; + return !expression.numericLiteralFlags + && text.indexOf(ts.tokenToString(23)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { var constantValue = ts.getConstantValue(expression); @@ -52184,16 +54528,16 @@ var ts; } function shouldEmitWhitespaceBeforeOperand(node) { var operand = node.operand; - return operand.kind === 191 - && ((node.operator === 36 && (operand.operator === 36 || operand.operator === 42)) - || (node.operator === 37 && (operand.operator === 37 || operand.operator === 43))); + return operand.kind === 192 + && ((node.operator === 37 && (operand.operator === 37 || operand.operator === 43)) + || (node.operator === 38 && (operand.operator === 38 || operand.operator === 44))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 25; + var isCommaOperator = node.operatorToken.kind !== 26; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -52261,17 +54605,17 @@ var ts; } function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(16, node.pos, node); + writeToken(17, node.pos, node); write(" "); - writeToken(17, node.statements.end, node); + writeToken(18, node.statements.end, node); } else { - writeToken(16, node.pos, node); + writeToken(17, node.pos, node); emitBlockStatements(node); increaseIndent(); emitLeadingCommentsOfPosition(node.statements.end); decreaseIndent(); - writeToken(17, node.statements.end, node); + writeToken(18, node.statements.end, node); } } function emitBlockStatements(node) { @@ -52295,16 +54639,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(89, node.pos, node); + var openParenPos = writeToken(90, node.pos, node); write(" "); - writeToken(18, openParenPos, node); + writeToken(19, openParenPos, node); emitExpression(node.expression); - writeToken(19, node.expression.end, node); + writeToken(20, node.expression.end, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - writeToken(81, node.thenStatement.end, node); - if (node.elseStatement.kind === 210) { + writeToken(82, node.thenStatement.end, node); + if (node.elseStatement.kind === 211) { write(" "); emit(node.elseStatement); } @@ -52333,9 +54677,9 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos, node); + writeToken(19, openParenPos, node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -52345,28 +54689,29 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(87, node.pos); + var openParenPos = writeToken(88, node.pos); write(" "); - writeToken(18, openParenPos); + emitWithSuffix(node.awaitModifier, " "); + writeToken(19, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 226) { + if (node.kind === 227) { emit(node); } else { @@ -52375,17 +54720,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(76, node.pos); + writeToken(77, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(71, node.pos); + writeToken(72, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(95, node.pos, node); + writeToken(96, node.pos, node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -52396,11 +54741,11 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(97, node.pos); + var openParenPos = writeToken(98, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emitExpression(node.expression); - writeToken(19, node.expression.end); + writeToken(20, node.expression.end); write(" "); emit(node.caseBlock); } @@ -52428,7 +54773,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(77, node.pos); + writeToken(78, node.pos); write(";"); } function emitVariableDeclaration(node) { @@ -52450,22 +54795,35 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint, body) { + emitBlockFunctionBody(body); + } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } - if (ts.getEmitFlags(node) & 262144) { + if (ts.getEmitFlags(node) & 524288) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } if (indentedFlag) { @@ -52518,9 +54876,14 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - emitBodyIndirect(body, body.statements, emitBlockFunctionBody); + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); + } + else { + emitBlockFunctionBody(body); + } decreaseIndent(); - writeToken(17, body.statements.end, body); + writeToken(18, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, true); @@ -52546,7 +54909,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = ts.getEmitFlags(node) & 32768; + var indentedFlag = ts.getEmitFlags(node) & 65536; if (indentedFlag) { increaseIndent(); } @@ -52597,7 +54960,7 @@ var ts; write(node.flags & 16 ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 232) { + while (body.kind === 233) { write("."); emit(body.name); body = body.body; @@ -52612,16 +54975,15 @@ var ts; else { pushNameGenerationScope(); write("{"); - increaseIndent(); emitBlockStatements(node); write("}"); popNameGenerationScope(); } } function emitCaseBlock(node) { - writeToken(16, node.pos); + writeToken(17, node.pos); emitList(node, node.clauses, 65); - writeToken(17, node.clauses.end); + writeToken(18, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -52632,7 +54994,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -52762,7 +55124,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 70) { + if (node.kind === 71) { emitExpression(node); } else { @@ -52799,11 +55161,11 @@ var ts; emitList(node, node.types, 272); } function emitCatchClause(node) { - var openParenPos = writeToken(73, node.pos); + var openParenPos = writeToken(74, node.pos); write(" "); - writeToken(18, openParenPos); + writeToken(19, openParenPos); emit(node.variableDeclaration); - writeToken(19, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(20, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -52836,27 +55198,43 @@ var ts; } function emitSourceFile(node) { writeLine(); - emitShebang(); - emitBodyIndirect(node, node.statements, emitSourceFileWorker); + var statements = node.statements; + if (emitBodyWithDetachedComments) { + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; + } + } + emitSourceFileWorker(node); } function emitSourceFileWorker(node) { var statements = node.statements; - var statementOffset = emitPrologueDirectives(statements); pushNameGenerationScope(); emitHelpersIndirect(node); - emitList(node, statements, 1, statementOffset); + var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); + emitList(node, statements, 1, index === -1 ? statements.length : index); popNameGenerationScope(); } function emitPartiallyEmittedExpression(node) { emitExpression(node.expression); } - function emitPrologueDirectives(statements, startWithNewLine) { + function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { for (var i = 0; i < statements.length; i++) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); + var statement = statements[i]; + if (ts.isPrologueDirective(statement)) { + var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; + if (shouldEmitPrologueDirective) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statement); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(statement.expression.text, statement.expression.text); + } } - emit(statements[i]); } else { return i; @@ -52864,11 +55242,36 @@ var ts; } return statements.length; } - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - writeLine(); + function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + setSourceFile(sourceFileOrBundle); + emitPrologueDirectives(sourceFileOrBundle.statements); + } + else { + var seenPrologueDirectives = ts.createMap(); + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + setSourceFile(sourceFile); + emitPrologueDirectives(sourceFile.statements, true, seenPrologueDirectives); + } + } + } + function emitShebangIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + var shebang = ts.getShebang(sourceFileOrBundle.text); + if (shebang) { + write(shebang); + writeLine(); + return true; + } + } + else { + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + if (emitShebangIfNeeded(sourceFile)) { + break; + } + } } } function emitModifiers(node, modifiers) { @@ -52953,6 +55356,9 @@ var ts; if (format & 7680) { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } if (isEmpty) { if (format & 1) { writeLine(); @@ -53029,6 +55435,9 @@ var ts; write(" "); } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } if (format & 7680) { write(getClosingBracket(format)); } @@ -53090,7 +55499,7 @@ var ts; for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { var line = lines_1[_a]; for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) { if (indentation === undefined || i < indentation) { indentation = i; break; @@ -53213,7 +55622,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 184 && ts.nodeIsSynthesized(node)) { + while (node.kind === 185 && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -53243,7 +55652,7 @@ var ts; return getLiteralTextOfNode(textSourceNode); } } - return ts.getLiteralText(node, currentSourceFile, languageVersion); + return ts.getLiteralText(node, currentSourceFile); } function pushNameGenerationScope() { tempFlagsStack.push(tempFlags); @@ -53341,23 +55750,23 @@ var ts; } function generateNameForNode(node) { switch (node.kind) { - case 70: + case 71: return makeUniqueName(getTextOfNode(node)); + case 233: case 232: - case 231: return generateNameForModuleOrEnum(node); - case 237: - case 243: + case 238: + case 244: return generateNameForImportOrExportDeclaration(node); - case 227: case 228: - case 242: + case 229: + case 243: return generateNameForExportDefault(); - case 198: + case 199: return generateNameForClassExpression(); - case 150: - case 152: + case 151: case 153: + case 154: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0); @@ -53488,6 +55897,7 @@ var ts; var ts; (function (ts) { var emptyArray = []; + var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } while (true) { @@ -53547,7 +55957,6 @@ var ts; function getCanonicalFileName(fileName) { return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - var unsupportedFileEncodingErrorCode = -2147024809; function getSourceFile(fileName, languageVersion, onError) { var text; try { @@ -53558,9 +55967,7 @@ var ts; } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } @@ -53723,6 +56130,8 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; + var cachedSemanticDiagnosticsForFile = {}; + var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0; @@ -53882,7 +56291,7 @@ var ts; : emptyArray; var j = 0; for (var i = 0; i < result.length; i++) { - if (result[i] == predictedToResolveToAmbientModuleMarker) { + if (result[i] === predictedToResolveToAmbientModuleMarker) { result[i] = undefined; } else { @@ -54033,13 +56442,13 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -54060,7 +56469,8 @@ var ts; } var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -54121,16 +56531,45 @@ var ts; } } function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + var includeCheckDiagnostics = !ts.isSourceFileJavaScript(sourceFile) || ts.isCheckJsEnabledForFile(sourceFile, options); + var checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return ts.isSourceFileJavaScript(sourceFile) + ? ts.filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + function shouldReportDiagnostic(diagnostic) { + var file = diagnostic.file, start = diagnostic.start; + if (file) { + var lineStarts = ts.getLineStarts(file); + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + while (line > 0) { + var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + return true; + } + if (result[3]) { + return false; + } + line--; + } + } + return true; + } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; @@ -54139,57 +56578,57 @@ var ts; return diagnostics; function walk(node) { switch (parent.kind) { - case 145: - case 148: + case 146: + case 149: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - case 150: - case 149: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: - case 227: - case 225: + case 228: + case 187: + case 228: + case 226: if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); return; } } switch (node.kind) { - case 236: + case 237: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 242: + case 243: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 258: + case 259: var heritageClause = node; - if (heritageClause.token === 107) { + if (heritageClause.token === 108) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 229: + case 230: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 232: + case 233: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 230: + case 231: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 231: + case 232: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 183: + case 184: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -54204,53 +56643,53 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, 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)); } switch (parent.kind) { - case 228: - case 150: - case 149: + case 229: case 151: + case 150: case 152: case 153: - case 185: - case 227: + case 154: case 186: - case 227: + case 228: + case 187: + case 228: if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - case 207: + case 208: if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 207); + return checkModifiers(nodes, parent.kind === 208); } break; - case 148: + case 149: if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 114) { + if (modifier.kind !== 115) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 145: + case 146: if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 180: case 181: - case 200: + case 182: + case 201: if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); return; } break; } - for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { - var node = nodes_6[_b]; + for (var _b = 0, nodes_8 = nodes; _b < nodes_8.length; _b++) { + var node = nodes_8[_b]; walk(node); } } @@ -54258,21 +56697,21 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 75: + case 76: if (isConstValid) { continue; } - case 113: - case 111: + case 114: case 112: - case 130: - case 123: - case 116: + case 113: + case 131: + case 124: + case 117: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; - case 114: - case 83: - case 78: + case 115: + case 84: + case 79: } } } @@ -54286,11 +56725,33 @@ var ts; }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } + function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) { + var cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + if (cachedResult) { + return cachedResult; + } + var result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = ts.createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } @@ -54349,9 +56810,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { + case 238: case 237: - case 236: - case 243: + case 244: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9) { break; @@ -54363,7 +56824,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 232: + case 233: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2) || ts.isDeclarationFile(file))) { var moduleName = node.name; if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(moduleName.text))) { @@ -54447,7 +56908,7 @@ var ts; if (file_1 && options.forceConsistentCasingInFileNames && ts.getNormalizedAbsolutePath(file_1.fileName, currentDirectory) !== ts.getNormalizedAbsolutePath(fileName, currentDirectory)) { reportFileNamesDifferOnlyInCasingError(fileName, file_1.fileName, refFile, refPos, refEnd); } - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); @@ -54605,8 +57066,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var file = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var file = sourceFiles_2[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -54617,8 +57078,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var sourceFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -54711,7 +57172,7 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } - if (options.noImplicitUseStrict && options.alwaysStrict) { + if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); } var languageVersion = options.target || 0; @@ -54751,6 +57212,9 @@ var ts; if (!options.noEmit && options.allowJs && options.declaration) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); @@ -54932,7 +57396,7 @@ var ts; ScriptElementKind.interfaceElement = "interface"; ScriptElementKind.typeElement = "type"; ScriptElementKind.enumElement = "enum"; - ScriptElementKind.enumMemberElement = "const"; + ScriptElementKind.enumMemberElement = "enum member"; ScriptElementKind.variableElement = "var"; ScriptElementKind.localVariableElement = "local var"; ScriptElementKind.functionElement = "function"; @@ -55038,34 +57502,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 145: - case 225: - case 175: - case 148: - case 147: - case 260: - case 261: - case 263: - case 150: + case 146: + case 226: + case 176: case 149: + case 148: + case 261: + case 262: + case 264: case 151: + case 150: case 152: case 153: - case 227: - case 185: - case 186: - case 259: - case 252: - return 1; - case 144: - case 229: - case 230: - case 162: - return 2; + case 154: case 228: + case 186: + case 187: + case 260: + case 253: + return 1; + case 145: + case 230: case 231: - return 1 | 2; + case 163: + return 2; + case 229: case 232: + return 1 | 2; + case 233: if (ts.isAmbientModule(node)) { return 4 | 1; } @@ -55075,24 +57539,24 @@ var ts; else { return 4; } - case 240: case 241: - case 236: - case 237: case 242: + case 237: + case 238: case 243: + case 244: return 1 | 2 | 4; - case 264: + case 265: return 4 | 1; } return 1 | 2 | 4; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 264) { + if (node.kind === 265) { return 1; } - else if (node.parent.kind === 242) { + else if (node.parent.kind === 243) { return 1 | 2 | 4; } else if (isInRightSideOfImport(node)) { @@ -55113,16 +57577,16 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 70); - if (node.parent.kind === 142 && + ts.Debug.assert(node.kind === 71); + if (node.parent.kind === 143 && node.parent.right === node && - node.parent.parent.kind === 236) { + node.parent.parent.kind === 237) { return 1 | 2 | 4; } return 4; } function isInRightSideOfImport(node) { - while (node.parent.kind === 142) { + while (node.parent.kind === 143) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -55133,27 +57597,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 142) { - while (root.parent && root.parent.kind === 142) { + if (root.parent.kind === 143) { + while (root.parent && root.parent.kind === 143) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 158 && !isLastClause; + return root.parent.kind === 159 && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 178) { - while (root.parent && root.parent.kind === 178) { + if (root.parent.kind === 179) { + while (root.parent && root.parent.kind === 179) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 200 && root.parent.parent.kind === 258) { + if (!isLastClause && root.parent.kind === 201 && root.parent.parent.kind === 259) { var decl = root.parent.parent.parent; - return (decl.kind === 228 && root.parent.parent.token === 107) || - (decl.kind === 229 && root.parent.parent.token === 84); + return (decl.kind === 229 && root.parent.parent.token === 108) || + (decl.kind === 230 && root.parent.parent.token === 85); } return false; } @@ -55161,17 +57625,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 158 || - (node.parent.kind === 200 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 98 && !ts.isPartOfExpression(node)) || - node.kind === 168; + return node.parent.kind === 159 || + (node.parent.kind === 201 && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 99 && !ts.isPartOfExpression(node)) || + node.kind === 169; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180); + return isCallOrNewExpressionTarget(node, 181); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 181); + return isCallOrNewExpressionTarget(node, 182); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -55184,7 +57648,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 221 && referenceNode.label.text === labelName) { + if (referenceNode.kind === 222 && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -55193,14 +57657,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 70 && - (node.parent.kind === 217 || node.parent.kind === 216) && + return node.kind === 71 && + (node.parent.kind === 218 || node.parent.kind === 217) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 70 && - node.parent.kind === 221 && + return node.kind === 71 && + node.parent.kind === 222 && node.parent.label === node; } function isLabelName(node) { @@ -55208,38 +57672,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 142 && node.parent.right === node; + return node.parent.kind === 143 && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 178 && node.parent.name === node; + return node && node.parent && node.parent.kind === 179 && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 232 && node.parent.name === node; + return node.parent.kind === 233 && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 70 && + return node.kind === 71 && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 || node.kind === 8) { switch (node.parent.kind) { - case 148: - case 147: - case 260: - case 263: - case 150: case 149: - case 152: + case 148: + case 261: + case 264: + case 151: + case 150: case 153: - case 232: + case 154: + case 233: return node.parent.name === node; - case 179: + case 180: return node.parent.argumentExpression === node; - case 143: + case 144: return true; } } @@ -55283,17 +57747,17 @@ var ts; return undefined; } switch (node.kind) { - case 264: + case 265: + case 151: case 150: - case 149: - case 227: - case 185: - case 152: - case 153: case 228: + case 186: + case 153: + case 154: case 229: - case 231: + case 230: case 232: + case 233: return node; } } @@ -55301,46 +57765,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 264: + case 265: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 232: + case 233: return ts.ScriptElementKind.moduleElement; - case 228: - case 198: + case 229: + case 199: return ts.ScriptElementKind.classElement; - case 229: return ts.ScriptElementKind.interfaceElement; - case 230: return ts.ScriptElementKind.typeElement; - case 231: return ts.ScriptElementKind.enumElement; - case 225: + case 230: return ts.ScriptElementKind.interfaceElement; + case 231: return ts.ScriptElementKind.typeElement; + case 232: return ts.ScriptElementKind.enumElement; + case 226: return getKindOfVariableDeclaration(node); - case 175: + case 176: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); + case 187: + case 228: case 186: - case 227: - case 185: return ts.ScriptElementKind.functionElement; - case 152: return ts.ScriptElementKind.memberGetAccessorElement; - case 153: return ts.ScriptElementKind.memberSetAccessorElement; + case 153: return ts.ScriptElementKind.memberGetAccessorElement; + case 154: return ts.ScriptElementKind.memberSetAccessorElement; + case 151: case 150: - case 149: return ts.ScriptElementKind.memberFunctionElement; + case 149: case 148: - case 147: return ts.ScriptElementKind.memberVariableElement; - case 156: return ts.ScriptElementKind.indexSignatureElement; - case 155: return ts.ScriptElementKind.constructSignatureElement; - case 154: return ts.ScriptElementKind.callSignatureElement; - case 151: return ts.ScriptElementKind.constructorImplementationElement; - case 144: return ts.ScriptElementKind.typeParameterElement; - case 263: return ts.ScriptElementKind.enumMemberElement; - case 145: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 236: - case 241: - case 238: - case 245: + case 157: return ts.ScriptElementKind.indexSignatureElement; + case 156: return ts.ScriptElementKind.constructSignatureElement; + case 155: return ts.ScriptElementKind.callSignatureElement; + case 152: return ts.ScriptElementKind.constructorImplementationElement; + case 145: return ts.ScriptElementKind.typeParameterElement; + case 264: return ts.ScriptElementKind.enumMemberElement; + case 146: return ts.hasModifier(node, 92) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 237: + case 242: case 239: + case 246: + case 240: return ts.ScriptElementKind.alias; - case 289: + case 290: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -55354,21 +57818,12 @@ var ts; } } ts.getNodeKind = getNodeKind; - function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 172 ? node.parent : node; - var type = typeChecker.getTypeAtLocation(searchNode); - if (type && type.flags & 32) { - return type; - } - return undefined; - } - ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 98: + case 99: return true; - case 70: - return ts.identifierIsThisKeyword(node) && node.parent.kind === 145; + case 71: + return ts.identifierIsThisKeyword(node) && node.parent.kind === 146; default: return false; } @@ -55376,7 +57831,7 @@ var ts; ts.isThis = isThis; var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= node.end) { + if (c.kind === 294 && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -55587,7 +58042,7 @@ var ts; if (includeJsDocComment === void 0) { includeJsDocComment = false; } var current = sourceFile; outer: while (true) { - if (isToken(current)) { + if (ts.isToken(current)) { return current; } if (includeJsDocComment) { @@ -55635,7 +58090,7 @@ var ts; } function findTokenOnLeftOfPosition(file, position) { var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } return findPrecedingToken(position, file); @@ -55644,7 +58099,7 @@ var ts; function findNextToken(previousToken, parent) { return find(parent); function find(n) { - if (isToken(n) && n.pos === previousToken.end) { + if (ts.isToken(n) && n.pos === previousToken.end) { return n; } var children = n.getChildren(); @@ -55663,7 +58118,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -55671,7 +58126,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -55690,7 +58145,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 264); + ts.Debug.assert(startNode !== undefined || n.kind === 265); if (children.length) { var candidate = findRightmostChildNodeWithTokens(children, children.length); return candidate && findRightmostToken(candidate); @@ -55732,16 +58187,16 @@ var ts; if (token.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 10) { + if (token.kind === 27 && token.parent.kind === 10) { return true; } - if (token.kind === 26 && token.parent.kind === 255) { + if (token.kind === 27 && token.parent.kind === 256) { return true; } - if (token && token.kind === 17 && token.parent.kind === 255) { + if (token && token.kind === 18 && token.parent.kind === 256) { return true; } - if (token.kind === 26 && token.parent.kind === 251) { + if (token.kind === 27 && token.parent.kind === 252) { return true; } return false; @@ -55758,10 +58213,10 @@ var ts; var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); return predicate ? ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end) && + (c.kind === 2 ? position <= c.end : position < c.end) && predicate(c); }) : ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 ? position <= c.end : position < c.end); }); + (c.kind === 2 ? position <= c.end : position < c.end); }); } return false; } @@ -55778,11 +58233,11 @@ var ts; ts.hasDocComment = hasDocComment; function getJsDocTagAtPosition(sourceFile, position) { var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { + if (ts.isToken(node)) { switch (node.kind) { - case 103: - case 109: - case 75: + case 104: + case 110: + case 76: node = node.parent === undefined ? undefined : node.parent.parent; break; default: @@ -55832,21 +58287,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 158 || node.kind === 180) { + if (node.kind === 159 || node.kind === 181) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 228 || node.kind === 229) { + if (ts.isFunctionLike(node) || node.kind === 229 || node.kind === 230) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 && n.kind <= 141; - } - ts.isToken = isToken; function isWord(kind) { - return kind === 70 || ts.isKeyword(kind); + return kind === 71 || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -55858,7 +58309,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 - || kind === 11 + || kind === 12 || ts.isTemplateLiteralKind(kind)) { return true; } @@ -55866,7 +58317,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 16 <= kind && kind <= 69; + return 17 <= kind && kind <= 70; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -55876,9 +58327,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 113: - case 111: + case 114: case 112: + case 113: return true; } return false; @@ -55901,18 +58352,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 176 || - node.kind === 177) { - if (node.parent.kind === 193 && + if (node.kind === 177 || + node.kind === 178) { + if (node.parent.kind === 194 && node.parent.left === node && - node.parent.operatorToken.kind === 57) { + node.parent.operatorToken.kind === 58) { return true; } - if (node.parent.kind === 215 && + if (node.parent.kind === 216 && node.parent.initializer === node) { return true; } - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 261 ? node.parent.parent : node.parent)) { return true; } } @@ -55946,24 +58397,37 @@ var ts; ts.createTextSpanFromNode = createTextSpanFromNode; function isTypeKeyword(kind) { switch (kind) { - case 118: - case 121: - case 129: - case 132: + case 119: + case 122: + case 130: case 133: - case 135: + case 134: case 136: - case 104: + case 137: + case 105: return true; default: return false; } } ts.isTypeKeyword = isTypeKeyword; + function isExternalModuleSymbol(moduleSymbol) { + ts.Debug.assert(!!(moduleSymbol.flags & 1536)); + return moduleSymbol.name.charCodeAt(0) === 34; + } + ts.isExternalModuleSymbol = isExternalModuleSymbol; + function nodeSeenTracker() { + var seen = []; + return function (node) { + var id = ts.getNodeId(node); + return !seen[id] && (seen[id] = true); + }; + } + ts.nodeSeenTracker = nodeSeenTracker; })(ts || (ts = {})); (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 146; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -56136,21 +58600,16 @@ var ts; } ts.signatureToDisplayParts = signatureToDisplayParts; function getDeclaredName(typeChecker, symbol, location) { - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 143) { + if (isImportOrExportSpecifierName(location) || ts.isStringOrNumericLiteral(location) && location.parent.kind === 144) { return location.text; } var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; + return typeChecker.symbolToString(localExportDefaultSymbol || symbol); } ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 241 || location.parent.kind === 245) && + (location.parent.kind === 242 || location.parent.kind === 246) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -56161,7 +58620,6 @@ var ts; (name.charCodeAt(0) === 34 || name.charCodeAt(0) === 39)) { return name.substring(1, length - 1); } - ; return name; } ts.stripQuotes = stripQuotes; @@ -56207,10 +58665,21 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; - function getOpenBraceEnd(constructor, sourceFile) { - return constructor.body.getFirstToken(sourceFile).getEnd(); + function getFirstNonSpaceCharacterPosition(text, position) { + while (ts.isWhiteSpaceLike(text.charCodeAt(position))) { + position += 1; + } + return position; } - ts.getOpenBraceEnd = getOpenBraceEnd; + ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getOpenBrace(constructor, sourceFile) { + return constructor.body.getFirstToken(sourceFile); + } + ts.getOpenBrace = getOpenBrace; + function getOpenBraceOfClassLike(declaration, sourceFile) { + return ts.getTokenAtPosition(sourceFile, declaration.members.pos - 1); + } + ts.getOpenBraceOfClassLike = getOpenBraceOfClassLike; })(ts || (ts = {})); var ts; (function (ts) { @@ -56259,176 +58728,176 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 207: + case 208: return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 225: - case 148: - case 147: - return spanInVariableDeclaration(node); - case 145: - return spanInParameterDeclaration(node); - case 227: - case 150: + case 226: case 149: - case 152: - case 153: + case 148: + return spanInVariableDeclaration(node); + case 146: + return spanInParameterDeclaration(node); + case 228: case 151: - case 185: + case 150: + case 153: + case 154: + case 152: case 186: + case 187: return spanInFunctionDeclaration(node); - case 206: + case 207: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - case 233: + case 234: return spanInBlock(node); - case 259: + case 260: return spanInBlock(node.block); - case 209: - return textSpan(node.expression); - case 218: - return textSpan(node.getChildAt(0), node.expression); - case 212: - return textSpanEndingAtNextToken(node, node.expression); - case 211: - return spanInNode(node.statement); - case 224: - return textSpan(node.getChildAt(0)); case 210: - return textSpanEndingAtNextToken(node, node.expression); - case 221: - return spanInNode(node.statement); - case 217: - case 216: - return textSpan(node.getChildAt(0), node.label); + return textSpan(node.expression); + case 219: + return textSpan(node.getChildAt(0), node.expression); case 213: - return spanInForStatement(node); - case 214: return textSpanEndingAtNextToken(node, node.expression); - case 215: - return spanInInitializerOfForLike(node); - case 220: + case 212: + return spanInNode(node.statement); + case 225: + return textSpan(node.getChildAt(0)); + case 211: return textSpanEndingAtNextToken(node, node.expression); - case 256: - case 257: - return spanInNode(node.statements[0]); - case 223: - return spanInBlock(node.tryBlock); case 222: + return spanInNode(node.statement); + case 218: + case 217: + return textSpan(node.getChildAt(0), node.label); + case 214: + return spanInForStatement(node); + case 215: + return textSpanEndingAtNextToken(node, node.expression); + case 216: + return spanInInitializerOfForLike(node); + case 221: + return textSpanEndingAtNextToken(node, node.expression); + case 257: + case 258: + return spanInNode(node.statements[0]); + case 224: + return spanInBlock(node.tryBlock); + case 223: return textSpan(node, node.expression); - case 242: - return textSpan(node, node.expression); - case 236: - return textSpan(node, node.moduleReference); - case 237: - return textSpan(node, node.moduleSpecifier); case 243: + return textSpan(node, node.expression); + case 237: + return textSpan(node, node.moduleReference); + case 238: return textSpan(node, node.moduleSpecifier); - case 232: + case 244: + return textSpan(node, node.moduleSpecifier); + case 233: if (ts.getModuleInstanceState(node) !== 1) { return undefined; } - case 228: - case 231: - case 263: - case 175: - return textSpan(node); - case 219: - return spanInNode(node.statement); - case 146: - return spanInNodeArray(node.parent.decorators); - case 173: - case 174: - return spanInBindingPattern(node); case 229: + case 232: + case 264: + case 176: + return textSpan(node); + case 220: + return spanInNode(node.statement); + case 147: + return spanInNodeArray(node.parent.decorators); + case 174: + case 175: + return spanInBindingPattern(node); case 230: + case 231: return undefined; - case 24: + case 25: case 1: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 25: - return spanInPreviousNode(node); - case 16: - return spanInOpenBraceToken(node); - case 17: - return spanInCloseBraceToken(node); - case 21: - return spanInCloseBracketToken(node); - case 18: - return spanInOpenParenToken(node); - case 19: - return spanInCloseParenToken(node); - case 55: - return spanInColonToken(node); - case 28: case 26: + return spanInPreviousNode(node); + case 17: + return spanInOpenBraceToken(node); + case 18: + return spanInCloseBraceToken(node); + case 22: + return spanInCloseBracketToken(node); + case 19: + return spanInOpenParenToken(node); + case 20: + return spanInCloseParenToken(node); + case 56: + return spanInColonToken(node); + case 29: + case 27: return spanInGreaterThanOrLessThanToken(node); - case 105: + case 106: return spanInWhileKeyword(node); - case 81: - case 73: - case 86: + case 82: + case 74: + case 87: return spanInNextNode(node); - case 141: + case 142: return spanInOfKeyword(node); default: if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(node); } - if ((node.kind === 70 || - node.kind == 197 || - node.kind === 260 || - node.kind === 261) && + if ((node.kind === 71 || + node.kind === 198 || + node.kind === 261 || + node.kind === 262) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 193) { + if (node.kind === 194) { var binaryExpression = node; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 57 && + if (binaryExpression.operatorToken.kind === 58 && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { return textSpan(node); } - if (binaryExpression.operatorToken.kind === 25) { + if (binaryExpression.operatorToken.kind === 26) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 211: + case 212: return spanInPreviousNode(node); - case 146: + case 147: return spanInNode(node.parent); - case 213: - case 215: + case 214: + case 216: return textSpan(node); - case 193: - if (node.parent.operatorToken.kind === 25) { + case 194: + if (node.parent.operatorToken.kind === 26) { return textSpan(node); } break; - case 186: + case 187: if (node.parent.body === node) { return textSpan(node); } break; } } - if (node.parent.kind === 260 && + if (node.parent.kind === 261 && node.parent.name === node && !ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.parent)) { return spanInNode(node.parent.initializer); } - if (node.parent.kind === 183 && node.parent.type === node) { + if (node.parent.kind === 184 && 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 === 225 || - node.parent.kind === 145)) { + if ((node.parent.kind === 226 || + node.parent.kind === 146)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -56436,7 +58905,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 193) { + if (node.parent.kind === 194) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -56448,8 +58917,8 @@ var ts; } } function textSpanFromVariableDeclaration(variableDeclaration) { - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { + if (variableDeclaration.parent.kind === 227 && + variableDeclaration.parent.declarations[0] === variableDeclaration) { return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); } else { @@ -56457,7 +58926,7 @@ var ts; } } function spanInVariableDeclaration(variableDeclaration) { - if (variableDeclaration.parent.parent.kind === 214) { + if (variableDeclaration.parent.parent.kind === 215) { return spanInNode(variableDeclaration.parent.parent); } if (ts.isBindingPattern(variableDeclaration.name)) { @@ -56465,11 +58934,11 @@ var ts; } if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1) || - variableDeclaration.parent.parent.kind === 215) { + variableDeclaration.parent.parent.kind === 216) { return textSpanFromVariableDeclaration(variableDeclaration); } - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { + if (variableDeclaration.parent.kind === 227 && + variableDeclaration.parent.declarations[0] !== variableDeclaration) { return spanInNode(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent)); } } @@ -56497,7 +58966,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1) || - (functionDeclaration.parent.kind === 228 && functionDeclaration.kind !== 151); + (functionDeclaration.parent.kind === 229 && functionDeclaration.kind !== 152); } function spanInFunctionDeclaration(functionDeclaration) { if (!functionDeclaration.body) { @@ -56517,22 +58986,22 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 232: + case 233: if (ts.getModuleInstanceState(block.parent) !== 1) { return undefined; } - case 212: - case 210: - case 214: - return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); case 213: + case 211: case 215: + return spanInNodeIfStartsOnSameLine(block.parent, block.statements[0]); + case 214: + case 216: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(block.pos, sourceFile, block.parent), block.statements[0]); } return spanInNode(block.statements[0]); } function spanInInitializerOfForLike(forLikeStatement) { - if (forLikeStatement.initializer.kind === 226) { + if (forLikeStatement.initializer.kind === 227) { var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { return spanInNode(variableDeclarationList.declarations[0]); @@ -56554,62 +59023,62 @@ var ts; } } function spanInBindingPattern(bindingPattern) { - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 200 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - if (bindingPattern.parent.kind === 175) { + if (bindingPattern.parent.kind === 176) { return textSpan(bindingPattern.parent); } return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 174 && node.kind !== 173); - var elements = node.kind === 176 ? + ts.Debug.assert(node.kind !== 175 && node.kind !== 174); + var elements = node.kind === 177 ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 200 ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } - return textSpan(node.parent.kind === 193 ? node.parent : node); + return textSpan(node.parent.kind === 194 ? node.parent : node); } function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 231: + case 232: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 228: + case 229: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 234: + case 235: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } return spanInNode(node.parent); } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 233: + case 234: if (ts.getModuleInstanceState(node.parent.parent) !== 1) { return undefined; } - case 231: - case 228: + case 232: + case 229: return textSpan(node); - case 206: + case 207: if (ts.isFunctionBlock(node.parent)) { return textSpan(node); } - case 259: + case 260: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 234: + case 235: var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); if (lastClause) { return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 173: + case 174: var bindingPattern = node.parent; return spanInNode(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -56622,7 +59091,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 174: + case 175: var bindingPattern = node.parent; return textSpan(ts.lastOrUndefined(bindingPattern.elements) || bindingPattern); default: @@ -56634,33 +59103,33 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 211 || - node.parent.kind === 180 || - node.parent.kind === 181) { + if (node.parent.kind === 212 || + node.parent.kind === 181 || + node.parent.kind === 182) { return spanInPreviousNode(node); } - if (node.parent.kind === 184) { + if (node.parent.kind === 185) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInCloseParenToken(node) { switch (node.parent.kind) { - case 185: - case 227: case 186: - case 150: - case 149: - case 152: - case 153: + case 228: + case 187: case 151: - case 212: - case 211: + case 150: + case 153: + case 154: + case 152: case 213: - case 215: - case 180: + case 212: + case 214: + case 216: case 181: - case 184: + case 182: + case 185: return spanInPreviousNode(node); default: return spanInNode(node.parent); @@ -56668,26 +59137,26 @@ var ts; } function spanInColonToken(node) { if (ts.isFunctionLike(node.parent) || - node.parent.kind === 260 || - node.parent.kind === 145) { + node.parent.kind === 261 || + node.parent.kind === 146) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 183) { + if (node.parent.kind === 184) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 211) { + if (node.parent.kind === 212) { return textSpanEndingAtNextToken(node, node.parent.expression); } return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 215) { + if (node.parent.kind === 216) { return spanInNextNode(node); } return spanInNode(node.parent); @@ -56702,25 +59171,25 @@ var ts; function createClassifier() { var scanner = ts.createScanner(5, false); var noRegexTable = []; - noRegexTable[70] = true; + noRegexTable[71] = true; noRegexTable[9] = true; noRegexTable[8] = true; - noRegexTable[11] = true; - noRegexTable[98] = true; - noRegexTable[42] = true; + noRegexTable[12] = true; + noRegexTable[99] = true; noRegexTable[43] = true; - noRegexTable[19] = true; - noRegexTable[21] = true; - noRegexTable[17] = true; - noRegexTable[100] = true; - noRegexTable[85] = true; + noRegexTable[44] = true; + noRegexTable[20] = true; + noRegexTable[22] = true; + noRegexTable[18] = true; + noRegexTable[101] = true; + noRegexTable[86] = true; var templateStack = []; function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 124 || - keyword2 === 134 || - keyword2 === 122 || - keyword2 === 114) { + if (keyword2 === 125 || + keyword2 === 135 || + keyword2 === 123 || + keyword2 === 115) { return true; } return false; @@ -56733,7 +59202,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_4 = dense[i + 1]; + var length_5 = dense[i + 1]; var type = dense[i + 2]; if (lastEnd >= 0) { var whitespaceLength_1 = start - lastEnd; @@ -56741,8 +59210,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_4, classification: convertClassification(type) }); - lastEnd = start + length_4; + entries.push({ length: length_5, classification: convertClassification(type) }); + lastEnd = start + length_5; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -56803,7 +59272,7 @@ var ts; text = "}\n" + text; offset = 2; case 6: - templateStack.push(13); + templateStack.push(14); break; } scanner.setText(text); @@ -56815,55 +59284,55 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 40 || token === 62) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 11) { - token = 11; + if ((token === 41 || token === 63) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 12) { + token = 12; } } - else if (lastNonTriviaToken === 22 && isKeyword(token)) { - token = 70; + else if (lastNonTriviaToken === 23 && isKeyword(token)) { + token = 71; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { - token = 70; + token = 71; } - else if (lastNonTriviaToken === 70 && - token === 26) { + else if (lastNonTriviaToken === 71 && + token === 27) { angleBracketStack++; } - else if (token === 28 && angleBracketStack > 0) { + else if (token === 29 && angleBracketStack > 0) { angleBracketStack--; } - else if (token === 118 || - token === 135 || - token === 132 || - token === 121 || - token === 136) { + else if (token === 119 || + token === 136 || + token === 133 || + token === 122 || + token === 137) { if (angleBracketStack > 0 && !syntacticClassifierAbsent) { - token = 70; + token = 71; } } - else if (token === 13) { + else if (token === 14) { templateStack.push(token); } - else if (token === 16) { + else if (token === 17) { if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 17) { + else if (token === 18) { if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 13) { + if (lastTemplateStackToken === 14) { token = scanner.reScanTemplateToken(); - if (token === 15) { + if (token === 16) { templateStack.pop(); } else { - ts.Debug.assert(token === 14, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 15, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 16, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 17, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -56901,10 +59370,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 15) { + if (token === 16) { result.endOfLineState = 5; } - else if (token === 12) { + else if (token === 13) { result.endOfLineState = 4; } else { @@ -56912,7 +59381,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 14) { result.endOfLineState = 6; } } @@ -56936,43 +59405,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 38: - case 40: + case 39: case 41: - case 36: + case 42: case 37: - case 44: + case 38: case 45: case 46: - case 26: - case 28: + case 47: + case 27: case 29: case 30: - case 92: - case 91: - case 117: case 31: + case 93: + case 92: + case 118: case 32: case 33: case 34: - case 47: - case 49: + case 35: case 48: - case 52: + case 50: + case 49: case 53: - case 68: - case 67: + case 54: case 69: - case 64: + case 68: + case 70: case 65: case 66: - case 58: + case 67: case 59: case 60: - case 62: + case 61: case 63: - case 57: - case 25: + case 64: + case 58: + case 26: return true; default: return false; @@ -56980,19 +59449,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 36: case 37: + case 38: + case 52: case 51: - case 50: - case 42: case 43: + case 44: return true; default: return false; } } function isKeyword(token) { - return token >= 71 && token <= 141; + return token >= 72 && token <= 142; } function classFromKind(token) { if (isKeyword(token)) { @@ -57001,7 +59470,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5; } - else if (token >= 16 && token <= 69) { + else if (token >= 17 && token <= 70) { return 10; } switch (token) { @@ -57009,7 +59478,7 @@ var ts; return 4; case 9: return 6; - case 11: + case 12: return 7; case 7: case 3: @@ -57018,7 +59487,7 @@ var ts; case 5: case 4: return 8; - case 70: + case 71: default: if (ts.isTemplateLiteralKind(token)) { return 6; @@ -57038,10 +59507,10 @@ var ts; ts.getSemanticClassifications = getSemanticClassifications; function checkForClassificationCancellation(cancellationToken, kind) { switch (kind) { - case 232: - case 228: + case 233: case 229: - case 227: + case 230: + case 228: cancellationToken.throwIfCancellationRequested(); } } @@ -57085,7 +59554,7 @@ var ts; return undefined; function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 232 && + return declaration.kind === 233 && ts.getModuleInstanceState(declaration) === 1; }); } @@ -57094,7 +59563,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 70 && !ts.nodeIsMissing(node)) { + if (kind === 71 && !ts.nodeIsMissing(node)) { var identifier = node; if (classifiableNames.get(identifier.text)) { var symbol = typeChecker.getSymbolAtLocation(node); @@ -57226,16 +59695,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18); pos = tag.tagName.end; switch (tag.kind) { - case 285: + case 286: processJSDocParameterTag(tag); break; - case 288: + case 289: processJSDocTemplateTag(tag); break; - case 287: + case 288: processElement(tag.typeExpression); break; - case 286: + case 287: processElement(tag.typeExpression); break; } @@ -57316,22 +59785,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 250: + case 251: if (token.parent.tagName === token) { return 19; } break; - case 251: + case 252: if (token.parent.tagName === token) { return 20; } break; - case 249: + case 250: if (token.parent.tagName === token) { return 21; } break; - case 252: + case 253: if (token.parent.name === token) { return 22; } @@ -57343,25 +59812,25 @@ var ts; if (ts.isKeyword(tokenKind)) { return 3; } - if (tokenKind === 26 || tokenKind === 28) { + if (tokenKind === 27 || tokenKind === 29) { if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { return 10; } } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 57) { - if (token.parent.kind === 225 || - token.parent.kind === 148 || - token.parent.kind === 145 || - token.parent.kind === 252) { + if (tokenKind === 58) { + if (token.parent.kind === 226 || + token.parent.kind === 149 || + token.parent.kind === 146 || + token.parent.kind === 253) { return 5; } } - if (token.parent.kind === 193 || - token.parent.kind === 191 || + if (token.parent.kind === 194 || token.parent.kind === 192 || - token.parent.kind === 194) { + token.parent.kind === 193 || + token.parent.kind === 195) { return 5; } } @@ -57371,9 +59840,9 @@ var ts; return 4; } else if (tokenKind === 9) { - return token.parent.kind === 252 ? 24 : 6; + return token.parent.kind === 253 ? 24 : 6; } - else if (tokenKind === 11) { + else if (tokenKind === 12) { return 6; } else if (ts.isTemplateLiteralKind(tokenKind)) { @@ -57382,35 +59851,35 @@ var ts; else if (tokenKind === 10) { return 23; } - else if (tokenKind === 70) { + else if (tokenKind === 71) { if (token) { switch (token.parent.kind) { - case 228: + case 229: if (token.parent.name === token) { return 11; } return; - case 144: + case 145: if (token.parent.name === token) { return 15; } return; - case 229: + case 230: if (token.parent.name === token) { return 13; } return; - case 231: + case 232: if (token.parent.name === token) { return 12; } return; - case 232: + case 233: if (token.parent.name === token) { return 14; } return; - case 145: + case 146: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 : 17; } @@ -57438,12 +59907,419 @@ var ts; ts.getEncodedSyntacticClassifications = getEncodedSyntacticClassifications; })(ts || (ts = {})); var ts; +(function (ts) { + var Completions; + (function (Completions) { + var PathCompletions; + (function (PathCompletions) { + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, false, span, host, scriptPath); + } + } + else { + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + PathCompletions.getStringLiteralCompletionEntriesFromModuleNames = getStringLiteralCompletionEntriesFromModuleNames; + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + var files = tryReadDirectory(host, baseDirectory, extensions, undefined, ["./*"]); + if (files) { + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + } + } + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); + if (matches) { + var result = []; + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_6 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_6))); + } + return result; + } + } + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, undefined, ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } + } + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); + } + else { + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + } + } + return completionInfo; + } + PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); + } + } + } + if (host.getDirectories) { + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName: moduleName, + moduleDir: moduleDir + }); + } + } + } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; + } + } + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); + } + } + } + } + } + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 || slashCharCode === 92; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } + var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), true, span_10, host, sourceFile.path); - } - else { - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; - } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - if (host.getDirectories) { - for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir, host) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent = ts.getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 || slashCharCode === 92; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); - } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { var completionData = getCompletionData(typeChecker, log, sourceFile, position); if (completionData) { var symbols = completionData.symbols, location_1 = completionData.location; var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -58022,7 +60538,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -58039,7 +60556,8 @@ var ts; Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); - var isJsDocTagName = false; + var requestJsDocTagName = false; + var requestJsDocTag = false; var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (ts.timestamp() - start)); @@ -58047,19 +60565,25 @@ var ts; var insideComment = ts.isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); if (insideComment) { - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64) { - isJsDocTagName = true; + if (ts.hasDocComment(sourceFile, position)) { + if (sourceFile.text.charCodeAt(position - 1) === 64) { + requestJsDocTagName = true; + } + else { + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + requestJsDocTag = !(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); + } } var insideJsDocTagExpression = false; var tag = ts.getJsDocTagAtPosition(sourceFile, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; + requestJsDocTagName = true; } switch (tag.kind) { - case 287: - case 285: + case 288: case 286: + case 287: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -58067,8 +60591,8 @@ var ts; break; } } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + if (requestJsDocTagName || requestJsDocTag) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; } if (!insideJsDocTagExpression) { log("Returning an empty list because completion was inside a regular comment or plain text part of a JsDoc comment."); @@ -58094,13 +60618,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent = contextToken.parent, kind = contextToken.kind; - if (kind === 22) { - if (parent.kind === 178) { + var parent = contextToken.parent; + if (contextToken.kind === 23) { + if (parent.kind === 179) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent.kind === 142) { + else if (parent.kind === 143) { node = contextToken.parent.left; isRightOfDot = true; } @@ -58109,21 +60633,25 @@ var ts; } } else if (sourceFile.languageVariant === 1) { - switch (contextToken.parent.kind) { - case 251: - if (kind === 40) { + if (parent && parent.kind === 179) { + contextToken = parent; + parent = parent.parent; + } + switch (parent.kind) { + case 252: + if (contextToken.kind === 41) { isStartingCloseTag = true; location = contextToken; } break; - case 193: - if (!(contextToken.parent.left.flags & 32768)) { + case 194: + if (!(parent.left.flags & 32768)) { break; } - case 249: - case 248: case 250: - if (kind === 26) { + case 249: + case 251: + if (contextToken.kind === 27) { isRightOfOpenTag = true; location = contextToken; } @@ -58165,12 +60693,12 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; function getTypeScriptMemberSymbols() { isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 || node.kind === 142 || node.kind === 178) { + if (node.kind === 71 || node.kind === 143 || node.kind === 179) { var symbol = typeChecker.getSymbolAtLocation(node); if (symbol && symbol.flags & 8388608) { symbol = typeChecker.getAliasedSymbol(symbol); @@ -58216,7 +60744,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 249) || (jsxContainer.kind === 250)) { + if ((jsxContainer.kind === 250) || (jsxContainer.kind === 251)) { attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { symbols = filterJsxAttributes(typeChecker.getPropertiesOfType(attrsType), jsxContainer.attributes.properties); @@ -58237,9 +60765,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 264 || - scopeNode.kind === 195 || - scopeNode.kind === 255 || + scopeNode.kind === 265 || + scopeNode.kind === 196 || + scopeNode.kind === 256 || ts.isStatement(scopeNode); } var symbolMeanings = 793064 | 107455 | 1920 | 8388608; @@ -58266,12 +60794,12 @@ var ts; if (contextToken.kind === 10) { return true; } - if (contextToken.kind === 28 && contextToken.parent) { - if (contextToken.parent.kind === 250) { + if (contextToken.kind === 29 && contextToken.parent) { + if (contextToken.parent.kind === 251) { return true; } - if (contextToken.parent.kind === 251 || contextToken.parent.kind === 249) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 248; + if (contextToken.parent.kind === 252 || contextToken.parent.kind === 250) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 249; } } return false; @@ -58280,41 +60808,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 25: - return containingNodeKind === 180 - || containingNodeKind === 151 - || containingNodeKind === 181 - || containingNodeKind === 176 - || containingNodeKind === 193 - || containingNodeKind === 159; - case 18: - return containingNodeKind === 180 - || containingNodeKind === 151 - || containingNodeKind === 181 - || containingNodeKind === 184 - || containingNodeKind === 167; - case 20: - return containingNodeKind === 176 - || containingNodeKind === 156 - || containingNodeKind === 143; - case 127: + case 26: + return containingNodeKind === 181 + || containingNodeKind === 152 + || containingNodeKind === 182 + || containingNodeKind === 177 + || containingNodeKind === 194 + || containingNodeKind === 160; + case 19: + return containingNodeKind === 181 + || containingNodeKind === 152 + || containingNodeKind === 182 + || containingNodeKind === 185 + || containingNodeKind === 168; + case 21: + return containingNodeKind === 177 + || containingNodeKind === 157 + || containingNodeKind === 144; case 128: + case 129: return true; - case 22: - return containingNodeKind === 232; - case 16: - return containingNodeKind === 228; - case 57: - return containingNodeKind === 225 - || containingNodeKind === 193; - case 13: - return containingNodeKind === 195; + case 23: + return containingNodeKind === 233; + case 17: + return containingNodeKind === 229; + case 58: + return containingNodeKind === 226 + || containingNodeKind === 194; case 14: - return containingNodeKind === 204; - case 113: - case 111: + return containingNodeKind === 196; + case 15: + return containingNodeKind === 205; + case 114: case 112: - return containingNodeKind === 148; + case 113: + return containingNodeKind === 149; } switch (previousToken.getText()) { case "public": @@ -58327,7 +60855,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 - || contextToken.kind === 11 + || contextToken.kind === 12 || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -58336,7 +60864,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 11; + || contextToken.kind === 12; } } return false; @@ -58345,22 +60873,22 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 177) { + if (objectLikeContainer.kind === 178) { isNewIdentifierLocation = true; typeForObject = typeChecker.getContextualType(objectLikeContainer); typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 173) { + else if (objectLikeContainer.kind === 174) { isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); if (ts.isVariableLike(rootDeclaration)) { var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 145) { + if (!canGetType && rootDeclaration.kind === 146) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 150 || rootDeclaration.parent.kind === 153) { + else if (rootDeclaration.parent.kind === 151 || rootDeclaration.parent.kind === 154) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -58386,9 +60914,9 @@ var ts; return true; } function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 240 ? - 237 : - 243; + var declarationKind = namedImportsOrExports.kind === 241 ? + 238 : + 244; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -58408,10 +60936,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16: - case 25: + case 17: + case 26: var parent = contextToken.parent; - if (parent && (parent.kind === 177 || parent.kind === 173)) { + if (parent && (parent.kind === 178 || parent.kind === 174)) { return parent; } break; @@ -58422,11 +60950,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16: - case 25: + case 17: + case 26: switch (contextToken.parent.kind) { - case 240: - case 244: + case 241: + case 245: return contextToken.parent; } } @@ -58437,31 +60965,32 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 27: - case 40: - case 70: - case 253: - case 252: + case 28: + case 41: + case 71: + case 179: case 254: - if (parent && (parent.kind === 249 || parent.kind === 250)) { + case 253: + case 255: + if (parent && (parent.kind === 250 || parent.kind === 251)) { return parent; } - else if (parent.kind === 252) { + else if (parent.kind === 253) { return parent.parent.parent; } break; case 9: - if (parent && ((parent.kind === 252) || (parent.kind === 254))) { + if (parent && ((parent.kind === 253) || (parent.kind === 255))) { return parent.parent.parent; } break; - case 17: + case 18: if (parent && - parent.kind === 255 && - parent.parent && parent.parent.kind === 252) { + parent.kind === 256 && + parent.parent && parent.parent.kind === 253) { return parent.parent.parent.parent; } - if (parent && parent.kind === 254) { + if (parent && parent.kind === 255) { return parent.parent.parent; } break; @@ -58470,85 +60999,82 @@ var ts; return undefined; } function isFunction(kind) { + if (!ts.isFunctionLikeKind(kind)) { + return false; + } switch (kind) { - case 185: - case 186: - case 227: - case 150: - case 149: case 152: - case 153: - case 154: - case 155: - case 156: + case 161: + case 160: + return false; + default: return true; } - return false; } function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 25: - return containingNodeKind === 225 || - containingNodeKind === 226 || - containingNodeKind === 207 || - containingNodeKind === 231 || - isFunction(containingNodeKind) || - containingNodeKind === 228 || - containingNodeKind === 198 || - containingNodeKind === 229 || - containingNodeKind === 174 || - containingNodeKind === 230; - case 22: - return containingNodeKind === 174; - case 55: - return containingNodeKind === 175; - case 20: - return containingNodeKind === 174; - case 18: - return containingNodeKind === 259 || - isFunction(containingNodeKind); - case 16: - return containingNodeKind === 231 || - containingNodeKind === 229 || - containingNodeKind === 162; - case 24: - return containingNodeKind === 147 && - contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 229 || - contextToken.parent.parent.kind === 162); case 26: - return containingNodeKind === 228 || - containingNodeKind === 198 || + return containingNodeKind === 226 || + containingNodeKind === 227 || + containingNodeKind === 208 || + containingNodeKind === 232 || + isFunction(containingNodeKind) || containingNodeKind === 229 || + containingNodeKind === 199 || containingNodeKind === 230 || - isFunction(containingNodeKind); - case 114: - return containingNodeKind === 148; + containingNodeKind === 175 || + containingNodeKind === 231; case 23: - return containingNodeKind === 145 || - (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 174); - case 113: - case 111: - case 112: - return containingNodeKind === 145; - case 117: - return containingNodeKind === 241 || - containingNodeKind === 245 || - containingNodeKind === 239; - case 74: - case 82: - case 108: - case 88: - case 103: - case 124: - case 134: - case 90: - case 109: - case 75: + return containingNodeKind === 175; + case 56: + return containingNodeKind === 176; + case 21: + return containingNodeKind === 175; + case 19: + return containingNodeKind === 260 || + isFunction(containingNodeKind); + case 17: + return containingNodeKind === 232 || + containingNodeKind === 230 || + containingNodeKind === 163; + case 25: + return containingNodeKind === 148 && + contextToken.parent && contextToken.parent.parent && + (contextToken.parent.parent.kind === 230 || + contextToken.parent.parent.kind === 163); + case 27: + return containingNodeKind === 229 || + containingNodeKind === 199 || + containingNodeKind === 230 || + containingNodeKind === 231 || + isFunction(containingNodeKind); case 115: - case 137: + return containingNodeKind === 149; + case 24: + return containingNodeKind === 146 || + (contextToken.parent && contextToken.parent.parent && + contextToken.parent.parent.kind === 175); + case 114: + case 112: + case 113: + return containingNodeKind === 146; + case 118: + return containingNodeKind === 242 || + containingNodeKind === 246 || + containingNodeKind === 240; + case 75: + case 83: + case 109: + case 89: + case 104: + case 125: + case 135: + case 91: + case 110: + case 76: + case 116: + case 138: return true; } switch (contextToken.getText()) { @@ -58600,20 +61126,20 @@ var ts; var existingMemberNames = ts.createMap(); for (var _i = 0, existingMembers_1 = existingMembers; _i < existingMembers_1.length; _i++) { var m = existingMembers_1[_i]; - if (m.kind !== 260 && - m.kind !== 261 && - m.kind !== 175 && - m.kind !== 150 && - m.kind !== 152 && - m.kind !== 153) { + if (m.kind !== 261 && + m.kind !== 262 && + m.kind !== 176 && + m.kind !== 151 && + m.kind !== 153 && + m.kind !== 154) { continue; } if (m.getStart() <= position && position <= m.getEnd()) { continue; } var existingName = void 0; - if (m.kind === 175 && m.propertyName) { - if (m.propertyName.kind === 70) { + if (m.kind === 176 && m.propertyName) { + if (m.propertyName.kind === 71) { existingName = m.propertyName.text; } } @@ -58631,7 +61157,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 252) { + if (attr.kind === 253) { seenNames.set(attr.name.text, true); } } @@ -58664,7 +61190,7 @@ var ts; return name; } var keywordCompletions = []; - for (var i = 71; i <= 141; i++) { + for (var i = 72; i <= 142; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -58672,46 +61198,14 @@ var ts; sortText: "0" }); } - var tripleSlashDirectiveFragmentRegex = /^(\/\/\/\s*= 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105)) { + if (pushKeywordIf(keywords, loopTokens[i], 106)) { break; } } @@ -59072,7 +61560,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71, 76); + pushKeywordIf(keywords, statement.getFirstToken(), 72, 77); } }); return keywords; @@ -59081,13 +61569,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 213: case 214: case 215: - case 211: + case 216: case 212: + case 213: return getLoopBreakContinueOccurrences(owner); - case 220: + case 221: return getSwitchCaseDefaultOccurrences(owner); } } @@ -59095,13 +61583,13 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 98); ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72, 78); + pushKeywordIf(keywords, clause.getFirstToken(), 73, 79); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71); + pushKeywordIf(keywords, statement.getFirstToken(), 72); } }); }); @@ -59109,13 +61597,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 102); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 87); } return keywords; } @@ -59126,50 +61614,50 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100); }); if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96); }); } return keywords; } function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); - if (!(func && hasKind(func.body, 206))) { + if (!(func && hasKind(func.body, 207))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96); }); ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100); }); return keywords; } function getIfElseOccurrences(ifStatement, sourceFile) { var keywords = []; - while (hasKind(ifStatement.parent, 210) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 211) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89); + pushKeywordIf(keywords, children[0], 90); for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81)) { + if (pushKeywordIf(keywords, children[i], 82)) { break; } } - if (!hasKind(ifStatement.elseStatement, 210)) { + if (!hasKind(ifStatement.elseStatement, 211)) { break; } ifStatement = ifStatement.elseStatement; } var result = []; for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 && i < keywords.length - 1) { + if (keywords[i].kind === 82 && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; var shouldCombindElseAndIf = true; @@ -59194,7 +61682,7 @@ var ts; return result; } function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 221; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 222; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -59309,1034 +61797,1651 @@ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { - var node = ts.getTouchingPropertyName(sourceFile, position, true); - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); + function createImportTracker(sourceFiles, checker, cancellationToken) { + var allDirectImports = getDirectImportsMap(sourceFiles, checker, cancellationToken); + return function (exportSymbol, exportInfo, isForRename) { + var _a = getImportersForExport(sourceFiles, allDirectImports, exportInfo, checker, cancellationToken), directImports = _a.directImports, indirectUsers = _a.indirectUsers; + return __assign({ indirectUsers: indirectUsers }, getSearchesFromDirectImports(directImports, exportSymbol, exportInfo.exportKind, checker, isForRename)); + }; } - FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function convertReferences(referenceSymbols) { - return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); - } - FindAllReferences.convertReferences = convertReferences; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { - if (!implementations) { - var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); - if (special) { - return special; + FindAllReferences.createImportTracker = createImportTracker; + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + })(ExportKind = FindAllReferences.ExportKind || (FindAllReferences.ExportKind = {})); + var ImportExport; + (function (ImportExport) { + ImportExport[ImportExport["Import"] = 0] = "Import"; + ImportExport[ImportExport["Export"] = 1] = "Export"; + })(ImportExport = FindAllReferences.ImportExport || (FindAllReferences.ImportExport = {})); + function getImportersForExport(sourceFiles, allDirectImports, _a, checker, cancellationToken) { + var exportingModuleSymbol = _a.exportingModuleSymbol, exportKind = _a.exportKind; + var markSeenDirectImport = ts.nodeSeenTracker(); + var markSeenIndirectUser = ts.nodeSeenTracker(); + var directImports = []; + var isAvailableThroughGlobal = !!exportingModuleSymbol.globalExports; + var indirectUserDeclarations = isAvailableThroughGlobal ? undefined : []; + handleDirectImports(exportingModuleSymbol); + return { directImports: directImports, indirectUsers: getIndirectUsers() }; + function getIndirectUsers() { + if (isAvailableThroughGlobal) { + return sourceFiles; } - } - var symbol = typeChecker.getSymbolAtLocation(node); - if (!symbol) { - if (!implementations && node.kind === 9) { - return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl)) { + addIndirectUser(decl); + } } - return undefined; + return indirectUserDeclarations.map(ts.getSourceFileOfNode); } - var declarations = symbol.declarations; - if (!declarations || !declarations.length) { - return undefined; + function handleDirectImports(exportingModuleSymbol) { + var theseDirectImports = getDirectImports(exportingModuleSymbol); + if (theseDirectImports) + for (var _i = 0, theseDirectImports_1 = theseDirectImports; _i < theseDirectImports_1.length; _i++) { + var direct = theseDirectImports_1[_i]; + if (!markSeenDirectImport(direct)) { + continue; + } + cancellationToken.throwIfCancellationRequested(); + switch (direct.kind) { + case 181: + if (!isAvailableThroughGlobal) { + var parent = direct.parent; + if (exportKind === 2 && parent.kind === 226) { + var name = parent.name; + if (name.kind === 71) { + directImports.push(name); + break; + } + } + addIndirectUser(direct.getSourceFile()); + } + break; + case 237: + handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1)); + break; + case 238: + var namedBindings = direct.importClause && direct.importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240) { + handleNamespaceImport(direct, namedBindings.name); + } + else { + directImports.push(direct); + } + break; + case 244: + if (!direct.exportClause) { + handleDirectImports(getContainingModuleSymbol(direct, checker)); + } + else { + directImports.push(direct); + } + break; + } + } } - var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; - symbol = aliasedSymbol; - var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); - if (shorthandModuleSymbol) { - searchSymbols.push(shorthandModuleSymbol); - } - var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); - var result = []; - var symbolToIndex = []; - var inheritsFromCache = ts.createMap(); - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - var scope = getSymbolScope(symbol); - if (scope) { - getRefs(scope, declaredName); - } - else { - var isDefault = ts.isExportDefaultSymbol(symbol); - var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; - cancellationToken.throwIfCancellationRequested(); - var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || - (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); - if (searchName !== undefined) { - getRefs(sourceFile, searchName); + function handleNamespaceImport(importDeclaration, name, isReExport) { + if (exportKind === 2) { + directImports.push(importDeclaration); + } + else if (!isAvailableThroughGlobal) { + var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); + ts.Debug.assert(sourceFileLike.kind === 265 || sourceFileLike.kind === 233); + if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { + addIndirectUsers(sourceFileLike); + } + else { + addIndirectUser(sourceFileLike); } } } - return result; - function getRefs(scope, searchName) { - getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); + function addIndirectUser(sourceFileLike) { + ts.Debug.assert(!isAvailableThroughGlobal); + var isNew = markSeenIndirectUser(sourceFileLike); + if (isNew) { + indirectUserDeclarations.push(sourceFileLike); + } + return isNew; + } + function addIndirectUsers(sourceFileLike) { + if (!addIndirectUser(sourceFileLike)) { + return; + } + var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); + ts.Debug.assert(!!(moduleSymbol.flags & 1536)); + var directImports = getDirectImports(moduleSymbol); + if (directImports) + for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { + var directImport = directImports_1[_i]; + addIndirectUsers(getSourceFileLikeForImportDeclaration(directImport)); + } + } + function getDirectImports(moduleSymbol) { + return allDirectImports.get(ts.getSymbolId(moduleSymbol).toString()); } } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { - if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { + var exportName = exportSymbol.name; + var importSearches = []; + var singleReferences = []; + function addSearch(location, symbol) { + importSearches.push([location, symbol]); } - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); + if (directImports) + for (var _i = 0, directImports_2 = directImports; _i < directImports_2.length; _i++) { + var decl = directImports_2[_i]; + handleImport(decl); + } + return { importSearches: importSearches, singleReferences: singleReferences }; + function handleImport(decl) { + if (decl.kind === 237) { + if (isExternalModuleImportEquals(decl)) { + handleNamespaceImportLike(decl.name); + } + return; + } + if (decl.kind === 71) { + handleNamespaceImportLike(decl); + return; + } + if (decl.moduleSpecifier.kind !== 9) { + return; + } + if (decl.kind === 244) { + searchForNamedImport(decl.exportClause); + return; + } + var importClause = decl.importClause; + var namedBindings = importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240) { + handleNamespaceImportLike(namedBindings.name); + return; + } + if (exportKind === 0) { + searchForNamedImport(namedBindings); } else { - return getLabelReferencesInNode(node.parent, node, cancellationToken); + var name = importClause.name; + if (name && (!isForRename || name.text === symbolName(exportSymbol))) { + var defaultImportAlias = checker.getSymbolAtLocation(name); + addSearch(name, defaultImportAlias); + } + if (!isForRename && exportKind === 1) { + ts.Debug.assert(exportName === "default"); + searchForNamedImport(namedBindings); + } } } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + function handleNamespaceImportLike(importName) { + if (exportKind === 2 && (!isForRename || importName.text === exportName)) { + addSearch(importName, checker.getSymbolAtLocation(importName)); + } } - if (node.kind === 96) { - return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); - } - return undefined; - } - function followAliases(symbol, node, typeChecker, isForRename) { - while (true) { - if (isForRename && isImportDefaultSymbol(symbol)) { - return { symbol: symbol }; - } - var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); - if (!aliasedSymbol || !aliasedSymbol.declarations) { - return { symbol: symbol }; - } - if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { - return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; - } - symbol = aliasedSymbol; + function searchForNamedImport(namedBindings) { + if (namedBindings) + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if ((propertyName || name).text !== exportName) { + continue; + } + if (propertyName) { + singleReferences.push(propertyName); + if (!isForRename) { + addSearch(name, checker.getSymbolAtLocation(name)); + } + } + else { + var localSymbol = element.kind === 246 && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } + } } } - function sourceFileHasName(sourceFile, name) { - return ts.getNameTable(sourceFile).get(name) !== undefined; + function findNamespaceReExports(sourceFileLike, name, checker) { + var namespaceImportSymbol = checker.getSymbolAtLocation(name); + return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + if (statement.kind !== 244) + return; + var _a = statement, exportClause = _a.exportClause, moduleSpecifier = _a.moduleSpecifier; + if (moduleSpecifier || !exportClause) + return; + for (var _i = 0, _b = exportClause.elements; _i < _b.length; _i++) { + var element = _b[_i]; + if (checker.getExportSpecifierLocalTargetSymbol(element) === namespaceImportSymbol) { + return true; + } + } + }); } - function getDefaultImportName(symbol, sourceFile, checker) { - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importSpecifier = _a[_i]; - var importDecl = importSpecifier.parent; - ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); - var defaultName = importDecl.importClause.name; - var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); - if (symbol === defaultReferencedSymbol) { - return defaultName.text; + function getDirectImportsMap(sourceFiles, checker, cancellationToken) { + var map = ts.createMap(); + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; + cancellationToken.throwIfCancellationRequested(); + forEachImport(sourceFile, function (importDecl, moduleSpecifier) { + var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); + if (moduleSymbol) { + var id = ts.getSymbolId(moduleSymbol).toString(); + var imports = map.get(id); + if (!imports) { + map.set(id, imports = []); + } + imports.push(importDecl); + } + }); + } + return map; + } + function forEachPossibleImportOrExportStatement(sourceFileLike, action) { + return ts.forEach(sourceFileLike.kind === 265 ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); + }); + } + function forEachImport(sourceFile, action) { + if (sourceFile.externalModuleIndicator) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; + action(importerFromModuleSpecifier(moduleSpecifier), moduleSpecifier); + } + } + else { + forEachPossibleImportOrExportStatement(sourceFile, function (statement) { + switch (statement.kind) { + case 244: + case 238: { + var decl = statement; + if (decl.moduleSpecifier && decl.moduleSpecifier.kind === 9) { + action(decl, decl.moduleSpecifier); + } + break; + } + case 237: { + var decl = statement; + var moduleReference = decl.moduleReference; + if (moduleReference.kind === 248 && + moduleReference.expression.kind === 9) { + action(decl, moduleReference.expression); + } + break; + } + } + }); + if (sourceFile.flags & 65536) { + sourceFile.forEachChild(function recur(node) { + if (ts.isRequireCall(node, true)) { + action(node, node.arguments[0]); + } + else { + node.forEachChild(recur); + } + }); } } - return undefined; } - function getDefinition(symbol, node, typeChecker) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; - var name = displayParts.map(function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { + function importerFromModuleSpecifier(moduleSpecifier) { + var decl = moduleSpecifier.parent; + if (decl.kind === 238 || decl.kind === 244) { + return decl; + } + ts.Debug.assert(decl.kind === 248); + return decl.parent; + } + function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { + return comingFromExport ? getExport() : getExport() || getImport(); + function getExport() { + var parent = node.parent; + if (symbol.flags & 7340032) { + if (parent.kind === 179) { + return symbol.declarations.some(function (d) { return d === parent; }) && parent.parent.kind === 194 + ? getSpecialPropertyExport(parent.parent, false) + : undefined; + } + else { + var exportSymbol = symbol.exportSymbol; + ts.Debug.assert(!!exportSymbol); + return exportInfo(exportSymbol, getExportKindForDeclaration(parent)); + } + } + else { + var exportNode = getExportNode(parent); + if (exportNode && ts.hasModifier(exportNode, 1)) { + if (exportNode.kind === 237 && exportNode.moduleReference === node) { + if (comingFromExport) { + return undefined; + } + var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); + return { kind: 0, symbol: lhsSymbol, isNamedImport: false }; + } + else { + return exportInfo(symbol, getExportKindForDeclaration(exportNode)); + } + } + else if (parent.kind === 243) { + var exportingModuleSymbol = parent.symbol.parent; + ts.Debug.assert(!!exportingModuleSymbol); + return { kind: 1, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 } }; + } + else if (parent.kind === 194) { + return getSpecialPropertyExport(parent, true); + } + else if (parent.parent.kind === 194) { + return getSpecialPropertyExport(parent.parent, true); + } + } + function getSpecialPropertyExport(node, useLhsSymbol) { + var kind; + switch (ts.getSpecialPropertyAssignmentKind(node)) { + case 1: + kind = 0; + break; + case 2: + kind = 2; + break; + default: + return undefined; + } + var sym = useLhsSymbol ? checker.getSymbolAtLocation(node.left.name) : symbol; + return sym && exportInfo(sym, kind); + } + } + function getImport() { + var isImport = isNodeImport(node); + if (!isImport) + return; + var importedSymbol = checker.getImmediateAliasedSymbol(symbol); + if (importedSymbol) { + importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker); + if (importedSymbol.name === "export=") { + importedSymbol = checker.getImmediateAliasedSymbol(importedSymbol); + } + if (symbolName(importedSymbol) === symbol.name) { + return __assign({ kind: 0, symbol: importedSymbol }, isImport); + } + } + } + function exportInfo(symbol, kind) { + var exportInfo = getExportInfo(symbol, kind, checker); + return exportInfo && { kind: 1, symbol: symbol, exportInfo: exportInfo }; + } + function getExportKindForDeclaration(node) { + return ts.hasModifier(node, 512) ? 1 : 0; + } + } + FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; + function getExportNode(parent) { + if (parent.kind === 226) { + var p = parent; + return p.parent.kind === 260 ? undefined : p.parent.parent.kind === 208 ? p.parent.parent : undefined; + } + else { + return parent; + } + } + function isNodeImport(node) { + var parent = node.parent; + switch (parent.kind) { + case 237: + return parent.name === node && isExternalModuleImportEquals(parent) + ? { isNamedImport: false } + : undefined; + case 242: + return parent.propertyName ? undefined : { isNamedImport: true }; + case 239: + case 240: + ts.Debug.assert(parent.name === node); + return { isNamedImport: false }; + default: + return undefined; + } + } + function getExportInfo(exportSymbol, exportKind, checker) { + var exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); + return ts.isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } : undefined; + } + FindAllReferences.getExportInfo = getExportInfo; + function symbolName(symbol) { + if (symbol.name !== "default") { + return symbol.name; + } + var name = ts.forEach(symbol.declarations, function (_a) { + var name = _a.name; + return name && name.kind === 71 && name.text; + }); + ts.Debug.assert(!!name); + return name; + } + function skipExportSpecifierSymbol(symbol, checker) { + if (symbol.declarations) + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) { + return checker.getExportSpecifierLocalTargetSymbol(declaration); + } + } + return symbol; + } + function getContainingModuleSymbol(importer, checker) { + return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); + } + function getSourceFileLikeForImportDeclaration(node) { + if (node.kind === 181) { + return node.getSourceFile(); + } + var parent = node.parent; + if (parent.kind === 265) { + return parent; + } + ts.Debug.assert(parent.kind === 234 && isAmbientModuleDeclaration(parent.parent)); + return parent.parent; + } + function isAmbientModuleDeclaration(node) { + return node.kind === 233 && node.name.kind === 9; + } + function isExternalModuleImportEquals(_a) { + var moduleReference = _a.moduleReference; + return moduleReference.kind === 248 && moduleReference.expression.kind === 9; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + function nodeEntry(node, isInString) { + return { type: "node", node: node, isInString: isInString }; + } + FindAllReferences.nodeEntry = nodeEntry; + function findReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position) { + var referencedSymbols = findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position); + if (!referencedSymbols || !referencedSymbols.length) { return undefined; } + var out = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var _a = referencedSymbols_1[_i], definition = _a.definition, references = _a.references; + if (definition) { + out.push({ definition: definitionToReferencedSymbolDefinitionInfo(definition, checker), references: references.map(toReferenceEntry) }); + } + } + return out; + } + FindAllReferences.findReferencedSymbols = findReferencedSymbols; + function getImplementationsAtPosition(checker, cancellationToken, sourceFiles, sourceFile, position) { + var node = ts.getTouchingPropertyName(sourceFile, position); + var referenceEntries = getImplementationReferenceEntries(checker, cancellationToken, sourceFiles, node); + return ts.map(referenceEntries, function (entry) { return toImplementationLocation(entry, checker); }); + } + FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; + function getImplementationReferenceEntries(typeChecker, cancellationToken, sourceFiles, node) { + if (node.parent.kind === 262) { + var result_4 = []; + FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, function (node) { return result_4.push(nodeEntry(node)); }); + return result_4; + } + else if (node.kind === 97 || ts.isSuperProperty(node.parent)) { + var symbol = typeChecker.getSymbolAtLocation(node); + return symbol.valueDeclaration && [nodeEntry(symbol.valueDeclaration)]; + } + else { + return getReferenceEntriesForNode(node, sourceFiles, typeChecker, cancellationToken, { implementations: true }); + } + } + function findReferencedEntries(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var x = flattenEntries(findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options)); + return ts.map(x, toReferenceEntry); + } + FindAllReferences.findReferencedEntries = findReferencedEntries; + function getReferenceEntriesForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + return flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options)); + } + FindAllReferences.getReferenceEntriesForNode = getReferenceEntriesForNode; + function findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var node = ts.getTouchingPropertyName(sourceFile, position, true); + return FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options); + } + function flattenEntries(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + function definitionToReferencedSymbolDefinitionInfo(def, checker) { + var info = (function () { + switch (def.type) { + case "symbol": { + var symbol = def.symbol, node_2 = def.node; + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; + var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + } + case "label": { + var node_3 = def.node; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + } + case "keyword": { + var node_4 = def.node; + var name_4 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; + } + case "this": { + var node_5 = def.node; + var symbol = checker.getSymbolAtLocation(node_5); + var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; + } + case "string": { + var node_6 = def.node; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + } + } + })(); + if (!info) { + return undefined; + } + var node = info.node, name = info.name, kind = info.kind, displayParts = info.displayParts; + var sourceFile = node.getSourceFile(); return { containerKind: "", containerName: "", + fileName: sourceFile.fileName, + kind: kind, name: name, - kind: symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + textSpan: ts.createTextSpanFromNode(node, sourceFile), displayParts: displayParts }; } - function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { - if (!(symbol.flags & 8388608)) { - return undefined; - } - var defaultImport = ts.getDeclarationOfKind(symbol, 238); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); - } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 || - declaration.kind === 245) ? declaration : undefined; }); - if (importOrExportSpecifier && - (!importOrExportSpecifier.propertyName || - importOrExportSpecifier.propertyName === location)) { - return importOrExportSpecifier.kind === 241 ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); - } + function getDefinitionKindAndDisplayParts(symbol, node, checker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + return { displayParts: displayParts, kind: symbolKind }; } - function followAliasIfNecessary(symbol, location, typeChecker) { - return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175); - return bindingElement && - bindingElement.parent.kind === 173 && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + function toReferenceEntry(entry) { + if (entry.type === "span") { + return { textSpan: entry.textSpan, fileName: entry.fileName, isWriteAccess: false, isDefinition: false }; } - return undefined; - } - function getInternedName(symbol, location) { - if (ts.isImportOrExportSpecifierName(location)) { - return location.text; - } - return ts.stripQuotes(symbol.name); - } - function getSymbolScope(symbol) { - var valueDeclaration = symbol.valueDeclaration; - if (valueDeclaration && (valueDeclaration.kind === 185 || valueDeclaration.kind === 198)) { - return valueDeclaration; - } - if (symbol.flags & (4 | 8192)) { - var privateDeclaration = ts.forEach(symbol.getDeclarations(), function (d) { return (ts.getModifierFlags(d) & 8) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 228); - } - } - if (symbol.flags & 8388608) { - return undefined; - } - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - return undefined; - } - if (symbol.parent || (symbol.flags & 134217728 && symbol.checkFlags & 2)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { - for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { - var declaration = declarations_10[_i]; - var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } - if (scope && scope !== container) { - return undefined; - } - if (container.kind === 264 && !ts.isExternalModule(container)) { - return undefined; - } - scope = container; - } - } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { - var positions = []; - if (!symbolName || !symbolName.length) { - return positions; - } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - if (position > end) - break; - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { - positions.push(position); - } - position = text.indexOf(symbolName, position + symbolNameLength + 1); - } - return positions; - } - function getLabelReferencesInNode(container, targetLabel, cancellationToken) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - return; - } - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] + var node = entry.node, isInString = entry.isInString; + return { + fileName: node.getSourceFile().fileName, + textSpan: getTextSpan(node), + isWriteAccess: isWriteAccess(node), + isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isInString: isInString }; - return [{ definition: definition, references: references }]; } - function isValidReferencePosition(node, searchSymbolName) { - switch (node && node.kind) { - case 70: - return node.getWidth() === searchSymbolName.length; - case 9: - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && - node.getWidth() === searchSymbolName.length + 2; - case 8: - return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; - default: - return false; - } - } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { - var name = ts.tokenToString(keywordKind); - var references = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); - } - if (!references.length) - return undefined; - var definition = { - containerKind: "", - containerName: "", - fileName: references[0].fileName, - kind: ts.ScriptElementKind.keyword, - name: name, - textSpan: references[0].textSpan, - displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] - }; - return [{ definition: definition, references: references }]; - } - function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (referenceLocation.kind === kind) { - references.push({ - textSpan: ts.createTextSpanFromNode(referenceLocation), - fileName: sourceFile.fileName, - isWriteAccess: false, - isDefinition: false, - }); - } - } - } - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); - var parents = getParentSymbolsOfPropertyAccess(); - for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { - var position = possiblePositions_2[_i]; - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); - } - continue; - } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - continue; - } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocation.kind === 122, parents, inheritsFromCache, typeChecker); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); - } - else if (!(referenceSymbol.flags & 134217728) && ts.contains(searchSymbols, shorthandValueSymbol)) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); - } - else if (searchLocation.kind === 122) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); - } - } - } - return; - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } - } - } - } - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); - addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); - } - else { - var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); - } - } - } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } - } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol, searchLocation, typeChecker), - references: [] - }); - } - return result[index]; - } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references, typeChecker); - } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - function findOwnConstructorCalls(classSymbol, sourceFile) { - var result = []; - for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 122, sourceFile); - ts.Debug.assert(decl.kind === 151 && !!ctrKeyword); - result.push(ctrKeyword); - } - classSymbol.exports.forEach(function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 150) { - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 98, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); - } - }); - } - } - }); - return result; - } - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor"); - if (!ctr) { - return []; - } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 151); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); - } - } - ; - return result; - } - function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70) { - if (refNode.parent.kind === 261) { - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); - } - var containingClass = getContainingClassIfInHeritageClause(refNode); - if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); - return; - } - var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { - var parent = containingTypeReference.parent; - if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); - } - else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - if (parent.body.kind === 206) { - ts.forEachReturnStatement(parent.body, function (returnStatement) { - if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); - } - }); - } - else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); - } - } - else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); - } - } - } - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); - } - } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 200 - && node.parent.kind === 258 - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 || node.kind === 178) { - return getContainingClassIfInHeritageClause(node.parent); - } - } - return undefined; - } - function isImplementationExpression(node) { - switch (node.kind) { - case 184: - return isImplementationExpression(node.expression); - case 186: - case 185: - case 177: - case 198: - case 176: - return true; - default: - return false; - } - } - function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { - var parentIsInterface = parent.getFlags() & 64; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - var cached = cachedResults.get(key); - if (cached !== undefined) { - return cached; - } - cachedResults.set(key, false); - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; - } - } - } - } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 229) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); - } - } - return false; - }); - cachedResults.set(key, inherits); - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } - } - return false; - } - } - function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, false); - if (!searchSpaceNode) { - return undefined; - } - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 148: - case 147: - case 150: - case 149: - case 151: - case 152: - case 153: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - default: - return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { - var position = possiblePositions_3[_i]; - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96) { - continue; - } - var container = ts.getSuperContainer(node, false); - if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - } - var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); - var staticFlag = 32; - switch (searchSpaceNode.kind) { - case 150: - case 149: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { - break; - } - case 148: - case 147: - case 151: - case 152: - case 153: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; - break; - case 264: - if (ts.isExternalModule(searchSpaceNode)) { - return undefined; - } - case 227: - case 185: - break; - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 264) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); + function toImplementationLocation(entry, checker) { + if (entry.type === "node") { + var node = entry.node; + return __assign({ textSpan: getTextSpan(node), fileName: node.getSourceFile().fileName }, implementationKindDisplayParts(node, checker)); } else { - var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: thisOrSuperKeyword.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, false); - switch (searchSpaceNode.kind) { - case 185: - case 227: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 150: - case 149: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 198: - case 228: - if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 264: - if (container.kind === 264 && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); + var textSpan = entry.textSpan, fileName = entry.fileName; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } - function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - return undefined; + function implementationKindDisplayParts(node, checker) { + var symbol = checker.getSymbolAtLocation(ts.isDeclaration(node) && node.name ? node.name : node); + if (symbol) { + return getDefinitionKindAndDisplayParts(symbol, node, checker); } - var references = []; - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); + else if (node.kind === 178) { + return { + kind: ts.ScriptElementKind.interfaceElement, + displayParts: [ts.punctuationPart(19), ts.textPart("object literal"), ts.punctuationPart(20)] + }; } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromNode(node), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { - for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { - var position = possiblePositions_4[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9) { - return; - } - var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_2 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); - } - } - } - } - function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { - var result = [symbol]; - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); - if (propertySymbol) { - result.push(propertySymbol); - } - } - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 145 && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); - } - } - return result; - } - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { - if (!symbol) { - return; - } - if (previousIterationSymbolsCache.has(symbol.name)) { - return; - } - if (symbol.flags & (32 | 64)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 229) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); - } - previousIterationSymbolsCache.set(symbol.name, symbol); - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { - if (ts.contains(searchSymbols, referenceSymbol)) { - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; - } - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); - } - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); - if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { - return propertySymbol; - } - } - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); - if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; - } - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - if (ts.contains(searchSymbols, rootSymbol)) { - return rootSymbol; - } - if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { - return undefined; - } - } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), typeChecker); - return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); - } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 143) { - var nameExpression = node.name.expression; - if (ts.isStringOrNumericLiteral(nameExpression)) { - return nameExpression.text; - } - return undefined; - } - return node.name.text; - } - function getPropertySymbolsFromContextualType(node, typeChecker) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_4 = []; - var symbol = contextualType.getProperty(name); - if (symbol) { - result_4.push(symbol); - } - if (contextualType.flags & 65536) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_4.push(symbol); - } - }); - } - return result_4; - } - return undefined; - } - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - var lastIterationMeaning = void 0; - do { - lastIterationMeaning = meaning; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; - } - } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - function isImplementation(node) { - if (!node) { - return false; - } - else if (ts.isVariableLike(node)) { - if (node.initializer) { - return true; - } - else if (node.kind === 225) { - var parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && ts.hasModifier(parentStatement, 2); - } - } - else if (ts.isFunctionLike(node)) { - return !!node.body || ts.hasModifier(node, 2); + else if (node.kind === 199) { + return { + kind: ts.ScriptElementKind.localClassElement, + displayParts: [ts.punctuationPart(19), ts.textPart("anonymous local class"), ts.punctuationPart(20)] + }; } else { - switch (node.kind) { - case 228: - case 198: - case 231: - case 232: - return true; - } - } - return false; - } - function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 207) { - ts.Debug.assert(node.parent.kind === 226); - return node.parent.parent; + return { kind: ts.getNodeKind(node), displayParts: [] }; } } - function getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result) { - var refSymbol = typeChecker.getSymbolAtLocation(node); - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); - if (shorthandSymbol) { - for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1) { - result.push(getReferenceEntryFromNode(declaration)); - } - } + function toHighlightSpan(entry) { + if (entry.type === "span") { + var fileName_1 = entry.fileName, textSpan = entry.textSpan; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; } + var node = entry.node, isInString = entry.isInString; + var fileName = entry.node.getSourceFile().fileName; + var writeAccess = isWriteAccess(node); + var span = { + textSpan: getTextSpan(node), + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, + isInString: isInString + }; + return { fileName: fileName, span: span }; } - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; - function getReferenceEntryFromNode(node) { + FindAllReferences.toHighlightSpan = toHighlightSpan; + function getTextSpan(node) { var start = node.getStart(); var end = node.getEnd(); if (node.kind === 9) { start += 1; end -= 1; } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - }; + return ts.createTextSpanFromBounds(start, end); } - FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; function isWriteAccess(node) { - if (node.kind === 70 && ts.isDeclarationName(node)) { + if (node.kind === 71 && ts.isDeclarationName(node)) { return true; } var parent = node.parent; if (parent) { - if (parent.kind === 192 || parent.kind === 191) { + if (parent.kind === 193 || parent.kind === 192) { return true; } - else if (parent.kind === 193 && parent.left === node) { + else if (parent.kind === 194 && parent.left === node) { var operator = parent.operatorToken.kind; - return 57 <= operator && operator <= 69; + return 58 <= operator && operator <= 70; } } return false; } - function forEachDescendantOfKind(node, kind, action) { - ts.forEachChild(node, function (child) { - if (child.kind === kind) { - action(child); + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + var Core; + (function (Core) { + function getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + if (node.kind === 265) { + return undefined; } - forEachDescendantOfKind(child, kind, action); - }); - } - function tryGetClassByExtendingIdentifier(node) { - return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9) { - return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + if (!options.implementations) { + var special = getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken); + if (special) { + return special; + } + } + var symbol = checker.getSymbolAtLocation(node); + if (!symbol) { + if (!options.implementations && node.kind === 9) { + return getReferencesForStringLiteral(node, sourceFiles, cancellationToken); + } + return undefined; + } + if (!symbol.declarations || !symbol.declarations.length) { + return undefined; + } + return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options); } - return false; - } - function isImportDefaultSymbol(symbol) { - return symbol.declarations[0].kind === 238; - } + Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition); + } + else { + return getLabelReferencesInNode(node.parent, node); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); + } + if (node.kind === 97) { + return getReferencesForSuperKeyword(node); + } + return undefined; + } + function getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options) { + symbol = skipPastExportOrImportSpecifier(symbol, node, checker); + var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), symbol.declarations); + var result = []; + var state = createState(sourceFiles, node, checker, cancellationToken, searchMeaning, options, result); + var search = state.createSearch(node, symbol, undefined, { allSearchSymbols: populateSearchSymbolSet(symbol, node, checker, options.implementations) }); + var scope = getSymbolScope(symbol); + if (scope) { + getReferencesInContainer(scope, scope.getSourceFile(), search, state); + } + else { + for (var _i = 0, _a = state.sourceFiles; _i < _a.length; _i++) { + var sourceFile = _a[_i]; + state.cancellationToken.throwIfCancellationRequested(); + searchForName(sourceFile, search, state); + } + } + return result; + } + function skipPastExportOrImportSpecifier(symbol, node, checker) { + var parent = node.parent; + if (ts.isExportSpecifier(parent)) { + return getLocalSymbolForExportSpecifier(node, symbol, parent, checker); + } + if (ts.isImportSpecifier(parent) && parent.propertyName === node) { + return checker.getImmediateAliasedSymbol(symbol); + } + return symbol; + } + function createState(sourceFiles, originalLocation, checker, cancellationToken, searchMeaning, options, result) { + var symbolIdToReferences = []; + var inheritsFromCache = ts.createMap(); + var sourceFileToSeenSymbols = []; + var isForConstructor = originalLocation.kind === 123; + var importTracker; + return __assign({}, options, { sourceFiles: sourceFiles, isForConstructor: isForConstructor, checker: checker, cancellationToken: cancellationToken, searchMeaning: searchMeaning, inheritsFromCache: inheritsFromCache, getImportSearches: getImportSearches, createSearch: createSearch, referenceAdder: referenceAdder, addStringOrCommentReference: addStringOrCommentReference, + markSearchedSymbol: markSearchedSymbol, markSeenContainingTypeReference: ts.nodeSeenTracker(), markSeenReExportRHS: ts.nodeSeenTracker() }); + function getImportSearches(exportSymbol, exportInfo) { + if (!importTracker) + importTracker = FindAllReferences.createImportTracker(sourceFiles, checker, cancellationToken); + return importTracker(exportSymbol, exportInfo, options.isForRename); + } + function createSearch(location, symbol, comingFrom, searchOptions) { + if (searchOptions === void 0) { searchOptions = {}; } + var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.getDeclaredName(checker, symbol, location)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? undefined : _b; + var escapedText = ts.escapeIdentifier(text); + var parents = options.implementations && getParentSymbolsOfPropertyAccess(location, symbol, checker); + return { location: location, symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, includes: includes }; + function includes(referenceSymbol) { + return allSearchSymbols ? ts.contains(allSearchSymbols, referenceSymbol) : referenceSymbol === symbol; + } + } + function referenceAdder(referenceSymbol, searchLocation) { + var symbolId = ts.getSymbolId(referenceSymbol); + var references = symbolIdToReferences[symbolId]; + if (!references) { + references = symbolIdToReferences[symbolId] = []; + result.push({ definition: { type: "symbol", symbol: referenceSymbol, node: searchLocation }, references: references }); + } + return function (node) { return references.push(FindAllReferences.nodeEntry(node)); }; + } + function addStringOrCommentReference(fileName, textSpan) { + result.push({ + definition: undefined, + references: [{ type: "span", fileName: fileName, textSpan: textSpan }] + }); + } + function markSearchedSymbol(sourceFile, symbol) { + var sourceId = ts.getNodeId(sourceFile); + var symbolId = ts.getSymbolId(symbol); + var seenSymbols = sourceFileToSeenSymbols[sourceId] || (sourceFileToSeenSymbols[sourceId] = []); + return !seenSymbols[symbolId] && (seenSymbols[symbolId] = true); + } + } + function searchForImportsOfExport(exportLocation, exportSymbol, exportInfo, state) { + var _a = state.getImportSearches(exportSymbol, exportInfo), importSearches = _a.importSearches, singleReferences = _a.singleReferences, indirectUsers = _a.indirectUsers; + if (singleReferences.length) { + var addRef = state.referenceAdder(exportSymbol, exportLocation); + for (var _i = 0, singleReferences_1 = singleReferences; _i < singleReferences_1.length; _i++) { + var singleRef = singleReferences_1[_i]; + addRef(singleRef); + } + } + for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { + var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1), state); + } + if (indirectUsers.length) { + var indirectSearch = void 0; + switch (exportInfo.exportKind) { + case 0: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1); + break; + case 1: + indirectSearch = state.isForRename ? undefined : state.createSearch(exportLocation, exportSymbol, 1, { text: "default" }); + break; + case 2: + break; + } + if (indirectSearch) { + for (var _d = 0, indirectUsers_1 = indirectUsers; _d < indirectUsers_1.length; _d++) { + var indirectUser = indirectUsers_1[_d]; + searchForName(indirectUser, indirectSearch, state); + } + } + } + } + function searchForImportedSymbol(symbol, state) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + getReferencesInSourceFile(declaration.getSourceFile(), state.createSearch(declaration, symbol, 0), state); + } + } + function searchForName(sourceFile, search, state) { + if (ts.getNameTable(sourceFile).get(search.escapedText) !== undefined) { + getReferencesInSourceFile(sourceFile, search, state); + } + } + function getPropertySymbolOfDestructuringAssignment(location, checker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + checker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176); + return bindingElement && + bindingElement.parent.kind === 174 && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176); + var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } + return undefined; + } + function getSymbolScope(symbol) { + var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 186 || valueDeclaration.kind === 199)) { + return valueDeclaration; + } + if (!declarations) { + return undefined; + } + if (flags & (4 | 8192)) { + var privateDeclaration = ts.find(declarations, function (d) { return !!(ts.getModifierFlags(d) & 8); }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 229); + } + } + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + if (parent && !((parent.flags & 1536) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { + return undefined; + } + if ((flags & 134217728 && symbol.checkFlags & 6)) { + return undefined; + } + var scope; + for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { + var declaration = declarations_10[_i]; + var container = ts.getContainerNode(declaration); + if (scope && scope !== container) { + return undefined; + } + if (!container || container.kind === 265 && !ts.isExternalOrCommonJsModule(container)) { + return undefined; + } + scope = container; + } + return parent ? scope.getSourceFile() : scope; + } + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + if (position > end) + break; + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5))) { + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } + return positions; + } + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + continue; + } + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(FindAllReferences.nodeEntry(node)); + } + } + return [{ definition: { type: "label", node: targetLabel }, references: references }]; + } + function isValidReferencePosition(node, searchSymbolName) { + switch (node && node.kind) { + case 71: + return node.getWidth() === searchSymbolName.length; + case 9: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + node.getWidth() === searchSymbolName.length + 2; + case 8: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, ts.tokenToString(keywordKind), references); + } + return references.length ? [{ definition: { type: "keyword", node: references[0].node }, references: references }] : undefined; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd()); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push(FindAllReferences.nodeEntry(referenceLocation)); + } + } + } + function getReferencesInSourceFile(sourceFile, search, state) { + state.cancellationToken.throwIfCancellationRequested(); + return getReferencesInContainer(sourceFile, sourceFile, search, state); + } + function getReferencesInContainer(container, sourceFile, search, state) { + if (!state.markSearchedSymbol(sourceFile, search.symbol)) { + return; + } + var start = state.findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, search.text, start, container.getEnd()); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + getReferencesAtLocation(sourceFile, position, search, state); + } + } + function getReferencesAtLocation(sourceFile, position, search, state) { + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (!isValidReferencePosition(referenceLocation, search.text)) { + if (!state.implementations && (state.findInStrings && ts.isInString(sourceFile, position) || state.findInComments && ts.isInNonReferenceComment(sourceFile, position))) { + state.addStringOrCommentReference(sourceFile.fileName, ts.createTextSpan(position, search.text.length)); + } + return; + } + if (!(ts.getMeaningFromLocation(referenceLocation) & state.searchMeaning)) { + return; + } + var referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation); + if (!referenceSymbol) { + return; + } + var parent = referenceLocation.parent; + if (ts.isImportSpecifier(parent) && parent.propertyName === referenceLocation) { + return; + } + if (ts.isExportSpecifier(parent)) { + ts.Debug.assert(referenceLocation.kind === 71); + getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state); + return; + } + var relatedSymbol = getRelatedSymbol(search, referenceSymbol, referenceLocation, state); + if (!relatedSymbol) { + getReferenceForShorthandProperty(referenceSymbol, search, state); + return; + } + if (state.isForConstructor) { + findConstructorReferences(referenceLocation, sourceFile, search, state); + } + else { + addReference(referenceLocation, relatedSymbol, search.location, state); + } + getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); + } + function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + var exportDeclaration = parent.parent; + var localSymbol = getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, state.checker); + if (!search.includes(localSymbol)) { + return; + } + if (!propertyName) { + addRef(); + } + else if (referenceLocation === propertyName) { + if (!exportDeclaration.moduleSpecifier) { + addRef(); + } + if (!state.isForRename && state.markSeenReExportRHS(name)) { + addReference(name, referenceSymbol, name, state); + } + } + else { + if (state.markSeenReExportRHS(referenceLocation)) { + addRef(); + } + } + if (!(referenceLocation === propertyName && state.isForRename)) { + var exportKind = referenceLocation.originalKeywordKind === 79 ? 1 : 0; + var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); + ts.Debug.assert(!!exportInfo); + searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); + } + if (search.comingFrom !== 1 && exportDeclaration.moduleSpecifier && !propertyName) { + searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state); + } + function addRef() { + addReference(referenceLocation, localSymbol, search.location, state); + } + } + function getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, checker) { + return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol; + } + function isExportSpecifierAlias(referenceLocation, exportSpecifier) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + ts.Debug.assert(propertyName === referenceLocation || name === referenceLocation); + if (propertyName) { + return propertyName === referenceLocation; + } + else { + return !parent.parent.moduleSpecifier; + } + } + function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1); + if (!importOrExport) + return; + var symbol = importOrExport.symbol; + if (importOrExport.kind === 0) { + if (!state.isForRename || importOrExport.isNamedImport) { + searchForImportedSymbol(symbol, state); + } + } + else { + searchForImportsOfExport(referenceLocation, symbol, importOrExport.exportInfo, state); + } + } + function getReferenceForShorthandProperty(_a, search, state) { + var flags = _a.flags, valueDeclaration = _a.valueDeclaration; + var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + if (!(flags & 134217728) && search.includes(shorthandValueSymbol)) { + addReference(valueDeclaration.name, shorthandValueSymbol, search.location, state); + } + } + function addReference(referenceLocation, relatedSymbol, searchLocation, state) { + var addRef = state.referenceAdder(relatedSymbol, searchLocation); + if (state.implementations) { + addImplementationReferences(referenceLocation, addRef, state); + } + else { + addRef(referenceLocation); + } + } + function findConstructorReferences(referenceLocation, sourceFile, search, state) { + if (ts.isNewExpressionTarget(referenceLocation)) { + addReference(referenceLocation, search.symbol, search.location, state); + } + var pusher = state.referenceAdder(search.symbol, search.location); + if (ts.isClassLike(referenceLocation.parent)) { + ts.Debug.assert(referenceLocation.parent.name === referenceLocation); + findOwnConstructorReferences(search.symbol, sourceFile, pusher); + } + else { + var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); + if (classExtending && ts.isClassLike(classExtending)) { + findSuperConstructorAccesses(classExtending, pusher); + } + } + } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; + } + function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 123, sourceFile); + ts.Debug.assert(decl.kind === 152 && !!ctrKeyword); + addNode(ctrKeyword); + } + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 151) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 99, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + addNode(thisKeyword); + } + }); + } + } + }); + } + function findSuperConstructorAccesses(cls, addNode) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return; + } + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 152); + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 97, function (node) { + if (ts.isCallExpressionTarget(node)) { + addNode(node); + } + }); + } + } + } + function addImplementationReferences(refNode, addReference, state) { + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + addReference(refNode.parent); + return; + } + if (refNode.kind !== 71) { + return; + } + if (refNode.parent.kind === 262) { + getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); + } + var containingClass = getContainingClassIfInHeritageClause(refNode); + if (containingClass) { + addReference(containingClass); + return; + } + var containingTypeReference = getContainingTypeReference(refNode); + if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { + var parent = containingTypeReference.parent; + if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { + addReference(parent.initializer); + } + else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { + if (parent.body.kind === 207) { + ts.forEachReturnStatement(parent.body, function (returnStatement) { + if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { + addReference(returnStatement.expression); + } + }); + } + else if (isImplementationExpression(parent.body)) { + addReference(parent.body); + } + } + else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { + addReference(parent.expression); + } + } + } + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 | 64)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 201 + && node.parent.kind === 259 + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 71 || node.kind === 179) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + function isImplementationExpression(node) { + switch (node.kind) { + case 185: + return isImplementationExpression(node.expression); + case 187: + case 186: + case 178: + case 199: + case 177: + return true; + default: + return false; + } + } + function explicitlyInheritsFrom(child, parent, cachedResults, checker) { + var parentIsInterface = parent.getFlags() & 64; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } + } + } + } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + } + else if (declaration.kind === 230) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); + } + } + return false; + } + } + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, false); + if (!searchSpaceNode) { + return undefined; + } + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 149: + case 148: + case 151: + case 150: + case 152: + case 153: + case 154: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + default: + return undefined; + } + var references = []; + var sourceFile = searchSpaceNode.getSourceFile(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { + var position = possiblePositions_4[_i]; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97) { + continue; + } + var container = ts.getSuperContainer(node, false); + if (container && (32 & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(FindAllReferences.nodeEntry(node)); + } + } + return [{ definition: { type: "symbol", symbol: searchSpaceNode.symbol, node: superKeyword }, references: references }]; + } + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, false); + var staticFlag = 32; + switch (searchSpaceNode.kind) { + case 151: + case 150: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; + } + case 149: + case 148: + case 152: + case 153: + case 154: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; + break; + case 265: + if (ts.isExternalModule(searchSpaceNode)) { + return undefined; + } + case 228: + case 186: + break; + default: + return undefined; + } + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 265) { + ts.forEach(sourceFiles, function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); + } + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); + } + return [{ + definition: { type: "this", node: thisOrSuperKeyword }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || !ts.isThis(node)) { + return; + } + var container = ts.getThisContainer(node, false); + switch (searchSpaceNode.kind) { + case 186: + case 228: + if (searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 151: + case 150: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 199: + case 229: + if (container.parent && searchSpaceNode.symbol === container.parent.symbol && (ts.getModifierFlags(container) & 32) === staticFlag) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 265: + if (container.kind === 265 && !ts.isExternalModule(container)) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + } + }); + } + } + function getReferencesForStringLiteral(node, sourceFiles, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text, sourceFile.getStart(), sourceFile.getEnd()); + getReferencesForStringLiteralInFile(sourceFile, node.text, possiblePositions, references); + } + return [{ + definition: { type: "string", node: node }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchText, possiblePositions, references) { + for (var _i = 0, possiblePositions_5 = possiblePositions; _i < possiblePositions_5.length; _i++) { + var position = possiblePositions_5[_i]; + var node_7 = ts.getTouchingWord(sourceFile, position); + if (node_7 && node_7.kind === 9 && node_7.text === searchText) { + references.push(FindAllReferences.nodeEntry(node_7, true)); + } + } + } + } + function populateSearchSymbolSet(symbol, location, checker, implementations) { + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement) { + if (containingObjectLiteralElement.kind !== 262) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker), function (contextualSymbol) { + ts.addRange(result, checker.getRootSymbols(contextualSymbol)); + }); + var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } + } + if (symbol.valueDeclaration && symbol.valueDeclaration.kind === 146 && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, checker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), checker); + } + } + return result; + } + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, checker) { + if (!symbol) { + return; + } + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 | 64)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 230) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = checker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, checker.getRootSymbols(propertySymbol)); + } + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, checker); + } + } + } + } + function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { + if (search.includes(referenceSymbol)) { + return referenceSymbol; + } + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, state.checker), function (contextualSymbol) { + return ts.find(state.checker.getRootSymbols(contextualSymbol), search.includes); + }); + if (contextualSymbol) { + return contextualSymbol; + } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, state.checker); + if (propertySymbol && search.includes(propertySymbol)) { + return propertySymbol; + } + } + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); + if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { + if (search.includes(rootSymbol)) { + return rootSymbol; + } + if (rootSymbol.parent && rootSymbol.parent.flags & (32 | 64)) { + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, ts.createMap(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 144) { + var nameExpression = node.name.expression; + if (ts.isStringOrNumericLiteral(nameExpression)) { + return nameExpression.text; + } + return undefined; + } + return node.name.text; + } + function getPropertySymbolsFromContextualType(node, checker) { + var objectLiteral = node.parent; + var contextualType = checker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_5 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + if (contextualType.flags & 65536) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + }); + } + return result_5; + } + return undefined; + } + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + var lastIterationMeaning = void 0; + do { + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + function isImplementation(node) { + if (!node) { + return false; + } + else if (ts.isVariableLike(node)) { + if (node.initializer) { + return true; + } + else if (node.kind === 226) { + var parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && ts.hasModifier(parentStatement, 2); + } + } + else if (ts.isFunctionLike(node)) { + return !!node.body || ts.hasModifier(node, 2); + } + else { + switch (node.kind) { + case 229: + case 199: + case 232: + case 233: + return true; + } + } + return false; + } + function getParentStatementOfVariableDeclaration(node) { + if (node.parent && node.parent.parent && node.parent.parent.kind === 208) { + ts.Debug.assert(node.parent.kind === 227); + return node.parent.parent; + } + } + function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { + var refSymbol = checker.getSymbolAtLocation(node); + var shorthandSymbol = checker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + if (shorthandSymbol) { + for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.getMeaningFromDeclaration(declaration) & 1) { + addReference(declaration); + } + } + } + } + Core.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; + function forEachDescendantOfKind(node, kind, action) { + ts.forEachChild(node, function (child) { + if (child.kind === kind) { + action(child); + } + forEachDescendantOfKind(child, kind, action); + }); + } + function tryGetClassByExtendingIdentifier(node) { + return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9) { + return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + } + return false; + } + function getParentSymbolsOfPropertyAccess(location, symbol, checker) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(location); + if (!propertyAccessExpression) { + return undefined; + } + var localParentType = checker.getTypeAtLocation(propertyAccessExpression.expression); + if (!localParentType) { + return undefined; + } + if (localParentType.symbol && localParentType.symbol.flags & (32 | 64) && localParentType.symbol !== symbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & 196608) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); var ts; @@ -60378,13 +63483,13 @@ var ts; } if (symbol.flags & 8388608) { var declaration = symbol.declarations[0]; - if (node.kind === 70 && + if (node.kind === 71 && (node.parent === declaration || - (declaration.kind === 241 && declaration.parent && declaration.parent.kind === 240))) { + (declaration.kind === 242 && declaration.parent && declaration.parent.kind === 241))) { symbol = typeChecker.getAliasedSymbol(symbol); } } - if (node.parent.kind === 261) { + if (node.parent.kind === 262) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -60428,13 +63533,13 @@ var ts; return undefined; } if (type.flags & 65536 && !(type.flags & 16)) { - var result_5 = []; + var result_6 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(result_5, getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(result_6, getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_5; + return result_6; } if (!type.symbol) { return undefined; @@ -60454,7 +63559,7 @@ var ts; } return result; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { - if (ts.isNewExpressionTarget(location) || location.kind === 122) { + if (ts.isNewExpressionTarget(location) || location.kind === 123) { if (symbol.flags & 32) { for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { var declaration = _a[_i]; @@ -60474,11 +63579,14 @@ var ts; return false; } function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + if (!signatureDeclarations) { + return false; + } var declarations = []; var definition; for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { var d = signatureDeclarations_1[_i]; - if (selectConstructors ? d.kind === 151 : isSignatureDeclaration(d)) { + if (selectConstructors ? d.kind === 152 : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; @@ -60493,10 +63601,10 @@ var ts; } function isSignatureDeclaration(node) { switch (node.kind) { + case 152: + case 228: case 151: - case 227: case 150: - case 149: return true; default: return false; @@ -60568,34 +63676,6 @@ var ts; })(GoToDefinition = ts.GoToDefinition || (ts.GoToDefinition = {})); })(ts || (ts = {})); var ts; -(function (ts) { - var GoToImplementation; - (function (GoToImplementation) { - function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - if (node.parent.kind === 261) { - var result = []; - ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); - return result.length > 0 ? result : undefined; - } - else if (node.kind === 96 || ts.isSuperProperty(node.parent)) { - var symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; - } - else { - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, false, false, false, true); - var result = ts.flatMap(referencedSymbols, function (symbol) { - return ts.map(symbol.references, function (_a) { - var textSpan = _a.textSpan, fileName = _a.fileName; - return ({ textSpan: textSpan, fileName: fileName }); - }); - }); - return result && result.length > 0 ? result : undefined; - } - } - GoToImplementation.getImplementationAtPosition = getImplementationAtPosition; - })(GoToImplementation = ts.GoToImplementation || (ts.GoToImplementation = {})); -})(ts || (ts = {})); -var ts; (function (ts) { var JsDoc; (function (JsDoc) { @@ -60641,7 +63721,8 @@ var ts; "prop", "version" ]; - var jsDocCompletionEntries; + var jsDocTagNameCompletionEntries; + var jsDocTagCompletionEntries; function getJsDocCommentsFromDeclarations(declarations) { var documentationComment = []; forEachUnique(declarations, function (declaration) { @@ -60662,6 +63743,29 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 284; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; function forEachUnique(array, callback) { if (array) { for (var i = 0; i < array.length; i++) { @@ -60675,8 +63779,8 @@ var ts; } return undefined; } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + function getJSDocTagNameCompletions() { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, kind: ts.ScriptElementKind.keyword, @@ -60685,7 +63789,18 @@ var ts; }; })); } - JsDoc.getAllJsDocCompletionEntries = getAllJsDocCompletionEntries; + JsDoc.getJSDocTagNameCompletions = getJSDocTagNameCompletions; + function getJSDocTagCompletions() { + return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: "@" + tagName, + kind: ts.ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + JsDoc.getJSDocTagCompletions = getJSDocTagCompletions; function getDocCommentTemplateAtPosition(newLine, sourceFile, position) { if (ts.isInString(sourceFile, position) || ts.isInComment(sourceFile, position) || ts.hasDocComment(sourceFile, position)) { return undefined; @@ -60698,16 +63813,16 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 227: - case 150: - case 151: case 228: - case 207: + case 151: + case 152: + case 229: + case 208: break findOwner; - case 264: + case 265: return undefined; - case 232: - if (commentOwner.parent.kind === 232) { + case 233: + if (commentOwner.parent.kind === 233) { return undefined; } break findOwner; @@ -60719,12 +63834,12 @@ var ts; var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 70 ? + var paramName = currentName.kind === 71 ? currentName.text : "param" + i; if (isJavaScriptFile) { @@ -60747,7 +63862,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 207) { + if (commentOwner.kind === 208) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -60757,17 +63872,17 @@ var ts; return ts.emptyArray; } function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 184) { + while (rightHandSide.kind === 185) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 185: case 186: + case 187: return rightHandSide.parameters; - case 198: + case 199: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151) { + if (member.kind === 152) { return member.parameters; } } @@ -60781,8 +63896,6 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - ; - ; var safeList; var EmptySafeList = ts.createMap(); JsTyping.nodeCoreModuleList = [ @@ -60823,8 +63936,10 @@ var ts; getTypingNamesFromJson(packageJsonPath, filesToWatch); var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components"); + getTypingNamesFromPackagesFolder(bowerComponentsPath); var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); + getTypingNamesFromPackagesFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); if (unresolvedImports) { @@ -60900,16 +64015,18 @@ var ts; mergeTypings(["react"]); } } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { + function getTypingNamesFromPackagesFolder(packagesFolderPath) { + filesToWatch.push(packagesFolderPath); + if (!host.directoryExists(packagesFolderPath)) { return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + var fileNames = host.readDirectory(packagesFolderPath, [".json"], undefined, undefined, 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + var baseFileName = ts.getBaseFileName(normalizedFileName); + if (baseFileName !== "package.json" && baseFileName !== "bower.json") { continue; } var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); @@ -60917,7 +64034,7 @@ var ts; continue; } var packageJson = result.config; - if (packageJson._requiredBy && + if (baseFileName === "package.json" && packageJson._requiredBy && ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { continue; } @@ -60975,13 +64092,13 @@ var ts; } }); }; - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; _loop_4(sourceFile); } rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 238 || decl.kind === 241 || decl.kind === 236) { + if (decl.kind === 239 || decl.kind === 242 || decl.kind === 237) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -61008,7 +64125,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 || + if (node.kind === 71 || node.kind === 9 || node.kind === 8) { return node.text; @@ -61022,7 +64139,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 143) { + else if (declaration.name.kind === 144) { return tryAddComputedPropertyName(declaration.name.expression, containers, true); } else { @@ -61039,7 +64156,7 @@ var ts; } return true; } - if (expression.kind === 178) { + if (expression.kind === 179) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -61050,7 +64167,7 @@ var ts; } function getContainers(declaration) { var containers = []; - if (declaration.name.kind === 143) { + if (declaration.name.kind === 144) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, false)) { return undefined; } @@ -61104,21 +64221,41 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { + var whiteSpaceRegex = /\s+/g; + var curCancellationToken; + var curSourceFile; + var parentsStack = []; + var parent; + var emptyChildItemArray = []; + function getNavigationBarItems(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); - curSourceFile = undefined; - return result; + try { + return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + } + finally { + reset(); + } } NavigationBar.getNavigationBarItems = getNavigationBarItems; - function getNavigationTree(sourceFile) { + function getNavigationTree(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = convertToTree(rootNavigationBarNode(sourceFile)); - curSourceFile = undefined; - return result; + try { + return convertToTree(rootNavigationBarNode(sourceFile)); + } + finally { + reset(); + } } NavigationBar.getNavigationTree = getNavigationTree; - var curSourceFile; + function reset() { + curSourceFile = undefined; + curCancellationToken = undefined; + parentsStack = []; + parent = undefined; + emptyChildItemArray = []; + } function nodeText(node) { return node.getText(curSourceFile); } @@ -61133,8 +64270,6 @@ var ts; parent.children = [child]; } } - var parentsStack = []; - var parent; function rootNavigationBarNode(sourceFile) { ts.Debug.assert(!parentsStack.length); var root = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; @@ -61178,11 +64313,12 @@ var ts; endNode(); } function addChildrenRecursively(node) { + curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 151: + case 152: var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); for (var _i = 0, _a = ctr.parameters; _i < _a.length; _i++) { @@ -61192,28 +64328,28 @@ var ts; } } break; - case 150: - case 152: + case 151: case 153: - case 149: + case 154: + case 150: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; + case 149: case 148: - case 147: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 238: + case 239: var importClause = node; if (importClause.name) { addLeafNode(importClause); } var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 239) { + if (namedBindings.kind === 240) { addLeafNode(namedBindings); } else { @@ -61224,8 +64360,8 @@ var ts; } } break; - case 175: - case 225: + case 176: + case 226: var decl = node; var name = decl.name; if (ts.isBindingPattern(name)) { @@ -61238,12 +64374,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; + case 187: + case 228: case 186: - case 227: - case 185: addNodeWithRecursiveChild(node, node.body); break; - case 231: + case 232: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -61253,9 +64389,9 @@ var ts; } endNode(); break; - case 228: - case 198: case 229: + case 199: + case 230: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -61263,21 +64399,21 @@ var ts; } endNode(); break; - case 232: + case 233: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 245: - case 236: - case 156: - case 154: + case 246: + case 237: + case 157: case 155: - case 230: + case 156: + case 231: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 289) { + if (tag.kind === 290) { addLeafNode(tag); } }); @@ -61325,12 +64461,12 @@ var ts; } }); function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 232 || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 233 || areSameModule(a, b)); function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 232) { + if (a.body.kind !== 233) { return true; } return areSameModule(a.body, b.body); @@ -61364,7 +64500,7 @@ var ts; } } function tryGetName(node) { - if (node.kind === 232) { + if (node.kind === 233) { return getModuleName(node); } var decl = node; @@ -61372,18 +64508,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 185: case 186: - case 198: + case 187: + case 199: return getFunctionOrClassName(node); - case 289: + case 290: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 232) { + if (node.kind === 233) { return getModuleName(node); } var name = node.name; @@ -61394,29 +64530,29 @@ var ts; } } switch (node.kind) { - case 264: + case 265: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 186: - case 227: - case 185: + case 187: case 228: - case 198: + case 186: + case 229: + case 199: if (ts.getModifierFlags(node) & 512) { return "default"; } return getFunctionOrClassName(node); - case 151: + case 152: return "constructor"; - case 155: - return "new()"; - case 154: - return "()"; case 156: + return "new()"; + case 155: + return "()"; + case 157: return "[]"; - case 289: + case 290: return getJSDocTypedefTagName(node); default: return ""; @@ -61428,10 +64564,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 207) { + if (parentNode && parentNode.kind === 208) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70) { + if (nameIdentifier.kind === 71) { return nameIdentifier.text; } } @@ -61456,24 +64592,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 228: - case 198: - case 231: case 229: + case 199: case 232: - case 264: case 230: - case 289: + case 233: + case 265: + case 231: + case 290: return true; - case 151: - case 150: case 152: + case 151: case 153: - case 225: + case 154: + case 226: return hasSomeImportantChild(item); + case 187: + case 228: case 186: - case 227: - case 185: return isTopLevelFunctionDeclaration(item); default: return false; @@ -61483,10 +64619,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 233: - case 264: - case 150: + case 234: + case 265: case 151: + case 152: return true; default: return hasSomeImportantChild(item); @@ -61495,12 +64631,11 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 225 && childKind !== 175; + return childKind !== 226 && childKind !== 176; }); } } } - var emptyChildItemArray = []; function convertToTree(n) { return { text: getItemName(n.node), @@ -61550,25 +64685,25 @@ var ts; } var result = []; result.push(moduleDeclaration.name.text); - while (moduleDeclaration.body && moduleDeclaration.body.kind === 232) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 233) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } return result.join("."); } function getInteriorModule(decl) { - return decl.body.kind === 232 ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 233 ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 143; + return !member.name || member.name.kind === 144; } function getNodeSpan(node) { - return node.kind === 264 + return node.kind === 265 ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 225) { + if (node.parent && node.parent.kind === 226) { node = node.parent; } return ts.getNodeModifiers(node); @@ -61577,14 +64712,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 225) { + else if (node.parent.kind === 226) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 193 && - node.parent.operatorToken.kind === 57) { + else if (node.parent.kind === 194 && + node.parent.operatorToken.kind === 58) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 260 && node.parent.name) { + else if (node.parent.kind === 261 && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512) { @@ -61595,38 +64730,37 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 185 || node.kind === 186 || node.kind === 198; + return node.kind === 186 || node.kind === 187 || node.kind === 199; } - var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { - function collectElements(sourceFile) { + function collectElements(sourceFile, cancellationToken) { var elements = []; var collapseText = "..."; function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { if (hintSpanNode && startElement && endElement) { - var span_12 = { + var span_13 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_12); + elements.push(span_13); } } function addOutliningSpanComments(commentSpan, autoCollapse) { if (commentSpan) { - var span_13 = { + var span_14 = { textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_13); + elements.push(span_14); } } function addOutliningForLeadingCommentsForNode(n) { @@ -61638,6 +64772,7 @@ var ts; var singleLineCommentCount = 0; for (var _i = 0, comments_4 = comments; _i < comments_4.length; _i++) { var currentComment = comments_4[_i]; + cancellationToken.throwIfCancellationRequested(); if (currentComment.kind === 2) { if (isFirstSingleLineComment) { firstSingleLineCommentStart = currentComment.pos; @@ -61660,19 +64795,20 @@ var ts; function combineAndAddMultipleSingleLineComments(count, start, end) { if (count > 1) { var multipleSingleLineComments = { + kind: 2, pos: start, end: end, - kind: 2 }; addOutliningSpanComments(multipleSingleLineComments, false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 186; + return ts.isFunctionBlock(node) && node.parent.kind !== 187; } var depth = 0; var maxDepth = 20; function walk(n) { + cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } @@ -61680,64 +64816,64 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 206: + case 207: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 16, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17, sourceFile); - if (parent.kind === 211 || - parent.kind === 214 || + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); + if (parent.kind === 212 || parent.kind === 215 || + parent.kind === 216 || + parent.kind === 214 || + parent.kind === 211 || parent.kind === 213 || - parent.kind === 210 || - parent.kind === 212 || - parent.kind === 219 || - parent.kind === 259) { + parent.kind === 220 || + parent.kind === 260) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent.kind === 223) { + if (parent.kind === 224) { var tryStatement = parent; if (tryStatement.tryBlock === n) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; } } } - var span_14 = ts.createTextSpanFromNode(n); + var span_15 = ts.createTextSpanFromNode(n); elements.push({ - textSpan: span_14, - hintSpan: span_14, + textSpan: span_15, + hintSpan: span_15, bannerText: collapseText, autoCollapse: autoCollapse(n) }); break; } - case 233: { - var openBrace = ts.findChildOfKind(n, 16, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + case 234: { + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 228: case 229: - case 231: - case 177: - case 234: { - var openBrace = ts.findChildOfKind(n, 16, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17, sourceFile); + case 230: + case 232: + case 178: + case 235: { + var openBrace = ts.findChildOfKind(n, 17, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 176: - var openBracket = ts.findChildOfKind(n, 20, sourceFile); - var closeBracket = ts.findChildOfKind(n, 21, sourceFile); + case 177: + var openBracket = ts.findChildOfKind(n, 21, sourceFile); + var closeBracket = ts.findChildOfKind(n, 22, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -61833,9 +64969,9 @@ var ts; if (index > 0) { var wordSpans = getWordSpans(candidate); for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { - var span_15 = wordSpans_1[_i]; - if (partStartsWith(candidate, span_15, chunk.text, true)) { - return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span_15, chunk.text, false)); + var span_16 = wordSpans_1[_i]; + if (partStartsWith(candidate, span_16, chunk.text, true)) { + return createPatternMatch(PatternMatchKind.substring, punctuationStripped, partStartsWith(candidate, span_16, chunk.text, false)); } } } @@ -62175,10 +65311,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 16) { + if (token === 17) { braceNesting++; } - else if (token === 17) { + else if (token === 18) { braceNesting--; } return token; @@ -62226,9 +65362,9 @@ var ts; } function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 123) { + if (token === 124) { token = nextToken(); - if (token === 127) { + if (token === 128) { token = nextToken(); if (token === 9) { recordAmbientExternalModule(); @@ -62240,42 +65376,42 @@ var ts; } function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 90) { + if (token === 91) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } else { - if (token === 70 || ts.isKeyword(token)) { + if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); return true; } } - else if (token === 57) { + else if (token === 58) { if (tryConsumeRequireCall(true)) { return true; } } - else if (token === 25) { + else if (token === 26) { token = nextToken(); } else { return true; } } - if (token === 16) { + if (token === 17) { token = nextToken(); - while (token !== 17 && token !== 1) { + while (token !== 18 && token !== 1) { token = nextToken(); } - if (token === 17) { + if (token === 18) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62283,13 +65419,13 @@ var ts; } } } - else if (token === 38) { + else if (token === 39) { token = nextToken(); - if (token === 117) { + if (token === 118) { token = nextToken(); - if (token === 70 || ts.isKeyword(token)) { + if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62305,17 +65441,17 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 83) { + if (token === 84) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 16) { + if (token === 17) { token = nextToken(); - while (token !== 17 && token !== 1) { + while (token !== 18 && token !== 1) { token = nextToken(); } - if (token === 17) { + if (token === 18) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62323,20 +65459,20 @@ var ts; } } } - else if (token === 38) { + else if (token === 39) { token = nextToken(); - if (token === 139) { + if (token === 140) { token = nextToken(); if (token === 9) { recordModuleName(); } } } - else if (token === 90) { + else if (token === 91) { token = nextToken(); - if (token === 70 || ts.isKeyword(token)) { + if (token === 71 || ts.isKeyword(token)) { token = nextToken(); - if (token === 57) { + if (token === 58) { if (tryConsumeRequireCall(true)) { return true; } @@ -62349,9 +65485,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 131) { + if (token === 132) { token = nextToken(); - if (token === 18) { + if (token === 19) { token = nextToken(); if (token === 9) { recordModuleName(); @@ -62363,27 +65499,27 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 70 && ts.scanner.getTokenValue() === "define") { + if (token === 71 && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 18) { + if (token !== 19) { return true; } token = nextToken(); if (token === 9) { token = nextToken(); - if (token === 25) { + if (token === 26) { token = nextToken(); } else { return true; } } - if (token !== 20) { + if (token !== 21) { return true; } token = nextToken(); var i = 0; - while (token !== 21 && token !== 1) { + while (token !== 22 && token !== 1) { if (token === 9) { recordModuleName(); i++; @@ -62476,20 +65612,22 @@ var ts; if (ts.some(declarations, isDefinedInLibraryFile)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + if (node.kind === 71 && + node.originalKeywordKind === 79 && + symbol.parent.flags & 1536) { + return undefined; + } var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; } } else if (node.kind === 9) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - var displayName = ts.stripQuotes(type.text); - return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + var displayName = ts.stripQuotes(node.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -62524,7 +65662,8 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 70 || node.kind === 9 || + return node.kind === 71 || + node.kind === 9 || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node); } @@ -62567,14 +65706,14 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 180) { + if (argumentInfo.invocation.kind !== 181) { return undefined; } var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 70 + var name = expression.kind === 71 ? expression - : expression.kind === 178 + : expression.kind === 179 ? expression.name : undefined; if (!name || !name.text) { @@ -62603,10 +65742,10 @@ var ts; } } function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 180 || node.parent.kind === 181) { + if (node.parent.kind === 181 || node.parent.kind === 182) { var callExpression = node.parent; - if (node.kind === 26 || - node.kind === 18) { + if (node.kind === 27 || + node.kind === 19) { var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); var isTypeArgList = callExpression.typeArguments && callExpression.typeArguments.pos === list.pos; ts.Debug.assert(list !== undefined); @@ -62635,24 +65774,24 @@ var ts; } return undefined; } - else if (node.kind === 12 && node.parent.kind === 182) { + else if (node.kind === 13 && node.parent.kind === 183) { if (ts.isInsideTemplateLiteral(node, position)) { return getArgumentListInfoForTemplate(node.parent, 0, sourceFile); } } - else if (node.kind === 13 && node.parent.parent.kind === 182) { + else if (node.kind === 14 && node.parent.parent.kind === 183) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195); + ts.Debug.assert(templateExpression.kind === 196); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 204 && node.parent.parent.parent.kind === 182) { + else if (node.parent.kind === 205 && node.parent.parent.parent.kind === 183) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195); - if (node.kind === 15 && !ts.isInsideTemplateLiteral(node, position)) { + ts.Debug.assert(templateExpression.kind === 196); + if (node.kind === 16 && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -62681,7 +65820,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 25) { + if (child.kind !== 26) { argumentIndex++; } } @@ -62689,8 +65828,8 @@ var ts; } function getArgumentCount(argumentsList) { var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 26; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 26) { argumentCount++; } return argumentCount; @@ -62706,7 +65845,7 @@ var ts; return spanIndex + 1; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { - var argumentCount = tagExpression.template.kind === 12 + var argumentCount = tagExpression.template.kind === 13 ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -62727,7 +65866,7 @@ var ts; var template = taggedTemplate.template; var applicableSpanStart = template.getStart(); var applicableSpanEnd = template.getEnd(); - if (template.kind === 195) { + if (template.kind === 196) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, false); @@ -62736,7 +65875,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 264; n = n.parent) { + for (var n = node; n.kind !== 265; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -62789,10 +65928,10 @@ var ts; var isVariadic; if (isTypeParameterList) { isVariadic = false; - prefixDisplayParts.push(ts.punctuationPart(26)); + prefixDisplayParts.push(ts.punctuationPart(27)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(28)); + suffixDisplayParts.push(ts.punctuationPart(29)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -62804,10 +65943,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(18)); + prefixDisplayParts.push(ts.punctuationPart(19)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(19)); + suffixDisplayParts.push(ts.punctuationPart(20)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -62817,9 +65956,10 @@ var ts; isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(25), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(26), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -62866,9 +66006,9 @@ var ts; var SymbolDisplay; (function (SymbolDisplay) { function getSymbolKind(typeChecker, symbol, location) { - var flags = symbol.getFlags(); + var flags = symbol.flags; if (flags & 32) - return ts.getDeclarationOfKind(symbol, 198) ? + return ts.getDeclarationOfKind(symbol, 199) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384) return ts.ScriptElementKind.enumElement; @@ -62878,12 +66018,12 @@ var ts; return ts.ScriptElementKind.interfaceElement; if (flags & 262144) return ts.ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); if (result === ts.ScriptElementKind.unknown) { if (flags & 262144) return ts.ScriptElementKind.typeParameterElement; if (flags & 8) - return ts.ScriptElementKind.variableElement; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608) return ts.ScriptElementKind.alias; if (flags & 1536) @@ -62892,16 +66032,17 @@ var ts; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 98 && ts.isExpression(location)) { + if (location.kind === 99 && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } + var flags = symbol.flags; if (flags & 3) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return ts.ScriptElementKind.parameterElement; @@ -62925,7 +66066,7 @@ var ts; if (flags & 16384) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4) { - if (flags & 134217728 && symbol.checkFlags & 2) { + if (flags & 134217728 && symbol.checkFlags & 6) { var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); if (rootSymbolFlags & (98308 | 3)) { @@ -62959,10 +66100,11 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 98 && ts.isExpression(location); + var isThisExpression = location.kind === 99 && ts.isExpression(location); var type; if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 || symbolFlags & 8388608) { if (symbolKind === ts.ScriptElementKind.memberGetAccessorElement || symbolKind === ts.ScriptElementKind.memberSetAccessorElement) { @@ -62971,14 +66113,14 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 178) { + if (location.parent && location.parent.kind === 179) { var right = location.parent.name; if (right === location || (right && right.getFullWidth() === 0)) { location = location.parent; } } var callExpressionLike = void 0; - if (location.kind === 180 || location.kind === 181) { + if (location.kind === 181 || location.kind === 182) { callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -62993,7 +66135,7 @@ var ts; if (!signature && candidateSignatures.length) { signature = candidateSignatures[0]; } - var useConstructSignatures = callExpressionLike.kind === 181 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96); + var useConstructSignatures = callExpressionLike.kind === 182 || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97); var allSignatures = useConstructSignatures ? type.getConstructSignatures() : type.getCallSignatures(); if (!ts.contains(allSignatures, signature.target) && !ts.contains(allSignatures, signature)) { signature = allSignatures.length ? allSignatures[0] : undefined; @@ -63008,7 +66150,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -63024,10 +66166,10 @@ var ts; case ts.ScriptElementKind.letElement: case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: - displayParts.push(ts.punctuationPart(55)); + displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93)); + displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768 && type.objectFlags & 16) && type.symbol) { @@ -63042,21 +66184,21 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304)) || - (location.kind === 122 && location.parent.kind === 151)) { + (location.kind === 123 && location.parent.kind === 152)) { var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 151 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 152 ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 151) { + if (functionDeclaration.kind === 152) { symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 155 && !(type.symbol.flags & 2048 || type.symbol.flags & 4096) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -63065,11 +66207,11 @@ var ts; } } if (symbolFlags & 32 && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 198)) { + if (ts.getDeclarationOfKind(symbol, 199)) { pushTypePart(ts.ScriptElementKind.localClassElement); } else { - displayParts.push(ts.keywordPart(74)); + displayParts.push(ts.keywordPart(75)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -63077,45 +66219,45 @@ var ts; } if ((symbolFlags & 64) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(108)); + displayParts.push(ts.keywordPart(109)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(137)); + displayParts.push(ts.keywordPart(138)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512)); } if (symbolFlags & 384) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(75)); + displayParts.push(ts.keywordPart(76)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(82)); + displayParts.push(ts.keywordPart(83)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 232); - var isNamespace = declaration && declaration.name && declaration.name.kind === 70; - displayParts.push(ts.keywordPart(isNamespace ? 128 : 127)); + var declaration = ts.getDeclarationOfKind(symbol, 233); + var isNamespace = declaration && declaration.name && declaration.name.kind === 71; + displayParts.push(ts.keywordPart(isNamespace ? 129 : 128)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144) && (semanticMeaning & 2)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.textPart("type parameter")); displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.textPart("type parameter")); + displayParts.push(ts.punctuationPart(20)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -63124,25 +66266,25 @@ var ts; writeTypeParametersOfSymbol(symbol.parent, enclosingDeclaration); } else { - var declaration = ts.getDeclarationOfKind(symbol, 144); + var declaration = ts.getDeclarationOfKind(symbol, 145); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 155) { - displayParts.push(ts.keywordPart(93)); + if (declaration.kind === 156) { + displayParts.push(ts.keywordPart(94)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 154 && declaration.name) { + else if (declaration.kind !== 155 && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32)); } - else if (declaration.kind === 230) { + else if (declaration.kind === 231) { addInPrefix(); - displayParts.push(ts.keywordPart(137)); + displayParts.push(ts.keywordPart(138)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -63151,13 +66293,14 @@ var ts; } } if (symbolFlags & 8) { + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 263) { + if (declaration.kind === 264) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -63165,33 +66308,33 @@ var ts; } if (symbolFlags & 8388608) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 235) { - displayParts.push(ts.keywordPart(83)); + if (symbol.declarations[0].kind === 236) { + displayParts.push(ts.keywordPart(84)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(128)); + displayParts.push(ts.keywordPart(129)); } else { - displayParts.push(ts.keywordPart(90)); + displayParts.push(ts.keywordPart(91)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 236) { + if (declaration.kind === 237) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(131)); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.keywordPart(132)); displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); + displayParts.push(ts.punctuationPart(20)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57)); + displayParts.push(ts.operatorPart(58)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -63205,7 +66348,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(98)); + displayParts.push(ts.keywordPart(99)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -63215,7 +66358,7 @@ var ts; symbolFlags & 3 || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(55)); + displayParts.push(ts.punctuationPart(56)); displayParts.push(ts.spacePart()); if (type.symbol && type.symbol.flags & 262144) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -63244,11 +66387,12 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4) { - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 265; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 193) { + if (!declaration.parent || declaration.parent.kind !== 194) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -63256,6 +66400,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -63263,7 +66408,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -63271,7 +66416,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91)); + displayParts.push(ts.keywordPart(92)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbol, enclosingDeclaration) { @@ -63296,9 +66441,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.textOrKeywordPart(symbolKind)); displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.textOrKeywordPart(symbolKind)); + displayParts.push(ts.punctuationPart(20)); return; } } @@ -63306,14 +66451,15 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(18)); - displayParts.push(ts.operatorPart(36)); + displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.operatorPart(37)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(19)); + displayParts.push(ts.punctuationPart(20)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -63328,14 +66474,14 @@ var ts; return false; } return ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 185) { + if (declaration.kind === 186) { return true; } - if (declaration.kind !== 225 && declaration.kind !== 227) { + if (declaration.kind !== 226 && declaration.kind !== 228) { return false; } for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { - if (parent.kind === 264 || parent.kind === 233) { + if (parent.kind === 265 || parent.kind === 234) { return false; } } @@ -63439,6 +66585,7 @@ var ts; } return options; } + ts.fixupCompilerOptions = fixupCompilerOptions; })(ts || (ts = {})); var ts; (function (ts) { @@ -63456,10 +66603,10 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(sourceFile, startPos, endPos) { + function getFormattingScanner(text, languageVariant, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === 1 ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner = languageVariant === 1 ? jsxScanner : standardScanner; + scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; var leadingTrivia; @@ -63522,11 +66669,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 30: - case 65: + case 31: case 66: + case 67: + case 47: case 46: - case 45: return true; } } @@ -63535,11 +66682,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { + case 253: + case 251: case 252: case 250: - case 251: - case 249: - return node.kind === 70; + return node.kind === 71; } } return false; @@ -63548,14 +66695,14 @@ var ts; return node && node.kind === 10; } function shouldRescanSlashToken(container) { - return container.kind === 11; + return container.kind === 12; } function shouldRescanTemplateToken(container) { - return container.kind === 14 || - container.kind === 15; + return container.kind === 15 || + container.kind === 16; } function startsWithSlashToken(t) { - return t === 40 || t === 62; + return t === 41 || t === 63; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -63586,7 +66733,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 && currentToken === 28) { + if (expectedScanAction === 1 && currentToken === 29) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1; @@ -63596,11 +66743,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2; } - else if (expectedScanAction === 3 && currentToken === 17) { + else if (expectedScanAction === 3 && currentToken === 18) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3; } - else if (expectedScanAction === 4 && currentToken === 70) { + else if (expectedScanAction === 4 && currentToken === 71) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4; } @@ -63647,8 +66794,8 @@ var ts; } function isOnToken() { ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 && !ts.isTrivia(current); } function fixTokenKind(tokenInfo, container) { @@ -63734,8 +66881,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 16, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 17, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 17, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 18, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -63902,91 +67049,91 @@ 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, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 54), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); - this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); - this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromRange(0, 141, [19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); - this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(17, 81), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17, 105), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.FromTokens([21, 25, 24])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22, 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, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(56, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 2)); + this.SpaceAfterQuestionMarkInConditionalOperator = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConditionalOperatorContext), 2)); + this.NoSpaceAfterQuestionMark = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.FromRange(0, 142, [20])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(18, 82), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(18, 106), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18, formatting.Shared.TokenRange.FromTokens([22, 26, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(23, 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, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(22, 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, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70, 3, 74, 83, 90]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19, 3, 80, 101, 86, 81]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); - this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(16, 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, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4)); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([71, 3, 75, 84, 91]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([20, 3, 81, 102, 87, 82]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2), 1); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(17, 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, 18), 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.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, 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, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(42, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36, 42), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); - this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103, 99, 93, 79, 95, 102, 120]), 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([109, 75]), 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, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); - this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(95, 24), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([19, 80, 81, 72]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); - this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([101, 86]), 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([124, 134]), 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(44, 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, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 44), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(43, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(37, 37), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(37, 43), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(44, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(38, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(38, 44), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2)); + this.NoSpaceBeforeComma = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104, 100, 94, 80, 96, 103, 121]), 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([110, 76]), 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(89, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(105, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), 2)); + this.NoSpaceBetweenReturnAndSemicolon = new formatting.Rule(formatting.RuleDescriptor.create1(96, 25), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([20, 81, 82, 73]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([102, 87]), 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125, 135]), 71), 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.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([127, 131]), 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 74, 123, 78, 82, 83, 84, 124, 107, 90, 108, 127, 128, 111, 113, 112, 130, 134, 114, 137, 139, 126]), 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([84, 107, 139])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); - this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 35), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(23, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54, formatting.Shared.TokenRange.FromTokens([19, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); - this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19, 26), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26, 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, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.FromTokens([18, 20, 28, 25])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); - this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56, 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([116, 70, 83, 78, 74, 114, 113, 111, 112, 124, 134, 20, 38])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38, formatting.Shared.TokenRange.FromTokens([70, 18])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115, 38), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); - this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([115, 38]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); - this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(119, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119, 88), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70, formatting.Shared.TokenRange.FromTokens([12, 13])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40, 28), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([128, 132]), 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([117, 75, 124, 79, 83, 84, 85, 125, 108, 91, 109, 128, 129, 112, 114, 113, 131, 135, 115, 138, 140, 127]), 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([85, 108, 140])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 36), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(36, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(24, 71), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(55, formatting.Shared.TokenRange.FromTokens([20, 26])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(20, 27), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27, 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, 29), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(29, formatting.Shared.TokenRange.FromTokens([19, 21, 29, 26])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(57, 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([117, 71, 84, 79, 75, 115, 114, 112, 113, 125, 135, 21, 39])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(89, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(39, formatting.Shared.TokenRange.FromTokens([71, 19])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(116, 39), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 8)); + this.SpaceBetweenYieldOrYieldStarAndOperand = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([116, 39]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(120, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(120, 89), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(71, formatting.Shared.TokenRange.FromTokens([13, 14])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 71), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 41), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(41, 29), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 58), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(58, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8)); this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, this.NoSpaceBeforeColon, this.SpaceAfterColon, this.NoSpaceBeforeQuestionMark, this.SpaceAfterQuestionMarkInConditionalOperator, @@ -64041,41 +67188,41 @@ var ts; this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 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, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); - this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); - this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(24, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); - this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18, 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, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, 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, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20, 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, 21), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); - this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([13, 14]), 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([13, 14]), 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([14, 15])), 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([14, 15])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8)); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4), 1); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 2)); + this.NoSpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, 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, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19, 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, 20), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, 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, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(21, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21, 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, 22), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([14, 15]), 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([14, 15]), 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([15, 16])), 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([15, 16])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89, 19), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -64087,36 +67234,36 @@ var ts; throw new Error("Unknown rule"); }; Rules.IsForContext = function (context) { - return context.contextNode.kind === 213; + return context.contextNode.kind === 214; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 193: case 194: - case 201: - case 245: - case 241: - case 157: - case 165: + case 195: + case 202: + case 246: + case 242: + case 158: case 166: + case 167: return true; - case 175: - case 230: - case 236: - case 225: - case 145: - case 263: + case 176: + case 231: + case 237: + case 226: + case 146: + case 264: + case 149: case 148: - case 147: - return context.currentTokenSpan.kind === 57 || context.nextTokenSpan.kind === 57; - case 214: - case 144: - return context.currentTokenSpan.kind === 91 || context.nextTokenSpan.kind === 91; + return context.currentTokenSpan.kind === 58 || context.nextTokenSpan.kind === 58; case 215: - return context.currentTokenSpan.kind === 141 || context.nextTokenSpan.kind === 141; + case 145: + return context.currentTokenSpan.kind === 92 || context.nextTokenSpan.kind === 92; + case 216: + return context.currentTokenSpan.kind === 142 || context.nextTokenSpan.kind === 142; } return false; }; @@ -64124,13 +67271,13 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 194; + return context.contextNode.kind === 195; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 173 || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 174 || Rules.IsSingleLineBlockContext(context); }; Rules.IsBeforeMultilineBlockContext = function (context) { return Rules.IsBeforeBlockContext(context) && !(context.NextNodeAllOnSameLine() || context.NextNodeBlockIsOnOneLine()); @@ -64152,65 +67299,65 @@ var ts; return true; } switch (node.kind) { - case 206: + case 207: + case 235: + case 178: case 234: - case 177: - case 233: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 227: + case 228: + case 151: case 150: - case 149: - case 152: case 153: case 154: - case 185: - case 151: + case 155: case 186: - case 229: + case 152: + case 187: + case 230: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 227 || context.contextNode.kind === 185; + return context.contextNode.kind === 228 || context.contextNode.kind === 186; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 228: - case 198: case 229: - case 231: - case 162: + case 199: + case 230: case 232: - case 243: + case 163: + case 233: case 244: - case 237: - case 240: + case 245: + case 238: + case 241: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 228: - case 232: - case 231: - case 259: + case 229: case 233: - case 220: + case 232: + case 260: + case 234: + case 221: return true; - case 206: { + case 207: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 186 && - blockParent.kind !== 185) { + if (blockParent.kind !== 187 && + blockParent.kind !== 186) { return true; } } @@ -64219,59 +67366,59 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 210: - case 220: - case 213: + case 211: + case 221: case 214: case 215: + case 216: + case 213: + case 224: case 212: - case 223: - case 211: - case 219: - case 259: + case 220: + case 260: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 177; + return context.contextNode.kind === 178; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 180; + return context.contextNode.kind === 181; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 181; + return context.contextNode.kind === 182; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 25; + return context.currentTokenSpan.kind !== 26; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 21; + return context.nextTokenSpan.kind !== 22; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 186; + return context.contextNode.kind === 187; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 248; + return context.contextNode.kind !== 249; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 255; + return context.contextNode.kind === 256; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 252; + return context.nextTokenParent.kind === 253; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 252; + return context.contextNode.kind === 253; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 249; + return context.contextNode.kind === 250; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -64286,42 +67433,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 146; + return node.kind === 147; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 226 && + return context.currentTokenParent.kind === 227 && context.currentTokenParent.getStart(context.sourceFile) === context.currentTokenSpan.pos; }; Rules.IsNotFormatOnEnter = function (context) { return context.formattingRequestKind !== 2; }; Rules.IsModuleDeclContext = function (context) { - return context.contextNode.kind === 232; + return context.contextNode.kind === 233; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 162; + return context.contextNode.kind === 163; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 26 && token.kind !== 28) { + if (token.kind !== 27 && token.kind !== 29) { return false; } switch (parent.kind) { - case 158: - case 183: + case 159: + case 184: + case 231: + case 229: + case 199: case 230: case 228: - case 198: - case 229: - case 227: - case 185: case 186: + case 187: + case 151: case 150: - case 149: - case 154: case 155: - case 180: + case 156: case 181: - case 200: + case 182: + case 201: return true; default: return false; @@ -64332,16 +67479,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 183; + return context.contextNode.kind === 184; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 && context.currentTokenParent.kind === 189; + return context.currentTokenSpan.kind === 105 && context.currentTokenParent.kind === 190; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 196 && context.contextNode.expression !== undefined; + return context.contextNode.kind === 197 && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 202; + return context.contextNode.kind === 203; }; return Rules; }()); @@ -64363,7 +67510,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 141 + 1; + this.mapRowLength = 142 + 1; this.map = new Array(this.mapRowLength * this.mapRowLength); var rulesBucketConstructionStateList = new Array(this.map.length); this.FillRules(rules, rulesBucketConstructionStateList); @@ -64376,7 +67523,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 141 && column <= 141, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 142 && column <= 142, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -64540,7 +67687,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0; token <= 141; token++) { + for (var token = 0; token <= 142; token++) { result.push(token); } return result; @@ -64584,17 +67731,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3])); - TokenRange.Keywords = TokenRange.FromRange(71, 141); - TokenRange.BinaryOperators = TokenRange.FromRange(26, 69); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91, 92, 141, 117, 125]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42, 43, 51, 50]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 70, 18, 20, 16, 98, 93]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70, 18, 98, 93]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70, 19, 21, 93]); + TokenRange.Keywords = TokenRange.FromRange(72, 142); + TokenRange.BinaryOperators = TokenRange.FromRange(27, 70); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([92, 93, 142, 118, 126]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([43, 44, 52, 51]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8, 71, 19, 21, 17, 99, 94]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([71, 19, 99, 94]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([71, 20, 22, 94]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([71, 19, 99, 94]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([71, 20, 22, 94]); TokenRange.Comments = TokenRange.FromTokens([2, 3]); - TokenRange.TypeNames = TokenRange.FromTokens([70, 132, 135, 121, 136, 104, 118]); + TokenRange.TypeNames = TokenRange.FromTokens([71, 133, 136, 122, 137, 105, 119]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -64616,6 +67763,9 @@ var ts; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; + RulesProvider.prototype.getFormatOptions = function () { + return this.options; + }; RulesProvider.prototype.ensureUpToDate = function (options) { if (!this.options || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); @@ -64766,11 +67916,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 24, sourceFile, options, rulesProvider, 3); + return formatOutermostParent(position, 25, sourceFile, options, rulesProvider, 3); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 17, sourceFile, options, rulesProvider, 4); + return formatOutermostParent(position, 18, sourceFile, options, rulesProvider, 4); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -64818,17 +67968,17 @@ var ts; } function isListElement(parent, node) { switch (parent.kind) { - case 228: case 229: + case 230: return ts.rangeContainsRange(parent.members, node); - case 232: - var body = parent.body; - return body && body.kind === 233 && ts.rangeContainsRange(body.statements, node); - case 264: - case 206: case 233: + var body = parent.body; + return body && body.kind === 234 && ts.rangeContainsRange(body.statements, node); + case 265: + case 207: + case 234: return ts.rangeContainsRange(parent.statements, node); - case 259: + case 260: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -64907,12 +68057,17 @@ var ts; } return 0; } + function formatNode(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { + var range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1, function (_) { return false; }, sourceFileLike); + } + formatting.formatNode = formatNode; function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + } + function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var previousRangeHasError; var previousRange; var previousParent; @@ -64927,7 +68082,6 @@ var ts; if (enclosingNode.decorators) { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { @@ -64984,18 +68138,18 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 228: return 74; - case 229: return 108; - case 227: return 88; - case 231: return 231; - case 152: return 124; - case 153: return 134; - case 150: + case 229: return 75; + case 230: return 109; + case 228: return 89; + case 232: return 232; + case 153: return 125; + case 154: return 135; + case 151: if (node.asteriskToken) { - return 38; + return 39; } - case 148: - case 145: + case 149: + case 146: return node.name.kind; } } @@ -65003,9 +68157,9 @@ var ts; return { getIndentationForComment: function (kind, tokenIndentation, container) { switch (kind) { - case 17: - case 21: - case 19: + case 18: + case 22: + case 20: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 ? tokenIndentation : indentation; @@ -65017,26 +68171,26 @@ var ts; } } switch (kind) { - case 16: case 17: case 18: case 19: - case 81: - case 105: - case 56: + case 20: + case 82: + case 106: + case 57: return indentation; - case 40: - case 28: { - if (container.kind === 250 || - container.kind === 251 || - container.kind === 249) { + case 41: + case 29: { + if (container.kind === 251 || + container.kind === 252 || + container.kind === 250) { return indentation; } break; } - case 20: - case 21: { - if (container.kind !== 171) { + case 21: + case 22: { + if (container.kind !== 172) { return indentation; } break; @@ -65124,11 +68278,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 146 ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 147 ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 176 && inheritedIndentation === -1) { + if (isFirstListItem && parent.kind === 177 && inheritedIndentation === -1) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -65444,41 +68598,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 151: - case 227: - case 185: - case 150: - case 149: + case 152: + case 228: case 186: + case 151: + case 150: + case 187: if (node.typeParameters === list) { - return 26; + return 27; } else if (node.parameters === list) { - return 18; + return 19; } break; - case 180: case 181: + case 182: if (node.typeArguments === list) { - return 26; + return 27; } else if (node.arguments === list) { - return 18; + return 19; } break; - case 158: + case 159: if (node.typeArguments === list) { - return 26; + return 27; } } return 0; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 18: - return 19; - case 26: - return 28; + case 19: + return 20; + case 27: + return 29; } return 0; } @@ -65543,7 +68697,8 @@ var ts; (function (Value) { Value[Value["Unknown"] = -1] = "Unknown"; })(Value || (Value = {})); - function getIndentation(position, sourceFile, options) { + function getIndentation(position, sourceFile, options, assumeNewLineBeforeCloseBrace) { + if (assumeNewLineBeforeCloseBrace === void 0) { assumeNewLineBeforeCloseBrace = false; } if (position > sourceFile.text.length) { return getBaseIndentation(options); } @@ -65563,7 +68718,7 @@ var ts; var current_1 = position; while (current_1 > 0) { var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char)) { + if (!ts.isWhiteSpaceLike(char)) { break; } current_1--; @@ -65571,7 +68726,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 && precedingToken.parent.kind !== 193) { + if (precedingToken.kind === 26 && precedingToken.parent.kind !== 194) { var actualIndentation = getActualIndentationForListItemBeforeComma(precedingToken, sourceFile, options); if (actualIndentation !== -1) { return actualIndentation; @@ -65584,8 +68739,9 @@ var ts; while (current) { if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== 0) { + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === 2 ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; @@ -65673,32 +68829,38 @@ var ts; } function getActualIndentationForNode(current, parent, currentLineAndChar, parentAndChildShareLine, sourceFile, options) { var useActualIndentation = (ts.isDeclaration(current) || ts.isStatementButNotDeclaration(current)) && - (parent.kind === 264 || !parentAndChildShareLine); + (parent.kind === 265 || !parentAndChildShareLine); if (!useActualIndentation) { return -1; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } + var NextTokenKind; + (function (NextTokenKind) { + NextTokenKind[NextTokenKind["Unknown"] = 0] = "Unknown"; + NextTokenKind[NextTokenKind["OpenBrace"] = 1] = "OpenBrace"; + NextTokenKind[NextTokenKind["CloseBrace"] = 2] = "CloseBrace"; + })(NextTokenKind || (NextTokenKind = {})); function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current); if (!nextToken) { - return false; + return 0; } - if (nextToken.kind === 16) { - return true; + if (nextToken.kind === 17) { + return 1; } - else if (nextToken.kind === 17) { + else if (nextToken.kind === 18) { var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? 2 : 0; } - return false; + return 0; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 210 && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 81, sourceFile); + if (parent.kind === 211 && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 82, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -65706,53 +68868,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getListIfStartEndIsInListRange(list, start, end) { + return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; + } function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 158: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 177: + case 159: + return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd()); + case 178: return node.parent.properties; - case 176: + case 177: return node.parent.elements; - case 227: - case 185: + case 228: case 186: + case 187: + case 151: case 150: - case 149: - case 154: - case 155: { + case 155: + case 152: + case 161: + case 156: { var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.parameters, start, node.getEnd()); } - case 181: - case 180: { + case 229: + return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), node.getEnd()); + case 182: + case 181: { var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.arguments, start, node.getEnd()); } + case 227: + return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), node.getEnd()); + case 241: + case 245: + return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; } + SmartIndenter.getContainingList = getContainingList; function getActualIndentationForListItem(node, sourceFile, options) { var containingList = getContainingList(node, sourceFile); return containingList ? getActualIndentationFromList(containingList) : -1; @@ -65762,11 +68920,11 @@ var ts; } } function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { - if (node.kind === 19) { + if (node.kind === 20) { return -1; } - if (node.parent && (node.parent.kind === 180 || - node.parent.kind === 181) && + if (node.parent && (node.parent.kind === 181 || + node.parent.kind === 182) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -65784,10 +68942,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 180: case 181: - case 178: + case 182: case 179: + case 180: node = node.expression; break; default: @@ -65801,7 +68959,7 @@ var ts; var node = list[index]; var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 25) { + if (list[i].kind === 26) { continue; } var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line; @@ -65841,49 +68999,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 209: - case 228: - case 198: + case 210: case 229: - case 231: + case 199: case 230: - case 176: - case 206: - case 233: + case 232: + case 231: case 177: - case 162: - case 171: - case 164: - case 234: - case 257: - case 256: - case 184: - case 178: - case 180: - case 181: case 207: - case 225: - case 242: - case 218: - case 194: - case 174: - case 173: - case 250: - case 249: - case 255: - case 149: - case 154: - case 155: - case 145: - case 159: - case 160: - case 167: + case 234: + case 178: + case 163: + case 172: + case 165: + case 235: + case 258: + case 257: + case 185: + case 179: + case 181: case 182: - case 190: - case 244: - case 240: + case 208: + case 226: + case 243: + case 219: + case 195: + case 175: + case 174: + case 251: + case 250: + case 256: + case 150: + case 155: + case 156: + case 146: + case 160: + case 161: + case 168: + case 183: + case 191: case 245: case 241: + case 246: + case 242: return true; } return false; @@ -65891,27 +69049,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0; switch (parent.kind) { - case 211: case 212: - case 214: - case 215: case 213: - case 210: - case 227: - case 185: - case 150: + case 215: + case 216: + case 214: + case 211: + case 228: case 186: case 151: + case 187: case 152: case 153: - return childKind !== 206; - case 243: - return childKind !== 244; - case 237: - return childKind !== 238 || - (child.namedBindings && child.namedBindings.kind !== 240); - case 248: - return childKind !== 251; + case 154: + return childKind !== 207; + case 244: + return childKind !== 245; + case 238: + return childKind !== 239 || + (child.namedBindings && child.namedBindings.kind !== 241); + case 249: + return childKind !== 252; } return indentByDefault; } @@ -65924,6 +69082,499 @@ var ts; })(formatting = ts.formatting || (ts.formatting = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var textChanges; + (function (textChanges) { + function getPos(n) { + return n["__pos"]; + } + function setPos(n, pos) { + n["__pos"] = pos; + } + function getEnd(n) { + return n["__end"]; + } + function setEnd(n, end) { + n["__end"] = end; + } + var Position; + (function (Position) { + Position[Position["FullStart"] = 0] = "FullStart"; + Position[Position["Start"] = 1] = "Start"; + })(Position = textChanges.Position || (textChanges.Position = {})); + function skipWhitespacesAndLineBreaks(text, start) { + return ts.skipTrivia(text, start, false, true); + } + function hasCommentsBeforeLineBreak(text, start) { + var i = start; + while (i < text.length) { + var ch = text.charCodeAt(i); + if (ts.isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === 47; + } + return false; + } + function getSeparatorCharacter(separator) { + return ts.tokenToString(separator.kind); + } + textChanges.getSeparatorCharacter = getSeparatorCharacter; + function getAdjustedStartPosition(sourceFile, node, options, position) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + var fullStart = node.getFullStart(); + var start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + var fullStartLine = ts.getLineStartPositionForPosition(fullStart, sourceFile); + var startLine = ts.getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + return position === Position.Start ? start : fullStart; + } + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); + return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + textChanges.getAdjustedStartPosition = getAdjustedStartPosition; + function getAdjustedEndPosition(sourceFile, node, options) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + var end = node.getEnd(); + var newEnd = ts.skipTrivia(sourceFile.text, end, true); + return newEnd !== end && ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + textChanges.getAdjustedEndPosition = getAdjustedEndPosition; + function isSeparator(node, candidate) { + return candidate && node.parent && (candidate.kind === 26 || (candidate.kind === 25 && node.parent.kind === 178)); + } + function spaces(count) { + var s = ""; + for (var i = 0; i < count; i++) { + s += " "; + } + return s; + } + var ChangeTracker = (function () { + function ChangeTracker(newLine, rulesProvider, validator) { + this.newLine = newLine; + this.rulesProvider = rulesProvider; + this.validator = validator; + this.changes = []; + this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); + } + ChangeTracker.fromCodeFixContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 : 0, context.rulesProvider); + }; + ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ sourceFile: sourceFile, range: range }); + return this; + }; + ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { + var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + var nextToken = ts.getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), false, true); + var nextElement = containingList[index + 1]; + var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), false, true); + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + }; + ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + return this; + }; + ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + return this; + }; + ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { + if (options === void 0) { options = {}; } + if ((ts.isStatementButNotDeclaration(after)) || + after.kind === 149 || + after.kind === 148 || + after.kind === 150) { + if (sourceFile.text.charCodeAt(after.end - 1) !== 59) { + this.changes.push({ + sourceFile: sourceFile, + options: {}, + range: { pos: after.end, end: after.end }, + node: ts.createToken(25) + }); + } + } + var endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeInListAfter = function (sourceFile, after, newNode) { + var containingList = ts.formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(after); + if (index < 0) { + return this; + } + var end = after.getEnd(); + if (index !== containingList.length - 1) { + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); + var prefix = void 0; + var startPos = void 0; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix: prefix, + suffix: "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)) + } + }); + } + } + else { + var afterStart = after.getStart(sourceFile); + var afterStartLinePosition = ts.getLineStartPositionForPosition(afterStart, sourceFile); + var separator = void 0; + var multilineList = false; + if (containingList.length === 1) { + separator = 26; + } + else { + var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 26; + var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + multilineList = true; + } + if (multilineList) { + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: ts.createToken(separator), + options: {} + }); + var indentation = ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + var insertPos = ts.skipTrivia(sourceFile.text, end, true, false); + if (insertPos !== end && ts.isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos--; + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation: indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: newNode, + options: { prefix: ts.tokenToString(separator) + " " } + }); + } + } + return this; + }; + ChangeTracker.prototype.getChanges = function () { + var _this = this; + var changesPerFile = ts.createFileMap(); + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var c = _a[_i]; + var changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + } + changesInFile.push(c); + } + var fileChangesList = []; + changesPerFile.forEachValue(function (path) { + var changesInFile = changesPerFile.get(path); + var sourceFile = changesInFile[0].sourceFile; + var fileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (var _i = 0, _a = ChangeTracker.normalize(changesInFile); _i < _a.length; _i++) { + var c = _a[_i]; + fileTextChanges.textChanges.push({ + span: _this.computeSpan(c, sourceFile), + newText: _this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + return fileChangesList; + }; + ChangeTracker.prototype.computeSpan = function (change, _sourceFile) { + return ts.createTextSpanFromBounds(change.range.pos, change.range.end); + }; + ChangeTracker.prototype.computeNewText = function (change, sourceFile) { + if (!change.node) { + return ""; + } + var options = change.options || {}; + var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var pos = change.range.pos; + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = change.options.indentation !== undefined + ? change.options.indentation + : change.useIndentationFromFile + ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) + : 0; + var delta = change.options.delta !== undefined + ? change.options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); + }; + ChangeTracker.normalize = function (changes) { + var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); + for (var i = 0; i < normalized.length - 2; i++) { + ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); + } + return normalized; + }; + return ChangeTracker; + }()); + textChanges.ChangeTracker = ChangeTracker; + function getNonformattedText(node, sourceFile, newLine) { + var options = { newLine: newLine, target: sourceFile.languageVersion }; + var writer = new Writer(ts.getNewLineCharacter(options)); + var printer = ts.createPrinter(options, writer); + printer.writeNode(3, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + textChanges.getNonformattedText = getNonformattedText; + function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { + var lineMap = ts.computeLineStarts(nonFormattedText.text); + var file = { + text: nonFormattedText.text, + lineMap: lineMap, + getLineAndCharacterOfPosition: function (pos) { return ts.computeLineAndCharacterOfPosition(lineMap, pos); } + }; + var changes = ts.formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + textChanges.applyFormatting = applyFormatting; + function applyChanges(text, changes) { + for (var i = changes.length - 1; i >= 0; i--) { + var change = changes[i]; + text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + } + return text; + } + textChanges.applyChanges = applyChanges; + function isTrivia(s) { + return ts.skipTrivia(s, 0) === s.length; + } + var nullTransformationContext = { + enableEmitNotification: ts.noop, + enableSubstitution: ts.noop, + endLexicalEnvironment: function () { return undefined; }, + getCompilerOptions: ts.notImplemented, + getEmitHost: ts.notImplemented, + getEmitResolver: ts.notImplemented, + hoistFunctionDeclaration: ts.noop, + hoistVariableDeclaration: ts.noop, + isEmitNotificationEnabled: ts.notImplemented, + isSubstitutionEnabled: ts.notImplemented, + onEmitNode: ts.noop, + onSubstituteNode: ts.notImplemented, + readEmitHelpers: ts.notImplemented, + requestEmitHelper: ts.noop, + resumeLexicalEnvironment: ts.noop, + startLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop + }; + function assignPositionsToNode(node) { + var visited = ts.visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + var newNode = ts.nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new Proxy()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + function Proxy() { } + } + function assignPositionsToNodeArray(nodes, visitor, test, start, count) { + var visited = ts.visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + var nodeArray = visited === nodes ? ts.createNodeArray(visited.slice(0)) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + var Writer = (function () { + function Writer(newLine) { + var _this = this; + this.lastNonTriviaPosition = 0; + this.writer = ts.createTextWriter(newLine); + this.onEmitNode = function (hint, node, printCallback) { + if (node) { + setPos(node, _this.lastNonTriviaPosition); + } + printCallback(hint, node); + if (node) { + setEnd(node, _this.lastNonTriviaPosition); + } + }; + this.onBeforeEmitNodeArray = function (nodes) { + if (nodes) { + setPos(nodes, _this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = function (nodes) { + if (nodes) { + setEnd(nodes, _this.lastNonTriviaPosition); + } + }; + } + Writer.prototype.setLastNonTriviaPosition = function (s, force) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + var i = 0; + while (ts.isWhiteSpaceLike(s.charCodeAt(s.length - i - 1))) { + i++; + } + this.lastNonTriviaPosition -= i; + } + }; + Writer.prototype.write = function (s) { + this.writer.write(s); + this.setLastNonTriviaPosition(s, false); + }; + Writer.prototype.writeTextOfNode = function (text, node) { + this.writer.writeTextOfNode(text, node); + }; + Writer.prototype.writeLine = function () { + this.writer.writeLine(); + }; + Writer.prototype.increaseIndent = function () { + this.writer.increaseIndent(); + }; + Writer.prototype.decreaseIndent = function () { + this.writer.decreaseIndent(); + }; + Writer.prototype.getText = function () { + return this.writer.getText(); + }; + Writer.prototype.rawWrite = function (s) { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, false); + }; + Writer.prototype.writeLiteral = function (s) { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, true); + }; + Writer.prototype.getTextPos = function () { + return this.writer.getTextPos(); + }; + Writer.prototype.getLine = function () { + return this.writer.getLine(); + }; + Writer.prototype.getColumn = function () { + return this.writer.getColumn(); + }; + Writer.prototype.getIndent = function () { + return this.writer.getIndent(); + }; + Writer.prototype.isAtStartOfLine = function () { + return this.writer.isAtStartOfLine(); + }; + Writer.prototype.reset = function () { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + }; + return Writer; + }()); + })(textChanges = ts.textChanges || (ts.textChanges = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -65970,53 +69621,46 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); - var classDecl = ts.getContainingClass(token); - if (!classDecl) { + var classDeclaration = ts.getContainingClass(token); + if (!classDeclaration) { return undefined; } - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var classType = checker.getTypeAtLocation(classDeclaration); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDeclaration); var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1); var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0); var result = []; for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { var implementedTypeNode = implementedTypeNodes_2[_i]; - var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); + var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8); }); - var insertion = getMissingIndexSignatureInsertion(implementedType, 1, classDecl, hasNumericIndexSignature); - insertion += getMissingIndexSignatureInsertion(implementedType, 0, classDecl, hasStringIndexSignature); - insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var newNodes = []; + createAndAddMissingIndexSignatureDeclaration(implementedType, 1, hasNumericIndexSignature, newNodes); + createAndAddMissingIndexSignatureDeclaration(implementedType, 0, hasStringIndexSignature, newNodes); + newNodes = newNodes.concat(codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker)); var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); - if (insertion) { - pushAction(result, insertion, message); + if (newNodes.length > 0) { + pushAction(result, newNodes, message); } } return result; - function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { - if (!hasIndexSigOfKind) { - var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); - if (IndexInfoOfKind) { - var writer = ts.getSingleLineStringWriter(); - checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_6 = writer.string(); - ts.releaseStringWriter(writer); - return result_6; - } + function createAndAddMissingIndexSignatureDeclaration(type, kind, hasIndexSigOfKind, newNodes) { + if (hasIndexSigOfKind) { + return; } - return ""; + var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (!indexInfoOfKind) { + return; + } + var newIndexSignatureDeclaration = checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration); + newNodes.push(newIndexSignatureDeclaration); } - function pushAction(result, insertion, description) { + function pushAction(result, newNodes, description) { var newAction = { description: description, - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: codefix.newNodesToChanges(newNodes, openBrace, context) }; result.push(newAction); } @@ -66024,6 +69668,102 @@ var ts; })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Property_0_does_not_exist_on_type_1.code], + getCodeActions: getActionsForAddMissingMember + }); + function getActionsForAddMissingMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind !== 71) { + return undefined; + } + if (!ts.isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== 99) { + return undefined; + } + var classMemberDeclaration = ts.getThisContainer(token, false); + if (!ts.isClassElement(classMemberDeclaration)) { + return undefined; + } + var classDeclaration = classMemberDeclaration.parent; + if (!classDeclaration || !ts.isClassLike(classDeclaration)) { + return undefined; + } + var isStatic = ts.hasModifier(classMemberDeclaration, 32); + return ts.isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + function getActionsForAddMissingMemberInJavaScriptFile() { + var memberName = token.getText(); + if (isStatic) { + if (classDeclaration.kind === 199) { + return undefined; + } + var className = classDeclaration.name.getText(); + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classDeclaration.getEnd(), length: 0 }, + newText: "" + context.newLineCharacter + className + "." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + else { + var classConstructor = ts.getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classConstructor.body.getEnd() - 1, length: 0 }, + newText: "this." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + } + function getActionsForAddMissingMemberInTypeScriptFile() { + var typeNode; + if (token.parent.parent.kind === 194) { + var binaryExpression = token.parent.parent; + var checker = context.program.getTypeChecker(); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + } + typeNode = typeNode || ts.createKeywordTypeNode(119); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var property = ts.createProperty(undefined, isStatic ? [ts.createToken(115)] : undefined, token.getText(sourceFile), undefined, typeNode, undefined); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); + var actions = [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: propertyChangeTracker.getChanges() + }]; + if (!isStatic) { + var stringTypeNode = ts.createKeywordTypeNode(136); + var indexingParameter = ts.createParameter(undefined, undefined, undefined, "x", undefined, stringTypeNode, undefined); + var indexSignature = ts.createIndexSignatureDeclaration(undefined, undefined, [indexingParameter], typeNode); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); + actions.push({ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: indexSignatureChangeTracker.getChanges() + }); + } + return actions; + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; (function (ts) { var codefix; (function (codefix) { @@ -66041,23 +69781,17 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); if (ts.isClassLike(token.parent)) { - var classDecl = token.parent; - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var classDeclaration = token.parent; + var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); - var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); - if (insertion.length) { + var newNodes = codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); + var changes = codefix.newNodesToChanges(newNodes, ts.getOpenBraceOfClassLike(classDeclaration, sourceFile), context); + if (changes && changes.length > 0) { return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: changes }]; } } @@ -66080,7 +69814,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 98) { + if (token.kind !== 99) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -66088,7 +69822,7 @@ var ts; if (!superCall) { return undefined; } - if (superCall.expression && superCall.expression.kind == 180) { + if (superCall.expression && superCall.expression.kind === 181) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -66096,23 +69830,15 @@ var ts; } } } - var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); - var changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes: changes + changes: changeTracker.getChanges() }]; function findSuperCall(n) { - if (n.kind === 209 && ts.isSuperCall(n.expression)) { + if (n.kind === 210 && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -66133,13 +69859,15 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122) { + if (token.kind !== 123) { return undefined; } - var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var superCall = ts.createStatement(ts.createCall(ts.createSuper(), undefined, ts.emptyArray)); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -66156,7 +69884,7 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var classDeclNode = ts.getContainingClass(token); - if (!(token.kind === 70 && ts.isClassLike(classDeclNode))) { + if (!(token.kind === 71 && ts.isClassLike(classDeclNode))) { return undefined; } var heritageClauses = classDeclNode.heritageClauses; @@ -66164,26 +69892,20 @@ var ts; return undefined; } var extendsToken = heritageClauses[0].getFirstToken(); - if (!(extendsToken && extendsToken.kind === 84)) { + if (!(extendsToken && extendsToken.kind === 85)) { return undefined; } - var changeStart = extendsToken.getStart(sourceFile); - var changeEnd = extendsToken.getEnd(); - var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108)); for (var i = 1; i < heritageClauses.length; i++) { var keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, ts.createToken(26)); } } var result = [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; } @@ -66199,10 +69921,14 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - var start = token.getStart(sourceFile); + if (token.kind !== 71) { + return undefined; + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -66221,156 +69947,147 @@ var ts; var sourceFile = context.sourceFile; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); - if (token.kind === 20) { + if (token.kind === 21) { token = ts.getTokenAtPosition(sourceFile, start + 1); } switch (token.kind) { - case 70: + case 71: switch (token.parent.kind) { - case 225: + case 226: switch (token.parent.parent.parent.kind) { - case 213: + case 214: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } - case 215: + case 216: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 226) { + if (forOfStatement.initializer.kind === 227) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], ts.createObjectLiteral()); } break; - case 214: + case 215: return undefined; - case 259: + case 260: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } - case 144: + case 145: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== 27) { + return deleteRange(typeParameters); + } + var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== 29) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } - case 145: + case 146: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } - case 236: - var importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); - case 241: + case 237: + var importEquals = ts.getAncestor(token, 237); + return deleteNode(importEquals); + case 242: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { - var importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + var importSpec = ts.getAncestor(token, 238); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); - } - case 238: - var importClause = token.parent; - if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); - } - else { - var start_4 = importClause.name.getStart(); - var end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === 44) { - end = findFirstNonSpaceCharPosStarting(end + 1); - } - return createCodeFix("", start_4, end - start_4); + return deleteNodeInList(token.parent); } case 239: - var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + var importClause = token.parent; + if (!importClause.namedBindings) { + var importDecl = ts.getAncestor(importClause, 238); + return deleteNode(importDecl); } else { - var start_5 = namespaceImport.parent.name.end; - return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + var start_4 = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26) { + return deleteRange({ pos: start_4, end: ts.skipTrivia(sourceFile.text, nextToken.end, false, true) }); + } + else { + return deleteNode(importClause.name); + } + } + case 240: + var namespaceImport = token.parent; + if (namespaceImport.name === token && !namespaceImport.parent.name) { + var importDecl = ts.getAncestor(namespaceImport, 238); + return deleteNode(importDecl); + } + else { + var previousToken = ts.getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === 26) { + var startPosition = ts.textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, ts.textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; - case 148: - case 239: - return createCodeFixToRemoveNode(token.parent); + case 149: + case 240: + return deleteNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 237 && importDecl.parent) { - importDecl = importDecl.parent; - } - return importDecl; + function deleteNode(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node) { - var end = node.getEnd(); - var endCharCode = sourceFile.text.charCodeAt(end); - var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (ts.isLineBreak(endCharCode)) { - end += 1; - } - if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - var start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start) { - while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText, start, length) { + function deleteNodeRange(start, end) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + function replaceNode(n, newNode) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + function makeChange(changeTracker) { return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] + changes: changeTracker.getChanges() }]; } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); })(codefix = ts.codefix || (ts.codefix = {})); @@ -66476,21 +70193,21 @@ var ts; var name = token.getText(); var symbolIdActionMap = new ImportCodeActionMap(); var cachedImportDeclarations = []; - var cachedNewImportInsertPosition; + var lastImportDeclaration; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); return getCodeActionForImport(symbol, false, true); } - var allPotentialModules = checker.getAmbientModules(); + var candidateModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; if (otherSourceFile !== sourceFile && ts.isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { - var moduleSymbol = allPotentialModules_1[_a]; + for (var _a = 0, candidateModules_1 = candidateModules; _a < candidateModules_1.length; _a++) { + var moduleSymbol = candidateModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); var defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); if (defaultExport) { @@ -66526,10 +70243,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 237) { + if (node.kind === 238) { return node; } - if (node.kind === 236) { + if (node.kind === 237) { return node; } node = node.parent; @@ -66562,9 +70279,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { var declaration = declarations_14[_i]; - if (declaration.kind === 237) { + if (declaration.kind === 238) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 239) { + if (namedBindings && namedBindings.kind === 240) { namespaceImportDeclaration = declaration; } else { @@ -66582,81 +70299,67 @@ var ts; } if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { - var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + var fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); - actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], textChange.newText, textChange.span, sourceFile.fileName, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); + actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); } else { actions.push(getCodeActionForNewImport(existingModuleSpecifier)); } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 247) { + if (declaration.moduleReference && declaration.moduleReference.kind === 248) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); } function getTextChangeForImportClause(importClause) { - var newImportText = isDefault ? "default as " + name : name; var importList = importClause.namedBindings; - if (!importList && importClause.name) { - var start = importClause.name.getEnd(); - return { - newText: ", { " + newImportText + " }", - span: { start: start, length: 0 } - }; + var newImportSpecifier = ts.createImportSpecifier(undefined, ts.createIdentifier(name)); + if (!importList || importList.elements.length === 0) { + var newImportClause = ts.createImportClause(importClause.name, ts.createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - if (importList.elements.length === 0) { - var start = importList.getStart(); - return { - newText: "{ " + newImportText + " }", - span: { start: start, length: importList.getEnd() - start } - }; - } - var insertPoint = importList.elements[importList.elements.length - 1].getEnd(); - var startLine = ts.getLineOfLocalPosition(sourceFile, importList.getStart()); - var endLine = ts.getLineOfLocalPosition(sourceFile, importList.getEnd()); - var oneImportPerLine = endLine - startLine > importList.elements.length; - return { - newText: "," + (oneImportPerLine ? context.newLineCharacter : " ") + newImportText, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter(sourceFile, importList.elements[importList.elements.length - 1], newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 237) { + if (declaration.kind === 238) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { namespacePrefix = declaration.name.getText(); } namespacePrefix = ts.stripQuotes(namespacePrefix); - return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], namespacePrefix + ".", { start: token.getStart(), length: 0 }, sourceFile.fileName, "CodeChange"); + return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], createChangeTracker().replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange"); } } function getCodeActionForNewImport(moduleSpecifier) { - if (!cachedNewImportInsertPosition) { - var lastModuleSpecifierEnd = -1; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var moduleSpecifier_1 = _a[_i]; - var end = moduleSpecifier_1.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + if (!lastImportDeclaration) { + for (var i = sourceFile.statements.length - 1; i >= 0; i--) { + var statement = sourceFile.statements[i]; + if (statement.kind === 237 || statement.kind === 238) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - var importStatementText = isDefault - ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + var changeTracker = createChangeTracker(); + var importClause = isDefault + ? ts.createImportClause(ts.createIdentifier(name), undefined) : isNamespaceImport - ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; - var newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter - : "" + context.newLineCharacter + importStatementText + ";"; - return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); + ? ts.createImportClause(undefined, ts.createNamespaceImport(ts.createIdentifier(name))) + : ts.createImportClause(undefined, ts.createNamedImports([ts.createImportSpecifier(undefined, ts.createIdentifier(name))])); + var importDecl = ts.createImportDeclaration(undefined, undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } + return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -66669,7 +70372,7 @@ var ts; tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 264) { + if (moduleSymbol.valueDeclaration.kind !== 265) { return moduleSymbol.name; } } @@ -66798,10 +70501,13 @@ var ts; } } } - function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { + function createChangeTracker() { + return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + } + function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { description: ts.formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName: fileName, textChanges: [{ newText: newText, span: span }] }], + changes: changes, kind: kind, moduleSpecifier: moduleSpecifier }; @@ -66814,128 +70520,227 @@ var ts; (function (ts) { var codefix; (function (codefix) { - function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + codefix.registerCodeFix({ + errorCodes: getApplicableDiagnosticCodes(), + getCodeActions: getDisableJsDiagnosticsCodeActions + }); + function getApplicableDiagnosticCodes() { + var allDiagnostcs = ts.Diagnostics; + return Object.keys(allDiagnostcs) + .filter(function (d) { return allDiagnostcs[d] && allDiagnostcs[d].category === ts.DiagnosticCategory.Error; }) + .map(function (d) { return allDiagnostcs[d].code; }); + } + function getIgnoreCommentLocationForLocation(sourceFile, position, newLineCharacter) { + var line = ts.getLineAndCharacterOfPosition(sourceFile, position).line; + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var startPosition = ts.getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + if (!ts.isInComment(sourceFile, startPosition) && !ts.isInString(sourceFile, startPosition) && !ts.isInTemplateString(sourceFile, startPosition)) { + var token = ts.getTouchingToken(sourceFile, startPosition); + var tokenLeadingCommnets = ts.getLeadingCommentRangesOfNode(token, sourceFile); + if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { + return { + span: { start: startPosition, length: 0 }, + newText: "// @ts-ignore" + newLineCharacter + }; + } + } + return { + span: { start: position, length: 0 }, + newText: (position === startPosition ? "" : newLineCharacter) + "// @ts-ignore" + newLineCharacter + }; + } + function getDisableJsDiagnosticsCodeActions(context) { + var sourceFile = context.sourceFile, program = context.program, newLineCharacter = context.newLineCharacter, span = context.span; + if (!ts.isInJavaScriptFile(sourceFile) || !ts.isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { + return undefined; + } + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Ignore_this_error_message), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + }] + }, + { + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Disable_checking_for_this_file), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { + start: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.pos : 0, + length: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.end - sourceFile.checkJsDirective.pos : 0 + }, + newText: "// @ts-nocheck" + newLineCharacter + }] + }] + }]; + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function newNodesToChanges(newNodes, insertAfter, context) { + var sourceFile = context.sourceFile; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { + var newNode = newNodes_1[_i]; + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); + } + var changes = changeTracker.getChanges(); + if (!ts.some(changes)) { + return changes; + } + ts.Debug.assert(changes.length === 1); + var consolidatedChanges = [{ + fileName: changes[0].fileName, + textChanges: [{ + span: changes[0].textChanges[0].span, + newText: changes[0].textChanges.reduce(function (prev, cur) { return prev + cur.newText; }, "") + }] + }]; + return consolidatedChanges; + } + codefix.newNodesToChanges = newNodesToChanges; + function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, checker) { var classMembers = classDeclaration.symbol.members; var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); - var insertion = ""; + var newNodes = []; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; - insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + var newNode = createNewNodeForMemberSymbol(symbol, classDeclaration, checker); + if (newNode) { + if (Array.isArray(newNode)) { + newNodes = newNodes.concat(newNode); + } + else { + newNodes.push(newNode); + } + } } - return insertion; + return newNodes; } - codefix.getMissingMembersInsertion = getMissingMembersInsertion; - function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { - var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + codefix.createMissingMemberNodes = createMissingMemberNodes; + function createNewNodeForMemberSymbol(symbol, enclosingDeclaration, checker) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { - return ""; + return undefined; } var declaration = declarations[0]; - var name = declaration.name ? declaration.name.getText() : undefined; - var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + var name = ts.getSynthesizedClone(declaration.name); + var visibilityModifier = createVisibilityModifier(ts.getModifierFlags(declaration)); + var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; + var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); + var optional = !!(symbol.flags & 67108864); switch (declaration.kind) { - case 152: case 153: - case 147: + case 154: case 148: - var typeString = checker.typeToString(type, enclosingDeclaration, 0); - return "" + visibility + name + ": " + typeString + ";" + newlineChar; case 149: + var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); + var property = ts.createProperty(undefined, modifiers, name, optional ? ts.createToken(55) : undefined, typeNode, undefined); + return property; case 150: + case 151: var signatures = checker.getSignaturesOfType(type, 0); - if (!(signatures && signatures.length > 0)) { - return ""; + if (!ts.some(signatures)) { + return undefined; } if (declarations.length === 1) { ts.Debug.assert(signatures.length === 1); - var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048, 0); - return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + var signature = signatures[0]; + return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - var result = ""; + var signatureDeclarations = []; for (var i = 0; i < signatures.length; i++) { - var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048, 0); - result += "" + visibility + name + sigString_2 + ";" + newlineChar; + var signature = signatures[i]; + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } - var bodySig = undefined; if (declarations.length > signatures.length) { - bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } else { ts.Debug.assert(declarations.length === signatures.length); - bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + var methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, optional, modifiers); + signatureDeclarations.push(methodImplementingSignatures); } - var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048, 0); - result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); - return result; + return signatureDeclarations; default: - return ""; + return undefined; + } + function signatureToMethodDeclaration(signature, enclosingDeclaration, body) { + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 151, enclosingDeclaration); + if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? ts.createToken(55) : undefined; + signatureDeclaration.body = body; + } + return signatureDeclaration; } } - function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(154); - newSignatureDeclaration.parent = enclosingDeclaration; - newSignatureDeclaration.name = signatures[0].getDeclaration().name; - var maxNonRestArgs = -1; - var maxArgsIndex = 0; + function createMethodImplementingSignatures(signatures, name, optional, modifiers) { + var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; - var hasRestParameter = false; + var someSigHasRestParameter = false; for (var i = 0; i < signatures.length; i++) { var sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - hasRestParameter = hasRestParameter || sig.hasRestParameter; - var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength > maxNonRestArgs) { - maxNonRestArgs = nonRestLength; - maxArgsIndex = i; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + maxArgsSignature = sig; } } - var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); - var optionalToken = ts.createToken(54); - newSignatureDeclaration.parameters = ts.createNodeArray(); + var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.getName(); }); + var parameters = []; for (var i = 0; i < maxNonRestArgs; i++) { - var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); - newSignatureDeclaration.parameters.push(newParameter); + var anyType = ts.createKeywordTypeNode(119); + var newParameter = ts.createParameter(undefined, undefined, undefined, maxArgsParameterSymbolNames[i], i >= minArgumentCount ? ts.createToken(55) : undefined, anyType, undefined); + parameters.push(newParameter); } - if (hasRestParameter) { - var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); - restParameter.dotDotDotToken = ts.createToken(23); - newSignatureDeclaration.parameters.push(restParameter); - } - return checker.getSignatureFromDeclaration(newSignatureDeclaration); - function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(145); - newParameter.symbol = new SymbolConstructor(1, maxArgsParameterSymbolNames[index] || "rest"); - newParameter.symbol.valueDeclaration = newParameter; - newParameter.symbol.declarations = [newParameter]; - newParameter.parent = enclosingSignatureDeclaration; - if (index >= minArgCount) { - newParameter.questionToken = optionalToken; - } - return newParameter; + if (someSigHasRestParameter) { + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119)); + var restParameter = ts.createParameter(undefined, undefined, ts.createToken(24), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", maxNonRestArgs >= minArgumentCount ? ts.createToken(55) : undefined, anyArrayType, undefined); + parameters.push(restParameter); } + return createStubbedMethod(modifiers, name, optional, undefined, parameters, undefined); } - function getMethodBodyStub(newLineChar) { - return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType) { + return ts.createMethodDeclaration(undefined, modifiers, undefined, name, optional ? ts.createToken(55) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody()); } - function getVisibilityPrefix(flags) { + codefix.createStubbedMethod = createStubbedMethod; + function createStubbedMethodBody() { + return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), undefined, [ts.createLiteral("Method not implemented.")]))], true); + } + function createVisibilityModifier(flags) { if (flags & 4) { - return "public "; + return ts.createToken(114); } else if (flags & 16) { - return "protected "; + return ts.createToken(113); } - return ""; + return undefined; } - var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); var ts; (function (ts) { ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 142 ? new NodeObject(kind, pos, end) : - kind === 70 ? new IdentifierObject(70, pos, end) : + var node = kind >= 143 ? new NodeObject(kind, pos, end) : + kind === 71 ? new IdentifierObject(71, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -66992,11 +70797,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(296, nodes.pos, nodes.end, this); + var list = createNode(294, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { - var node = nodes_7[_i]; + for (var _i = 0, nodes_9 = nodes; _i < nodes_9.length; _i++) { + var node = nodes_9[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -67011,11 +70816,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 142) { + if (this.kind >= 143) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 282 && this.kind <= 295; + var useJSDocScanner_1 = this.kind >= 283 && this.kind <= 293; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -67068,8 +70873,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 266 || kid.kind > 295; }); - return child.kind < 142 ? + var child = ts.find(children, function (kid) { return kid.kind < 267 || kid.kind > 293; }); + return child.kind < 143 ? child : child.getFirstToken(sourceFile); }; @@ -67079,7 +70884,10 @@ var ts; if (!child) { return undefined; } - return child.kind < 142 ? child : child.getLastToken(sourceFile); + return child.kind < 143 ? child : child.getLastToken(sourceFile); + }; + NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { + return ts.forEachChild(this, cbNode, cbNodeArray); }; return NodeObject; }()); @@ -67132,6 +70940,9 @@ var ts; TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; + TokenOrIdentifierObject.prototype.forEachChild = function () { + return undefined; + }; return TokenOrIdentifierObject; }()); var SymbolObject = (function () { @@ -67154,6 +70965,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -67172,7 +70989,7 @@ var ts; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 70; + IdentifierObject.prototype.kind = 71; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -67237,6 +71054,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -67298,9 +71121,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 143) { + if (declaration.name.kind === 144) { var expr = declaration.name.expression; - if (expr.kind === 178) { + if (expr.kind === 179) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -67310,7 +71133,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 || + if (node.kind === 71 || node.kind === 9 || node.kind === 8) { return node.text; @@ -67320,10 +71143,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 227: - case 185: + case 228: + case 186: + case 151: case 150: - case 149: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -67340,30 +71163,30 @@ var ts; } ts.forEachChild(node, visit); break; - case 228: - case 198: case 229: + case 199: case 230: case 231: case 232: - case 236: - case 245: - case 241: - case 236: - case 238: + case 233: + case 237: + case 246: + case 242: + case 237: case 239: - case 152: + case 240: case 153: - case 162: + case 154: + case 163: addDeclaration(node); ts.forEachChild(node, visit); break; - case 145: + case 146: if (!ts.hasModifier(node, 92)) { break; } - case 225: - case 175: { + case 226: + case 176: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -67372,24 +71195,24 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 263: + case 264: + case 149: case 148: - case 147: addDeclaration(node); break; - case 243: + case 244: if (node.exportClause) { ts.forEach(node.exportClause.elements, visit); } break; - case 237: + case 238: var importClause = node.importClause; if (importClause) { if (importClause.name) { addDeclaration(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239) { + if (importClause.namedBindings.kind === 240) { addDeclaration(importClause.namedBindings); } else { @@ -67615,6 +71438,30 @@ var ts; }; return CancellationTokenObject; }()); + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken, throttleWaitMilliseconds) { + if (throttleWaitMilliseconds === void 0) { throttleWaitMilliseconds = 20; } + this.hostCancellationToken = hostCancellationToken; + this.throttleWaitMilliseconds = throttleWaitMilliseconds; + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return ThrottledCancellationToken; + }()); + ts.ThrottledCancellationToken = ThrottledCancellationToken; function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -67831,12 +71678,12 @@ var ts; var symbol = typeChecker.getSymbolAtLocation(node); if (!symbol || typeChecker.isUnknownSymbol(symbol)) { switch (node.kind) { - case 70: - case 178: - case 142: - case 98: - case 168: - case 96: + case 71: + case 179: + case 143: + case 99: + case 169: + case 97: var type = typeChecker.getTypeAtLocation(node); if (type) { return { @@ -67844,7 +71691,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -67856,21 +71704,22 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } function getDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } - function getImplementationAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); - } function getTypeDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); } + function getImplementationAtPosition(fileName, position) { + synchronizeHostData(); + return ts.FindAllReferences.getImplementationsAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); + } function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { @@ -67886,7 +71735,6 @@ var ts; return ts.DocumentHighlights.getDocumentHighlights(program.getTypeChecker(), cancellationToken, sourceFile, position, sourceFilesToSearch); } function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); function convertDocumentHighlights(documentHighlights) { if (!documentHighlights) { @@ -67901,7 +71749,8 @@ var ts; fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, - isDefinition: false + isDefinition: false, + isInString: highlightSpan.isInString, }); } } @@ -67909,20 +71758,18 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, true); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position); + } + function getReferences(fileName, position, options) { + synchronizeHostData(); + return ts.FindAllReferences.findReferencedEntries(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, false, false, false); - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { synchronizeHostData(); @@ -67940,7 +71787,8 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); + var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -67964,16 +71812,16 @@ var ts; return; } switch (node.kind) { - case 178: - case 142: + case 179: + case 143: case 9: - case 85: - case 100: - case 94: - case 96: - case 98: - case 168: - case 70: + case 86: + case 101: + case 95: + case 97: + case 99: + case 169: + case 71: break; default: return; @@ -67984,7 +71832,7 @@ var ts; nodeForStartPos = nodeForStartPos.parent; } else if (ts.isNameOfModuleDeclaration(nodeForStartPos)) { - if (nodeForStartPos.parent.parent.kind === 232 && + if (nodeForStartPos.parent.parent.kind === 233 && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { nodeForStartPos = nodeForStartPos.parent.parent.name; } @@ -68003,10 +71851,10 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName) { - return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName) { var kind = ts.getScriptKind(fileName, host); @@ -68034,7 +71882,7 @@ var ts; } function getOutliningSpans(fileName) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); + return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -68064,14 +71912,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 16: return 17; - case 18: return 19; - case 20: return 21; - case 26: return 28; - case 17: return 16; - case 19: return 18; - case 21: return 20; - case 28: return 26; + case 17: return 18; + case 19: return 20; + case 21: return 22; + case 27: return 29; + case 18: return 17; + case 20: return 19; + case 22: return 21; + case 29: return 27; } return undefined; } @@ -68110,7 +71958,7 @@ var ts; } return []; } - function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = { start: start, length: end - start }; @@ -68125,7 +71973,8 @@ var ts; program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; var fixes = ts.codefix.getFixes(context); if (fixes) { @@ -68276,13 +72125,13 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 70: + case 71: setNameTable(node.text, node); break; case 9: case 8: if (ts.isDeclarationName(node) || - node.parent.kind === 247 || + node.parent.kind === 248 || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { setNameTable(node.text, node); @@ -68304,13 +72153,13 @@ var ts; } function isObjectLiteralElement(node) { switch (node.kind) { - case 252: - case 254: - case 260: + case 253: + case 255: case 261: - case 150: - case 152: + case 262: + case 151: case 153: + case 154: return true; } return false; @@ -68319,12 +72168,12 @@ var ts; switch (node.kind) { case 9: case 8: - if (node.parent.kind === 143) { + if (node.parent.kind === 144) { return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } - case 70: + case 71: return isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 177 || node.parent.parent.kind === 253) && + (node.parent.parent.kind === 178 || node.parent.parent.kind === 254) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -68357,7 +72206,7 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 179 && + node.parent.kind === 180 && node.parent.argumentExpression === node; } function getDefaultLibFilePath(options) { @@ -68377,11 +72226,13 @@ var ts; server.ActionInvalidate = "action::invalidate"; server.EventBeginInstallTypes = "event::beginInstallTypes"; server.EventEndInstallTypes = "event::endInstallTypes"; + server.EventInitializationFailed = "event::initializationFailed"; var Arguments; (function (Arguments) { Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; Arguments.LogFile = "--logFile"; Arguments.EnableTelemetry = "--enableTelemetry"; + Arguments.TypingSafeListLocation = "--typingSafeListLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; @@ -68571,7 +72422,7 @@ var ts; this.logger = logger; } GcTimer.prototype.scheduleCollect = function () { - if (!this.host.gc || this.timerId != undefined) { + if (!this.host.gc || this.timerId !== undefined) { return; } this.timerId = this.host.setTimeout(GcTimer.run, this.delay, this); @@ -68605,12 +72456,11 @@ var ts; var nanoseconds = time[1]; return ((1e9 * seconds) + nanoseconds) / 1000000.0; } - function shouldSkipSematicCheck(project) { - if (project.getCompilerOptions().skipLibCheck !== undefined) { - return false; - } - if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && project.isJsOnlyProject()) { - return true; + function isDeclarationFileInJSOnlyNonConfiguredProject(project, file) { + if ((project.projectKind === server.ProjectKind.Inferred || project.projectKind === server.ProjectKind.External) && + project.isJsOnlyProject()) { + var scriptInfo = project.getScriptInfoForNormalizedPath(file); + return scriptInfo && !scriptInfo.isJavaScript(); } return false; } @@ -68621,7 +72471,7 @@ var ts; if (a.file < b.file) { return -1; } - else if (a.file == b.file) { + else if (a.file === b.file) { var n = compareNumber(a.start.line, b.start.line); if (n === 0) { return compareNumber(a.start.offset, b.start.offset); @@ -68639,14 +72489,18 @@ var ts; start: scriptInfo.positionToLineOffset(diag.start), end: scriptInfo.positionToLineOffset(diag.start + diag.length), text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), - code: diag.code + code: diag.code, + category: ts.DiagnosticCategory[diag.category].toLowerCase(), + source: diag.source }; } function formatConfigFileDiag(diag) { return { start: undefined, end: undefined, - text: ts.flattenDiagnosticMessageText(diag.messageText, "\n") + text: ts.flattenDiagnosticMessageText(diag.messageText, "\n"), + category: ts.DiagnosticCategory[diag.category].toLowerCase(), + source: diag.source }; } function allEditsBeforePos(edits, pos) { @@ -68804,7 +72658,6 @@ var ts; } }; MultistepOperation.prototype.setTimerHandle = function (timerHandle) { - ; if (this.timerHandle !== undefined) { this.operationHost.getServerHost().clearTimeout(this.timerHandle); } @@ -68822,15 +72675,8 @@ var ts; return MultistepOperation; }()); var Session = (function () { - function Session(host, cancellationToken, useSingleInferredProject, typingsInstaller, byteLength, hrtime, logger, canUseEvents, eventHandler) { + function Session(opts) { var _this = this; - this.host = host; - this.cancellationToken = cancellationToken; - this.typingsInstaller = typingsInstaller; - this.byteLength = byteLength; - this.hrtime = hrtime; - this.logger = logger; - this.canUseEvents = canUseEvents; this.changeSeq = 0; this.handlers = ts.createMapFromTemplate((_a = {}, _a[CommandNames.OpenExternalProject] = function (request) { @@ -68903,7 +72749,7 @@ var ts; return _this.requiredResponse(_this.getRenameInfo(request.arguments)); }, _a[CommandNames.Open] = function (request) { - _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName)); + _this.openClientFile(server.toNormalizedPath(request.arguments.file), request.arguments.fileContent, server.convertScriptKindName(request.arguments.scriptKindName), request.arguments.projectRootPath ? server.toNormalizedPath(request.arguments.projectRootPath) : undefined); return _this.notRequired(); }, _a[CommandNames.Quickinfo] = function (request) { @@ -69070,8 +72916,16 @@ var ts; return _this.requiredResponse(_this.getSupportedCodeFixes()); }, _a)); - this.eventHander = canUseEvents - ? eventHandler || (function (event) { return _this.defaultEventHandler(event); }) + this.host = opts.host; + this.cancellationToken = opts.cancellationToken; + this.typingsInstaller = opts.typingsInstaller; + this.byteLength = opts.byteLength; + this.hrtime = opts.hrtime; + this.logger = opts.logger; + this.canUseEvents = opts.canUseEvents; + var throttleWaitMilliseconds = opts.throttleWaitMilliseconds; + this.eventHandler = this.canUseEvents + ? opts.eventHandler || (function (event) { return _this.defaultEventHandler(event); }) : undefined; var multistepOperationHost = { executeWithRequestId: function (requestId, action) { return _this.executeWithRequestId(requestId, action); }, @@ -69079,11 +72933,22 @@ var ts; getServerHost: function () { return _this.host; }, logError: function (err, cmd) { return _this.logError(err, cmd); }, sendRequestCompletedEvent: function (requestId) { return _this.sendRequestCompletedEvent(requestId); }, - isCancellationRequested: function () { return cancellationToken.isCancellationRequested(); } + isCancellationRequested: function () { return _this.cancellationToken.isCancellationRequested(); } }; this.errorCheck = new MultistepOperation(multistepOperationHost); - this.projectService = new server.ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, this.eventHander); - this.gcTimer = new server.GcTimer(host, 7000, logger); + var settings = { + host: this.host, + logger: this.logger, + cancellationToken: this.cancellationToken, + useSingleInferredProject: opts.useSingleInferredProject, + typingsInstaller: this.typingsInstaller, + throttleWaitMilliseconds: throttleWaitMilliseconds, + eventHandler: this.eventHandler, + globalPlugins: opts.globalPlugins, + pluginProbeLocations: opts.pluginProbeLocations + }; + this.projectService = new server.ProjectService(settings); + this.gcTimer = new server.GcTimer(this.host, 7000, this.logger); var _a; } Session.prototype.sendRequestCompletedEvent = function (requestId) { @@ -69099,9 +72964,9 @@ var ts; var _this = this; switch (event.eventName) { case server.ContextEvent: - var _a = event.data, project_1 = _a.project, fileName_1 = _a.fileName; - this.projectService.logger.info("got context event, updating diagnostics for " + fileName_1); - this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_1, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); + var _a = event.data, project_1 = _a.project, fileName_2 = _a.fileName; + this.projectService.logger.info("got context event, updating diagnostics for " + fileName_2); + this.errorCheck.startNew(function (next) { return _this.updateErrorCheck(next, [{ fileName: fileName_2, project: project_1 }], _this.changeSeq, function (n) { return n === _this.changeSeq; }, 100); }); break; case server.ConfigFileDiagEvent: var _b = event.data, triggerFile = _b.triggerFile, configFileName = _b.configFileName, diagnostics = _b.diagnostics; @@ -69178,7 +73043,7 @@ var ts; Session.prototype.semanticCheck = function (file, project) { try { var diags = []; - if (!shouldSkipSematicCheck(project)) { + if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { diags = project.getLanguageService().getSemanticDiagnostics(file); } var bakedDiags = diags.map(function (diag) { return formatDiag(file, project, diag); }); @@ -69275,13 +73140,14 @@ var ts; length: d.length, category: ts.DiagnosticCategory[d.category].toLowerCase(), code: d.code, + source: d.source, startLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start), endLocation: scriptInfo && scriptInfo.positionToLineOffset(d.start + d.length) }); }); }; Session.prototype.getDiagnosticsWorker = function (args, isSemantic, selector, includeLinePosition) { var _a = this.getFileAndProject(args), project = _a.project, file = _a.file; - if (isSemantic && shouldSkipSematicCheck(project)) { + if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) { return []; } var scriptInfo = project.getScriptInfoForNormalizedPath(file); @@ -69360,16 +73226,20 @@ var ts; return undefined; } return occurrences.map(function (occurrence) { - var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan; + var fileName = occurrence.fileName, isWriteAccess = occurrence.isWriteAccess, textSpan = occurrence.textSpan, isInString = occurrence.isInString; var scriptInfo = project.getScriptInfo(fileName); var start = scriptInfo.positionToLineOffset(textSpan.start); var end = scriptInfo.positionToLineOffset(ts.textSpanEnd(textSpan)); - return { + var result = { start: start, end: end, file: fileName, isWriteAccess: isWriteAccess, }; + if (isInString) { + result.isInString = isInString; + } + return result; }); }; Session.prototype.getSyntacticDiagnosticsSync = function (args) { @@ -69446,13 +73316,23 @@ var ts; } return projects; }; + Session.prototype.getDefaultProject = function (args) { + if (args.projectFileName) { + var project = this.getProject(args.projectFileName); + if (project) { + return project; + } + } + var info = this.projectService.getScriptInfo(args.file); + return info.getDefaultProject(); + }; Session.prototype.getRenameLocations = function (args, simplifiedResult) { var file = server.toNormalizedPath(args.file); var info = this.projectService.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, info); var projects = this.getProjects(args); if (simplifiedResult) { - var defaultProject = projects[0]; + var defaultProject = this.getDefaultProject(args); var renameInfo = defaultProject.getLanguageService().getRenameInfo(file, position); if (!renameInfo) { return undefined; @@ -69531,7 +73411,7 @@ var ts; Session.prototype.getReferences = function (args, simplifiedResult) { var file = server.toNormalizedPath(args.file); var projects = this.getProjects(args); - var defaultProject = projects[0]; + var defaultProject = this.getDefaultProject(args); var scriptInfo = defaultProject.getScriptInfoForNormalizedPath(file); var position = this.getPosition(args, scriptInfo); if (simplifiedResult) { @@ -69582,10 +73462,10 @@ var ts; return false; } }; - Session.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; - if (this.eventHander) { - this.eventHander({ + Session.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + var _a = this.projectService.openClientFileWithNormalizedPath(fileName, fileContent, scriptKind, false, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors; + if (this.eventHandler) { + this.eventHandler({ eventName: "configFileDiag", data: { triggerFile: fileName, configFileName: configFileName, diagnostics: configFileErrors || [] } }); @@ -69663,6 +73543,7 @@ var ts; end: scriptInfo.positionToLineOffset(ts.textSpanEnd(quickInfo.textSpan)), displayString: displayString, documentation: docString, + tags: quickInfo.tags || [] }; } else { @@ -69702,7 +73583,7 @@ var ts; var position = scriptInfo.lineOffsetToPosition(args.line, args.offset); var formatOptions = this.projectService.getFormatCodeOptions(file); var edits = project.getLanguageService(false).getFormattingEditsAfterKeystroke(file, position, args.key, formatOptions); - if ((args.key == "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { + if ((args.key === "\n") && ((!edits) || (edits.length === 0) || allEditsBeforePos(edits, position))) { var lineInfo = scriptInfo.getLineInfo(args.line); if (lineInfo && (lineInfo.leaf) && (lineInfo.leaf.text)) { var lineText = lineInfo.leaf.text; @@ -69711,10 +73592,10 @@ var ts; var hasIndent = 0; var i = void 0, len = void 0; for (i = 0, len = lineText.length; i < len; i++) { - if (lineText.charAt(i) == " ") { + if (lineText.charAt(i) === " ") { hasIndent++; } - else if (lineText.charAt(i) == "\t") { + else if (lineText.charAt(i) === "\t") { hasIndent += formatOptions.tabSize; } else { @@ -69818,12 +73699,12 @@ var ts; return undefined; } if (simplifiedResult) { - var span_16 = helpItems.applicableSpan; + var span_17 = helpItems.applicableSpan; return { items: helpItems.items, applicableSpan: { - start: scriptInfo.positionToLineOffset(span_16.start), - end: scriptInfo.positionToLineOffset(span_16.start + span_16.length) + start: scriptInfo.positionToLineOffset(span_17.start), + end: scriptInfo.positionToLineOffset(span_17.start + span_17.length) }, selectedItemIndex: helpItems.selectedItemIndex, argumentIndex: helpItems.argumentIndex, @@ -70002,11 +73883,15 @@ var ts; }; Session.prototype.getCodeFixes = function (args, simplifiedResult) { var _this = this; + if (args.errorCodes.length === 0) { + return undefined; + } var _a = this.getFileAndProjectWithoutRefreshingInferredProjects(args), file = _a.file, project = _a.project; var scriptInfo = project.getScriptInfoForNormalizedPath(file); var startPosition = getStartPosition(); var endPosition = getEndPosition(); - var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes); + var formatOptions = this.projectService.getFormatCodeOptions(file); + var codeActions = project.getLanguageService().getCodeFixesAtPosition(file, startPosition, endPosition, args.errorCodes, formatOptions); if (!codeActions) { return undefined; } @@ -70067,7 +73952,7 @@ var ts; var project = this.projectService.getDefaultProjectForFile(normalizedFileName, true); for (var _i = 0, fileNamesInProject_1 = fileNamesInProject; _i < fileNamesInProject_1.length; _i++) { var fileNameInProject = fileNamesInProject_1[_i]; - if (this.getCanonicalFileName(fileNameInProject) == this.getCanonicalFileName(fileName)) + if (this.getCanonicalFileName(fileNameInProject) === this.getCanonicalFileName(fileName)) highPriorityFiles.push(fileNameInProject); else { var info = this.projectService.getScriptInfo(fileNameInProject); @@ -70084,7 +73969,7 @@ var ts; fileNamesInProject = highPriorityFiles.concat(mediumPriorityFiles).concat(lowPriorityFiles).concat(veryLowPriorityFiles); if (fileNamesInProject.length > 0) { var checkList = fileNamesInProject.map(function (fileName) { return ({ fileName: fileName, project: project }); }); - this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n == _this.changeSeq; }, delay, 200, false); + this.updateErrorCheck(next, checkList, this.changeSeq, function (n) { return n === _this.changeSeq; }, delay, 200, false); } }; Session.prototype.getCanonicalFileName = function (fileName) { @@ -70229,7 +74114,7 @@ var ts; var lm = LineIndex.linesFromText(insertedText); var lines = lm.lines; if (lines.length > 1) { - if (lines[lines.length - 1] == "") { + if (lines[lines.length - 1] === "") { lines.length--; } } @@ -70670,7 +74555,7 @@ var ts; } if (this.checkEdits) { var updatedText = this.getText(0, this.root.charCount()); - ts.Debug.assert(checkText == updatedText, "buffer edit mismatch"); + ts.Debug.assert(checkText === updatedText, "buffer edit mismatch"); } return walker.lineIndex; } @@ -71231,10 +75116,24 @@ var ts; this.containingProjects.length = 0; }; ScriptInfo.prototype.getDefaultProject = function () { - if (this.containingProjects.length === 0) { - return server.Errors.ThrowNoProject(); + switch (this.containingProjects.length) { + case 0: + return server.Errors.ThrowNoProject(); + case 1: + return this.containingProjects[0]; + default: + var firstExternalProject = void 0; + for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { + var project = _a[_i]; + if (project.projectKind === server.ProjectKind.Configured) { + return project; + } + else if (project.projectKind === server.ProjectKind.External && !firstExternalProject) { + firstExternalProject = project; + } + } + return firstExternalProject || this.containingProjects[0]; } - return this.containingProjects[0]; }; ScriptInfo.prototype.registerFileUpdate = function () { for (var _i = 0, _a = this.containingProjects; _i < _a.length; _i++) { @@ -71322,6 +75221,7 @@ var ts; this.cancellationToken = cancellationToken; this.resolvedModuleNames = ts.createFileMap(); this.resolvedTypeReferenceDirectives = ts.createFileMap(); + this.cancellationToken = new ts.ThrottledCancellationToken(cancellationToken, project.projectService.throttleWaitMilliseconds); this.getCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); if (host.trace) { this.trace = function (s) { return host.trace(s); }; @@ -71540,7 +75440,7 @@ var ts; !setIsEqualTo(opt1.exclude, opt2.exclude); } function compilerOptionsChanged(opt1, opt2) { - return opt1.allowJs != opt2.allowJs; + return opt1.allowJs !== opt2.allowJs; } function unresolvedImportsChanged(imports1, imports2) { if (imports1 === imports2) { @@ -71617,7 +75517,7 @@ var ts; BuilderFileInfo.prototype.containsOnlyAmbientModules = function (sourceFile) { for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var statement = _a[_i]; - if (statement.kind !== 232 || statement.name.kind !== 9) { + if (statement.kind !== 233 || statement.name.kind !== 9) { return false; } } @@ -71738,7 +75638,6 @@ var ts; var r = rf.scriptInfo.fileName; return (l < r ? -1 : (l > r ? 1 : 0)); }; - ; ModuleBuilderFileInfo.addToReferenceList = function (array, fileInfo) { if (array.length === 0) { array.push(fileInfo); @@ -72393,7 +76292,7 @@ var ts; var updatedFileNames = this.updatedFileNames; this.updatedFileNames = undefined; if (this.lastReportedFileNames && lastKnownVersion === this.lastReportedVersion) { - if (this.projectStructureVersion == this.lastReportedVersion && !updatedFileNames) { + if (this.projectStructureVersion === this.lastReportedVersion && !updatedFileNames) { return { info: info, projectErrors: this.projectErrors }; } var lastReportedFileNames_1 = this.lastReportedFileNames; @@ -72552,7 +76451,6 @@ var ts; __extends(ConfiguredProject, _super); function ConfiguredProject(configFileName, projectService, documentRegistry, hasExplicitListOfFiles, compilerOptions, wildcardDirectories, languageServiceEnabled, compileOnSaveEnabled) { var _this = _super.call(this, configFileName, ProjectKind.Configured, projectService, documentRegistry, hasExplicitListOfFiles, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; - _this.configFileName = configFileName; _this.wildcardDirectories = wildcardDirectories; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.plugins = []; @@ -72565,28 +76463,46 @@ var ts; return this.getProjectName(); }; ConfiguredProject.prototype.enablePlugins = function () { - var _this = this; var host = this.projectService.host; var options = this.getCompilerOptions(); - var log = function (message) { - _this.projectService.logger.info(message); - }; - if (!(options.plugins && options.plugins.length)) { - this.projectService.logger.info("No plugins exist"); - return; - } if (!host.require) { this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded"); return; } - for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { - var pluginConfigEntry = _a[_i]; - var searchPath = ts.getDirectoryPath(this.configFileName); - var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, host, log); - if (resolvedModule) { - this.enableProxy(resolvedModule, pluginConfigEntry); + var searchPaths = [ts.combinePaths(host.getExecutingFilePath(), "../../..")].concat(this.projectService.pluginProbeLocations); + if (options.plugins) { + for (var _i = 0, _a = options.plugins; _i < _a.length; _i++) { + var pluginConfigEntry = _a[_i]; + this.enablePlugin(pluginConfigEntry, searchPaths); } } + if (this.projectService.globalPlugins) { + var _loop_6 = function (globalPluginName) { + if (options.plugins && options.plugins.some(function (p) { return p.name === globalPluginName; })) + return "continue"; + this_1.enablePlugin({ name: globalPluginName, global: true }, searchPaths); + }; + var this_1 = this; + for (var _b = 0, _c = this.projectService.globalPlugins; _b < _c.length; _b++) { + var globalPluginName = _c[_b]; + _loop_6(globalPluginName); + } + } + }; + ConfiguredProject.prototype.enablePlugin = function (pluginConfigEntry, searchPaths) { + var _this = this; + var log = function (message) { + _this.projectService.logger.info(message); + }; + for (var _i = 0, searchPaths_1 = searchPaths; _i < searchPaths_1.length; _i++) { + var searchPath = searchPaths_1[_i]; + var resolvedModule = Project.resolveModule(pluginConfigEntry.name, searchPath, this.projectService.host, log); + if (resolvedModule) { + this.enableProxy(resolvedModule, pluginConfigEntry); + return; + } + } + this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name + " anywhere in paths: " + searchPaths.join(",")); }; ConfiguredProject.prototype.enableProxy = function (pluginModuleFactory, configEntry) { try { @@ -72716,6 +76632,7 @@ var ts; __extends(ExternalProject, _super); function ExternalProject(externalProjectName, projectService, documentRegistry, compilerOptions, languageServiceEnabled, compileOnSaveEnabled, projectFilePath) { var _this = _super.call(this, externalProjectName, ProjectKind.External, projectService, documentRegistry, true, languageServiceEnabled, compilerOptions, compileOnSaveEnabled) || this; + _this.externalProjectName = externalProjectName; _this.compileOnSaveEnabled = compileOnSaveEnabled; _this.projectFilePath = projectFilePath; return _this; @@ -72786,6 +76703,31 @@ var ts; "block": ts.IndentStyle.Block, "smart": ts.IndentStyle.Smart }); + var defaultTypeSafeList = { + "jquery": { + "match": /jquery(-(\.?\d+)+)?(\.intellisense)?(\.min)?\.js$/i, + "types": ["jquery"] + }, + "WinJS": { + "match": /^(.*\/winjs-[.\d]+)\/js\/base\.js$/i, + "exclude": [["^", 1, "/.*"]], + "types": ["winjs"] + }, + "Kendo": { + "match": /^(.*\/kendo)\/kendo\.all\.min\.js$/i, + "exclude": [["^", 1, "/.*"]], + "types": ["kendo-ui"] + }, + "Office Nuget": { + "match": /^(.*\/office\/1)\/excel-\d+\.debug\.js$/i, + "exclude": [["^", 1, "/.*"]], + "types": ["office"] + }, + "Minified files": { + "match": /^(.+\.min\.js)$/i, + "exclude": [["^", 1, "$"]] + } + }; function convertFormatOptions(protocolOptions) { if (typeof protocolOptions.indentStyle === "string") { protocolOptions.indentStyle = indentStyle.get(protocolOptions.indentStyle.toLowerCase()); @@ -72878,7 +76820,7 @@ var ts; DirectoryWatchers.prototype.startWatchingContainingDirectoriesForFile = function (fileName, project, callback) { var currentPath = ts.getDirectoryPath(fileName); var parentPath = ts.getDirectoryPath(currentPath); - while (currentPath != parentPath) { + while (currentPath !== parentPath) { if (!this.directoryWatchersForTsconfig.has(currentPath)) { this.projectService.logger.info("Add watcher for: " + currentPath); this.directoryWatchersForTsconfig.set(currentPath, this.projectService.host.watchDirectory(currentPath, callback)); @@ -72895,24 +76837,27 @@ var ts; return DirectoryWatchers; }()); var ProjectService = (function () { - function ProjectService(host, logger, cancellationToken, useSingleInferredProject, typingsInstaller, eventHandler) { - if (typingsInstaller === void 0) { typingsInstaller = server.nullTypingsInstaller; } - this.host = host; - this.logger = logger; - this.cancellationToken = cancellationToken; - this.useSingleInferredProject = useSingleInferredProject; - this.typingsInstaller = typingsInstaller; - this.eventHandler = eventHandler; + function ProjectService(opts) { this.filenameToScriptInfo = ts.createFileMap(); this.externalProjectToConfiguredProjectMap = ts.createMap(); this.externalProjects = []; this.inferredProjects = []; this.configuredProjects = []; this.openFiles = []; - ts.Debug.assert(!!host.createHash, "'ServerHost.createHash' is required for ProjectService"); - this.toCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames); + this.projectToSizeMap = ts.createMap(); + this.host = opts.host; + this.logger = opts.logger; + this.cancellationToken = opts.cancellationToken; + this.useSingleInferredProject = opts.useSingleInferredProject; + this.typingsInstaller = opts.typingsInstaller || server.nullTypingsInstaller; + this.throttleWaitMilliseconds = opts.throttleWaitMilliseconds; + this.eventHandler = opts.eventHandler; + this.globalPlugins = opts.globalPlugins || server.emptyArray; + this.pluginProbeLocations = opts.pluginProbeLocations || server.emptyArray; + ts.Debug.assert(!!this.host.createHash, "'ServerHost.createHash' is required for ProjectService"); + this.toCanonicalFileName = ts.createGetCanonicalFileName(this.host.useCaseSensitiveFileNames); this.directoryWatchers = new DirectoryWatchers(this); - this.throttledOperations = new server.ThrottledOperations(host); + this.throttledOperations = new server.ThrottledOperations(this.host); this.typingsInstaller.attach(this); this.typingsCache = new server.TypingsCache(this.typingsInstaller); this.hostConfiguration = { @@ -72920,7 +76865,7 @@ var ts; hostInfo: "Unknown host", extraFileExtensions: [] }; - this.documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames, host.getCurrentDirectory()); + this.documentRegistry = ts.createDocumentRegistry(this.host.useCaseSensitiveFileNames, this.host.getCurrentDirectory()); } ProjectService.prototype.getChangedFiles_TestOnly = function () { return this.changedFiles; @@ -73110,7 +77055,7 @@ var ts; this.refreshInferredProjects(); }; ProjectService.prototype.onConfigFileAddedForInferredProject = function (fileName) { - if (ts.getBaseFileName(fileName) != "tsconfig.json") { + if (ts.getBaseFileName(fileName) !== "tsconfig.json") { this.logger.info(fileName + " is not tsconfig.json"); return; } @@ -73129,9 +77074,11 @@ var ts; switch (project.projectKind) { case server.ProjectKind.External: server.removeItemFromSet(this.externalProjects, project); + this.projectToSizeMap.delete(project.externalProjectName); break; case server.ProjectKind.Configured: server.removeItemFromSet(this.configuredProjects, project); + this.projectToSizeMap.delete(project.canonicalConfigFilePath); break; case server.ProjectKind.Inferred: server.removeItemFromSet(this.inferredProjects, project); @@ -73167,13 +77114,17 @@ var ts; if (!this.useSingleInferredProject) { for (var _b = 0, _c = this.openFiles; _b < _c.length; _b++) { var f = _c[_b]; - if (f.containingProjects.length === 0) { + if (f.containingProjects.length === 0 || !inferredProject.containsScriptInfo(f)) { continue; } - var defaultProject = f.getDefaultProject(); - if (isRootFileInInferredProject(info) && defaultProject !== inferredProject && inferredProject.containsScriptInfo(f)) { - this.removeProject(defaultProject); - f.attachToProject(inferredProject); + for (var _d = 0, _e = f.containingProjects; _d < _e.length; _d++) { + var fContainingProject = _e[_d]; + if (fContainingProject.projectKind === server.ProjectKind.Inferred && + fContainingProject.isRoot(f) && + fContainingProject !== inferredProject) { + this.removeProject(fContainingProject); + f.attachToProject(inferredProject); + } } } } @@ -73226,10 +77177,10 @@ var ts; this.filenameToScriptInfo.remove(info.path); } }; - ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName) { + ProjectService.prototype.openOrUpdateConfiguredProjectForFile = function (fileName, projectRootPath) { var searchPath = ts.getDirectoryPath(fileName); this.logger.info("Search path: " + searchPath); - var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath)); + var configFileName = this.findConfigFile(server.asNormalizedPath(searchPath), projectRootPath); if (!configFileName) { this.logger.info("No config files found."); return {}; @@ -73251,8 +77202,8 @@ var ts; } return { configFileName: configFileName }; }; - ProjectService.prototype.findConfigFile = function (searchPath) { - while (true) { + ProjectService.prototype.findConfigFile = function (searchPath, projectRootPath) { + while (!projectRootPath || searchPath.indexOf(projectRootPath) >= 0) { var tsconfigFileName = server.asNormalizedPath(ts.combinePaths(searchPath, "tsconfig.json")); if (this.host.fileExists(tsconfigFileName)) { return tsconfigFileName; @@ -73338,10 +77289,13 @@ var ts; }; return { success: true, projectOptions: projectOptions, configFileErrors: errors }; }; - ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (options, fileNames, propertyReader) { + ProjectService.prototype.exceededTotalSizeLimitForNonTsFiles = function (name, options, fileNames, propertyReader) { if (options && options.disableSizeLimit || !this.host.getFileSize) { return false; } + var availableSpace = server.maxProgramSizeForNonTsFiles; + this.projectToSizeMap.set(name, 0); + this.projectToSizeMap.forEach(function (val) { return (availableSpace -= (val || 0)); }); var totalNonTsFileSize = 0; for (var _i = 0, fileNames_3 = fileNames; _i < fileNames_3.length; _i++) { var f = fileNames_3[_i]; @@ -73354,11 +77308,15 @@ var ts; return true; } } + if (totalNonTsFileSize > availableSpace) { + return true; + } + this.projectToSizeMap.set(name, totalNonTsFileSize); return false; }; ProjectService.prototype.createAndAddExternalProject = function (projectFileName, files, options, typeAcquisition) { var compilerOptions = convertCompilerOptions(options); - var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); + var project = new server.ExternalProject(projectFileName, this, this.documentRegistry, compilerOptions, !this.exceededTotalSizeLimitForNonTsFiles(projectFileName, compilerOptions, files, externalFilePropertyReader), options.compileOnSave === undefined ? true : options.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, files, externalFilePropertyReader, undefined, typeAcquisition, undefined); this.externalProjects.push(project); return project; @@ -73374,7 +77332,7 @@ var ts; }; ProjectService.prototype.createAndAddConfiguredProject = function (configFileName, projectOptions, configFileErrors, clientFileName) { var _this = this; - var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); + var sizeLimitExceeded = this.exceededTotalSizeLimitForNonTsFiles(configFileName, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader); var project = new server.ConfiguredProject(configFileName, this, this.documentRegistry, projectOptions.configHasFilesProperty, projectOptions.compilerOptions, projectOptions.wildcardDirectories, !sizeLimitExceeded, projectOptions.compileOnSave === undefined ? false : projectOptions.compileOnSave); this.addFilesToProjectAndUpdateGraph(project, projectOptions.files, fileNamePropertyReader, clientFileName, projectOptions.typeAcquisition, configFileErrors); project.watchConfigFile(function (project) { return _this.onConfigChangedForConfiguredProject(project); }); @@ -73400,7 +77358,7 @@ var ts; var scriptKind = propertyReader.getScriptKind(f); var hasMixedContent = propertyReader.hasMixedContent(f, this.hostConfiguration.extraFileExtensions); if (this.host.fileExists(rootFilename)) { - var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName == rootFilename, undefined, scriptKind, hasMixedContent); + var info = this.getOrCreateScriptInfoForNormalizedPath(server.toNormalizedPath(rootFilename), clientFileName === rootFilename, undefined, scriptKind, hasMixedContent); project.addRoot(info); } else { @@ -73415,7 +77373,7 @@ var ts; var conversionResult = this.convertConfigFileContentToProjectOptions(configFileName); var projectOptions = conversionResult.success ? conversionResult.projectOptions - : { files: [], compilerOptions: {} }; + : { files: [], compilerOptions: {}, typeAcquisition: { enable: false } }; var project = this.createAndAddConfiguredProject(configFileName, projectOptions, conversionResult.configFileErrors, clientFileName); return { success: conversionResult.success, @@ -73503,7 +77461,7 @@ var ts; this.updateNonInferredProject(project, [], fileNamePropertyReader, {}, {}, false, configFileErrors); return configFileErrors; } - if (this.exceededTotalSizeLimitForNonTsFiles(projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(project.canonicalConfigFilePath, projectOptions.compilerOptions, projectOptions.files, fileNamePropertyReader)) { project.setCompilerOptions(projectOptions.compilerOptions); if (!project.languageServiceEnabled) { return configFileErrors; @@ -73640,15 +77598,15 @@ var ts; } this.printProjects(); }; - ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind) { - return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind); + ProjectService.prototype.openClientFile = function (fileName, fileContent, scriptKind, projectRootPath) { + return this.openClientFileWithNormalizedPath(server.toNormalizedPath(fileName), fileContent, scriptKind, false, projectRootPath ? server.toNormalizedPath(projectRootPath) : undefined); }; - ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent) { + ProjectService.prototype.openClientFileWithNormalizedPath = function (fileName, fileContent, scriptKind, hasMixedContent, projectRootPath) { var configFileName; var configFileErrors; var project = this.findContainingExternalProject(fileName); if (!project) { - (_a = this.openOrUpdateConfiguredProjectForFile(fileName), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); + (_a = this.openOrUpdateConfiguredProjectForFile(fileName, projectRootPath), configFileName = _a.configFileName, configFileErrors = _a.configFileErrors); if (configFileName) { project = this.findConfiguredProjectByProjectName(configFileName); } @@ -73670,13 +77628,13 @@ var ts; this.printProjects(); }; ProjectService.prototype.collectChanges = function (lastKnownProjectVersions, currentProjects, result) { - var _loop_6 = function (proj) { + var _loop_7 = function (proj) { var knownProject = ts.forEach(lastKnownProjectVersions, function (p) { return p.projectName === proj.getProjectName() && p; }); result.push(proj.getChangesSinceVersion(knownProject && knownProject.version)); }; for (var _i = 0, currentProjects_1 = currentProjects; _i < currentProjects_1.length; _i++) { var proj = currentProjects_1[_i]; - _loop_6(proj); + _loop_7(proj); } }; ProjectService.prototype.synchronizeProjectList = function (knownProjects) { @@ -73775,12 +77733,95 @@ var ts; }); this.refreshInferredProjects(); }; + ProjectService.escapeFilenameForRegex = function (filename) { + return filename.replace(this.filenameEscapeRegexp, "\\$&"); + }; + ProjectService.prototype.resetSafeList = function () { + ProjectService.safelist = defaultTypeSafeList; + }; + ProjectService.prototype.loadSafeList = function (fileName) { + var raw = JSON.parse(this.host.readFile(fileName, "utf-8")); + for (var _i = 0, _a = Object.keys(raw); _i < _a.length; _i++) { + var k = _a[_i]; + raw[k].match = new RegExp(raw[k].match, "i"); + } + ProjectService.safelist = raw; + }; + ProjectService.prototype.applySafeList = function (proj) { + var _this = this; + var rootFiles = proj.rootFiles, typeAcquisition = proj.typeAcquisition; + var types = (typeAcquisition && typeAcquisition.include) || []; + var excludeRules = []; + var normalizedNames = rootFiles.map(function (f) { return ts.normalizeSlashes(f.fileName); }); + var _loop_8 = function (name) { + var rule = ProjectService.safelist[name]; + for (var _i = 0, normalizedNames_1 = normalizedNames; _i < normalizedNames_1.length; _i++) { + var root = normalizedNames_1[_i]; + if (rule.match.test(root)) { + this_2.logger.info("Excluding files based on rule " + name); + if (rule.types) { + for (var _a = 0, _b = rule.types; _a < _b.length; _a++) { + var type = _b[_a]; + if (types.indexOf(type) < 0) { + types.push(type); + } + } + } + if (rule.exclude) { + var _loop_9 = function (exclude) { + var processedRule = root.replace(rule.match, function () { + var groups = []; + for (var _i = 0; _i < arguments.length; _i++) { + groups[_i] = arguments[_i]; + } + return exclude.map(function (groupNumberOrString) { + if (typeof groupNumberOrString === "number") { + if (typeof groups[groupNumberOrString] !== "string") { + _this.logger.info("Incorrect RegExp specification in safelist rule " + name + " - not enough groups"); + return "\\*"; + } + return ProjectService.escapeFilenameForRegex(groups[groupNumberOrString]); + } + return groupNumberOrString; + }).join(""); + }); + if (excludeRules.indexOf(processedRule) === -1) { + excludeRules.push(processedRule); + } + }; + for (var _c = 0, _d = rule.exclude; _c < _d.length; _c++) { + var exclude = _d[_c]; + _loop_9(exclude); + } + } + else { + var escaped = ProjectService.escapeFilenameForRegex(root); + if (excludeRules.indexOf(escaped) < 0) { + excludeRules.push(escaped); + } + } + } + } + if (types.length > 0) { + proj.typeAcquisition = proj.typeAcquisition || {}; + proj.typeAcquisition.include = types; + } + }; + var this_2 = this; + for (var _i = 0, _a = Object.keys(ProjectService.safelist); _i < _a.length; _i++) { + var name = _a[_i]; + _loop_8(name); + } + var excludeRegexes = excludeRules.map(function (e) { return new RegExp(e, "i"); }); + proj.rootFiles = proj.rootFiles.filter(function (_file, index) { return !excludeRegexes.some(function (re) { return re.test(normalizedNames[index]); }); }); + }; ProjectService.prototype.openExternalProject = function (proj, suppressRefreshOfInferredProjects) { if (suppressRefreshOfInferredProjects === void 0) { suppressRefreshOfInferredProjects = false; } if (proj.typingOptions && !proj.typeAcquisition) { var typeAcquisition = ts.convertEnableAutoDiscoveryToEnable(proj.typingOptions); proj.typeAcquisition = typeAcquisition; } + this.applySafeList(proj); var tsConfigFiles; var rootFiles = []; for (var _i = 0, _a = proj.rootFiles; _i < _a.length; _i++) { @@ -73803,7 +77844,7 @@ var ts; if (externalProject) { if (!tsConfigFiles) { var compilerOptions = convertCompilerOptions(proj.options); - if (this.exceededTotalSizeLimitForNonTsFiles(compilerOptions, proj.rootFiles, externalFilePropertyReader)) { + if (this.exceededTotalSizeLimitForNonTsFiles(proj.projectFileName, compilerOptions, proj.rootFiles, externalFilePropertyReader)) { externalProject.disableLanguageService(); } else { @@ -73867,6 +77908,8 @@ var ts; }; return ProjectService; }()); + ProjectService.safelist = defaultTypeSafeList; + ProjectService.filenameEscapeRegexp = /[-\/\\^$*+?.()|[\]{}]/g; server.ProjectService = ProjectService; })(server = ts.server || (ts.server = {})); })(ts || (ts = {})); @@ -73891,7 +77934,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - if (encoded == null) { + if (encoded === null) { return null; } var decoded = JSON.parse(encoded); @@ -73959,7 +78002,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); - if (settingsJson == null || settingsJson == "") { + if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } var compilerOptions = JSON.parse(settingsJson); @@ -73987,7 +78030,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; } try { @@ -74000,7 +78043,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); + return new ts.ThrottledCancellationToken(hostCancellationToken); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -74024,22 +78067,6 @@ var ts; return LanguageServiceShimHostAdapter; }()); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); var CoreServicesShimHostAdapter = (function () { function CoreServicesShimHostAdapter(shimHost) { var _this = this; @@ -74563,4 +78590,4 @@ var TypeScript; Services.TypeScriptServicesFactory = ts.TypeScriptServicesFactory; })(Services = TypeScript.Services || (TypeScript.Services = {})); })(TypeScript || (TypeScript = {})); -var toolsVersion = "2.3"; +var toolsVersion = "2.4"; diff --git a/lib/typescript.d.ts b/lib/typescript.d.ts index 05f02b45233..2f11d458e20 100644 --- a/lib/typescript.d.ts +++ b/lib/typescript.d.ts @@ -24,7 +24,7 @@ declare namespace ts { } /** ES6 Map interface. */ interface Map { - get(key: string): T; + get(key: string): T | undefined; has(key: string): boolean; set(key: string, value: T): this; delete(key: string): boolean; @@ -73,326 +73,324 @@ declare namespace ts { NumericLiteral = 8, StringLiteral = 9, JsxText = 10, - RegularExpressionLiteral = 11, - NoSubstitutionTemplateLiteral = 12, - TemplateHead = 13, - TemplateMiddle = 14, - TemplateTail = 15, - OpenBraceToken = 16, - CloseBraceToken = 17, - OpenParenToken = 18, - CloseParenToken = 19, - OpenBracketToken = 20, - CloseBracketToken = 21, - DotToken = 22, - DotDotDotToken = 23, - SemicolonToken = 24, - CommaToken = 25, - LessThanToken = 26, - LessThanSlashToken = 27, - GreaterThanToken = 28, - LessThanEqualsToken = 29, - GreaterThanEqualsToken = 30, - EqualsEqualsToken = 31, - ExclamationEqualsToken = 32, - EqualsEqualsEqualsToken = 33, - ExclamationEqualsEqualsToken = 34, - EqualsGreaterThanToken = 35, - PlusToken = 36, - MinusToken = 37, - AsteriskToken = 38, - AsteriskAsteriskToken = 39, - SlashToken = 40, - PercentToken = 41, - PlusPlusToken = 42, - MinusMinusToken = 43, - LessThanLessThanToken = 44, - GreaterThanGreaterThanToken = 45, - GreaterThanGreaterThanGreaterThanToken = 46, - AmpersandToken = 47, - BarToken = 48, - CaretToken = 49, - ExclamationToken = 50, - TildeToken = 51, - AmpersandAmpersandToken = 52, - BarBarToken = 53, - QuestionToken = 54, - ColonToken = 55, - AtToken = 56, - EqualsToken = 57, - PlusEqualsToken = 58, - MinusEqualsToken = 59, - AsteriskEqualsToken = 60, - AsteriskAsteriskEqualsToken = 61, - SlashEqualsToken = 62, - PercentEqualsToken = 63, - LessThanLessThanEqualsToken = 64, - GreaterThanGreaterThanEqualsToken = 65, - GreaterThanGreaterThanGreaterThanEqualsToken = 66, - AmpersandEqualsToken = 67, - BarEqualsToken = 68, - CaretEqualsToken = 69, - Identifier = 70, - BreakKeyword = 71, - CaseKeyword = 72, - CatchKeyword = 73, - ClassKeyword = 74, - ConstKeyword = 75, - ContinueKeyword = 76, - DebuggerKeyword = 77, - DefaultKeyword = 78, - DeleteKeyword = 79, - DoKeyword = 80, - ElseKeyword = 81, - EnumKeyword = 82, - ExportKeyword = 83, - ExtendsKeyword = 84, - FalseKeyword = 85, - FinallyKeyword = 86, - ForKeyword = 87, - FunctionKeyword = 88, - IfKeyword = 89, - ImportKeyword = 90, - InKeyword = 91, - InstanceOfKeyword = 92, - NewKeyword = 93, - NullKeyword = 94, - ReturnKeyword = 95, - SuperKeyword = 96, - SwitchKeyword = 97, - ThisKeyword = 98, - ThrowKeyword = 99, - TrueKeyword = 100, - TryKeyword = 101, - TypeOfKeyword = 102, - VarKeyword = 103, - VoidKeyword = 104, - WhileKeyword = 105, - WithKeyword = 106, - ImplementsKeyword = 107, - InterfaceKeyword = 108, - LetKeyword = 109, - PackageKeyword = 110, - PrivateKeyword = 111, - ProtectedKeyword = 112, - PublicKeyword = 113, - StaticKeyword = 114, - YieldKeyword = 115, - AbstractKeyword = 116, - AsKeyword = 117, - AnyKeyword = 118, - AsyncKeyword = 119, - AwaitKeyword = 120, - BooleanKeyword = 121, - ConstructorKeyword = 122, - DeclareKeyword = 123, - GetKeyword = 124, - IsKeyword = 125, - KeyOfKeyword = 126, - ModuleKeyword = 127, - NamespaceKeyword = 128, - NeverKeyword = 129, - ReadonlyKeyword = 130, - RequireKeyword = 131, - NumberKeyword = 132, - ObjectKeyword = 133, - SetKeyword = 134, - StringKeyword = 135, - SymbolKeyword = 136, - TypeKeyword = 137, - UndefinedKeyword = 138, - FromKeyword = 139, - GlobalKeyword = 140, - OfKeyword = 141, - QualifiedName = 142, - ComputedPropertyName = 143, - TypeParameter = 144, - Parameter = 145, - Decorator = 146, - PropertySignature = 147, - PropertyDeclaration = 148, - MethodSignature = 149, - MethodDeclaration = 150, - Constructor = 151, - GetAccessor = 152, - SetAccessor = 153, - CallSignature = 154, - ConstructSignature = 155, - IndexSignature = 156, - TypePredicate = 157, - TypeReference = 158, - FunctionType = 159, - ConstructorType = 160, - TypeQuery = 161, - TypeLiteral = 162, - ArrayType = 163, - TupleType = 164, - UnionType = 165, - IntersectionType = 166, - ParenthesizedType = 167, - ThisType = 168, - TypeOperator = 169, - IndexedAccessType = 170, - MappedType = 171, - LiteralType = 172, - ObjectBindingPattern = 173, - ArrayBindingPattern = 174, - BindingElement = 175, - ArrayLiteralExpression = 176, - ObjectLiteralExpression = 177, - PropertyAccessExpression = 178, - ElementAccessExpression = 179, - CallExpression = 180, - NewExpression = 181, - TaggedTemplateExpression = 182, - TypeAssertionExpression = 183, - ParenthesizedExpression = 184, - FunctionExpression = 185, - ArrowFunction = 186, - DeleteExpression = 187, - TypeOfExpression = 188, - VoidExpression = 189, - AwaitExpression = 190, - PrefixUnaryExpression = 191, - PostfixUnaryExpression = 192, - BinaryExpression = 193, - ConditionalExpression = 194, - TemplateExpression = 195, - YieldExpression = 196, - SpreadElement = 197, - ClassExpression = 198, - OmittedExpression = 199, - ExpressionWithTypeArguments = 200, - AsExpression = 201, - NonNullExpression = 202, - MetaProperty = 203, - TemplateSpan = 204, - SemicolonClassElement = 205, - Block = 206, - VariableStatement = 207, - EmptyStatement = 208, - ExpressionStatement = 209, - IfStatement = 210, - DoStatement = 211, - WhileStatement = 212, - ForStatement = 213, - ForInStatement = 214, - ForOfStatement = 215, - ContinueStatement = 216, - BreakStatement = 217, - ReturnStatement = 218, - WithStatement = 219, - SwitchStatement = 220, - LabeledStatement = 221, - ThrowStatement = 222, - TryStatement = 223, - DebuggerStatement = 224, - VariableDeclaration = 225, - VariableDeclarationList = 226, - FunctionDeclaration = 227, - ClassDeclaration = 228, - InterfaceDeclaration = 229, - TypeAliasDeclaration = 230, - EnumDeclaration = 231, - ModuleDeclaration = 232, - ModuleBlock = 233, - CaseBlock = 234, - NamespaceExportDeclaration = 235, - ImportEqualsDeclaration = 236, - ImportDeclaration = 237, - ImportClause = 238, - NamespaceImport = 239, - NamedImports = 240, - ImportSpecifier = 241, - ExportAssignment = 242, - ExportDeclaration = 243, - NamedExports = 244, - ExportSpecifier = 245, - MissingDeclaration = 246, - ExternalModuleReference = 247, - JsxElement = 248, - JsxSelfClosingElement = 249, - JsxOpeningElement = 250, - JsxClosingElement = 251, - JsxAttribute = 252, - JsxAttributes = 253, - JsxSpreadAttribute = 254, - JsxExpression = 255, - CaseClause = 256, - DefaultClause = 257, - HeritageClause = 258, - CatchClause = 259, - PropertyAssignment = 260, - ShorthandPropertyAssignment = 261, - SpreadAssignment = 262, - EnumMember = 263, - SourceFile = 264, - Bundle = 265, - JSDocTypeExpression = 266, - JSDocAllType = 267, - JSDocUnknownType = 268, - JSDocArrayType = 269, - JSDocUnionType = 270, - JSDocTupleType = 271, - JSDocNullableType = 272, - JSDocNonNullableType = 273, - JSDocRecordType = 274, - JSDocRecordMember = 275, - JSDocTypeReference = 276, - JSDocOptionalType = 277, - JSDocFunctionType = 278, - JSDocVariadicType = 279, - JSDocConstructorType = 280, - JSDocThisType = 281, - JSDocComment = 282, - JSDocTag = 283, - JSDocAugmentsTag = 284, - JSDocParameterTag = 285, - JSDocReturnTag = 286, - JSDocTypeTag = 287, - JSDocTemplateTag = 288, - JSDocTypedefTag = 289, - JSDocPropertyTag = 290, - JSDocTypeLiteral = 291, - JSDocLiteralType = 292, - JSDocNullKeyword = 293, - JSDocUndefinedKeyword = 294, - JSDocNeverKeyword = 295, - SyntaxList = 296, - NotEmittedStatement = 297, - PartiallyEmittedExpression = 298, - MergeDeclarationMarker = 299, - EndOfDeclarationMarker = 300, - Count = 301, - FirstAssignment = 57, - LastAssignment = 69, - FirstCompoundAssignment = 58, - LastCompoundAssignment = 69, - FirstReservedWord = 71, - LastReservedWord = 106, - FirstKeyword = 71, - LastKeyword = 141, - FirstFutureReservedWord = 107, - LastFutureReservedWord = 115, - FirstTypeNode = 157, - LastTypeNode = 172, - FirstPunctuation = 16, - LastPunctuation = 69, + JsxTextAllWhiteSpaces = 11, + RegularExpressionLiteral = 12, + NoSubstitutionTemplateLiteral = 13, + TemplateHead = 14, + TemplateMiddle = 15, + TemplateTail = 16, + OpenBraceToken = 17, + CloseBraceToken = 18, + OpenParenToken = 19, + CloseParenToken = 20, + OpenBracketToken = 21, + CloseBracketToken = 22, + DotToken = 23, + DotDotDotToken = 24, + SemicolonToken = 25, + CommaToken = 26, + LessThanToken = 27, + LessThanSlashToken = 28, + GreaterThanToken = 29, + LessThanEqualsToken = 30, + GreaterThanEqualsToken = 31, + EqualsEqualsToken = 32, + ExclamationEqualsToken = 33, + EqualsEqualsEqualsToken = 34, + ExclamationEqualsEqualsToken = 35, + EqualsGreaterThanToken = 36, + PlusToken = 37, + MinusToken = 38, + AsteriskToken = 39, + AsteriskAsteriskToken = 40, + SlashToken = 41, + PercentToken = 42, + PlusPlusToken = 43, + MinusMinusToken = 44, + LessThanLessThanToken = 45, + GreaterThanGreaterThanToken = 46, + GreaterThanGreaterThanGreaterThanToken = 47, + AmpersandToken = 48, + BarToken = 49, + CaretToken = 50, + ExclamationToken = 51, + TildeToken = 52, + AmpersandAmpersandToken = 53, + BarBarToken = 54, + QuestionToken = 55, + ColonToken = 56, + AtToken = 57, + EqualsToken = 58, + PlusEqualsToken = 59, + MinusEqualsToken = 60, + AsteriskEqualsToken = 61, + AsteriskAsteriskEqualsToken = 62, + SlashEqualsToken = 63, + PercentEqualsToken = 64, + LessThanLessThanEqualsToken = 65, + GreaterThanGreaterThanEqualsToken = 66, + GreaterThanGreaterThanGreaterThanEqualsToken = 67, + AmpersandEqualsToken = 68, + BarEqualsToken = 69, + CaretEqualsToken = 70, + Identifier = 71, + BreakKeyword = 72, + CaseKeyword = 73, + CatchKeyword = 74, + ClassKeyword = 75, + ConstKeyword = 76, + ContinueKeyword = 77, + DebuggerKeyword = 78, + DefaultKeyword = 79, + DeleteKeyword = 80, + DoKeyword = 81, + ElseKeyword = 82, + EnumKeyword = 83, + ExportKeyword = 84, + ExtendsKeyword = 85, + FalseKeyword = 86, + FinallyKeyword = 87, + ForKeyword = 88, + FunctionKeyword = 89, + IfKeyword = 90, + ImportKeyword = 91, + InKeyword = 92, + InstanceOfKeyword = 93, + NewKeyword = 94, + NullKeyword = 95, + ReturnKeyword = 96, + SuperKeyword = 97, + SwitchKeyword = 98, + ThisKeyword = 99, + ThrowKeyword = 100, + TrueKeyword = 101, + TryKeyword = 102, + TypeOfKeyword = 103, + VarKeyword = 104, + VoidKeyword = 105, + WhileKeyword = 106, + WithKeyword = 107, + ImplementsKeyword = 108, + InterfaceKeyword = 109, + LetKeyword = 110, + PackageKeyword = 111, + PrivateKeyword = 112, + ProtectedKeyword = 113, + PublicKeyword = 114, + StaticKeyword = 115, + YieldKeyword = 116, + AbstractKeyword = 117, + AsKeyword = 118, + AnyKeyword = 119, + AsyncKeyword = 120, + AwaitKeyword = 121, + BooleanKeyword = 122, + ConstructorKeyword = 123, + DeclareKeyword = 124, + GetKeyword = 125, + IsKeyword = 126, + KeyOfKeyword = 127, + ModuleKeyword = 128, + NamespaceKeyword = 129, + NeverKeyword = 130, + ReadonlyKeyword = 131, + RequireKeyword = 132, + NumberKeyword = 133, + ObjectKeyword = 134, + SetKeyword = 135, + StringKeyword = 136, + SymbolKeyword = 137, + TypeKeyword = 138, + UndefinedKeyword = 139, + FromKeyword = 140, + GlobalKeyword = 141, + OfKeyword = 142, + QualifiedName = 143, + ComputedPropertyName = 144, + TypeParameter = 145, + Parameter = 146, + Decorator = 147, + PropertySignature = 148, + PropertyDeclaration = 149, + MethodSignature = 150, + MethodDeclaration = 151, + Constructor = 152, + GetAccessor = 153, + SetAccessor = 154, + CallSignature = 155, + ConstructSignature = 156, + IndexSignature = 157, + TypePredicate = 158, + TypeReference = 159, + FunctionType = 160, + ConstructorType = 161, + TypeQuery = 162, + TypeLiteral = 163, + ArrayType = 164, + TupleType = 165, + UnionType = 166, + IntersectionType = 167, + ParenthesizedType = 168, + ThisType = 169, + TypeOperator = 170, + IndexedAccessType = 171, + MappedType = 172, + LiteralType = 173, + ObjectBindingPattern = 174, + ArrayBindingPattern = 175, + BindingElement = 176, + ArrayLiteralExpression = 177, + ObjectLiteralExpression = 178, + PropertyAccessExpression = 179, + ElementAccessExpression = 180, + CallExpression = 181, + NewExpression = 182, + TaggedTemplateExpression = 183, + TypeAssertionExpression = 184, + ParenthesizedExpression = 185, + FunctionExpression = 186, + ArrowFunction = 187, + DeleteExpression = 188, + TypeOfExpression = 189, + VoidExpression = 190, + AwaitExpression = 191, + PrefixUnaryExpression = 192, + PostfixUnaryExpression = 193, + BinaryExpression = 194, + ConditionalExpression = 195, + TemplateExpression = 196, + YieldExpression = 197, + SpreadElement = 198, + ClassExpression = 199, + OmittedExpression = 200, + ExpressionWithTypeArguments = 201, + AsExpression = 202, + NonNullExpression = 203, + MetaProperty = 204, + TemplateSpan = 205, + SemicolonClassElement = 206, + Block = 207, + VariableStatement = 208, + EmptyStatement = 209, + ExpressionStatement = 210, + IfStatement = 211, + DoStatement = 212, + WhileStatement = 213, + ForStatement = 214, + ForInStatement = 215, + ForOfStatement = 216, + ContinueStatement = 217, + BreakStatement = 218, + ReturnStatement = 219, + WithStatement = 220, + SwitchStatement = 221, + LabeledStatement = 222, + ThrowStatement = 223, + TryStatement = 224, + DebuggerStatement = 225, + VariableDeclaration = 226, + VariableDeclarationList = 227, + FunctionDeclaration = 228, + ClassDeclaration = 229, + InterfaceDeclaration = 230, + TypeAliasDeclaration = 231, + EnumDeclaration = 232, + ModuleDeclaration = 233, + ModuleBlock = 234, + CaseBlock = 235, + NamespaceExportDeclaration = 236, + ImportEqualsDeclaration = 237, + ImportDeclaration = 238, + ImportClause = 239, + NamespaceImport = 240, + NamedImports = 241, + ImportSpecifier = 242, + ExportAssignment = 243, + ExportDeclaration = 244, + NamedExports = 245, + ExportSpecifier = 246, + MissingDeclaration = 247, + ExternalModuleReference = 248, + JsxElement = 249, + JsxSelfClosingElement = 250, + JsxOpeningElement = 251, + JsxClosingElement = 252, + JsxAttribute = 253, + JsxAttributes = 254, + JsxSpreadAttribute = 255, + JsxExpression = 256, + CaseClause = 257, + DefaultClause = 258, + HeritageClause = 259, + CatchClause = 260, + PropertyAssignment = 261, + ShorthandPropertyAssignment = 262, + SpreadAssignment = 263, + EnumMember = 264, + SourceFile = 265, + Bundle = 266, + JSDocTypeExpression = 267, + JSDocAllType = 268, + JSDocUnknownType = 269, + JSDocArrayType = 270, + JSDocUnionType = 271, + JSDocTupleType = 272, + JSDocNullableType = 273, + JSDocNonNullableType = 274, + JSDocRecordType = 275, + JSDocRecordMember = 276, + JSDocTypeReference = 277, + JSDocOptionalType = 278, + JSDocFunctionType = 279, + JSDocVariadicType = 280, + JSDocConstructorType = 281, + JSDocThisType = 282, + JSDocComment = 283, + JSDocTag = 284, + JSDocAugmentsTag = 285, + JSDocParameterTag = 286, + JSDocReturnTag = 287, + JSDocTypeTag = 288, + JSDocTemplateTag = 289, + JSDocTypedefTag = 290, + JSDocPropertyTag = 291, + JSDocTypeLiteral = 292, + JSDocLiteralType = 293, + SyntaxList = 294, + NotEmittedStatement = 295, + PartiallyEmittedExpression = 296, + MergeDeclarationMarker = 297, + EndOfDeclarationMarker = 298, + Count = 299, + FirstAssignment = 58, + LastAssignment = 70, + FirstCompoundAssignment = 59, + LastCompoundAssignment = 70, + FirstReservedWord = 72, + LastReservedWord = 107, + FirstKeyword = 72, + LastKeyword = 142, + FirstFutureReservedWord = 108, + LastFutureReservedWord = 116, + FirstTypeNode = 158, + LastTypeNode = 173, + FirstPunctuation = 17, + LastPunctuation = 70, FirstToken = 0, - LastToken = 141, + LastToken = 142, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 12, - FirstTemplateToken = 12, - LastTemplateToken = 15, - FirstBinaryOperator = 26, - LastBinaryOperator = 69, - FirstNode = 142, - FirstJSDocNode = 266, - LastJSDocNode = 295, - FirstJSDocTagNode = 282, - LastJSDocTagNode = 295, + LastLiteralToken = 13, + FirstTemplateToken = 13, + LastTemplateToken = 16, + FirstBinaryOperator = 27, + LastBinaryOperator = 70, + FirstNode = 143, + FirstJSDocNode = 267, + LastJSDocNode = 293, + FirstJSDocTagNode = 283, + LastJSDocTagNode = 293, } enum NodeFlags { None = 0, @@ -471,6 +469,7 @@ declare namespace ts { type EndOfFileToken = Token; type AtToken = Token; type ReadonlyToken = Token; + type AwaitKeywordToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { @@ -507,6 +506,7 @@ declare namespace ts { } interface TypeParameterDeclaration extends Declaration { kind: SyntaxKind.TypeParameter; + parent?: DeclarationWithTypeParameters; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -527,17 +527,19 @@ declare namespace ts { type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends Declaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList; + parent?: VariableDeclarationList | CatchClause; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; + parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } interface ParameterDeclaration extends Declaration { kind: SyntaxKind.Parameter; + parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; @@ -546,6 +548,7 @@ declare namespace ts { } interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; + parent?: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; @@ -569,7 +572,7 @@ declare namespace ts { _objectLiteralBrandBrand: any; name?: PropertyName; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -600,10 +603,12 @@ declare namespace ts { } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; @@ -638,41 +643,45 @@ declare namespace ts { } interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { kind: SyntaxKind.Constructor; + parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; } + /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; + parent?: ClassDeclaration | ClassExpression; } interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.GetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.SetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; + parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; - } - interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + interface FunctionTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.ConstructorType; } interface TypeReferenceNode extends TypeNode { @@ -701,15 +710,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface UnionOrIntersectionTypeNode extends TypeNode { - kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; + type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + interface UnionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType; types: NodeArray; } - interface UnionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.UnionType; - } - interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; + types: NodeArray; } interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; @@ -727,6 +735,7 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; + parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -741,7 +750,6 @@ declare namespace ts { } interface Expression extends Node { _expressionBrand: any; - contextualType?: Type; } interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; @@ -777,13 +785,13 @@ declare namespace ts { interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression { + interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression { + interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression { + interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } interface SuperExpression extends PrimaryExpression { @@ -891,16 +899,18 @@ declare namespace ts { } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; - trailingComment?: string; } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; + parent?: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; + parent?: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; + parent?: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { @@ -910,6 +920,7 @@ declare namespace ts { } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; + parent?: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -926,18 +937,18 @@ declare namespace ts { expression: Expression; } /** - * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to - * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be - * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type - * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) - **/ + * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to + * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be + * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type + * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) + */ interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, Declaration { kind: SyntaxKind.PropertyAccessExpression; @@ -972,6 +983,7 @@ declare namespace ts { } interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; + parent?: HeritageClause; expression: LeftHandSideExpression; typeArguments?: NodeArray; } @@ -979,7 +991,7 @@ declare namespace ts { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; - arguments: NodeArray; + arguments?: NodeArray; } interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; @@ -1017,9 +1029,11 @@ declare namespace ts { type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase { + parent?: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; + parent?: JsxElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } @@ -1030,24 +1044,30 @@ declare namespace ts { } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; + parent?: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; + parent?: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; + parent?: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + parent?: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; + containsOnlyWhiteSpaces: boolean; + parent?: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { @@ -1110,6 +1130,7 @@ declare namespace ts { } interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; + awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } @@ -1139,15 +1160,18 @@ declare namespace ts { } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; + parent?: SwitchStatement; clauses: NodeArray; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; + parent?: CaseBlock; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; + parent?: CaseBlock; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; @@ -1168,6 +1192,7 @@ declare namespace ts { } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; + parent?: TryStatement; variableDeclaration: VariableDeclaration; block: Block; } @@ -1203,8 +1228,9 @@ declare namespace ts { } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; - token: SyntaxKind; - types?: NodeArray; + parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; + token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; + types: NodeArray; } interface TypeAliasDeclaration extends DeclarationStatement { kind: SyntaxKind.TypeAliasDeclaration; @@ -1214,6 +1240,7 @@ declare namespace ts { } interface EnumMember extends Declaration { kind: SyntaxKind.EnumMember; + parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } @@ -1226,8 +1253,9 @@ declare namespace ts { type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; - name: Identifier | StringLiteral; - body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; + parent?: ModuleBody | SourceFile; + name: ModuleName; + body?: ModuleBody | JSDocNamespaceDeclaration; } type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { @@ -1241,74 +1269,101 @@ declare namespace ts { } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; + parent?: ModuleDeclaration; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; + /** + * One of: + * - import x = require("mod"); + * - import x = M.x; + */ interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; + parent?: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; + parent?: ImportEqualsDeclaration; expression?: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; + parent?: SourceFile | ModuleBlock; importClause?: ImportClause; + /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends Declaration { kind: SyntaxKind.ImportClause; + parent?: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends Declaration { kind: SyntaxKind.NamespaceImport; + parent?: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; - moduleReference: LiteralLikeNode; } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; + parent?: SourceFile | ModuleBlock; exportClause?: NamedExports; + /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; + parent?: ImportClause; elements: NodeArray; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; + parent?: ExportDeclaration; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends Declaration { kind: SyntaxKind.ImportSpecifier; + parent?: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends Declaration { kind: SyntaxKind.ExportSpecifier; + parent?: NamedExports; propertyName?: Identifier; name: Identifier; } type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; + parent?: SourceFile; isExportEquals?: boolean; expression: Expression; } interface FileReference extends TextRange { fileName: string; } + interface CheckJsDirective extends TextRange { + enabled: boolean; + } + type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; - kind: SyntaxKind; + kind: CommentKind; + } + interface SynthesizedComment extends CommentRange { + text: string; + pos: -1; + end: -1; } interface JSDocTypeExpression extends Node { kind: SyntaxKind.JSDocTypeExpression; @@ -1509,7 +1564,6 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Token; fileName: string; - path: Path; text: string; amdDependencies: AmdDependency[]; moduleName: string; @@ -1542,9 +1596,9 @@ declare namespace ts { useCaseSensitiveFileNames: boolean; readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[]; /** - * Gets a value indicating whether the specified path exists and is a file. - * @param path The path to test. - */ + * Gets a value indicating whether the specified path exists and is a file. + * @param path The path to test. + */ fileExists(path: string): boolean; readFile(path: string): string; } @@ -1577,7 +1631,7 @@ declare namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -1588,6 +1642,12 @@ declare namespace ts { */ getTypeChecker(): TypeChecker; } + interface CustomTransformers { + /** Custom transformers to evaluate before built-in transformations. */ + before?: TransformerFactory[]; + /** Custom transformers to evaluate after built-in transformations. */ + after?: TransformerFactory[]; + } interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; @@ -1635,8 +1695,16 @@ declare namespace ts { getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): BaseType[]; + getBaseTypeOfLiteralType(type: Type): Type; + getWidenedType(type: Type): Type; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; + /** Note that the resulting nodes cannot be checked. */ + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + /** Note that the resulting nodes cannot be checked. */ + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; + /** Note that the resulting nodes cannot be checked. */ + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -1661,6 +1729,7 @@ declare namespace ts { isUnknownSymbol(symbol: Symbol): boolean; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; @@ -1670,6 +1739,15 @@ declare namespace ts { tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; } + enum NodeBuilderFlags { + None = 0, + allowThisInObjectLiteral = 1, + allowQualifedNameInPlaceOfIdentifier = 2, + allowTypeParameterInQualifiedName = 4, + allowAnonymousIdentifier = 8, + allowEmptyUnionOrIntersection = 16, + allowEmptyTuple = 32, + } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; @@ -1878,7 +1956,6 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -1988,6 +2065,7 @@ declare namespace ts { messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; + source?: string; } enum DiagnosticCategory { Warning = 0, @@ -2010,9 +2088,11 @@ declare namespace ts { alwaysStrict?: boolean; baseUrl?: string; charset?: string; + checkJs?: boolean; declaration?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; @@ -2057,6 +2137,7 @@ declare namespace ts { skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strict?: boolean; strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; @@ -2239,13 +2320,15 @@ declare namespace ts { HelperName = 4096, ExportName = 8192, LocalName = 16384, - Indented = 32768, - NoIndentation = 65536, - AsyncFunctionBody = 131072, - ReuseTempVariableScope = 262144, - CustomPrologue = 524288, - NoHoisting = 1048576, - HasEndOfDeclarationMarker = 2097152, + InternalName = 32768, + Indented = 65536, + NoIndentation = 131072, + AsyncFunctionBody = 262144, + ReuseTempVariableScope = 524288, + CustomPrologue = 1048576, + NoHoisting = 2097152, + HasEndOfDeclarationMarker = 4194304, + Iterator = 8388608, } interface EmitHelper { readonly name: string; @@ -2259,6 +2342,95 @@ declare namespace ts { IdentifierName = 2, Unspecified = 3, } + interface TransformationContext { + /** Gets the compiler options supplied to the transformer. */ + getCompilerOptions(): CompilerOptions; + /** Starts a new lexical environment. */ + startLexicalEnvironment(): void; + /** Suspends the current lexical environment, usually after visiting a parameter list. */ + suspendLexicalEnvironment(): void; + /** Resumes a suspended lexical environment, usually before visiting a function body. */ + resumeLexicalEnvironment(): void; + /** Ends a lexical environment, returning any declarations. */ + endLexicalEnvironment(): Statement[]; + /** Hoists a function declaration to the containing scope. */ + hoistFunctionDeclaration(node: FunctionDeclaration): void; + /** Hoists a variable declaration to the containing scope. */ + hoistVariableDeclaration(node: Identifier): void; + /** Records a request for a non-scoped emit helper in the current context. */ + requestEmitHelper(helper: EmitHelper): void; + /** Gets and resets the requested non-scoped emit helpers. */ + readEmitHelpers(): EmitHelper[] | undefined; + /** Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ + enableSubstitution(kind: SyntaxKind): void; + /** Determines whether expression substitutions are enabled for the provided node. */ + isSubstitutionEnabled(node: Node): boolean; + /** + * Hook used by transformers to substitute expressions just before they + * are emitted by the pretty printer. + * + * NOTE: Transformation hooks should only be modified during `Transformer` initialization, + * before returning the `NodeTransformer` callback. + */ + onSubstituteNode: (hint: EmitHint, node: Node) => Node; + /** + * Enables before/after emit notifications in the pretty printer for the provided + * SyntaxKind. + */ + enableEmitNotification(kind: SyntaxKind): void; + /** + * Determines whether before/after emit notifications should be raised in the pretty + * printer when it emits a node. + */ + isEmitNotificationEnabled(node: Node): boolean; + /** + * Hook used to allow transformers to capture state before or after + * the printer emits a node. + * + * NOTE: Transformation hooks should only be modified during `Transformer` initialization, + * before returning the `NodeTransformer` callback. + */ + onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; + } + interface TransformationResult { + /** Gets the transformed source files. */ + transformed: T[]; + /** Gets diagnostics for the transformation. */ + diagnostics?: Diagnostic[]; + /** + * Gets a substitute for a node, if one is available; otherwise, returns the original node. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + substituteNode(hint: EmitHint, node: Node): Node; + /** + * Emits a node with possible notification. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. + */ + emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * Clean up EmitNode entries on any parse-tree nodes. + */ + dispose(): void; + } + /** + * A function that is used to initialize and return a `Transformer` callback, which in turn + * will be used to transform one or more nodes. + */ + type TransformerFactory = (context: TransformationContext) => Transformer; + /** + * A function that transforms a node. + */ + type Transformer = (node: T) => T; + /** + * A function that accepts and possibly transforms a node. + */ + type Visitor = (node: Node) => VisitResult; + type VisitResult = T | T[]; interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. @@ -2311,26 +2483,22 @@ declare namespace ts { /** * A hook used by the Printer to perform just-in-time substitution of a node. This is * primarily used by node transformations that need to substitute one node for another, - * such as replacing `myExportedVar` with `exports.myExportedVar`. A compatible - * implementation **must** invoke `emitCallback` eith the provided `hint` and either - * the provided `node`, or its substitute. + * such as replacing `myExportedVar` with `exports.myExportedVar`. * @param hint A hint indicating the intended purpose of the node. * @param node The node to emit. - * @param emitCallback A callback that, when invoked, will emit the node. * @example * ```ts * var printer = createPrinter(printerOptions, { - * onSubstituteNode(hint, node, emitCallback) { + * substituteNode(hint, node) { * // perform substitution if necessary... - * emitCallback(hint, node); + * return node; * } * }); * ``` */ - onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + substituteNode?(hint: EmitHint, node: Node): Node; } interface PrinterOptions { - target?: ScriptTarget; removeComments?: boolean; newLine?: NewLineKind; } @@ -2348,7 +2516,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.3.0"; + const version = "2.4.0"; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -2397,6 +2565,7 @@ declare namespace ts { directoryName: string; referenceCount: number; } + function getNodeMajorVersion(): number; let sys: System; } declare namespace ts { @@ -2437,15 +2606,15 @@ declare namespace ts { function tokenToString(t: SyntaxKind): string; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; - function isWhiteSpace(ch: number): boolean; + function isWhiteSpaceLike(ch: number): boolean; /** Does not include line breaks. For that, see isWhiteSpaceLike. */ function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; - function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; + function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ @@ -2487,9 +2656,9 @@ declare namespace ts { function getCombinedModifierFlags(node: Node): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** - * Checks to see if the locale is in the appropriate format, - * and if it is, attempts to set the appropriate language. - */ + * Checks to see if the locale is in the appropriate format, + * and if it is, attempts to set the appropriate language. + */ function validateLocaleAndSetLanguage(locale: string, sys: { getExecutingFilePath(): string; resolvePath(path: string): string; @@ -2549,35 +2718,80 @@ declare namespace ts { /** Create a unique name generated for a node. */ function getGeneratedNameForNode(node: Node): Identifier; function createToken(token: TKind): Token; - function createSuper(): PrimaryExpression; - function createThis(): PrimaryExpression; - function createNull(): PrimaryExpression; - function createTrue(): BooleanLiteral; - function createFalse(): BooleanLiteral; + function createSuper(): SuperExpression; + function createThis(): ThisExpression & Token; + function createNull(): NullLiteral & Token; + function createTrue(): BooleanLiteral & Token; + function createFalse(): BooleanLiteral & Token; function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; function createComputedPropertyName(expression: Expression): ComputedPropertyName; function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): SignatureDeclaration; + function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; + function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; + function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; + function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; + function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; + function createThisTypeNode(): ThisTypeNode; + function createLiteralTypeNode(literal: Expression): LiteralTypeNode; + function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode; + function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; + function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; + function createTypeQueryNode(exprName: EntityName): TypeQueryNode; + function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; + function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; + function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray): UnionOrIntersectionTypeNode; + function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; + function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; + function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode; + function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; + function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode; + function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode; + function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; + function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; + function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration; + function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; - function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; @@ -2586,20 +2800,20 @@ declare namespace ts { function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createCall(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -2621,11 +2835,11 @@ declare namespace ts { function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; - function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createClassExpression(modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; @@ -2637,33 +2851,33 @@ declare namespace ts { function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createBlock(statements: Statement[], multiLine?: boolean): Block; function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; - function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; function createEmptyStatement(): EmptyStatement; function createStatement(expression: Expression): ExpressionStatement; function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; - function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; function createWhile(expression: Expression, statement: Statement): WhileStatement; function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createFor(initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function createContinue(label?: string | Identifier): ContinueStatement; - function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; function createBreak(label?: string | Identifier): BreakStatement; - function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier | undefined): BreakStatement; function createReturn(expression?: Expression): ReturnStatement; - function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression | undefined): ReturnStatement; function createWith(expression: Expression, statement: Statement): WithStatement; function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; @@ -2672,40 +2886,40 @@ declare namespace ts { function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; function createThrow(expression: Expression): ThrowStatement; function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; - function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; + function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; function createModuleBlock(statements: Statement[]): ModuleBlock; function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined): ImportDeclaration; function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; function createNamedImports(elements: ImportSpecifier[]): NamedImports; function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; - function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; function createNamedExports(elements: ExportSpecifier[]): NamedExports; function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; - function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; @@ -2722,9 +2936,9 @@ declare namespace ts { function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; - function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; + function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; @@ -2734,9 +2948,9 @@ declare namespace ts { function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined): ShorthandPropertyAssignment; function createSpreadAssignment(expression: Expression): SpreadAssignment; - function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; @@ -2788,7 +3002,7 @@ declare namespace ts { /** * Gets flags that control emit behavior of a node. */ - function getEmitFlags(node: Node): EmitFlags; + function getEmitFlags(node: Node): EmitFlags | undefined; /** * Sets flags that control emit behavior of a node. */ @@ -2800,15 +3014,15 @@ declare namespace ts { /** * Sets a custom text range to use when emitting source maps. */ - function setSourceMapRange(node: T, range: TextRange): T; + function setSourceMapRange(node: T, range: TextRange | undefined): T; /** * Gets the TextRange to use for source maps for a token of a node. */ - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange | undefined; /** * Sets the TextRange to use for source maps for a token of a node. */ - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange | undefined): T; /** * Gets a custom text range to use when emitting comments. */ @@ -2817,6 +3031,12 @@ declare namespace ts { * Sets a custom text range to use when emitting comments. */ function setCommentRange(node: T, range: TextRange): T; + function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined; + function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]): T; + function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; + function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; + function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; + function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; /** * Gets the constant value to emit for an expression. */ @@ -2845,7 +3065,7 @@ declare namespace ts { * Moves matching emit helpers from a source node to a target node. */ function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function setOriginalNode(node: T, original: Node): T; + function setOriginalNode(node: T, original: Node | undefined): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2872,13 +3092,13 @@ declare namespace ts { */ function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; /** * Cached module resolutions per containing directory. @@ -2903,6 +3123,87 @@ declare namespace ts { function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } +declare namespace ts { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + /** + * Starts a new lexical environment and visits a statement list, ending the lexical environment + * and merging hoisted declarations upon completion. + */ + function visitLexicalEnvironment(statements: NodeArray, visitor: Visitor, context: TransformationContext, start?: number, ensureUseStrict?: boolean): NodeArray; + /** + * Starts a new lexical environment and visits a parameter list, suspending the lexical + * environment upon completion. + */ + function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + /** + * Resumes a suspended lexical environment and visits a function body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + function visitFunctionBody(node: FunctionBody, visitor: Visitor, context: TransformationContext): FunctionBody; + /** + * Resumes a suspended lexical environment and visits a function body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + function visitFunctionBody(node: FunctionBody | undefined, visitor: Visitor, context: TransformationContext): FunctionBody | undefined; + /** + * Resumes a suspended lexical environment and visits a concise body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + /** + * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. + * + * @param node The Node whose children will be visited. + * @param visitor The callback used to visit each child. + * @param context A lexical environment context for the visitor. + */ + function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; + /** + * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. + * + * @param node The Node whose children will be visited. + * @param visitor The callback used to visit each child. + * @param context A lexical environment context for the visitor. + */ + function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; +} declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } @@ -2923,31 +3224,31 @@ declare namespace ts { declare namespace ts { function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ + * Read tsconfig.json file + * @param fileName The path to the config file + */ function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic; }; /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { config?: any; error?: Diagnostic; }; /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @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, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; @@ -2973,12 +3274,14 @@ declare namespace ts { getText(sourceFile?: SourceFile): string; getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; + forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; } interface Symbol { getFlags(): SymbolFlags; getName(): string; getDeclarations(): Declaration[]; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -2995,10 +3298,11 @@ declare namespace ts { } interface Signature { getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; + getTypeParameters(): TypeParameter[]; getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -3007,6 +3311,9 @@ declare namespace ts { getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } + interface SourceFileLike { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the * snapshot is observably immutable. i.e. the same calls with the same parameters will return @@ -3065,6 +3372,10 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; getDirectories?(directoryName: string): string[]; + /** + * Gets a set of custom transformers to use during emit. + */ + getCustomTransformers?(): CustomTransformers | undefined; } interface LanguageService { cleanupSemanticCache(): void; @@ -3110,7 +3421,7 @@ declare namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; dispose(): void; @@ -3186,19 +3497,20 @@ declare namespace ts { /** The position in newText the caret should point to after the insertion. */ caretOffset: number; } - interface RenameLocation { + interface DocumentSpan { textSpan: TextSpan; fileName: string; } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; + interface RenameLocation extends DocumentSpan { + } + interface ReferenceEntry extends DocumentSpan { isWriteAccess: boolean; isDefinition: boolean; + isInString?: true; } - interface ImplementationLocation { - textSpan: TextSpan; - fileName: string; + interface ImplementationLocation extends DocumentSpan { + kind: string; + displayParts: SymbolDisplayPart[]; } interface DocumentHighlights { fileName: string; @@ -3212,6 +3524,7 @@ declare namespace ts { } interface HighlightSpan { fileName?: string; + isInString?: true; textSpan: TextSpan; kind: string; } @@ -3324,12 +3637,17 @@ declare namespace ts { text: string; kind: string; } + interface JSDocTagInfo { + name: string; + text?: string; + } interface QuickInfo { kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; @@ -3360,6 +3678,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } /** * Represents a set of signature help items, and the preferred item that should be selected. @@ -3386,10 +3705,10 @@ declare namespace ts { kindModifiers: string; sortText: string; /** - * An optional span that indicates the text to be replaced by this completion item. It will be - * set if the required span differs from the one generated by the default replacement behavior and should - * be used in that case - */ + * An optional span that indicates the text to be replaced by this completion item. It will be + * set if the required span differs from the one generated by the default replacement behavior and should + * be used in that case + */ replacementSpan?: TextSpan; } interface CompletionEntryDetails { @@ -3398,6 +3717,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ @@ -3407,9 +3727,9 @@ declare namespace ts { /** The text to display in the editor for the collapsed region. */ bannerText: string; /** - * Whether or not this region should be automatically collapsed when - * the 'Collapse to Definitions' command is invoked. - */ + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ autoCollapse: boolean; } interface EmitOutput { @@ -3497,7 +3817,7 @@ declare namespace ts { const typeElement = "type"; /** enum E */ const enumElement = "enum"; - const enumMemberElement = "const"; + const enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. @@ -3542,7 +3862,7 @@ declare namespace ts { const externalModuleName = "external module name"; /** * - **/ + */ const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { @@ -3612,61 +3932,61 @@ declare namespace ts { } declare namespace ts { /** - * The document registry represents a store of SourceFile objects that can be shared between - * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) - * of files in the context. - * SourceFile objects account for most of the memory usage by the language service. Sharing - * the same DocumentRegistry instance between different instances of LanguageService allow - * for more efficient memory utilization since all projects will share at least the library - * file (lib.d.ts). - * - * A more advanced use of the document registry is to serialize sourceFile objects to disk - * and re-hydrate them when needed. - * - * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it - * to all subsequent createLanguageService calls. - */ + * The document registry represents a store of SourceFile objects that can be shared between + * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) + * of files in the context. + * SourceFile objects account for most of the memory usage by the language service. Sharing + * the same DocumentRegistry instance between different instances of LanguageService allow + * for more efficient memory utilization since all projects will share at least the library + * file (lib.d.ts). + * + * A more advanced use of the document registry is to serialize sourceFile objects to disk + * and re-hydrate them when needed. + * + * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it + * to all subsequent createLanguageService calls. + */ interface DocumentRegistry { /** - * Request a stored SourceFile with a given fileName and compilationSettings. - * The first call to acquire will call createLanguageServiceSourceFile to generate - * the SourceFile if was not found in the registry. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - */ + * Request a stored SourceFile with a given fileName and compilationSettings. + * The first call to acquire will call createLanguageServiceSourceFile to generate + * the SourceFile if was not found in the registry. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @parm scriptSnapshot Text of the file. Only used if the file was not found + * in the registry and a new one was created. + * @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, scriptKind?: ScriptKind): SourceFile; acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, 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 - * to get an updated SourceFile. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @param scriptSnapshot Text of the file. - * @param version Current version of the file. - */ + * Request an updated version of an already existing SourceFile with a given fileName + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile + * to get an updated SourceFile. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. + */ updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; /** - * Informs the DocumentRegistry that a file is not needed any longer. - * - * Note: It is not allowed to call release on a SourceFile that was not acquired from - * this registry originally. - * - * @param fileName The name of the file to be released - * @param compilationSettings The compilation settings used to acquire the file - */ + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; reportStats(): string; @@ -3710,11 +4030,20 @@ declare namespace ts { function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ function getDefaultLibFilePath(options: CompilerOptions): string; } +declare namespace ts { + /** + * Transform one or more nodes using the supplied transformers. + * @param source A single `Node` or an array of `Node` objects. + * @param transformers An array of `TransformerFactory` callbacks used to process the transformation. + * @param compilerOptions Optional compiler options. + */ + function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; +} export = ts; \ No newline at end of file diff --git a/lib/typescript.js b/lib/typescript.js index a8db5a7997f..4fe0eb9bf25 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -13,6 +13,14 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || @@ -44,355 +52,353 @@ var ts; SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 126] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 127] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 128] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 129] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 130] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 131] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 132] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 133] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 134] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 135] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 136] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 137] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 138] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 139] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 140] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 141] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 142] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 143] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 144] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 145] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 146] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 147] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 149] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 151] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 152] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 153] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 154] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 155] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 156] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 157] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 158] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 159] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 160] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 161] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 162] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 163] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 164] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 165] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 166] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 167] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 168] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 169] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 170] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 171] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 172] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 173] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 174] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 175] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 176] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 177] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 178] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 179] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 180] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 181] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 182] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 183] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 184] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 185] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 187] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 188] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 189] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 190] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 191] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 192] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 193] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 194] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 195] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 196] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 197] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 198] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 199] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 200] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 201] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 202] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 203] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 204] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 205] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 206] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 207] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 208] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 209] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 210] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 211] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 212] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 213] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 214] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 215] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 216] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 217] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 218] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 219] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 220] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 221] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 222] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 223] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 224] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 225] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 226] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 227] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 228] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 229] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 230] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 231] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 232] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 233] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 234] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 235] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 236] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 237] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 238] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 239] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 240] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 241] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 242] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 243] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 244] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 245] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 246] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 247] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 248] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 249] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 250] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 251] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 252] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 253] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 254] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 255] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 256] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 257] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 258] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 259] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 260] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 261] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 262] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 263] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 264] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; + SyntaxKind[SyntaxKind["SourceFile"] = 265] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 266] = "Bundle"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 267] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 268] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 269] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 270] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 271] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 272] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 273] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 274] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 275] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 276] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 277] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 278] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 279] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 280] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 281] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 282] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 283] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 284] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 285] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 286] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 287] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 288] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 289] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 290] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 291] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 293] = "JSDocLiteralType"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 294] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 295] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 296] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 297] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 298] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 299] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 142] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 158] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 173] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 142] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 143] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 267] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 293] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 283] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 293] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -471,6 +477,17 @@ var ts; GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + /* @internal */ + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 2] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["HexSpecifier"] = 8] = "HexSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinarySpecifier"] = 16] = "BinarySpecifier"; + NumericLiteralFlags[NumericLiteralFlags["OctalSpecifier"] = 32] = "OctalSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalSpecifier"] = 48] = "BinaryOrOctalSpecifier"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -507,6 +524,16 @@ var ts; // Diagnostics were produced and outputs were generated in spite of them. ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + NodeBuilderFlags[NodeBuilderFlags["allowThisInObjectLiteral"] = 1] = "allowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["allowQualifedNameInPlaceOfIdentifier"] = 2] = "allowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowTypeParameterInQualifiedName"] = 4] = "allowTypeParameterInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["allowAnonymousIdentifier"] = 8] = "allowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyUnionOrIntersection"] = 16] = "allowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyTuple"] = 32] = "allowEmptyTuple"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); var TypeFormatFlags; (function (TypeFormatFlags) { TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; @@ -555,8 +582,7 @@ var ts; TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator - * metadata */ + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { @@ -655,13 +681,15 @@ var ts; (function (CheckFlags) { CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; - CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; - CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; - CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; - CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; - CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; - CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; - CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod"; + CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 16] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; + CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); /* @internal */ var NodeCheckFlags; @@ -761,7 +789,6 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -786,6 +813,8 @@ var ts; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; /// this.name = expr SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + // F.name = expr + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property"; })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -1081,13 +1110,15 @@ var ts; EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; - EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; - EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName"; + EmitFlags[EmitFlags["Indented"] = 65536] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /** * Used by the checker, this enum keeps track of external emit helpers that should be type @@ -1104,8 +1135,20 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values"; + ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read"; + ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 2048] = "AsyncGenerator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 4096] = "AsyncDelegator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 8192] = "AsyncValues"; + // Helpers included by ES2015 for..of + ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; + // Helpers included by ES2017 for..await..of + ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 8192] = "ForAwaitOfIncludes"; + // Helpers included by ES2015 spread + ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes"; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; - ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 8192] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); var EmitHint; (function (EmitHint) { @@ -1214,7 +1257,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.3.0"; + ts.version = "2.4.0"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -1239,7 +1282,7 @@ var ts; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -1407,6 +1450,26 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Iterates through the parent chain of a node and performs the callback on each parent until the callback + * returns a truthy value, then returns that value. + * If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit" + * At that point findAncestor returns undefined. + */ + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; function zipWith(arrayA, arrayB, callback) { Debug.assert(arrayA.length === arrayB.length); for (var i = 0; i < arrayA.length; i++) { @@ -2062,11 +2125,10 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - /** Shims `Array.from`. */ - function arrayFrom(iterator) { + function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { - result.push(value); + result.push(map ? map(value) : value); } return result; var _b; @@ -2125,10 +2187,10 @@ var ts; } for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { var arg = args_1[_a]; - for (var _b = 0, _c = getOwnKeys(arg); _b < _c.length; _b++) { - var p = _c[_b]; - t[p] = arg[p]; - } + for (var p in arg) + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } } return t; } @@ -2484,7 +2546,7 @@ var ts; ts.normalizeSlashes = normalizeSlashes; /** * Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") - */ + */ function getRootLength(path) { if (path.charCodeAt(0) === 47 /* slash */) { if (path.charCodeAt(1) !== 47 /* slash */) @@ -3427,144 +3489,30 @@ var ts; } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; + function isCheckJsEnabledForFile(sourceFile, compilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; })(ts || (ts = {})); /// var ts; (function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var shell = new ActiveXObject("WScript.Shell"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1 /*binary*/; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - // Write characters in UTF-8 encoding - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). - // If not, start from position 0, as the BOM will be added automatically when charset==utf8. - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2 /*overwrite*/); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function getDirectories(path) { - var folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - function getAccessibleFileSystemEntries(path) { - try { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - var directories = getNames(folder.subfolders); - return { files: files, directories: directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function readDirectory(path, extensions, excludes, includes) { - return ts.matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - var wscriptSystem = { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return shell.CurrentDirectory; - }, - getDirectories: getDirectories, - getEnvironmentVariable: function (name) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings("%" + name + "%"); - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; + function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; } + var version = process.version; + if (!version) { + return undefined; + } + var dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + ts.getNodeMajorVersion = getNodeMajorVersion; + ts.sys = (function () { function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); @@ -3631,9 +3579,8 @@ var ts; } } var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } + var nodeVersion = getNodeMajorVersion(); + var isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive() { // win32\win64 are case insensitive platforms if (platform === "win32" || platform === "win64") { @@ -3654,7 +3601,7 @@ var ts; if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, // flip all byte pairs and treat as little endian. - len &= ~1; + len &= ~1; // Round down to a multiple of 2 for (var i = 0; i < len; i += 2) { var temp = buffer[i]; buffer[i] = buffer[i + 1]; @@ -3681,7 +3628,7 @@ var ts; var fd; try { fd = _fs.openSync(fileName, "w"); - _fs.writeSync(fd, data, undefined, "utf8"); + _fs.writeSync(fd, data, /*position*/ undefined, "utf8"); } finally { if (fd !== undefined) { @@ -3785,13 +3732,11 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; - if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { - // do nothing if either - // - target folder does not exist - // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) + if (!directoryExists(directoryName)) { + // do nothing if target folder does not exist return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { @@ -3805,11 +3750,7 @@ var ts; // When deleting a file, the passed baseFileName is null callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName))); } - ; }); - function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; - } }, resolvePath: function (path) { return _path.resolve(path); @@ -3928,9 +3869,6 @@ var ts; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify @@ -4005,11 +3943,11 @@ var ts; Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", message: "The return type of an async function must either be a valid promise or must not contain a callable 'then' member." }, + A_promise_must_have_a_then_method: { code: 1059, category: ts.DiagnosticCategory.Error, key: "A_promise_must_have_a_then_method_1059", message: "A promise must have a 'then' method." }, + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: { code: 1060, category: ts.DiagnosticCategory.Error, key: "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", message: "The first parameter of the 'then' method of a promise must be a callback." }, 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." }, + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "Type 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." }, @@ -4034,6 +3972,7 @@ var ts; Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: { code: 1103, category: ts.DiagnosticCategory.Error, key: "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", message: "A 'for-await-of' statement is only allowed within an async function or async generator." }, A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, @@ -4041,7 +3980,7 @@ var ts; Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'." }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, @@ -4073,9 +4012,9 @@ var ts; 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_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." }, - 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" }, + 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" }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized." }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, @@ -4124,8 +4063,8 @@ var ts; Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_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." }, @@ -4177,6 +4116,9 @@ var ts; A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1320, category: ts.DiagnosticCategory.Error, key: "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", message: "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1321, category: ts.DiagnosticCategory.Error, key: "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", message: "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1322, category: ts.DiagnosticCategory.Error, key: "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", message: "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -4238,13 +4180,13 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'." }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, @@ -4284,12 +4226,12 @@ var ts; The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class." }, The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - 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_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}'." }, 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}'." }, @@ -4298,19 +4240,19 @@ var ts; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, 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}'" }, + 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_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}'" }, + 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." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged." }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged." }, Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name." }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'." }, Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'." }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, @@ -4319,18 +4261,20 @@ 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." }, + Class_0_used_before_its_declaration: { code: 2449, category: ts.DiagnosticCategory.Error, key: "Class_0_used_before_its_declaration_2449", message: "Class '{0}' used before its declaration." }, + Enum_0_used_before_its_declaration: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Enum_0_used_before_its_declaration_2450", message: "Enum '{0}' used before its declaration." }, 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." }, Variable_0_is_used_before_being_assigned: { code: 2454, category: ts.DiagnosticCategory.Error, key: "Variable_0_is_used_before_being_assigned_2454", message: "Variable '{0}' is used before being assigned." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'." }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern." }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -4351,13 +4295,13 @@ var ts; let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, 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}'" }, + 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_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, 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." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause." }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, @@ -4369,6 +4313,7 @@ var ts; A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: { code: 2504, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", message: "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, @@ -4383,6 +4328,7 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, + An_async_iterator_must_have_a_next_method: { code: 2519, category: ts.DiagnosticCategory.Error, key: "An_async_iterator_must_have_a_next_method_2519", message: "An async iterator must have a 'next()' method." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", message: "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method." }, @@ -4410,25 +4356,29 @@ var ts; Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, + The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: { code: 2547, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", message: "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property." }, + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2548, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", message: "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2549, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", message: "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: { code: 2550, category: ts.DiagnosticCategory.Error, key: "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", message: "Generic type instantiation is excessively deep and possibly infinite." }, 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." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'." }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property." }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property." }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React." }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, - Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element." }, + Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'." }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", message: "Cannot export '{0}'. Only local declarations can be exported from a module." }, @@ -4460,7 +4410,6 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, - A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { code: 2693, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", message: "'{0}' only refers to a type, but is being used as a value here." }, @@ -4473,11 +4422,14 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, - The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference." }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property." }, An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, + Cannot_use_namespace_0_as_a_value: { code: 2708, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_value_2708", message: "Cannot use namespace '{0}' as a value." }, + Cannot_use_namespace_0_as_a_type: { code: 2709, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_type_2709", message: "Cannot use namespace '{0}' as a type." }, + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: { code: 2710, category: ts.DiagnosticCategory.Error, key: "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", message: "'{0}' are specified twice. The attribute named '{0}' will be overwritten." }, 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}'." }, @@ -4557,12 +4509,11 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { code: 5011, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011", message: "File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}." }, Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", message: "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, @@ -4571,12 +4522,12 @@ var ts; A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, 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}'" }, + 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}'." }, 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" }, + 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." }, Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." }, Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, @@ -4594,11 +4545,11 @@ var ts; Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'." }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -4618,7 +4569,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_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}" }, + Argument_for_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}." }, 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}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, @@ -4640,18 +4591,18 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context (experimental)." }, Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'." }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, 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}." }, 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." }, - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", message: "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit" }, Enable_tracing_of_the_name_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_name_resolution_process_6085", message: "Enable tracing of the name 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}'." }, @@ -4673,12 +4624,12 @@ var ts; 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_0_field_in_package_json_to_be_string_got_1: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", message: "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'." }, - 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" }, + 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." }, Enable_strict_null_checks: { code: 6113, category: ts.DiagnosticCategory.Message, key: "Enable_strict_null_checks_6113", message: "Enable strict null checks." }, Unknown_option_excludes_Did_you_mean_exclude: { code: 6114, category: ts.DiagnosticCategory.Error, key: "Unknown_option_excludes_Did_you_mean_exclude_6114", message: "Unknown option 'excludes'. Did you mean 'exclude'?" }, @@ -4688,26 +4639,26 @@ var ts; Resolving_from_node_modules_folder: { code: 6118, category: ts.DiagnosticCategory.Message, key: "Resolving_from_node_modules_folder_6118", message: "Resolving from node_modules folder..." }, Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { code: 6119, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", message: "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========" }, Type_reference_directive_0_was_not_resolved: { code: 6120, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_not_resolved_6120", message: "======== Type reference directive '{0}' was not resolved. ========" }, - Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'" }, + Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'." }, Root_directory_cannot_be_determined_skipping_primary_search_paths: { code: 6122, category: ts.DiagnosticCategory.Message, key: "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", message: "Root directory cannot be determined, skipping primary search paths." }, Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { code: 6123, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", message: "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========" }, Type_declaration_files_to_be_included_in_compilation: { code: 6124, category: ts.DiagnosticCategory.Message, key: "Type_declaration_files_to_be_included_in_compilation_6124", message: "Type declaration files to be included in compilation." }, - Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'" }, + Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'." }, Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { code: 6126, category: ts.DiagnosticCategory.Message, key: "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", message: "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { code: 6127, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", message: "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========" }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" }, The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." }, - Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, + Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'." }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, - File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it." }, _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files." }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file." }, Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, @@ -4715,6 +4666,40 @@ var ts; Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, + Show_diagnostic_information: { code: 6149, category: ts.DiagnosticCategory.Message, key: "Show_diagnostic_information_6149", message: "Show diagnostic information." }, + Show_verbose_diagnostic_information: { code: 6150, category: ts.DiagnosticCategory.Message, key: "Show_verbose_diagnostic_information_6150", message: "Show verbose diagnostic information." }, + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: { code: 6151, category: ts.DiagnosticCategory.Message, key: "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", message: "Emit a single file with source maps instead of having a separate file." }, + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: { code: 6152, category: ts.DiagnosticCategory.Message, key: "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", message: "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set." }, + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: { code: 6153, category: ts.DiagnosticCategory.Message, key: "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", message: "Transpile each file as a separate module (similar to 'ts.transpileModule')." }, + Print_names_of_generated_files_part_of_the_compilation: { code: 6154, category: ts.DiagnosticCategory.Message, key: "Print_names_of_generated_files_part_of_the_compilation_6154", message: "Print names of generated files part of the compilation." }, + Print_names_of_files_part_of_the_compilation: { code: 6155, category: ts.DiagnosticCategory.Message, key: "Print_names_of_files_part_of_the_compilation_6155", message: "Print names of files part of the compilation." }, + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: { code: 6156, category: ts.DiagnosticCategory.Message, key: "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", message: "The locale used when displaying messages to the user (e.g. 'en-us')" }, + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: { code: 6157, category: ts.DiagnosticCategory.Message, key: "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", message: "Do not generate custom helper functions like '__extends' in compiled output." }, + Do_not_include_the_default_library_file_lib_d_ts: { code: 6158, category: ts.DiagnosticCategory.Message, key: "Do_not_include_the_default_library_file_lib_d_ts_6158", message: "Do not include the default library file (lib.d.ts)." }, + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: { code: 6159, category: ts.DiagnosticCategory.Message, key: "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", message: "Do not add triple-slash references or imported modules to the list of compiled files." }, + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: { code: 6160, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", message: "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files." }, + List_of_folders_to_include_type_definitions_from: { code: 6161, category: ts.DiagnosticCategory.Message, key: "List_of_folders_to_include_type_definitions_from_6161", message: "List of folders to include type definitions from." }, + Disable_size_limitations_on_JavaScript_projects: { code: 6162, category: ts.DiagnosticCategory.Message, key: "Disable_size_limitations_on_JavaScript_projects_6162", message: "Disable size limitations on JavaScript projects." }, + The_character_set_of_the_input_files: { code: 6163, category: ts.DiagnosticCategory.Message, key: "The_character_set_of_the_input_files_6163", message: "The character set of the input files." }, + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: { code: 6164, category: ts.DiagnosticCategory.Message, key: "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", message: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." }, + Do_not_truncate_error_messages: { code: 6165, category: ts.DiagnosticCategory.Message, key: "Do_not_truncate_error_messages_6165", message: "Do not truncate error messages." }, + Output_directory_for_generated_declaration_files: { code: 6166, category: ts.DiagnosticCategory.Message, key: "Output_directory_for_generated_declaration_files_6166", message: "Output directory for generated declaration files." }, + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: { code: 6167, category: ts.DiagnosticCategory.Message, key: "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", message: "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'." }, + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: { code: 6168, category: ts.DiagnosticCategory.Message, key: "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", message: "List of root folders whose combined content represents the structure of the project at runtime." }, + Show_all_compiler_options: { code: 6169, category: ts.DiagnosticCategory.Message, key: "Show_all_compiler_options_6169", message: "Show all compiler options." }, + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: { code: 6170, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", message: "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file" }, + Command_line_Options: { code: 6171, category: ts.DiagnosticCategory.Message, key: "Command_line_Options_6171", message: "Command-line Options" }, + Basic_Options: { code: 6172, category: ts.DiagnosticCategory.Message, key: "Basic_Options_6172", message: "Basic Options" }, + Strict_Type_Checking_Options: { code: 6173, category: ts.DiagnosticCategory.Message, key: "Strict_Type_Checking_Options_6173", message: "Strict Type-Checking Options" }, + Module_Resolution_Options: { code: 6174, category: ts.DiagnosticCategory.Message, key: "Module_Resolution_Options_6174", message: "Module Resolution Options" }, + Source_Map_Options: { code: 6175, category: ts.DiagnosticCategory.Message, key: "Source_Map_Options_6175", message: "Source Map Options" }, + Additional_Checks: { code: 6176, category: ts.DiagnosticCategory.Message, key: "Additional_Checks_6176", message: "Additional Checks" }, + Experimental_Options: { code: 6177, category: ts.DiagnosticCategory.Message, key: "Experimental_Options_6177", message: "Experimental Options" }, + Advanced_Options: { code: 6178, category: ts.DiagnosticCategory.Message, key: "Advanced_Options_6178", message: "Advanced Options" }, + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: { code: 6179, category: ts.DiagnosticCategory.Message, key: "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", message: "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'." }, + Enable_all_strict_type_checking_options: { code: 6180, category: ts.DiagnosticCategory.Message, key: "Enable_all_strict_type_checking_options_6180", message: "Enable all strict type-checking options." }, + List_of_language_service_plugins: { code: 6181, category: ts.DiagnosticCategory.Message, key: "List_of_language_service_plugins_6181", message: "List of language service plugins." }, + Scoped_package_detected_looking_in_0: { code: 6182, category: ts.DiagnosticCategory.Message, key: "Scoped_package_detected_looking_in_0_6182", message: "Scoped package detected, looking in '{0}'" }, 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." }, @@ -4732,7 +4717,7 @@ var ts; _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists." }, Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, @@ -4741,6 +4726,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, + Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: { code: 7035, category: ts.DiagnosticCategory.Error, key: "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", message: "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4764,14 +4750,14 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + 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." }, 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." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" }, Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, @@ -4780,17 +4766,24 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: '{0}'." }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig." }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, - Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, - Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, - Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}." }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}." }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." }, + Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." }, + Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'." }, + Disable_checking_for_this_file: { code: 90018, category: ts.DiagnosticCategory.Message, key: "Disable_checking_for_this_file_90018", message: "Disable checking for this file." }, + Ignore_this_error_message: { code: 90019, category: ts.DiagnosticCategory.Message, key: "Ignore_this_error_message_90019", message: "Ignore this error message." }, + Initialize_property_0_in_the_constructor: { code: 90020, category: ts.DiagnosticCategory.Message, key: "Initialize_property_0_in_the_constructor_90020", message: "Initialize property '{0}' in the constructor." }, + Initialize_static_property_0: { code: 90021, category: ts.DiagnosticCategory.Message, key: "Initialize_static_property_0_90021", message: "Initialize static property '{0}'." }, Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, + Report_errors_in_js_files: { code: 8019, category: ts.DiagnosticCategory.Message, key: "Report_errors_in_js_files_8019", message: "Report errors in .js files." }, }; })(ts || (ts = {})); /// @@ -4799,135 +4792,135 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 70 /* Identifier */; + return token >= 71 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMapFromTemplate({ - "abstract": 116 /* AbstractKeyword */, - "any": 118 /* AnyKeyword */, - "as": 117 /* AsKeyword */, - "boolean": 121 /* BooleanKeyword */, - "break": 71 /* BreakKeyword */, - "case": 72 /* CaseKeyword */, - "catch": 73 /* CatchKeyword */, - "class": 74 /* ClassKeyword */, - "continue": 76 /* ContinueKeyword */, - "const": 75 /* ConstKeyword */, - "constructor": 122 /* ConstructorKeyword */, - "debugger": 77 /* DebuggerKeyword */, - "declare": 123 /* DeclareKeyword */, - "default": 78 /* DefaultKeyword */, - "delete": 79 /* DeleteKeyword */, - "do": 80 /* DoKeyword */, - "else": 81 /* ElseKeyword */, - "enum": 82 /* EnumKeyword */, - "export": 83 /* ExportKeyword */, - "extends": 84 /* ExtendsKeyword */, - "false": 85 /* FalseKeyword */, - "finally": 86 /* FinallyKeyword */, - "for": 87 /* ForKeyword */, - "from": 139 /* FromKeyword */, - "function": 88 /* FunctionKeyword */, - "get": 124 /* GetKeyword */, - "if": 89 /* IfKeyword */, - "implements": 107 /* ImplementsKeyword */, - "import": 90 /* ImportKeyword */, - "in": 91 /* InKeyword */, - "instanceof": 92 /* InstanceOfKeyword */, - "interface": 108 /* InterfaceKeyword */, - "is": 125 /* IsKeyword */, - "keyof": 126 /* KeyOfKeyword */, - "let": 109 /* LetKeyword */, - "module": 127 /* ModuleKeyword */, - "namespace": 128 /* NamespaceKeyword */, - "never": 129 /* NeverKeyword */, - "new": 93 /* NewKeyword */, - "null": 94 /* NullKeyword */, - "number": 132 /* NumberKeyword */, - "object": 133 /* ObjectKeyword */, - "package": 110 /* PackageKeyword */, - "private": 111 /* PrivateKeyword */, - "protected": 112 /* ProtectedKeyword */, - "public": 113 /* PublicKeyword */, - "readonly": 130 /* ReadonlyKeyword */, - "require": 131 /* RequireKeyword */, - "global": 140 /* GlobalKeyword */, - "return": 95 /* ReturnKeyword */, - "set": 134 /* SetKeyword */, - "static": 114 /* StaticKeyword */, - "string": 135 /* StringKeyword */, - "super": 96 /* SuperKeyword */, - "switch": 97 /* SwitchKeyword */, - "symbol": 136 /* SymbolKeyword */, - "this": 98 /* ThisKeyword */, - "throw": 99 /* ThrowKeyword */, - "true": 100 /* TrueKeyword */, - "try": 101 /* TryKeyword */, - "type": 137 /* TypeKeyword */, - "typeof": 102 /* TypeOfKeyword */, - "undefined": 138 /* UndefinedKeyword */, - "var": 103 /* VarKeyword */, - "void": 104 /* VoidKeyword */, - "while": 105 /* WhileKeyword */, - "with": 106 /* WithKeyword */, - "yield": 115 /* YieldKeyword */, - "async": 119 /* AsyncKeyword */, - "await": 120 /* AwaitKeyword */, - "of": 141 /* OfKeyword */, - "{": 16 /* OpenBraceToken */, - "}": 17 /* CloseBraceToken */, - "(": 18 /* OpenParenToken */, - ")": 19 /* CloseParenToken */, - "[": 20 /* OpenBracketToken */, - "]": 21 /* CloseBracketToken */, - ".": 22 /* DotToken */, - "...": 23 /* DotDotDotToken */, - ";": 24 /* SemicolonToken */, - ",": 25 /* CommaToken */, - "<": 26 /* LessThanToken */, - ">": 28 /* GreaterThanToken */, - "<=": 29 /* LessThanEqualsToken */, - ">=": 30 /* GreaterThanEqualsToken */, - "==": 31 /* EqualsEqualsToken */, - "!=": 32 /* ExclamationEqualsToken */, - "===": 33 /* EqualsEqualsEqualsToken */, - "!==": 34 /* ExclamationEqualsEqualsToken */, - "=>": 35 /* EqualsGreaterThanToken */, - "+": 36 /* PlusToken */, - "-": 37 /* MinusToken */, - "**": 39 /* AsteriskAsteriskToken */, - "*": 38 /* AsteriskToken */, - "/": 40 /* SlashToken */, - "%": 41 /* PercentToken */, - "++": 42 /* PlusPlusToken */, - "--": 43 /* MinusMinusToken */, - "<<": 44 /* LessThanLessThanToken */, - ">": 45 /* GreaterThanGreaterThanToken */, - ">>>": 46 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 47 /* AmpersandToken */, - "|": 48 /* BarToken */, - "^": 49 /* CaretToken */, - "!": 50 /* ExclamationToken */, - "~": 51 /* TildeToken */, - "&&": 52 /* AmpersandAmpersandToken */, - "||": 53 /* BarBarToken */, - "?": 54 /* QuestionToken */, - ":": 55 /* ColonToken */, - "=": 57 /* EqualsToken */, - "+=": 58 /* PlusEqualsToken */, - "-=": 59 /* MinusEqualsToken */, - "*=": 60 /* AsteriskEqualsToken */, - "**=": 61 /* AsteriskAsteriskEqualsToken */, - "/=": 62 /* SlashEqualsToken */, - "%=": 63 /* PercentEqualsToken */, - "<<=": 64 /* LessThanLessThanEqualsToken */, - ">>=": 65 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 67 /* AmpersandEqualsToken */, - "|=": 68 /* BarEqualsToken */, - "^=": 69 /* CaretEqualsToken */, - "@": 56 /* AtToken */, + "abstract": 117 /* AbstractKeyword */, + "any": 119 /* AnyKeyword */, + "as": 118 /* AsKeyword */, + "boolean": 122 /* BooleanKeyword */, + "break": 72 /* BreakKeyword */, + "case": 73 /* CaseKeyword */, + "catch": 74 /* CatchKeyword */, + "class": 75 /* ClassKeyword */, + "continue": 77 /* ContinueKeyword */, + "const": 76 /* ConstKeyword */, + "constructor": 123 /* ConstructorKeyword */, + "debugger": 78 /* DebuggerKeyword */, + "declare": 124 /* DeclareKeyword */, + "default": 79 /* DefaultKeyword */, + "delete": 80 /* DeleteKeyword */, + "do": 81 /* DoKeyword */, + "else": 82 /* ElseKeyword */, + "enum": 83 /* EnumKeyword */, + "export": 84 /* ExportKeyword */, + "extends": 85 /* ExtendsKeyword */, + "false": 86 /* FalseKeyword */, + "finally": 87 /* FinallyKeyword */, + "for": 88 /* ForKeyword */, + "from": 140 /* FromKeyword */, + "function": 89 /* FunctionKeyword */, + "get": 125 /* GetKeyword */, + "if": 90 /* IfKeyword */, + "implements": 108 /* ImplementsKeyword */, + "import": 91 /* ImportKeyword */, + "in": 92 /* InKeyword */, + "instanceof": 93 /* InstanceOfKeyword */, + "interface": 109 /* InterfaceKeyword */, + "is": 126 /* IsKeyword */, + "keyof": 127 /* KeyOfKeyword */, + "let": 110 /* LetKeyword */, + "module": 128 /* ModuleKeyword */, + "namespace": 129 /* NamespaceKeyword */, + "never": 130 /* NeverKeyword */, + "new": 94 /* NewKeyword */, + "null": 95 /* NullKeyword */, + "number": 133 /* NumberKeyword */, + "object": 134 /* ObjectKeyword */, + "package": 111 /* PackageKeyword */, + "private": 112 /* PrivateKeyword */, + "protected": 113 /* ProtectedKeyword */, + "public": 114 /* PublicKeyword */, + "readonly": 131 /* ReadonlyKeyword */, + "require": 132 /* RequireKeyword */, + "global": 141 /* GlobalKeyword */, + "return": 96 /* ReturnKeyword */, + "set": 135 /* SetKeyword */, + "static": 115 /* StaticKeyword */, + "string": 136 /* StringKeyword */, + "super": 97 /* SuperKeyword */, + "switch": 98 /* SwitchKeyword */, + "symbol": 137 /* SymbolKeyword */, + "this": 99 /* ThisKeyword */, + "throw": 100 /* ThrowKeyword */, + "true": 101 /* TrueKeyword */, + "try": 102 /* TryKeyword */, + "type": 138 /* TypeKeyword */, + "typeof": 103 /* TypeOfKeyword */, + "undefined": 139 /* UndefinedKeyword */, + "var": 104 /* VarKeyword */, + "void": 105 /* VoidKeyword */, + "while": 106 /* WhileKeyword */, + "with": 107 /* WithKeyword */, + "yield": 116 /* YieldKeyword */, + "async": 120 /* AsyncKeyword */, + "await": 121 /* AwaitKeyword */, + "of": 142 /* OfKeyword */, + "{": 17 /* OpenBraceToken */, + "}": 18 /* CloseBraceToken */, + "(": 19 /* OpenParenToken */, + ")": 20 /* CloseParenToken */, + "[": 21 /* OpenBracketToken */, + "]": 22 /* CloseBracketToken */, + ".": 23 /* DotToken */, + "...": 24 /* DotDotDotToken */, + ";": 25 /* SemicolonToken */, + ",": 26 /* CommaToken */, + "<": 27 /* LessThanToken */, + ">": 29 /* GreaterThanToken */, + "<=": 30 /* LessThanEqualsToken */, + ">=": 31 /* GreaterThanEqualsToken */, + "==": 32 /* EqualsEqualsToken */, + "!=": 33 /* ExclamationEqualsToken */, + "===": 34 /* EqualsEqualsEqualsToken */, + "!==": 35 /* ExclamationEqualsEqualsToken */, + "=>": 36 /* EqualsGreaterThanToken */, + "+": 37 /* PlusToken */, + "-": 38 /* MinusToken */, + "**": 40 /* AsteriskAsteriskToken */, + "*": 39 /* AsteriskToken */, + "/": 41 /* SlashToken */, + "%": 42 /* PercentToken */, + "++": 43 /* PlusPlusToken */, + "--": 44 /* MinusMinusToken */, + "<<": 45 /* LessThanLessThanToken */, + ">": 46 /* GreaterThanGreaterThanToken */, + ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 48 /* AmpersandToken */, + "|": 49 /* BarToken */, + "^": 50 /* CaretToken */, + "!": 51 /* ExclamationToken */, + "~": 52 /* TildeToken */, + "&&": 53 /* AmpersandAmpersandToken */, + "||": 54 /* BarBarToken */, + "?": 55 /* QuestionToken */, + ":": 56 /* ColonToken */, + "=": 58 /* EqualsToken */, + "+=": 59 /* PlusEqualsToken */, + "-=": 60 /* MinusEqualsToken */, + "*=": 61 /* AsteriskEqualsToken */, + "**=": 62 /* AsteriskAsteriskEqualsToken */, + "/=": 63 /* SlashEqualsToken */, + "%=": 64 /* PercentEqualsToken */, + "<<=": 65 /* LessThanLessThanEqualsToken */, + ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 68 /* AmpersandEqualsToken */, + "|=": 69 /* BarEqualsToken */, + "^=": 70 /* CaretEqualsToken */, + "@": 57 /* AtToken */, }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -5041,6 +5034,7 @@ var ts; if (text.charCodeAt(pos) === 10 /* lineFeed */) { pos++; } + // falls through case 10 /* lineFeed */: result.push(lineStart); lineStart = pos; @@ -5099,10 +5093,10 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function isWhiteSpace(ch) { + function isWhiteSpaceLike(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - ts.isWhiteSpace = isWhiteSpace; + ts.isWhiteSpaceLike = isWhiteSpaceLike; /** Does not include line breaks. For that, see isWhiteSpaceLike. */ function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. @@ -5185,6 +5179,7 @@ var ts; if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { pos++; } + // falls through case 10 /* lineFeed */: pos++; if (stopAfterLineBreak) { @@ -5238,7 +5233,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch))) { + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -5339,6 +5334,7 @@ var ts; if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { pos++; } + // falls through case 10 /* lineFeed */: pos++; if (trailing) { @@ -5399,7 +5395,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch))) { + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -5434,15 +5430,15 @@ var ts; if (!comments) { comments = []; } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine }); return comments; } function getLeadingCommentRanges(text, pos) { - return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); + return reduceEachLeadingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); + return reduceEachTrailingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined); } ts.getTrailingCommentRanges = getTrailingCommentRanges; /** Optionally, get the shebang */ @@ -5493,6 +5489,7 @@ var ts; var precedingLineBreak; var hasExtendedUnicodeEscape; var tokenIsUnterminated; + var numericLiteralFlags; setText(text, start, length); return { getStartPos: function () { return startPos; }, @@ -5503,9 +5500,10 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 70 /* Identifier */ || token > 106 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */; }, + isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, + getNumericLiteralFlags: function () { return numericLiteralFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, @@ -5542,6 +5540,7 @@ var ts; var end = pos; if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { pos++; + numericLiteralFlags = 2 /* Scientific */; if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) pos++; if (isDigit(text.charCodeAt(pos))) { @@ -5652,7 +5651,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; + resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -5660,14 +5659,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; + resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 13 /* TemplateHead */ : 14 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; break; } // Escape character @@ -5740,7 +5739,7 @@ var ts; if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { pos++; } - // fall through + // falls through case 10 /* lineFeed */: case 8232 /* lineSeparator */: case 8233 /* paragraphSeparator */: @@ -5848,7 +5847,7 @@ var ts; } } } - return token = 70 /* Identifier */; + return token = 71 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5877,6 +5876,7 @@ var ts; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -5928,12 +5928,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 32 /* ExclamationEqualsToken */; + return pos += 2, token = 33 /* ExclamationEqualsToken */; } pos++; - return token = 50 /* ExclamationToken */; + return token = 51 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -5942,68 +5942,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PercentEqualsToken */; + return pos += 2, token = 64 /* PercentEqualsToken */; } pos++; - return token = 41 /* PercentToken */; + return token = 42 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 52 /* AmpersandAmpersandToken */; + return pos += 2, token = 53 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* AmpersandEqualsToken */; + return pos += 2, token = 68 /* AmpersandEqualsToken */; } pos++; - return token = 47 /* AmpersandToken */; + return token = 48 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 18 /* OpenParenToken */; + return token = 19 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 19 /* CloseParenToken */; + return token = 20 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* AsteriskEqualsToken */; + return pos += 2, token = 61 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 39 /* AsteriskAsteriskToken */; + return pos += 2, token = 40 /* AsteriskAsteriskToken */; } pos++; - return token = 38 /* AsteriskToken */; + return token = 39 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 42 /* PlusPlusToken */; + return pos += 2, token = 43 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* PlusEqualsToken */; + return pos += 2, token = 59 /* PlusEqualsToken */; } pos++; - return token = 36 /* PlusToken */; + return token = 37 /* PlusToken */; case 44 /* comma */: pos++; - return token = 25 /* CommaToken */; + return token = 26 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 43 /* MinusMinusToken */; + return pos += 2, token = 44 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* MinusEqualsToken */; + return pos += 2, token = 60 /* MinusEqualsToken */; } pos++; - return token = 37 /* MinusToken */; + return token = 38 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 23 /* DotDotDotToken */; + return pos += 3, token = 24 /* DotDotDotToken */; } pos++; - return token = 22 /* DotToken */; + return token = 23 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -6049,10 +6049,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* SlashEqualsToken */; + return pos += 2, token = 63 /* SlashEqualsToken */; } pos++; - return token = 40 /* SlashToken */; + return token = 41 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -6062,6 +6062,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 8 /* HexSpecifier */; return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { @@ -6072,6 +6073,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 16 /* BinarySpecifier */; return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { @@ -6082,16 +6084,19 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 32 /* OctalSpecifier */; return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = 4 /* Octal */; return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). + // falls through case 49 /* _1 */: case 50 /* _2 */: case 51 /* _3 */: @@ -6105,10 +6110,10 @@ var ts; return token = 8 /* NumericLiteral */; case 58 /* colon */: pos++; - return token = 55 /* ColonToken */; + return token = 56 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 24 /* SemicolonToken */; + return token = 25 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6121,20 +6126,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 44 /* LessThanLessThanToken */; + return pos += 2, token = 45 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 29 /* LessThanEqualsToken */; + return pos += 2, token = 30 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 27 /* LessThanSlashToken */; + return pos += 2, token = 28 /* LessThanSlashToken */; } pos++; - return token = 26 /* LessThanToken */; + return token = 27 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6147,15 +6152,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 33 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 31 /* EqualsEqualsToken */; + return pos += 2, token = 32 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 35 /* EqualsGreaterThanToken */; + return pos += 2, token = 36 /* EqualsGreaterThanToken */; } pos++; - return token = 57 /* EqualsToken */; + return token = 58 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6167,43 +6172,43 @@ var ts; } } pos++; - return token = 28 /* GreaterThanToken */; + return token = 29 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 54 /* QuestionToken */; + return token = 55 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 20 /* OpenBracketToken */; + return token = 21 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 21 /* CloseBracketToken */; + return token = 22 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* CaretEqualsToken */; + return pos += 2, token = 70 /* CaretEqualsToken */; } pos++; - return token = 49 /* CaretToken */; + return token = 50 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 16 /* OpenBraceToken */; + return token = 17 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 53 /* BarBarToken */; + return pos += 2, token = 54 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* BarEqualsToken */; + return pos += 2, token = 69 /* BarEqualsToken */; } pos++; - return token = 48 /* BarToken */; + return token = 49 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 17 /* CloseBraceToken */; + return token = 18 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 51 /* TildeToken */; + return token = 52 /* TildeToken */; case 64 /* at */: pos++; - return token = 56 /* AtToken */; + return token = 57 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -6241,29 +6246,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 28 /* GreaterThanToken */) { + if (token === 29 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 46 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 45 /* GreaterThanGreaterThanToken */; + return token = 46 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 30 /* GreaterThanEqualsToken */; + return token = 31 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) { + if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -6308,7 +6313,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 11 /* RegularExpressionLiteral */; + token = 12 /* RegularExpressionLiteral */; } return token; } @@ -6316,7 +6321,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 17 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -6333,23 +6338,46 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 27 /* LessThanSlashToken */; + return token = 28 /* LessThanSlashToken */; } pos++; - return token = 26 /* LessThanToken */; + return token = 27 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 16 /* OpenBraceToken */; + return token = 17 /* OpenBraceToken */; } + // First non-whitespace character on this line. + var firstNonWhitespace = 0; + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitspace, while (pos < end) { - pos++; char = text.charCodeAt(pos); - if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { + if (char === 123 /* openBrace */) { break; } + if (char === 60 /* lessThan */) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = 7 /* ConflictMarkerTrivia */; + } + break; + } + // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. + // i.e (- : whitespace) + //
---- + //
becomes
+ // + //
----
becomes
----
+ if (isLineBreak(char) && firstNonWhitespace === 0) { + firstNonWhitespace = -1; + } + else if (!isWhiteSpaceLike(char)) { + firstNonWhitespace = pos; + } + pos++; } - return token = 10 /* JsxText */; + return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -6399,42 +6427,42 @@ var ts; return token = 5 /* WhitespaceTrivia */; case 64 /* at */: pos++; - return token = 56 /* AtToken */; + return token = 57 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: pos++; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: pos++; - return token = 38 /* AsteriskToken */; + return token = 39 /* AsteriskToken */; case 123 /* openBrace */: pos++; - return token = 16 /* OpenBraceToken */; + return token = 17 /* OpenBraceToken */; case 125 /* closeBrace */: pos++; - return token = 17 /* CloseBraceToken */; + return token = 18 /* CloseBraceToken */; case 91 /* openBracket */: pos++; - return token = 20 /* OpenBracketToken */; + return token = 21 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 21 /* CloseBracketToken */; + return token = 22 /* CloseBracketToken */; case 61 /* equals */: pos++; - return token = 57 /* EqualsToken */; + return token = 58 /* EqualsToken */; case 44 /* comma */: pos++; - return token = 25 /* CommaToken */; + return token = 26 /* CommaToken */; case 46 /* dot */: pos++; - return token = 22 /* DotToken */; + return token = 23 /* DotToken */; } if (isIdentifierStart(ch, 5 /* Latest */)) { pos++; while (isIdentifierPart(text.charCodeAt(pos), 5 /* Latest */) && pos < end) { pos++; } - return token = 70 /* Identifier */; + return token = 71 /* Identifier */; } else { return pos += 1, token = 0 /* Unknown */; @@ -6666,7 +6694,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 264 /* SourceFile */) { + while (node && node.kind !== 265 /* SourceFile */) { node = node.parent; } return node; @@ -6674,11 +6702,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 206 /* Block */: - case 234 /* CaseBlock */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 207 /* Block */: + case 235 /* CaseBlock */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: return true; } return false; @@ -6753,6 +6781,10 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isToken(n) { + return n.kind >= 0 /* FirstToken */ && n.kind <= 142 /* LastToken */; + } + ts.isToken = isToken; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -6769,18 +6801,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 294 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 266 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */; + return node.kind >= 267 /* FirstJSDocNode */ && node.kind <= 293 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 282 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */; + return node.kind >= 283 /* FirstJSDocTagNode */ && node.kind <= 293 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6811,33 +6843,24 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - // Any template literal or string literal with an extended escape - // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES2015 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } + function getLiteralText(node, sourceFile) { // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 /* ES2015 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; + return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { case 9 /* StringLiteral */: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return getQuotedEscapedLiteralText("`", node.text, "`"); - case 13 /* TemplateHead */: + case 14 /* TemplateHead */: return getQuotedEscapedLiteralText("`", node.text, "${"); - case 14 /* TemplateMiddle */: + case 15 /* TemplateMiddle */: return getQuotedEscapedLiteralText("}", node.text, "${"); - case 15 /* TemplateTail */: + case 16 /* TemplateTail */: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8 /* NumericLiteral */: return node.text; @@ -6845,53 +6868,6 @@ var ts; ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - return node.kind === 8 /* NumericLiteral */ - && (getNumericLiteralFlags(text, /*hint*/ 6 /* BinaryOrOctal */) & 6 /* BinaryOrOctal */) !== 0; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - var NumericLiteralFlags; - (function (NumericLiteralFlags) { - NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; - NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; - NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; - NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; - })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); - /** - * Scans a numeric literal string to determine the form of the number. - * @param text Numeric literal text - * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. - */ - function getNumericLiteralFlags(text, hint) { - if (text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - return 2 /* Binary */; - case 111 /* o */: - case 79 /* O */: - return 4 /* Octal */; - case 120 /* x */: - case 88 /* X */: - return 1 /* Hexadecimal */; - } - if (hint & 8 /* Scientific */) { - for (var i = text.length - 1; i >= 0; i--) { - switch (text.charCodeAt(i)) { - case 101 /* e */: - case 69 /* E */: - return 8 /* Scientific */; - } - } - } - } - return 0 /* None */; - } - ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6913,26 +6889,26 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 225 /* VariableDeclaration */ && node.parent.kind === 259 /* CatchClause */; + return node.kind === 226 /* VariableDeclaration */ && node.parent.kind === 260 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 232 /* ModuleDeclaration */ && + return node && node.kind === 233 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; - /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ + /** Given a symbol for a module, checks that it is a shorthand ambient module. */ function isShorthandAmbientModuleSymbol(moduleSymbol) { return isShorthandAmbientModule(moduleSymbol.valueDeclaration); } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 232 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 233 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 264 /* SourceFile */ || - node.kind === 232 /* ModuleDeclaration */ || + return node.kind === 265 /* SourceFile */ || + node.kind === 233 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6948,9 +6924,9 @@ var ts; return false; } switch (node.parent.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: return ts.isExternalModule(node.parent); - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6962,22 +6938,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 264 /* SourceFile */: - case 234 /* CaseBlock */: - case 259 /* CatchClause */: - case 232 /* ModuleDeclaration */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 265 /* SourceFile */: + case 235 /* CaseBlock */: + case 260 /* CatchClause */: + case 233 /* ModuleDeclaration */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return true; - case 206 /* Block */: + case 207 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -7004,14 +6980,18 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getNameFromIndexInfo(info) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } + ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return name.text; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -7021,11 +7001,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -7062,7 +7042,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 206 /* Block */) { + if (node.body && node.body.kind === 207 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7076,7 +7056,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 264 /* SourceFile */: + case 265 /* 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 @@ -7085,23 +7065,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 231 /* EnumDeclaration */: - case 263 /* EnumMember */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 230 /* TypeAliasDeclaration */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: + case 264 /* EnumMember */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 231 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7124,7 +7104,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 231 /* EnumDeclaration */ && isConst(node); + return node.kind === 232 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7137,11 +7117,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 180 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 181 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 209 /* ExpressionStatement */ + return node.kind === 210 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7154,10 +7134,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 145 /* Parameter */ || - node.kind === 144 /* TypeParameter */ || - node.kind === 185 /* FunctionExpression */ || - node.kind === 186 /* ArrowFunction */) ? + var commentRanges = (node.kind === 146 /* Parameter */ || + node.kind === 145 /* TypeParameter */ || + node.kind === 186 /* FunctionExpression */ || + node.kind === 187 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); // True if the comment starts with '/**' but not if it is '/**/' @@ -7172,79 +7152,80 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (157 /* FirstTypeNode */ <= node.kind && node.kind <= 172 /* LastTypeNode */) { + if (158 /* FirstTypeNode */ <= node.kind && node.kind <= 173 /* LastTypeNode */) { return true; } switch (node.kind) { - case 118 /* AnyKeyword */: - case 132 /* NumberKeyword */: - case 135 /* StringKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 138 /* UndefinedKeyword */: - case 129 /* NeverKeyword */: + case 119 /* AnyKeyword */: + case 133 /* NumberKeyword */: + case 136 /* StringKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 139 /* UndefinedKeyword */: + case 130 /* NeverKeyword */: return true; - case 104 /* VoidKeyword */: - return node.parent.kind !== 189 /* VoidExpression */; - case 200 /* ExpressionWithTypeArguments */: + case 105 /* VoidKeyword */: + return node.parent.kind !== 190 /* VoidExpression */; + case 201 /* 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 70 /* Identifier */: + case 71 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 179 /* 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 === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 142 /* QualifiedName */: - case 178 /* PropertyAccessExpression */: - case 98 /* ThisKeyword */: + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 143 /* QualifiedName */ || node.kind === 179 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + // falls through + case 143 /* QualifiedName */: + case 179 /* PropertyAccessExpression */: + case 99 /* ThisKeyword */: var parent = node.parent; - if (parent.kind === 161 /* TypeQuery */) { + if (parent.kind === 162 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: // // let a: A.B.C; // - // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. - if (157 /* FirstTypeNode */ <= parent.kind && parent.kind <= 172 /* LastTypeNode */) { + // Calling isPartOfTypeNode would consider the qualified name A.B a type node. + // Only C and A.B.C are type nodes. + if (158 /* FirstTypeNode */ <= parent.kind && parent.kind <= 173 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return node === parent.constraint; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 145 /* Parameter */: - case 225 /* VariableDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 146 /* Parameter */: + case 226 /* VariableDeclaration */: return node === parent.type; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return node === parent.type; - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: return node === parent.type; - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return node === parent.type; - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -7263,7 +7244,7 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 191 /* PrefixUnaryExpression */; + return node.kind === 192 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, @@ -7272,23 +7253,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitor(node); - case 234 /* CaseBlock */: - case 206 /* Block */: - case 210 /* IfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 219 /* WithStatement */: - case 220 /* SwitchStatement */: - case 256 /* CaseClause */: - case 257 /* DefaultClause */: - case 221 /* LabeledStatement */: - case 223 /* TryStatement */: - case 259 /* CatchClause */: + case 235 /* CaseBlock */: + case 207 /* Block */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 220 /* WithStatement */: + case 221 /* SwitchStatement */: + case 257 /* CaseClause */: + case 258 /* DefaultClause */: + case 222 /* LabeledStatement */: + case 224 /* TryStatement */: + case 260 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7298,18 +7279,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 231 /* EnumDeclaration */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + return; + case 232 /* EnumDeclaration */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* 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. @@ -7317,7 +7299,7 @@ var ts; default: if (isFunctionLike(node)) { var name = node.name; - if (name && name.kind === 143 /* ComputedPropertyName */) { + if (name && name.kind === 144 /* 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.expression); @@ -7340,10 +7322,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 163 /* ArrayType */) { + if (node && node.kind === 164 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 158 /* TypeReference */) { + else if (node && node.kind === 159 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7354,14 +7336,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 175 /* BindingElement */: - case 263 /* EnumMember */: - case 145 /* Parameter */: - case 260 /* PropertyAssignment */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 261 /* ShorthandPropertyAssignment */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 264 /* EnumMember */: + case 146 /* Parameter */: + case 261 /* PropertyAssignment */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 262 /* ShorthandPropertyAssignment */: + case 226 /* VariableDeclaration */: return true; } } @@ -7369,11 +7351,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */); + return node && (node.kind === 153 /* GetAccessor */ || node.kind === 154 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */); + return node && (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7382,19 +7364,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 151 /* Constructor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 152 /* Constructor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return true; } return false; @@ -7402,13 +7384,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return true; } return false; @@ -7416,42 +7398,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: return true; - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; - function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) { while (true) { if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 221 /* LabeledStatement */) { + if (node.statement.kind !== 222 /* LabeledStatement */) { return node.statement; } node = node.statement; } } - ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 206 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 207 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 150 /* MethodDeclaration */ && node.parent.kind === 177 /* ObjectLiteralExpression */; + return node && node.kind === 151 /* MethodDeclaration */ && node.parent.kind === 178 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 150 /* MethodDeclaration */ && - (node.parent.kind === 177 /* ObjectLiteralExpression */ || - node.parent.kind === 198 /* ClassExpression */); + return node.kind === 151 /* MethodDeclaration */ && + (node.parent.kind === 178 /* ObjectLiteralExpression */ || + node.parent.kind === 199 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7487,7 +7469,7 @@ var ts; return undefined; } switch (node.kind) { - case 143 /* ComputedPropertyName */: + case 144 /* 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 @@ -7502,9 +7484,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 146 /* Decorator */: + case 147 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 145 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 146 /* 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; @@ -7515,26 +7497,26 @@ var ts; node = node.parent; } break; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - // Fall through - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 232 /* ModuleDeclaration */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 231 /* EnumDeclaration */: - case 264 /* SourceFile */: + // falls through + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 233 /* ModuleDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 232 /* EnumDeclaration */: + case 265 /* SourceFile */: return node; } } @@ -7544,9 +7526,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return container; } } @@ -7554,13 +7536,13 @@ var ts; } ts.getNewTargetContainer = getNewTargetContainer; /** - * Given an super call/property node, returns the closest node where - * - a super call/property access is legal in the node and not legal in the parent node the node. - * i.e. super call is legal in constructor but not legal in the class body. - * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) - * - a super call/property is definitely illegal in the container (but might be legal in some subnode) - * i.e. super property access is illegal in function declaration but can be legal in the statement list - */ + * Given an super call/property node, returns the closest node where + * - a super call/property access is legal in the node and not legal in the parent node the node. + * i.e. super call is legal in constructor but not legal in the class body. + * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) + * - a super call/property is definitely illegal in the container (but might be legal in some subnode) + * i.e. super property access is illegal in function declaration but can be legal in the statement list + */ function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7568,26 +7550,27 @@ var ts; return node; } switch (node.kind) { - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: node = node.parent; break; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + // falls through + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return node; - case 146 /* Decorator */: + case 147 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 145 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 146 /* 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; @@ -7603,14 +7586,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */) { + if (func.kind === 186 /* FunctionExpression */ || func.kind === 187 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 184 /* ParenthesizedExpression */) { + while (parent.kind === 185 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 180 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 181 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -7621,21 +7604,21 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 178 /* PropertyAccessExpression */ || kind === 179 /* ElementAccessExpression */) - && node.expression.kind === 96 /* SuperKeyword */; + return (kind === 179 /* PropertyAccessExpression */ || kind === 180 /* ElementAccessExpression */) + && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 158 /* TypeReference */: - case 276 /* JSDocTypeReference */: + case 159 /* TypeReference */: + case 277 /* JSDocTypeReference */: return node.typeName; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 70 /* Identifier */: - case 142 /* QualifiedName */: + case 71 /* Identifier */: + case 143 /* QualifiedName */: return node; } return undefined; @@ -7643,12 +7626,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 182 /* TaggedTemplateExpression */: - case 146 /* Decorator */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 183 /* TaggedTemplateExpression */: + case 147 /* Decorator */: return true; default: return false; @@ -7656,7 +7639,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* TaggedTemplateExpression */) { return node.tag; } else if (isJsxOpeningLikeElement(node)) { @@ -7668,25 +7651,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: // classes are valid targets return true; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 228 /* ClassDeclaration */; - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 150 /* MethodDeclaration */: + return node.parent.kind === 229 /* ClassDeclaration */; + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 151 /* 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 === 228 /* ClassDeclaration */; - case 145 /* Parameter */: + && node.parent.kind === 229 /* ClassDeclaration */; + case 146 /* 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 === 151 /* Constructor */ - || node.parent.kind === 150 /* MethodDeclaration */ - || node.parent.kind === 153 /* SetAccessor */) - && node.parent.parent.kind === 228 /* ClassDeclaration */; + && (node.parent.kind === 152 /* Constructor */ + || node.parent.kind === 151 /* MethodDeclaration */ + || node.parent.kind === 154 /* SetAccessor */) + && node.parent.parent.kind === 229 /* ClassDeclaration */; } return false; } @@ -7702,19 +7685,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 150 /* MethodDeclaration */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 154 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 250 /* JsxOpeningElement */ || - parent.kind === 249 /* JsxSelfClosingElement */ || - parent.kind === 251 /* JsxClosingElement */) { + if (parent.kind === 251 /* JsxOpeningElement */ || + parent.kind === 250 /* JsxSelfClosingElement */ || + parent.kind === 252 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7722,100 +7705,100 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: - case 11 /* RegularExpressionLiteral */: - case 176 /* ArrayLiteralExpression */: - case 177 /* ObjectLiteralExpression */: - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 182 /* TaggedTemplateExpression */: - case 201 /* AsExpression */: - case 183 /* TypeAssertionExpression */: - case 202 /* NonNullExpression */: - case 184 /* ParenthesizedExpression */: - case 185 /* FunctionExpression */: - case 198 /* ClassExpression */: - case 186 /* ArrowFunction */: - case 189 /* VoidExpression */: - case 187 /* DeleteExpression */: - case 188 /* TypeOfExpression */: - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: - case 193 /* BinaryExpression */: - case 194 /* ConditionalExpression */: - case 197 /* SpreadElement */: - case 195 /* TemplateExpression */: - case 12 /* NoSubstitutionTemplateLiteral */: - case 199 /* OmittedExpression */: - case 248 /* JsxElement */: - case 249 /* JsxSelfClosingElement */: - case 196 /* YieldExpression */: - case 190 /* AwaitExpression */: - case 203 /* MetaProperty */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 12 /* RegularExpressionLiteral */: + case 177 /* ArrayLiteralExpression */: + case 178 /* ObjectLiteralExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 183 /* TaggedTemplateExpression */: + case 202 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 203 /* NonNullExpression */: + case 185 /* ParenthesizedExpression */: + case 186 /* FunctionExpression */: + case 199 /* ClassExpression */: + case 187 /* ArrowFunction */: + case 190 /* VoidExpression */: + case 188 /* DeleteExpression */: + case 189 /* TypeOfExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + case 194 /* BinaryExpression */: + case 195 /* ConditionalExpression */: + case 198 /* SpreadElement */: + case 196 /* TemplateExpression */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 200 /* OmittedExpression */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 197 /* YieldExpression */: + case 191 /* AwaitExpression */: + case 204 /* MetaProperty */: return true; - case 142 /* QualifiedName */: - while (node.parent.kind === 142 /* QualifiedName */) { + case 143 /* QualifiedName */: + while (node.parent.kind === 143 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node); - case 70 /* Identifier */: - if (node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 162 /* TypeQuery */ || isJSXTagName(node); + case 71 /* Identifier */: + if (node.parent.kind === 162 /* TypeQuery */ || isJSXTagName(node)) { return true; } - // fall through + // falls through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: var parent = node.parent; switch (parent.kind) { - case 225 /* VariableDeclaration */: - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 263 /* EnumMember */: - case 260 /* PropertyAssignment */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 264 /* EnumMember */: + case 261 /* PropertyAssignment */: + case 176 /* BindingElement */: return parent.initializer === node; - case 209 /* ExpressionStatement */: - case 210 /* IfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 218 /* ReturnStatement */: - case 219 /* WithStatement */: - case 220 /* SwitchStatement */: - case 256 /* CaseClause */: - case 222 /* ThrowStatement */: - case 220 /* SwitchStatement */: + case 210 /* ExpressionStatement */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 219 /* ReturnStatement */: + case 220 /* WithStatement */: + case 221 /* SwitchStatement */: + case 257 /* CaseClause */: + case 223 /* ThrowStatement */: + case 221 /* SwitchStatement */: return parent.expression === node; - case 213 /* ForStatement */: + case 214 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 226 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 227 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227 /* VariableDeclarationList */) || forInStatement.expression === node; - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: return node === parent.expression; - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return node === parent.expression; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return node === parent.expression; - case 146 /* Decorator */: - case 255 /* JsxExpression */: - case 254 /* JsxSpreadAttribute */: - case 262 /* SpreadAssignment */: + case 147 /* Decorator */: + case 256 /* JsxExpression */: + case 255 /* JsxSpreadAttribute */: + case 263 /* SpreadAssignment */: return true; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: if (isPartOfExpression(parent)) { @@ -7833,7 +7816,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */; + return node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 248 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7842,7 +7825,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 247 /* ExternalModuleReference */; + return node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 248 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7855,16 +7838,22 @@ var ts; ts.isInJavaScriptFile = isInJavaScriptFile; /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one argument. + * exactly one argument (of the form 'require("name")'). * This function does not test if the node is in a JavaScript file or not. - */ - function isRequireCall(expression, checkArgumentIsStringLiteral) { - // of the form 'require("name")' - var isRequire = expression.kind === 180 /* CallExpression */ && - expression.expression.kind === 70 /* Identifier */ && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); + */ + function isRequireCall(callExpression, checkArgumentIsStringLiteral) { + if (callExpression.kind !== 181 /* CallExpression */) { + return false; + } + var _a = callExpression, expression = _a.expression, args = _a.arguments; + if (expression.kind !== 71 /* Identifier */ || expression.text !== "require") { + return false; + } + if (args.length !== 1) { + return false; + } + var arg = args[0]; + return !checkArgumentIsStringLiteral || arg.kind === 9 /* StringLiteral */ || arg.kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -7875,29 +7864,41 @@ var ts; * Returns true if the node is a variable declaration whose initializer is a function expression. * This function does not test if the node is in a JavaScript file or not. */ - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 225 /* VariableDeclaration */) { + function isDeclarationOfFunctionOrClassExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 226 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 185 /* FunctionExpression */; + return declaration.initializer && (declaration.initializer.kind === 186 /* FunctionExpression */ || declaration.initializer.kind === 199 /* ClassExpression */); } return false; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + ts.isDeclarationOfFunctionOrClassExpression = isDeclarationOfFunctionOrClassExpression; + function getRightMostAssignedExpression(node) { + while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + node = node.right; + } + return node; + } + ts.getRightMostAssignedExpression = getRightMostAssignedExpression; + function isExportsIdentifier(node) { + return isIdentifier(node) && node.text === "exports"; + } + ts.isExportsIdentifier = isExportsIdentifier; + function isModuleExportsPropertyAccessExpression(node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getSpecialPropertyAssignmentKind(expression) { if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 193 /* BinaryExpression */) { - return 0 /* None */; - } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 178 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 58 /* EqualsToken */ || expr.left.kind !== 179 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; - if (lhs.expression.kind === 70 /* Identifier */) { + if (lhs.expression.kind === 71 /* Identifier */) { var lhsId = lhs.expression; if (lhsId.text === "exports") { // exports.name = expr @@ -7907,14 +7908,18 @@ var ts; // module.exports = expr return 2 /* ModuleExports */; } + else { + // F.x = expr + return 5 /* Property */; + } } - else if (lhs.expression.kind === 98 /* ThisKeyword */) { + else if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 178 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 179 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { + if (innerPropertyAccess.expression.kind === 71 /* Identifier */) { // module.exports.name = expr var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { @@ -7929,35 +7934,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 237 /* ImportDeclaration */) { + if (node.kind === 238 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 247 /* ExternalModuleReference */) { + if (reference.kind === 248 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 243 /* ExportDeclaration */) { + if (node.kind === 244 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 232 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 233 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 240 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 237 /* ImportDeclaration */ + return node.kind === 238 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7965,13 +7970,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 145 /* Parameter */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 261 /* ShorthandPropertyAssignment */: - case 260 /* PropertyAssignment */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 146 /* Parameter */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 262 /* ShorthandPropertyAssignment */: + case 261 /* PropertyAssignment */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7979,9 +7984,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 278 /* JSDocFunctionType */ && + return node.kind === 279 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 280 /* JSDocConstructorType */; + node.parameters[0].type.kind === 281 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -7989,7 +7994,7 @@ var ts; } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; function hasJSDocParameterTags(node) { - var parameterTags = getJSDocTags(node, 285 /* JSDocParameterTag */); + var parameterTags = getJSDocTags(node, 286 /* JSDocParameterTag */); return parameterTags && parameterTags.length > 0; } ts.hasJSDocParameterTags = hasJSDocParameterTags; @@ -7999,13 +8004,16 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 285 /* JSDocParameterTag */) { + if (doc.kind === 286 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } } else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + var tags = doc.tags; + if (tags) { + result.push.apply(result, ts.filter(tags, function (tag) { return tag.kind === kind; })); + } } } return result; @@ -8031,9 +8039,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 207 /* VariableStatement */; + parent.parent.parent.kind === 208 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 207 /* VariableStatement */; + parent.parent.kind === 208 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8042,20 +8050,20 @@ var ts; } // Also recognize when the node is the RHS of an assignment expression var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 193 /* BinaryExpression */ && - parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 209 /* ExpressionStatement */; + parent.kind === 194 /* BinaryExpression */ && + parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 210 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 232 /* ModuleDeclaration */ && - parent && parent.kind === 232 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 260 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 233 /* ModuleDeclaration */ && + parent && parent.kind === 233 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 261 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -8064,23 +8072,24 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 285 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 286 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 286 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } - else if (param.name.kind === 70 /* Identifier */) { + else if (param.name.kind === 71 /* Identifier */) { var name_1 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); + return ts.filter(tags, function (tag) { return tag.kind === 286 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -8090,8 +8099,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 287 /* JSDocTypeTag */); - if (!tag && node.kind === 145 /* Parameter */) { + var tag = getFirstJSDocTag(node, 288 /* JSDocTypeTag */); + if (!tag && node.kind === 146 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -8101,15 +8110,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 285 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 286 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 287 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 288 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 289 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8122,8 +8131,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 279 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 280 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 280 /* JSDocVariadicType */; })) { return true; } } @@ -8144,30 +8153,30 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 184 /* ParenthesizedExpression */: - case 176 /* ArrayLiteralExpression */: - case 197 /* SpreadElement */: + case 185 /* ParenthesizedExpression */: + case 177 /* ArrayLiteralExpression */: + case 198 /* SpreadElement */: node = parent; break; - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -8190,14 +8199,14 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { + if (node.kind !== 179 /* PropertyAccessExpression */ && node.kind !== 180 /* ElementAccessExpression */) { return false; } node = node.parent; - while (node && node.kind === 184 /* ParenthesizedExpression */) { + while (node && node.kind === 185 /* ParenthesizedExpression */) { node = node.parent; } - return node && node.kind === 187 /* DeleteExpression */; + return node && node.kind === 188 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8211,7 +8220,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 264 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 265 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8221,11 +8230,11 @@ var ts; ts.isInAmbientContext = isInAmbientContext; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 70 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 71 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 241 /* ImportSpecifier */ || parent.kind === 245 /* ExportSpecifier */) { + if (parent.kind === 242 /* ImportSpecifier */ || parent.kind === 246 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8238,7 +8247,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 143 /* ComputedPropertyName */ && + node.parent.kind === 144 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -8246,31 +8255,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 263 /* EnumMember */: - case 260 /* PropertyAssignment */: - case 178 /* PropertyAccessExpression */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 264 /* EnumMember */: + case 261 /* PropertyAssignment */: + case 179 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 142 /* QualifiedName */) { + while (parent.kind === 143 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 161 /* TypeQuery */; + return parent.kind === 162 /* TypeQuery */; } return false; - case 175 /* BindingElement */: - case 241 /* ImportSpecifier */: + case 176 /* BindingElement */: + case 242 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 245 /* ExportSpecifier */: + case 246 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8286,13 +8295,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */ || - node.kind === 235 /* NamespaceExportDeclaration */ || - node.kind === 238 /* ImportClause */ && !!node.name || - node.kind === 239 /* NamespaceImport */ || - node.kind === 241 /* ImportSpecifier */ || - node.kind === 245 /* ExportSpecifier */ || - node.kind === 242 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 237 /* ImportEqualsDeclaration */ || + node.kind === 236 /* NamespaceExportDeclaration */ || + node.kind === 239 /* ImportClause */ && !!node.name || + node.kind === 240 /* NamespaceImport */ || + node.kind === 242 /* ImportSpecifier */ || + node.kind === 246 /* ExportSpecifier */ || + node.kind === 243 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8300,17 +8309,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -8378,17 +8387,62 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 141 /* LastKeyword */; + return 72 /* FirstKeyword */ <= token && token <= 142 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256 /* Async */) && !isAccessor(node); + var FunctionFlags; + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal"; + FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator"; + FunctionFlags[FunctionFlags["Async"] = 2] = "Async"; + FunctionFlags[FunctionFlags["AsyncOrAsyncGenerator"] = 3] = "AsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid"; + FunctionFlags[FunctionFlags["InvalidAsyncOrAsyncGenerator"] = 7] = "InvalidAsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["InvalidGenerator"] = 5] = "InvalidGenerator"; + })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); + function getFunctionFlags(node) { + var flags = 0 /* Normal */; + switch (node.kind) { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + if (node.asteriskToken) { + flags |= 1 /* Generator */; + } + // falls through + case 187 /* ArrowFunction */: + if (hasModifier(node, 256 /* Async */)) { + flags |= 2 /* Async */; + } + break; + } + if (!node.body) { + flags |= 4 /* Invalid */; + } + return flags; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; + ts.getFunctionFlags = getFunctionFlags; + function isAsyncFunction(node) { + switch (node.kind) { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + return node.body !== undefined + && node.asteriskToken === undefined + && hasModifier(node, 256 /* Async */); + } + return false; + } + ts.isAsyncFunction = isAsyncFunction; + function isNumericLiteral(node) { + return node.kind === 8 /* NumericLiteral */; + } + ts.isNumericLiteral = isNumericLiteral; function isStringOrNumericLiteral(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ @@ -8407,7 +8461,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 143 /* ComputedPropertyName */ && + return name.kind === 144 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8422,10 +8476,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 145 /* Parameter */) { + if (name.kind === 71 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 146 /* Parameter */) { return name.text; } - if (name.kind === 143 /* ComputedPropertyName */) { + if (name.kind === 144 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8446,7 +8500,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 70 /* Identifier */ && node.text === "Symbol"; + return node.kind === 71 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -8455,17 +8509,17 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 116 /* AbstractKeyword */: - case 119 /* AsyncKeyword */: - case 75 /* ConstKeyword */: - case 123 /* DeclareKeyword */: - case 78 /* DefaultKeyword */: - case 83 /* ExportKeyword */: - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 130 /* ReadonlyKeyword */: - case 114 /* StaticKeyword */: + case 117 /* AbstractKeyword */: + case 120 /* AsyncKeyword */: + case 76 /* ConstKeyword */: + case 124 /* DeclareKeyword */: + case 79 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 131 /* ReadonlyKeyword */: + case 115 /* StaticKeyword */: return true; } return false; @@ -8473,11 +8527,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 145 /* Parameter */; + return root.kind === 146 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 175 /* BindingElement */) { + while (node.kind === 176 /* BindingElement */) { node = node.parent.parent; } return node; @@ -8485,15 +8539,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 151 /* Constructor */ - || kind === 185 /* FunctionExpression */ - || kind === 227 /* FunctionDeclaration */ - || kind === 186 /* ArrowFunction */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 232 /* ModuleDeclaration */ - || kind === 264 /* SourceFile */; + return kind === 152 /* Constructor */ + || kind === 186 /* FunctionExpression */ + || kind === 228 /* FunctionDeclaration */ + || kind === 187 /* ArrowFunction */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 233 /* ModuleDeclaration */ + || kind === 265 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8502,7 +8556,7 @@ var ts; } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFileOrBundle(sourceFileOrBundle) { - if (sourceFileOrBundle.kind === 265 /* Bundle */) { + if (sourceFileOrBundle.kind === 266 /* Bundle */) { return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } return getOriginalSourceFile(sourceFileOrBundle); @@ -8527,38 +8581,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 181 /* NewExpression */: + case 182 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 191 /* PrefixUnaryExpression */: - case 188 /* TypeOfExpression */: - case 189 /* VoidExpression */: - case 187 /* DeleteExpression */: - case 190 /* AwaitExpression */: - case 194 /* ConditionalExpression */: - case 196 /* YieldExpression */: + case 192 /* PrefixUnaryExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 188 /* DeleteExpression */: + case 191 /* AwaitExpression */: + case 195 /* ConditionalExpression */: + case 197 /* YieldExpression */: return 1 /* Right */; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (operator) { - case 39 /* AsteriskAsteriskToken */: - case 57 /* EqualsToken */: - case 58 /* PlusEqualsToken */: - case 59 /* MinusEqualsToken */: - case 61 /* AsteriskAsteriskEqualsToken */: - case 60 /* AsteriskEqualsToken */: - case 62 /* SlashEqualsToken */: - case 63 /* PercentEqualsToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 67 /* AmpersandEqualsToken */: - case 69 /* CaretEqualsToken */: - case 68 /* BarEqualsToken */: + case 40 /* AsteriskAsteriskToken */: + case 58 /* EqualsToken */: + case 59 /* PlusEqualsToken */: + case 60 /* MinusEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: + case 61 /* AsteriskEqualsToken */: + case 63 /* SlashEqualsToken */: + case 64 /* PercentEqualsToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 68 /* AmpersandEqualsToken */: + case 70 /* CaretEqualsToken */: + case 69 /* BarEqualsToken */: return 1 /* Right */; } } @@ -8567,15 +8621,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 193 /* BinaryExpression */) { + if (expression.kind === 194 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 191 /* PrefixUnaryExpression */ || expression.kind === 192 /* PostfixUnaryExpression */) { + else if (expression.kind === 192 /* PrefixUnaryExpression */ || expression.kind === 193 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8585,106 +8639,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 70 /* Identifier */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 71 /* Identifier */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 176 /* ArrayLiteralExpression */: - case 177 /* ObjectLiteralExpression */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 198 /* ClassExpression */: - case 248 /* JsxElement */: - case 249 /* JsxSelfClosingElement */: - case 11 /* RegularExpressionLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: - case 195 /* TemplateExpression */: - case 184 /* ParenthesizedExpression */: - case 199 /* OmittedExpression */: + case 177 /* ArrayLiteralExpression */: + case 178 /* ObjectLiteralExpression */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 199 /* ClassExpression */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 196 /* TemplateExpression */: + case 185 /* ParenthesizedExpression */: + case 200 /* OmittedExpression */: return 19; - case 182 /* TaggedTemplateExpression */: - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: + case 183 /* TaggedTemplateExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: return 18; - case 181 /* NewExpression */: + case 182 /* NewExpression */: return hasArguments ? 18 : 17; - case 180 /* CallExpression */: + case 181 /* CallExpression */: return 17; - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return 16; - case 191 /* PrefixUnaryExpression */: - case 188 /* TypeOfExpression */: - case 189 /* VoidExpression */: - case 187 /* DeleteExpression */: - case 190 /* AwaitExpression */: + case 192 /* PrefixUnaryExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 188 /* DeleteExpression */: + case 191 /* AwaitExpression */: return 15; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (operatorKind) { - case 50 /* ExclamationToken */: - case 51 /* TildeToken */: + case 51 /* ExclamationToken */: + case 52 /* TildeToken */: return 15; - case 39 /* AsteriskAsteriskToken */: - case 38 /* AsteriskToken */: - case 40 /* SlashToken */: - case 41 /* PercentToken */: + case 40 /* AsteriskAsteriskToken */: + case 39 /* AsteriskToken */: + case 41 /* SlashToken */: + case 42 /* PercentToken */: return 14; - case 36 /* PlusToken */: - case 37 /* MinusToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: return 13; - case 44 /* LessThanLessThanToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* LessThanLessThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 26 /* LessThanToken */: - case 29 /* LessThanEqualsToken */: - case 28 /* GreaterThanToken */: - case 30 /* GreaterThanEqualsToken */: - case 91 /* InKeyword */: - case 92 /* InstanceOfKeyword */: + case 27 /* LessThanToken */: + case 30 /* LessThanEqualsToken */: + case 29 /* GreaterThanToken */: + case 31 /* GreaterThanEqualsToken */: + case 92 /* InKeyword */: + case 93 /* InstanceOfKeyword */: return 11; - case 31 /* EqualsEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: return 10; - case 47 /* AmpersandToken */: + case 48 /* AmpersandToken */: return 9; - case 49 /* CaretToken */: + case 50 /* CaretToken */: return 8; - case 48 /* BarToken */: + case 49 /* BarToken */: return 7; - case 52 /* AmpersandAmpersandToken */: + case 53 /* AmpersandAmpersandToken */: return 6; - case 53 /* BarBarToken */: + case 54 /* BarBarToken */: return 5; - case 57 /* EqualsToken */: - case 58 /* PlusEqualsToken */: - case 59 /* MinusEqualsToken */: - case 61 /* AsteriskAsteriskEqualsToken */: - case 60 /* AsteriskEqualsToken */: - case 62 /* SlashEqualsToken */: - case 63 /* PercentEqualsToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 67 /* AmpersandEqualsToken */: - case 69 /* CaretEqualsToken */: - case 68 /* BarEqualsToken */: + case 58 /* EqualsToken */: + case 59 /* PlusEqualsToken */: + case 60 /* MinusEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: + case 61 /* AsteriskEqualsToken */: + case 63 /* SlashEqualsToken */: + case 64 /* PercentEqualsToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 68 /* AmpersandEqualsToken */: + case 70 /* CaretEqualsToken */: + case 69 /* BarEqualsToken */: return 3; - case 25 /* CommaToken */: + case 26 /* CommaToken */: return 0; default: return -1; } - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return 4; - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return 2; - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return 1; default: return -1; @@ -8980,7 +9034,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -9039,7 +9093,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 151 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 152 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -9067,11 +9121,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 70 /* Identifier */ && identifierIsThisKeyword(node); + return node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98 /* ThisKeyword */; + return id.originalKeywordKind === 99 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -9081,10 +9135,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 152 /* GetAccessor */) { + if (accessor.kind === 153 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 153 /* SetAccessor */) { + else if (accessor.kind === 154 /* SetAccessor */) { setAccessor = accessor; } else { @@ -9093,7 +9147,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 152 /* GetAccessor */ || member.kind === 153 /* SetAccessor */) + if ((member.kind === 153 /* GetAccessor */ || member.kind === 154 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -9104,10 +9158,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 152 /* GetAccessor */ && !getAccessor) { + if (member.kind === 153 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 153 /* SetAccessor */ && !setAccessor) { + if (member.kind === 154 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -9334,7 +9388,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } node.modifierFlagsCache = flags | 536870912 /* HasComputedFlags */; @@ -9343,35 +9397,35 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 114 /* StaticKeyword */: return 32 /* Static */; - case 113 /* PublicKeyword */: return 4 /* Public */; - case 112 /* ProtectedKeyword */: return 16 /* Protected */; - case 111 /* PrivateKeyword */: return 8 /* Private */; - case 116 /* AbstractKeyword */: return 128 /* Abstract */; - case 83 /* ExportKeyword */: return 1 /* Export */; - case 123 /* DeclareKeyword */: return 2 /* Ambient */; - case 75 /* ConstKeyword */: return 2048 /* Const */; - case 78 /* DefaultKeyword */: return 512 /* Default */; - case 119 /* AsyncKeyword */: return 256 /* Async */; - case 130 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 115 /* StaticKeyword */: return 32 /* Static */; + case 114 /* PublicKeyword */: return 4 /* Public */; + case 113 /* ProtectedKeyword */: return 16 /* Protected */; + case 112 /* PrivateKeyword */: return 8 /* Private */; + case 117 /* AbstractKeyword */: return 128 /* Abstract */; + case 84 /* ExportKeyword */: return 1 /* Export */; + case 124 /* DeclareKeyword */: return 2 /* Ambient */; + case 76 /* ConstKeyword */: return 2048 /* Const */; + case 79 /* DefaultKeyword */: return 512 /* Default */; + case 120 /* AsyncKeyword */: return 256 /* Async */; + case 131 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 53 /* BarBarToken */ - || token === 52 /* AmpersandAmpersandToken */ - || token === 50 /* ExclamationToken */; + return token === 54 /* BarBarToken */ + || token === 53 /* AmpersandAmpersandToken */ + || token === 51 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 57 /* FirstAssignment */ && token <= 69 /* LastAssignment */; + return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 200 /* ExpressionWithTypeArguments */ && - node.parent.token === 84 /* ExtendsKeyword */ && + if (node.kind === 201 /* ExpressionWithTypeArguments */ && + node.parent.token === 85 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -9380,7 +9434,7 @@ var ts; function isAssignmentExpression(node, excludeCompoundAssignment) { return isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 /* EqualsToken */ + ? node.operatorToken.kind === 58 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left); } @@ -9388,8 +9442,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 177 /* ObjectLiteralExpression */ - || kind === 176 /* ArrayLiteralExpression */; + return kind === 178 /* ObjectLiteralExpression */ + || kind === 177 /* ArrayLiteralExpression */; } return false; } @@ -9401,7 +9455,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { return true; } else if (isPropertyAccessExpression(node)) { @@ -9415,27 +9469,35 @@ var ts; return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isExpressionWithTypeArgumentsInClassImplementsClause(node) { + return node.kind === 201 /* ExpressionWithTypeArguments */ + && isEntityNameExpression(node.expression) + && node.parent + && node.parent.token === 108 /* ImplementsKeyword */ + && node.parent.parent + && isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassImplementsClause = isExpressionWithTypeArgumentsInClassImplementsClause; function isEntityNameExpression(node) { - return node.kind === 70 /* Identifier */ || - node.kind === 178 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + return node.kind === 71 /* Identifier */ || + node.kind === 179 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 177 /* ObjectLiteralExpression */) { - return expression.properties.length === 0; - } - if (kind === 176 /* ArrayLiteralExpression */) { - return expression.elements.length === 0; - } - return false; + function isEmptyObjectLiteral(expression) { + return expression.kind === 178 /* ObjectLiteralExpression */ && + expression.properties.length === 0; } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + ts.isEmptyObjectLiteral = isEmptyObjectLiteral; + function isEmptyArrayLiteral(expression) { + return expression.kind === 177 /* ArrayLiteralExpression */ && + expression.elements.length === 0; + } + ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -9443,7 +9505,6 @@ var ts; function isExportDefaultSymbol(symbol) { return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */); } - ts.isExportDefaultSymbol = isExportDefaultSymbol; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -9545,49 +9606,49 @@ var ts; var kind = node.kind; if (kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 11 /* RegularExpressionLiteral */ - || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 70 /* Identifier */ - || kind === 98 /* ThisKeyword */ - || kind === 96 /* SuperKeyword */ - || kind === 100 /* TrueKeyword */ - || kind === 85 /* FalseKeyword */ - || kind === 94 /* NullKeyword */) { + || kind === 12 /* RegularExpressionLiteral */ + || kind === 13 /* NoSubstitutionTemplateLiteral */ + || kind === 71 /* Identifier */ + || kind === 99 /* ThisKeyword */ + || kind === 97 /* SuperKeyword */ + || kind === 101 /* TrueKeyword */ + || kind === 86 /* FalseKeyword */ + || kind === 95 /* NullKeyword */) { return true; } - else if (kind === 178 /* PropertyAccessExpression */) { + else if (kind === 179 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 179 /* ElementAccessExpression */) { + else if (kind === 180 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 191 /* PrefixUnaryExpression */ - || kind === 192 /* PostfixUnaryExpression */) { + else if (kind === 192 /* PrefixUnaryExpression */ + || kind === 193 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 193 /* BinaryExpression */) { - return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ + else if (kind === 194 /* BinaryExpression */) { + return node.operatorToken.kind !== 40 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 194 /* ConditionalExpression */) { + else if (kind === 195 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 189 /* VoidExpression */ - || kind === 188 /* TypeOfExpression */ - || kind === 187 /* DeleteExpression */) { + else if (kind === 190 /* VoidExpression */ + || kind === 189 /* TypeOfExpression */ + || kind === 188 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 176 /* ArrayLiteralExpression */) { + else if (kind === 177 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 177 /* ObjectLiteralExpression */) { + else if (kind === 178 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 180 /* CallExpression */) { + else if (kind === 181 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9765,8 +9826,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9787,7 +9848,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 229 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9817,15 +9878,15 @@ var ts; ts.isNodeArray = isNodeArray; // Literals function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12 /* NoSubstitutionTemplateLiteral */; + return node.kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 12 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9834,26 +9895,26 @@ var ts; ts.isLiteralExpression = isLiteralExpression; // Pseudo-literals function isTemplateLiteralKind(kind) { - return 12 /* FirstTemplateToken */ <= kind && kind <= 15 /* LastTemplateToken */; + return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 13 /* TemplateHead */; + return node.kind === 14 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 14 /* TemplateMiddle */ - || kind === 15 /* TemplateTail */; + return kind === 15 /* TemplateMiddle */ + || kind === 16 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { - return node.kind === 70 /* Identifier */; + return node.kind === 71 /* Identifier */; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 189 /* VoidExpression */; + return node.kind === 190 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -9868,91 +9929,95 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 142 /* QualifiedName */; + return node.kind === 143 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 143 /* ComputedPropertyName */; + return node.kind === 144 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 142 /* QualifiedName */ - || kind === 70 /* Identifier */; + return kind === 143 /* QualifiedName */ + || kind === 71 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 70 /* Identifier */ + return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 143 /* ComputedPropertyName */; + || kind === 144 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 70 /* Identifier */ + return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 70 /* Identifier */ - || kind === 173 /* ObjectBindingPattern */ - || kind === 174 /* ArrayBindingPattern */; + return kind === 71 /* Identifier */ + || kind === 174 /* ObjectBindingPattern */ + || kind === 175 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 144 /* TypeParameter */; + return node.kind === 145 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 145 /* Parameter */; + return node.kind === 146 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 146 /* Decorator */; + return node.kind === 147 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 150 /* MethodDeclaration */; + return node.kind === 151 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 151 /* Constructor */ - || kind === 148 /* PropertyDeclaration */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 156 /* IndexSignature */ - || kind === 205 /* SemicolonClassElement */; + return kind === 152 /* Constructor */ + || kind === 149 /* PropertyDeclaration */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 157 /* IndexSignature */ + || kind === 206 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 260 /* PropertyAssignment */ - || kind === 261 /* ShorthandPropertyAssignment */ - || kind === 262 /* SpreadAssignment */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 246 /* MissingDeclaration */; + return kind === 261 /* PropertyAssignment */ + || kind === 262 /* ShorthandPropertyAssignment */ + || kind === 263 /* SpreadAssignment */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 247 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) - || kind === 118 /* AnyKeyword */ - || kind === 132 /* NumberKeyword */ - || kind === 121 /* BooleanKeyword */ - || kind === 135 /* StringKeyword */ - || kind === 136 /* SymbolKeyword */ - || kind === 104 /* VoidKeyword */ - || kind === 129 /* NeverKeyword */ - || kind === 200 /* ExpressionWithTypeArguments */; + return (kind >= 158 /* FirstTypeNode */ && kind <= 173 /* LastTypeNode */) + || kind === 119 /* AnyKeyword */ + || kind === 133 /* NumberKeyword */ + || kind === 134 /* ObjectKeyword */ + || kind === 122 /* BooleanKeyword */ + || kind === 136 /* StringKeyword */ + || kind === 137 /* SymbolKeyword */ + || kind === 99 /* ThisKeyword */ + || kind === 105 /* VoidKeyword */ + || kind === 139 /* UndefinedKeyword */ + || kind === 95 /* NullKeyword */ + || kind === 130 /* NeverKeyword */ + || kind === 201 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9965,36 +10030,36 @@ var ts; ts.isTypeNode = isTypeNode; // Binding patterns function isArrayBindingPattern(node) { - return node.kind === 174 /* ArrayBindingPattern */; + return node.kind === 175 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 173 /* ObjectBindingPattern */; + return node.kind === 174 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 174 /* ArrayBindingPattern */ - || kind === 173 /* ObjectBindingPattern */; + return kind === 175 /* ArrayBindingPattern */ + || kind === 174 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 176 /* ArrayLiteralExpression */ - || kind === 177 /* ObjectLiteralExpression */; + return kind === 177 /* ArrayLiteralExpression */ + || kind === 178 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 175 /* BindingElement */; + return node.kind === 176 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 175 /* BindingElement */ - || kind === 199 /* OmittedExpression */; + return kind === 176 /* BindingElement */ + || kind === 200 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -10002,9 +10067,9 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 225 /* VariableDeclaration */: - case 145 /* Parameter */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 176 /* BindingElement */: return true; } return false; @@ -10023,8 +10088,8 @@ var ts; */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173 /* ObjectBindingPattern */: - case 177 /* ObjectLiteralExpression */: + case 174 /* ObjectBindingPattern */: + case 178 /* ObjectLiteralExpression */: return true; } return false; @@ -10035,8 +10100,8 @@ var ts; */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 174 /* ArrayBindingPattern */: - case 176 /* ArrayLiteralExpression */: + case 175 /* ArrayBindingPattern */: + case 177 /* ArrayLiteralExpression */: return true; } return false; @@ -10044,86 +10109,92 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; // Expression function isArrayLiteralExpression(node) { - return node.kind === 176 /* ArrayLiteralExpression */; + return node.kind === 177 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 177 /* ObjectLiteralExpression */; + return node.kind === 178 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 178 /* PropertyAccessExpression */; + return node.kind === 179 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessOrQualifiedName(node) { + var kind = node.kind; + return kind === 179 /* PropertyAccessExpression */ + || kind === 143 /* QualifiedName */; + } + ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isElementAccessExpression(node) { - return node.kind === 179 /* ElementAccessExpression */; + return node.kind === 180 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 193 /* BinaryExpression */; + return node.kind === 194 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 194 /* ConditionalExpression */; + return node.kind === 195 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 180 /* CallExpression */; + return node.kind === 181 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 195 /* TemplateExpression */ - || kind === 12 /* NoSubstitutionTemplateLiteral */; + return kind === 196 /* TemplateExpression */ + || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 197 /* SpreadElement */; + return node.kind === 198 /* SpreadElement */; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 200 /* ExpressionWithTypeArguments */; + return node.kind === 201 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 178 /* PropertyAccessExpression */ - || kind === 179 /* ElementAccessExpression */ - || kind === 181 /* NewExpression */ - || kind === 180 /* CallExpression */ - || kind === 248 /* JsxElement */ - || kind === 249 /* JsxSelfClosingElement */ - || kind === 182 /* TaggedTemplateExpression */ - || kind === 176 /* ArrayLiteralExpression */ - || kind === 184 /* ParenthesizedExpression */ - || kind === 177 /* ObjectLiteralExpression */ - || kind === 198 /* ClassExpression */ - || kind === 185 /* FunctionExpression */ - || kind === 70 /* Identifier */ - || kind === 11 /* RegularExpressionLiteral */ + return kind === 179 /* PropertyAccessExpression */ + || kind === 180 /* ElementAccessExpression */ + || kind === 182 /* NewExpression */ + || kind === 181 /* CallExpression */ + || kind === 249 /* JsxElement */ + || kind === 250 /* JsxSelfClosingElement */ + || kind === 183 /* TaggedTemplateExpression */ + || kind === 177 /* ArrayLiteralExpression */ + || kind === 185 /* ParenthesizedExpression */ + || kind === 178 /* ObjectLiteralExpression */ + || kind === 199 /* ClassExpression */ + || kind === 186 /* FunctionExpression */ + || kind === 71 /* Identifier */ + || kind === 12 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ - || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 195 /* TemplateExpression */ - || kind === 85 /* FalseKeyword */ - || kind === 94 /* NullKeyword */ - || kind === 98 /* ThisKeyword */ - || kind === 100 /* TrueKeyword */ - || kind === 96 /* SuperKeyword */ - || kind === 202 /* NonNullExpression */ - || kind === 203 /* MetaProperty */; + || kind === 13 /* NoSubstitutionTemplateLiteral */ + || kind === 196 /* TemplateExpression */ + || kind === 86 /* FalseKeyword */ + || kind === 95 /* NullKeyword */ + || kind === 99 /* ThisKeyword */ + || kind === 101 /* TrueKeyword */ + || kind === 97 /* SuperKeyword */ + || kind === 203 /* NonNullExpression */ + || kind === 204 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 191 /* PrefixUnaryExpression */ - || kind === 192 /* PostfixUnaryExpression */ - || kind === 187 /* DeleteExpression */ - || kind === 188 /* TypeOfExpression */ - || kind === 189 /* VoidExpression */ - || kind === 190 /* AwaitExpression */ - || kind === 183 /* TypeAssertionExpression */ + return kind === 192 /* PrefixUnaryExpression */ + || kind === 193 /* PostfixUnaryExpression */ + || kind === 188 /* DeleteExpression */ + || kind === 189 /* TypeOfExpression */ + || kind === 190 /* VoidExpression */ + || kind === 191 /* AwaitExpression */ + || kind === 184 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10131,13 +10202,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 194 /* ConditionalExpression */ - || kind === 196 /* YieldExpression */ - || kind === 186 /* ArrowFunction */ - || kind === 193 /* BinaryExpression */ - || kind === 197 /* SpreadElement */ - || kind === 201 /* AsExpression */ - || kind === 199 /* OmittedExpression */ + return kind === 195 /* ConditionalExpression */ + || kind === 197 /* YieldExpression */ + || kind === 187 /* ArrowFunction */ + || kind === 194 /* BinaryExpression */ + || kind === 198 /* SpreadElement */ + || kind === 202 /* AsExpression */ + || kind === 200 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10146,16 +10217,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 183 /* TypeAssertionExpression */ - || kind === 201 /* AsExpression */; + return kind === 184 /* TypeAssertionExpression */ + || kind === 202 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 298 /* PartiallyEmittedExpression */; + return node.kind === 296 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 297 /* NotEmittedStatement */; + return node.kind === 295 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10164,17 +10235,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 199 /* OmittedExpression */; + return node.kind === 200 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 204 /* TemplateSpan */; + return node.kind === 205 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 206 /* Block */; + return node.kind === 207 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10192,135 +10263,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 225 /* VariableDeclaration */; + return node.kind === 226 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 226 /* VariableDeclarationList */; + return node.kind === 227 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 234 /* CaseBlock */; + return node.kind === 235 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 233 /* ModuleBlock */ - || kind === 232 /* ModuleDeclaration */ - || kind === 70 /* Identifier */; + return kind === 234 /* ModuleBlock */ + || kind === 233 /* ModuleDeclaration */ + || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 233 /* ModuleBlock */ - || kind === 232 /* ModuleDeclaration */; + return kind === 234 /* ModuleBlock */ + || kind === 233 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 70 /* Identifier */ - || kind === 232 /* ModuleDeclaration */; + return kind === 71 /* Identifier */ + || kind === 233 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */; + return node.kind === 237 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 238 /* ImportClause */; + return node.kind === 239 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 240 /* NamedImports */ - || kind === 239 /* NamespaceImport */; + return kind === 241 /* NamedImports */ + || kind === 240 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 241 /* ImportSpecifier */; + return node.kind === 242 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 244 /* NamedExports */; + return node.kind === 245 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 245 /* ExportSpecifier */; + return node.kind === 246 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 232 /* ModuleDeclaration */ || node.kind === 231 /* EnumDeclaration */; + return node.kind === 233 /* ModuleDeclaration */ || node.kind === 232 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 186 /* ArrowFunction */ - || kind === 175 /* BindingElement */ - || kind === 228 /* ClassDeclaration */ - || kind === 198 /* ClassExpression */ - || kind === 151 /* Constructor */ - || kind === 231 /* EnumDeclaration */ - || kind === 263 /* EnumMember */ - || kind === 245 /* ExportSpecifier */ - || kind === 227 /* FunctionDeclaration */ - || kind === 185 /* FunctionExpression */ - || kind === 152 /* GetAccessor */ - || kind === 238 /* ImportClause */ - || kind === 236 /* ImportEqualsDeclaration */ - || kind === 241 /* ImportSpecifier */ - || kind === 229 /* InterfaceDeclaration */ - || kind === 252 /* JsxAttribute */ - || kind === 150 /* MethodDeclaration */ - || kind === 149 /* MethodSignature */ - || kind === 232 /* ModuleDeclaration */ - || kind === 235 /* NamespaceExportDeclaration */ - || kind === 239 /* NamespaceImport */ - || kind === 145 /* Parameter */ - || kind === 260 /* PropertyAssignment */ - || kind === 148 /* PropertyDeclaration */ - || kind === 147 /* PropertySignature */ - || kind === 153 /* SetAccessor */ - || kind === 261 /* ShorthandPropertyAssignment */ - || kind === 230 /* TypeAliasDeclaration */ - || kind === 144 /* TypeParameter */ - || kind === 225 /* VariableDeclaration */ - || kind === 289 /* JSDocTypedefTag */; + return kind === 187 /* ArrowFunction */ + || kind === 176 /* BindingElement */ + || kind === 229 /* ClassDeclaration */ + || kind === 199 /* ClassExpression */ + || kind === 152 /* Constructor */ + || kind === 232 /* EnumDeclaration */ + || kind === 264 /* EnumMember */ + || kind === 246 /* ExportSpecifier */ + || kind === 228 /* FunctionDeclaration */ + || kind === 186 /* FunctionExpression */ + || kind === 153 /* GetAccessor */ + || kind === 239 /* ImportClause */ + || kind === 237 /* ImportEqualsDeclaration */ + || kind === 242 /* ImportSpecifier */ + || kind === 230 /* InterfaceDeclaration */ + || kind === 253 /* JsxAttribute */ + || kind === 151 /* MethodDeclaration */ + || kind === 150 /* MethodSignature */ + || kind === 233 /* ModuleDeclaration */ + || kind === 236 /* NamespaceExportDeclaration */ + || kind === 240 /* NamespaceImport */ + || kind === 146 /* Parameter */ + || kind === 261 /* PropertyAssignment */ + || kind === 149 /* PropertyDeclaration */ + || kind === 148 /* PropertySignature */ + || kind === 154 /* SetAccessor */ + || kind === 262 /* ShorthandPropertyAssignment */ + || kind === 231 /* TypeAliasDeclaration */ + || kind === 145 /* TypeParameter */ + || kind === 226 /* VariableDeclaration */ + || kind === 290 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 227 /* FunctionDeclaration */ - || kind === 246 /* MissingDeclaration */ - || kind === 228 /* ClassDeclaration */ - || kind === 229 /* InterfaceDeclaration */ - || kind === 230 /* TypeAliasDeclaration */ - || kind === 231 /* EnumDeclaration */ - || kind === 232 /* ModuleDeclaration */ - || kind === 237 /* ImportDeclaration */ - || kind === 236 /* ImportEqualsDeclaration */ - || kind === 243 /* ExportDeclaration */ - || kind === 242 /* ExportAssignment */ - || kind === 235 /* NamespaceExportDeclaration */; + return kind === 228 /* FunctionDeclaration */ + || kind === 247 /* MissingDeclaration */ + || kind === 229 /* ClassDeclaration */ + || kind === 230 /* InterfaceDeclaration */ + || kind === 231 /* TypeAliasDeclaration */ + || kind === 232 /* EnumDeclaration */ + || kind === 233 /* ModuleDeclaration */ + || kind === 238 /* ImportDeclaration */ + || kind === 237 /* ImportEqualsDeclaration */ + || kind === 244 /* ExportDeclaration */ + || kind === 243 /* ExportAssignment */ + || kind === 236 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 217 /* BreakStatement */ - || kind === 216 /* ContinueStatement */ - || kind === 224 /* DebuggerStatement */ - || kind === 211 /* DoStatement */ - || kind === 209 /* ExpressionStatement */ - || kind === 208 /* EmptyStatement */ - || kind === 214 /* ForInStatement */ - || kind === 215 /* ForOfStatement */ - || kind === 213 /* ForStatement */ - || kind === 210 /* IfStatement */ - || kind === 221 /* LabeledStatement */ - || kind === 218 /* ReturnStatement */ - || kind === 220 /* SwitchStatement */ - || kind === 222 /* ThrowStatement */ - || kind === 223 /* TryStatement */ - || kind === 207 /* VariableStatement */ - || kind === 212 /* WhileStatement */ - || kind === 219 /* WithStatement */ - || kind === 297 /* NotEmittedStatement */ - || kind === 300 /* EndOfDeclarationMarker */ - || kind === 299 /* MergeDeclarationMarker */; + return kind === 218 /* BreakStatement */ + || kind === 217 /* ContinueStatement */ + || kind === 225 /* DebuggerStatement */ + || kind === 212 /* DoStatement */ + || kind === 210 /* ExpressionStatement */ + || kind === 209 /* EmptyStatement */ + || kind === 215 /* ForInStatement */ + || kind === 216 /* ForOfStatement */ + || kind === 214 /* ForStatement */ + || kind === 211 /* IfStatement */ + || kind === 222 /* LabeledStatement */ + || kind === 219 /* ReturnStatement */ + || kind === 221 /* SwitchStatement */ + || kind === 223 /* ThrowStatement */ + || kind === 224 /* TryStatement */ + || kind === 208 /* VariableStatement */ + || kind === 213 /* WhileStatement */ + || kind === 220 /* WithStatement */ + || kind === 295 /* NotEmittedStatement */ + || kind === 298 /* EndOfDeclarationMarker */ + || kind === 297 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10341,102 +10412,104 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 206 /* Block */; + || kind === 207 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 247 /* ExternalModuleReference */ - || kind === 142 /* QualifiedName */ - || kind === 70 /* Identifier */; + return kind === 248 /* ExternalModuleReference */ + || kind === 143 /* QualifiedName */ + || kind === 71 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 250 /* JsxOpeningElement */; + return node.kind === 251 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 251 /* JsxClosingElement */; + return node.kind === 252 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 98 /* ThisKeyword */ - || kind === 70 /* Identifier */ - || kind === 178 /* PropertyAccessExpression */; + return kind === 99 /* ThisKeyword */ + || kind === 71 /* Identifier */ + || kind === 179 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 248 /* JsxElement */ - || kind === 255 /* JsxExpression */ - || kind === 249 /* JsxSelfClosingElement */ + return kind === 249 /* JsxElement */ + || kind === 256 /* JsxExpression */ + || kind === 250 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributes(node) { var kind = node.kind; - return kind === 253 /* JsxAttributes */; + return kind === 254 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 252 /* JsxAttribute */ - || kind === 254 /* JsxSpreadAttribute */; + return kind === 253 /* JsxAttribute */ + || kind === 255 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 254 /* JsxSpreadAttribute */; + return node.kind === 255 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 252 /* JsxAttribute */; + return node.kind === 253 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; - function isJsxOpeningLikeElement(node) { - return node.kind === 250 /* JsxOpeningElement */ || node.kind === 249 /* JsxSelfClosingElement */; - } - ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 255 /* JsxExpression */; + || kind === 256 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isJsxOpeningLikeElement(node) { + var kind = node.kind; + return kind === 251 /* JsxOpeningElement */ + || kind === 250 /* JsxSelfClosingElement */; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 256 /* CaseClause */ - || kind === 257 /* DefaultClause */; + return kind === 257 /* CaseClause */ + || kind === 258 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 258 /* HeritageClause */; + return node.kind === 259 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 259 /* CatchClause */; + return node.kind === 260 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 260 /* PropertyAssignment */; + return node.kind === 261 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 261 /* ShorthandPropertyAssignment */; + return node.kind === 262 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 263 /* EnumMember */; + return node.kind === 264 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 264 /* SourceFile */; + return node.kind === 265 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10449,12 +10522,13 @@ var ts; function getDefaultLibFileName(options) { switch (options.target) { case 5 /* ESNext */: + return "lib.esnext.full.d.ts"; case 4 /* ES2017 */: - return "lib.es2017.d.ts"; + return "lib.es2017.full.d.ts"; case 3 /* ES2016 */: - return "lib.es2016.d.ts"; + return "lib.es2016.full.d.ts"; case 2 /* ES2015 */: - return "lib.es6.d.ts"; + return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; } @@ -10662,13 +10736,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 144 /* TypeParameter */) { + if (d && d.kind === 145 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 230 /* InterfaceDeclaration */) { return current; } } @@ -10676,11 +10750,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 151 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 152 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 175 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 176 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10688,14 +10762,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 225 /* VariableDeclaration */) { + if (node.kind === 226 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 226 /* VariableDeclarationList */) { + if (node && node.kind === 227 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 207 /* VariableStatement */) { + if (node && node.kind === 208 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10711,23 +10785,23 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 225 /* VariableDeclaration */) { + if (node.kind === 226 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 226 /* VariableDeclarationList */) { + if (node && node.kind === 227 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 207 /* VariableStatement */) { + if (node && node.kind === 208 /* VariableStatement */) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** - * Checks to see if the locale is in the appropriate format, - * and if it is, attempts to set the appropriate language. - */ + * Checks to see if the locale is in the appropriate format, + * and if it is, attempts to set the appropriate language. + */ function validateLocaleAndSetLanguage(locale, sys, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -10797,7 +10871,7 @@ var ts; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { + if (node === undefined || isParseTreeNode(node)) { return node; } node = getOriginalNode(node); @@ -10895,6 +10969,7 @@ var ts; function createNumericLiteral(value) { var node = createSynthesizedNode(8 /* NumericLiteral */); node.text = value; + node.numericLiteralFlags = 0; return node; } ts.createNumericLiteral = createNumericLiteral; @@ -10910,7 +10985,7 @@ var ts; } // Identifiers function createIdentifier(text) { - var node = createSynthesizedNode(70 /* Identifier */); + var node = createSynthesizedNode(71 /* Identifier */); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateKind = 0 /* None */; @@ -10966,28 +11041,28 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(96 /* SuperKeyword */); + return createSynthesizedNode(97 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(98 /* ThisKeyword */); + return createSynthesizedNode(99 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(94 /* NullKeyword */); + return createSynthesizedNode(95 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(100 /* TrueKeyword */); + return createSynthesizedNode(101 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(85 /* FalseKeyword */); + return createSynthesizedNode(86 /* FalseKeyword */); } ts.createFalse = createFalse; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(142 /* QualifiedName */); + var node = createSynthesizedNode(143 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -11001,7 +11076,7 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function createComputedPropertyName(expression) { - var node = createSynthesizedNode(143 /* ComputedPropertyName */); + var node = createSynthesizedNode(144 /* ComputedPropertyName */); node.expression = expression; return node; } @@ -11012,9 +11087,290 @@ var ts; : node; } ts.updateComputedPropertyName = updateComputedPropertyName; + // Type Elements + function createSignatureDeclaration(kind, typeParameters, parameters, type) { + var signatureDeclaration = createSynthesizedNode(kind); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + ts.createSignatureDeclaration = createSignatureDeclaration; + function updateSignatureDeclaration(node, typeParameters, parameters, type) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + function createFunctionTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(160 /* FunctionType */, typeParameters, parameters, type); + } + ts.createFunctionTypeNode = createFunctionTypeNode; + function updateFunctionTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateFunctionTypeNode = updateFunctionTypeNode; + function createConstructorTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(161 /* ConstructorType */, typeParameters, parameters, type); + } + ts.createConstructorTypeNode = createConstructorTypeNode; + function updateConstructorTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructorTypeNode = updateConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(155 /* CallSignature */, typeParameters, parameters, type); + } + ts.createCallSignatureDeclaration = createCallSignatureDeclaration; + function updateCallSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateCallSignatureDeclaration = updateCallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(156 /* ConstructSignature */, typeParameters, parameters, type); + } + ts.createConstructSignatureDeclaration = createConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructSignatureDeclaration = updateConstructSignatureDeclaration; + function createMethodSignature(typeParameters, parameters, type, name, questionToken) { + var methodSignature = createSignatureDeclaration(150 /* MethodSignature */, typeParameters, parameters, type); + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + ts.createMethodSignature = createMethodSignature; + function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + ts.updateMethodSignature = updateMethodSignature; + // Types + function createKeywordTypeNode(kind) { + return createSynthesizedNode(kind); + } + ts.createKeywordTypeNode = createKeywordTypeNode; + function createThisTypeNode() { + return createSynthesizedNode(169 /* ThisType */); + } + ts.createThisTypeNode = createThisTypeNode; + function createLiteralTypeNode(literal) { + var literalTypeNode = createSynthesizedNode(173 /* LiteralType */); + literalTypeNode.literal = literal; + return literalTypeNode; + } + ts.createLiteralTypeNode = createLiteralTypeNode; + function updateLiteralTypeNode(node, literal) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + ts.updateLiteralTypeNode = updateLiteralTypeNode; + function createTypeReferenceNode(typeName, typeArguments) { + var typeReference = createSynthesizedNode(159 /* TypeReference */); + typeReference.typeName = asName(typeName); + typeReference.typeArguments = asNodeArray(typeArguments); + return typeReference; + } + ts.createTypeReferenceNode = createTypeReferenceNode; + function updateTypeReferenceNode(node, typeName, typeArguments) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + ts.updateTypeReferenceNode = updateTypeReferenceNode; + function createTypePredicateNode(parameterName, type) { + var typePredicateNode = createSynthesizedNode(158 /* TypePredicate */); + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + ts.createTypePredicateNode = createTypePredicateNode; + function updateTypePredicateNode(node, parameterName, type) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function createTypeQueryNode(exprName) { + var typeQueryNode = createSynthesizedNode(162 /* TypeQuery */); + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + ts.createTypeQueryNode = createTypeQueryNode; + function updateTypeQueryNode(node, exprName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; + } + ts.updateTypeQueryNode = updateTypeQueryNode; + function createArrayTypeNode(elementType) { + var arrayTypeNode = createSynthesizedNode(164 /* ArrayType */); + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + ts.createArrayTypeNode = createArrayTypeNode; + function updateArrayTypeNode(node, elementType) { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + ts.updateArrayTypeNode = updateArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind, types) { + var unionTypeNode = createSynthesizedNode(kind); + unionTypeNode.types = createNodeArray(types); + return unionTypeNode; + } + ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node, types) { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + ts.updateUnionOrIntersectionTypeNode = updateUnionOrIntersectionTypeNode; + function createParenthesizedType(type) { + var node = createSynthesizedNode(168 /* ParenthesizedType */); + node.type = type; + return node; + } + ts.createParenthesizedType = createParenthesizedType; + function updateParenthesizedType(node, type) { + return node.type !== type + ? updateNode(createParenthesizedType(type), node) + : node; + } + ts.updateParenthesizedType = updateParenthesizedType; + function createTypeLiteralNode(members) { + var typeLiteralNode = createSynthesizedNode(163 /* TypeLiteral */); + typeLiteralNode.members = createNodeArray(members); + return typeLiteralNode; + } + ts.createTypeLiteralNode = createTypeLiteralNode; + function updateTypeLiteralNode(node, members) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + ts.updateTypeLiteralNode = updateTypeLiteralNode; + function createTupleTypeNode(elementTypes) { + var tupleTypeNode = createSynthesizedNode(165 /* TupleType */); + tupleTypeNode.elementTypes = createNodeArray(elementTypes); + return tupleTypeNode; + } + ts.createTupleTypeNode = createTupleTypeNode; + function updateTypleTypeNode(node, elementTypes) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + ts.updateTypleTypeNode = updateTypleTypeNode; + function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { + var mappedTypeNode = createSynthesizedNode(172 /* MappedType */); + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + ts.createMappedTypeNode = createMappedTypeNode; + function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + ts.updateMappedTypeNode = updateMappedTypeNode; + function createTypeOperatorNode(type) { + var typeOperatorNode = createSynthesizedNode(170 /* TypeOperator */); + typeOperatorNode.operator = 127 /* KeyOfKeyword */; + typeOperatorNode.type = type; + return typeOperatorNode; + } + ts.createTypeOperatorNode = createTypeOperatorNode; + function updateTypeOperatorNode(node, type) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + ts.updateTypeOperatorNode = updateTypeOperatorNode; + function createIndexedAccessTypeNode(objectType, indexType) { + var indexedAccessTypeNode = createSynthesizedNode(171 /* IndexedAccessType */); + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node, objectType, indexType) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; + // Type Declarations + function createTypeParameterDeclaration(name, constraint, defaultType) { + var typeParameter = createSynthesizedNode(145 /* TypeParameter */); + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultType; + return typeParameter; + } + ts.createTypeParameterDeclaration = createTypeParameterDeclaration; + function updateTypeParameterDeclaration(node, name, constraint, defaultType) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) + : node; + } + ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; + // Signature elements + function createPropertySignature(name, questionToken, type, initializer) { + var propertySignature = createSynthesizedNode(148 /* PropertySignature */); + propertySignature.name = asName(name); + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + ts.createPropertySignature = createPropertySignature; + function updatePropertySignature(node, name, questionToken, type, initializer) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + ts.updatePropertySignature = updatePropertySignature; + function createIndexSignatureDeclaration(decorators, modifiers, parameters, type) { + var indexSignature = createSynthesizedNode(157 /* IndexSignature */); + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; + return indexSignature; + } + ts.createIndexSignatureDeclaration = createIndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node, decorators, modifiers, parameters, type) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) + : node; + } + ts.updateIndexSignatureDeclaration = updateIndexSignatureDeclaration; // Signature elements function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(145 /* Parameter */); + var node = createSynthesizedNode(146 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -11025,11 +11381,12 @@ var ts; return node; } ts.createParameter = createParameter; - function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { + function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -11037,7 +11394,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(146 /* Decorator */); + var node = createSynthesizedNode(147 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -11050,7 +11407,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148 /* PropertyDeclaration */); + var node = createSynthesizedNode(149 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11070,33 +11427,35 @@ var ts; : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(150 /* MethodDeclaration */); + function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(151 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - ts.createMethod = createMethod; - function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + ts.createMethodDeclaration = createMethodDeclaration; + function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(151 /* Constructor */); + var node = createSynthesizedNode(152 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -11116,7 +11475,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(152 /* GetAccessor */); + var node = createSynthesizedNode(153 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11139,7 +11498,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(153 /* SetAccessor */); + var node = createSynthesizedNode(154 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11161,7 +11520,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(173 /* ObjectBindingPattern */); + var node = createSynthesizedNode(174 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -11173,7 +11532,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(174 /* ArrayBindingPattern */); + var node = createSynthesizedNode(175 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -11184,10 +11543,10 @@ var ts; : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer) { - var node = createSynthesizedNode(175 /* BindingElement */); - node.propertyName = asName(propertyName); + function createBindingElement(dotDotDotToken, propertyName, name, initializer) { + var node = createSynthesizedNode(176 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; + node.propertyName = asName(propertyName); node.name = asName(name); node.initializer = initializer; return node; @@ -11198,13 +11557,13 @@ var ts; || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer - ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) : node; } ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(176 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(177 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -11219,7 +11578,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(177 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(178 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11234,10 +11593,10 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(178 /* PropertyAccessExpression */); + var node = createSynthesizedNode(179 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); - setEmitFlags(node, 65536 /* NoIndentation */); + setEmitFlags(node, 131072 /* NoIndentation */); return node; } ts.createPropertyAccess = createPropertyAccess; @@ -11251,7 +11610,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(179 /* ElementAccessExpression */); + var node = createSynthesizedNode(180 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -11265,7 +11624,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(180 /* CallExpression */); + var node = createSynthesizedNode(181 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -11281,7 +11640,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(181 /* NewExpression */); + var node = createSynthesizedNode(182 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -11297,7 +11656,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template) { - var node = createSynthesizedNode(182 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(183 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; @@ -11311,7 +11670,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(183 /* TypeAssertionExpression */); + var node = createSynthesizedNode(184 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -11325,7 +11684,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(184 /* ParenthesizedExpression */); + var node = createSynthesizedNode(185 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -11337,7 +11696,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(185 /* FunctionExpression */); + var node = createSynthesizedNode(186 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -11348,24 +11707,25 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.name !== name || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(186 /* ArrowFunction */); + var node = createSynthesizedNode(187 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -11381,7 +11741,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(187 /* DeleteExpression */); + var node = createSynthesizedNode(188 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11393,7 +11753,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(188 /* TypeOfExpression */); + var node = createSynthesizedNode(189 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11405,7 +11765,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(189 /* VoidExpression */); + var node = createSynthesizedNode(190 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11417,7 +11777,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(190 /* AwaitExpression */); + var node = createSynthesizedNode(191 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11429,7 +11789,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(191 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(192 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -11442,7 +11802,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(192 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(193 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -11455,7 +11815,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(193 /* BinaryExpression */); + var node = createSynthesizedNode(194 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -11472,11 +11832,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(194 /* ConditionalExpression */); + var node = createSynthesizedNode(195 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(55 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -11490,7 +11850,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(195 /* TemplateExpression */); + var node = createSynthesizedNode(196 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -11504,20 +11864,21 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(196 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(197 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; - function updateYield(node, expression) { + function updateYield(node, asteriskToken, expression) { return node.expression !== expression - ? updateNode(createYield(node.asteriskToken, expression), node) + || node.asteriskToken !== asteriskToken + ? updateNode(createYield(asteriskToken, expression), node) : node; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(197 /* SpreadElement */); + var node = createSynthesizedNode(198 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -11529,7 +11890,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(198 /* ClassExpression */); + var node = createSynthesizedNode(199 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11550,11 +11911,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(199 /* OmittedExpression */); + return createSynthesizedNode(200 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(200 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(201 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -11568,7 +11929,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(201 /* AsExpression */); + var node = createSynthesizedNode(202 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -11582,7 +11943,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(202 /* NonNullExpression */); + var node = createSynthesizedNode(203 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -11595,7 +11956,7 @@ var ts; ts.updateNonNullExpression = updateNonNullExpression; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(204 /* TemplateSpan */); + var node = createSynthesizedNode(205 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -11610,7 +11971,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(206 /* Block */); + var block = createSynthesizedNode(207 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -11624,7 +11985,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(207 /* VariableStatement */); + var node = createSynthesizedNode(208 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11639,7 +12000,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(226 /* VariableDeclarationList */); + var node = createSynthesizedNode(227 /* VariableDeclarationList */); node.flags |= flags; node.declarations = createNodeArray(declarations); return node; @@ -11652,7 +12013,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(225 /* VariableDeclaration */); + var node = createSynthesizedNode(226 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -11668,11 +12029,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement() { - return createSynthesizedNode(208 /* EmptyStatement */); + return createSynthesizedNode(209 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { - var node = createSynthesizedNode(209 /* ExpressionStatement */); + var node = createSynthesizedNode(210 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11684,7 +12045,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(210 /* IfStatement */); + var node = createSynthesizedNode(211 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11700,7 +12061,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(211 /* DoStatement */); + var node = createSynthesizedNode(212 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -11714,7 +12075,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(212 /* WhileStatement */); + var node = createSynthesizedNode(213 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -11728,7 +12089,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(213 /* ForStatement */); + var node = createSynthesizedNode(214 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11746,7 +12107,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(214 /* ForInStatement */); + var node = createSynthesizedNode(215 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11761,24 +12122,26 @@ var ts; : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement) { - var node = createSynthesizedNode(215 /* ForOfStatement */); + function createForOf(awaitModifier, initializer, expression, statement) { + var node = createSynthesizedNode(216 /* ForOfStatement */); + node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; node.statement = statement; return node; } ts.createForOf = createForOf; - function updateForOf(node, initializer, expression, statement) { - return node.initializer !== initializer + function updateForOf(node, awaitModifier, initializer, expression, statement) { + return node.awaitModifier !== awaitModifier + || node.initializer !== initializer || node.expression !== expression || node.statement !== statement - ? updateNode(createForOf(initializer, expression, statement), node) + ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node) : node; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(216 /* ContinueStatement */); + var node = createSynthesizedNode(217 /* ContinueStatement */); node.label = asName(label); return node; } @@ -11790,7 +12153,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(217 /* BreakStatement */); + var node = createSynthesizedNode(218 /* BreakStatement */); node.label = asName(label); return node; } @@ -11802,7 +12165,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(218 /* ReturnStatement */); + var node = createSynthesizedNode(219 /* ReturnStatement */); node.expression = expression; return node; } @@ -11814,7 +12177,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(219 /* WithStatement */); + var node = createSynthesizedNode(220 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -11828,7 +12191,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(220 /* SwitchStatement */); + var node = createSynthesizedNode(221 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11842,7 +12205,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(221 /* LabeledStatement */); + var node = createSynthesizedNode(222 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -11856,7 +12219,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(222 /* ThrowStatement */); + var node = createSynthesizedNode(223 /* ThrowStatement */); node.expression = expression; return node; } @@ -11868,7 +12231,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(223 /* TryStatement */); + var node = createSynthesizedNode(224 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11884,7 +12247,7 @@ var ts; } ts.updateTry = updateTry; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(227 /* FunctionDeclaration */); + var node = createSynthesizedNode(228 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -11896,20 +12259,21 @@ var ts; return node; } ts.createFunctionDeclaration = createFunctionDeclaration; - function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(228 /* ClassDeclaration */); + var node = createSynthesizedNode(229 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11931,7 +12295,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(231 /* EnumDeclaration */); + var node = createSynthesizedNode(232 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11949,7 +12313,7 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(232 /* ModuleDeclaration */); + var node = createSynthesizedNode(233 /* ModuleDeclaration */); node.flags |= flags; node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -11968,7 +12332,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(234 /* CaseBlock */); + var node = createSynthesizedNode(234 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -11980,7 +12344,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(234 /* CaseBlock */); + var node = createSynthesizedNode(235 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -11992,7 +12356,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(236 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(237 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -12010,7 +12374,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(237 /* ImportDeclaration */); + var node = createSynthesizedNode(238 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -12027,7 +12391,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(238 /* ImportClause */); + var node = createSynthesizedNode(239 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -12041,7 +12405,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(239 /* NamespaceImport */); + var node = createSynthesizedNode(240 /* NamespaceImport */); node.name = name; return node; } @@ -12053,7 +12417,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(240 /* NamedImports */); + var node = createSynthesizedNode(241 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -12065,7 +12429,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(241 /* ImportSpecifier */); + var node = createSynthesizedNode(242 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -12079,7 +12443,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(242 /* ExportAssignment */); + var node = createSynthesizedNode(243 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -12096,7 +12460,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(243 /* ExportDeclaration */); + var node = createSynthesizedNode(244 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -12114,7 +12478,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(244 /* NamedExports */); + var node = createSynthesizedNode(245 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -12125,22 +12489,23 @@ var ts; : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName) { - var node = createSynthesizedNode(245 /* ExportSpecifier */); - node.name = asName(name); + function createExportSpecifier(propertyName, name) { + var node = createSynthesizedNode(246 /* ExportSpecifier */); node.propertyName = asName(propertyName); + node.name = asName(name); return node; } ts.createExportSpecifier = createExportSpecifier; - function updateExportSpecifier(node, name, propertyName) { - return node.name !== name || node.propertyName !== propertyName - ? updateNode(createExportSpecifier(name, propertyName), node) + function updateExportSpecifier(node, propertyName, name) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createExportSpecifier(propertyName, name), node) : node; } ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(247 /* ExternalModuleReference */); + var node = createSynthesizedNode(248 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -12153,7 +12518,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(248 /* JsxElement */); + var node = createSynthesizedNode(249 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -12169,7 +12534,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes) { - var node = createSynthesizedNode(249 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(250 /* JsxSelfClosingElement */); node.tagName = tagName; node.attributes = attributes; return node; @@ -12183,7 +12548,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes) { - var node = createSynthesizedNode(250 /* JsxOpeningElement */); + var node = createSynthesizedNode(251 /* JsxOpeningElement */); node.tagName = tagName; node.attributes = attributes; return node; @@ -12197,7 +12562,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(251 /* JsxClosingElement */); + var node = createSynthesizedNode(252 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -12209,7 +12574,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttributes(properties) { - var jsxAttributes = createSynthesizedNode(253 /* JsxAttributes */); + var jsxAttributes = createSynthesizedNode(254 /* JsxAttributes */); jsxAttributes.properties = createNodeArray(properties); return jsxAttributes; } @@ -12222,7 +12587,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(252 /* JsxAttribute */); + var node = createSynthesizedNode(253 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -12236,7 +12601,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(254 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(255 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -12247,8 +12612,8 @@ var ts; : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken) { - var node = createSynthesizedNode(255 /* JsxExpression */); + function createJsxExpression(dotDotDotToken, expression) { + var node = createSynthesizedNode(256 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -12256,13 +12621,13 @@ var ts; ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { return node.expression !== expression - ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node) : node; } ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types) { - var node = createSynthesizedNode(258 /* HeritageClause */); + var node = createSynthesizedNode(259 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -12276,7 +12641,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(256 /* CaseClause */); + var node = createSynthesizedNode(257 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -12290,7 +12655,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(257 /* DefaultClause */); + var node = createSynthesizedNode(258 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -12303,7 +12668,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(259 /* CatchClause */); + var node = createSynthesizedNode(260 /* CatchClause */); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -12318,7 +12683,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(260 /* PropertyAssignment */); + var node = createSynthesizedNode(261 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -12333,18 +12698,12 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(261 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(262 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression) { - var node = createSynthesizedNode(262 /* SpreadAssignment */); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; - return node; - } - ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); @@ -12352,6 +12711,12 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(263 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { return updateNode(createSpreadAssignment(expression), node); @@ -12361,7 +12726,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(263 /* EnumMember */); + var node = createSynthesizedNode(264 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -12377,7 +12742,7 @@ var ts; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createSynthesizedNode(264 /* SourceFile */); + var updated = createSynthesizedNode(265 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -12456,7 +12821,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(297 /* NotEmittedStatement */); + var node = createSynthesizedNode(295 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -12468,7 +12833,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(300 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(298 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12480,7 +12845,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(299 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(297 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12495,7 +12860,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(296 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -12510,7 +12875,7 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createBundle(sourceFiles) { - var node = ts.createNode(265 /* Bundle */); + var node = ts.createNode(266 /* Bundle */); node.sourceFiles = sourceFiles; return node; } @@ -12524,47 +12889,47 @@ var ts; ts.updateBundle = updateBundle; // Compound nodes function createComma(left, right) { - return createBinary(left, 25 /* CommaToken */, right); + return createBinary(left, 26 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 26 /* LessThanToken */, right); + return createBinary(left, 27 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 57 /* EqualsToken */, right); + return createBinary(left, 58 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 33 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 34 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 36 /* PlusToken */, right); + return createBinary(left, 37 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 37 /* MinusToken */, right); + return createBinary(left, 38 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 42 /* PlusPlusToken */); + return createPostfix(operand, 43 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 52 /* AmpersandAmpersandToken */, right); + return createBinary(left, 53 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 53 /* BarBarToken */, right); + return createBinary(left, 54 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(50 /* ExclamationToken */, operand); + return createPrefix(51 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -12576,7 +12941,7 @@ var ts; } ts.createExportDefault = createExportDefault; function createExternalModuleExport(exportName) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(/*propertyName*/ undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; function asName(name) { @@ -12624,7 +12989,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12710,6 +13075,34 @@ var ts; return node; } ts.setCommentRange = setCommentRange; + function getSyntheticLeadingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.leadingComments; + } + ts.getSyntheticLeadingComments = getSyntheticLeadingComments; + function setSyntheticLeadingComments(node, comments) { + getOrCreateEmitNode(node).leadingComments = comments; + return node; + } + ts.setSyntheticLeadingComments = setSyntheticLeadingComments; + function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticLeadingComment = addSyntheticLeadingComment; + function getSyntheticTrailingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.trailingComments; + } + ts.getSyntheticTrailingComments = getSyntheticTrailingComments; + function setSyntheticTrailingComments(node, comments) { + getOrCreateEmitNode(node).trailingComments = comments; + return node; + } + ts.setSyntheticTrailingComments = setSyntheticTrailingComments; + function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticTrailingComment = addSyntheticTrailingComment; /** * Gets the constant value to emit for an expression. */ @@ -12825,9 +13218,13 @@ var ts; } ts.setOriginalNode = setOriginalNode; function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + var flags = sourceEmitNode.flags, leadingComments = sourceEmitNode.leadingComments, trailingComments = sourceEmitNode.trailingComments, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; if (!destEmitNode) destEmitNode = {}; + if (leadingComments) + destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) + destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; if (commentRange) @@ -12962,12 +13359,72 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + var valuesHelper = { + name: "typescript:values", + scoped: false, + text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };\n " + }; + function createValuesHelper(context, expression, location) { + context.requestEmitHelper(valuesHelper); + return ts.setTextRange(ts.createCall(getHelperName("__values"), + /*typeArguments*/ undefined, [expression]), location); + } + ts.createValuesHelper = createValuesHelper; + var readHelper = { + name: "typescript:read", + scoped: false, + text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };\n " + }; + function createReadHelper(context, iteratorRecord, count, location) { + context.requestEmitHelper(readHelper); + return ts.setTextRange(ts.createCall(getHelperName("__read"), + /*typeArguments*/ undefined, count !== undefined + ? [iteratorRecord, ts.createLiteral(count)] + : [iteratorRecord]), location); + } + ts.createReadHelper = createReadHelper; + var spreadHelper = { + name: "typescript:spread", + scoped: false, + text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" + }; + function createSpreadHelper(context, argumentList, location) { + context.requestEmitHelper(readHelper); + context.requestEmitHelper(spreadHelper); + return ts.setTextRange(ts.createCall(getHelperName("__spread"), + /*typeArguments*/ undefined, argumentList), location); + } + ts.createSpreadHelper = createSpreadHelper; // Utilities + function createForOfBindingStatement(node, boundValue) { + if (ts.isVariableDeclarationList(node)) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, + /*typeNode*/ undefined, boundValue); + return ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), + /*location*/ node); + } + else { + var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), /*location*/ node); + return ts.setTextRange(ts.createStatement(updatedExpression), /*location*/ node); + } + } + ts.createForOfBindingStatement = createForOfBindingStatement; + function insertLeadingStatement(dest, source) { + if (ts.isBlock(dest)) { + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + } + else { + return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); + } + } + ts.insertLeadingStatement = insertLeadingStatement; function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 222 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -12979,19 +13436,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return cacheIdentifiers; - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -13005,15 +13462,19 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 96 /* SuperKeyword */) { + else if (callee.kind === 97 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) : callee; } + else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(callee); + } else { switch (callee.kind) { - case 178 /* PropertyAccessExpression */: { + case 179 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -13026,7 +13487,7 @@ var ts; } break; } - case 179 /* ElementAccessExpression */: { + case 180 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -13079,14 +13540,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -13148,6 +13609,28 @@ var ts; /*location*/ method), /*original*/ method)); } + /** + * Gets the internal name of a declaration. This is primarily used for declarations that can be + * referred to by name in the body of an ES5 class function body. An internal name will *never* + * be prefixed with an module or namespace export modifier like "exports." when emitted as an + * expression. An internal name will also *never* be renamed due to a collision with a block + * scoped variable. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getInternalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + } + ts.getInternalName = getInternalName; + /** + * Gets whether an identifier should only be referred to by its internal name. + */ + function isInternalName(node) { + return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + } + ts.isInternalName = isInternalName; /** * Gets the local name of a declaration. This is primarily used for declarations that can be * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A @@ -13273,7 +13756,18 @@ var ts; * @param ensureUseStrict: boolean determining whether the function need to add prologue-directives * @param visitor: Optional callback used to visit any custom prologue directives. */ - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + function addPrologue(target, source, ensureUseStrict, visitor) { + var offset = addStandardPrologue(target, source, ensureUseStrict); + return addCustomPrologue(target, source, offset, visitor); + } + ts.addPrologue = addPrologue; + /** + * Add just the standard (string-expression) prologue-directives into target statement-array. + * The function needs to be called during each transformation step. + * This function needs to be called whenever we transform the statement + * list of a source file, namespace, or function-like body. + */ + function addStandardPrologue(target, source, ensureUseStrict) { ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; @@ -13294,9 +13788,20 @@ var ts; if (ensureUseStrict && !foundUseStrict) { target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } + return statementOffset; + } + ts.addStandardPrologue = addStandardPrologue; + /** + * Add just the custom prologue-directives into target statement-array. + * The function needs to be called during each transformation step. + * This function needs to be called whenever we transform the statement + * list of a source file, namespace, or function-like body. + */ + function addCustomPrologue(target, source, statementOffset, visitor) { + var numStatements = source.length; while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -13306,7 +13811,7 @@ var ts; } return statementOffset; } - ts.addPrologueDirectives = addPrologueDirectives; + ts.addCustomPrologue = addCustomPrologue; function startsWithUseStrict(statements) { var firstStatement = ts.firstOrUndefined(statements); return firstStatement !== undefined @@ -13341,6 +13846,16 @@ var ts; return statements; } ts.ensureUseStrict = ensureUseStrict; + function parenthesizeConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(195 /* ConditionalExpression */, 55 /* QuestionToken */); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeConditionalHead = parenthesizeConditionalHead; /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. @@ -13353,7 +13868,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 184 /* ParenthesizedExpression */) { + if (skipped.kind === 185 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -13387,8 +13902,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(193 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(194 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(194 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -13397,7 +13912,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 196 /* YieldExpression */) { + && operand.kind === 197 /* YieldExpression */) { return false; } return true; @@ -13434,7 +13949,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 36 /* PlusToken */) { + if (binaryOperator === 37 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -13469,10 +13984,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 38 /* AsteriskToken */ - || binaryOperator === 48 /* BarToken */ - || binaryOperator === 47 /* AmpersandToken */ - || binaryOperator === 49 /* CaretToken */; + return binaryOperator === 39 /* AsteriskToken */ + || binaryOperator === 49 /* BarToken */ + || binaryOperator === 48 /* AmpersandToken */ + || binaryOperator === 50 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -13485,7 +14000,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 194 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -13500,7 +14015,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(194 /* ConditionalExpression */, 54 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(195 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -13513,7 +14028,7 @@ var ts; // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence - return e.kind === 193 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ + return e.kind === 194 /* BinaryExpression */ && e.operatorToken.kind === 26 /* CommaToken */ ? ts.createParen(e) : e; } @@ -13527,9 +14042,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 180 /* CallExpression */: + case 181 /* CallExpression */: return ts.createParen(expression); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return emittedExpression.arguments ? expression : ts.createParen(expression); @@ -13545,17 +14060,14 @@ var ts; */ function parenthesizeForAccess(expression) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: + // to parenthesize the expression before a dot. The known exception is: // // NewExpression: // new C.x -> not the same as (new C).x - // NumericLiteral - // 1.x -> not the same as (1).x // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 181 /* NewExpression */ || emittedExpression.arguments) - && emittedExpression.kind !== 8 /* NumericLiteral */) { + && (emittedExpression.kind !== 182 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -13593,7 +14105,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(194 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -13604,7 +14116,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 185 /* FunctionExpression */ || kind === 186 /* ArrowFunction */) { + if (kind === 186 /* FunctionExpression */ || kind === 187 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -13612,7 +14124,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 177 /* ObjectLiteralExpression */ || leftmostExpressionKind === 185 /* FunctionExpression */) { + if (leftmostExpressionKind === 178 /* ObjectLiteralExpression */ || leftmostExpressionKind === 186 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } } @@ -13636,21 +14148,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: node = node.operand; continue; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: node = node.left; continue; - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: node = node.condition; continue; - case 180 /* CallExpression */: - case 179 /* ElementAccessExpression */: - case 178 /* PropertyAccessExpression */: + case 181 /* CallExpression */: + case 180 /* ElementAccessExpression */: + case 179 /* PropertyAccessExpression */: node = node.expression; continue; - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13658,8 +14170,7 @@ var ts; } } function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 177 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && getLeftmostExpression(body).kind === 178 /* ObjectLiteralExpression */) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -13691,7 +14202,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 184 /* ParenthesizedExpression */) { + while (node.kind === 185 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -13705,7 +14216,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 298 /* PartiallyEmittedExpression */) { + while (node.kind === 296 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13751,10 +14262,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 237 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 238 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 243 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 244 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -13872,7 +14383,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13884,11 +14395,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13920,12 +14431,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 145 /* Parameter */: - case 175 /* BindingElement */: + case 146 /* Parameter */: + case 176 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 197 /* SpreadElement */: - case 262 /* SpreadAssignment */: + case 198 /* SpreadElement */: + case 263 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13937,7 +14448,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 175 /* BindingElement */: + case 176 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -13949,7 +14460,7 @@ var ts; : propertyName; } break; - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13961,7 +14472,7 @@ var ts; : propertyName; } break; - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13979,13 +14490,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: - case 176 /* ArrayLiteralExpression */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: + case 177 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -14025,11 +14536,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 174 /* ArrayBindingPattern */: - case 176 /* ArrayLiteralExpression */: + case 175 /* ArrayBindingPattern */: + case 177 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 173 /* ObjectBindingPattern */: - case 177 /* ObjectLiteralExpression */: + case 174 /* ObjectBindingPattern */: + case 178 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -14077,20 +14588,20 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 236 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { + case 237 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 248 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -14120,13 +14631,13 @@ var ts; } } break; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -14134,7 +14645,7 @@ var ts; } } break; - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -14154,7 +14665,7 @@ var ts; } } break; - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -14218,13 +14729,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 264 /* SourceFile */) { + if (kind === 265 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 70 /* Identifier */) { + else if (kind === 71 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 142 /* FirstNode */) { + else if (kind < 143 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -14267,29 +14778,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* 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 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 260 /* PropertyAssignment */: - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -14298,24 +14809,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14326,325 +14837,326 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 164 /* TupleType */: + case 165 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 165 /* UnionType */: - case 166 /* IntersectionType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 167 /* ParenthesizedType */: - case 169 /* TypeOperator */: + case 168 /* ParenthesizedType */: + case 170 /* TypeOperator */: return visitNode(cbNode, node.type); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 171 /* MappedType */: + case 172 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 172 /* LiteralType */: + case 173 /* LiteralType */: return visitNode(cbNode, node.literal); - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 188 /* TypeOfExpression */: + case 189 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 201 /* AsExpression */: + case 202 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return visitNode(cbNode, node.name); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 206 /* Block */: - case 233 /* ModuleBlock */: + case 207 /* Block */: + case 234 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 264 /* SourceFile */: + case 265 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 215 /* ForOfStatement */: - return visitNode(cbNode, node.initializer) || + case 216 /* ForOfStatement */: + return visitNode(cbNode, node.awaitModifier) || + visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 216 /* ContinueStatement */: - case 217 /* BreakStatement */: + case 217 /* ContinueStatement */: + case 218 /* BreakStatement */: return visitNode(cbNode, node.label); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 256 /* CaseClause */: + case 257 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 257 /* DefaultClause */: + case 258 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 146 /* Decorator */: + case 147 /* Decorator */: return visitNode(cbNode, node.expression); - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* 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 229 /* InterfaceDeclaration */: + case 230 /* 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 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 263 /* EnumMember */: + case 264 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 238 /* ImportClause */: + case 239 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 235 /* NamespaceExportDeclaration */: + case 236 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 240 /* NamedImports */: - case 244 /* NamedExports */: + case 241 /* NamedImports */: + case 245 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 247 /* ExternalModuleReference */: + case 248 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 246 /* MissingDeclaration */: + case 247 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 248 /* JsxElement */: + case 249 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 249 /* JsxSelfClosingElement */: - case 250 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.attributes); - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return visitNodes(cbNodes, node.properties); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 254 /* JsxSpreadAttribute */: + case 255 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 266 /* JSDocTypeExpression */: + case 267 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 270 /* JSDocUnionType */: + case 271 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 271 /* JSDocTupleType */: + case 272 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 269 /* JSDocArrayType */: + case 270 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 273 /* JSDocNonNullableType */: + case 274 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 272 /* JSDocNullableType */: + case 273 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 274 /* JSDocRecordType */: + case 275 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 276 /* JSDocTypeReference */: + case 277 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 277 /* JSDocOptionalType */: + case 278 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 278 /* JSDocFunctionType */: + case 279 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 279 /* JSDocVariadicType */: + case 280 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 280 /* JSDocConstructorType */: + case 281 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 281 /* JSDocThisType */: + case 282 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 275 /* JSDocRecordMember */: + case 276 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 282 /* JSDocComment */: + case 283 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 285 /* JSDocParameterTag */: + case 286 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 286 /* JSDocReturnTag */: + case 287 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 287 /* JSDocTypeTag */: + case 288 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocAugmentsTag */: + case 285 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocTemplateTag */: + case 289 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 291 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 290 /* JSDocPropertyTag */: + case 291 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 292 /* JSDocLiteralType */: + case 293 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14662,6 +15174,7 @@ var ts; return Parser.parseIsolatedEntityName(text, languageVersion); } ts.parseIsolatedEntityName = parseIsolatedEntityName; + // See also `isExternalOrCommonJsModule` in utilities.ts function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -14916,7 +15429,7 @@ var ts; 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(264 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(265 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15120,20 +15633,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 70 /* Identifier */) { + if (token() === 71 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 115 /* YieldKeyword */ && inYieldContext()) { + if (token() === 116 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 120 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 121 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 106 /* LastReservedWord */; + return token() > 107 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -15176,22 +15689,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 24 /* SemicolonToken */) { + if (token() === 25 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 17 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 24 /* SemicolonToken */) { + if (token() === 25 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(24 /* SemicolonToken */); + return parseExpected(25 /* SemicolonToken */); } } // note: this function creates only node @@ -15200,8 +15713,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 142 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : - kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 143 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -15252,16 +15765,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(70 /* Identifier */); + var node = createNode(71 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 70 /* Identifier */) { + if (token() !== 71 /* Identifier */) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -15278,7 +15791,7 @@ var ts; if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token() === 20 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -15296,13 +15809,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(143 /* ComputedPropertyName */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(144 /* ComputedPropertyName */); + parseExpected(21 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -15316,21 +15829,21 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 75 /* ConstKeyword */) { + if (token() === 76 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 82 /* EnumKeyword */; + return nextToken() === 83 /* EnumKeyword */; } - if (token() === 83 /* ExportKeyword */) { + if (token() === 84 /* ExportKeyword */) { nextToken(); - if (token() === 78 /* DefaultKeyword */) { + if (token() === 79 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 38 /* AsteriskToken */ && token() !== 117 /* AsKeyword */ && token() !== 16 /* OpenBraceToken */ && canFollowModifier(); + return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); } - if (token() === 78 /* DefaultKeyword */) { + if (token() === 79 /* DefaultKeyword */) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 114 /* StaticKeyword */) { + if (token() === 115 /* StaticKeyword */) { nextToken(); return canFollowModifier(); } @@ -15340,16 +15853,17 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 20 /* OpenBracketToken */ - || token() === 16 /* OpenBraceToken */ - || token() === 38 /* AsteriskToken */ - || token() === 23 /* DotDotDotToken */ + return token() === 21 /* OpenBracketToken */ + || token() === 17 /* OpenBraceToken */ + || token() === 39 /* AsteriskToken */ + || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 74 /* ClassKeyword */ || token() === 88 /* FunctionKeyword */ || - (token() === 119 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || + (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -15367,9 +15881,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 24 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; + return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -15377,21 +15891,21 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 24 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 25 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 21 /* OpenBracketToken */ || token() === 39 /* AsteriskToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); case 17 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 20 /* OpenBracketToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: - // If we see { } then only consume it as an expression if it is followed by , or { + // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -15406,23 +15920,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); case 18 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 19 /* TypeArguments */: case 20 /* TupleElementTypes */: - return token() === 25 /* CommaToken */ || isStartOfType(); + return token() === 26 /* CommaToken */ || isStartOfType(); case 21 /* HeritageClauses */: return isHeritageClause(); case 22 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 23 /* JSDocFunctionParameters */: @@ -15435,8 +15949,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 16 /* OpenBraceToken */); - if (nextToken() === 17 /* CloseBraceToken */) { + ts.Debug.assert(token() === 17 /* OpenBraceToken */); + if (nextToken() === 18 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -15445,7 +15959,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 25 /* CommaToken */ || next === 16 /* OpenBraceToken */ || next === 84 /* ExtendsKeyword */ || next === 107 /* ImplementsKeyword */; + return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; } return true; } @@ -15458,8 +15972,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 107 /* ImplementsKeyword */ || - token() === 84 /* ExtendsKeyword */) { + if (token() === 108 /* ImplementsKeyword */ || + token() === 85 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -15483,44 +15997,44 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 22 /* ImportOrExportSpecifiers */: - return token() === 17 /* CloseBraceToken */; + return token() === 18 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; + return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; + return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 18 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; + return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; + return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 20 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 21 /* CloseBracketToken */; + return token() === 22 /* CloseBracketToken */; case 16 /* Parameters */: case 17 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 19 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 25 /* CommaToken */; + return token() !== 26 /* CommaToken */; case 21 /* HeritageClauses */: - return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; + return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; + return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 23 /* JSDocFunctionParameters */: - return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; + return token() === 20 /* CloseParenToken */ || token() === 56 /* ColonToken */ || token() === 18 /* CloseBraceToken */; case 24 /* JSDocTypeArguments */: - return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; + return token() === 29 /* GreaterThanToken */ || token() === 18 /* CloseBraceToken */; case 26 /* JSDocTupleTypes */: - return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; + return token() === 22 /* CloseBracketToken */ || token() === 18 /* CloseBraceToken */; case 25 /* JSDocRecordMembers */: - return token() === 17 /* CloseBraceToken */; + return token() === 18 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -15538,7 +16052,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 35 /* EqualsGreaterThanToken */) { + if (token() === 36 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -15703,20 +16217,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 151 /* Constructor */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 148 /* PropertyDeclaration */: - case 205 /* SemicolonClassElement */: + case 152 /* Constructor */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 149 /* PropertyDeclaration */: + case 206 /* SemicolonClassElement */: return true; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 70 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 122 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 71 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -15725,8 +16239,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 256 /* CaseClause */: - case 257 /* DefaultClause */: + case 257 /* CaseClause */: + case 258 /* DefaultClause */: return true; } } @@ -15735,58 +16249,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: - case 207 /* VariableStatement */: - case 206 /* Block */: - case 210 /* IfStatement */: - case 209 /* ExpressionStatement */: - case 222 /* ThrowStatement */: - case 218 /* ReturnStatement */: - case 220 /* SwitchStatement */: - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 213 /* ForStatement */: - case 212 /* WhileStatement */: - case 219 /* WithStatement */: - case 208 /* EmptyStatement */: - case 223 /* TryStatement */: - case 221 /* LabeledStatement */: - case 211 /* DoStatement */: - case 224 /* DebuggerStatement */: - case 237 /* ImportDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 243 /* ExportDeclaration */: - case 242 /* ExportAssignment */: - case 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 228 /* FunctionDeclaration */: + case 208 /* VariableStatement */: + case 207 /* Block */: + case 211 /* IfStatement */: + case 210 /* ExpressionStatement */: + case 223 /* ThrowStatement */: + case 219 /* ReturnStatement */: + case 221 /* SwitchStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 214 /* ForStatement */: + case 213 /* WhileStatement */: + case 220 /* WithStatement */: + case 209 /* EmptyStatement */: + case 224 /* TryStatement */: + case 222 /* LabeledStatement */: + case 212 /* DoStatement */: + case 225 /* DebuggerStatement */: + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 244 /* ExportDeclaration */: + case 243 /* ExportAssignment */: + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 231 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 263 /* EnumMember */; + return node.kind === 264 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 155 /* ConstructSignature */: - case 149 /* MethodSignature */: - case 156 /* IndexSignature */: - case 147 /* PropertySignature */: - case 154 /* CallSignature */: + case 156 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 157 /* IndexSignature */: + case 148 /* PropertySignature */: + case 155 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 225 /* VariableDeclaration */) { + if (node.kind !== 226 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15807,7 +16321,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 145 /* Parameter */) { + if (node.kind !== 146 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -15854,7 +16368,6 @@ var ts; case 25 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } - ; // Parses a comma-delimited list of elements function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; @@ -15865,7 +16378,7 @@ var ts; if (isListElement(kind, /*inErrorRecovery*/ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(25 /* CommaToken */)) { + if (parseOptional(26 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -15874,13 +16387,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(25 /* CommaToken */); + parseExpected(26 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 24 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -15919,8 +16432,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(22 /* DotToken */)) { - var node = createNode(142 /* QualifiedName */, entity.pos); // !!! + while (parseOptional(23 /* DotToken */)) { + var node = createNode(143 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15953,33 +16466,33 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(195 /* TemplateExpression */); + var template = createNode(196 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 14 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 15 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(204 /* TemplateSpan */); + var span = createNode(205 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 17 /* CloseBraceToken */) { + if (token() === 18 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(15 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(17 /* CloseBraceToken */)); + literal = parseExpectedToken(16 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -15989,12 +16502,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 14 /* TemplateMiddle */ || fragment.kind === 15 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -16007,54 +16520,50 @@ var ts; if (scanner.isUnterminated()) { node.isUnterminated = true; } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal.But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 8 /* NumericLiteral */ - && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.isOctalLiteral = true; + if (node.kind === 8 /* NumericLiteral */) { + node.numericLiteralFlags = scanner.getNumericLiteralFlags(); } + nextToken(); + finishNode(node); return node; } // TYPES function parseTypeReference() { - var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(158 /* TypeReference */, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + var node = createNode(159 /* TypeReference */); + node.typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(157 /* TypePredicate */, lhs.pos); + var node = createNode(158 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(168 /* ThisType */); + var node = createNode(169 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(161 /* TypeQuery */); - parseExpected(102 /* TypeOfKeyword */); + var node = createNode(162 /* TypeQuery */); + parseExpected(103 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(144 /* TypeParameter */); + var node = createNode(145 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(84 /* ExtendsKeyword */)) { + if (parseOptional(85 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -16073,35 +16582,35 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(57 /* EqualsToken */)) { + if (parseOptional(58 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 26 /* LessThanToken */) { - return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + if (token() === 27 /* LessThanToken */) { + return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(55 /* ColonToken */)) { + if (parseOptional(56 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; + return token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 57 /* AtToken */ || token() === 99 /* ThisKeyword */; } function parseParameter() { - var node = createNode(145 /* Parameter */); - if (token() === 98 /* ThisKeyword */) { - node.name = createIdentifier(/*isIdentifier*/ true, undefined); + var node = createNode(146 /* Parameter */); + if (token() === 99 /* ThisKeyword */) { + node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -16116,7 +16625,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(54 /* QuestionToken */); + node.questionToken = parseOptionalToken(55 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -16136,7 +16645,7 @@ var ts; return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 35 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 36 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -16161,7 +16670,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(18 /* OpenParenToken */)) { + if (parseExpected(19 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -16169,7 +16678,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(19 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(20 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -16184,7 +16693,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(25 /* CommaToken */)) { + if (parseOptional(26 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -16192,15 +16701,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 155 /* ConstructSignature */) { - parseExpected(93 /* NewKeyword */); + if (kind === 156 /* ConstructSignature */) { + parseExpected(94 /* NewKeyword */); } - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 20 /* OpenBracketToken */) { + if (token() !== 21 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -16223,7 +16732,7 @@ var ts; // [] // nextToken(); - if (token() === 23 /* DotDotDotToken */ || token() === 21 /* CloseBracketToken */) { + if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -16242,49 +16751,49 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */) { + if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 54 /* QuestionToken */) { + if (token() !== 55 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; + return token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(156 /* IndexSignature */, fullStart); + var node = createNode(157 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(54 /* QuestionToken */); - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(149 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(55 /* QuestionToken */); + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + var method = createNode(150 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(147 /* PropertySignature */, fullStart); + var property = createNode(148 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 57 /* EqualsToken */) { + if (token() === 58 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -16295,43 +16804,43 @@ var ts; } } function isTypeMemberStart() { - var idToken; // Return true if we have the start of a signature member - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return true; } + var idToken; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } // Index signatures and computed property names are type members - if (token() === 20 /* OpenBracketToken */) { + if (token() === 21 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 18 /* OpenParenToken */ || - token() === 26 /* LessThanToken */ || - token() === 54 /* QuestionToken */ || - token() === 55 /* ColonToken */ || - token() === 25 /* CommaToken */ || + return token() === 19 /* OpenParenToken */ || + token() === 27 /* LessThanToken */ || + token() === 55 /* QuestionToken */ || + token() === 56 /* ColonToken */ || + token() === 26 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(154 /* CallSignature */); + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + return parseSignatureMember(155 /* CallSignature */); } - if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(155 /* ConstructSignature */); + if (token() === 94 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(156 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -16342,18 +16851,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; + return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(162 /* TypeLiteral */); + var node = createNode(163 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(16 /* OpenBraceToken */)) { + if (parseExpected(17 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { members = createMissingList(); @@ -16362,57 +16871,57 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 130 /* ReadonlyKeyword */) { + if (token() === 131 /* ReadonlyKeyword */) { nextToken(); } - return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; + return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(144 /* TypeParameter */); + var node = createNode(145 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(91 /* InKeyword */); + parseExpected(92 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(171 /* MappedType */); - parseExpected(16 /* OpenBraceToken */); - node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(172 /* MappedType */); + parseExpected(17 /* OpenBraceToken */); + node.readonlyToken = parseOptionalToken(131 /* ReadonlyKeyword */); + parseExpected(21 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(21 /* CloseBracketToken */); - node.questionToken = parseOptionalToken(54 /* QuestionToken */); + parseExpected(22 /* CloseBracketToken */); + node.questionToken = parseOptionalToken(55 /* QuestionToken */); node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseTupleType() { - var node = createNode(164 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); + var node = createNode(165 /* TupleType */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(167 /* ParenthesizedType */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(168 /* ParenthesizedType */); + parseExpected(19 /* OpenParenToken */); node.type = parseType(); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 160 /* ConstructorType */) { - parseExpected(93 /* NewKeyword */); + if (kind === 161 /* ConstructorType */) { + parseExpected(94 /* NewKeyword */); } - fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(36 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 22 /* DotToken */ ? undefined : node; + return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(172 /* LiteralType */); + var node = createNode(173 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16422,43 +16931,43 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 138 /* UndefinedKeyword */: - case 129 /* NeverKeyword */: - case 133 /* ObjectKeyword */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 139 /* UndefinedKeyword */: + case 130 /* NeverKeyword */: + case 134 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return parseLiteralTypeNode(); - case 37 /* MinusToken */: + case 38 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 104 /* VoidKeyword */: - case 94 /* NullKeyword */: + case 105 /* VoidKeyword */: + case 95 /* NullKeyword */: return parseTokenNode(); - case 98 /* ThisKeyword */: { + case 99 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 102 /* TypeOfKeyword */: + case 103 /* TypeOfKeyword */: return parseTypeQuery(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 20 /* OpenBracketToken */: + case 21 /* OpenBracketToken */: return parseTupleType(); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReference(); @@ -16466,32 +16975,32 @@ var ts; } function isStartOfType() { switch (token()) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 98 /* ThisKeyword */: - case 102 /* TypeOfKeyword */: - case 129 /* NeverKeyword */: - case 16 /* OpenBraceToken */: - case 20 /* OpenBracketToken */: - case 26 /* LessThanToken */: - case 48 /* BarToken */: - case 47 /* AmpersandToken */: - case 93 /* NewKeyword */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 99 /* ThisKeyword */: + case 103 /* TypeOfKeyword */: + case 130 /* NeverKeyword */: + case 17 /* OpenBraceToken */: + case 21 /* OpenBracketToken */: + case 27 /* LessThanToken */: + case 49 /* BarToken */: + case 48 /* AmpersandToken */: + case 94 /* NewKeyword */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: - case 133 /* ObjectKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 134 /* ObjectKeyword */: return true; - case 37 /* MinusToken */: + case 38 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -16501,29 +17010,29 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 19 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token() === 20 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { + while (!scanner.hasPrecedingLineBreak() && parseOptional(21 /* OpenBracketToken */)) { if (isStartOfType()) { - var node = createNode(170 /* IndexedAccessType */, type.pos); + var node = createNode(171 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(163 /* ArrayType */, type.pos); + var node = createNode(164 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } } return type; } function parseTypeOperator(operator) { - var node = createNode(169 /* TypeOperator */); + var node = createNode(170 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16531,8 +17040,8 @@ var ts; } function parseTypeOperatorOrHigher() { switch (token()) { - case 126 /* KeyOfKeyword */: - return parseTypeOperator(126 /* KeyOfKeyword */); + case 127 /* KeyOfKeyword */: + return parseTypeOperator(127 /* KeyOfKeyword */); } return parseArrayTypeOrHigher(); } @@ -16552,27 +17061,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(166 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(167 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(165 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(166 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 26 /* LessThanToken */) { + if (token() === 27 /* LessThanToken */) { return true; } - return token() === 18 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 98 /* ThisKeyword */) { + if (isIdentifier() || token() === 99 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 20 /* OpenBracketToken */ || token() === 16 /* OpenBraceToken */) { + if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -16582,7 +17091,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 19 /* CloseParenToken */ || token() === 23 /* DotDotDotToken */) { + if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -16590,17 +17099,17 @@ var ts; 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() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || - token() === 54 /* QuestionToken */ || token() === 57 /* EqualsToken */) { + if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || + token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 19 /* CloseParenToken */) { + if (token() === 20 /* CloseParenToken */) { nextToken(); - if (token() === 35 /* EqualsGreaterThanToken */) { + if (token() === 36 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -16612,7 +17121,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(157 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(158 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16623,7 +17132,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -16635,37 +17144,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(159 /* FunctionType */); + return parseFunctionOrConstructorType(160 /* FunctionType */); } - if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(160 /* ConstructorType */); + if (token() === 94 /* NewKeyword */) { + return parseFunctionOrConstructorType(161 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(55 /* ColonToken */) ? parseType() : undefined; + return parseOptional(56 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: - case 13 /* TemplateHead */: - case 18 /* OpenParenToken */: - case 20 /* OpenBracketToken */: - case 16 /* OpenBraceToken */: - case 88 /* FunctionKeyword */: - case 74 /* ClassKeyword */: - case 93 /* NewKeyword */: - case 40 /* SlashToken */: - case 62 /* SlashEqualsToken */: - case 70 /* Identifier */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* TemplateHead */: + case 19 /* OpenParenToken */: + case 21 /* OpenBracketToken */: + case 17 /* OpenBraceToken */: + case 89 /* FunctionKeyword */: + case 75 /* ClassKeyword */: + case 94 /* NewKeyword */: + case 41 /* SlashToken */: + case 63 /* SlashEqualsToken */: + case 71 /* Identifier */: return true; default: return isIdentifier(); @@ -16676,18 +17185,18 @@ var ts; return true; } switch (token()) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: - case 79 /* DeleteKeyword */: - case 102 /* TypeOfKeyword */: - case 104 /* VoidKeyword */: - case 42 /* PlusPlusToken */: - case 43 /* MinusMinusToken */: - case 26 /* LessThanToken */: - case 120 /* AwaitKeyword */: - case 115 /* YieldKeyword */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: + case 80 /* DeleteKeyword */: + case 103 /* TypeOfKeyword */: + case 105 /* VoidKeyword */: + case 43 /* PlusPlusToken */: + case 44 /* MinusMinusToken */: + case 27 /* LessThanToken */: + case 121 /* AwaitKeyword */: + case 116 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -16705,10 +17214,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 16 /* OpenBraceToken */ && - token() !== 88 /* FunctionKeyword */ && - token() !== 74 /* ClassKeyword */ && - token() !== 56 /* AtToken */ && + return token() !== 17 /* OpenBraceToken */ && + token() !== 89 /* FunctionKeyword */ && + token() !== 75 /* ClassKeyword */ && + token() !== 57 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -16722,7 +17231,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(25 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -16731,7 +17240,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 57 /* EqualsToken */) { + if (token() !== 58 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -16740,7 +17249,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -16748,7 +17257,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(57 /* EqualsToken */); + parseExpected(58 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -16794,7 +17303,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { + if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -16810,7 +17319,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 115 /* YieldKeyword */) { + if (token() === 116 /* YieldKeyword */) { // 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()) { @@ -16839,15 +17348,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(196 /* YieldExpression */); + var node = createNode(197 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 38 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -16858,21 +17367,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(186 /* ArrowFunction */, asyncModifier.pos); + node = createNode(187 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(186 /* ArrowFunction */, identifier.pos); + node = createNode(187 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(145 /* Parameter */, identifier.pos); + var parameter = createNode(146 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -16897,8 +17406,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 35 /* EqualsGreaterThanToken */ || lastToken === 16 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); @@ -16908,10 +17417,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */ || token() === 119 /* AsyncKeyword */) { + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 35 /* EqualsGreaterThanToken */) { + if (token() === 36 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -16921,28 +17430,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 18 /* OpenParenToken */ && token() !== 26 /* LessThanToken */) { + if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 18 /* OpenParenToken */) { - if (second === 19 /* CloseParenToken */) { + if (first === 19 /* OpenParenToken */) { + if (second === 20 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 35 /* EqualsGreaterThanToken */: - case 55 /* ColonToken */: - case 16 /* OpenBraceToken */: + case 36 /* EqualsGreaterThanToken */: + case 56 /* ColonToken */: + case 17 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -16954,12 +17463,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 20 /* OpenBracketToken */ || second === 16 /* OpenBraceToken */) { + if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 23 /* DotDotDotToken */) { + if (second === 24 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -16972,7 +17481,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 55 /* ColonToken */) { + if (nextToken() === 56 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -16980,7 +17489,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 26 /* LessThanToken */); + ts.Debug.assert(first === 27 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -16990,17 +17499,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 84 /* ExtendsKeyword */) { + if (third === 85 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 57 /* EqualsToken */: - case 28 /* GreaterThanToken */: + case 58 /* EqualsToken */: + case 29 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 25 /* CommaToken */) { + else if (third === 26 /* CommaToken */) { return true; } return false; @@ -17019,7 +17528,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); @@ -17033,23 +17542,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a begining of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 35 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 36 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(186 /* ArrowFunction */); + var node = createNode(187 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -17059,7 +17568,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -17072,19 +17581,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 35 /* EqualsGreaterThanToken */ && token() !== 16 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token() !== 24 /* SemicolonToken */ && - token() !== 88 /* FunctionKeyword */ && - token() !== 74 /* ClassKeyword */ && + if (token() !== 25 /* SemicolonToken */ && + token() !== 89 /* FunctionKeyword */ && + token() !== 75 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -17109,17 +17618,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(54 /* QuestionToken */); + var questionToken = parseOptionalToken(55 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(194 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(195 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(55 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(55 /* ColonToken */)); + node.colonToken = parseExpectedToken(56 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -17128,7 +17637,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 141 /* OfKeyword */; + return t === 92 /* InKeyword */ || t === 142 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -17157,16 +17666,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 39 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 40 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 91 /* InKeyword */ && inDisallowInContext()) { + if (token() === 92 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 117 /* AsKeyword */) { + if (token() === 118 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -17187,48 +17696,48 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 91 /* InKeyword */) { + if (inDisallowInContext() && token() === 92 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 53 /* BarBarToken */: + case 54 /* BarBarToken */: return 1; - case 52 /* AmpersandAmpersandToken */: + case 53 /* AmpersandAmpersandToken */: return 2; - case 48 /* BarToken */: + case 49 /* BarToken */: return 3; - case 49 /* CaretToken */: + case 50 /* CaretToken */: return 4; - case 47 /* AmpersandToken */: + case 48 /* AmpersandToken */: return 5; - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: return 6; - case 26 /* LessThanToken */: - case 28 /* GreaterThanToken */: - case 29 /* LessThanEqualsToken */: - case 30 /* GreaterThanEqualsToken */: - case 92 /* InstanceOfKeyword */: - case 91 /* InKeyword */: - case 117 /* AsKeyword */: + case 27 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 30 /* LessThanEqualsToken */: + case 31 /* GreaterThanEqualsToken */: + case 93 /* InstanceOfKeyword */: + case 92 /* InKeyword */: + case 118 /* AsKeyword */: return 7; - case 44 /* LessThanLessThanToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* LessThanLessThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 36 /* PlusToken */: - case 37 /* MinusToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: return 9; - case 38 /* AsteriskToken */: - case 40 /* SlashToken */: - case 41 /* PercentToken */: + case 39 /* AsteriskToken */: + case 41 /* SlashToken */: + case 42 /* PercentToken */: return 10; - case 39 /* AsteriskAsteriskToken */: + case 40 /* AsteriskAsteriskToken */: return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -17236,45 +17745,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(193 /* BinaryExpression */, left.pos); + var node = createNode(194 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(201 /* AsExpression */, left.pos); + var node = createNode(202 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(191 /* PrefixUnaryExpression */); + var node = createNode(192 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(187 /* DeleteExpression */); + var node = createNode(188 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(188 /* TypeOfExpression */); + var node = createNode(189 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(189 /* VoidExpression */); + var node = createNode(190 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 120 /* AwaitKeyword */) { + if (token() === 121 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -17284,7 +17793,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(190 /* AwaitExpression */); + var node = createNode(191 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -17308,7 +17817,7 @@ var ts; */ if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 39 /* AsteriskAsteriskToken */ ? + return token() === 40 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } @@ -17325,9 +17834,9 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 39 /* AsteriskAsteriskToken */) { + if (token() === 40 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 183 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 184 /* 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 { @@ -17352,26 +17861,27 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 79 /* DeleteKeyword */: + case 80 /* DeleteKeyword */: return parseDeleteExpression(); - case 102 /* TypeOfKeyword */: + case 103 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 104 /* VoidKeyword */: + case 105 /* VoidKeyword */: return parseVoidExpression(); - case 26 /* LessThanToken */: + case 27 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 120 /* AwaitKeyword */: + case 121 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } + // falls through default: return parseIncrementExpression(); } @@ -17390,22 +17900,22 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: - case 79 /* DeleteKeyword */: - case 102 /* TypeOfKeyword */: - case 104 /* VoidKeyword */: - case 120 /* AwaitKeyword */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: + case 80 /* DeleteKeyword */: + case 103 /* TypeOfKeyword */: + case 105 /* VoidKeyword */: + case 121 /* AwaitKeyword */: return false; - case 26 /* LessThanToken */: + case 27 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. - // Fall through + // falls through default: return true; } @@ -17422,21 +17932,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseIncrementExpression() { - if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(191 /* PrefixUnaryExpression */); + if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { + var node = createNode(192 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(192 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(193 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -17475,7 +17985,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token() === 96 /* SuperKeyword */ + var expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -17535,14 +18045,14 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 18 /* OpenParenToken */ || token() === 22 /* DotToken */ || token() === 20 /* OpenBracketToken */) { + if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(178 /* PropertyAccessExpression */, expression.pos); + var node = createNode(179 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(23 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } @@ -17550,10 +18060,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 70 /* Identifier */) { + if (lhs.kind === 71 /* Identifier */) { return lhs.text === rhs.text; } - if (lhs.kind === 98 /* ThisKeyword */) { + if (lhs.kind === 99 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -17565,8 +18075,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 250 /* JsxOpeningElement */) { - var node = createNode(248 /* JsxElement */, opening.pos); + if (opening.kind === 251 /* JsxOpeningElement */) { + var node = createNode(249 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17576,7 +18086,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 249 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 250 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17587,15 +18097,15 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 26 /* LessThanToken */) { + if (inExpressionContext && token() === 27 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(193 /* BinaryExpression */, result.pos); + var badNode = createNode(194 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(25 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -17604,16 +18114,18 @@ var ts; } function parseJsxText() { var node = createNode(10 /* JsxText */, scanner.getStartPos()); + node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { case 10 /* JsxText */: + case 11 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 26 /* LessThanToken */: + case 27 /* LessThanToken */: return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -17624,7 +18136,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 27 /* LessThanSlashToken */) { + if (token() === 28 /* LessThanSlashToken */) { // Closing tag break; } @@ -17634,40 +18146,46 @@ var ts; parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } - result.push(parseJsxChild()); + else if (token() === 7 /* ConflictMarkerTrivia */) { + break; + } + var child = parseJsxChild(); + if (child) { + result.push(child); + } } result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; return result; } function parseJsxAttributes() { - var jsxAttributes = createNode(253 /* JsxAttributes */); + var jsxAttributes = createNode(254 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(26 /* LessThanToken */); + parseExpected(27 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseJsxAttributes(); var node; - if (token() === 28 /* GreaterThanToken */) { + if (token() === 29 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(250 /* JsxOpeningElement */, fullStart); + node = createNode(251 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(40 /* SlashToken */); + parseExpected(41 /* SlashToken */); if (inExpressionContext) { - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); } else { - parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(249 /* JsxSelfClosingElement */, fullStart); + node = createNode(250 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17680,10 +18198,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 98 /* ThisKeyword */ ? + var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(23 /* DotToken */)) { + var propertyAccess = createNode(179 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17691,29 +18209,29 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(255 /* JsxExpression */); - parseExpected(16 /* OpenBraceToken */); - if (token() !== 17 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var node = createNode(256 /* JsxExpression */); + parseExpected(17 /* OpenBraceToken */); + if (token() !== 18 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { - parseExpected(17 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(252 /* JsxAttribute */); + var node = createNode(253 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 57 /* EqualsToken */) { + if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -17726,72 +18244,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(254 /* JsxSpreadAttribute */); - parseExpected(16 /* OpenBraceToken */); - parseExpected(23 /* DotDotDotToken */); + var node = createNode(255 /* JsxSpreadAttribute */); + parseExpected(17 /* OpenBraceToken */); + parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(251 /* JsxClosingElement */); - parseExpected(27 /* LessThanSlashToken */); + var node = createNode(252 /* JsxClosingElement */); + parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); } else { - parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(183 /* TypeAssertionExpression */); - parseExpected(26 /* LessThanToken */); + var node = createNode(184 /* TypeAssertionExpression */); + parseExpected(27 /* LessThanToken */); node.type = parseType(); - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(22 /* DotToken */); + var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(179 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(202 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(203 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(179 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { + var indexedAccess = createNode(180 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token() !== 21 /* CloseBracketToken */) { + if (token() !== 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(182 /* TaggedTemplateExpression */, expression.pos); + if (token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */) { + var tagExpression = createNode(183 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -17803,7 +18321,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 26 /* LessThanToken */) { + if (token() === 27 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -17812,15 +18330,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(180 /* CallExpression */, expression.pos); + var callExpr = createNode(181 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(180 /* CallExpression */, expression.pos); + else if (token() === 19 /* OpenParenToken */) { + var callExpr = createNode(181 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17830,17 +18348,17 @@ var ts; } } function parseArgumentList() { - parseExpected(18 /* OpenParenToken */); + parseExpected(19 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(26 /* LessThanToken */)) { + if (!parseOptional(27 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(19 /* TypeArguments */, parseType); - if (!parseExpected(28 /* GreaterThanToken */)) { + if (!parseExpected(29 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -17852,32 +18370,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 18 /* OpenParenToken */: // foo( + case 19 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 22 /* DotToken */: // foo. - case 19 /* CloseParenToken */: // foo) - case 21 /* CloseBracketToken */: // foo] - case 55 /* ColonToken */: // foo: - case 24 /* SemicolonToken */: // foo; - case 54 /* QuestionToken */: // foo? - case 31 /* EqualsEqualsToken */: // foo == - case 33 /* EqualsEqualsEqualsToken */: // foo === - case 32 /* ExclamationEqualsToken */: // foo != - case 34 /* ExclamationEqualsEqualsToken */: // foo !== - case 52 /* AmpersandAmpersandToken */: // foo && - case 53 /* BarBarToken */: // foo || - case 49 /* CaretToken */: // foo ^ - case 47 /* AmpersandToken */: // foo & - case 48 /* BarToken */: // foo | - case 17 /* CloseBraceToken */: // foo } + case 23 /* DotToken */: // foo. + case 20 /* CloseParenToken */: // foo) + case 22 /* CloseBracketToken */: // foo] + case 56 /* ColonToken */: // foo: + case 25 /* SemicolonToken */: // foo; + case 55 /* QuestionToken */: // foo? + case 32 /* EqualsEqualsToken */: // foo == + case 34 /* EqualsEqualsEqualsToken */: // foo === + case 33 /* ExclamationEqualsToken */: // foo != + case 35 /* ExclamationEqualsEqualsToken */: // foo !== + case 53 /* AmpersandAmpersandToken */: // foo && + case 54 /* BarBarToken */: // foo || + case 50 /* CaretToken */: // foo ^ + case 48 /* AmpersandToken */: // foo & + case 49 /* BarToken */: // foo | + case 18 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 25 /* CommaToken */: // foo, - case 16 /* OpenBraceToken */: // foo { + case 26 /* CommaToken */: // foo, + case 17 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -17890,21 +18408,21 @@ var ts; switch (token()) { case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return parseTokenNode(); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return parseParenthesizedExpression(); - case 20 /* OpenBracketToken */: + case 21 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 119 /* AsyncKeyword */: + case 120 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -17912,68 +18430,68 @@ var ts; break; } return parseFunctionExpression(); - case 74 /* ClassKeyword */: + case 75 /* ClassKeyword */: return parseClassExpression(); - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseFunctionExpression(); - case 93 /* NewKeyword */: + case 94 /* NewKeyword */: return parseNewExpression(); - case 40 /* SlashToken */: - case 62 /* SlashEqualsToken */: - if (reScanSlashToken() === 11 /* RegularExpressionLiteral */) { + case 41 /* SlashToken */: + case 63 /* SlashEqualsToken */: + if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 13 /* TemplateHead */: + case 14 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(184 /* ParenthesizedExpression */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(185 /* ParenthesizedExpression */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(197 /* SpreadElement */); - parseExpected(23 /* DotDotDotToken */); + var node = createNode(198 /* SpreadElement */); + parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(199 /* OmittedExpression */) : + return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 26 /* CommaToken */ ? createNode(200 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(176 /* ArrayLiteralExpression */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(177 /* ArrayLiteralExpression */); + parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(152 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(125 /* GetKeyword */)) { + return parseAccessorDeclaration(153 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(134 /* SetKeyword */)) { - return parseAccessorDeclaration(153 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(135 /* SetKeyword */)) { + return parseAccessorDeclaration(154 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); - var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(262 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(263 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17983,12 +18501,12 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(54 /* QuestionToken */); - if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var questionToken = parseOptionalToken(55 /* QuestionToken */); + if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // check if it is short-hand property assignment or normal property assignment @@ -17996,12 +18514,12 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(261 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(262 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(57 /* EqualsToken */); + var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -18009,23 +18527,23 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(260 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(261 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(177 /* ObjectLiteralExpression */); - parseExpected(16 /* OpenBraceToken */); + var node = createNode(178 /* ObjectLiteralExpression */); + parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -18038,10 +18556,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(185 /* FunctionExpression */); + var node = createNode(186 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(88 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + parseExpected(89 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); node.name = @@ -18049,7 +18567,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -18061,30 +18579,30 @@ var ts; } function parseNewExpression() { var fullStart = scanner.getStartPos(); - parseExpected(93 /* NewKeyword */); - if (parseOptional(22 /* DotToken */)) { - var node_1 = createNode(203 /* MetaProperty */, fullStart); - node_1.keywordToken = 93 /* NewKeyword */; + parseExpected(94 /* NewKeyword */); + if (parseOptional(23 /* DotToken */)) { + var node_1 = createNode(204 /* MetaProperty */, fullStart); + node_1.keywordToken = 94 /* NewKeyword */; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(181 /* NewExpression */, fullStart); + var node = createNode(182 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 18 /* OpenParenToken */) { + if (node.typeArguments || token() === 19 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(206 /* Block */); - if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(207 /* Block */); + if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -18111,51 +18629,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(208 /* EmptyStatement */); - parseExpected(24 /* SemicolonToken */); + var node = createNode(209 /* EmptyStatement */); + parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(210 /* IfStatement */); - parseExpected(89 /* IfKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(211 /* IfStatement */); + parseExpected(90 /* IfKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(81 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(211 /* DoStatement */); - parseExpected(80 /* DoKeyword */); + var node = createNode(212 /* DoStatement */); + parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(105 /* WhileKeyword */); - parseExpected(18 /* OpenParenToken */); + parseExpected(106 /* WhileKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(24 /* SemicolonToken */); + parseOptional(25 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(212 /* WhileStatement */); - parseExpected(105 /* WhileKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(213 /* WhileStatement */); + parseExpected(106 /* WhileKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(87 /* ForKeyword */); - parseExpected(18 /* OpenParenToken */); + parseExpected(88 /* ForKeyword */); + var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); + parseExpected(19 /* OpenParenToken */); var initializer = undefined; - if (token() !== 24 /* SemicolonToken */) { - if (token() === 103 /* VarKeyword */ || token() === 109 /* LetKeyword */ || token() === 75 /* ConstKeyword */) { + if (token() !== 25 /* SemicolonToken */) { + if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -18163,32 +18682,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(214 /* ForInStatement */, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(141 /* OfKeyword */)) { - var forOfStatement = createNode(215 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(142 /* OfKeyword */) : parseOptional(142 /* OfKeyword */)) { + var forOfStatement = createNode(216 /* ForOfStatement */, pos); + forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } + else if (parseOptional(92 /* InKeyword */)) { + var forInStatement = createNode(215 /* ForInStatement */, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(20 /* CloseParenToken */); + forOrForInOrForOfStatement = forInStatement; + } else { - var forStatement = createNode(213 /* ForStatement */, pos); + var forStatement = createNode(214 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(24 /* SemicolonToken */); - if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { + parseExpected(25 /* SemicolonToken */); + if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(24 /* SemicolonToken */); - if (token() !== 19 /* CloseParenToken */) { + parseExpected(25 /* SemicolonToken */); + if (token() !== 20 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -18196,7 +18716,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 217 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 218 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -18204,8 +18724,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(218 /* ReturnStatement */); - parseExpected(95 /* ReturnKeyword */); + var node = createNode(219 /* ReturnStatement */); + parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -18213,42 +18733,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(219 /* WithStatement */); - parseExpected(106 /* WithKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(220 /* WithStatement */); + parseExpected(107 /* WithKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(256 /* CaseClause */); - parseExpected(72 /* CaseKeyword */); + var node = createNode(257 /* CaseClause */); + parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(257 /* DefaultClause */); - parseExpected(78 /* DefaultKeyword */); - parseExpected(55 /* ColonToken */); + var node = createNode(258 /* DefaultClause */); + parseExpected(79 /* DefaultKeyword */); + parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(220 /* SwitchStatement */); - parseExpected(97 /* SwitchKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(221 /* SwitchStatement */); + parseExpected(98 /* SwitchKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(234 /* CaseBlock */, scanner.getStartPos()); - parseExpected(16 /* OpenBraceToken */); + parseExpected(20 /* CloseParenToken */); + var caseBlock = createNode(235 /* CaseBlock */, scanner.getStartPos()); + parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -18260,39 +18780,39 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(222 /* ThrowStatement */); - parseExpected(99 /* ThrowKeyword */); + var node = createNode(223 /* ThrowStatement */); + parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(223 /* TryStatement */); - parseExpected(101 /* TryKeyword */); + var node = createNode(224 /* TryStatement */); + parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 86 /* FinallyKeyword */) { - parseExpected(86 /* FinallyKeyword */); + if (!node.catchClause || token() === 87 /* FinallyKeyword */) { + parseExpected(87 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(259 /* CatchClause */); - parseExpected(73 /* CatchKeyword */); - if (parseExpected(18 /* OpenParenToken */)) { + var result = createNode(260 /* CatchClause */); + parseExpected(74 /* CatchKeyword */); + if (parseExpected(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(224 /* DebuggerStatement */); - parseExpected(77 /* DebuggerKeyword */); + var node = createNode(225 /* DebuggerStatement */); + parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -18302,14 +18822,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(221 /* LabeledStatement */, fullStart); + if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { + var labeledStatement = createNode(222 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(209 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(210 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18319,9 +18839,13 @@ var ts; nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsClassKeywordOnSameLine() { + nextToken(); + return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 88 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -18330,12 +18854,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: - case 88 /* FunctionKeyword */: - case 74 /* ClassKeyword */: - case 82 /* EnumKeyword */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: + case 89 /* FunctionKeyword */: + case 75 /* ClassKeyword */: + case 83 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -18358,41 +18882,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 108 /* InterfaceKeyword */: - case 137 /* TypeKeyword */: + case 109 /* InterfaceKeyword */: + case 138 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116 /* AbstractKeyword */: - case 119 /* AsyncKeyword */: - case 123 /* DeclareKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 130 /* ReadonlyKeyword */: + case 117 /* AbstractKeyword */: + case 120 /* AsyncKeyword */: + case 124 /* DeclareKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 114 /* PublicKeyword */: + case 131 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 140 /* GlobalKeyword */: + case 141 /* GlobalKeyword */: nextToken(); - return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; - case 90 /* ImportKeyword */: + return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; + case 91 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 38 /* AsteriskToken */ || - token() === 16 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 83 /* ExportKeyword */: + return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || + token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 84 /* ExportKeyword */: nextToken(); - if (token() === 57 /* EqualsToken */ || token() === 38 /* AsteriskToken */ || - token() === 16 /* OpenBraceToken */ || token() === 78 /* DefaultKeyword */ || - token() === 117 /* AsKeyword */) { + if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || + token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || + token() === 118 /* AsKeyword */) { return true; } continue; - case 114 /* StaticKeyword */: + case 115 /* StaticKeyword */: nextToken(); continue; default: @@ -18405,49 +18929,49 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 56 /* AtToken */: - case 24 /* SemicolonToken */: - case 16 /* OpenBraceToken */: - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 88 /* FunctionKeyword */: - case 74 /* ClassKeyword */: - case 82 /* EnumKeyword */: - case 89 /* IfKeyword */: - case 80 /* DoKeyword */: - case 105 /* WhileKeyword */: - case 87 /* ForKeyword */: - case 76 /* ContinueKeyword */: - case 71 /* BreakKeyword */: - case 95 /* ReturnKeyword */: - case 106 /* WithKeyword */: - case 97 /* SwitchKeyword */: - case 99 /* ThrowKeyword */: - case 101 /* TryKeyword */: - case 77 /* DebuggerKeyword */: + case 57 /* AtToken */: + case 25 /* SemicolonToken */: + case 17 /* OpenBraceToken */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 89 /* FunctionKeyword */: + case 75 /* ClassKeyword */: + case 83 /* EnumKeyword */: + case 90 /* IfKeyword */: + case 81 /* DoKeyword */: + case 106 /* WhileKeyword */: + case 88 /* ForKeyword */: + case 77 /* ContinueKeyword */: + case 72 /* BreakKeyword */: + case 96 /* ReturnKeyword */: + case 107 /* WithKeyword */: + case 98 /* SwitchKeyword */: + case 100 /* ThrowKeyword */: + case 102 /* TryKeyword */: + case 78 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 73 /* CatchKeyword */: - case 86 /* FinallyKeyword */: + case 74 /* CatchKeyword */: + case 87 /* FinallyKeyword */: return true; - case 75 /* ConstKeyword */: - case 83 /* ExportKeyword */: - case 90 /* ImportKeyword */: + case 76 /* ConstKeyword */: + case 84 /* ExportKeyword */: + case 91 /* ImportKeyword */: return isStartOfDeclaration(); - case 119 /* AsyncKeyword */: - case 123 /* DeclareKeyword */: - case 108 /* InterfaceKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 137 /* TypeKeyword */: - case 140 /* GlobalKeyword */: + case 120 /* AsyncKeyword */: + case 124 /* DeclareKeyword */: + case 109 /* InterfaceKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: + case 138 /* TypeKeyword */: + case 141 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 114 /* StaticKeyword */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 115 /* StaticKeyword */: + case 131 /* 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); @@ -18457,7 +18981,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */; + return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -18466,67 +18990,67 @@ var ts; } function parseStatement() { switch (token()) { - case 24 /* SemicolonToken */: + case 25 /* SemicolonToken */: return parseEmptyStatement(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 103 /* VarKeyword */: + case 104 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 109 /* LetKeyword */: + case 110 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 74 /* ClassKeyword */: + case 75 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 89 /* IfKeyword */: + case 90 /* IfKeyword */: return parseIfStatement(); - case 80 /* DoKeyword */: + case 81 /* DoKeyword */: return parseDoStatement(); - case 105 /* WhileKeyword */: + case 106 /* WhileKeyword */: return parseWhileStatement(); - case 87 /* ForKeyword */: + case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(216 /* ContinueStatement */); - case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(217 /* BreakStatement */); - case 95 /* ReturnKeyword */: + case 77 /* ContinueKeyword */: + return parseBreakOrContinueStatement(217 /* ContinueStatement */); + case 72 /* BreakKeyword */: + return parseBreakOrContinueStatement(218 /* BreakStatement */); + case 96 /* ReturnKeyword */: return parseReturnStatement(); - case 106 /* WithKeyword */: + case 107 /* WithKeyword */: return parseWithStatement(); - case 97 /* SwitchKeyword */: + case 98 /* SwitchKeyword */: return parseSwitchStatement(); - case 99 /* ThrowKeyword */: + case 100 /* ThrowKeyword */: return parseThrowStatement(); - case 101 /* TryKeyword */: + case 102 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 73 /* CatchKeyword */: - case 86 /* FinallyKeyword */: + case 74 /* CatchKeyword */: + case 87 /* FinallyKeyword */: return parseTryStatement(); - case 77 /* DebuggerKeyword */: + case 78 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 56 /* AtToken */: + case 57 /* AtToken */: return parseDeclaration(); - case 119 /* AsyncKeyword */: - case 108 /* InterfaceKeyword */: - case 137 /* TypeKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 123 /* DeclareKeyword */: - case 75 /* ConstKeyword */: - case 82 /* EnumKeyword */: - case 83 /* ExportKeyword */: - case 90 /* ImportKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 116 /* AbstractKeyword */: - case 114 /* StaticKeyword */: - case 130 /* ReadonlyKeyword */: - case 140 /* GlobalKeyword */: + case 120 /* AsyncKeyword */: + case 109 /* InterfaceKeyword */: + case 138 /* TypeKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: + case 124 /* DeclareKeyword */: + case 76 /* ConstKeyword */: + case 83 /* EnumKeyword */: + case 84 /* ExportKeyword */: + case 91 /* ImportKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 114 /* PublicKeyword */: + case 117 /* AbstractKeyword */: + case 115 /* StaticKeyword */: + case 131 /* ReadonlyKeyword */: + case 141 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -18539,33 +19063,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 74 /* ClassKeyword */: + case 75 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 108 /* InterfaceKeyword */: + case 109 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 137 /* TypeKeyword */: + case 138 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 82 /* EnumKeyword */: + case 83 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 140 /* GlobalKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: + case 141 /* GlobalKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 90 /* ImportKeyword */: + case 91 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 83 /* ExportKeyword */: + case 84 /* ExportKeyword */: nextToken(); switch (token()) { - case 78 /* DefaultKeyword */: - case 57 /* EqualsToken */: + case 79 /* DefaultKeyword */: + case 58 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); - case 117 /* AsKeyword */: + case 118 /* AsKeyword */: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); @@ -18574,7 +19098,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(246 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(247 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18587,7 +19111,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 16 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -18595,25 +19119,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 25 /* CommaToken */) { - return createNode(199 /* OmittedExpression */); + if (token() === 26 /* CommaToken */) { + return createNode(200 /* OmittedExpression */); } - var node = createNode(175 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var node = createNode(176 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(175 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var node = createNode(176 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -18621,33 +19145,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(173 /* ObjectBindingPattern */); - parseExpected(16 /* OpenBraceToken */); + var node = createNode(174 /* ObjectBindingPattern */); + parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(174 /* ArrayBindingPattern */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(175 /* ArrayBindingPattern */); + parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */ || isIdentifier(); + return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 20 /* OpenBracketToken */) { + if (token() === 21 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(225 /* VariableDeclaration */); + var node = createNode(226 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18656,14 +19180,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(226 /* VariableDeclarationList */); + var node = createNode(227 /* VariableDeclarationList */); switch (token()) { - case 103 /* VarKeyword */: + case 104 /* VarKeyword */: break; - case 109 /* LetKeyword */: + case 110 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 75 /* ConstKeyword */: + case 76 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -18679,7 +19203,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() === 141 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 142 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -18691,10 +19215,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(207 /* VariableStatement */, fullStart); + var node = createNode(208 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18702,29 +19226,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* FunctionDeclaration */, fullStart); + var node = createNode(228 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(88 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + parseExpected(89 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256 /* Async */); - fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(151 /* Constructor */, pos); + var node = createNode(152 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(122 /* ConstructorKeyword */); - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(123 /* ConstructorKeyword */); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(150 /* MethodDeclaration */, fullStart); + var method = createNode(151 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18732,12 +19256,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256 /* Async */); - fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(56 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(148 /* PropertyDeclaration */, fullStart); + var property = createNode(149 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18759,12 +19283,12 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(54 /* QuestionToken */); - if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var questionToken = parseOptionalToken(55 /* QuestionToken */); + if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -18779,17 +19303,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 114 /* StaticKeyword */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 115 /* StaticKeyword */: + case 131 /* ReadonlyKeyword */: return true; default: return false; @@ -18797,7 +19321,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 56 /* AtToken */) { + if (token() === 57 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -18814,7 +19338,7 @@ var ts; } nextToken(); } - if (token() === 38 /* AsteriskToken */) { + if (token() === 39 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -18824,23 +19348,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 20 /* OpenBracketToken */) { + if (token() === 21 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 134 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 135 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 18 /* OpenParenToken */: // Method declaration - case 26 /* LessThanToken */: // Generic Method declaration - case 55 /* ColonToken */: // Type Annotation for declaration - case 57 /* EqualsToken */: // Initializer for declaration - case 54 /* QuestionToken */: + case 19 /* OpenParenToken */: // Method declaration + case 27 /* LessThanToken */: // Generic Method declaration + case 56 /* ColonToken */: // Type Annotation for declaration + case 58 /* EqualsToken */: // Initializer for declaration + case 55 /* QuestionToken */: return true; default: // Covers @@ -18857,10 +19381,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(56 /* AtToken */)) { + if (!parseOptional(57 /* AtToken */)) { break; } - var decorator = createNode(146 /* Decorator */, decoratorStart); + var decorator = createNode(147 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18887,7 +19411,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 75 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -18914,7 +19438,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -18925,8 +19449,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 24 /* SemicolonToken */) { - var result = createNode(205 /* SemicolonClassElement */); + if (token() === 25 /* SemicolonToken */) { + var result = createNode(206 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18937,7 +19461,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 122 /* ConstructorKeyword */) { + if (token() === 123 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -18948,13 +19472,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 38 /* AsteriskToken */ || - token() === 20 /* OpenBracketToken */) { + token() === 39 /* AsteriskToken */ || + token() === 21 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -18964,24 +19488,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 198 /* ClassExpression */); + /*modifiers*/ undefined, 199 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 229 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(74 /* ClassKeyword */); + parseExpected(75 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(16 /* OpenBraceToken */)) { + if (parseExpected(17 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -18999,7 +19523,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 107 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -19010,9 +19534,10 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(258 /* HeritageClause */); - node.token = token(); + var tok = token(); + if (tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */) { + var node = createNode(259 /* HeritageClause */); + node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); @@ -19020,24 +19545,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(200 /* ExpressionWithTypeArguments */); + var node = createNode(201 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + if (token() === 27 /* LessThanToken */) { + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; + return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* InterfaceDeclaration */, fullStart); + var node = createNode(230 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(108 /* InterfaceKeyword */); + parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -19045,13 +19570,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* TypeAliasDeclaration */, fullStart); + var node = createNode(231 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(137 /* TypeKeyword */); + parseExpected(138 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(57 /* EqualsToken */); + parseExpected(58 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -19061,20 +19586,20 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(263 /* EnumMember */, scanner.getStartPos()); + var node = createNode(264 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231 /* EnumDeclaration */, fullStart); + var node = createNode(232 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(82 /* EnumKeyword */); + parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(16 /* OpenBraceToken */)) { + if (parseExpected(17 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -19082,10 +19607,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(233 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(16 /* OpenBraceToken */)) { + var node = createNode(234 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -19093,7 +19618,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(232 /* ModuleDeclaration */, fullStart); + var node = createNode(233 /* 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 & 16 /* Namespace */; @@ -19101,16 +19626,16 @@ var ts; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(22 /* DotToken */) + node.body = parseOptional(23 /* DotToken */) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(232 /* ModuleDeclaration */, fullStart); + var node = createNode(233 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 140 /* GlobalKeyword */) { + if (token() === 141 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -19118,7 +19643,7 @@ var ts; else { node.name = parseLiteralNode(/*internName*/ true); } - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -19128,15 +19653,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 140 /* GlobalKeyword */) { + if (token() === 141 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(128 /* NamespaceKeyword */)) { + else if (parseOptional(129 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(127 /* ModuleKeyword */); + parseExpected(128 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -19144,62 +19669,62 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 131 /* RequireKeyword */ && + return token() === 132 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 18 /* OpenParenToken */; + return nextToken() === 19 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 40 /* SlashToken */; + return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(235 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(236 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(117 /* AsKeyword */); - parseExpected(128 /* NamespaceKeyword */); + parseExpected(118 /* AsKeyword */); + parseExpected(129 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(90 /* ImportKeyword */); + parseExpected(91 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 139 /* FromKeyword */) { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; - var importEqualsDeclaration = createNode(236 /* ImportEqualsDeclaration */, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(57 /* EqualsToken */); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + if (token() !== 26 /* CommaToken */ && token() !== 140 /* FromKeyword */) { + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } // Import statement - var importDeclaration = createNode(237 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(238 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token() === 38 /* AsteriskToken */ || - token() === 16 /* OpenBraceToken */) { + token() === 39 /* AsteriskToken */ || + token() === 17 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(139 /* FromKeyword */); + parseExpected(140 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier) { + var importEqualsDeclaration = createNode(237 /* ImportEqualsDeclaration */, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(58 /* EqualsToken */); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } function parseImportClause(identifier, fullStart) { // ImportClause: // ImportedDefaultBinding @@ -19207,7 +19732,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(238 /* ImportClause */, fullStart); + var importClause = createNode(239 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -19216,8 +19741,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(240 /* NamedImports */); + parseOptional(26 /* CommaToken */)) { + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(241 /* NamedImports */); } return finishNode(importClause); } @@ -19227,11 +19752,11 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(247 /* ExternalModuleReference */); - parseExpected(131 /* RequireKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(248 /* ExternalModuleReference */); + parseExpected(132 /* RequireKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -19250,9 +19775,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(239 /* NamespaceImport */); - parseExpected(38 /* AsteriskToken */); - parseExpected(117 /* AsKeyword */); + var namespaceImport = createNode(240 /* NamespaceImport */); + parseExpected(39 /* AsteriskToken */); + parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -19265,14 +19790,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 240 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 241 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(245 /* ExportSpecifier */); + return parseImportOrExportSpecifier(246 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(241 /* ImportSpecifier */); + return parseImportOrExportSpecifier(242 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -19286,9 +19811,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 117 /* AsKeyword */) { + if (token() === 118 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(117 /* AsKeyword */); + parseExpected(118 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -19297,27 +19822,27 @@ var ts; else { node.name = identifierName; } - if (kind === 241 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 242 /* 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(243 /* ExportDeclaration */, fullStart); + var node = createNode(244 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(139 /* FromKeyword */); + if (parseOptional(39 /* AsteriskToken */)) { + parseExpected(140 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(244 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(245 /* 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() === 139 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(139 /* FromKeyword */); + if (token() === 140 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(140 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -19325,14 +19850,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(242 /* ExportAssignment */, fullStart); + var node = createNode(243 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(57 /* EqualsToken */)) { + if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(78 /* DefaultKeyword */); + parseExpected(79 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -19344,6 +19869,7 @@ var ts; var typeReferenceDirectives = []; var amdDependencies = []; var amdModuleName; + var checkJsDirective = undefined; // Keep scanning all the leading trivia in the file until we get to something that // isn't trivia. Any single line comment will be analyzed to see if it is a // reference comment. @@ -19357,7 +19883,11 @@ var ts; break; } } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var range = { + kind: triviaScanner.getToken(), + pos: triviaScanner.getTokenPos(), + end: triviaScanner.getTextPos(), + }; var comment = sourceText.substring(range.pos, range.end); var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { @@ -19397,20 +19927,30 @@ var ts; amdDependencies.push(amdDependency); } } + var checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; + var checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: ts.compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", /*ignoreCase*/ true) === 0 /* EqualTo */, + end: range.end, + pos: range.pos + }; + } } } sourceFile.referencedFiles = referencedFiles; sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */ - || node.kind === 237 /* ImportDeclaration */ - || node.kind === 242 /* ExportAssignment */ - || node.kind === 243 /* ExportDeclaration */ + || node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 248 /* ExternalModuleReference */ + || node.kind === 238 /* ImportDeclaration */ + || node.kind === 243 /* ExportAssignment */ + || node.kind === 244 /* ExportDeclaration */ ? node : undefined; }); @@ -19456,16 +19996,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 38 /* AsteriskToken */: - case 54 /* QuestionToken */: - case 18 /* OpenParenToken */: - case 20 /* OpenBracketToken */: - case 50 /* ExclamationToken */: - case 16 /* OpenBraceToken */: - case 88 /* FunctionKeyword */: - case 23 /* DotDotDotToken */: - case 93 /* NewKeyword */: - case 98 /* ThisKeyword */: + case 39 /* AsteriskToken */: + case 55 /* QuestionToken */: + case 19 /* OpenParenToken */: + case 21 /* OpenBracketToken */: + case 51 /* ExclamationToken */: + case 17 /* OpenBraceToken */: + case 89 /* FunctionKeyword */: + case 24 /* DotDotDotToken */: + case 94 /* NewKeyword */: + case 99 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token()); @@ -19485,23 +20025,23 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(266 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(16 /* OpenBraceToken */); + var result = createNode(267 /* JSDocTypeExpression */, scanner.getTokenPos()); + parseExpected(17 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 48 /* BarToken */) { - var unionType = createNode(270 /* JSDocUnionType */, type.pos); + if (token() === 49 /* BarToken */) { + var unionType = createNode(271 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(277 /* JSDocOptionalType */, type.pos); + if (token() === 58 /* EqualsToken */) { + var optionalType = createNode(278 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19511,21 +20051,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(269 /* JSDocArrayType */, type.pos); + if (token() === 21 /* OpenBracketToken */) { + var arrayType = createNode(270 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(272 /* JSDocNullableType */, type.pos); + else if (token() === 55 /* QuestionToken */) { + var nullableType = createNode(273 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(273 /* JSDocNonNullableType */, type.pos); + else if (token() === 51 /* ExclamationToken */) { + var nonNullableType = createNode(274 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19538,96 +20078,96 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: return parseJSDocAllType(); - case 54 /* QuestionToken */: + case 55 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return parseJSDocUnionType(); - case 20 /* OpenBracketToken */: + case 21 /* OpenBracketToken */: return parseJSDocTupleType(); - case 50 /* ExclamationToken */: + case 51 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseJSDocRecordType(); - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 23 /* DotDotDotToken */: + case 24 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 93 /* NewKeyword */: + case 94 /* NewKeyword */: return parseJSDocConstructorType(); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return parseJSDocThisType(); - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 94 /* NullKeyword */: - case 138 /* UndefinedKeyword */: - case 129 /* NeverKeyword */: - case 133 /* ObjectKeyword */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 95 /* NullKeyword */: + case 139 /* UndefinedKeyword */: + case 130 /* NeverKeyword */: + case 134 /* ObjectKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(281 /* JSDocThisType */); + var result = createNode(282 /* JSDocThisType */); nextToken(); - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(280 /* JSDocConstructorType */); + var result = createNode(281 /* JSDocConstructorType */); nextToken(); - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(279 /* JSDocVariadicType */); + var result = createNode(280 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(278 /* JSDocFunctionType */); + var result = createNode(279 /* JSDocFunctionType */); nextToken(); - parseExpected(18 /* OpenParenToken */); + parseExpected(19 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(19 /* CloseParenToken */); - if (token() === 55 /* ColonToken */) { + parseExpected(20 /* CloseParenToken */); + if (token() === 56 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(145 /* Parameter */); + var parameter = createNode(146 /* Parameter */); parameter.type = parseJSDocType(); - if (parseOptional(57 /* EqualsToken */)) { + if (parseOptional(58 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? - parameter.questionToken = createNode(57 /* EqualsToken */); + parameter.questionToken = createNode(58 /* EqualsToken */); } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(276 /* JSDocTypeReference */); + var result = createNode(277 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - if (token() === 26 /* LessThanToken */) { + if (token() === 27 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(22 /* DotToken */)) { - if (token() === 26 /* LessThanToken */) { + while (parseOptional(23 /* DotToken */)) { + if (token() === 27 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -19644,7 +20184,7 @@ var ts; var typeArguments = parseDelimitedList(24 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -19655,28 +20195,28 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(142 /* QualifiedName */, left.pos); + var result = createNode(143 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(274 /* JSDocRecordType */); + var result = createNode(275 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(273 /* JSDocNonNullableType */); + var result = createNode(274 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(271 /* JSDocTupleType */); + var result = createNode(272 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -19686,28 +20226,28 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(270 /* JSDocUnionType */); + var result = createNode(271 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(48 /* BarToken */)) { + while (parseOptional(49 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(267 /* JSDocAllType */); + var result = createNode(268 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(292 /* JSDocLiteralType */); + var result = createNode(293 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19724,17 +20264,17 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 25 /* CommaToken */ || - token() === 17 /* CloseBraceToken */ || - token() === 19 /* CloseParenToken */ || - token() === 28 /* GreaterThanToken */ || - token() === 57 /* EqualsToken */ || - token() === 48 /* BarToken */) { - var result = createNode(268 /* JSDocUnknownType */, pos); + if (token() === 26 /* CommaToken */ || + token() === 18 /* CloseBraceToken */ || + token() === 20 /* CloseParenToken */ || + token() === 29 /* GreaterThanToken */ || + token() === 58 /* EqualsToken */ || + token() === 49 /* BarToken */) { + var result = createNode(269 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(272 /* JSDocNullableType */, pos); + var result = createNode(273 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19810,7 +20350,7 @@ var ts; } while (token() !== 1 /* EndOfFileToken */) { switch (token()) { - case 56 /* AtToken */: + case 57 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); parseTag(indent); @@ -19831,7 +20371,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -19844,7 +20384,7 @@ var ts; indent += asterisk.length; } break; - case 70 /* Identifier */: + case 71 /* Identifier */: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. @@ -19899,7 +20439,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(282 /* JSDocComment */, start); + var result = createNode(283 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19910,8 +20450,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 56 /* AtToken */); - var atToken = createNode(56 /* AtToken */, scanner.getTokenPos()); + ts.Debug.assert(token() === 57 /* AtToken */); + var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -19957,7 +20497,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1 /* SawAsterisk */; + var state = 0 /* BeginningOfLine */; var margin; function pushComment(text) { if (!margin) { @@ -19966,7 +20506,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 56 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 57 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { switch (token()) { case 4 /* NewLineTrivia */: if (state >= 1 /* SawAsterisk */) { @@ -19975,7 +20515,7 @@ var ts; } indent = 0; break; - case 56 /* AtToken */: + case 57 /* AtToken */: // Done break; case 5 /* WhitespaceTrivia */: @@ -19991,20 +20531,21 @@ var ts; indent += whitespace.length; } break; - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; indent += scanner.getTokenText().length; break; } - // FALLTHROUGH otherwise to record the * as a comment + // record the * as a comment + // falls through default: state = 2 /* SavingComments */; // leading identifiers start recording as well pushComment(scanner.getTokenText()); break; } - if (token() === 56 /* AtToken */) { + if (token() === 57 /* AtToken */) { // Done break; } @@ -20015,7 +20556,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(283 /* JSDocTag */, atToken.pos); + var result = createNode(284 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20033,7 +20574,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 16 /* OpenBraceToken */) { + if (token() !== 17 /* OpenBraceToken */) { return undefined; } return parseJSDocTypeExpression(); @@ -20045,15 +20586,15 @@ var ts; var name; var isBracketed; // Looking for something like '[foo]' or 'foo' - if (parseOptionalToken(20 /* OpenBracketToken */)) { + if (parseOptionalToken(21 /* OpenBracketToken */)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(57 /* EqualsToken */)) { + if (parseOptionalToken(58 /* EqualsToken */)) { parseExpression(); } - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -20072,7 +20613,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(285 /* JSDocParameterTag */, atToken.pos); + var result = createNode(286 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -20083,20 +20624,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 286 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(286 /* JSDocReturnTag */, atToken.pos); + var result = createNode(287 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(287 /* JSDocTypeTag */, atToken.pos); + var result = createNode(288 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -20111,7 +20652,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(290 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(291 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -20120,7 +20661,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(284 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(285 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -20129,17 +20670,17 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(289 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(290 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; while (true) { - if (rightNode.kind === 70 /* Identifier */ || !rightNode.body) { + if (rightNode.kind === 71 /* Identifier */ || !rightNode.body) { // if node is identifier - use it as name // otherwise use name of the rightmost part that we were able to parse - typedefTag.name = rightNode.kind === 70 /* Identifier */ ? rightNode : rightNode.name; + typedefTag.name = rightNode.kind === 71 /* Identifier */ ? rightNode : rightNode.name; break; } rightNode = rightNode.body; @@ -20148,9 +20689,9 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 276 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 277 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 70 /* Identifier */) { + if (jsDocTypeReference.name.kind === 71 /* Identifier */) { var name = jsDocTypeReference.name; if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -20166,7 +20707,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(291 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -20174,7 +20715,7 @@ var ts; while (token() !== 1 /* EndOfFileToken */ && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 56 /* AtToken */: + case 57 /* AtToken */: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -20188,14 +20729,15 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 70 /* Identifier */: + case 71 /* Identifier */: canParseTag = false; + break; case 1 /* EndOfFileToken */: break; } @@ -20206,8 +20748,8 @@ var ts; function parseJSDocTypeNameWithNamespace(flags) { var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(232 /* ModuleDeclaration */, pos); + if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) { + var jsDocNamespaceNode = createNode(233 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -20220,8 +20762,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 56 /* AtToken */); - var atToken = createNode(56 /* AtToken */, scanner.getStartPos()); + ts.Debug.assert(token() === 57 /* AtToken */); + var atToken = createNode(57 /* AtToken */, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -20253,7 +20795,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 289 /* 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' @@ -20265,11 +20807,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(144 /* TypeParameter */, name.pos); + var typeParameter = createNode(145 /* TypeParameter */, name.pos); typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 25 /* CommaToken */) { + if (token() === 26 /* CommaToken */) { nextJSDocToken(); skipWhitespace(); } @@ -20277,7 +20819,7 @@ var ts; break; } } - var result = createNode(288 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(289 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20298,7 +20840,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(70 /* Identifier */, pos); + var result = createNode(71 /* Identifier */, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -20426,7 +20968,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 70 /* Identifier */: + case 71 /* Identifier */: return true; } return false; @@ -20797,16 +21339,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 230 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* InterfaceDeclaration */ || node.kind === 231 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 238 /* ImportDeclaration */ || node.kind === 237 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 233 /* ModuleBlock */) { + else if (node.kind === 234 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20825,11 +21367,11 @@ var ts; }); return state_1; } - else if (node.kind === 232 /* ModuleDeclaration */) { + else if (node.kind === 233 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } - else if (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace) { + else if (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace) { return 0 /* NonInstantiated */; } else { @@ -20938,7 +21480,7 @@ var ts; } return bindSourceFile; function bindInStrictMode(file, opts) { - if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !ts.isDeclarationFile(file)) { // bind in strict mode source files with alwaysStrict option return true; } @@ -20966,7 +21508,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 233 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20979,7 +21521,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* 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)) { @@ -20991,27 +21533,28 @@ var ts; return node.name.text; } switch (node.kind) { - case 151 /* Constructor */: + case 152 /* Constructor */: return "__constructor"; - case 159 /* FunctionType */: - case 154 /* CallSignature */: + case 160 /* FunctionType */: + case 155 /* CallSignature */: return "__call"; - case 160 /* ConstructorType */: - case 155 /* ConstructSignature */: + case 161 /* ConstructorType */: + case 156 /* ConstructSignature */: return "__new"; - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return "__index"; - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return "__export"; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... return "export="; case 1 /* ExportsProperty */: case 4 /* ThisProperty */: + case 5 /* Property */: // exports.x = ... or this.y = ... return node.left.name.text; case 3 /* PrototypeProperty */: @@ -21020,25 +21563,25 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 227 /* FunctionDeclaration */: - case 228 /* ClassDeclaration */: + case 228 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 278 /* JSDocFunctionType */: + case 279 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 145 /* Parameter */: + case 146 /* 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 === 278 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 279 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 207 /* VariableStatement */) { + if (parentNode && parentNode.kind === 208 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70 /* Identifier */) { + if (nameIdentifier.kind === 71 /* Identifier */) { nameFromParentNode = nameIdentifier.text; } } @@ -21125,7 +21668,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 242 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 243 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -21145,11 +21688,11 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 245 /* ExportSpecifier */ || (node.kind === 236 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 246 /* ExportSpecifier */ || (node.kind === 237 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } } else { @@ -21168,21 +21711,21 @@ 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. - var isJSDocTypedefInJSDocNamespace = node.kind === 289 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 290 /* JSDocTypedefTag */ && node.name && - node.name.kind === 70 /* Identifier */ && + node.name.kind === 71 /* Identifier */ && node.name.isInJSDocNamespace; if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793064 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1920 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); - var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); + var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; return local; } else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } } } @@ -21255,7 +21798,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -21334,66 +21877,72 @@ var ts; return; } switch (node.kind) { - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: bindWhileStatement(node); break; - case 211 /* DoStatement */: + case 212 /* DoStatement */: bindDoStatement(node); break; - case 213 /* ForStatement */: + case 214 /* ForStatement */: bindForStatement(node); break; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 210 /* IfStatement */: + case 211 /* IfStatement */: bindIfStatement(node); break; - case 218 /* ReturnStatement */: - case 222 /* ThrowStatement */: + case 219 /* ReturnStatement */: + case 223 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 223 /* TryStatement */: + case 224 /* TryStatement */: bindTryStatement(node); break; - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: bindSwitchStatement(node); break; - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: bindCaseBlock(node); break; - case 256 /* CaseClause */: + case 257 /* CaseClause */: bindCaseClause(node); break; - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: bindLabeledStatement(node); break; - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 180 /* CallExpression */: + case 181 /* CallExpression */: bindCallExpressionFlow(node); break; + case 283 /* JSDocComment */: + bindJSDocComment(node); + break; + case 290 /* JSDocTypedefTag */: + bindJSDocTypedefTag(node); + break; default: bindEachChild(node); break; @@ -21401,25 +21950,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 99 /* ThisKeyword */: + case 179 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return hasNarrowableArgument(expr); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 191 /* PrefixUnaryExpression */: - return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 192 /* PrefixUnaryExpression */: + return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 70 /* Identifier */ || - expr.kind === 98 /* ThisKeyword */ || - expr.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + return expr.kind === 71 /* Identifier */ || + expr.kind === 99 /* ThisKeyword */ || + expr.kind === 97 /* SuperKeyword */ || + expr.kind === 179 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21430,41 +21980,41 @@ var ts; } } } - if (expr.expression.kind === 178 /* PropertyAccessExpression */ && + if (expr.expression.kind === 179 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 188 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 189 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return isNarrowableReference(expr.left); - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 92 /* InstanceOfKeyword */: + case 93 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -21499,8 +22049,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 100 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 85 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -21555,34 +22105,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 210 /* IfStatement */: - case 212 /* WhileStatement */: - case 211 /* DoStatement */: + case 211 /* IfStatement */: + case 213 /* WhileStatement */: + case 212 /* DoStatement */: return parent.expression === node; - case 213 /* ForStatement */: - case 194 /* ConditionalExpression */: + case 214 /* ForStatement */: + case 195 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 184 /* ParenthesizedExpression */) { + if (node.kind === 185 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 191 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 192 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 193 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 53 /* BarBarToken */); + return node.kind === 194 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 184 /* ParenthesizedExpression */ || - node.parent.kind === 191 /* PrefixUnaryExpression */ && - node.parent.operator === 50 /* ExclamationToken */) { + while (node.parent.kind === 185 /* ParenthesizedExpression */ || + node.parent.kind === 192 /* PrefixUnaryExpression */ && + node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -21623,7 +22173,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 221 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 222 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21657,10 +22207,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; + if (node.kind === 216 /* ForOfStatement */) { + bind(node.awaitModifier); + } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 226 /* VariableDeclarationList */) { + if (node.initializer.kind !== 227 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21682,7 +22235,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 218 /* ReturnStatement */) { + if (node.kind === 219 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21702,7 +22255,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 217 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 218 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21743,8 +22296,8 @@ var ts; // second -> edge that represents post-finally flow. // these edges are used in following scenario: // let a; (1) - // try { a = someOperation(); (2)} - // finally { (3) console.log(a) } (4) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) // (5) a // flow graph for this case looks roughly like this (arrows show ): // (1-pre-try-flow) <--.. <-- (2-post-try-flow) @@ -21755,11 +22308,11 @@ var ts; // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable - // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // Simply speaking code inside finally block is treated as reachable as pre-try-flow // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from // final flows of these blocks without taking pre-try flow into account. - // + // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preTryFlow, lock: {} }; @@ -21798,7 +22351,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 258 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21865,14 +22418,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 211 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 212 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 194 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -21883,10 +22436,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 176 /* ArrayLiteralExpression */) { + else if (node.kind === 177 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 197 /* SpreadElement */) { + if (e.kind === 198 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -21894,16 +22447,16 @@ var ts; } } } - else if (node.kind === 177 /* ObjectLiteralExpression */) { + else if (node.kind === 178 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 260 /* PropertyAssignment */) { + if (p.kind === 261 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 261 /* ShorthandPropertyAssignment */) { + else if (p.kind === 262 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 262 /* SpreadAssignment */) { + else if (p.kind === 263 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21911,7 +22464,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -21922,7 +22475,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 50 /* ExclamationToken */) { + if (node.operator === 51 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -21932,20 +22485,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { + if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { + if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 52 /* AmpersandAmpersandToken */ || operator === 53 /* BarBarToken */) { + if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -21959,7 +22512,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 /* EqualsToken */ && node.left.kind === 179 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 180 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21970,7 +22523,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 178 /* PropertyAccessExpression */) { + if (node.expression.kind === 179 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -22003,19 +22556,37 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 214 /* ForInStatement */ || node.parent.parent.kind === 215 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 215 /* ForInStatement */ || node.parent.parent.kind === 216 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } + function bindJSDocComment(node) { + ts.forEachChild(node, function (n) { + if (n.kind !== 290 /* JSDocTypedefTag */) { + bind(n); + } + }); + } + function bindJSDocTypedefTag(node) { + ts.forEachChild(node, function (n) { + // if the node has a fullName "A.B.C", that means symbol "C" was already bound + // when we visit "fullName"; so when we visit the name "C" as the next child of + // the jsDocTypedefTag, we should skip binding it. + if (node.fullName && n === node.name && node.fullName.kind !== 71 /* Identifier */) { + return; + } + bind(n); + }); + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 184 /* ParenthesizedExpression */) { + while (expr.kind === 185 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 185 /* FunctionExpression */ || expr.kind === 186 /* ArrowFunction */) { + if (expr.kind === 186 /* FunctionExpression */ || expr.kind === 187 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -22023,7 +22594,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 178 /* PropertyAccessExpression */) { + if (node.expression.kind === 179 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22032,53 +22603,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 198 /* ClassExpression */: - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 177 /* ObjectLiteralExpression */: - case 162 /* TypeLiteral */: - case 291 /* JSDocTypeLiteral */: - case 274 /* JSDocRecordType */: - case 253 /* JsxAttributes */: + case 199 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 178 /* ObjectLiteralExpression */: + case 163 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 275 /* JSDocRecordType */: + case 254 /* JsxAttributes */: return 1 /* IsContainer */; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 278 /* JSDocFunctionType */: - case 232 /* ModuleDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 171 /* MappedType */: + case 279 /* JSDocFunctionType */: + case 233 /* ModuleDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 172 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 264 /* SourceFile */: + case 265 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + // falls through + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 259 /* CatchClause */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 234 /* CaseBlock */: + case 260 /* CatchClause */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 235 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 206 /* Block */: + case 207 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -22115,43 +22687,43 @@ 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 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 264 /* SourceFile */: + case 265 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 198 /* ClassExpression */: - case 228 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 229 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 162 /* TypeLiteral */: - case 177 /* ObjectLiteralExpression */: - case 229 /* InterfaceDeclaration */: - case 274 /* JSDocRecordType */: - case 291 /* JSDocTypeLiteral */: - case 253 /* JsxAttributes */: + case 163 /* TypeLiteral */: + case 178 /* ObjectLiteralExpression */: + case 230 /* InterfaceDeclaration */: + case 275 /* JSDocRecordType */: + case 292 /* JSDocTypeLiteral */: + case 254 /* JsxAttributes */: // 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 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 278 /* JSDocFunctionType */: - case 230 /* TypeAliasDeclaration */: - case 171 /* MappedType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 279 /* JSDocFunctionType */: + case 231 /* TypeAliasDeclaration */: + case 172 /* MappedType */: // 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 @@ -22169,14 +22741,14 @@ var ts; function declareSourceFileMember(node, symbolFlags, symbolExcludes) { return ts.isExternalModule(file) ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); + : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 264 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 264 /* SourceFile */ || body.kind === 233 /* ModuleBlock */)) { + var body = node.kind === 265 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 265 /* SourceFile */ || body.kind === 234 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 243 /* ExportDeclaration */ || stat.kind === 242 /* ExportAssignment */) { + if (stat.kind === 244 /* ExportDeclaration */ || stat.kind === 243 /* ExportAssignment */) { return true; } } @@ -22271,7 +22843,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 263 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -22283,7 +22855,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 === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */ || prop.kind === 150 /* MethodDeclaration */ + var currentKind = prop.kind === 261 /* PropertyAssignment */ || prop.kind === 262 /* ShorthandPropertyAssignment */ || prop.kind === 151 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.text); @@ -22311,21 +22883,21 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; } - // fall through. + // falls through default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = ts.createMap(); addToContainerChain(blockScopeContainer); } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); + declareSymbol(blockScopeContainer.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } } function bindBlockScopedVariableDeclaration(node) { @@ -22335,8 +22907,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 107 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 115 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { // Report error only if there are no parse errors in file @@ -22372,7 +22944,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 70 /* Identifier */) { + if (inStrictMode && node.expression.kind === 71 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span_2 = ts.getErrorSpanForNode(file, node.expression); @@ -22380,11 +22952,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 70 /* Identifier */ && + return node.kind === 71 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 70 /* Identifier */) { + if (name && name.kind === 71 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -22425,8 +22997,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 264 /* SourceFile */ && - blockScopeContainer.kind !== 232 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 265 /* SourceFile */ && + blockScopeContainer.kind !== 233 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22436,7 +23008,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.isOctalLiteral) { + if (inStrictMode && node.numericLiteralFlags & 4 /* Octal */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -22452,7 +23024,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { + if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -22476,6 +23048,18 @@ var ts; } node.parent = parent; var saveInStrictMode = inStrictMode; + // Even though in the AST the jsdoc @typedef node belongs to the current node, + // its symbol might be in the same scope with the current node's symbol. Consider: + // + // /** @typedef {string | number} MyType */ + // function foo(); + // + // Here the current node is "foo", which is a container, but the scope of "MyType" should + // not be inside "foo". Therefore we always bind @typedef before bind the parent node, + // and skip binding this tag later when binding all the other jsdoc tags. + if (ts.isInJavaScriptFile(node)) { + bindJSDocTypedefTagIfAny(node); + } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -22492,7 +23076,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 141 /* LastToken */) { + if (node.kind > 142 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -22509,6 +23093,26 @@ var ts; } inStrictMode = saveInStrictMode; } + function bindJSDocTypedefTagIfAny(node) { + if (!node.jsDoc) { + return; + } + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + if (!jsDoc.tags) { + continue; + } + for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) { + var tag = _c[_b]; + if (tag.kind === 290 /* JSDocTypedefTag */) { + var savedParent = parent; + parent = jsDoc; + bind(tag); + parent = savedParent; + } + } + } + } function updateStrictModeStatementList(statements) { if (!inStrictMode) { for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { @@ -22533,95 +23137,97 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 70 /* Identifier */: + case 71 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 289 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 290 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } - case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 261 /* ShorthandPropertyAssignment */)) { + // falls through + case 99 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 262 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 193 /* BinaryExpression */: - if (ts.isInJavaScriptFile(node)) { - var specialKind = ts.getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case 1 /* ExportsProperty */: - bindExportsPropertyAssignment(node); - break; - case 2 /* ModuleExports */: - bindModuleExportsAssignment(node); - break; - case 3 /* PrototypeProperty */: - bindPrototypePropertyAssignment(node); - break; - case 4 /* ThisProperty */: - bindThisPropertyAssignment(node); - break; - case 0 /* None */: - // Nothing to do - break; - default: - ts.Debug.fail("Unknown special property assignment kind"); - } + case 194 /* BinaryExpression */: + var specialKind = ts.getSpecialPropertyAssignmentKind(node); + switch (specialKind) { + case 1 /* ExportsProperty */: + bindExportsPropertyAssignment(node); + break; + case 2 /* ModuleExports */: + bindModuleExportsAssignment(node); + break; + case 3 /* PrototypeProperty */: + bindPrototypePropertyAssignment(node); + break; + case 4 /* ThisProperty */: + bindThisPropertyAssignment(node); + break; + case 5 /* Property */: + bindStaticPropertyAssignment(node); + break; + case 0 /* None */: + // Nothing to do + break; + default: + ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return checkStrictModeCatchClause(node); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return checkStrictModeWithStatement(node); - case 168 /* ThisType */: + case 169 /* ThisType */: seenThisKeyword = true; return; - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return checkTypePredicate(node); - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 145 /* Parameter */: + case 146 /* Parameter */: return bindParameter(node); - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 275 /* JSDocRecordMember */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 276 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 290 /* JSDocPropertyTag */: + case 291 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 263 /* EnumMember */: + case 264 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 262 /* SpreadAssignment */: - case 254 /* JsxSpreadAttribute */: + case 263 /* SpreadAssignment */: + case 255 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 177 /* ObjectLiteralExpression */ && - root.parent.kind === 193 /* BinaryExpression */ && - root.parent.operatorToken.kind === 57 /* EqualsToken */ && + if (root.kind === 178 /* ObjectLiteralExpression */ && + root.parent.kind === 194 /* BinaryExpression */ && + root.parent.operatorToken.kind === 58 /* EqualsToken */ && root.parent.left === root) { hasRest = true; break; @@ -22629,100 +23235,100 @@ var ts; root = root.parent; } return; - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* 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 ? 67108864 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 278 /* JSDocFunctionType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 279 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 162 /* TypeLiteral */: - case 171 /* MappedType */: - case 291 /* JSDocTypeLiteral */: - case 274 /* JSDocRecordType */: + case 163 /* TypeLiteral */: + case 172 /* MappedType */: + case 292 /* JSDocTypeLiteral */: + case 275 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return bindFunctionExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 198 /* ClassExpression */: - case 228 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 229 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 289 /* JSDocTypedefTag */: - if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { + case 290 /* JSDocTypedefTag */: + if (!node.fullName || node.fullName.kind === 71 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return bindJsxAttributes(node); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 236 /* ImportEqualsDeclaration */: - case 239 /* NamespaceImport */: - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 240 /* NamespaceImport */: + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 235 /* NamespaceExportDeclaration */: + case 236 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 238 /* ImportClause */: + case 239 /* ImportClause */: return bindImportClause(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return bindExportDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return bindExportAssignment(node); - case 264 /* SourceFile */: + case 265 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 206 /* Block */: + case 207 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } - // Fall through - case 233 /* ModuleBlock */: + // falls through + case 234 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 70 /* Identifier */) { + if (parameterName && parameterName.kind === 71 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 168 /* ThisType */) { + if (parameterName && parameterName.kind === 169 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -22745,7 +23351,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 242 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 243 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22755,7 +23361,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 264 /* SourceFile */) { + if (node.parent.kind !== 265 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22802,30 +23408,67 @@ var ts; setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); } + function isExportsOrModuleExportsOrAlias(node) { + return ts.isExportsIdentifier(node) || + ts.isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + function isNameOfExportsOrModuleExportsAliasDeclaration(node) { + if (node.kind === 71 /* Identifier */) { + var symbol = lookupSymbolForName(node.text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* VariableDeclaration */) { + var declaration = symbol.valueDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + function isExportsOrModuleExportsOrAliasOrAssignemnt(node) { + return isExportsOrModuleExportsOrAlias(node) || + (ts.isAssignmentExpression(node, /*excludeCompoundAssignements*/ true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } function bindModuleExportsAssignment(node) { + // A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports' + // is still pointing to 'module.exports'. + // We do not want to consider this as 'export=' since a module can have only one of these. + // Similarlly we do not want to treat 'module.exports = exports' as an 'export='. + var assignedExpression = ts.getRightMostAssignedExpression(node.right); + if (ts.isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + // Mark it as a module in case there are no other exports in the file + setCommonJsModuleIndicator(node); + return; + } // 'module.exports = expr' assignment setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, 4 /* Property */ | 7340032 /* Export */ | 512 /* ValueModule */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 227 /* FunctionDeclaration */ || container.kind === 185 /* FunctionExpression */) { - container.symbol.members = container.symbol.members || ts.createMap(); - // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); - } - else if (container.kind === 151 /* Constructor */) { - // this.foo assignment in a JavaScript class - // Bind this property to the containing class - var saveContainer = container; - container = container.parent; - var symbol = bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* None */); - if (symbol) { - // constructor-declared symbols can be overwritten by subsequent method declarations - symbol.isReplaceableByMethod = true; - } - container = saveContainer; + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + switch (container.kind) { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + // Declare a 'member' if the container is an ES5 class or ES6 constructor + container.symbol.members = container.symbol.members || ts.createMap(); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + break; + case 152 /* Constructor */: + case 149 /* PropertyDeclaration */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + var containingClass = container.parent; + var symbol = declareSymbol(ts.hasModifier(container, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, 4 /* Property */, 0 /* None */); + if (symbol) { + // symbols declared through 'this' property assignements can be overwritten by subsequent method declarations + symbol.isReplaceableByMethod = true; + } + break; } } function bindPrototypePropertyAssignment(node) { @@ -22839,16 +23482,44 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals.get(constructorFunction.text); - if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, /*isPrototypeProperty*/ true); + } + function bindStaticPropertyAssignment(node) { + // We saw a node of the form 'x.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 leftSideOfAssignment = node.left; + var target = leftSideOfAssignment.expression; + // Fix up parent pointers since we're going to use these nodes before we bind into them + leftSideOfAssignment.parent = node; + target.parent = leftSideOfAssignment; + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + // This can be an alias for the 'exports' or 'module.exports' names, e.g. + // var util = module.exports; + // util.property = function ... + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + } + } + function lookupSymbolForName(name) { + return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name)); + } + function bindPropertyAssignment(functionName, propertyAccessExpression, isPrototypeProperty) { + var targetSymbol = lookupSymbolForName(functionName); + if (targetSymbol && ts.isDeclarationOfFunctionOrClassExpression(targetSymbol)) { + targetSymbol = targetSymbol.valueDeclaration.initializer.symbol; + } + if (!targetSymbol || !(targetSymbol.flags & (16 /* Function */ | 32 /* Class */))) { return; } // Set up the members collection if it doesn't exist already - if (!funcSymbol.members) { - funcSymbol.members = ts.createMap(); - } + var symbolTable = isPrototypeProperty ? + (targetSymbol.members || (targetSymbol.members = ts.createMap())) : + (targetSymbol.exports || (targetSymbol.exports = ts.createMap())); // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4 /* Property */, 0 /* PropertyExcludes */); + declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, 4 /* Property */, 0 /* PropertyExcludes */); } function bindCallExpression(node) { // We're only inspecting call expressions to detect CommonJS modules, so we can skip @@ -22858,7 +23529,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22941,7 +23612,7 @@ var ts; } function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024 /* HasAsyncFunctions */; } } @@ -22956,7 +23627,7 @@ var ts; } function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024 /* HasAsyncFunctions */; } } @@ -22969,7 +23640,7 @@ var ts; } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024 /* HasAsyncFunctions */; } } @@ -22995,13 +23666,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 208 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 209 /* EmptyStatement */) || // report error on class declarations - node.kind === 228 /* ClassDeclaration */ || + node.kind === 229 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 232 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 233 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 231 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 232 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -23015,7 +23686,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 207 /* VariableStatement */ || + (node.kind !== 208 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -23035,56 +23706,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 180 /* CallExpression */: + case 181 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 145 /* Parameter */: + case 146 /* Parameter */: return computeParameter(node, subtreeFlags); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 151 /* Constructor */: + case 152 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -23109,13 +23780,13 @@ var ts; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: return true; - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 96 /* SuperKeyword */; + return expressionKind === 97 /* SuperKeyword */; } return false; } @@ -23136,17 +23807,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 177 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 178 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 177 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ - || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ + || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -23191,8 +23862,8 @@ 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 (expressionKind === 201 /* AsExpression */ - || expressionKind === 183 /* TypeAssertionExpression */) { + if (expressionKind === 202 /* AsExpression */ + || expressionKind === 184 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -23250,11 +23921,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 84 /* ExtendsKeyword */: + case 85 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 107 /* ImplementsKeyword */: + case 108 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -23317,10 +23988,9 @@ var ts; } // An async method declaration is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 16 /* AssertES2017 */; + transformFlags |= node.asteriskToken ? 8 /* AssertESNext */ : 16 /* AssertES2017 */; } - // Currently, we only support generators that were originally async function bodies. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { transformFlags |= 768 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -23374,7 +24044,7 @@ var ts; } // An async function declaration is ES2017 syntax. if (modifierFlags & 256 /* Async */) { - transformFlags |= 16 /* AssertES2017 */; + transformFlags |= node.asteriskToken ? 8 /* AssertESNext */ : 16 /* AssertES2017 */; } // function declarations with object rest destructuring are ES Next syntax if (subtreeFlags & 1048576 /* ContainsObjectRest */) { @@ -23391,7 +24061,7 @@ var ts; // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { transformFlags |= 768 /* AssertGenerator */; } } @@ -23409,7 +24079,7 @@ var ts; } // An async function expression is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 16 /* AssertES2017 */; + transformFlags |= node.asteriskToken ? 8 /* AssertESNext */ : 16 /* AssertES2017 */; } // function expressions with object rest destructuring are ES Next syntax if (subtreeFlags & 1048576 /* ContainsObjectRest */) { @@ -23424,9 +24094,7 @@ var ts; // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. - // Currently we do not support transforming any other generator fucntions - // down level. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { transformFlags |= 768 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -23463,7 +24131,7 @@ var ts; var expressionKind = expression.kind; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === 96 /* SuperKeyword */) { + if (expressionKind === 97 /* SuperKeyword */) { transformFlags |= 16384 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -23556,95 +24224,109 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536872257 /* NodeExcludes */; switch (kind) { - case 119 /* AsyncKeyword */: - case 190 /* AwaitExpression */: - // async/await is ES2017 syntax - transformFlags |= 16 /* AssertES2017 */; + case 120 /* AsyncKeyword */: + case 191 /* AwaitExpression */: + // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) + transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 116 /* AbstractKeyword */: - case 123 /* DeclareKeyword */: - case 75 /* ConstKeyword */: - case 231 /* EnumDeclaration */: - case 263 /* EnumMember */: - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: - case 202 /* NonNullExpression */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 117 /* AbstractKeyword */: + case 124 /* DeclareKeyword */: + case 76 /* ConstKeyword */: + case 232 /* EnumDeclaration */: + case 264 /* EnumMember */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: + case 203 /* NonNullExpression */: + case 131 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 248 /* JsxElement */: - case 249 /* JsxSelfClosingElement */: - case 250 /* JsxOpeningElement */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: case 10 /* JsxText */: - case 251 /* JsxClosingElement */: - case 252 /* JsxAttribute */: - case 253 /* JsxAttributes */: - case 254 /* JsxSpreadAttribute */: - case 255 /* JsxExpression */: + case 252 /* JsxClosingElement */: + case 253 /* JsxAttribute */: + case 254 /* JsxAttributes */: + case 255 /* JsxSpreadAttribute */: + case 256 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 215 /* ForOfStatement */: - // for-of might be ESNext if it has a rest destructuring - transformFlags |= 8 /* AssertESNext */; - // FALLTHROUGH - case 12 /* NoSubstitutionTemplateLiteral */: - case 13 /* TemplateHead */: - case 14 /* TemplateMiddle */: - case 15 /* TemplateTail */: - case 195 /* TemplateExpression */: - case 182 /* TaggedTemplateExpression */: - case 261 /* ShorthandPropertyAssignment */: - case 114 /* StaticKeyword */: - case 203 /* MetaProperty */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* TemplateHead */: + case 15 /* TemplateMiddle */: + case 16 /* TemplateTail */: + case 196 /* TemplateExpression */: + case 183 /* TaggedTemplateExpression */: + case 262 /* ShorthandPropertyAssignment */: + case 115 /* StaticKeyword */: + case 204 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 196 /* YieldExpression */: - // This node is ES6 syntax. - transformFlags |= 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; + case 9 /* StringLiteral */: + if (node.hasExtendedUnicodeEscape) { + transformFlags |= 192 /* AssertES2015 */; + } break; - case 118 /* AnyKeyword */: - case 132 /* NumberKeyword */: - case 129 /* NeverKeyword */: - case 133 /* ObjectKeyword */: - case 135 /* StringKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 144 /* TypeParameter */: - case 147 /* PropertySignature */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 157 /* TypePredicate */: - case 158 /* TypeReference */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 161 /* TypeQuery */: - case 162 /* TypeLiteral */: - case 163 /* ArrayType */: - case 164 /* TupleType */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: - case 167 /* ParenthesizedType */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 168 /* ThisType */: - case 169 /* TypeOperator */: - case 170 /* IndexedAccessType */: - case 171 /* MappedType */: - case 172 /* LiteralType */: + case 8 /* NumericLiteral */: + if (node.numericLiteralFlags & 48 /* BinaryOrOctalSpecifier */) { + transformFlags |= 192 /* AssertES2015 */; + } + break; + case 216 /* ForOfStatement */: + // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). + if (node.awaitModifier) { + transformFlags |= 8 /* AssertESNext */; + } + transformFlags |= 192 /* AssertES2015 */; + break; + case 197 /* YieldExpression */: + // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async + // generator). + transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; + break; + case 119 /* AnyKeyword */: + case 133 /* NumberKeyword */: + case 130 /* NeverKeyword */: + case 134 /* ObjectKeyword */: + case 136 /* StringKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 145 /* TypeParameter */: + case 148 /* PropertySignature */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 158 /* TypePredicate */: + case 159 /* TypeReference */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 162 /* TypeQuery */: + case 163 /* TypeLiteral */: + case 164 /* ArrayType */: + case 165 /* TupleType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: + case 168 /* ParenthesizedType */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 169 /* ThisType */: + case 170 /* TypeOperator */: + case 171 /* IndexedAccessType */: + case 172 /* MappedType */: + case 173 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -23661,42 +24343,42 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 173 /* ObjectBindingPattern */: + case 174 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 174 /* ArrayBindingPattern */: + case 175 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 175 /* BindingElement */: + case 176 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 146 /* Decorator */: + case 147 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: excludeFlags = 540087617 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -23714,8 +24396,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 176 /* ArrayLiteralExpression */: - case 181 /* NewExpression */: + case 177 /* ArrayLiteralExpression */: + case 182 /* NewExpression */: excludeFlags = 537396545 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -23723,23 +24405,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* ReturnStatement */: - case 216 /* ContinueStatement */: - case 217 /* BreakStatement */: + case 219 /* ReturnStatement */: + case 217 /* ContinueStatement */: + case 218 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23755,57 +24437,57 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) { + if (kind >= 158 /* FirstTypeNode */ && kind <= 173 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 176 /* ArrayLiteralExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 177 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; - case 145 /* Parameter */: + case 146 /* Parameter */: return 536872257 /* ParameterExcludes */; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return 539358529 /* ClassExcludes */; - case 151 /* Constructor */: + case 152 /* Constructor */: return 601015617 /* ConstructorExcludes */; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return 601015617 /* MethodOrAccessorExcludes */; - case 118 /* AnyKeyword */: - case 132 /* NumberKeyword */: - case 129 /* NeverKeyword */: - case 135 /* StringKeyword */: - case 133 /* ObjectKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 144 /* TypeParameter */: - case 147 /* PropertySignature */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 119 /* AnyKeyword */: + case 133 /* NumberKeyword */: + case 130 /* NeverKeyword */: + case 136 /* StringKeyword */: + case 134 /* ObjectKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 145 /* TypeParameter */: + case 148 /* PropertySignature */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 259 /* CatchClause */: + case 260 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: return 537396545 /* BindingPatternExcludes */; default: return 536872257 /* NodeExcludes */; @@ -23917,7 +24599,7 @@ var ts; // And if it doesn't exist, tough. } var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) { var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -24020,13 +24702,13 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ function getAutomaticTypeDirectiveNames(options, host) { // Use explicit type list from tsconfig.json if (options.types) { @@ -24120,7 +24802,7 @@ var ts; } directoryPathMap.set(parent, result); current = parent; - if (current == commonPrefix) { + if (current === commonPrefix) { break; } } @@ -24380,7 +25062,7 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false); } ts.nodeModuleNameResolver = nodeModuleNameResolver; /* @internal */ @@ -24634,9 +25316,23 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } + /** For a scoped package, we must look in `@types/foo__bar` instead of `@types/@foo/bar`. */ + function mangleScopedPackage(moduleName, state) { + if (ts.startsWith(moduleName, "@")) { + var replaceSlash = moduleName.replace(ts.directorySeparator, "__"); + if (replaceSlash !== moduleName) { + var mangled = replaceSlash.slice(1); // Take off the "@" + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled); + } + return mangled; + } + } + return moduleName; + } function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { var result = cache && cache.get(containingDirectory); if (result) { @@ -24766,18 +25462,27 @@ var ts; var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; var symbolCount = 0; + var symbolInstantiationDepth = 0; var emptyArray = []; var emptySymbols = ts.createMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; + var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); var noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; - var strictNullChecks = compilerOptions.strictNullChecks; + var strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks; + var noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny; + var noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; var emitResolver = createResolver(); + var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); undefinedSymbol.declarations = []; var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); + // for public members that accept a Node or one of its subtypes, we must guard against + // synthetic nodes created during transformations by calling `getParseTreeNode`. + // for most of these, we perform the guard only on `checker` to avoid any possible + // extra cost of calling `getParseTreeNode` when calling these functions from inside the + // checker. var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -24786,10 +25491,18 @@ var ts; isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, + getMergedSymbol: getMergedSymbol, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, - getSymbolsOfParameterPropertyDeclaration: getSymbolsOfParameterPropertyDeclaration, + getTypeOfSymbolAtLocation: function (symbol, location) { + location = ts.getParseTreeNode(location); + return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + }, + getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { + parameter = ts.getParseTreeNode(parameter, ts.isParameter); + ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + return getSymbolsOfParameterPropertyDeclaration(parameter, parameterName); + }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -24797,37 +25510,103 @@ var ts; getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, - getTypeFromTypeNode: getTypeFromTypeNode, + getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, + getWidenedType: getWidenedType, + getTypeFromTypeNode: function (node) { + node = ts.getParseTreeNode(node, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : unknownType; + }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, - getTypeAtLocation: getTypeOfNode, - getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, - signatureToString: signatureToString, - typeToString: typeToString, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, + getSymbolsInScope: function (location, meaning) { + location = ts.getParseTreeNode(location); + return location ? getSymbolsInScope(location, meaning) : []; + }, + getSymbolAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getSymbolAtLocation(node) : undefined; + }, + getShorthandAssignmentValueSymbol: function (node) { + node = ts.getParseTreeNode(node); + return node ? getShorthandAssignmentValueSymbol(node) : undefined; + }, + getExportSpecifierLocalTargetSymbol: function (node) { + node = ts.getParseTreeNode(node, ts.isExportSpecifier); + return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; + }, + getTypeAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getTypeOfNode(node) : unknownType; + }, + getPropertySymbolOfDestructuringAssignment: function (location) { + location = ts.getParseTreeNode(location, ts.isIdentifier); + return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; + }, + signatureToString: function (signature, enclosingDeclaration, flags, kind) { + return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind); + }, + typeToString: function (type, enclosingDeclaration, flags) { + return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags); + }, getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, + symbolToString: function (symbol, enclosingDeclaration, meaning) { + return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning); + }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: getContextualType, + getContextualType: function (node) { + node = ts.getParseTreeNode(node, ts.isExpression); + return node ? getContextualType(node) : undefined; + }, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, + getResolvedSignature: function (node, candidatesOutArray) { + node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + return node ? getResolvedSignature(node, candidatesOutArray) : undefined; + }, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, + isValidPropertyAccess: function (node, propertyName) { + node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedName); + return node ? isValidPropertyAccess(node, propertyName) : false; + }, + getSignatureFromDeclaration: function (declaration) { + declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + return declaration ? getSignatureFromDeclaration(declaration) : undefined; + }, + isImplementationOfOverload: function (node) { + node = ts.getParseTreeNode(node, ts.isFunctionLike); + return node ? isImplementationOfOverload(node) : undefined; + }, + getImmediateAliasedSymbol: function (symbol) { + ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.immediateTarget) { + var node = getDeclarationOfAliasSymbol(symbol); + ts.Debug.assert(!!node); + links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true); + } + return links.immediateTarget; + }, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, + getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { + node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; + }, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter, + isOptionalParameter: function (node) { + node = ts.getParseTreeNode(node, ts.isParameter); + return node ? isOptionalParameter(node) : false; + }, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations @@ -24879,16 +25658,14 @@ var ts; var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); + var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createMap(); /** * List of every ambient module with a "*" wildcard. * Unlike other ambient modules, these can't be stored in `globals` because symbol tables only deal with exact matches. * This is only used if there is no exact match. - */ + */ var patternAmbientModules; - var getGlobalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var tryGetGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -24897,29 +25674,29 @@ var ts; var globalNumberType; var globalBooleanType; var globalRegExpType; + var globalThisType; var anyArrayType; var autoArrayType; var anyReadonlyArrayType; // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files - var getGlobalTemplateStringsArrayType; - var getGlobalESSymbolType; - var getGlobalIterableType; - var getGlobalIteratorType; - var getGlobalIterableIteratorType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var jsxElementClassType; + var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolType; + var deferredGlobalTypedPropertyDescriptorType; + var deferredGlobalPromiseType; + var deferredGlobalPromiseConstructorSymbol; + var deferredGlobalPromiseConstructorLikeType; + var deferredGlobalIterableType; + var deferredGlobalIteratorType; + var deferredGlobalIterableIteratorType; + var deferredGlobalAsyncIterableType; + var deferredGlobalAsyncIteratorType; + var deferredGlobalAsyncIterableIteratorType; + var deferredGlobalTemplateStringsArrayType; + var deferredJsxElementClassType; + var deferredJsxElementType; + var deferredJsxStatelessElementType; var deferredNodes; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; @@ -25032,9 +25809,12 @@ var ts; "undefined": undefinedType }); var typeofType = createTypeofType(); - var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; + var _jsxElementPropertiesName; + var _hasComputedJsxElementPropertiesName = false; + var _jsxElementChildrenPropertyName; + var _hasComputedJsxElementChildrenPropertyName = false; /** Things we lazy load from the JSX namespace */ var jsxTypes = ts.createMap(); var JsxNames = { @@ -25042,6 +25822,7 @@ var ts; IntrinsicElements: "IntrinsicElements", ElementClass: "ElementClass", ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + ElementChildrenAttributeNameContainer: "ElementChildrenAttribute", Element: "Element", IntrinsicAttributes: "IntrinsicAttributes", IntrinsicClassAttributes: "IntrinsicClassAttributes" @@ -25060,12 +25841,18 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["SkipContextSensitive"] = 1] = "SkipContextSensitive"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createMap(); builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { - if (_jsxNamespace === undefined) { + if (!_jsxNamespace) { _jsxNamespace = "React"; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); @@ -25097,6 +25884,9 @@ var ts; symbol.checkFlags = 0; return symbol; } + function isTransientSymbol(symbol) { + return (symbol.flags & 134217728 /* Transient */) !== 0; + } function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) @@ -25164,7 +25954,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 232 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 232 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 233 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 233 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -25182,7 +25972,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ @@ -25277,7 +26067,7 @@ var ts; return symbol.flags & 134217728 /* Transient */ ? symbol.checkFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 264 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 265 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -25320,12 +26110,12 @@ var ts; if (declarationFile !== useFile) { if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out)) { - // nodes are in different files and order cannot be determines + // nodes are in different files and order cannot be determined return true; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrInstanceProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { return true; } var sourceFiles = host.getSourceFiles(); @@ -25333,34 +26123,41 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 175 /* BindingElement */) { + if (declaration.kind === 176 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 175 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 176 /* BindingElement */); if (errorBindingElement) { - return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 226 /* VariableDeclaration */), usage); } - else if (declaration.kind === 225 /* VariableDeclaration */) { + else if (declaration.kind === 226 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } // declaration is after usage, but it can still be legal if usage is deferred: - // 1. inside a function - // 2. inside an instance property initializer, a reference to a non-instance property + // 1. inside an export specifier + // 2. inside a function + // 3. inside an instance property initializer, a reference to a non-instance property + // 4. inside a static property initializer, a reference to a static method in the same class + // or if usage is in a type context: + // 1. inside a type query (typeof in type position) + if (usage.parent.kind === 246 /* ExportSpecifier */) { + // export specifiers do not use the variable, they only make it available for use + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); - var isInstanceProperty = declaration.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); - return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); + return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 207 /* VariableStatement */: - case 213 /* ForStatement */: - case 215 /* ForOfStatement */: + case 208 /* VariableStatement */: + case 214 /* ForStatement */: + case 216 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -25369,8 +26166,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -25378,34 +26175,31 @@ var ts; } return false; } - function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { - var current = usage; - while (current) { + function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { + return !!ts.findAncestor(usage, function (current) { if (current === container) { - return false; + return "quit"; } if (ts.isFunctionLike(current)) { return true; } - var initializerOfInstanceProperty = current.parent && - current.parent.kind === 148 /* PropertyDeclaration */ && - (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && + var initializerOfProperty = current.parent && + current.parent.kind === 149 /* PropertyDeclaration */ && current.parent.initializer === current; - if (initializerOfInstanceProperty) { - return !isDeclarationInstanceProperty; + if (initializerOfProperty) { + if (ts.getModifierFlags(current.parent) & 32 /* Static */) { + if (declaration.kind === 151 /* MethodDeclaration */) { + return true; + } + } + else { + var isDeclarationInstanceProperty = declaration.kind === 149 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { + return true; + } + } } - current = current.parent; - } - return false; - } - function getAncestorBindingPattern(node) { - while (node) { - if (ts.isBindingPattern(node)) { - return node; - } - node = node.parent; - } - return undefined; + }); } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and @@ -25430,11 +26224,11 @@ var ts; // - parameters are only in the scope of function body // 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 & 793064 /* Type */ && lastLocation.kind !== 282 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 283 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 145 /* Parameter */ || - lastLocation.kind === 144 /* TypeParameter */ + lastLocation.kind === 146 /* Parameter */ || + lastLocation.kind === 145 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -25443,9 +26237,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 === 145 /* Parameter */ || + lastLocation.kind === 146 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 145 /* Parameter */); + result.valueDeclaration.kind === 146 /* Parameter */); } } if (useResult) { @@ -25457,13 +26251,14 @@ var ts; } } switch (location.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 232 /* ModuleDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 264 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 265 /* 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.get("default")) { @@ -25487,7 +26282,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 245 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 246 /* ExportSpecifier */)) { break; } } @@ -25495,13 +26290,13 @@ var ts; break loop; } break; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* 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 @@ -25518,9 +26313,9 @@ var ts; } } break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -25536,7 +26331,7 @@ var ts; } break loop; } - if (location.kind === 198 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 199 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -25552,9 +26347,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 229 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 230 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -25562,19 +26357,19 @@ var ts; } } break; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -25587,7 +26382,7 @@ var ts; } } break; - case 146 /* Decorator */: + case 147 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -25596,7 +26391,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 === 145 /* Parameter */) { + if (location.parent && location.parent.kind === 146 /* Parameter */) { location = location.parent; } // @@ -25625,7 +26420,8 @@ var ts; !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); } } @@ -25651,16 +26447,17 @@ var ts; // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped - if (meaning & 2 /* BlockScopedVariable */) { + if (meaning & 2 /* BlockScopedVariable */ || + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 107455 /* Value */) === 107455 /* Value */)) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 235 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 236 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -25670,14 +26467,14 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 144 /* TypeParameter */ && decl.parent === container) { + if (decl.kind === 145 /* TypeParameter */ && decl.parent === container) { return true; } } return false; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 71 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, /*includeArrowFunctions*/ true); @@ -25722,10 +26519,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 70 /* Identifier */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -25752,13 +26549,38 @@ var ts; } return false; } + function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { + if (meaning & (107455 /* Value */ & ~1024 /* NamespaceModule */ & ~793064 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, name); + return true; + } + } + else if (meaning & (793064 /* Type */ & ~1024 /* NamespaceModule */ & ~107455 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~793064 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, name); + return true; + } + } + return false; + } function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); + ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // 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"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 232 /* EnumDeclaration */) ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + if (result.flags & 2 /* BlockScopedVariable */) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 32 /* Class */) { + error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 384 /* Enum */) { + error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } } } /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. @@ -25766,37 +26588,26 @@ var ts; * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. */ function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { - return true; - } - } - return false; + return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 237 /* ImportDeclaration */) { - node = node.parent; - } - return node; + return ts.findAncestor(node, function (n) { return n.kind === 238 /* ImportDeclaration */; }); } } function getDeclarationOfAliasSymbol(symbol) { return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { + function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { + if (node.moduleReference.kind === 248 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); } - function getTargetOfImportClause(node) { + function getTargetOfImportClause(node, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -25807,20 +26618,20 @@ var ts; var exportValue = moduleSymbol.exports.get("export="); exportDefaultSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") - : resolveSymbol(moduleSymbol.exports.get("default")); + : resolveSymbol(moduleSymbol.exports.get("default"), dontResolveAlias); } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } return exportDefaultSymbol; } } - function getTargetOfNamespaceImport(node) { + function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -25855,12 +26666,9 @@ var ts; result.exports = valueSymbol.exports; return result; } - function getExportOfModule(symbol, name) { + function getExportOfModule(symbol, name, dontResolveAlias) { if (symbol.flags & 1536 /* Module */) { - var exportedSymbol = getExportsOfSymbol(symbol).get(name); - if (exportedSymbol) { - return resolveSymbol(exportedSymbol); - } + return resolveSymbol(getExportsOfSymbol(symbol).get(name), dontResolveAlias); } } function getPropertyOfVariable(symbol, name) { @@ -25871,9 +26679,9 @@ var ts; } } } - function getExternalModuleMember(node, specifier) { + function getExternalModuleMember(node, specifier, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; if (name.text) { @@ -25889,11 +26697,11 @@ var ts; symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } // if symbolFromVariable is export - get its final target - symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name.text); + symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); + var symbolFromModule = getExportOfModule(targetSymbol, name.text, dontResolveAlias); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { - symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : @@ -25905,40 +26713,41 @@ var ts; } } } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); + function getTargetOfImportSpecifier(node, dontResolveAlias) { + return getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); } - function getTargetOfNamespaceExportDeclaration(node) { - return resolveExternalModuleSymbol(node.parent.symbol); + function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) { + return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); } - function getTargetOfExportSpecifier(node) { + function getTargetOfExportSpecifier(node, dontResolveAlias) { return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */); + getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : + resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */); + function getTargetOfExportAssignment(node, dontResolveAlias) { + return resolveEntityName(node.expression, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } - function getTargetOfAliasDeclaration(node) { + function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: - return getTargetOfImportEqualsDeclaration(node); - case 238 /* ImportClause */: - return getTargetOfImportClause(node); - case 239 /* NamespaceImport */: - return getTargetOfNamespaceImport(node); - case 241 /* ImportSpecifier */: - return getTargetOfImportSpecifier(node); - case 245 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node); - case 242 /* ExportAssignment */: - return getTargetOfExportAssignment(node); - case 235 /* NamespaceExportDeclaration */: - return getTargetOfNamespaceExportDeclaration(node); + case 237 /* ImportEqualsDeclaration */: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); + case 239 /* ImportClause */: + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 240 /* NamespaceImport */: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); + case 242 /* ImportSpecifier */: + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 246 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, dontRecursivelyResolve); + case 243 /* ExportAssignment */: + return getTargetOfExportAssignment(node, dontRecursivelyResolve); + case 236 /* NamespaceExportDeclaration */: + return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); } } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */)) ? resolveAlias(symbol) : symbol; + function resolveSymbol(symbol, dontResolveAlias) { + var shouldResolve = !dontResolveAlias && symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */)); + return shouldResolve ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); @@ -25980,11 +26789,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 242 /* ExportAssignment */) { + if (node.kind === 243 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 245 /* ExportSpecifier */) { + else if (node.kind === 246 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -26002,17 +26811,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 70 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 142 /* QualifiedName */) { + if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 143 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 236 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 237 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -26027,16 +26836,30 @@ var ts; return undefined; } var symbol; - if (name.kind === 70 /* Identifier */) { + if (name.kind === 71 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 142 /* QualifiedName */ || name.kind === 178 /* PropertyAccessExpression */) { - var left = name.kind === 142 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 142 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 143 /* QualifiedName */ || name.kind === 179 /* PropertyAccessExpression */) { + var left = void 0; + if (name.kind === 143 /* QualifiedName */) { + left = name.left; + } + else if (name.kind === 179 /* PropertyAccessExpression */ && + (name.expression.kind === 185 /* ParenthesizedExpression */ || ts.isEntityNameExpression(name.expression))) { + left = name.expression; + } + else { + // If the expression in property-access expression is not entity-name or parenthsizedExpression (e.g. it is a call expression), it won't be able to successfully resolve the name. + // This is the case when we are trying to do any language service operation in heritage clauses. By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression + // will attempt to checkPropertyAccessExpression to resolve symbol. + // i.e class C extends foo()./*do language service operation here*/B {} + return undefined; + } + var right = name.kind === 143 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -26052,6 +26875,15 @@ var ts; return undefined; } } + else if (name.kind === 185 /* ParenthesizedExpression */) { + // If the expression in parenthesizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name. + // This is the case when we are trying to do any language service operation in heritage clauses. + // By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression will attempt to checkPropertyAccessExpression to resolve symbol. + // i.e class C extends foo()./*do language service operation here*/B {} + return ts.isEntityNameExpression(name.expression) ? + resolveEntityName(name.expression, meaning, ignoreErrors, dontResolveAlias, location) : + undefined; + } else { ts.Debug.fail("Unknown entity name kind."); } @@ -26063,7 +26895,7 @@ var ts; } function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */ && moduleReferenceExpression.kind !== 13 /* NoSubstitutionTemplateLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -26108,8 +26940,10 @@ var ts; var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } - else if (compilerOptions.noImplicitAny && moduleNotFoundError) { - error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + else if (noImplicitAny && moduleNotFoundError) { + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } // Failed imports and untyped modules are both treated in an untyped manner; only difference is whether we give a diagnostic first. return undefined; @@ -26134,15 +26968,15 @@ 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 && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; + function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || 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 // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression, dontResolveAlias) { + var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); + if (!dontResolveAlias && symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } @@ -26265,7 +27099,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 === 151 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 152 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -26343,11 +27177,12 @@ var ts; } } switch (location.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232 /* ModuleDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -26399,7 +27234,7 @@ var ts; return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -26439,7 +27274,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, 245 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -26454,10 +27289,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 148 /* PropertyDeclaration */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 149 /* PropertyDeclaration */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: continue; default: return false; @@ -26530,15 +27365,12 @@ var ts; } return { accessibility: 0 /* Accessible */ }; function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } + var node = ts.findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 265 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -26579,12 +27411,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 161 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 162 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 142 /* QualifiedName */ || entityName.kind === 178 /* PropertyAccessExpression */ || - entityName.parent.kind === 236 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 143 /* QualifiedName */ || entityName.kind === 179 /* PropertyAccessExpression */ || + entityName.parent.kind === 237 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -26636,6 +27468,516 @@ var ts; } return result; } + function createNodeBuilder() { + var context; + return { + typeToTypeNode: function (type, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = typeToTypeNodeHelper(type); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + } + }; + function createNodeBuilderContext(enclosingDeclaration, flags) { + return { + enclosingDeclaration: enclosingDeclaration, + flags: flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + function typeToTypeNodeHelper(type) { + if (!type) { + context.encounteredError = true; + // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? + return undefined; + } + if (type.flags & 1 /* Any */) { + return ts.createKeywordTypeNode(119 /* AnyKeyword */); + } + if (type.flags & 2 /* String */) { + return ts.createKeywordTypeNode(136 /* StringKeyword */); + } + if (type.flags & 4 /* Number */) { + return ts.createKeywordTypeNode(133 /* NumberKeyword */); + } + if (type.flags & 8 /* Boolean */) { + return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + } + if (type.flags & 16 /* Enum */) { + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & (32 /* StringLiteral */)) { + return ts.createLiteralTypeNode((ts.createLiteral(type.text))); + } + if (type.flags & (64 /* NumberLiteral */)) { + return ts.createLiteralTypeNode((ts.createNumericLiteral(type.text))); + } + if (type.flags & 128 /* BooleanLiteral */) { + return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); + } + if (type.flags & 256 /* EnumLiteral */) { + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & 1024 /* Void */) { + return ts.createKeywordTypeNode(105 /* VoidKeyword */); + } + if (type.flags & 2048 /* Undefined */) { + return ts.createKeywordTypeNode(139 /* UndefinedKeyword */); + } + if (type.flags & 4096 /* Null */) { + return ts.createKeywordTypeNode(95 /* NullKeyword */); + } + if (type.flags & 8192 /* Never */) { + return ts.createKeywordTypeNode(130 /* NeverKeyword */); + } + if (type.flags & 512 /* ESSymbol */) { + return ts.createKeywordTypeNode(137 /* SymbolKeyword */); + } + if (type.flags & 16777216 /* NonPrimitive */) { + return ts.createKeywordTypeNode(134 /* ObjectKeyword */); + } + if (type.flags & 16384 /* TypeParameter */ && type.isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return ts.createThis(); + } + var objectFlags = getObjectFlags(type); + if (objectFlags & 4 /* Reference */) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & 3 /* ClassOrInterface */) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // TODO(aozgaa): handle type arguments. + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & 16384 /* TypeParameter */) { + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (context.checkAlias && type.aliasSymbol) { + var name = symbolToName(type.aliasSymbol, /*expectsIdentifier*/ false); + var typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return ts.createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + if (type.flags & 65536 /* Union */) { + var formattedUnionTypes = formatUnionTypes(type.types); + var unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return ts.createUnionOrIntersectionTypeNode(166 /* UnionType */, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } + return undefined; + } + } + if (type.flags & 131072 /* Intersection */) { + return ts.createUnionOrIntersectionTypeNode(167 /* IntersectionType */, mapToTypeNodeArray(type.types)); + } + if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + // The type is an object literal type. + return createAnonymousTypeNode(type); + } + if (type.flags & 262144 /* Index */) { + var indexedType = type.type; + var indexTypeNode = typeToTypeNodeHelper(indexedType); + return ts.createTypeOperatorNode(indexTypeNode); + } + if (type.flags & 524288 /* IndexedAccess */) { + var objectTypeNode = typeToTypeNodeHelper(type.objectType); + var indexTypeNode = typeToTypeNodeHelper(type.indexType); + return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + ts.Debug.fail("Should be unreachable."); + function mapToTypeNodeArray(types) { + var result = []; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type_1 = types_1[_i]; + var typeNode = typeToTypeNodeHelper(type_1); + if (typeNode) { + result.push(typeNode); + } + } + return result; + } + function createMappedTypeNodeFromType(type) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + var typeParameter = getTypeParameterFromMappedType(type); + var typeParameterNode = typeParameterToDeclaration(typeParameter); + var templateType = getTemplateTypeFromMappedType(type); + var templateTypeNode = typeToTypeNodeHelper(templateType); + var readonlyToken = type.declaration && type.declaration.readonlyToken ? ts.createToken(131 /* ReadonlyKeyword */) : undefined; + var questionToken = type.declaration && type.declaration.questionToken ? ts.createToken(55 /* QuestionToken */) : undefined; + return ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + function createAnonymousTypeNode(type) { + var symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromSymbol(symbol); + } + else if (ts.contains(context.symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + var entityName = symbolToName(typeAlias, /*expectsIdentifier*/ false); + return ts.createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + } + else { + return ts.createKeywordTypeNode(119 /* AnyKeyword */); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.symbolStack) { + context.symbolStack = []; + } + context.symbolStack.push(symbol); + var result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + // Anonymous types without a symbol are never circular. + return createTypeNodeFromObjectType(type); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && + ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32 /* Static */; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return ts.contains(context.symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + function createTypeNodeFromObjectType(type) { + if (type.objectFlags & 32 /* Mapped */) { + if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { + return createMappedTypeNodeFromType(type); + } + } + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return ts.createTypeLiteralNode(/*members*/ undefined); + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + var signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 160 /* FunctionType */); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + var signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 161 /* ConstructorType */); + } + } + var saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + var members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return ts.createTypeLiteralNode(members); + } + function createTypeQueryNodeFromSymbol(symbol) { + var entityName = symbolToName(symbol, /*expectsIdentifier*/ false); + return ts.createTypeQueryNode(entityName); + } + function typeReferenceToTypeNode(type) { + var typeArguments = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + var elementType = typeToTypeNodeHelper(typeArguments[0]); + return ts.createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & 8 /* Tuple */) { + if (typeArguments.length > 0) { + var tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return ts.createTupleTypeNode(tupleConstituentNodes); + } + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; + } + return undefined; + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + var qualifiedName = undefined; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + // Find group of type arguments for type parameters with the same declaring container. + var start = i; + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // 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)) { + var qualifiedNamePart = symbolToName(parent, /*expectsIdentifier*/ true); + if (!qualifiedName) { + qualifiedName = ts.createQualifiedName(qualifiedNamePart, /*right*/ undefined); + } + else { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = ts.createQualifiedName(qualifiedName, /*right*/ undefined); + } + } + } + } + var entityName = undefined; + var nameIdentifier = symbolToName(type.symbol, /*expectsIdentifier*/ true); + if (qualifiedName) { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + var typeArgumentNodes = ts.some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return ts.createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + function createTypeNodesFromResolvedType(resolvedType) { + var typeElements = []; + for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 155 /* CallSignature */)); + } + for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 156 /* ConstructSignature */)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0 /* String */)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1 /* Number */)); + } + var properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + for (var _d = 0, properties_2 = properties; _d < properties_2.length; _d++) { + var propertySymbol = properties_2[_d]; + var propertyType = getTypeOfSymbol(propertySymbol); + var oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0]; + if (!oldDeclaration) { + return; + } + var propertyName = oldDeclaration.name; + var optionalToken = propertySymbol.flags & 67108864 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { + var signatures = getSignaturesOfType(propertyType, 0 /* Call */); + for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { + var signature = signatures_1[_e]; + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 150 /* MethodSignature */); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + // TODO(aozgaa): should we create a node with explicit or implict any? + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + typeElements.push(ts.createPropertySignature(propertyName, optionalToken, propertyTypeNode, + /*initializer*/ undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind) { + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 136 /* StringKeyword */ : 133 /* NumberKeyword */); + var name = ts.getNameFromIndexInfo(indexInfo); + var indexingParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, name, + /*questionToken*/ undefined, indexerTypeNode, + /*initializer*/ undefined); + var typeNode = typeToTypeNodeHelper(indexInfo.type); + return ts.createIndexSignatureDeclaration( + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(131 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + } + function signatureToSignatureDeclarationHelper(signature, kind) { + var typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter); }); + var returnTypeNode; + if (signature.typePredicate) { + var typePredicate = signature.typePredicate; + var parameterName = typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(); + var typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + } + else { + var returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } + var returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== 119 /* AnyKeyword */ ? returnTypeNode : undefined; + return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + } + function typeParameterToDeclaration(type) { + var constraint = getConstraintFromTypeParameter(type); + var constraintNode = constraint && typeToTypeNodeHelper(constraint); + var defaultParameter = getDefaultFromTypeParameter(type); + var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + var name = symbolToName(type.symbol, /*expectsIdentifier*/ true); + return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); + } + function symbolToParameterDeclaration(parameterSymbol) { + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 146 /* Parameter */); + var parameterType = getTypeOfSymbol(parameterSymbol); + var parameterTypeNode = typeToTypeNodeHelper(parameterType); + // TODO(aozgaa): In the future, check initializer accessibility. + var parameterNode = ts.createParameter(parameterDeclaration.decorators, parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && ts.createToken(24 /* DotDotDotToken */), + // Clone name to remove trivia. + ts.getSynthesizedClone(parameterDeclaration.name), parameterDeclaration.questionToken && ts.createToken(55 /* QuestionToken */), parameterTypeNode, parameterDeclaration.initializer); + return parameterNode; + } + function symbolToName(symbol, expectsIdentifier) { + // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. + var chain; + var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; + if (!isTypeParameter && context.enclosingDeclaration) { + chain = getSymbolChain(symbol, 0 /* None */, /*endOfChain*/ true); + ts.Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & ts.NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); + function createEntityNameFromSymbolChain(chain, index) { + ts.Debug.assert(chain && 0 <= index && index < chain.length); + // const parentIndex = index - 1; + var symbol = chain[index]; + var typeParameterString = ""; + if (index > 0) { + var parentSymbol = chain[index - 1]; + var typeParameters = void 0; + if (getCheckFlags(symbol) & 1 /* Instantiated */) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + var targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if (typeParameters && typeParameters.length > 0) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } + var writer = ts.getSingleLineStringWriter(); + var displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); + typeParameterString = writer.string(); + ts.releaseStringWriter(writer); + } + } + var symbolName = getNameOfSymbol(symbol); + var symbolNameWithTypeParameters = typeParameterString.length > 0 ? symbolName + "<" + typeParameterString + ">" : symbolName; + var identifier = ts.createIdentifier(symbolNameWithTypeParameters); + return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ + function getSymbolChain(symbol, meaning, endOfChain) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false); + var parentSymbol; + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + // Go up and add our parent. + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + parentSymbol = parent; + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + return [symbol]; + } + } + function getNameOfSymbol(symbol) { + var declaration = ts.firstOrUndefined(symbol.declarations); + if (declaration) { + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { + return ts.declarationNameToString(declaration.parent.name); + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case 199 /* ClassExpression */: + return "(Anonymous class)"; + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return "(Anonymous function)"; + } + } + return symbol.name; + } + } + } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -26679,11 +28021,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 167 /* ParenthesizedType */) { - node = node.parent; - } - if (node.kind === 230 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 168 /* ParenthesizedType */; }); + if (node.kind === 231 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -26691,7 +28030,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 233 /* ModuleBlock */ && + node.parent.kind === 234 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -26703,11 +28042,14 @@ var ts; if (declaration.name) { return ts.declarationNameToString(declaration.name); } + if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { + return ts.declarationNameToString(declaration.parent.name); + } switch (declaration.kind) { - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return "(Anonymous class)"; - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -26731,17 +28073,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else { - writePunctuation(writer, 22 /* DotToken */); + writePunctuation(writer, 23 /* DotToken */); writer.writeSymbol(symbolName, symbol); } } @@ -26840,7 +28182,7 @@ var ts; } else if (type.flags & 256 /* EnumLiteral */) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); - writePunctuation(writer, 22 /* DotToken */); + writePunctuation(writer, 23 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } else if (getObjectFlags(type) & 3 /* ClassOrInterface */ || type.flags & (16 /* Enum */ | 16384 /* TypeParameter */)) { @@ -26868,30 +28210,30 @@ var ts; } else if (type.flags & 524288 /* IndexedAccess */) { writeType(type.objectType, 64 /* InElementType */); - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); writeType(type.indexType, 0 /* None */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else { // Should never get here // { ... } - writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 23 /* DotDotDotToken */); + writePunctuation(writer, 24 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 25 /* CommaToken */) { + if (delimiter !== 26 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 25 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 26 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -26900,29 +28242,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } if (pos < end) { - writePunctuation(writer, 26 /* LessThanToken */); + writePunctuation(writer, 27 /* LessThanToken */); writeType(typeArguments[pos], 256 /* InFirstTypeArgument */); pos++; while (pos < end) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos], 0 /* None */); pos++; } - writePunctuation(writer, 28 /* GreaterThanToken */); + writePunctuation(writer, 29 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 20 /* OpenBracketToken */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else if (type.target.objectFlags & 8 /* Tuple */) { - writePunctuation(writer, 20 /* OpenBracketToken */); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 26 /* CommaToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else { // Write the type reference in the format f.g.C where A and B are type arguments @@ -26931,19 +28273,19 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // 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, typeArguments, start, i, flags); - writePunctuation(writer, 22 /* DotToken */); + writePunctuation(writer, 23 /* DotToken */); } } } @@ -26953,16 +28295,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); } if (type.flags & 65536 /* Union */) { - writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); + writeTypeList(formatUnionTypes(type.types), 49 /* BarToken */); } else { - writeTypeList(type.types, 47 /* AmpersandToken */); + writeTypeList(type.types, 48 /* AmpersandToken */); } if (flags & 64 /* InElementType */) { - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -26985,7 +28327,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 118 /* AnyKeyword */); + writeKeyword(writer, 119 /* AnyKeyword */); } } else { @@ -27009,7 +28351,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 264 /* SourceFile */ || declaration.parent.kind === 233 /* ModuleBlock */; + return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -27019,18 +28361,18 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 102 /* TypeOfKeyword */); + writeKeyword(writer, 103 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeKeyword(writer, 131 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 67108864 /* Optional */) { - writePunctuation(writer, 54 /* QuestionToken */); + writePunctuation(writer, 55 /* QuestionToken */); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -27055,55 +28397,55 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 16 /* OpenBraceToken */); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); } - writeKeyword(writer, 93 /* NewKeyword */); + writeKeyword(writer, 94 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); writeObjectLiteralType(resolved); writer.decreaseIndent(); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); inObjectTypeLiteral = saveInObjectTypeLiteral; } function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1 /* Construct */, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); @@ -27113,49 +28455,49 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { - var signature = signatures_1[_f]; + for (var _f = 0, signatures_2 = signatures; _f < signatures_2.length; _f++) { + var signature = signatures_2[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } } } function writeMappedType(type) { - writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); if (type.declaration.readonlyToken) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeKeyword(writer, 131 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); writeSpace(writer); - writeKeyword(writer, 91 /* InKeyword */); + writeKeyword(writer, 92 /* InKeyword */); writeSpace(writer); writeType(getConstraintTypeFromMappedType(type), 0 /* None */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); if (type.declaration.questionToken) { - writePunctuation(writer, 54 /* QuestionToken */); + writePunctuation(writer, 55 /* QuestionToken */); } - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); writeType(getTemplateTypeFromMappedType(type), 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); writer.decreaseIndent(); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -27169,65 +28511,65 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 84 /* ExtendsKeyword */); + writeKeyword(writer, 85 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } var defaultType = getDefaultFromTypeParameter(tp); if (defaultType) { writeSpace(writer); - writePunctuation(writer, 57 /* EqualsToken */); + writePunctuation(writer, 58 /* EqualsToken */); writeSpace(writer); buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 23 /* DotDotDotToken */); + if (parameterNode ? ts.isRestParameter(parameterNode) : isTransientSymbol(p) && p.isRestParameter) { + writePunctuation(writer, 24 /* DotDotDotToken */); } - if (ts.isBindingPattern(parameterNode.name)) { + if (parameterNode && ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); } else { appendSymbolNameOnly(p, writer); } - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 54 /* QuestionToken */); + if (parameterNode && isOptionalParameter(parameterNode)) { + writePunctuation(writer, 55 /* QuestionToken */); } - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); var type = getTypeOfSymbol(p); - if (isRequiredInitializedParameter(parameterNode)) { + if (parameterNode && isRequiredInitializedParameter(parameterNode)) { type = includeFalsyTypes(type, 2048 /* Undefined */); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { - writePunctuation(writer, 16 /* OpenBraceToken */); + if (bindingPattern.kind === 174 /* ObjectBindingPattern */) { + writePunctuation(writer, 17 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); } - else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { - writePunctuation(writer, 20 /* OpenBracketToken */); + else if (bindingPattern.kind === 175 /* ArrayBindingPattern */) { + writePunctuation(writer, 21 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); } - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 175 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 176 /* BindingElement */); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -27235,22 +28577,22 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 23 /* DotDotDotToken */); + writePunctuation(writer, 24 /* DotDotDotToken */); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26 /* LessThanToken */); + writePunctuation(writer, 27 /* LessThanToken */); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 28 /* GreaterThanToken */); + writePunctuation(writer, 29 /* GreaterThanToken */); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); } action(list[i]); @@ -27258,42 +28600,42 @@ var ts; } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26 /* LessThanToken */); + writePunctuation(writer, 27 /* LessThanToken */); var flags = 256 /* InFirstTypeArgument */; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); flags = 0 /* None */; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 28 /* GreaterThanToken */); + writePunctuation(writer, 29 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 98 /* ThisKeyword */); + writeKeyword(writer, 99 /* ThisKeyword */); } writeSpace(writer); - writeKeyword(writer, 125 /* IsKeyword */); + writeKeyword(writer, 126 /* IsKeyword */); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } @@ -27304,10 +28646,10 @@ var ts; } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 35 /* EqualsGreaterThanToken */); + writePunctuation(writer, 36 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); } writeSpace(writer); if (signature.typePredicate) { @@ -27319,7 +28661,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { - writeKeyword(writer, 93 /* NewKeyword */); + writeKeyword(writer, 94 /* NewKeyword */); writeSpace(writer); } if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -27336,26 +28678,26 @@ var ts; function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeKeyword(writer, 131 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); switch (kind) { case 1 /* Number */: - writeKeyword(writer, 132 /* NumberKeyword */); + writeKeyword(writer, 133 /* NumberKeyword */); break; case 0 /* String */: - writeKeyword(writer, 135 /* StringKeyword */); + writeKeyword(writer, 136 /* StringKeyword */); break; } - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } } @@ -27384,22 +28726,22 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 175 /* BindingElement */: + case 176 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 225 /* VariableDeclaration */: + case 226 /* 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 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 227 /* FunctionDeclaration */: - case 231 /* EnumDeclaration */: - case 236 /* ImportEqualsDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 228 /* FunctionDeclaration */: + case 232 /* EnumDeclaration */: + case 237 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -27407,52 +28749,53 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 236 /* ImportEqualsDeclaration */ && parent.kind !== 264 /* SourceFile */ && ts.isInAmbientContext(parent))) { + !(node.kind !== 237 /* ImportEqualsDeclaration */ && parent.kind !== 265 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.getModifierFlags(node) & (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 151 /* Constructor */: - case 155 /* ConstructSignature */: - case 154 /* CallSignature */: - case 156 /* IndexSignature */: - case 145 /* Parameter */: - case 233 /* ModuleBlock */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 162 /* TypeLiteral */: - case 158 /* TypeReference */: - case 163 /* ArrayType */: - case 164 /* TupleType */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: - case 167 /* ParenthesizedType */: + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 152 /* Constructor */: + case 156 /* ConstructSignature */: + case 155 /* CallSignature */: + case 157 /* IndexSignature */: + case 146 /* Parameter */: + case 234 /* ModuleBlock */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 163 /* TypeLiteral */: + case 159 /* TypeReference */: + case 164 /* ArrayType */: + case 165 /* TupleType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: + case 168 /* 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 238 /* ImportClause */: - case 239 /* NamespaceImport */: - case 241 /* ImportSpecifier */: + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + case 242 /* ImportSpecifier */: return false; // Type parameters are always visible - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: // Source file and namespace export are always visible - case 264 /* SourceFile */: - case 235 /* NamespaceExportDeclaration */: + case 265 /* SourceFile */: + case 236 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return false; default: return false; @@ -27461,10 +28804,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 242 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 243 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 245 /* ExportSpecifier */) { + else if (node.parent.kind === 246 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -27509,8 +28852,8 @@ var ts; var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -27554,21 +28897,20 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - while (node) { + node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 225 /* VariableDeclaration */: - case 226 /* VariableDeclarationList */: - case 241 /* ImportSpecifier */: - case 240 /* NamedImports */: - case 239 /* NamespaceImport */: - case 238 /* ImportClause */: - node = node.parent; - break; + case 226 /* VariableDeclaration */: + case 227 /* VariableDeclarationList */: + case 242 /* ImportSpecifier */: + case 241 /* NamedImports */: + case 240 /* NamespaceImport */: + case 239 /* ImportClause */: + return false; default: - return node.parent; + return true; } - } + }); + return node && node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -27593,7 +28935,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 143 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 144 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); @@ -27605,8 +28947,8 @@ var ts; } var members = ts.createMap(); var names = ts.createMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var name = properties_3[_i]; names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { @@ -27640,7 +28982,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 173 /* ObjectBindingPattern */) { + if (pattern.kind === 174 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -27681,7 +29023,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); if (declaration.dotDotDotToken) { // Rest element has an array type with the same element type as the parent type type = createArrayType(elementType); @@ -27721,24 +29063,15 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 94 /* NullKeyword */ || expr.kind === 70 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 176 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 177 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } - /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ - function removeOptionalityFromAnnotation(annotatedType, declaration) { - var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 145 /* Parameter */ && - declaration.initializer && - getFalsyFlags(annotatedType) & 2048 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536 /* JavaScriptFile */) { @@ -27752,27 +29085,28 @@ var ts; } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 214 /* ForInStatement */) { + if (declaration.parent.parent.kind === 215 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 215 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 216 /* 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, // or it may have led to an error inside getElementTypeOfIterable. - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + var forOfStatement = declaration.parent.parent; + return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } // Use type from type annotation if one is present if (declaration.type) { - var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + var declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 225 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + if ((noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && + declaration.kind === 226 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27786,11 +29120,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 145 /* Parameter */) { + if (declaration.kind === 146 /* 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 === 153 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152 /* GetAccessor */); + if (func.kind === 154 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 153 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -27825,7 +29159,7 @@ var ts; return trueType; } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 261 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 262 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27835,22 +29169,37 @@ var ts; // No type specified and nothing can be inferred return undefined; } - // Return the inferred type for a variable, parameter, or property declaration - function getTypeForJSSpecialPropertyDeclaration(declaration) { - var expression = declaration.kind === 193 /* BinaryExpression */ ? declaration : - declaration.kind === 178 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 193 /* BinaryExpression */) : - undefined; - if (!expression) { - return unknownType; - } - if (expression.flags & 65536 /* JavaScriptFile */) { - // If there is a JSDoc type, use it - var type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol) { + var types = []; + var definedInConstructor = false; + var definedInMethod = false; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = declaration.kind === 194 /* BinaryExpression */ ? declaration : + declaration.kind === 179 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 194 /* BinaryExpression */) : + undefined; + if (!expression) { + return unknownType; } + if (ts.isPropertyAccessExpression(expression.left) && expression.left.expression.kind === 99 /* ThisKeyword */) { + if (ts.getThisContainer(expression, /*includeArrowFunctions*/ false).kind === 152 /* Constructor */) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (expression.flags & 65536 /* JavaScriptFile */) { + // If there is a JSDoc type, use it + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, /*subtypeReduction*/ true), definedInMethod && !definedInConstructor)); } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding @@ -27862,7 +29211,7 @@ var ts; if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -27923,7 +29272,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, reportErrors) { - return pattern.kind === 173 /* ObjectBindingPattern */ + return pattern.kind === 174 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27945,7 +29294,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 === 260 /* PropertyAssignment */) { + if (declaration.kind === 261 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27953,7 +29302,7 @@ var ts; // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration - if (reportErrors && compilerOptions.noImplicitAny) { + if (reportErrors && noImplicitAny) { if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } @@ -27962,7 +29311,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 145 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 146 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -27978,10 +29327,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 242 /* ExportAssignment */) { + if (declaration.kind === 243 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 290 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 291 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27994,9 +29343,9 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 193 /* BinaryExpression */ || - declaration.kind === 178 /* PropertyAccessExpression */ && declaration.parent.kind === 193 /* BinaryExpression */) { - type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); + if (declaration.kind === 194 /* BinaryExpression */ || + declaration.kind === 179 /* PropertyAccessExpression */ && declaration.parent.kind === 194 /* BinaryExpression */) { + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -28010,7 +29359,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 152 /* GetAccessor */) { + if (accessor.kind === 153 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -28030,8 +29379,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 153 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 153 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 154 /* SetAccessor */); if (getter && getter.flags & 65536 /* JavaScriptFile */) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -28059,7 +29408,7 @@ var ts; type = getReturnTypeFromBody(getter); } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { if (setter) { error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } @@ -28074,8 +29423,8 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); + if (noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 153 /* 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)); } } @@ -28131,14 +29480,22 @@ var ts; function getTypeOfInstantiatedSymbol(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + if (symbolInstantiationDepth === 100) { + error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); + links.type = unknownType; } - var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - if (!popTypeResolution()) { - type = reportCircularityError(symbol); + else { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return unknownType; + } + symbolInstantiationDepth++; + var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + symbolInstantiationDepth--; + if (!popTypeResolution()) { + type = reportCircularityError(symbol); + } + links.type = type; } - links.type = type; } return links.type; } @@ -28149,7 +29506,7 @@ var ts; return unknownType; } // Otherwise variable has initializer that circularly references the variable itself - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -28175,6 +29532,12 @@ var ts; } return unknownType; } + function isReferenceToType(type, target) { + return type !== undefined + && target !== undefined + && (getObjectFlags(type) & 4 /* Reference */) !== 0 + && type.target === target; + } function getTargetType(type) { return getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } @@ -28215,9 +29578,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */ || - node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */ || - node.kind === 150 /* MethodDeclaration */ || node.kind === 186 /* ArrowFunction */) { + if (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */ || + node.kind === 228 /* FunctionDeclaration */ || node.kind === 186 /* FunctionExpression */ || + node.kind === 151 /* MethodDeclaration */ || node.kind === 187 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -28227,8 +29590,8 @@ 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, 229 /* InterfaceDeclaration */); - return appendOuterTypeParameters(undefined, declaration); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230 /* InterfaceDeclaration */); + return appendOuterTypeParameters(/*typeParameters*/ undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. @@ -28236,8 +29599,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 228 /* ClassDeclaration */ || - node.kind === 198 /* ClassExpression */ || node.kind === 230 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* InterfaceDeclaration */ || node.kind === 229 /* ClassDeclaration */ || + node.kind === 199 /* ClassExpression */ || node.kind === 231 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -28267,19 +29630,20 @@ var ts; } if (type.flags & 540672 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return isValidBaseType(constraint) && isMixinConstructorType(constraint); + return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { + function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); + var isJavaScript = ts.isInJavaScriptFile(location); + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); @@ -28290,7 +29654,8 @@ var ts; * The base constructor of a class can resolve to * * undefinedType if the class has no extends clause, * * unknownType if an error occurred during resolution of the extends expression, - * * nullType if the extends expression is the null value, or + * * nullType if the extends expression is the null value, + * * anyType if the extends expression has type any, or * * an object type with at least one construct signature. */ function getBaseConstructorTypeOfClass(type) { @@ -28312,7 +29677,7 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = unknownType; } - if (baseConstructorType !== unknownType && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); return type.resolvedBaseConstructorType = unknownType; } @@ -28342,7 +29707,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */))) { + if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 1 /* Any */))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -28355,11 +29720,14 @@ var ts; // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } + else if (baseConstructorType.flags & 1 /* Any */) { + baseType = baseConstructorType; + } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere // we check that all instantiated signatures return the same type. - var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -28403,17 +29771,17 @@ var ts; } return true; } - // A valid base type is any non-generic object type or intersection of non-generic + // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */) && !isGenericMappedType(type) || + return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || type.flags & 131072 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 230 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -28445,7 +29813,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* InterfaceDeclaration */) { + if (declaration.kind === 230 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -28502,7 +29870,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 289 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 290 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -28513,7 +29881,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 230 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 231 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -28540,14 +29908,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 192 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 70 /* Identifier */ && !!symbol.exports.get(expr.text); + expr.kind === 71 /* Identifier */ && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231 /* EnumDeclaration */) { + if (declaration.kind === 232 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -28575,7 +29943,7 @@ var ts; var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231 /* EnumDeclaration */) { + if (declaration.kind === 232 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28662,21 +30030,21 @@ var ts; // considered independent. function isIndependentType(node) { switch (node.kind) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 133 /* ObjectKeyword */: - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 129 /* NeverKeyword */: - case 172 /* LiteralType */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 134 /* ObjectKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 130 /* NeverKeyword */: + case 173 /* LiteralType */: return true; - case 163 /* ArrayType */: + case 164 /* ArrayType */: return isIndependentType(node.elementType); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -28689,7 +30057,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 !== 151 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 152 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -28710,12 +30078,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -28807,7 +30175,11 @@ var ts; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); + if (!stringIndexInfo) { + stringIndexInfo = instantiatedBaseType === anyType ? + createIndexInfo(anyType, /*isReadonly*/ false) : + getIndexInfoOfType(instantiatedBaseType, 0 /* String */); + } numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); } } @@ -28846,6 +30218,7 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); + var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = ts.length(typeArguments); var result = []; @@ -28853,8 +30226,8 @@ var ts; var baseSig = baseSignatures_1[_i]; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -28933,8 +30306,8 @@ var ts; 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]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type = types_2[_i]; var indexInfo = getIndexInfoOfType(type, kind); if (!indexInfo) { return undefined; @@ -29035,7 +30408,8 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var constructSignatures = emptyArray; - if (symbol.flags & 1952 /* HasExports */) { + var stringIndexInfo = undefined; + if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { @@ -29049,9 +30423,12 @@ var ts; members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } + else if (baseConstructorType === anyType) { + stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, stringIndexInfo, 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 @@ -29075,7 +30452,7 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 169 /* TypeOperator */) { + if (type.declaration.typeParameter.constraint.kind === 170 /* TypeOperator */) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var propertySymbol = _a[_i]; @@ -29108,10 +30485,10 @@ var ts; var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864 /* Optional */); var prop = createSymbol(4 /* Property */ | (isOptional ? 67108864 /* Optional */ : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 /* Readonly */ : 0; + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 8 /* Readonly */ : 0; prop.type = propType; if (propertySymbol) { - prop.mappedTypeOrigin = propertySymbol; + prop.syntheticOrigin = propertySymbol; } members.set(propName, prop); } @@ -29137,7 +30514,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 169 /* TypeOperator */) { + if (constraintDeclaration.kind === 170 /* TypeOperator */) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -29195,7 +30572,8 @@ var ts; return emptyArray; } /** If the given type is an object type and that type has a property by the given name, - * return the symbol for that property. Otherwise return undefined. */ + * return the symbol for that property. Otherwise return undefined. + */ function getPropertyOfObjectType(type, name) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); @@ -29236,14 +30614,29 @@ var ts; getPropertiesOfObjectType(type); } function getConstraintOfType(type) { - return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 524288 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } + function getConstraintOfIndexedAccess(type) { + var baseObjectType = getBaseConstraintOfType(type.objectType); + var baseIndexType = getBaseConstraintOfType(type.indexType); + return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; + } function getBaseConstraintOfType(type) { - var constraint = getResolvedBaseConstraint(type); - return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + if (type.flags & (540672 /* TypeVariable */ | 196608 /* UnionOrIntersection */)) { + var constraint = getResolvedBaseConstraint(type); + if (constraint !== noConstraintType && constraint !== circularConstraintType) { + return constraint; + } + } + else if (type.flags & 262144 /* Index */) { + return stringType; + } + return undefined; } function hasNonCircularBaseConstraint(type) { return getResolvedBaseConstraint(type) !== circularConstraintType; @@ -29281,9 +30674,9 @@ var ts; if (t.flags & 196608 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_1 = types_2[_i]; - var baseType = getBaseConstraint(type_1); + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; + var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); } @@ -29340,7 +30733,7 @@ var ts; t.flags & 262178 /* StringLike */ ? globalStringType : t.flags & 340 /* NumberLike */ ? globalNumberType : t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : t; } @@ -29351,9 +30744,10 @@ var ts; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 67108864 /* Optional */; - var checkFlags = 2 /* SyntheticProperty */; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + var syntheticFlag = 4 /* SyntheticMethod */; + var checkFlags = 0; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); @@ -29366,21 +30760,24 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - checkFlags |= (isReadonlySymbol(prop) ? 4 /* Readonly */ : 0) | - (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 32 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 64 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 128 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 256 /* ContainsStatic */ : 0); + checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | + (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 64 /* ContainsPublic */ : 0) | + (modifiers & 16 /* Protected */ ? 128 /* ContainsProtected */ : 0) | + (modifiers & 8 /* Private */ ? 256 /* ContainsPrivate */ : 0) | + (modifiers & 32 /* Static */ ? 512 /* ContainsStatic */ : 0); + if (!isMethodLike(prop)) { + syntheticFlag = 2 /* SyntheticProperty */; + } } else if (isUnion) { - checkFlags |= 8 /* Partial */; + checkFlags |= 16 /* Partial */; } } } if (!props) { return undefined; } - if (props.length === 1 && !(checkFlags & 8 /* Partial */)) { + if (props.length === 1 && !(checkFlags & 16 /* Partial */)) { return props[0]; } var propTypes = []; @@ -29396,12 +30793,12 @@ var ts; commonType = type; } else if (type !== commonType) { - checkFlags |= 16 /* HasNonUniformType */; + checkFlags |= 32 /* HasNonUniformType */; } propTypes.push(type); } var result = createSymbol(4 /* Property */ | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -29426,7 +30823,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(getCheckFlags(property) & 8 /* Partial */) ? property : undefined; + return property && !(getCheckFlags(property) & 16 /* Partial */) ? property : undefined; } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when @@ -29538,7 +30935,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 277 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 278 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -29549,7 +30946,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 277 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 278 /* JSDocOptionalType */; } } } @@ -29583,7 +30980,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 70 /* Identifier */) { + if (node.parameterName.kind === 71 /* Identifier */) { var parameterName = node.parameterName; return { kind: 1 /* Identifier */, @@ -29622,11 +31019,12 @@ var ts; * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + var isJavaScript = ts.isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } @@ -29634,12 +31032,12 @@ var ts; // If a type parameter does not have a default type, or if the default type // is a forward reference, the empty object type is used. for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (var i = numTypeArguments; i < numTypeParameters; i++) { var mapper = createTypeMapper(typeParameters, typeArguments); var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -29674,7 +31072,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 172 /* LiteralType */) { + if (param.type && param.type.kind === 173 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -29687,23 +31085,23 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 152 /* GetAccessor */ || declaration.kind === 153 /* SetAccessor */) && + if ((declaration.kind === 153 /* GetAccessor */ || declaration.kind === 154 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; + var otherKind = declaration.kind === 153 /* GetAccessor */ ? 154 /* SetAccessor */ : 153 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 151 /* Constructor */ ? + var classType = declaration.kind === 152 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 157 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 158 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -29728,14 +31126,42 @@ var ts; } // 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 === 152 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 153 /* SetAccessor */); + if (declaration.kind === 153 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 154 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { return anyType; } } + function containsArgumentsReference(declaration) { + var links = getNodeLinks(declaration); + if (links.containsArgumentsReference === undefined) { + if (links.flags & 8192 /* CaptureArguments */) { + links.containsArgumentsReference = true; + } + else { + links.containsArgumentsReference = traverse(declaration.body); + } + } + return links.containsArgumentsReference; + function traverse(node) { + if (!node) + return false; + switch (node.kind) { + case 71 /* Identifier */: + return node.text === "arguments" && ts.isPartOfExpression(node); + case 149 /* PropertyDeclaration */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + return node.name.kind === 144 /* ComputedPropertyName */ + && traverse(node.name); + default: + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + } + } + } function getSignaturesOfSymbol(symbol) { if (!symbol) return emptyArray; @@ -29743,20 +31169,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 278 /* JSDocFunctionType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 279 /* 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). @@ -29803,7 +31229,7 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { var declaration = signature.declaration; if (declaration.name) { error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name)); @@ -29853,7 +31279,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 === 151 /* Constructor */ || signature.declaration.kind === 155 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 152 /* Constructor */ || signature.declaration.kind === 156 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -29867,7 +31293,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 135 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 133 /* NumberKeyword */ : 136 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -29894,7 +31320,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 144 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 145 /* TypeParameter */).constraint; } function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { @@ -29910,17 +31336,17 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 145 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; if (types) { - var length_3 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_3) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_3 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -29941,8 +31367,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -29979,7 +31405,7 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, typeParameters.length); @@ -29988,7 +31414,7 @@ var ts; // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -30042,11 +31468,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 158 /* TypeReference */: + case 159 /* TypeReference */: return node.typeName; - case 276 /* JSDocTypeReference */: + case 277 /* JSDocTypeReference */: return node.name; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -30072,7 +31498,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 276 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 277 /* 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. @@ -30080,19 +31506,54 @@ var ts; } return getTypeFromNonGenericTypeReference(node, symbol); } + function getPrimitiveTypeFromJSDocTypeReference(node) { + if (ts.isIdentifier(node.name)) { + switch (node.name.text) { + case "String": + return stringType; + case "Number": + return numberType; + case "Boolean": + return booleanType; + case "Void": + return voidType; + case "Undefined": + return undefinedType; + case "Null": + return nullType; + case "Object": + return anyType; + case "Function": + return anyFunctionType; + case "Array": + case "array": + return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + case "Promise": + case "promise": + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + } + } + } + function getTypeFromJSDocNullableTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getUnionType([type, nullType]) : type; + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 276 /* JSDocTypeReference */) { - var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(typeReferenceName); - type = getTypeReferenceType(node, symbol); + if (node.kind === 277 /* JSDocTypeReference */) { + type = getPrimitiveTypeFromJSDocTypeReference(node); + if (!type) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(typeReferenceName); + type = getTypeReferenceType(node, symbol); + } } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 158 /* TypeReference */ + var typeNameOrExpression = node.kind === 159 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -30127,9 +31588,9 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var declaration = declarations_4[_i]; switch (declaration.kind) { - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: return declaration; } } @@ -30148,18 +31609,62 @@ var ts; } return type; } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455 /* Value */, ts.Diagnostics.Cannot_find_global_value_0); + function getGlobalValueSymbol(name, reportErrors) { + return getGlobalSymbol(name, 107455 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793064 /* Type */, ts.Diagnostics.Cannot_find_global_type_0); + function getGlobalTypeSymbol(name, reportErrors) { + return getGlobalSymbol(name, 793064 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name, arity) { + function getGlobalType(name, arity, reportErrors) { + var symbol = getGlobalTypeSymbol(name, reportErrors); + return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; + } + function getGlobalTypedPropertyDescriptorType() { + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", /*arity*/ 1, /*reportErrors*/ true)) || emptyGenericType; + } + function getGlobalTemplateStringsArrayType() { + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", /*arity*/ 0, /*reportErrors*/ true)) || emptyObjectType; + } + function getGlobalESSymbolConstructorSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); + } + function getGlobalESSymbolType(reportErrors) { + return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; + } + function getGlobalPromiseType(reportErrors) { + return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalPromiseConstructorSymbol(reportErrors) { + return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); + } + function getGlobalPromiseConstructorLikeType(reportErrors) { + return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", /*arity*/ 0, reportErrors)) || emptyObjectType; + } + function getGlobalAsyncIterableType(reportErrors) { + return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIteratorType(reportErrors) { + return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIterableIteratorType(reportErrors) { + return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableType(reportErrors) { + return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalIteratorType(reportErrors) { + return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableIteratorType(reportErrors) { + return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + var symbol = getGlobalSymbol(name, 793064 /* Type */, /*diagnostic*/ undefined); + return symbol && getTypeOfGlobalSymbol(symbol, arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. @@ -30170,26 +31675,26 @@ var ts; var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793064 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } - /** - * Creates a TypeReference for a generic `TypedPropertyDescriptor`. - */ - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableType(), [elementType]); + function createTypedPropertyDescriptorType(propertyType) { + return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); + function createAsyncIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(/*reportErrors*/ true), [iteratedType]); + } + function createAsyncIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(/*reportErrors*/ true), [iteratedType]); + } + function createIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableType(/*reportErrors*/ true), [iteratedType]); + } + function createIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(/*reportErrors*/ true), [iteratedType]); } function createArrayType(elementType) { return createTypeFromGenericGlobalType(globalArrayType, [elementType]); @@ -30307,14 +31812,14 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -30322,8 +31827,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -30435,7 +31940,13 @@ var ts; else if (type.flags & 1 /* Any */) { typeSet.containsAny = true; } + else if (getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { + typeSet.containsEmptyObject = true; + } else if (!(type.flags & 8192 /* Never */) && (strictNullChecks || !(type.flags & 6144 /* Nullable */)) && !ts.contains(typeSet, type)) { + if (type.flags & 32768 /* Object */) { + typeSet.containsObjectType = true; + } if (type.flags & 65536 /* Union */ && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } @@ -30448,8 +31959,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -30472,6 +31983,9 @@ var ts; if (typeSet.containsAny) { return anyType; } + if (typeSet.containsEmptyObject && !typeSet.containsObjectType) { + typeSet.push(emptyObjectType); + } if (typeSet.length === 1) { return typeSet[0]; } @@ -30541,7 +32055,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode : undefined; var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -30577,7 +32091,7 @@ var ts; return indexInfo.type; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, 1 /* Number */)) { error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } @@ -30589,7 +32103,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -30599,11 +32113,12 @@ var ts; else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } + return unknownType; } - return unknownType; + return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; @@ -30620,7 +32135,7 @@ var ts; // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 179 /* ElementAccessExpression */) || + maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) || isGenericMappedType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; @@ -30694,7 +32209,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 230 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 231 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -30747,7 +32262,7 @@ var ts; skippedPrivateMembers.set(rightProp.name, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.name, rightProp); + members.set(rightProp.name, getNonReadonlySymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -30764,7 +32279,6 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 67108864 /* Optional */); var result = createSymbol(flags, leftProp.name); - result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 /* Readonly */ : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; @@ -30773,11 +32287,22 @@ var ts; } } else { - members.set(leftProp.name, leftProp); + members.set(leftProp.name, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function getNonReadonlySymbol(prop) { + if (!isReadonlySymbol(prop)) { + return prop; + } + var flags = 4 /* Property */ | (prop.flags & 67108864 /* Optional */); + var result = createSymbol(flags, prop.name); + result.type = getTypeOfSymbol(prop); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + return result; + } function isClassMethod(prop) { return prop.flags & 8192 /* Method */ && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); } @@ -30834,9 +32359,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 229 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 230 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 151 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 152 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -30852,90 +32377,85 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 118 /* AnyKeyword */: - case 267 /* JSDocAllType */: - case 268 /* JSDocUnknownType */: + case 119 /* AnyKeyword */: + case 268 /* JSDocAllType */: + case 269 /* JSDocUnknownType */: return anyType; - case 135 /* StringKeyword */: + case 136 /* StringKeyword */: return stringType; - case 132 /* NumberKeyword */: + case 133 /* NumberKeyword */: return numberType; - case 121 /* BooleanKeyword */: + case 122 /* BooleanKeyword */: return booleanType; - case 136 /* SymbolKeyword */: + case 137 /* SymbolKeyword */: return esSymbolType; - case 104 /* VoidKeyword */: + case 105 /* VoidKeyword */: return voidType; - case 138 /* UndefinedKeyword */: + case 139 /* UndefinedKeyword */: return undefinedType; - case 94 /* NullKeyword */: + case 95 /* NullKeyword */: return nullType; - case 129 /* NeverKeyword */: + case 130 /* NeverKeyword */: return neverType; - case 133 /* ObjectKeyword */: + case 134 /* ObjectKeyword */: return nonPrimitiveType; - case 293 /* JSDocNullKeyword */: - return nullType; - case 294 /* JSDocUndefinedKeyword */: - return undefinedType; - case 295 /* JSDocNeverKeyword */: - return neverType; - case 168 /* ThisType */: - case 98 /* ThisKeyword */: + case 169 /* ThisType */: + case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 172 /* LiteralType */: + case 173 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 292 /* JSDocLiteralType */: + case 293 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 158 /* TypeReference */: - case 276 /* JSDocTypeReference */: + case 159 /* TypeReference */: + case 277 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return booleanType; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 163 /* ArrayType */: - case 269 /* JSDocArrayType */: + case 164 /* ArrayType */: + case 270 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 164 /* TupleType */: + case 165 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 165 /* UnionType */: - case 270 /* JSDocUnionType */: + case 166 /* UnionType */: + case 271 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 166 /* IntersectionType */: + case 167 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 167 /* ParenthesizedType */: - case 272 /* JSDocNullableType */: - case 273 /* JSDocNonNullableType */: - case 280 /* JSDocConstructorType */: - case 281 /* JSDocThisType */: - case 277 /* JSDocOptionalType */: + case 273 /* JSDocNullableType */: + return getTypeFromJSDocNullableTypeNode(node); + case 168 /* ParenthesizedType */: + case 274 /* JSDocNonNullableType */: + case 281 /* JSDocConstructorType */: + case 282 /* JSDocThisType */: + case 278 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 274 /* JSDocRecordType */: + case 275 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 162 /* TypeLiteral */: - case 291 /* JSDocTypeLiteral */: - case 278 /* JSDocFunctionType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 163 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 279 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 169 /* TypeOperator */: + case 170 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 171 /* MappedType */: + case 172 /* MappedType */: return getTypeFromMappedTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 70 /* Identifier */: - case 142 /* QualifiedName */: + case 71 /* Identifier */: + case 143 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 271 /* JSDocTupleType */: + case 272 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 279 /* JSDocVariadicType */: + case 280 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30986,7 +32506,7 @@ var ts; return mapper; } function createTypeEraser(sources) { - return createTypeMapper(sources, undefined); + return createTypeMapper(sources, /*targets*/ undefined); } /** * Maps forward-references to later types parameters to the empty object type. @@ -31144,26 +32664,28 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0]; - while (node) { + return !!ts.findAncestor(symbol.declarations[0], function (node) { + if (node.kind === 233 /* ModuleDeclaration */ || node.kind === 265 /* SourceFile */) { + return "quit"; + } switch (node.kind) { - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -31173,19 +32695,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 229 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 230 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 171 /* MappedType */: + case 172 /* MappedType */: if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { return true; } break; - case 278 /* JSDocFunctionType */: + case 279 /* JSDocFunctionType */: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -31194,18 +32716,13 @@ var ts; } } break; - case 232 /* ModuleDeclaration */: - case 264 /* SourceFile */: - return false; } - node = node.parent; - } - return false; + }); } function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 264 /* SourceFile */ || parentKind === 233 /* ModuleBlock */; + return parentKind === 265 /* SourceFile */ || parentKind === 234 /* ModuleBlock */; } return false; } @@ -31282,34 +32799,34 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 193 /* BinaryExpression */: - return node.operatorToken.kind === 53 /* BarBarToken */ && + case 194 /* BinaryExpression */: + return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return ts.forEach(node.properties, isContextSensitive); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. return node.initializer && isContextSensitive(node.initializer); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: // It is possible to that node.expression is undefined (e.g
) return node.expression && isContextSensitive(node.expression); } @@ -31325,7 +32842,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 186 /* ArrowFunction */) { + if (node.kind === 187 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -31401,12 +32918,13 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, ignoreReturnTypes, /*reportErrors*/ false, + /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -31441,9 +32959,23 @@ var ts; var sourceParams = source.parameters; var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - var related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors); + var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); + var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var sourceSig = getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = getSingleCallSignature(getNonNullableType(targetType)); + // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter + // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, + // they naturally relate only contra-variantly). However, if the source and target parameters both have + // function types with a single call signature, we known we are relating two callback parameters. In + // that case it is sufficient to only relate the parameters of the signatures co-variantly because, + // similar to return values, callback parameters are output positions. This means that a Promise, + // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) + // with respect to T. + var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate && + (getFalsyFlags(sourceType) & 6144 /* Nullable */) === (getFalsyFlags(targetType) & 6144 /* Nullable */); + var related = callbacks ? + compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + !checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); @@ -31471,7 +33003,11 @@ var ts; } } else { - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + // When relating callback signatures, we still need to relate return types bi-variantly as otherwise + // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } + // wouldn't be co-variant for T without this rule. + result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + compareTypes(sourceReturnType, targetReturnType, reportErrors); } } return result; @@ -31538,6 +33074,19 @@ var ts; sourceNonRestParamCount; } } + function isEmptyResolvedType(t) { + return t.properties.length === 0 && + t.callSignatures.length === 0 && + t.constructSignatures.length === 0 && + !t.stringIndexInfo && + !t.numberIndexInfo; + } + function isEmptyObjectType(type) { + return type.flags & 32768 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 65536 /* Union */ ? ts.forEach(type.types, isEmptyObjectType) : + type.flags & 131072 /* Intersection */ ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + false; + } function isEnumTypeRelatedTo(source, target, errorReporter) { if (source === target) { return true; @@ -31628,7 +33177,7 @@ var ts; } } if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { - return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); + return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } @@ -31692,7 +33241,7 @@ var ts; if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType() === source && esSymbolType === target)) { + (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) { reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -31767,136 +33316,37 @@ var ts; return result; } } - else if (target.flags & 65536 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { - return result; - } - } - else if (target.flags & 131072 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & 131072 /* Intersection */) { - // Check to see if any constituents of the intersection are immediately related to the target. - // - // Don't report errors though. Checking whether a constituent is related to the source is not actually - // useful and leads to some confusing error messages. Instead it is better to let the below checks - // take care of this, or to not elaborate at all. For instance, - // - // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. - // - // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection - // than to report that 'D' is not assignable to 'A' or 'B'. - // - // - For a primitive type or type parameter (such as 'number = A & B') there is no point in - // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { - return result; - } - } - else if (target.flags & 16384 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!source.declaration.questionToken) { - var templateType = getTemplateTypeFromMappedType(source); - var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { - return result; - } - } - } - } - else if (target.flags & 262144 /* Index */) { - // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 262144 /* Index */) { - if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { - return result; - } - } - // A type S is assignable to keyof T if S is assignable to keyof C, where C is the - // constraint of T. - var constraint = getConstraintOfType(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } - } - } - else if (target.flags & 524288 /* IndexedAccess */) { - // if we have indexed access types with identical index types, see if relationship holds for - // the two object types. - if (source.flags & 524288 /* IndexedAccess */ && source.indexType === target.indexType) { - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - return result; - } - } - // A type S is related to a type T[K] if S is related to A[K], where K is string-like and - // A is the apparent type of S. - var constraint = getBaseConstraintOfType(target); - if (constraint) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (source.flags & 16384 /* TypeParameter */) { - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (getObjectFlags(target) & 32 /* Mapped */ && getConstraintTypeFromMappedType(target) === getIndexType(source)) { - var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); - var templateType = getTemplateTypeFromMappedType(target); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - var constraint = getConstraintOfTypeParameter(source); - // A type parameter with no constraint is not related to the non-primitive object type. - if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // Report constraint errors only if the constraint is not the empty object type - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - } - else if (source.flags & 524288 /* IndexedAccess */) { - // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and - // A is the apparent type of S. - var constraint = getBaseConstraintOfType(source); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } else { - if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + if (target.flags & 65536 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { return result; } } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - var apparentSource = getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (apparentSource.flags & (32768 /* Object */ | 131072 /* Intersection */) && target.flags & 32768 /* Object */) { - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190 /* Primitive */); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + else if (target.flags & 131072 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072 /* Intersection */) { + // Check to see if any constituents of the intersection are immediately related to the target. + // + // Don't report errors though. Checking whether a constituent is related to the source is not actually + // useful and leads to some confusing error messages. Instead it is better to let the below checks + // take care of this, or to not elaborate at all. For instance, + // + // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. + // + // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection + // than to report that 'D' is not assignable to 'A' or 'B'. + // + // - For a primitive type or type parameter (such as 'number = A & B') there is no point in + // breaking the intersection apart. + if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + return result; + } + } + if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -31916,13 +33366,7 @@ var ts; function isIdenticalTo(source, target) { var result; if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { - if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if all type arguments are identical - if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } if (source.flags & 65536 /* Union */ && target.flags & 65536 /* Union */ || source.flags & 131072 /* Intersection */ && target.flags & 131072 /* Intersection */) { @@ -31941,14 +33385,8 @@ var ts; function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && - (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { - return true; - } - else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { - return true; - } - else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } @@ -31963,19 +33401,13 @@ var ts; } return false; } - function isEmptyResolvedType(t) { - return t.properties.length === 0 && - t.callSignatures.length === 0 && - t.constructSignatures.length === 0 && - !t.stringIndexInfo && - !t.numberIndexInfo; - } - function isEmptyObjectType(type) { - return type.flags & 32768 /* Object */ && isEmptyResolvedType(resolveStructuredTypeMembers(type)); - } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(source.flags & 33554432 /* JsxAttributes */); + if ((relation === assignableRelation || relation === comparableRelation) && + (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { + return false; + } for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { @@ -31984,7 +33416,7 @@ var ts; // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. ts.Debug.assert(!!errorNode); - if (ts.isJsxAttributes(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); @@ -32106,12 +33538,12 @@ var ts; } return result; } - // Determine if two object types are related by structure. First, check if the result is already available in the global cache. + // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source, originalSource, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0 /* False */; } @@ -32151,32 +33583,11 @@ var ts; maybeStack[depth].set(id, 1 /* Succeeded */); depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1 /* Maybe */; - } - else if (isGenericMappedType(source) || isGenericMappedType(target)) { - result = mappedTypeRelatedTo(source, target, reportErrors); - } - else { - result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 0 /* String */, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 1 /* Number */, reportErrors); - } - } - } - } - } + var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -32192,6 +33603,139 @@ var ts; } return result; } + function structuredTypeRelatedTo(source, target, reportErrors) { + var result; + var saveErrorInfo = errorInfo; + if (target.flags & 16384 /* TypeParameter */) { + // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. + if (getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!source.declaration.questionToken) { + var templateType = getTemplateTypeFromMappedType(source); + var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + } + else if (target.flags & 262144 /* Index */) { + // A keyof S is related to a keyof T if T is related to S. + if (source.flags & 262144 /* Index */) { + if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { + return result; + } + } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } + else if (target.flags & 524288 /* IndexedAccess */) { + // A type S is related to a type T[K] if S is related to A[K], where K is string-like and + // A is the apparent type of S. + var constraint = getConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (source.flags & 16384 /* TypeParameter */) { + // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. + if (getObjectFlags(target) & 32 /* Mapped */ && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + var templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + var constraint = getConstraintOfTypeParameter(source); + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + } + else if (source.flags & 524288 /* IndexedAccess */) { + // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and + // A is the apparent type of S. + var constraint = getConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (target.flags & 524288 /* IndexedAccess */ && source.indexType === target.indexType) { + // if we have indexed access types with identical index types, see if relationship holds for + // the two object types. + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + return result; + } + } + } + else { + if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var sourceIsPrimitive = !!(source.flags & 8190 /* Primitive */); + if (relation !== identityRelation) { + source = getApparentType(source); + } + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (source.flags & (32768 /* Object */ | 131072 /* Intersection */) && target.flags & 32768 /* Object */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportStructuralErrors); + } + else { + result = propertiesRelatedTo(source, target, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 0 /* String */, sourceIsPrimitive, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 1 /* Number */, sourceIsPrimitive, reportStructuralErrors); + } + } + } + } + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + return 0 /* False */; + } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -32232,8 +33776,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -32248,7 +33792,7 @@ var ts; var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { - if (getCheckFlags(sourceProp) & 128 /* ContainsPrivate */) { + if (getCheckFlags(sourceProp) & 256 /* ContainsPrivate */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); } @@ -32382,7 +33926,7 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, reportErrors) { - return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -32424,12 +33968,12 @@ var ts; } return related; } - function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors) { if (relation === identityRelation) { return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || ((targetInfo.type.flags & 1 /* Any */) && !(originalSource.flags & 8190 /* Primitive */))) { + if (!targetInfo || targetInfo.type.flags & 1 /* Any */ && !sourceIsPrimitive) { // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } @@ -32494,7 +34038,7 @@ var ts; // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (getCheckFlags(prop) & 6 /* Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.name); @@ -32543,22 +34087,24 @@ var ts; } return false; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack, depth) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (getObjectFlags(type) & (4 /* Reference */ | 64 /* Instantiated */) && depth >= 5) { + // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons + // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely + // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 + // levels, but unequal at some level beyond that. + function isDeeplyNestedType(type, stack, depth) { + // We track all object types that have an associated symbol (representing the origin of the type) + if (depth >= 5 && type.flags & 32768 /* Object */) { var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (getObjectFlags(t) & (4 /* Reference */ | 64 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; + if (symbol) { + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & 32768 /* Object */ && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } } } } @@ -32669,8 +34215,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -32678,8 +34224,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -32785,8 +34331,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -32856,7 +34402,6 @@ var ts; var updated = f(original); members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } - ; return members; } /** @@ -32880,11 +34425,19 @@ var ts; type.regularType = regularNew; return regularNew; } + function getWidenedProperty(prop) { + var original = getTypeOfSymbol(prop); + var widened = getWidenedType(original); + return widened === original ? prop : createSymbolWithType(prop, widened); + } function getWidenedTypeOfObjectLiteral(type) { - var members = transformTypeOfMembers(type, function (prop) { - var widened = getWidenedType(prop); - return prop === widened ? prop : widened; - }); + var members = ts.createMap(); + for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + // Since get accessors already widen their return value there is no need to + // widen accessor based properties here. + members.set(prop.name, prop.flags & 4 /* Property */ ? getWidenedProperty(prop) : prop); + } 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)); @@ -32956,25 +34509,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 145 /* Parameter */: + case 146 /* 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 175 /* BindingElement */: + case 176 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -32987,7 +34540,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsWideningType */) { + if (produceDiagnostics && noImplicitAny && type.flags & 2097152 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -33014,13 +34567,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, inferUnionTypes) { + function createInferenceContext(signature, inferUnionTypes, useAnyForNoInferences) { var inferences = ts.map(signature.typeParameters, createTypeInferencesObject); return { signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences: useAnyForNoInferences }; } function createTypeInferencesObject() { @@ -33069,14 +34623,14 @@ var ts; var readonlyMask = target.declaration.readonlyToken ? false : true; var optionalMask = target.declaration.questionToken ? 0 : 67108864 /* Optional */; var members = createSymbolTable(properties); - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var prop = properties_5[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (!inferredPropType) { return undefined; } var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.name); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 /* Readonly */ : 0; + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; members.set(prop.name, inferredProp); @@ -33249,7 +34803,7 @@ var ts; if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } var key = source.id + "," + target.id; @@ -33303,8 +34857,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -33354,8 +34908,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -33417,7 +34971,7 @@ var ts; inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; } @@ -33459,33 +35013,21 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - while (node) { - switch (node.kind) { - case 161 /* TypeQuery */: - return true; - case 70 /* Identifier */: - case 142 /* QualifiedName */: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); + return !!ts.findAncestor(node, function (n) { return n.kind === 162 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 143 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the // leftmost identifier followed by zero or more property names separated by dots. // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 98 /* ThisKeyword */) { + if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 178 /* PropertyAccessExpression */) { + if (node.kind === 179 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -33493,31 +35035,33 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 70 /* Identifier */: - case 98 /* ThisKeyword */: + case 71 /* Identifier */: + case 99 /* ThisKeyword */: return node; - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 70 /* Identifier */: - return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 225 /* VariableDeclaration */ || target.kind === 175 /* BindingElement */) && + case 71 /* Identifier */: + return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 226 /* VariableDeclaration */ || target.kind === 176 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 98 /* ThisKeyword */: - return target.kind === 98 /* ThisKeyword */; - case 178 /* PropertyAccessExpression */: - return target.kind === 178 /* PropertyAccessExpression */ && + case 99 /* ThisKeyword */: + return target.kind === 99 /* ThisKeyword */; + case 97 /* SuperKeyword */: + return target.kind === 97 /* SuperKeyword */; + case 179 /* PropertyAccessExpression */: + return target.kind === 179 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 178 /* PropertyAccessExpression */) { + while (source.kind === 179 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -33530,15 +35074,15 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 178 /* PropertyAccessExpression */ && + return target.kind === 179 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 70 /* Identifier */) { + if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 178 /* PropertyAccessExpression */) { + if (expr.kind === 179 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -33549,7 +35093,7 @@ var ts; var prop = getUnionOrIntersectionProperty(type, name); if (prop && getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 16 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 32 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -33568,7 +35112,7 @@ var ts; } } } - if (callExpression.expression.kind === 178 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 179 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -33610,8 +35154,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -33667,9 +35211,8 @@ var ts; if (flags & 16777216 /* NonPrimitive */) { return strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; } - if (flags & 16384 /* TypeParameter */) { - var constraint = getConstraintOfTypeParameter(type); - return getTypeFacts(constraint || emptyObjectType); + if (flags & 540672 /* TypeVariable */) { + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & 196608 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); @@ -33695,22 +35238,22 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || + checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 176 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 260 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 177 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 261 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 215 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 194 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 216 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); @@ -33727,21 +35270,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return stringType; - case 215 /* ForOfStatement */: - return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 193 /* BinaryExpression */: + case 216 /* ForOfStatement */: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; + case 194 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return undefinedType; - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -33749,7 +35292,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 173 /* ObjectBindingPattern */ ? + var type = pattern.kind === 174 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -33767,39 +35310,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 214 /* ForInStatement */) { + if (node.parent.parent.kind === 215 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 215 /* ForOfStatement */) { - return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; + if (node.parent.parent.kind === 216 /* ForOfStatement */) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 225 /* VariableDeclaration */ ? + return node.kind === 226 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */ ? + return node.kind === 226 /* VariableDeclaration */ || node.kind === 176 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 225 /* VariableDeclaration */ && node.initializer && + return node.kind === 226 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 175 /* BindingElement */ && node.parent.kind === 193 /* BinaryExpression */ && + node.kind !== 176 /* BindingElement */ && node.parent.kind === 194 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return getReferenceCandidate(node.left); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -33807,13 +35350,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 184 /* ParenthesizedExpression */ || - parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 185 /* ParenthesizedExpression */ || + parent.kind === 194 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 194 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 256 /* CaseClause */) { + if (clause.kind === 257 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -33861,8 +35404,32 @@ var ts; } return f(type) ? type : neverType; } - function mapType(type, f) { - return type.flags & 65536 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); + // Apply a mapping function to a type and return the resulting type. If the source type + // is a union type, the mapping function is applied to each constituent type and a union + // of the resulting types is returned. + function mapType(type, mapper) { + if (!(type.flags & 65536 /* Union */)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -33906,7 +35473,7 @@ var ts; // we defer subtype reduction until the evolving array type is finalized into a manifest // array type. function addEvolvingArrayElementType(evolvingArrayType, node) { - var elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node)); + var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { @@ -33928,8 +35495,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33952,12 +35519,12 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 178 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 180 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 179 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 179 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 181 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 180 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 193 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 57 /* EqualsToken */ && + parent.parent.kind === 194 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); @@ -33971,7 +35538,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 96 /* SuperKeyword */) { + if (node.expression.kind !== 97 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -33983,14 +35550,12 @@ var ts; } return false; } - function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { + function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { + if (initialType === void 0) { initialType = declaredType; } var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -33999,7 +35564,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 202 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 203 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -34017,7 +35582,7 @@ var ts; } var type = void 0; if (flow.flags & 4096 /* AfterFinally */) { - // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; @@ -34060,7 +35625,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 178 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 179 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -34114,7 +35679,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 180 /* CallExpression */ ? + var expr = node.kind === 181 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -34122,7 +35687,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 180 /* CallExpression */) { + if (node.kind === 181 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -34182,7 +35747,7 @@ var ts; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { - // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. continue; @@ -34286,7 +35851,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 178 /* PropertyAccessExpression */ && + return expr.kind === 179 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -34311,19 +35876,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 188 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 189 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 188 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 189 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -34342,9 +35907,9 @@ var ts; return declaredType; } break; - case 92 /* InstanceOfKeyword */: + case 93 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -34353,7 +35918,7 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { + if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); @@ -34361,10 +35926,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 31 /* EqualsEqualsToken */ || operator === 32 /* ExclamationEqualsToken */; + var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - value.kind === 94 /* NullKeyword */ ? + value.kind === 95 /* NullKeyword */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); @@ -34393,7 +35958,7 @@ var ts; } return type; } - if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { + if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536 /* Union */)) { @@ -34401,8 +35966,16 @@ var ts; // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. var targetType = typeofTypesByName.get(literal.text); - if (targetType && isTypeSubtypeOf(targetType, type)) { - return targetType; + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 540672 /* TypeVariable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } } } var facts = assumeTrue ? @@ -34490,10 +36063,9 @@ var ts; // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the // two types. - var targetType = type.flags & 16384 /* TypeParameter */ ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, targetType) ? candidate : + isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { @@ -34510,7 +36082,7 @@ var ts; return type; } if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + var predicateArgument = callExpression.arguments[predicate.parameterIndex - (signature.thisParameter ? 1 : 0)]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -34522,7 +36094,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 179 /* ElementAccessExpression */ || invokedExpression.kind === 178 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 180 /* ElementAccessExpression */ || invokedExpression.kind === 179 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -34539,18 +36111,19 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 179 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 191 /* PrefixUnaryExpression */: - if (expr.operator === 50 /* ExclamationToken */) { + case 192 /* PrefixUnaryExpression */: + if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -34563,7 +36136,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 70 /* Identifier */) { + if (location.kind === 71 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -34582,15 +36155,12 @@ var ts; return getTypeOfSymbol(symbol); } function getControlFlowContainer(node) { - while (true) { - node = node.parent; - if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 233 /* ModuleBlock */ || - node.kind === 264 /* SourceFile */ || - node.kind === 148 /* PropertyDeclaration */) { - return node; - } - } + return ts.findAncestor(node.parent, function (node) { + return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || + node.kind === 234 /* ModuleBlock */ || + node.kind === 265 /* SourceFile */ || + node.kind === 149 /* PropertyDeclaration */; + }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { @@ -34605,21 +36175,13 @@ var ts; return symbol.isAssigned || false; } function hasParentWithAssignmentsMarked(node) { - while (true) { - node = node.parent; - if (!node) { - return false; - } - if (ts.isFunctionLike(node) && getNodeLinks(node).flags & 4194304 /* AssignmentsMarked */) { - return true; - } - } + return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 4194304 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 146 /* Parameter */) { symbol.isAssigned = true; } } @@ -34631,6 +36193,15 @@ var ts; function isConstVariable(symbol) { return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromDeclaredType(declaredType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 146 /* Parameter */ && + declaration.initializer && + getFalsyFlags(declaredType) & 2048 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -34645,16 +36216,14 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 186 /* ArrowFunction */) { + if (container.kind === 187 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 16384 /* AwaitContext */) { - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; - } + getNodeLinks(container).flags |= 8192 /* CaptureArguments */; return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -34666,7 +36235,7 @@ var ts; // 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 (declaration_1.kind === 228 /* ClassDeclaration */ + if (declaration_1.kind === 229 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -34678,14 +36247,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 198 /* ClassExpression */) { + else if (declaration_1.kind === 199 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 148 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 149 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -34720,15 +36289,15 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 145 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 146 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 185 /* FunctionExpression */ || - flowContainer.kind === 186 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 186 /* FunctionExpression */ || + flowContainer.kind === 187 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -34736,15 +36305,18 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node) || node.parent.kind === 246 /* ExportSpecifier */) || ts.isInAmbientContext(declaration); - var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, ts.getRootDeclaration(declaration)) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, 2048 /* Undefined */); + var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } @@ -34759,19 +36331,12 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; + return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 259 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 260 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -34796,8 +36361,8 @@ var ts; } // 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 === 213 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 226 /* VariableDeclarationList */).parent === container && + if (container.kind === 214 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 227 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -34809,9 +36374,9 @@ var ts; } } function isAssignedInBodyOfForStatement(node, container) { - var current = node; // skip parenthesized nodes - while (current.parent.kind === 184 /* ParenthesizedExpression */) { + var current = node; + while (current.parent.kind === 185 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -34819,28 +36384,20 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 191 /* PrefixUnaryExpression */ || current.parent.kind === 192 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 192 /* PrefixUnaryExpression */ || current.parent.kind === 193 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; + isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* 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; + return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 148 /* PropertyDeclaration */ || container.kind === 151 /* Constructor */) { + if (container.kind === 149 /* PropertyDeclaration */ || container.kind === 152 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -34908,38 +36465,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 151 /* Constructor */) { + if (container.kind === 152 /* Constructor */) { checkThisBeforeSuper(node, container, 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 === 186 /* ArrowFunction */) { + if (container.kind === 187 /* 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 /* ES2015 */); } switch (container.kind) { - case 232 /* ModuleDeclaration */: + case 233 /* 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 231 /* EnumDeclaration */: + case 232 /* 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 151 /* Constructor */: + case 152 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -34951,8 +36508,8 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // 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 === 185 /* FunctionExpression */ && - ts.isInJavaScriptFile(container.parent) && + if (container.kind === 186 /* FunctionExpression */ && + container.parent.kind === 194 /* BinaryExpression */ && 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 @@ -34972,7 +36529,7 @@ var ts; if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); var type = ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + return getFlowTypeOfReference(node, type); } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); @@ -34980,7 +36537,7 @@ var ts; return type; } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } @@ -34988,28 +36545,23 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 278 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 279 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 282 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 145 /* Parameter */) { - return true; - } - } - return false; + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 146 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 180 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 181 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 186 /* ArrowFunction */) { + while (container && container.kind === 187 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -35022,17 +36574,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = node; - while (current && current !== container && current.kind !== 143 /* ComputedPropertyName */) { - current = current.parent; - } - if (current && current.kind === 143 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 144 /* ComputedPropertyName */; }); + if (current && current.kind === 144 /* 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 === 177 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 178 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -35040,7 +36589,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 151 /* Constructor */) { + if (!isCallExpression && container.kind === 152 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { @@ -35106,7 +36655,7 @@ var ts; // 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 === 150 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 151 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -35120,7 +36669,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 177 /* ObjectLiteralExpression */) { + if (container.parent.kind === 178 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -35140,7 +36689,7 @@ var ts; } return unknownType; } - if (container.kind === 151 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 152 /* 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; @@ -35155,7 +36704,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 === 151 /* Constructor */; + return container.kind === 152 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -35163,29 +36712,47 @@ 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 === 177 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 178 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 150 /* MethodDeclaration */ || - container.kind === 149 /* MethodSignature */ || - container.kind === 152 /* GetAccessor */ || - container.kind === 153 /* SetAccessor */; + return container.kind === 151 /* MethodDeclaration */ || + container.kind === 150 /* MethodSignature */ || + container.kind === 153 /* GetAccessor */ || + container.kind === 154 /* SetAccessor */; } else { - return container.kind === 150 /* MethodDeclaration */ || - container.kind === 149 /* MethodSignature */ || - container.kind === 152 /* GetAccessor */ || - container.kind === 153 /* SetAccessor */ || - container.kind === 148 /* PropertyDeclaration */ || - container.kind === 147 /* PropertySignature */ || - container.kind === 151 /* Constructor */; + return container.kind === 151 /* MethodDeclaration */ || + container.kind === 150 /* MethodSignature */ || + container.kind === 153 /* GetAccessor */ || + container.kind === 154 /* SetAccessor */ || + container.kind === 149 /* PropertyDeclaration */ || + container.kind === 148 /* PropertySignature */ || + container.kind === 152 /* Constructor */; } } } return false; } } + function getContainingObjectLiteral(func) { + return (func.kind === 151 /* MethodDeclaration */ || + func.kind === 153 /* GetAccessor */ || + func.kind === 154 /* SetAccessor */) && func.parent.kind === 178 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 186 /* FunctionExpression */ && func.parent.kind === 261 /* PropertyAssignment */ ? func.parent.parent : + undefined; + } + function getThisTypeArgument(type) { + return getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + } + function getThisTypeFromContextualType(type) { + return mapType(type, function (t) { + return t.flags & 131072 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + }); + } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186 /* ArrowFunction */) { + if (func.kind === 187 /* ArrowFunction */) { + return undefined; + } + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -35194,6 +36761,40 @@ var ts; } } } + if (noImplicitThis) { + var containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + // We have an object literal method. Check if the containing object literal has a contextual type + // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in + // any directly enclosing object literals. + var contextualType = getApparentTypeOfContextualType(containingLiteral); + var literal = containingLiteral; + var type = contextualType; + while (type) { + var thisType = getThisTypeFromContextualType(type); + if (thisType) { + return instantiateType(thisType, getContextualMapper(containingLiteral)); + } + if (literal.parent.kind !== 261 /* PropertyAssignment */) { + break; + } + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); + } + // There was no contextual ThisType for the containing object literal, so the contextual type + // for 'this' is the non-null form of the contextual type for the containing object literal or + // the type of the object literal itself. + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); + } + // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the + // contextual type for 'this' is 'obj'. + if (func.parent.kind === 194 /* BinaryExpression */ && func.parent.operatorToken.kind === 58 /* EqualsToken */) { + var target = func.parent.left; + if (target.kind === 179 /* PropertyAccessExpression */ || target.kind === 180 /* ElementAccessExpression */) { + return checkExpressionCached(target.expression); + } + } + } return undefined; } // Return contextual type of parameter or undefined if no contextual type is available @@ -35251,7 +36852,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 145 /* Parameter */) { + if (declaration.kind === 146 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -35263,7 +36864,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (ts.isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== 176 /* BindingElement */ && parentDeclaration.type && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -35277,33 +36878,34 @@ var ts; } function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); - if (ts.isAsyncFunctionLike(func)) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getPromisedType(contextualReturnType); + if (func) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1 /* Generator */) { + return undefined; } - return undefined; - } - if (func && !func.asteriskToken) { - return getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func); + return functionFlags & 2 /* Async */ + ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) // Async function + : contextualReturnType; // Regular function } return undefined; } function getContextualTypeForYieldOperand(node) { var func = ts.getContainingFunction(node); if (func) { + var functionFlags = ts.getFunctionFlags(func); var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); + : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & 2 /* Async */) !== 0); } } return undefined; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 145 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 146 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -35314,8 +36916,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 === 151 /* Constructor */ || - functionDecl.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153 /* SetAccessor */))) { + functionDecl.kind === 152 /* Constructor */ || + functionDecl.kind === 153 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 154 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -35337,7 +36939,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 182 /* TaggedTemplateExpression */) { + if (template.parent.kind === 183 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -35345,7 +36947,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { + if (operator >= 58 /* FirstAssignment */ && operator <= 70 /* LastAssignment */) { // Don't do this for special property assignments to avoid circularity if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0 /* None */) { return undefined; @@ -35355,7 +36957,7 @@ var ts; return getTypeOfExpression(binaryExpression.left); } } - else if (operator === 53 /* BarBarToken */) { + else if (operator === 54 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -35364,48 +36966,21 @@ var ts; } return type; } - else if (operator === 52 /* AmpersandAmpersandToken */ || operator === 25 /* CommaToken */) { + else if (operator === 53 /* AmpersandAmpersandToken */ || operator === 26 /* CommaToken */) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } } return undefined; } - // Apply a mapping function to a contextual type and return the resulting type. If the contextual type - // is a union type, the mapping function is applied to each constituent type and a union of the resulting - // types is returned. - function applyToContextualType(type, mapper) { - if (!(type.flags & 65536 /* Union */)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { + return mapType(type, function (t) { var prop = t.flags & 229376 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { @@ -35452,7 +37027,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); } return undefined; } @@ -35461,6 +37036,32 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(node) { + // JSX expression can appear in two position : JSX Element's children or JSX attribute + var jsxAttributes = ts.isJsxAttributeLike(node.parent) ? + node.parent.parent : + node.parent.openingElement.attributes; // node.parent is JsxElement + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + var attributesType = getContextualType(jsxAttributes); + if (!attributesType || isTypeAny(attributesType)) { + return undefined; + } + if (ts.isJsxAttribute(node.parent)) { + // JSX expression is in JSX attribute + return getTypeOfPropertyOfType(attributesType, node.parent.name.text); + } + else if (node.parent.kind === 249 /* JsxElement */) { + // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + } + else { + // JSX expression is in JSX spread attribute + return attributesType; + } + } function getContextualTypeForJsxAttribute(attribute) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. @@ -35509,48 +37110,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 225 /* VariableDeclaration */: - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 176 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 186 /* ArrowFunction */: - case 218 /* ReturnStatement */: + case 187 /* ArrowFunction */: + case 219 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 176 /* ArrayLiteralExpression */: + case 263 /* SpreadAssignment */: + return getApparentTypeOfContextualType(parent.parent); + case 177 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 204 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 195 /* TemplateExpression */); + case 205 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 196 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return getContextualType(parent); - case 255 /* JsxExpression */: - return getContextualType(parent); - case 252 /* JsxAttribute */: - case 254 /* JsxSpreadAttribute */: + case 256 /* JsxExpression */: + return getContextualTypeForJsxExpression(parent); + case 253 /* JsxAttribute */: + case 255 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } + function getContextualMapper(node) { + node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return node ? node.contextualMapper : identityMapper; + } // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type, node) { @@ -35578,7 +37185,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */; + return node.kind === 186 /* FunctionExpression */ || node.kind === 187 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -35597,7 +37204,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 !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -35607,8 +37214,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var current = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var current = types_17[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -35635,40 +37242,25 @@ var ts; } return result; } - /** - * Detect if the mapper implies an inference context. Specifically, there are 4 possible values - * for a mapper. Let's go through each one of them: - * - * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, - * which could cause us to assign a parameter a type - * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in - * inferential typing (context is undefined for the identityMapper) - * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign - * types to parameters and fix type parameters (context is defined) - * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be - * passed as the contextual mapper when checking an expression (context is undefined for these) - * - * isInferentialContext is detecting if we are in case 3 - */ - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function checkSpreadExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpression(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + function checkSpreadExpression(node, checkMode) { + if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 1536 /* SpreadIncludes */); + } + var arrayOrIterableType = checkExpression(node.expression, checkMode); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); } function hasDefaultValue(node) { - return (node.kind === 175 /* BindingElement */ && !!node.initializer) || - (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 176 /* BindingElement */ && !!node.initializer) || + (node.kind === 194 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } - function checkArrayLiteral(node, contextualMapper) { + function checkArrayLiteral(node, checkMode) { var elements = node.elements; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 197 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 198 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -35681,18 +37273,18 @@ var ts; // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. - var restArrayType = checkExpression(e.expression, contextualMapper); + var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); if (restElementType) { elementTypes.push(restElementType); } } else { - var type = checkExpressionForMutableLocation(e, contextualMapper); + var type = checkExpressionForMutableLocation(e, checkMode); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 197 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 198 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -35707,7 +37299,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 === 174 /* ArrayBindingPattern */ || pattern.kind === 176 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 175 /* ArrayBindingPattern */ || pattern.kind === 177 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -35715,7 +37307,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 199 /* OmittedExpression */) { + if (patternElement.kind !== 200 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -35732,7 +37324,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 143 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 144 /* 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, @@ -35794,7 +37386,7 @@ var ts; var unionType = propTypes.length ? getUnionType(propTypes, /*subtypeReduction*/ true) : undefinedType; return createIndexInfo(unionType, /*isReadonly*/ false); } - function checkObjectLiteral(node, contextualMapper) { + function checkObjectLiteral(node, checkMode) { var inDestructuringPattern = ts.isAssignmentTarget(node); // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); @@ -35804,7 +37396,8 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 173 /* ObjectBindingPattern */ || contextualType.pattern.kind === 177 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 174 /* ObjectBindingPattern */ || contextualType.pattern.kind === 178 /* ObjectLiteralExpression */); + var isJSObjectLiteral = !contextualType && ts.isInJavaScriptFile(node); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -35813,27 +37406,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 260 /* PropertyAssignment */ || - memberDecl.kind === 261 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 261 /* PropertyAssignment */ || + memberDecl.kind === 262 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 260 /* PropertyAssignment */) { - type = checkPropertyAssignment(memberDecl, contextualMapper); + if (memberDecl.kind === 261 /* PropertyAssignment */) { + type = checkPropertyAssignment(memberDecl, checkMode); } - else if (memberDecl.kind === 150 /* MethodDeclaration */) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); + else if (memberDecl.kind === 151 /* MethodDeclaration */) { + type = checkObjectLiteralMethod(memberDecl, checkMode); } else { - ts.Debug.assert(memberDecl.kind === 261 /* ShorthandPropertyAssignment */); - type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 262 /* ShorthandPropertyAssignment */); + type = checkExpressionForMutableLocation(memberDecl.name, checkMode); } typeFlags |= type.flags; var prop = createSymbol(4 /* Property */ | member.flags, member.name); 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 === 260 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 261 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 261 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 262 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 67108864 /* Optional */; } @@ -35861,7 +37454,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 262 /* SpreadAssignment */) { + else if (memberDecl.kind === 263 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -35888,8 +37481,8 @@ 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 === 152 /* GetAccessor */ || memberDecl.kind === 153 /* SetAccessor */); - checkAccessorDeclaration(memberDecl); + ts.Debug.assert(memberDecl.kind === 153 /* GetAccessor */ || memberDecl.kind === 154 /* SetAccessor */); + checkNodeDeferred(memberDecl); } if (ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { @@ -35931,8 +37524,8 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; + var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; + var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; result.flags |= 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); @@ -35956,7 +37549,7 @@ var ts; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function checkJsxElement(node) { // Check attributes @@ -35968,22 +37561,7 @@ var ts; else { checkExpression(node.closingElement.tagName); } - // Check children - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 255 /* JsxExpression */: - checkJsxExpression(child); - break; - case 248 /* JsxElement */: - checkJsxElement(child); - break; - case 249 /* JsxSelfClosingElement */: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } /** * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers @@ -35997,7 +37575,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 178 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 179 /* PropertyAccessExpression */ || tagName.kind === 99 /* ThisKeyword */) { return false; } else { @@ -36010,8 +37588,10 @@ var ts; * @param openingLikeElement a JSX opening-like element * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + * @remarks Because this function calls getSpreadType, it needs to use the same checks as checkObjectLiteral, + * which also calls getSpreadType. */ - function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createMap(); var spread = emptyObjectType; @@ -36021,8 +37601,8 @@ var ts; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = attributeDecl.initializer ? - checkExpression(attributeDecl.initializer, contextualMapper) : - trueType; // is sugar for + checkExpression(attributeDecl.initializer, checkMode) : + trueType; // is sugar for var attributeSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -36035,14 +37615,14 @@ var ts; attributesArray.push(attributeSymbol); } else { - ts.Debug.assert(attributeDecl.kind === 254 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 255 /* JsxSpreadAttribute */); if (attributesArray.length > 0) { spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = ts.createMap(); } var exprType = checkExpression(attributeDecl.expression); - if (!(exprType.flags & (32768 /* Object */ | 1 /* Any */))) { + if (!isValidSpreadType(exprType)) { error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return anyType; } @@ -36068,6 +37648,39 @@ var ts; } }); } + // Handle children attribute + var parent = openingLikeElement.parent.kind === 249 /* JsxElement */ ? openingLikeElement.parent : undefined; + // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement + if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { + var childrenTypes = []; + for (var _b = 0, _c = parent.children; _b < _c.length; _b++) { + var child = _c[_b]; + // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that + // because then type of children property will have constituent of string type. + if (child.kind === 10 /* JsxText */) { + if (!child.containsOnlyWhiteSpaces) { + childrenTypes.push(stringType); + } + } + else { + childrenTypes.push(checkExpression(child, checkMode)); + } + } + // Error if there is a attribute named "children" and children element. + // This is because children element will overwrite the value from attributes + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { + if (attributesTable.has(jsxChildrenPropertyName)) { + error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); + } + // If there are children in the body of JSX element, create dummy attribute "children" with anyType so that it will pass the attribute checking process + var childrenPropSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, jsxChildrenPropertyName); + childrenPropSymbol.type = childrenTypes.length === 1 ? + childrenTypes[0] : + createArrayType(getUnionType(childrenTypes, /*subtypeReduction*/ false)); + attributesTable.set(jsxChildrenPropertyName, childrenPropSymbol); + } + } return createJsxAttributesType(attributes.symbol, attributesTable); /** * Create anonymous type from given attributes symbol table. @@ -36087,8 +37700,8 @@ var ts; * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) * @param node a JSXAttributes to be resolved of its type */ - function checkJsxAttributes(node, contextualMapper) { - return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, contextualMapper); + function checkJsxAttributes(node, checkMode) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, checkMode); } function getJsxType(name) { var jsxType = jsxTypes.get(name); @@ -36098,11 +37711,11 @@ var ts; return jsxType; } /** - * 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. - */ + * 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) { @@ -36125,7 +37738,7 @@ var ts; return links.resolvedSymbol = unknownSymbol; } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } return links.resolvedSymbol = unknownSymbol; @@ -36157,37 +37770,55 @@ var ts; } return getUnionType(ts.map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } + /** + * Look into JSX namespace and then look for container with matching name as nameOfAttribPropContainer. + * Get a single property from that container if existed. Report an error if there are more than one property. + * + * @param nameOfAttribPropContainer a string of value JsxNames.ElementAttributesPropertyNameContainer or JsxNames.ElementChildrenAttributeNameContainer + * if other string is given or the container doesn't exist, return undefined. + */ + function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer) { + // JSX + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); + // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 793064 /* Type */); + // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] + var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); + // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute + var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); + if (propertiesOfJsxElementAttribPropInterface) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (propertiesOfJsxElementAttribPropInterface.length === 0) { + return ""; + } + else if (propertiesOfJsxElementAttribPropInterface.length === 1) { + return propertiesOfJsxElementAttribPropInterface[0].name; + } + else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + // More than one property on ElementAttributesProperty is an error + error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, nameOfAttribPropContainer); + } + } + return undefined; + } /// e.g. "props" for React.d.ts, /// 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-intrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { - // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); - // JSX.ElementAttributesProperty [symbol] - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793064 /* Type */); - // JSX.ElementAttributesProperty [type] - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // 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 - if (attribProperties.length === 0) { - return ""; - } - else if (attribProperties.length === 1) { - return attribProperties[0].name; - } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; - } + if (!_hasComputedJsxElementPropertiesName) { + _hasComputedJsxElementPropertiesName = true; + _jsxElementPropertiesName = getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer); } - else { - // No interface exists, so the element attributes type will be an implicit any - return undefined; + return _jsxElementPropertiesName; + } + function getJsxElementChildrenPropertyname() { + if (!_hasComputedJsxElementChildrenPropertyName) { + _hasComputedJsxElementChildrenPropertyName = true; + _jsxElementChildrenPropertyName = getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer); } + return _jsxElementChildrenPropertyName; } /** * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. @@ -36202,13 +37833,14 @@ var ts; function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); if (callSignature !== unknownSignature) { var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { @@ -36235,7 +37867,8 @@ var ts; ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. var candidatesOutArray = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); @@ -36245,7 +37878,7 @@ var ts; var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var shouldBeCandidate = true; for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { var attribute = _b[_a]; @@ -36292,7 +37925,7 @@ var ts; * @return attributes type if able to resolve the type of node * anyType if there is no type ElementAttributesProperty or there is an error * emptyObjectType if there is no "prop" in the element instance type - **/ + */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { if (!elementType) { elementType = checkExpression(openingLikeElement.tagName); @@ -36311,7 +37944,7 @@ var ts; // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; - // Hello World + // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { var stringLiteralTypeName = elementType.text; @@ -36364,11 +37997,6 @@ var ts; // Props is of type 'any' or unknown return attributesType; } - else if (attributesType.flags & 65536 /* Union */) { - // Props cannot be a union type - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); - return anyType; - } else { // Normal case -- add in IntrinsicClassElements and IntrinsicElements var apparentAttributesType = attributesType; @@ -36424,7 +38052,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); } return links.resolvedJsxElementAttributesType; } @@ -36467,10 +38095,25 @@ var ts; return prop || unknownSymbol; } function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + if (!deferredJsxElementClassType) { + deferredJsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } - return jsxElementClassType; + return deferredJsxElementClassType; + } + function getJsxGlobalElementType() { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + function getJsxGlobalStatelessElementType() { + if (!deferredJsxStatelessElementType) { + var jsxElementType = getJsxGlobalElementType(); + if (jsxElementType) { + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; } /** * Returns all the properties of the Jsx.IntrinsicElements interface @@ -36484,8 +38127,8 @@ var ts; if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { + if (getJsxGlobalElementType() === undefined) { + if (noImplicitAny) { error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -36510,11 +38153,11 @@ var ts; checkJsxAttributesAssignableToTagNameAttributes(node); } /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { // The function involves following steps: // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. @@ -36540,9 +38183,9 @@ var ts; checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node, contextualMapper) { + function checkJsxExpression(node, checkMode) { if (node.expression) { - var type = checkExpression(node.expression, contextualMapper); + var type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -36555,19 +38198,19 @@ 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 : 148 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 149 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { if (s.valueDeclaration) { var flags = ts.getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } - if (getCheckFlags(s) & 2 /* SyntheticProperty */) { + if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 128 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 32 /* ContainsPublic */ ? 4 /* Public */ : + var accessModifier = checkFlags & 256 /* ContainsPrivate */ ? 8 /* Private */ : + checkFlags & 64 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; - var staticModifier = checkFlags & 256 /* ContainsStatic */ ? 32 /* Static */ : 0; + var staticModifier = checkFlags & 512 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } if (s.flags & 16777216 /* Prototype */) { @@ -36578,6 +38221,9 @@ var ts; function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol) { + return !!(symbol.flags & 8192 /* Method */ || getCheckFlags(symbol) & 4 /* SyntheticMethod */); + } /** * Check whether the requested property access is valid. * Returns true if node is a valid property access, and false otherwise. @@ -36588,15 +38234,15 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 178 /* PropertyAccessExpression */ || node.kind === 225 /* VariableDeclaration */ ? + var errorNode = node.kind === 179 /* PropertyAccessExpression */ || node.kind === 226 /* VariableDeclaration */ ? node.name : node.right; - if (getCheckFlags(prop) & 128 /* ContainsPrivate */) { + if (getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; } - if (left.kind === 96 /* SuperKeyword */) { + if (left.kind === 97 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or // instance member variable initializer where this references a derived class instance, @@ -36605,10 +38251,11 @@ var ts; // 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 /* ES2015 */) { - var propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== 150 /* MethodDeclaration */ && propKind !== 149 /* MethodSignature */) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. + var hasNonMethodDeclaration = forEachProperty(prop, function (p) { + var propKind = getDeclarationKindFromSymbol(p); + return propKind !== 151 /* MethodDeclaration */ && propKind !== 150 /* MethodSignature */; + }); + if (hasNonMethodDeclaration) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -36638,7 +38285,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 96 /* SuperKeyword */) { + if (left.kind === 97 /* SuperKeyword */) { return true; } // Find the first enclosing class that has the declaring classes of the protected constituents @@ -36717,7 +38364,7 @@ var ts; } function isInPropertyInitializer(node) { while (node) { - if (node.parent && node.parent.kind === 148 /* PropertyDeclaration */ && node.parent.initializer === node) { + if (node.parent && node.parent.kind === 149 /* PropertyDeclaration */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -36745,10 +38392,17 @@ var ts; } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === 229 /* ClassDeclaration */ && + node.parent && node.parent.kind !== 159 /* TypeReference */ && + !ts.isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; @@ -36764,16 +38418,16 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 178 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || + if (node.kind !== 179 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; } - var flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 178 /* PropertyAccessExpression */ + var left = node.kind === 179 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -36790,13 +38444,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 226 /* VariableDeclarationList */) { + if (initializer.kind === 227 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 70 /* Identifier */) { + else if (initializer.kind === 71 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -36813,13 +38467,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 70 /* Identifier */) { + if (e.kind === 71 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 214 /* ForInStatement */ && + if (node.kind === 215 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -36837,7 +38491,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 181 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 182 /* 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); @@ -36881,7 +38535,7 @@ var ts; if (!leftHandSideSymbol) { return false; } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); if (!globalESSymbol) { // Already errored when we tried to look up the symbol return false; @@ -36895,10 +38549,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 146 /* Decorator */) { + else if (node.kind !== 147 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -36925,8 +38579,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var signature = signatures_2[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -36964,7 +38618,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 197 /* SpreadElement */) { + if (arg && arg.kind === 198 /* SpreadElement */) { return i; } } @@ -36981,13 +38635,13 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* 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 argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 195 /* TemplateExpression */) { + if (tagExpression.template.kind === 196 /* 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; @@ -37000,11 +38654,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 12 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 13 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 146 /* Decorator */) { + else if (node.kind === 147 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -37013,7 +38667,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 === 181 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 182 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -37057,7 +38711,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, /*inferUnionTypes*/ true); + var context = createInferenceContext(signature, /*inferUnionTypes*/ true, /*useAnyForNoInferences*/ false); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypesWithContext(context, instantiateType(source, contextualMapper), target); @@ -37099,7 +38753,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 !== 199 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 200 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -37163,7 +38817,7 @@ var ts; */ function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete + // 1. callIsIncomplete // 2. attributes property has same number of properties as the parameter object type. // We can figure that out by resolving attributes property and check number of properties in the resolved type // If the call has correct arity, we will then check if the argument type and parameter type is assignable @@ -37191,7 +38845,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 181 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 182 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -37208,7 +38862,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 !== 199 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 200 /* 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); @@ -37230,12 +38884,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 180 /* CallExpression */) { + if (node.kind === 181 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 178 /* PropertyAccessExpression */) { + if (callee.kind === 179 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 179 /* ElementAccessExpression */) { + else if (callee.kind === 180 /* ElementAccessExpression */) { return callee.expression; } } @@ -37251,16 +38905,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 195 /* TemplateExpression */) { + if (template.kind === 196 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 146 /* Decorator */) { + else if (node.kind === 147 /* 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. @@ -37275,32 +38929,32 @@ var ts; return args; } /** - * Returns the effective argument count for a node that works like a function invocation. - * If 'node' is a Decorator, the number of arguments is derived from the decoration - * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument - * count is 1. - * If 'node.target' is a parameter declaration, the effective argument count is 3. - * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count - * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. - * Otherwise, the argument count is the length of the 'args' array. - */ + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 146 /* Decorator */) { + if (node.kind === 147 /* Decorator */) { switch (node.parent.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* 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. @@ -37310,7 +38964,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 145 /* Parameter */: + case 146 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -37321,38 +38975,38 @@ var ts; } } /** - * Returns the effective type of the first argument to a decorator. - * If 'node' is a class declaration or class expression, the effective argument type - * is the type of the static side of the class. - * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, - * depending on whether the method is declared static. - * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. - */ + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* 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 === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 151 /* Constructor */) { + if (node.kind === 152 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 148 /* PropertyDeclaration */ || - node.kind === 150 /* MethodDeclaration */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 149 /* PropertyDeclaration */ || + node.kind === 151 /* MethodDeclaration */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* 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 @@ -37363,50 +39017,50 @@ var ts; return unknownType; } /** - * Returns the effective type for the second argument to a decorator. - * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we - * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, - * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will - * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the - * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either - * be a symbol type or the string type. - * A class decorator does not have a second argument type. - */ + * Returns the effective type for the second argument to a decorator. + * If 'node' is a parameter, its effective argument type is one of the following: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { node = node.parent; - if (node.kind === 151 /* Constructor */) { + if (node.kind === 152 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. } - if (node.kind === 148 /* PropertyDeclaration */ || - node.kind === 150 /* MethodDeclaration */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 149 /* PropertyDeclaration */ || + node.kind === 151 /* MethodDeclaration */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -37423,30 +39077,30 @@ var ts; return unknownType; } /** - * Returns the effective argument type for the third argument to a decorator. - * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a - * `TypedPropertyDescriptor` instantiated with the type of the member. - * Class and property decorators do not have a third effective argument. - */ + * Returns the effective argument type for the third argument to a decorator. + * If 'node' is a parameter, the effective argument type is the number type. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 148 /* PropertyDeclaration */) { + if (node.kind === 149 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 150 /* MethodDeclaration */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 151 /* MethodDeclaration */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -37456,8 +39110,8 @@ var ts; return unknownType; } /** - * Returns the effective argument type for the provided argument to a decorator. - */ + * Returns the effective argument type for the provided argument to a decorator. + */ function getEffectiveDecoratorArgumentType(node, argIndex) { if (argIndex === 0) { return getEffectiveDecoratorFirstArgumentType(node.parent); @@ -37472,16 +39126,16 @@ var ts; return unknownType; } /** - * Gets the effective argument type for an argument in a call expression. - */ + * Gets the effective argument type for an argument in a call expression. + */ function getEffectiveArgumentType(node, argIndex) { // 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 === 146 /* Decorator */) { + if (node.kind === 147 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 183 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -37489,25 +39143,25 @@ var ts; return undefined; } /** - * Gets the effective argument expression for an argument in a call expression. - */ + * Gets the effective argument expression for an argument in a call expression. + */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 146 /* Decorator */ || - (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */)) { + if (node.kind === 147 /* Decorator */ || + (argIndex === 0 && node.kind === 183 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; } /** - * Gets the error node to use when reporting errors for an effective argument. - */ + * Gets the error node to use when reporting errors for an effective argument. + */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 146 /* Decorator */) { + if (node.kind === 147 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 183 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -37516,17 +39170,31 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 182 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 146 /* Decorator */; + var isTaggedTemplate = node.kind === 183 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 147 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 96 /* SuperKeyword */) { + if (node.expression.kind !== 97 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } + if (signatures.length === 1) { + var declaration = signatures[0].declaration; + if (declaration && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration)) { + if (containsArgumentsReference(declaration)) { + var signatureWithRest = cloneSignature(signatures[0]); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + syntheticArgsSymbol.type = anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + signatureWithRest.parameters = ts.concatenate(signatureWithRest.parameters, [syntheticArgsSymbol]); + signatureWithRest.hasRestParameter = true; + signatures = [signatureWithRest]; + } + } + } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); @@ -37589,7 +39257,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 181 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -37684,7 +39352,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false) + ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false, /*useAnyForNoInferences*/ ts.isInJavaScriptFile(node)) : undefined; while (true) { candidate = originalCandidate; @@ -37707,7 +39375,7 @@ var ts; if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; + var index = excludeArgument ? ts.indexOf(excludeArgument, /*value*/ true) : -1; if (index < 0) { return candidate; } @@ -37739,14 +39407,14 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -37938,26 +39606,26 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } /** - * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. - */ + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 145 /* Parameter */: + case 146 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } /** - * Resolves a decorator as if it were a call expression. - */ + * Resolves a decorator as if it were a call expression. + */ function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); @@ -38008,8 +39676,8 @@ var ts; if (elementType.flags & 65536 /* Union */) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var type = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var type = types_18[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -38024,16 +39692,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 180 /* CallExpression */: + case 181 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 146 /* Decorator */: + case 147 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: // This code-path is called by language service return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } @@ -38085,28 +39753,31 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 181 /* NewExpression */) { + if (node.kind === 182 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 151 /* Constructor */ && - declaration.kind !== 155 /* ConstructSignature */ && - declaration.kind !== 160 /* ConstructorType */ && + declaration.kind !== 152 /* Constructor */ && + declaration.kind !== 156 /* ConstructSignature */ && + declaration.kind !== 161 /* 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 // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - var funcSymbol = node.expression.kind === 70 /* Identifier */ ? + var funcSymbol = node.expression.kind === 71 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { + funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + } + if (funcSymbol && funcSymbol.members && funcSymbol.flags & 16 /* Function */) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -38133,9 +39804,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 227 /* FunctionDeclaration */ + ? 228 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 225 /* VariableDeclaration */ + ? 226 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -38164,13 +39835,12 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 151 /* Constructor */) { + else if (container.kind === 152 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -38194,9 +39864,12 @@ var ts; pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; } - function assignContextualParameterTypes(signature, context, mapper) { + function getTypeOfFirstParameterOfSignature(signature) { + return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + } + function assignContextualParameterTypes(signature, context, mapper, checkMode) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - if (isInferentialContext(mapper)) { + if (checkMode === 2 /* Inferential */) { for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -38208,23 +39881,23 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, /*type*/ undefined); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper, checkMode); } } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } } @@ -38235,7 +39908,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 70 /* Identifier */) { + if (element.name.kind === 71 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -38243,19 +39916,19 @@ var ts; } } } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper, checkMode) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 173 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 174 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 174 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 175 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); } - else if (isInferentialContext(mapper)) { + else if (checkMode === 2 /* Inferential */) { // Even if the parameter already has a type, it might be because it was given a type while // processing the function as an argument to a prior signature during overload resolution. // If this was the case, it may have caused some type parameters to be fixed. So here, @@ -38297,10 +39970,10 @@ var ts; } function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument - var globalPromiseType = getGlobalPromiseType(); + var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType); + promisedType = getAwaitedType(promisedType) || emptyObjectType; return createTypeReference(globalPromiseType, [promisedType]); } return emptyObjectType; @@ -38311,56 +39984,63 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } - else if (!getGlobalPromiseConstructorSymbol()) { + else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } return promiseType; } - function getReturnTypeFromBody(func, contextualMapper) { + function getReturnTypeFromBody(func, checkMode) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } - var isAsync = ts.isAsyncFunctionLike(func); + var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 206 /* Block */) { - type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { + if (func.body.kind !== 207 /* Block */) { + type = checkExpressionCached(func.body, checkMode); + if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which we will wrap in // the native Promise type later in this function. - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, /*errorNode*/ func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } } else { var types = void 0; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { + if (functionFlags & 1 /* Generator */) { + types = ts.concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode)); + if (!types || types.length === 0) { + var iterableIteratorAny = functionFlags & 2 /* Async */ + ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function + : createIterableIteratorType(anyType); // Generator function + if (noImplicitAny) { error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); } return iterableIteratorAny; } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return isAsync ? createPromiseReturnType(func, neverType) : neverType; + return functionFlags & 2 /* Async */ + ? createPromiseReturnType(func, neverType) // Async function + : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return isAsync ? createPromiseReturnType(func, voidType) : voidType; + return functionFlags & 2 /* Async */ + ? createPromiseReturnType(func, voidType) // Async function + : voidType; // Normal function } } // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - if (funcIsGenerator) { - type = createIterableIteratorType(type); + if (functionFlags & 1 /* Generator */) { + type = functionFlags & 2 /* Async */ + ? createAsyncIterableIteratorType(type) // AsyncGenerator function + : createIterableIteratorType(type); // Generator function } } if (!contextualSignature) { @@ -38375,17 +40055,25 @@ var ts; // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body is awaited type of the body, wrapped in a native Promise type. - return isAsync ? createPromiseReturnType(func, widenedType) : widenedType; + return (functionFlags & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */ + ? createPromiseReturnType(func, widenedType) // Async function + : widenedType; // Generator function, AsyncGenerator function, or normal function } - function checkAndAggregateYieldOperandTypes(func, contextualMapper) { + function checkAndAggregateYieldOperandTypes(func, checkMode) { var aggregatedTypes = []; + var functionFlags = ts.getFunctionFlags(func); ts.forEachYieldExpression(func.body, function (yieldExpression) { var expr = yieldExpression.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); + var type = checkExpressionCached(expr, checkMode); if (yieldExpression.asteriskToken) { // A yield* expression effectively yields everything that its operand yields - type = checkElementTypeOfIterable(type, yieldExpression.expression); + type = checkIteratedTypeOrElementType(type, yieldExpression.expression, /*allowStringInput*/ false, (functionFlags & 2 /* Async */) !== 0); + } + if (functionFlags & 2 /* Async */) { + type = checkAwaitedType(type, expr, yieldExpression.asteriskToken + ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); @@ -38413,26 +40101,26 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 220 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 221 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; } - function checkAndAggregateReturnExpressionTypes(func, contextualMapper) { - var isAsync = ts.isAsyncFunctionLike(func); + function checkAndAggregateReturnExpressionTypes(func, checkMode) { + var functionFlags = ts.getFunctionFlags(func); var aggregatedTypes = []; var hasReturnWithNoExpression = functionHasImplicitReturn(func); var hasReturnOfTypeNever = false; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { + var type = checkExpressionCached(expr, checkMode); + if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (type.flags & 8192 /* Never */) { hasReturnOfTypeNever = true; @@ -38446,7 +40134,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */)) { + func.kind === 186 /* FunctionExpression */ || func.kind === 187 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -38475,7 +40163,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 207 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -38507,22 +40195,22 @@ var ts; error(func.type || func, ts.Diagnostics.Not_all_code_paths_return_a_value); } } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 185 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 186 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards - if (contextualMapper === identityMapper && isContextSensitive(node)) { + if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + var mightFixTypeParameters = contextSensitive && checkMode === 2 /* Inferential */; // Check if function expression is contextually typed and assign parameter types if so. // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to // check mightFixTypeParameters. @@ -38537,10 +40225,10 @@ var ts; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + assignContextualParameterTypes(signature, contextualSignature, getContextualMapper(node), checkMode); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); + var returnType = getReturnTypeFromBody(node, checkMode); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -38552,7 +40240,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 150 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 151 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -38560,10 +40248,13 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var functionFlags = ts.getFunctionFlags(node); + var returnOrPromisedType = node.type && + ((functionFlags & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */ ? + checkAsyncFunctionReturnType(node) : + getTypeFromTypeNode(node.type)); // AsyncGenerator function, Generator function, or normal function + if ((functionFlags & 1 /* Generator */) === 0) { // return is not necessary in the body of generators checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } @@ -38576,7 +40267,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 206 /* Block */) { + if (node.body.kind === 207 /* Block */) { checkSourceElement(node.body); } else { @@ -38587,8 +40278,8 @@ var ts; // its return type annotation. var exprType = checkExpression(node.body); if (returnOrPromisedType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + if ((functionFlags & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } else { @@ -38613,7 +40304,7 @@ var ts; // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(getCheckFlags(symbol) & 4 /* Readonly */ || + return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || @@ -38623,11 +40314,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) && - expr.expression.kind === 98 /* ThisKeyword */) { + (expr.kind === 179 /* PropertyAccessExpression */ || expr.kind === 180 /* ElementAccessExpression */) && + expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 151 /* Constructor */)) + if (!(func && func.kind === 152 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -38639,13 +40330,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) { + if (expr.kind === 179 /* PropertyAccessExpression */ || expr.kind === 180 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 239 /* NamespaceImport */; + return declaration && declaration.kind === 240 /* NamespaceImport */; } } } @@ -38654,7 +40345,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipParentheses(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 179 /* PropertyAccessExpression */ && node.kind !== 180 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -38663,7 +40354,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 178 /* PropertyAccessExpression */ && expr.kind !== 179 /* ElementAccessExpression */) { + if (expr.kind !== 179 /* PropertyAccessExpression */ && expr.kind !== 180 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -38693,32 +40384,32 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); + return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 37 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 38 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, "" + -node.operand.text)); } switch (node.operator) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 50 /* ExclamationToken */: + case 51 /* ExclamationToken */: var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); return facts === 1048576 /* Truthy */ ? falseType : facts === 2097152 /* Falsy */ ? trueType : booleanType; - case 42 /* PlusPlusToken */: - case 43 /* MinusMinusToken */: + case 43 /* PlusPlusToken */: + case 44 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 @@ -38748,8 +40439,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -38766,8 +40457,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -38776,8 +40467,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { - var t = types_20[_a]; + for (var _a = 0, types_21 = types; _a < types_21.length; _a++) { + var t = types_21[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -38825,24 +40516,24 @@ var ts; if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 /* NumberLike */ | 512 /* ESSymbol */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 260 /* PropertyAssignment */ || property.kind === 261 /* ShorthandPropertyAssignment */) { + if (property.kind === 261 /* PropertyAssignment */ || property.kind === 262 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 143 /* ComputedPropertyName */) { + if (name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -38855,7 +40546,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 261 /* ShorthandPropertyAssignment */) { + if (property.kind === 262 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -38867,7 +40558,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 262 /* SpreadAssignment */) { + else if (property.kind === 263 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -38884,22 +40575,25 @@ var ts; error(property, ts.Diagnostics.Property_assignment_expected); } } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + function checkArrayLiteralAssignment(node, sourceType, checkMode) { + if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* Read */); + } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } return sourceType; } - function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { + function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 199 /* OmittedExpression */) { - if (element.kind !== 197 /* SpreadElement */) { + if (element.kind !== 200 /* OmittedExpression */) { + if (element.kind !== 198 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -38907,7 +40601,7 @@ var ts; ? getTypeOfPropertyOfType(sourceType, propName) : elementType; if (type) { - return checkDestructuringAssignment(element, type, contextualMapper); + return checkDestructuringAssignment(element, type, checkMode); } else { // We still need to check element expression here because we may need to set appropriate flag on the expression @@ -38927,20 +40621,20 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 193 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 194 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { - return checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); } } } } return undefined; } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 261 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 262 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -38949,28 +40643,28 @@ var ts; !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 2048 /* Undefined */)) { sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); } - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } target = exprOrAssignment.name; } else { target = exprOrAssignment; } - if (target.kind === 193 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { - checkBinaryExpression(target, contextualMapper); + if (target.kind === 194 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 177 /* ObjectLiteralExpression */) { + if (target.kind === 178 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 176 /* ArrayLiteralExpression */) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 177 /* ArrayLiteralExpression */) { + return checkArrayLiteralAssignment(target, sourceType, checkMode); } - return checkReferenceAssignment(target, sourceType, contextualMapper); + return checkReferenceAssignment(target, sourceType, checkMode); } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 262 /* SpreadAssignment */ ? + function checkReferenceAssignment(target, sourceType, checkMode) { + var targetType = checkExpression(target, checkMode); + var error = target.parent.kind === 263 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -38989,52 +40683,52 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: case 9 /* StringLiteral */: - case 11 /* RegularExpressionLiteral */: - case 182 /* TaggedTemplateExpression */: - case 195 /* TemplateExpression */: - case 12 /* NoSubstitutionTemplateLiteral */: + case 12 /* RegularExpressionLiteral */: + case 183 /* TaggedTemplateExpression */: + case 196 /* TemplateExpression */: + case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: - case 94 /* NullKeyword */: - case 138 /* UndefinedKeyword */: - case 185 /* FunctionExpression */: - case 198 /* ClassExpression */: - case 186 /* ArrowFunction */: - case 176 /* ArrayLiteralExpression */: - case 177 /* ObjectLiteralExpression */: - case 188 /* TypeOfExpression */: - case 202 /* NonNullExpression */: - case 249 /* JsxSelfClosingElement */: - case 248 /* JsxElement */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 139 /* UndefinedKeyword */: + case 186 /* FunctionExpression */: + case 199 /* ClassExpression */: + case 187 /* ArrowFunction */: + case 177 /* ArrayLiteralExpression */: + case 178 /* ObjectLiteralExpression */: + case 189 /* TypeOfExpression */: + case 203 /* NonNullExpression */: + case 250 /* JsxSelfClosingElement */: + case 249 /* JsxElement */: return true; - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 50 /* ExclamationToken */: - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: + case 51 /* ExclamationToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 189 /* VoidExpression */: // Explicit opt-out - case 183 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 201 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 190 /* VoidExpression */: // Explicit opt-out + case 184 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 202 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -39049,39 +40743,39 @@ var ts; firstAssignableToSecond && !secondAssignableToFirst ? type2 : getUnionType([type1, type2], /*subtypeReduction*/ true); } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + function checkBinaryExpression(node, checkMode) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 177 /* ObjectLiteralExpression */ || left.kind === 176 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + if (operator === 58 /* EqualsToken */ && (left.kind === 178 /* ObjectLiteralExpression */ || left.kind === 177 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); + var leftType = checkExpression(left, checkMode); + var rightType = checkExpression(right, checkMode); switch (operator) { - case 38 /* AsteriskToken */: - case 39 /* AsteriskAsteriskToken */: - case 60 /* AsteriskEqualsToken */: - case 61 /* AsteriskAsteriskEqualsToken */: - case 40 /* SlashToken */: - case 62 /* SlashEqualsToken */: - case 41 /* PercentToken */: - case 63 /* PercentEqualsToken */: - case 37 /* MinusToken */: - case 59 /* MinusEqualsToken */: - case 44 /* LessThanLessThanToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* BarToken */: - case 68 /* BarEqualsToken */: - case 49 /* CaretToken */: - case 69 /* CaretEqualsToken */: - case 47 /* AmpersandToken */: - case 67 /* AmpersandEqualsToken */: + case 39 /* AsteriskToken */: + case 40 /* AsteriskAsteriskToken */: + case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: + case 41 /* SlashToken */: + case 63 /* SlashEqualsToken */: + case 42 /* PercentToken */: + case 64 /* PercentEqualsToken */: + case 38 /* MinusToken */: + case 60 /* MinusEqualsToken */: + case 45 /* LessThanLessThanToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* BarToken */: + case 69 /* BarEqualsToken */: + case 50 /* CaretToken */: + case 70 /* CaretEqualsToken */: + case 48 /* AmpersandToken */: + case 68 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -39104,8 +40798,8 @@ var ts; } } return numberType; - case 36 /* PlusToken */: - case 58 /* PlusEqualsToken */: + case 37 /* PlusToken */: + case 59 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -39138,14 +40832,14 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 58 /* PlusEqualsToken */) { + if (operator === 59 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 26 /* LessThanToken */: - case 28 /* GreaterThanToken */: - case 29 /* LessThanEqualsToken */: - case 30 /* GreaterThanEqualsToken */: + case 27 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 30 /* LessThanEqualsToken */: + case 31 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -39154,10 +40848,10 @@ var ts; } } return booleanType; - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -39168,27 +40862,30 @@ var ts; reportOperatorError(); } return booleanType; - case 92 /* InstanceOfKeyword */: + case 93 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 91 /* InKeyword */: + case 92 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 52 /* AmpersandAmpersandToken */: + case 53 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 1048576 /* Truthy */ ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 53 /* BarBarToken */: + case 54 /* BarBarToken */: return getTypeFacts(leftType) & 2097152 /* Falsy */ ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 25 /* CommaToken */: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { + case 26 /* CommaToken */: + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; } + function isEvalNode(node) { + return node.kind === 71 /* Identifier */ && node.text === "eval"; + } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 512 /* ESSymbol */) ? left : @@ -39202,21 +40899,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 48 /* BarToken */: - case 68 /* BarEqualsToken */: - return 53 /* BarBarToken */; - case 49 /* CaretToken */: - case 69 /* CaretEqualsToken */: - return 34 /* ExclamationEqualsEqualsToken */; - case 47 /* AmpersandToken */: - case 67 /* AmpersandEqualsToken */: - return 52 /* AmpersandAmpersandToken */; + case 49 /* BarToken */: + case 69 /* BarEqualsToken */: + return 54 /* BarBarToken */; + case 50 /* CaretToken */: + case 70 /* CaretEqualsToken */: + return 35 /* ExclamationEqualsEqualsToken */; + case 48 /* AmpersandToken */: + case 68 /* AmpersandEqualsToken */: + return 53 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { + if (produceDiagnostics && operator >= 58 /* FirstAssignment */ && operator <= 70 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -39262,23 +40959,40 @@ var ts; var func = ts.getContainingFunction(node); // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. - if (func && func.asteriskToken) { + var functionFlags = func && ts.getFunctionFlags(func); + if (node.asteriskToken) { + if (functionFlags & 2 /* Async */) { + if (languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 4096 /* AsyncDelegator */); + } + } + else if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* Values */); + } + } + if (functionFlags & 1 /* Generator */) { var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + expressionElementType = checkIteratedTypeOrElementType(expressionType, node.expression, /*allowStringInput*/ false, (functionFlags & 2 /* Async */) !== 0); } // There is no point in doing an assignability check if the function // has no explicit return type because the return type is directly computed // from the yield expressions. if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(func.type), (functionFlags & 2 /* Async */) !== 0) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(functionFlags & 2 /* Async */ + ? getAwaitedType(expressionElementType, node.expression, ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionElementType, signatureElementType, node.expression, + /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(functionFlags & 2 /* Async */ + ? getAwaitedType(expressionType, node.expression, ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionType, signatureElementType, node.expression, + /*headMessage*/ undefined); } } } @@ -39286,10 +41000,10 @@ var ts; // Both yield and yield* expressions have type 'any' return anyType; } - function checkConditionalExpression(node, contextualMapper) { + function checkConditionalExpression(node, checkMode) { checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); + var type1 = checkExpression(node.whenTrue, checkMode); + var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { @@ -39301,9 +41015,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32 /* StringLiteral */, node.text)); case 8 /* NumericLiteral */: return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, node.text)); - case 100 /* TrueKeyword */: + case 101 /* TrueKeyword */: return trueType; - case 85 /* FalseKeyword */: + case 86 /* FalseKeyword */: return falseType; } } @@ -39320,12 +41034,17 @@ var ts; } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; + var saveContextualMapper = node.contextualMapper; node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); + node.contextualMapper = contextualMapper; + var checkMode = contextualMapper === identityMapper ? 1 /* SkipContextSensitive */ : + contextualMapper ? 2 /* Inferential */ : 0 /* Normal */; + var result = checkExpression(node, checkMode); node.contextualType = saveContextualType; + node.contextualMapper = saveContextualMapper; return result; } - function checkExpressionCached(node, contextualMapper) { + function checkExpressionCached(node, checkMode) { var links = getNodeLinks(node); if (!links.resolvedType) { // When computing a type that we're going to cache, we need to ignore any ongoing control flow @@ -39333,17 +41052,17 @@ var ts; // to the top of the stack ensures all transient types are computed from a known point. var saveFlowLoopStart = flowLoopStart; flowLoopStart = flowLoopCount; - links.resolvedType = checkExpression(node, contextualMapper); + links.resolvedType = checkExpression(node, checkMode); flowLoopStart = saveFlowLoopStart; } return links.resolvedType; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 183 /* TypeAssertionExpression */ || node.kind === 201 /* AsExpression */; + return node.kind === 184 /* TypeAssertionExpression */ || node.kind === 202 /* AsExpression */; } function checkDeclarationInitializer(declaration) { - var type = checkExpressionCached(declaration.initializer); + var type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -39364,52 +41083,56 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, contextualMapper) { - var type = checkExpression(node, contextualMapper); + function checkExpressionForMutableLocation(node, checkMode) { + var type = checkExpression(node, checkMode); return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } - function checkPropertyAssignment(node, contextualMapper) { + function checkPropertyAssignment(node, checkMode) { // 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 === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - return checkExpressionForMutableLocation(node.initializer, contextualMapper); + return checkExpressionForMutableLocation(node.initializer, checkMode); } - function checkObjectLiteralMethod(node, contextualMapper) { + function checkObjectLiteralMethod(node, checkMode) { // Grammar checking checkGrammarMethod(node); // 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 === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { + function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { + if (checkMode === 2 /* Inferential */) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getApparentTypeOfContextualType(node); if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, getContextualMapper(node))); } } } } return type; } - // Returns the type of an expression. Unlike checkExpression, this function is simply concerned - // with computing the type and may not fully check all contained sub-expressions for errors. - function getTypeOfExpression(node) { + /** + * Returns the type of an expression. Unlike checkExpression, this function is simply concerned + * with computing the type and may not fully check all contained sub-expressions for errors. + * A cache argument of true indicates that if the function performs a full type check, it is ok + * to cache the result. + */ + function getTypeOfExpression(node, cache) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === 180 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { + if (node.kind === 181 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -39419,7 +41142,21 @@ var ts; // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions // should have a parameter that indicates whether full error checking is required such that // we can perform the optimizations locally. - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); + } + /** + * Returns the type of an expression. Unlike checkExpression, this function is simply concerned + * with computing the type and may not fully check all contained sub-expressions for errors. + * It is intended for uses where you know there is no contextual type, + * and requesting the contextual type might cause a circularity or other bad behaviour. + * It sets the contextual type of the node to any before calling getTypeOfExpression. + */ + function getContextFreeTypeOfExpression(node) { + var saveContextualType = node.contextualType; + node.contextualType = anyType; + var type = getTypeOfExpression(node); + node.contextualType = saveContextualType; + return type; } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the @@ -39428,108 +41165,108 @@ var ts; // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpression(node, contextualMapper) { + function checkExpression(node, checkMode) { var type; - if (node.kind === 142 /* QualifiedName */) { + if (node.kind === 143 /* QualifiedName */) { type = checkQualifiedName(node); } else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkExpressionWorker(node, checkMode); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { // enum object type for const enums are only permitted in: // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 71 /* Identifier */ || node.kind === 143 /* 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); } } return type; } - function checkExpressionWorker(node, contextualMapper) { + function checkExpressionWorker(node, checkMode) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return checkIdentifier(node); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return checkThisExpression(node); - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: return checkSuperExpression(node); - case 94 /* NullKeyword */: + case 95 /* NullKeyword */: return nullWideningType; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return checkLiteralExpression(node); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return stringType; - case 11 /* RegularExpressionLiteral */: + case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 176 /* ArrayLiteralExpression */: - return checkArrayLiteral(node, contextualMapper); - case 177 /* ObjectLiteralExpression */: - return checkObjectLiteral(node, contextualMapper); - case 178 /* PropertyAccessExpression */: + case 177 /* ArrayLiteralExpression */: + return checkArrayLiteral(node, checkMode); + case 178 /* ObjectLiteralExpression */: + return checkObjectLiteral(node, checkMode); + case 179 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return checkCallExpression(node); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 184 /* ParenthesizedExpression */: - return checkExpression(node.expression, contextualMapper); - case 198 /* ClassExpression */: + case 185 /* ParenthesizedExpression */: + return checkExpression(node.expression, checkMode); + case 199 /* ClassExpression */: return checkClassExpression(node); - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 188 /* TypeOfExpression */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 189 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: return checkAssertion(node); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return checkNonNullAssertion(node); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return checkMetaProperty(node); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return checkDeleteExpression(node); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return checkVoidExpression(node); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return checkAwaitExpression(node); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 193 /* BinaryExpression */: - return checkBinaryExpression(node, contextualMapper); - case 194 /* ConditionalExpression */: - return checkConditionalExpression(node, contextualMapper); - case 197 /* SpreadElement */: - return checkSpreadExpression(node, contextualMapper); - case 199 /* OmittedExpression */: + case 194 /* BinaryExpression */: + return checkBinaryExpression(node, checkMode); + case 195 /* ConditionalExpression */: + return checkConditionalExpression(node, checkMode); + case 198 /* SpreadElement */: + return checkSpreadExpression(node, checkMode); + case 200 /* OmittedExpression */: return undefinedWideningType; - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return checkYieldExpression(node); - case 255 /* JsxExpression */: - return checkJsxExpression(node, contextualMapper); - case 248 /* JsxElement */: + case 256 /* JsxExpression */: + return checkJsxExpression(node, checkMode); + case 249 /* JsxElement */: return checkJsxElement(node); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 253 /* JsxAttributes */: - return checkJsxAttributes(node, contextualMapper); - case 250 /* JsxOpeningElement */: + case 254 /* JsxAttributes */: + return checkJsxAttributes(node, checkMode); + case 251 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -39566,7 +41303,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 151 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 152 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -39577,7 +41314,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 151 /* Constructor */ || func.kind === 155 /* ConstructSignature */ || func.kind === 160 /* ConstructorType */) { + if (func.kind === 152 /* Constructor */ || func.kind === 156 /* ConstructSignature */ || func.kind === 161 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -39587,19 +41324,11 @@ var ts; error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 150 /* MethodDeclaration */ || - node.kind === 227 /* FunctionDeclaration */ || - node.kind === 185 /* FunctionExpression */; - } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 70 /* Identifier */ && + if (param.name.kind === 71 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -39628,7 +41357,7 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); + var leadingError = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, /*headMessage*/ undefined, leadingError); } @@ -39651,13 +41380,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 186 /* ArrowFunction */: - case 154 /* CallSignature */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 159 /* FunctionType */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 187 /* ArrowFunction */: + case 155 /* CallSignature */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 160 /* FunctionType */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -39671,13 +41400,13 @@ var ts; continue; } var name = element.name; - if (name.kind === 70 /* Identifier */ && + if (name.kind === 71 /* Identifier */ && name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 174 /* ArrayBindingPattern */ || - name.kind === 173 /* ObjectBindingPattern */) { + else if (name.kind === 175 /* ArrayBindingPattern */ || + name.kind === 174 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -39686,20 +41415,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 159 /* FunctionType */ || node.kind === 227 /* FunctionDeclaration */ || node.kind === 160 /* ConstructorType */ || - node.kind === 154 /* CallSignature */ || node.kind === 151 /* Constructor */ || - node.kind === 155 /* ConstructSignature */) { + else if (node.kind === 160 /* FunctionType */ || node.kind === 228 /* FunctionDeclaration */ || node.kind === 161 /* ConstructorType */ || + node.kind === 155 /* CallSignature */ || node.kind === 152 /* Constructor */ || + node.kind === 156 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } - if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { + var functionFlags = ts.getFunctionFlags(node); + if ((functionFlags & 7 /* InvalidAsyncOrAsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { checkExternalEmitHelpers(node, 64 /* Awaiter */); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 128 /* Generator */); } } + if ((functionFlags & 5 /* InvalidGenerator */) === 1 /* Generator */) { + if (functionFlags & 2 /* Async */ && languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 2048 /* AsyncGenerator */); + } + else if (languageVersion < 2 /* ES2015 */) { + checkExternalEmitHelpers(node, 128 /* Generator */); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -39707,25 +41445,28 @@ var ts; } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { + if (noImplicitAny && !node.type) { switch (node.kind) { - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 154 /* CallSignature */: + case 155 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 /* ES2015 */ && isSyntacticallyValidGenerator(node)) { + var functionFlags_1 = ts.getFunctionFlags(node); + if ((functionFlags_1 & 5 /* InvalidGenerator */) === 1 /* Generator */) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + var generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; + var iterableIteratorInstantiation = functionFlags_1 & 2 /* Async */ + ? createAsyncIterableIteratorType(generatorElementType) // AsyncGenerator function + : createIterableIteratorType(generatorElementType); // Generator function // Naively, one could check that IterableIterator is assignable to the return type annotation. // However, that would not catch the error in the following case. // @@ -39735,7 +41476,7 @@ var ts; checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if (ts.isAsyncFunctionLike(node)) { + else if ((functionFlags_1 & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */) { checkAsyncFunctionReturnType(node); } } @@ -39756,7 +41497,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* Constructor */) { + if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -39770,16 +41511,16 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: addName(names, member.name, memberName, 4 /* Method */); break; } @@ -39842,12 +41583,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 147 /* PropertySignature */) { + if (member.kind === 148 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 70 /* Identifier */: + case 71 /* Identifier */: memberName = member.name.text; break; default: @@ -39864,7 +41605,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 229 /* InterfaceDeclaration */) { + if (node.kind === 230 /* 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 @@ -39884,7 +41625,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 135 /* StringKeyword */: + case 136 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -39892,7 +41633,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 132 /* NumberKeyword */: + case 133 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -39957,15 +41698,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 98 /* ThisKeyword */) { + if (n.kind === 99 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 185 /* FunctionExpression */ && n.kind !== 227 /* FunctionDeclaration */) { + else if (n.kind !== 186 /* FunctionExpression */ && n.kind !== 228 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 148 /* PropertyDeclaration */ && + return n.kind === 149 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -39995,7 +41736,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -40019,7 +41760,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 152 /* GetAccessor */) { + if (node.kind === 153 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -40029,13 +41770,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* 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 === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; + var otherKind = node.kind === 153 /* GetAccessor */ ? 154 /* SetAccessor */ : 153 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -40051,17 +41792,12 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 152 /* GetAccessor */) { + if (node.kind === 153 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 177 /* ObjectLiteralExpression */) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - else { - checkNodeDeferred(node); - } + checkSourceElement(node.body); + registerForUnusedIdentifiersCheck(node); } function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { var firstType = getAnnotatedType(first); @@ -40070,10 +41806,6 @@ var ts; error(first, message); } } - function checkAccessorDeferred(node) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } function checkMissingDeclaration(node) { checkDecorators(node); } @@ -40177,9 +41909,9 @@ var ts; var flags = ts.getCombinedModifierFlags(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 !== 229 /* InterfaceDeclaration */ && - n.parent.kind !== 228 /* ClassDeclaration */ && - n.parent.kind !== 198 /* ClassExpression */ && + if (n.parent.kind !== 230 /* InterfaceDeclaration */ && + n.parent.kind !== 229 /* ClassDeclaration */ && + n.parent.kind !== 199 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -40267,7 +41999,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */) && + var reportError = (node.kind === 151 /* MethodDeclaration */ || node.kind === 150 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -40306,7 +42038,7 @@ var ts; var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 229 /* InterfaceDeclaration */ || node.parent.kind === 162 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 230 /* InterfaceDeclaration */ || node.parent.kind === 163 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -40317,7 +42049,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 === 227 /* FunctionDeclaration */ || node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */ || node.kind === 151 /* Constructor */) { + if (node.kind === 228 /* FunctionDeclaration */ || node.kind === 151 /* MethodDeclaration */ || node.kind === 150 /* MethodSignature */ || node.kind === 152 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -40369,8 +42101,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; + for (var _a = 0, signatures_4 = signatures; _a < signatures_4.length; _a++) { + var signature = signatures_4[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -40439,16 +42171,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -40458,26 +42190,16 @@ var ts; } } } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - var apparentType = getApparentType(type); - if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; + function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage) { + var promisedType = getPromisedTypeOfPromise(type, errorNode); + return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage); } /** - * Gets the "promised type" of a promise. - * @param type The type of the promise. - * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. - */ - function getPromisedType(promise) { + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedTypeOfPromise(promise, errorNode) { // // { // promise // then( // thenFunction @@ -40490,22 +42212,22 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (getObjectFlags(promise) & 4 /* Reference */) { - if (promise.target === tryGetGlobalPromiseType() - || promise.target === getGlobalPromiseLikeType()) { - return promise.typeArguments[0]; - } + var typeAsPromise = promise; + if (typeAsPromise.promisedTypeOfPromise) { + return typeAsPromise.promisedTypeOfPromise; } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; + if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { + return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (!thenFunction || isTypeAny(thenFunction)) { + if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = getSignaturesOfType(thenFunction, 0 /* Call */); + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; if (thenSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); + } return undefined; } var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); @@ -40514,103 +42236,116 @@ var ts; } var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); if (onfulfilledParameterSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); + } return undefined; } - return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true); - } - function getTypeOfFirstParameterOfSignature(signature) { - return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true); } /** - * Gets the "awaited type" of a type. - * @param type The type to await. - * @remarks The "awaited type" of an expression is its "promised type" if the expression is a - * Promise-like type; otherwise, it is the type of the expression. This is used to reflect - * The runtime behavior of the `await` keyword. - */ - function getAwaitedType(type) { - return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function checkAwaitedType(type, errorNode, diagnosticMessage) { + return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 65536 /* Union */) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types, /*subtypeReduction*/ true); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - // The type was not a PromiseLike, so it could not be unwrapped any further. - // As long as the type does not have a callable "then" property, it is - // safe to return the type; otherwise, an error will have been reported in - // the call to checkNonThenableType and we will return unknownType. - // - // An example of a non-promise "thenable" might be: - // - // await { then(): void {} } - // - // The "thenable" does not match the minimal definition for a PromiseLike. When - // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise - // will never settle. We treat this as an error to help flag an early indicator - // of a runtime problem. If the user wants to return this value from an async - // function, they would need to wrap it in some other value. If they want it to - // be treated as a promise, they can cast to . - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { - // We have a bad actor in the form of a promise whose promised type is - // the same promise type, or a mutually recursive promise. Return the - // unknown type as we cannot guess the shape. If this were the actual - // case in the JavaScript, this Promise would never resolve. - // - // An example of a bad actor with a singly-recursive promise type might - // be: - // - // interface BadPromise { - // then( - // onfulfilled: (value: BadPromise) => any, - // onrejected: (error: any) => any): BadPromise; - // } - // - // The above interface will pass the PromiseLike check, and return a - // promised type of `BadPromise`. Since this is a self reference, we - // don't want to keep recursing ad infinitum. - // - // An example of a bad actor in the form of a mutually-recursive - // promise type might be: - // - // interface BadPromiseA { - // then( - // onfulfilled: (value: BadPromiseB) => any, - // onrejected: (error: any) => any): BadPromiseB; - // } - // - // interface BadPromiseB { - // then( - // onfulfilled: (value: BadPromiseA) => any, - // onrejected: (error: any) => any): BadPromiseA; - // } - // - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - // Keep track of the type we're about to unwrap to avoid bad recursive promise types. - // See the comments above for more information. - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } + function getAwaitedType(type, errorNode, diagnosticMessage) { + var typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } + if (isTypeAny(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + if (type.flags & 65536 /* Union */) { + var types = void 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types = ts.append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage)); + } + if (!types) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, /*subtypeReduction*/ true); + } + var promisedType = getPromisedTypeOfPromise(type); + if (promisedType) { + if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { + // Verify that we don't have a bad actor in the form of a promise whose + // promised type is the same as the promise type, or a mutually recursive + // promise. If so, we return undefined as we cannot guess the shape. If this + // were the actual case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage); + awaitedTypeStack.pop(); + if (!awaitedType) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = awaitedType; + } + // The type was not a promise, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will be reported in + // the call to getNonThenableType and we will return undefined. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a promise. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + var thenFunction = getTypeOfPropertyOfType(type, "then"); + if (thenFunction && getSignaturesOfType(thenFunction, 0 /* Call */).length > 0) { + if (errorNode) { + ts.Debug.assert(!!diagnosticMessage); + error(errorNode, diagnosticMessage); + } + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = type; } /** * Checks the return type of an async function to ensure it is a compatible @@ -40655,8 +42390,8 @@ var ts; if (returnType === unknownType) { return unknownType; } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); + if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // 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(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); @@ -40677,7 +42412,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - if (promiseConstructorName.kind === 70 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -40685,7 +42420,7 @@ var ts; } return unknownType; } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. @@ -40704,7 +42439,7 @@ var ts; } } // Get and return the awaited type of the return type. - return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } /** Check a decorator */ function checkDecorator(node) { @@ -40717,22 +42452,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 145 /* Parameter */: + case 146 /* 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 148 /* PropertyDeclaration */: + case 149 /* 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 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -40747,7 +42482,7 @@ var ts; function markTypeNodeAsReferenced(node) { var typeName = node && ts.getEntityNameFromTypeNode(node); var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 71 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && symbolIsValue(rootSymbol) @@ -40773,14 +42508,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -40789,19 +42524,19 @@ var ts; } } break; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 145 /* Parameter */: + case 146 /* Parameter */: markTypeNodeAsReferenced(node.type); break; } @@ -40821,11 +42556,11 @@ var ts; function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); + var functionFlags = ts.getFunctionFlags(node); // 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 === 143 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 144 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -40856,17 +42591,19 @@ var ts; } } checkSourceElement(node.body); - if (!node.asteriskToken) { - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if ((functionFlags & 1 /* Generator */) === 0) { + var returnOrPromisedType = node.type && (functionFlags & 2 /* Async */ + ? checkAsyncFunctionReturnType(node) // Async function + : getTypeFromTypeNode(node.type)); // normal function checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method // in an ambient context - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(node.body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -40885,55 +42622,54 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 264 /* SourceFile */: - case 232 /* ModuleDeclaration */: + case 265 /* SourceFile */: + case 233 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 206 /* Block */: - case 234 /* CaseBlock */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 207 /* Block */: + case 235 /* CaseBlock */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 151 /* Constructor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 152 /* Constructor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: checkUnusedTypeParameters(node); break; } - ; } } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 229 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 230 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 146 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -40959,13 +42695,13 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 225 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 214 /* ForInStatement */ || - declaration.parent.parent.kind === 215 /* ForOfStatement */)) { + if (declaration.kind === 226 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 215 /* ForInStatement */ || + declaration.parent.parent.kind === 216 /* ForOfStatement */)) { return; } } - if (!isRemovedPropertyFromObjectSpread(node.kind === 70 /* Identifier */ ? node.parent : node)) { + if (!isRemovedPropertyFromObjectSpread(node.kind === 71 /* Identifier */ ? node.parent : node)) { error(node, ts.Diagnostics._0_is_declared_but_never_used, name); } } @@ -40973,19 +42709,19 @@ var ts; return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); } function isIdentifierThatStartsWithUnderScore(node) { - return node.kind === 70 /* Identifier */ && node.text.charCodeAt(0) === 95 /* _ */; + return node.kind === 71 /* Identifier */ && node.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* MethodDeclaration */ || member.kind === 148 /* PropertyDeclaration */) { + if (member.kind === 151 /* MethodDeclaration */ || member.kind === 149 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 151 /* Constructor */) { + else if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -41032,7 +42768,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 206 /* Block */) { + if (node.kind === 207 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -41055,12 +42791,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 148 /* PropertyDeclaration */ || - node.kind === 147 /* PropertySignature */ || - node.kind === 150 /* MethodDeclaration */ || - node.kind === 149 /* MethodSignature */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 149 /* PropertyDeclaration */ || + node.kind === 148 /* PropertySignature */ || + node.kind === 151 /* MethodDeclaration */ || + node.kind === 150 /* MethodSignature */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -41069,7 +42805,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 145 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 146 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -41087,36 +42823,32 @@ var ts; } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 70 /* Identifier */; + var isDeclaration_1 = node.kind !== 71 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; + var isDeclaration_2 = node.kind !== 71 /* Identifier */; if (isDeclaration_2) { error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { @@ -41129,7 +42861,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_3 = node.kind !== 70 /* Identifier */; + var isDeclaration_3 = node.kind !== 71 /* Identifier */; if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -41147,12 +42879,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 233 /* 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 === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 265 /* 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)); } @@ -41162,12 +42894,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 233 /* 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 === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 265 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* 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)); } @@ -41202,7 +42934,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 225 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 226 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -41212,17 +42944,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 207 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 227 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 208 /* 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 === 206 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 233 /* ModuleBlock */ || - container.kind === 232 /* ModuleDeclaration */ || - container.kind === 264 /* SourceFile */); + (container.kind === 207 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 234 /* ModuleBlock */ || + container.kind === 233 /* ModuleDeclaration */ || + container.kind === 265 /* 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 @@ -41237,7 +42969,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 !== 145 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 146 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -41248,11 +42980,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 178 /* PropertyAccessExpression */) { + if (n.kind === 179 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 70 /* Identifier */) { + else if (n.kind === 71 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -41267,27 +42999,26 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 145 /* Parameter */ || - symbol.valueDeclaration.kind === 175 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 146 /* Parameter */ || + symbol.valueDeclaration.kind === 176 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { return; } // - parameter is wrapped in function-like entity - var current = n; - while (current !== node.initializer) { - if (ts.isFunctionLike(current.parent)) { - return; + if (ts.findAncestor(n, function (current) { + if (current === node.initializer) { + return "quit"; } - // computed property names/initializers in instance property declaration of class like entities - // are executed in constructor and thus deferred - if (current.parent.kind === 148 /* PropertyDeclaration */ && - !(ts.hasModifier(current.parent, 32 /* Static */)) && - ts.isClassLike(current.parent.parent)) { - return; - } - current = current.parent; + return ts.isFunctionLike(current.parent) || + // computed property names/initializers in instance property declaration of class like entities + // are executed in constructor and thus deferred + (current.parent.kind === 149 /* PropertyDeclaration */ && + !(ts.hasModifier(current.parent, 32 /* Static */)) && + ts.isClassLike(current.parent.parent)); + })) { + return; } // fall through to report error } @@ -41310,18 +43041,18 @@ 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 === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 175 /* BindingElement */) { - if (node.parent.kind === 173 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { + if (node.kind === 176 /* BindingElement */) { + if (node.parent.kind === 174 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 143 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -41336,17 +43067,20 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { + if (node.name.kind === 175 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* Read */); + } 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 === 145 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 146 /* 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 !== 214 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 215 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -41357,7 +43091,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 !== 214 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 215 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -41377,10 +43111,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */) { + if (node.kind !== 149 /* PropertyDeclaration */ && node.kind !== 148 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */) { + if (node.kind === 226 /* VariableDeclaration */ || node.kind === 176 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -41391,8 +43125,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 145 /* Parameter */ && right.kind === 225 /* VariableDeclaration */) || - (left.kind === 225 /* VariableDeclaration */ && right.kind === 145 /* Parameter */)) { + if ((left.kind === 146 /* Parameter */ && right.kind === 226 /* VariableDeclaration */) || + (left.kind === 226 /* VariableDeclaration */ && right.kind === 146 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -41422,8 +43156,8 @@ 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 === 177 /* ObjectLiteralExpression */) { - if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers && node.parent.kind === 178 /* ObjectLiteralExpression */) { + if (ts.getFunctionFlags(node) & 2 /* Async */) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -41443,7 +43177,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 208 /* EmptyStatement */) { + if (node.thenStatement.kind === 209 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -41463,12 +43197,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 226 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 227 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 226 /* VariableDeclarationList */) { + if (node.initializer.kind === 227 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -41486,19 +43220,29 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); + if (node.kind === 216 /* ForOfStatement */) { + if (node.awaitModifier) { + if (languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 8192 /* ForAwaitOfIncludes */); + } + } + else if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + } + } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // 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 === 226 /* VariableDeclarationList */) { + if (node.initializer.kind === 227 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); + var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { + if (varExpr.kind === 177 /* ArrayLiteralExpression */ || varExpr.kind === 178 /* 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. @@ -41530,7 +43274,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 === 226 /* VariableDeclarationList */) { + if (node.initializer.kind === 227 /* 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); @@ -41544,7 +43288,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 === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { + if (varExpr.kind === 177 /* ArrayLiteralExpression */ || varExpr.kind === 178 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -41557,7 +43301,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -41573,52 +43317,113 @@ var ts; checkVariableDeclaration(decl); } } - function checkRightHandSideOfForOf(rhsExpression) { + function checkRightHandSideOfForOf(rhsExpression, awaitModifier) { var expressionType = checkNonNullExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable) { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2 /* ES2015 */) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1 /* Number */); - if (indexType) { - return indexType; - } - } - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - } - return unknownType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, /*checkAssignability*/ true) || anyType; } /** - * When errorNode is undefined, it means we should not report any errors. + * When consuming an iterable type in a for..of, spread, or iterator destructuring assignment + * we want to get the iterated type of an iterable for ES2015 or later, or the iterated type + * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - // Now even though we have extracted the iteratedType, we will have to validate that the type - // passed in is actually an Iterable. - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, checkAssignability) { + var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 + // or higher, when inside of an async generator or for-await-if, or when + // downlevelIteration is requested. + if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + // We only report errors for an invalid iterable type in ES2015 or higher. + var iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + if (iteratedType || uplevelIteration) { + return iteratedType; + } } - return elementType || anyType; + var arrayType = inputType; + var reportedError = false; + var hasStringConstituent = false; + // If strings are permitted, remove any string-like constituents from the array type. + // This allows us to find other non-string element types from an array unioned with + // a string. + if (allowStringInput) { + if (arrayType.flags & 65536 /* Union */) { + // After we remove all types that are StringLike, we will know if there was a string constituent + // based on whether the result of filter is a new array. + var arrayTypes = inputType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178 /* StringLike */); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); + } + } + else if (arrayType.flags & 262178 /* StringLike */) { + arrayType = neverType; + } + hasStringConstituent = arrayType !== inputType; + if (hasStringConstituent) { + if (languageVersion < 1 /* ES5 */) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + } + // Now that we've removed all the StringLike types, if no constituents remain, then the entire + // arrayOrStringType was a string. + if (arrayType.flags & 8192 /* Never */) { + return stringType; + } + } + } + if (!isArrayLikeType(arrayType)) { + if (errorNode && !reportedError) { + // Which error we report depends on whether we allow strings or if there was a + // string constituent. For example, if the input type is number | string, we + // want to say that number is not an array type. But if the input was just + // number and string input is allowed, we want to say that number is not an + // array type or a string type. + var diagnostic = !allowStringInput || hasStringConstituent + ? downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type + : downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : undefined; + } + var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); + if (hasStringConstituent && arrayElementType) { + // This is just an optimization for the case where arrayOrStringType is string | string[] + if (arrayElementType.flags & 262178 /* StringLike */) { + return stringType; + } + return getUnionType([arrayElementType, stringType], /*subtypeReduction*/ true); + } + return arrayElementType; } /** * We want to treat type as an iterable, and get the type it is an iterable of. The iterable * must have the following structure (annotated with the names of the variables below): * - * { // iterable - * [Symbol.iterator]: { // iteratorFunction - * (): Iterator + * { // iterable + * [Symbol.iterator]: { // iteratorMethod + * (): Iterator + * } + * } + * + * For an async iterable, we expect the following structure: + * + * { // iterable + * [Symbol.asyncIterator]: { // iteratorMethod + * (): AsyncIterator + * } * } - * } * * T is the type we are after. At every level that involves analyzing return types * of signatures, we union the return types of all the signatures. @@ -41630,166 +43435,170 @@ var ts; * caller requested it. Then the caller can decide what to do in the case where there is no iterated * type. This is different from returning anyType, because that would signify that we have matched the * whole pattern and that T (above) is 'any'. + * + * For a **for-of** statement, `yield*` (in a normal generator), spread, array + * destructuring, or normal generator we will only ever look for a `[Symbol.iterator]()` + * method. + * + * For an async generator we will only ever look at the `[Symbol.asyncIterator]()` method. + * + * For a **for-await-of** statement or a `yield*` in an async generator we will look for + * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ - function getElementTypeOfIterable(type, errorNode) { + function getIteratedTypeOfIterable(type, errorNode, isAsyncIterable, allowNonAsyncIterables, checkAssignability) { if (isTypeAny(type)) { return undefined; } var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), - // then just grab its type argument. - if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableType()) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0 /* Call */) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true), errorNode); + if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { + return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; + } + if (isAsyncIterable) { + // As an optimization, if the type is an instantiation of the global `AsyncIterable` + // or the global `AsyncIterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0]; } } - return typeAsIterable.iterableElementType; + if (!isAsyncIterable || allowNonAsyncIterables) { + // As an optimization, if the type is an instantiation of the global `Iterable` or + // `IterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0] + : typeAsIterable.iteratedTypeOfIterable = type.typeArguments[0]; + } + } + var iteratorMethodSignatures; + var isNonAsyncIterable = false; + if (isAsyncIterable) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0 /* Call */); + } + if (!isAsyncIterable || (allowNonAsyncIterables && !ts.some(iteratorMethodSignatures))) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0 /* Call */); + isNonAsyncIterable = true; + } + if (ts.some(iteratorMethodSignatures)) { + var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ !isNonAsyncIterable); + if (checkAssignability && errorNode && iteratedType) { + // If `checkAssignability` was specified, we were called from + // `checkIteratedTypeOrElementType`. As such, we need to validate that + // the type passed in is actually an Iterable. + checkTypeAssignableTo(type, isNonAsyncIterable + ? createIterableType(iteratedType) + : createAsyncIterableType(iteratedType), errorNode); + } + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType + : typeAsIterable.iteratedTypeOfIterable = iteratedType; + } + if (errorNode) { + error(errorNode, isAsyncIterable + ? ts.Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; } /** - * This function has very similar logic as getElementTypeOfIterable, except that it operates on + * This function has very similar logic as getIteratedTypeOfIterable, except that it operates on * Iterators instead of Iterables. Here is the structure: * * { // iterator - * next: { // iteratorNextFunction - * (): { // iteratorNextResult - * value: T // iteratorNextValue + * next: { // nextMethod + * (): { // nextResult + * value: T // nextValue * } * } * } * + * For an async iterator, we expect the following structure: + * + * { // iterator + * next: { // nextMethod + * (): PromiseLike<{ // nextResult + * value: T // nextValue + * }> + * } + * } */ - function getElementTypeOfIterator(type, errorNode) { + function getIteratedTypeOfIterator(type, errorNode, isAsyncIterator) { if (isTypeAny(type)) { return undefined; } var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), - // then just grab its type argument. - if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIteratorType()) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0 /* Call */) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } + if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { + return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { + // As an optimization, if the type is an instantiation of the global `Iterator` (for + // a non-async iterator) or the global `AsyncIterator` (for an async-iterator) then + // just grab its type argument. + var getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; + if (isReferenceToType(type, getIteratorType(/*reportErrors*/ false))) { + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = type.typeArguments[0] + : typeAsIterator.iteratedTypeOfIterator = type.typeArguments[0]; + } + // Both async and non-async iterators must have a `next` method. + var nextMethod = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(nextMethod)) { return undefined; } - // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), - // then just grab its type argument. - if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableIteratorType()) { - return type.typeArguments[0]; + var nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, 0 /* Call */) : emptyArray; + if (nextMethodSignatures.length === 0) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.An_async_iterator_must_have_a_next_method + : ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; } - return getElementTypeOfIterable(type, /*errorNode*/ undefined) || - getElementTypeOfIterator(type, /*errorNode*/ undefined); + var nextResult = getUnionType(ts.map(nextMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + if (isTypeAny(nextResult)) { + return undefined; + } + // For an async iterator, we must get the awaited type of the return type. + if (isAsyncIterator) { + nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); + if (isTypeAny(nextResult)) { + return undefined; + } + } + var nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value"); + if (!nextValue) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue + : typeAsIterator.iteratedTypeOfIterator = nextValue; } /** - * 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 constituent. - * - * For example: - * string -> string - * number[] -> number - * string[] | number[] -> string | number - * string | number[] -> string | number - * string | string[] | number[] -> string | number - * - * It also errors if: - * 1. Some constituent is neither a string nor an array. - * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). + * A generator may have a return type of `Iterator`, `Iterable`, or + * `IterableIterator`. An async generator may have a return type of `AsyncIterator`, + * `AsyncIterable`, or `AsyncIterableIterator`. This function can be used to extract + * the iterated type from this return type for contextual typing and verifying signatures. */ - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2 /* ES2015 */); - var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 65536 /* Union */) { - // After we remove all types that are StringLike, we will know if there was a string constituent - // based on whether the result of filter is a new array. - var arrayTypes = arrayOrStringType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178 /* StringLike */); }); - if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); - } + function getIteratedTypeOfGenerator(returnType, isAsyncGenerator) { + if (isTypeAny(returnType)) { + return undefined; } - else if (arrayOrStringType.flags & 262178 /* StringLike */) { - arrayType = neverType; - } - var hasStringConstituent = arrayOrStringType !== arrayType; - var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; - } - // Now that we've removed all the StringLike types, if no constituents remain, then the entire - // arrayOrStringType was a string. - if (arrayType.flags & 8192 /* Never */) { - return stringType; - } - } - if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - // Which error we report depends on whether there was a string constituent. For example, - // if the input type is number | string, we want to say that number is not an array type. - // But if the input was just number, we want to say that number is not an array type - // or a string type. - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; - error(errorNode, diagnostic, typeToString(arrayType)); - } - return hasStringConstituent ? stringType : unknownType; - } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; - if (hasStringConstituent) { - // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 262178 /* StringLike */) { - return stringType; - } - return getUnionType([arrayElementType, stringType], /*subtypeReduction*/ true); - } - return arrayElementType; + return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, isAsyncGenerator, /*allowNonAsyncIterables*/ false, /*checkAssignability*/ false) + || getIteratedTypeOfIterator(returnType, /*errorNode*/ undefined, isAsyncGenerator); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -41797,10 +43606,12 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153 /* SetAccessor */))); + return !!(node.kind === 153 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 154 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { - var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; + var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */ + ? getPromisedTypeOfPromise(returnType) // Async function + : returnType; // AsyncGenerator function, Generator function, or normal function return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 1024 /* Void */ | 1 /* Any */); } function checkReturnStatement(node) { @@ -41817,27 +43628,28 @@ var ts; var returnType = getReturnTypeOfSignature(signature); if (strictNullChecks || node.expression || returnType.flags & 8192 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.asteriskToken) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1 /* Generator */) { // A generator does not need its return expressions checked against its return type. // Instead, the yield expressions are checked against the element type. // TODO: Check return expressions of generators when return type tracking is added // for generators. return; } - if (func.kind === 153 /* SetAccessor */) { + if (func.kind === 154 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 151 /* Constructor */) { + else if (func.kind === 152 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (functionFlags & 2 /* Async */) { + var promisedType = getPromisedTypeOfPromise(returnType); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType @@ -41850,7 +43662,7 @@ var ts; } } } - else if (func.kind !== 151 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 152 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -41880,7 +43692,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 257 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 258 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -41892,7 +43704,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 256 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 257 /* 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 comparable @@ -41918,18 +43730,16 @@ var ts; function checkLabeledStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { + ts.findAncestor(node.parent, function (current) { if (ts.isFunctionLike(current)) { - break; + return "quit"; } - if (current.kind === 221 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 222 /* 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; + return true; } - current = current.parent; - } + }); } // ensure that label is unique checkSourceElement(node.statement); @@ -42027,7 +43837,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 (propDeclaration && (propDeclaration.name.kind === 143 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { + if (propDeclaration && (propDeclaration.name.kind === 144 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { @@ -42165,7 +43975,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); @@ -42188,7 +43998,7 @@ var ts; } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (languageVersion < 2 /* ES2015 */ && !ts.isInAmbientContext(node)) { + if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } var baseTypes = getBaseTypes(type); @@ -42200,7 +44010,7 @@ var ts; checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { var constructor = _a[_i]; if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; @@ -42212,19 +44022,12 @@ var ts; if (baseConstructorType.flags & 540672 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && - !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 228 /* ClassDeclaration */) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { - error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 540672 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // 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); + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); 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); } @@ -42280,7 +44083,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 228 /* ClassDeclaration */ || d.kind === 229 /* InterfaceDeclaration */; + return d.kind === 229 /* ClassDeclaration */ || d.kind === 230 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -42319,7 +44122,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 || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 198 /* ClassExpression */) { + if (derivedClassDecl.kind === 199 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -42330,7 +44133,7 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 8 /* Private */) || (derivedDeclarationFlags & 8 /* Private */)) { + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { // either base or derived property is private - not override, skip it continue; } @@ -42338,36 +44141,32 @@ var ts; // value of 'static' is not the same for properties - not override, skip it continue; } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } var errorMessage = void 0; - if (base.flags & 8192 /* Method */) { + if (isMethodLike(base)) { if (derived.flags & 98304 /* Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } } function isAccessor(kind) { - return kind === 152 /* GetAccessor */ || kind === 153 /* SetAccessor */; + return kind === 153 /* GetAccessor */ || kind === 154 /* SetAccessor */; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -42380,8 +44179,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.name); if (!existing) { seen.set(prop.name, { prop: prop, containingType: base }); @@ -42392,7 +44191,7 @@ var ts; ok = false; var typeName1 = typeToString(existing.containingType); var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); } @@ -42411,7 +44210,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 230 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -42518,18 +44317,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 36 /* PlusToken */: return value_1; - case 37 /* MinusToken */: return -value_1; - case 51 /* TildeToken */: return ~value_1; + case 37 /* PlusToken */: return value_1; + case 38 /* MinusToken */: return -value_1; + case 52 /* TildeToken */: return ~value_1; } return undefined; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -42539,32 +44338,32 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 48 /* BarToken */: return left | right; - case 47 /* AmpersandToken */: return left & right; - case 45 /* GreaterThanGreaterThanToken */: return left >> right; - case 46 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 44 /* LessThanLessThanToken */: return left << right; - case 49 /* CaretToken */: return left ^ right; - case 38 /* AsteriskToken */: return left * right; - case 40 /* SlashToken */: return left / right; - case 36 /* PlusToken */: return left + right; - case 37 /* MinusToken */: return left - right; - case 41 /* PercentToken */: return left % right; + case 49 /* BarToken */: return left | right; + case 48 /* AmpersandToken */: return left & right; + case 46 /* GreaterThanGreaterThanToken */: return left >> right; + case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 45 /* LessThanLessThanToken */: return left << right; + case 50 /* CaretToken */: return left ^ right; + case 39 /* AsteriskToken */: return left * right; + case 41 /* SlashToken */: return left / right; + case 37 /* PlusToken */: return left + right; + case 38 /* MinusToken */: return left - right; + case 42 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(e); return +e.text; - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 70 /* Identifier */: - case 179 /* ElementAccessExpression */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 180 /* ElementAccessExpression */: + case 179 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 70 /* Identifier */) { + if (e.kind === 71 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -42572,7 +44371,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 179 /* ElementAccessExpression */) { + if (e.kind === 180 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -42587,10 +44386,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 70 /* Identifier */) { + if (current.kind === 71 /* Identifier */) { break; } - else if (current.kind === 178 /* PropertyAccessExpression */) { + else if (current.kind === 179 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -42663,7 +44462,7 @@ var ts; 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 !== 231 /* EnumDeclaration */) { + if (declaration.kind !== 232 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -42686,8 +44485,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 228 /* ClassDeclaration */ || - (declaration.kind === 227 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 229 /* ClassDeclaration */ || + (declaration.kind === 228 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -42751,7 +44550,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, 228 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 229 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -42802,23 +44601,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 207 /* VariableStatement */: + case 208 /* 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 242 /* ExportAssignment */: - case 243 /* ExportDeclaration */: + case 243 /* ExportAssignment */: + case 244 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 236 /* ImportEqualsDeclaration */: - case 237 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 238 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 175 /* BindingElement */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 226 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -42828,13 +44627,13 @@ var ts; } break; } - // fallthrough - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 227 /* FunctionDeclaration */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 230 /* TypeAliasDeclaration */: + // falls through + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 228 /* FunctionDeclaration */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 231 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -42855,17 +44654,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return node; - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 70 /* Identifier */); + } while (node.kind !== 71 /* Identifier */); return node; - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 70 /* Identifier */); + } while (node.kind !== 71 /* Identifier */); return node; } } @@ -42875,9 +44674,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 243 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 234 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 265 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 244 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -42910,7 +44709,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 245 /* ExportSpecifier */ ? + var message = node.kind === 246 /* 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)); @@ -42938,7 +44737,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 240 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -42995,10 +44794,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 234 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 234 /* ModuleBlock */ && !node.moduleSpecifier && ts.isInAmbientContext(node); - if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 265 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -43012,7 +44811,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 264 /* SourceFile */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 232 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 265 /* SourceFile */ || node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 233 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -43038,8 +44837,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 264 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 232 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 265 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 233 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -43052,7 +44851,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 70 /* Identifier */) { + if (node.expression.kind === 71 /* Identifier */) { markExportAsReferenced(node); } else { @@ -43114,7 +44913,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 227 /* FunctionDeclaration */ && declaration.kind !== 150 /* MethodDeclaration */) || + return (declaration.kind !== 228 /* FunctionDeclaration */ && declaration.kind !== 151 /* MethodDeclaration */) || !!declaration.body; } } @@ -43127,123 +44926,123 @@ var ts; // 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 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 227 /* FunctionDeclaration */: + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 228 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return checkTypeParameter(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return checkParameter(node); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return checkPropertyDeclaration(node); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return checkSignatureDeclaration(node); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return checkMethodDeclaration(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return checkConstructorDeclaration(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return checkAccessorDeclaration(node); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return checkTypeReferenceNode(node); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return checkTypePredicate(node); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return checkTypeQuery(node); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return checkTypeLiteral(node); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return checkArrayType(node); - case 164 /* TupleType */: + case 165 /* TupleType */: return checkTupleType(node); - case 165 /* UnionType */: - case 166 /* IntersectionType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 167 /* ParenthesizedType */: - case 169 /* TypeOperator */: + case 168 /* ParenthesizedType */: + case 170 /* TypeOperator */: return checkSourceElement(node.type); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 171 /* MappedType */: + case 172 /* MappedType */: return checkMappedType(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 206 /* Block */: - case 233 /* ModuleBlock */: + case 207 /* Block */: + case 234 /* ModuleBlock */: return checkBlock(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return checkVariableStatement(node); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return checkExpressionStatement(node); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return checkIfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return checkDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return checkWhileStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return checkForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return checkForInStatement(node); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return checkForOfStatement(node); - case 216 /* ContinueStatement */: - case 217 /* BreakStatement */: + case 217 /* ContinueStatement */: + case 218 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return checkReturnStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return checkWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return checkSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return checkLabeledStatement(node); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return checkThrowStatement(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return checkTryStatement(node); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 175 /* BindingElement */: + case 176 /* BindingElement */: return checkBindingElement(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return checkClassDeclaration(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return checkImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return checkExportDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return checkExportAssignment(node); - case 208 /* EmptyStatement */: + case 209 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 224 /* DebuggerStatement */: + case 225 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 246 /* MissingDeclaration */: + case 247 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -43265,17 +45064,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - checkAccessorDeferred(node); + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + checkAccessorDeclaration(node); break; - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -43381,7 +45180,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 219 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 220 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -43390,12 +45189,12 @@ var ts; return false; } function getSymbolsInScope(location, meaning) { - var symbols = ts.createMap(); - var memberFlags = 0 /* None */; if (isInsideWithStatementBody(location)) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } + var symbols = ts.createMap(); + var memberFlags = 0 /* None */; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -43404,25 +45203,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232 /* ModuleDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // fall through; this fall-through is necessary because we would like to handle + // falls 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 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* 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. @@ -43431,7 +45232,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -43473,34 +45274,34 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 70 /* Identifier */ && + return name.kind === 71 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 144 /* TypeParameter */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 231 /* EnumDeclaration */: + case 145 /* TypeParameter */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 232 /* 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 === 142 /* QualifiedName */) { + while (node.parent && node.parent.kind === 143 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 158 /* TypeReference */ || node.parent.kind === 276 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 159 /* TypeReference */ || node.parent.kind === 277 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 178 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 179 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 200 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 201 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -43517,13 +45318,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 142 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 143 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 237 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 243 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -43531,29 +45332,38 @@ var ts; function isInRightSideOfImportOrExportAssignment(node) { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } + function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { + 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 */: + case 5 /* Property */: + return getSymbolOfNode(entityName.parent.parent); + } + } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178 /* 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 (ts.isInJavaScriptFile(entityName) && + entityName.parent.kind === 179 /* PropertyAccessExpression */ && + entityName.parent === entityName.parent.parent.left) { + // Check if this is a special property assignment + var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); + if (specialPropertyAssignmentSymbol) { + return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 242 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 243 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 178 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 179 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 236 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 237 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -43563,7 +45373,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 === 200 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 201 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -43574,27 +45384,30 @@ var ts; meaning = 1920 /* Namespace */; } meaning |= 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); + var entityNameSymbol = resolveEntityName(entityName, meaning); + if (entityNameSymbol) { + return entityNameSymbol; + } } - else if (ts.isPartOfExpression(entityName)) { + if (ts.isPartOfExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { // Missing entity name. return undefined; } - if (entityName.kind === 70 /* Identifier */) { + if (entityName.kind === 71 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 178 /* PropertyAccessExpression */) { + else if (entityName.kind === 179 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 142 /* QualifiedName */) { + else if (entityName.kind === 143 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -43603,20 +45416,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 158 /* TypeReference */ || entityName.parent.kind === 276 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 159 /* TypeReference */ || entityName.parent.kind === 277 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 252 /* JsxAttribute */) { + else if (entityName.parent.kind === 253 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 157 /* TypePredicate */) { + if (entityName.parent.kind === 158 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -43630,12 +45443,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 175 /* BindingElement */ && - node.parent.parent.kind === 173 /* ObjectBindingPattern */ && + else if (node.parent.kind === 176 /* BindingElement */ && + node.parent.parent.kind === 174 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -43645,11 +45458,11 @@ var ts; } } switch (node.kind) { - case 70 /* Identifier */: - case 178 /* PropertyAccessExpression */: - case 142 /* QualifiedName */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: + case 143 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -43657,16 +45470,16 @@ var ts; return sig.thisParameter; } } - // fallthrough - case 96 /* SuperKeyword */: + // falls through + case 97 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 168 /* ThisType */: + case 169 /* ThisType */: return getTypeFromTypeNode(node).symbol; - case 122 /* ConstructorKeyword */: + case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 151 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 152 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -43674,17 +45487,17 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 237 /* ImportDeclaration */ || node.parent.kind === 243 /* ExportDeclaration */) && + ((node.parent.kind === 238 /* ImportDeclaration */ || node.parent.kind === 244 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) { return resolveExternalModuleName(node, node); } - // Fall through + // falls through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -43701,7 +45514,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 === 261 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 262 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -43718,7 +45531,13 @@ var ts; return unknownType; } if (ts.isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + var typeFromTypeNode = getTypeFromTypeNode(node); + if (typeFromTypeNode && ts.isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + var containingClass = ts.getContainingClass(node); + var classType = getTypeOfNode(containingClass); + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + return typeFromTypeNode; } if (ts.isPartOfExpression(node)) { return getRegularTypeOfExpression(node); @@ -43726,7 +45545,10 @@ var ts; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + var classNode = ts.getContainingClass(node); + var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)); + var baseType = getBaseTypes(classType)[0]; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration @@ -43763,31 +45585,31 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 177 /* ObjectLiteralExpression */ || expr.kind === 176 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 178 /* ObjectLiteralExpression */ || expr.kind === 177 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 215 /* ForOfStatement */) { - var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); + if (expr.parent.kind === 216 /* ForOfStatement */) { + var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 193 /* BinaryExpression */) { + if (expr.parent.kind === 194 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 260 /* PropertyAssignment */) { + if (expr.parent.kind === 261 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 176 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 177 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -43808,9 +45630,9 @@ var ts; return getRegularTypeOfLiteralType(getTypeOfExpression(expr)); } /** - * Gets either the static or instance type of a class element, based on - * whether the element is declared as "static". - */ + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); return ts.getModifierFlags(node) & 32 /* Static */ @@ -43832,7 +45654,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (getCheckFlags(symbol) & 2 /* SyntheticProperty */) { + if (getCheckFlags(symbol) & 6 /* Synthetic */) { var symbols_3 = []; var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { @@ -43846,10 +45668,10 @@ var ts; else if (symbol.flags & 134217728 /* Transient */) { if (symbol.leftSpread) { var links = symbol; - return [links.leftSpread, links.rightSpread]; + return getRootSymbols(links.leftSpread).concat(getRootSymbols(links.rightSpread)); } - if (symbol.mappedTypeOrigin) { - return getRootSymbols(symbol.mappedTypeOrigin); + if (symbol.syntheticOrigin) { + return getRootSymbols(symbol.syntheticOrigin); } var target = void 0; var next = symbol; @@ -43867,7 +45689,7 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -43922,20 +45744,16 @@ var ts; } symbol = exportSymbol; } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 264 /* SourceFile */) { - var symbolFile = parentSymbol.valueDeclaration; + var parentSymbol_1 = getParentOfSymbol(symbol); + if (parentSymbol_1) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 265 /* SourceFile */) { + var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. var symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - for (var n = node.parent; n; n = n.parent) { - if (ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } + return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; }); } } } @@ -43981,7 +45799,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 206 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 207 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -44021,24 +45839,19 @@ var ts; return false; } function isValueAliasDeclaration(node) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - // A synthesized node comes from an emit transformation and is always a value. - return true; - } switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: - case 238 /* ImportClause */: - case 239 /* NamespaceImport */: - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return node.expression - && node.expression.kind === 70 /* Identifier */ + && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -44046,7 +45859,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 264 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 265 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -44067,11 +45880,6 @@ var ts; return isConstEnumSymbol(s) || s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { - node = ts.getParseTreeNode(node); - // Purely synthesized nodes are always emitted. - if (node === undefined) { - return true; - } if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (symbol && getSymbolLinks(symbol).referenced) { @@ -44110,15 +45918,23 @@ var ts; !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { - node = ts.getParseTreeNode(node); - return node ? getNodeLinks(node).flags : undefined; + return getNodeLinks(node).flags; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function canHaveConstantValue(node) { + switch (node.kind) { + case 264 /* EnumMember */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: + return true; + } + return false; + } function getConstantValue(node) { - if (node.kind === 263 /* EnumMember */) { + if (node.kind === 264 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -44139,7 +45955,7 @@ var ts; // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. var typeSymbol = resolveEntityName(typeName, 793064 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { return ts.TypeReferenceSerializationKind.Promise; } @@ -44278,10 +46094,21 @@ var ts; getReferencedImportDeclaration: getReferencedImportDeclaration, getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, isDeclarationWithCollidingName: isDeclarationWithCollidingName, - isValueAliasDeclaration: isValueAliasDeclaration, + isValueAliasDeclaration: function (node) { + node = ts.getParseTreeNode(node); + // Synthesized nodes are always treated like values. + return node ? isValueAliasDeclaration(node) : true; + }, hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, + isReferencedAliasDeclaration: function (node, checkChildren) { + node = ts.getParseTreeNode(node); + // Synthesized nodes are always treated as referenced. + return node ? isReferencedAliasDeclaration(node, checkChildren) : true; + }, + getNodeCheckFlags: function (node) { + node = ts.getParseTreeNode(node); + return node ? getNodeCheckFlags(node) : undefined; + }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, @@ -44292,7 +46119,10 @@ var ts; writeBaseConstructorTypeOfClass: writeBaseConstructorTypeOfClass, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, collectLinkedAliases: collectLinkedAliases, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, @@ -44315,7 +46145,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 178 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 179 /* PropertyAccessExpression */) || (node.kind === 71 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -44366,7 +46196,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 264 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 265 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -44386,7 +46216,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 264 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 265 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -44431,58 +46261,30 @@ var ts; // Setup global builtins addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = unknownType; // Initialize special types - globalArrayType = getGlobalType("Array", /*arity*/ 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); - getGlobalESSymbolConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Symbol"); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793064 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - tryGetGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalSymbol("Promise", 107455 /* Value */, /*diagnostic*/ undefined) && getGlobalPromiseConstructorSymbol(); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2 /* ES2015 */) { - getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); - getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", /*arity*/ 1); }); - getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", /*arity*/ 1); }); - getGlobalIterableIteratorType = ts.memoize(function () { return getGlobalType("IterableIterator", /*arity*/ 1); }); - } - else { - getGlobalESSymbolType = ts.memoize(function () { return emptyObjectType; }); - getGlobalIterableType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIteratorType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); - } + globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); + globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); + globalFunctionType = getGlobalType("Function", /*arity*/ 0, /*reportErrors*/ true); + globalStringType = getGlobalType("String", /*arity*/ 0, /*reportErrors*/ true); + globalNumberType = getGlobalType("Number", /*arity*/ 0, /*reportErrors*/ true); + globalBooleanType = getGlobalType("Boolean", /*arity*/ 0, /*reportErrors*/ true); + globalRegExpType = getGlobalType("RegExp", /*arity*/ 0, /*reportErrors*/ true); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); - var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); - globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); + globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; + globalThisType = getGlobalTypeOrUndefined("ThisType", /*arity*/ 1); } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !ts.isInAmbientContext(location)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* FirstEmitHelper */; helper <= 8192 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455 /* Value */); @@ -44506,6 +46308,13 @@ var ts; case 32 /* Param */: return "__param"; case 64 /* Awaiter */: return "__awaiter"; case 128 /* Generator */: return "__generator"; + case 256 /* Values */: return "__values"; + case 512 /* Read */: return "__read"; + case 1024 /* Spread */: return "__spread"; + case 2048 /* AsyncGenerator */: return "__asyncGenerator"; + case 4096 /* AsyncDelegator */: return "__asyncDelegator"; + case 8192 /* AsyncValues */: return "__asyncValues"; + default: ts.Debug.fail("Unrecognized helper."); } } function resolveHelpersModule(node, errorNode) { @@ -44514,38 +46323,20 @@ var ts; } return externalHelpersModule; } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. - var thenPropertySymbol = createSymbol(4 /* Property */, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(16 /* Anonymous */); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } // GRAMMAR CHECKING function checkGrammarDecorators(node) { if (!node.decorators) { return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 150 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 151 /* 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 === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */) { + else if (node.kind === 153 /* GetAccessor */ || node.kind === 154 /* 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); @@ -44562,28 +46353,28 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 130 /* ReadonlyKeyword */) { - if (node.kind === 147 /* PropertySignature */ || node.kind === 149 /* MethodSignature */) { + if (modifier.kind !== 131 /* ReadonlyKeyword */) { + if (node.kind === 148 /* PropertySignature */ || node.kind === 150 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 75 /* ConstKeyword */: - if (node.kind !== 231 /* EnumDeclaration */ && node.parent.kind === 228 /* ClassDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); + case 76 /* ConstKeyword */: + if (node.kind !== 232 /* EnumDeclaration */ && node.parent.kind === 229 /* ClassDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; - case 113 /* PublicKeyword */: - case 112 /* ProtectedKeyword */: - case 111 /* PrivateKeyword */: + case 114 /* PublicKeyword */: + case 113 /* ProtectedKeyword */: + case 112 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 112 /* ProtectedKeyword */) { + if (modifier.kind === 113 /* ProtectedKeyword */) { lastProtected = modifier; } - else if (modifier.kind === 111 /* PrivateKeyword */) { + else if (modifier.kind === 112 /* PrivateKeyword */) { lastPrivate = modifier; } if (flags & 28 /* AccessibilityModifier */) { @@ -44598,11 +46389,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + else if (node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* 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 === 111 /* PrivateKeyword */) { + if (modifier.kind === 112 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -44611,7 +46402,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 114 /* StaticKeyword */: + case 115 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -44621,10 +46412,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + else if (node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -44633,18 +46424,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 130 /* ReadonlyKeyword */: + case 131 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */ && node.kind !== 156 /* IndexSignature */ && node.kind !== 145 /* Parameter */) { + else if (node.kind !== 149 /* PropertyDeclaration */ && node.kind !== 148 /* PropertySignature */ && node.kind !== 157 /* IndexSignature */ && node.kind !== 146 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 83 /* ExportKeyword */: + case 84 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -44657,45 +46448,45 @@ 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 === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 123 /* DeclareKeyword */: + case 124 /* DeclareKeyword */: 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 === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 234 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 116 /* AbstractKeyword */: + case 117 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 228 /* ClassDeclaration */) { - if (node.kind !== 150 /* MethodDeclaration */ && - node.kind !== 148 /* PropertyDeclaration */ && - node.kind !== 152 /* GetAccessor */ && - node.kind !== 153 /* SetAccessor */) { + if (node.kind !== 229 /* ClassDeclaration */) { + if (node.kind !== 151 /* MethodDeclaration */ && + node.kind !== 149 /* PropertyDeclaration */ && + node.kind !== 153 /* GetAccessor */ && + node.kind !== 154 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 228 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 229 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -44707,14 +46498,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 119 /* AsyncKeyword */: + case 120 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -44722,7 +46513,7 @@ var ts; break; } } - if (node.kind === 151 /* Constructor */) { + if (node.kind === 152 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -44737,13 +46528,13 @@ var ts; } return; } - else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 238 /* ImportDeclaration */ || node.kind === 237 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 146 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 146 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -44763,38 +46554,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 151 /* Constructor */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 156 /* IndexSignature */: - case 232 /* ModuleDeclaration */: - case 237 /* ImportDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 243 /* ExportDeclaration */: - case 242 /* ExportAssignment */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 145 /* Parameter */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 152 /* Constructor */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 157 /* IndexSignature */: + case 233 /* ModuleDeclaration */: + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 244 /* ExportDeclaration */: + case 243 /* ExportAssignment */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 146 /* Parameter */: return false; default: - if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + if (node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* SourceFile */) { return false; } switch (node.kind) { - case 227 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 228 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 229 /* InterfaceDeclaration */: - case 207 /* VariableStatement */: - case 230 /* TypeAliasDeclaration */: + case 228 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); + case 229 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); + case 230 /* InterfaceDeclaration */: + case 208 /* VariableStatement */: + case 231 /* TypeAliasDeclaration */: return true; - case 231 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); + case 232 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -44806,14 +46597,11 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 150 /* MethodDeclaration */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - if (!node.asteriskToken) { - return false; - } - break; + case 151 /* MethodDeclaration */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } @@ -44871,8 +46659,12 @@ var ts; return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } function checkGrammarArrowFunction(node, file) { - if (node.kind === 186 /* ArrowFunction */) { + if (node.kind === 187 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -44907,7 +46699,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 135 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { + if (parameter.type.kind !== 136 /* StringKeyword */ && parameter.type.kind !== 133 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -44935,7 +46727,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 199 /* OmittedExpression */) { + if (arg.kind === 200 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -44961,7 +46753,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84 /* ExtendsKeyword */) { + if (heritageClause.token === 85 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -44974,7 +46766,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -44990,14 +46782,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84 /* ExtendsKeyword */) { + if (heritageClause.token === 85 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -45008,28 +46800,25 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 143 /* ComputedPropertyName */) { + if (node.kind !== 144 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 193 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 194 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* 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 === 227 /* FunctionDeclaration */ || - node.kind === 185 /* FunctionExpression */ || - node.kind === 150 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 228 /* FunctionDeclaration */ || + node.kind === 186 /* FunctionExpression */ || + node.kind === 151 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2 /* ES2015 */) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); - } } } function checkGrammarForInvalidQuestionMark(questionToken, message) { @@ -45045,15 +46834,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 /* SpreadAssignment */) { + if (prop.kind === 263 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 143 /* ComputedPropertyName */) { + if (name.kind === 144 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 261 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 262 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -45062,7 +46851,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 150 /* MethodDeclaration */) { + if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 151 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -45076,7 +46865,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */) { + if (prop.kind === 261 /* PropertyAssignment */ || prop.kind === 262 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -45084,13 +46873,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 150 /* MethodDeclaration */) { + else if (prop.kind === 151 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 152 /* GetAccessor */) { + else if (prop.kind === 153 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 153 /* SetAccessor */) { + else if (prop.kind === 154 /* SetAccessor */) { currentKind = SetAccessor; } else { @@ -45126,7 +46915,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 254 /* JsxSpreadAttribute */) { + if (attr.kind === 255 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -45138,7 +46927,7 @@ var ts; return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 255 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 256 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -45147,7 +46936,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { + if (forInOrOfStatement.kind === 216 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + } + } + if (forInOrOfStatement.initializer.kind === 227 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -45162,20 +46956,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 214 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 215 /* 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 === 214 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 215 /* 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 === 214 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 215 /* 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); @@ -45202,11 +46996,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 152 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 153 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 153 /* SetAccessor */) { + else if (kind === 154 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -45225,14 +47019,14 @@ var ts; } } /** Does the accessor have the right number of parameters? - - A get accessor has no parameters or a single `this` parameter. - A set accessor has one parameter or a `this` parameter and one more parameter */ + * A get accessor has no parameters or a single `this` parameter. + * A set accessor has one parameter or a `this` parameter and one more parameter. + */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 153 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 153 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -45247,7 +47041,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 177 /* ObjectLiteralExpression */) { + if (node.parent.kind === 178 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -45268,10 +47062,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 === 229 /* InterfaceDeclaration */) { + else if (node.parent.kind === 230 /* 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 === 162 /* TypeLiteral */) { + else if (node.parent.kind === 163 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -45282,11 +47076,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 221 /* LabeledStatement */: + case 222 /* 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 === 216 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 217 /* 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); @@ -45294,8 +47088,8 @@ var ts; return false; } break; - case 220 /* SwitchStatement */: - if (node.kind === 217 /* BreakStatement */ && !node.label) { + case 221 /* SwitchStatement */: + if (node.kind === 218 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -45310,13 +47104,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 217 /* BreakStatement */ + var message = node.kind === 218 /* 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 === 217 /* BreakStatement */ + var message = node.kind === 218 /* 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); @@ -45328,7 +47122,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 174 /* ArrayBindingPattern */ || node.name.kind === 173 /* ObjectBindingPattern */) { + if (node.name.kind === 175 /* ArrayBindingPattern */ || node.name.kind === 174 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -45339,11 +47133,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 192 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 214 /* ForInStatement */ && node.parent.parent.kind !== 215 /* ForOfStatement */) { + if (node.parent.parent.kind !== 215 /* ForInStatement */ && node.parent.parent.kind !== 216 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -45386,7 +47180,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 70 /* Identifier */) { + if (name.kind === 71 /* Identifier */) { if (ts.unescapeIdentifier(name.text) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -45402,8 +47196,8 @@ var ts; } } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 70 /* Identifier */) { - if (name.originalKeywordKind === 109 /* LetKeyword */) { + if (name.kind === 71 /* Identifier */) { + if (name.originalKeywordKind === 110 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -45428,15 +47222,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 210 /* IfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 219 /* WithStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 220 /* WithStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: return false; - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -45452,9 +47246,9 @@ var ts; } } function checkGrammarMetaProperty(node) { - if (node.keywordToken === 93 /* NewKeyword */) { + if (node.keywordToken === 94 /* NewKeyword */) { if (node.name.text !== "target") { - return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, ts.tokenToString(node.keywordToken), "target"); } } } @@ -45498,7 +47292,7 @@ var ts; return true; } } - else if (node.parent.kind === 229 /* InterfaceDeclaration */) { + else if (node.parent.kind === 230 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -45506,7 +47300,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 162 /* TypeLiteral */) { + else if (node.parent.kind === 163 /* 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; } @@ -45531,13 +47325,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 229 /* InterfaceDeclaration */ || - node.kind === 230 /* TypeAliasDeclaration */ || - node.kind === 237 /* ImportDeclaration */ || - node.kind === 236 /* ImportEqualsDeclaration */ || - node.kind === 243 /* ExportDeclaration */ || - node.kind === 242 /* ExportAssignment */ || - node.kind === 235 /* NamespaceExportDeclaration */ || + if (node.kind === 230 /* InterfaceDeclaration */ || + node.kind === 231 /* TypeAliasDeclaration */ || + node.kind === 238 /* ImportDeclaration */ || + node.kind === 237 /* ImportEqualsDeclaration */ || + node.kind === 244 /* ExportDeclaration */ || + node.kind === 243 /* ExportAssignment */ || + node.kind === 236 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -45546,7 +47340,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 === 207 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 208 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -45572,7 +47366,7 @@ var ts; // 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 === 206 /* Block */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + if (node.parent.kind === 207 /* Block */ || node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -45588,19 +47382,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral) { + if (node.numericLiteralFlags & 4 /* Octal */) { var diagnosticMessage = void 0; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 172 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 173 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 263 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 264 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 38 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -45629,446 +47423,19 @@ var ts; /// /// /// -/* @internal */ var ts; (function (ts) { - function reduceNode(node, f, initial) { - return node ? f(initial, node) : initial; - } - function reduceNodeArray(nodes, f, initial) { - return nodes ? f(initial, nodes) : initial; - } - /** - * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. - * - * @param node The node containing the children to reduce. - * @param initial The initial value to supply to the reduction. - * @param f The callback function - */ - function reduceEachChild(node, initial, cbNode, cbNodeArray) { - if (node === undefined) { - return initial; - } - var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; - var cbNodes = cbNodeArray || cbNode; - var kind = node.kind; - // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { - return initial; - } - // We do not yet support types. - if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { - return initial; - } - var result = initial; - switch (node.kind) { - // Leaf nodes - case 205 /* SemicolonClassElement */: - case 208 /* EmptyStatement */: - case 199 /* OmittedExpression */: - case 224 /* DebuggerStatement */: - case 297 /* NotEmittedStatement */: - // No need to visit nodes with no children. - break; - // Names - case 142 /* QualifiedName */: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 143 /* ComputedPropertyName */: - result = reduceNode(node.expression, cbNode, result); - break; - // Signature elements - case 145 /* Parameter */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 146 /* Decorator */: - result = reduceNode(node.expression, cbNode, result); - break; - // Type member - case 148 /* PropertyDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 150 /* MethodDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 151 /* Constructor */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 152 /* GetAccessor */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 153 /* SetAccessor */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - // Binding patterns - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 175 /* BindingElement */: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - // Expression - case 176 /* ArrayLiteralExpression */: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 177 /* ObjectLiteralExpression */: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 178 /* PropertyAccessExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 179 /* ElementAccessExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); - break; - case 180 /* CallExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 181 /* NewExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 182 /* TaggedTemplateExpression */: - result = reduceNode(node.tag, cbNode, result); - result = reduceNode(node.template, cbNode, result); - break; - case 183 /* TypeAssertionExpression */: - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 185 /* FunctionExpression */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 186 /* ArrowFunction */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 184 /* ParenthesizedExpression */: - case 187 /* DeleteExpression */: - case 188 /* TypeOfExpression */: - case 189 /* VoidExpression */: - case 190 /* AwaitExpression */: - case 196 /* YieldExpression */: - case 197 /* SpreadElement */: - case 202 /* NonNullExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: - result = reduceNode(node.operand, cbNode, result); - break; - case 193 /* BinaryExpression */: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 194 /* ConditionalExpression */: - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.whenTrue, cbNode, result); - result = reduceNode(node.whenFalse, cbNode, result); - break; - case 195 /* TemplateExpression */: - result = reduceNode(node.head, cbNode, result); - result = reduceNodes(node.templateSpans, cbNodes, result); - break; - case 198 /* ClassExpression */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 200 /* ExpressionWithTypeArguments */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - break; - case 201 /* AsExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.type, cbNode, result); - break; - case 202 /* NonNullExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - // Misc - case 204 /* TemplateSpan */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.literal, cbNode, result); - break; - // Element - case 206 /* Block */: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 207 /* VariableStatement */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.declarationList, cbNode, result); - break; - case 209 /* ExpressionStatement */: - result = reduceNode(node.expression, cbNode, result); - break; - case 210 /* IfStatement */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.thenStatement, cbNode, result); - result = reduceNode(node.elseStatement, cbNode, result); - break; - case 211 /* DoStatement */: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 212 /* WhileStatement */: - case 219 /* WithStatement */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 213 /* ForStatement */: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.incrementor, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 218 /* ReturnStatement */: - case 222 /* ThrowStatement */: - result = reduceNode(node.expression, cbNode, result); - break; - case 220 /* SwitchStatement */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.caseBlock, cbNode, result); - break; - case 221 /* LabeledStatement */: - result = reduceNode(node.label, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 223 /* TryStatement */: - result = reduceNode(node.tryBlock, cbNode, result); - result = reduceNode(node.catchClause, cbNode, result); - result = reduceNode(node.finallyBlock, cbNode, result); - break; - case 225 /* VariableDeclaration */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 226 /* VariableDeclarationList */: - result = reduceNodes(node.declarations, cbNodes, result); - break; - case 227 /* FunctionDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 228 /* ClassDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 231 /* EnumDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 232 /* ModuleDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 233 /* ModuleBlock */: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 234 /* CaseBlock */: - result = reduceNodes(node.clauses, cbNodes, result); - break; - case 236 /* ImportEqualsDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.moduleReference, cbNode, result); - break; - case 237 /* ImportDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.importClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 238 /* ImportClause */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.namedBindings, cbNode, result); - break; - case 239 /* NamespaceImport */: - result = reduceNode(node.name, cbNode, result); - break; - case 240 /* NamedImports */: - case 244 /* NamedExports */: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 242 /* ExportAssignment */: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 243 /* ExportDeclaration */: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.exportClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - // Module references - case 247 /* ExternalModuleReference */: - result = reduceNode(node.expression, cbNode, result); - break; - // JSX - case 248 /* JsxElement */: - result = reduceNode(node.openingElement, cbNode, result); - result = ts.reduceLeft(node.children, cbNode, result); - result = reduceNode(node.closingElement, cbNode, result); - break; - case 249 /* JsxSelfClosingElement */: - case 250 /* JsxOpeningElement */: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNode(node.attributes, cbNode, result); - break; - case 251 /* JsxClosingElement */: - result = reduceNode(node.tagName, cbNode, result); - break; - case 253 /* JsxAttributes */: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 252 /* JsxAttribute */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 254 /* JsxSpreadAttribute */: - result = reduceNode(node.expression, cbNode, result); - break; - case 255 /* JsxExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - // Clauses - case 256 /* CaseClause */: - result = reduceNode(node.expression, cbNode, result); - // fall-through - case 257 /* DefaultClause */: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 258 /* HeritageClause */: - result = reduceNodes(node.types, cbNodes, result); - break; - case 259 /* CatchClause */: - result = reduceNode(node.variableDeclaration, cbNode, result); - result = reduceNode(node.block, cbNode, result); - break; - // Property assignments - case 260 /* PropertyAssignment */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 261 /* ShorthandPropertyAssignment */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); - break; - case 262 /* SpreadAssignment */: - result = reduceNode(node.expression, cbNode, result); - break; - // Enum - case 263 /* EnumMember */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - // Top-level nodes - case 264 /* SourceFile */: - result = reduceNodes(node.statements, cbNodes, result); - break; - // Transformation nodes - case 298 /* PartiallyEmittedExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - default: - break; - } - return result; - } - ts.reduceEachChild = reduceEachChild; - /** - * Visits a Node using the supplied visitor, possibly returning a new Node in its place. - * - * @param node The Node to visit. - * @param visitor The callback used to visit the Node. - * @param test A callback to execute to verify the Node is valid. - * @param optional An optional value indicating whether the Node is itself optional. - * @param lift An optional callback to execute to lift a NodeArray into a valid Node. - */ - function visitNode(node, visitor, test, optional, lift) { + function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; } - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; } var visitedNode; if (visited === undefined) { - if (!optional) { - Debug.failNotOptional(); - } return undefined; } else if (ts.isArray(visited)) { @@ -46077,8 +47444,8 @@ var ts; else { visitedNode = visited; } - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; @@ -46092,8 +47459,8 @@ var ts; * @param count An optional value indicating the maximum number of nodes to visit. */ function visitNodes(nodes, visitor, test, start, count) { - if (nodes === undefined) { - return undefined; + if (nodes === undefined || visitor === undefined) { + return nodes; } var updated; // Ensure start and count have valid values @@ -46113,7 +47480,7 @@ var ts; // Visit each original node. for (var i = 0; i < count; i++) { var node = nodes[i + start]; - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -46125,14 +47492,14 @@ var ts; if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - Debug.assertNode(visited, test); - aggregateTransformFlags(visited); + ts.Debug.assertNode(visited, test); + ts.aggregateTransformFlags(visited); updated.push(visited); } } @@ -46159,9 +47526,10 @@ var ts; * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes, visitor, context) { + function visitParameterList(nodes, visitor, context, nodesVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } context.startLexicalEnvironment(); - var updated = visitNodes(nodes, visitor, ts.isParameterDeclaration); + var updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -46172,237 +47540,706 @@ var ts; var declarations = context.endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(updated); - var statements = mergeLexicalEnvironment(block.statements, declarations); + var statements = ts.mergeLexicalEnvironment(block.statements, declarations); return ts.updateBlock(block, statements); } return updated; } ts.visitFunctionBody = visitFunctionBody; - function visitEachChild(node, visitor, context) { + function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (node === undefined) { return undefined; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { - return node; - } - // We do not yet support types. - if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { + if ((kind > 0 /* FirstToken */ && kind <= 142 /* LastToken */) || kind === 169 /* ThisType */) { return node; } switch (node.kind) { - case 205 /* SemicolonClassElement */: - case 208 /* EmptyStatement */: - case 199 /* OmittedExpression */: - case 224 /* DebuggerStatement */: + case 206 /* SemicolonClassElement */: + case 209 /* EmptyStatement */: + case 200 /* OmittedExpression */: + case 225 /* DebuggerStatement */: + case 298 /* EndOfDeclarationMarker */: + case 247 /* MissingDeclaration */: // No need to visit nodes with no children. return node; // Names - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - // Signature elements - case 145 /* Parameter */: - return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 146 /* Decorator */: + // Signatures and Signature Elements + case 160 /* FunctionType */: + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 161 /* ConstructorType */: + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 155 /* CallSignature */: + return ts.updateCallSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 156 /* ConstructSignature */: + return ts.updateConstructSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 150 /* MethodSignature */: + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + case 157 /* IndexSignature */: + return ts.updateIndexSignatureDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 146 /* Parameter */: + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 147 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - // Type member - case 148 /* PropertyDeclaration */: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 150 /* MethodDeclaration */: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 151 /* Constructor */: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 152 /* GetAccessor */: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 153 /* SetAccessor */: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + // Types + case 159 /* TypeReference */: + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + case 158 /* TypePredicate */: + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 162 /* TypeQuery */: + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + case 163 /* TypeLiteral */: + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor)); + case 164 /* ArrayType */: + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + case 165 /* TupleType */: + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 166 /* UnionType */: + case 167 /* IntersectionType */: + return ts.updateUnionOrIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 168 /* ParenthesizedType */: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* TypeOperator */: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* IndexedAccessType */: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 172 /* MappedType */: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameter), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 173 /* LiteralType */: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + // Type Declarations + case 145 /* TypeParameter */: + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + // Type members + case 148 /* PropertySignature */: + return ts.updatePropertySignature(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 149 /* PropertyDeclaration */: + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 151 /* MethodDeclaration */: + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 152 /* Constructor */: + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 153 /* GetAccessor */: + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 154 /* SetAccessor */: + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); // Binding patterns - case 173 /* ObjectBindingPattern */: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 174 /* ArrayBindingPattern */: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 175 /* BindingElement */: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 174 /* ObjectBindingPattern */: + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + case 175 /* ArrayBindingPattern */: + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + case 176 /* BindingElement */: + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 176 /* ArrayLiteralExpression */: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 177 /* ObjectLiteralExpression */: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 178 /* PropertyAccessExpression */: + case 177 /* ArrayLiteralExpression */: + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + case 178 /* ObjectLiteralExpression */: + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 179 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 180 /* CallExpression */: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181 /* NewExpression */: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 182 /* TaggedTemplateExpression */: + case 181 /* CallExpression */: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 182 /* NewExpression */: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 183 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185 /* FunctionExpression */: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 186 /* ArrowFunction */: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 187 /* DeleteExpression */: + case 186 /* FunctionExpression */: + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 187 /* ArrowFunction */: + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 188 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* TypeOfExpression */: + case 189 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 195 /* TemplateExpression */: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 196 /* YieldExpression */: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* SpreadElement */: + case 196 /* TemplateExpression */: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + case 197 /* YieldExpression */: + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 198 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* ClassExpression */: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 200 /* ExpressionWithTypeArguments */: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* AsExpression */: + case 199 /* ClassExpression */: + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 201 /* ExpressionWithTypeArguments */: + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 206 /* Block */: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 207 /* VariableStatement */: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 209 /* ExpressionStatement */: + case 207 /* Block */: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 208 /* VariableStatement */: + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 210 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* IfStatement */: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 211 /* DoStatement */: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* WhileStatement */: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForStatement */: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ForInStatement */: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ForOfStatement */: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 216 /* ContinueStatement */: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 217 /* BreakStatement */: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 218 /* ReturnStatement */: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 219 /* WithStatement */: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* SwitchStatement */: + case 211 /* IfStatement */: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + case 212 /* DoStatement */: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 213 /* WhileStatement */: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 214 /* ForStatement */: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 215 /* ForInStatement */: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 216 /* ForOfStatement */: + return ts.updateForOf(node, node.awaitModifier, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 217 /* ContinueStatement */: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 218 /* BreakStatement */: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 219 /* ReturnStatement */: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* WithStatement */: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 221 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 221 /* LabeledStatement */: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 222 /* ThrowStatement */: + case 222 /* LabeledStatement */: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 223 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* TryStatement */: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 225 /* VariableDeclaration */: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 226 /* VariableDeclarationList */: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 227 /* FunctionDeclaration */: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 228 /* ClassDeclaration */: - return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 231 /* EnumDeclaration */: - return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); - case 232 /* ModuleDeclaration */: - return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 233 /* ModuleBlock */: - return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 234 /* CaseBlock */: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236 /* ImportEqualsDeclaration */: - return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 237 /* ImportDeclaration */: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 238 /* ImportClause */: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 239 /* NamespaceImport */: + case 224 /* TryStatement */: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + case 226 /* VariableDeclaration */: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 227 /* VariableDeclarationList */: + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + case 228 /* FunctionDeclaration */: + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 229 /* ClassDeclaration */: + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 232 /* EnumDeclaration */: + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + case 233 /* ModuleDeclaration */: + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 234 /* ModuleBlock */: + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 235 /* CaseBlock */: + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + case 237 /* ImportEqualsDeclaration */: + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 238 /* ImportDeclaration */: + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 239 /* ImportClause */: + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + case 240 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* NamedImports */: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 241 /* ImportSpecifier */: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 242 /* ExportAssignment */: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 243 /* ExportDeclaration */: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 244 /* NamedExports */: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 245 /* ExportSpecifier */: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); + case 241 /* NamedImports */: + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + case 242 /* ImportSpecifier */: + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 243 /* ExportAssignment */: + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 244 /* ExportDeclaration */: + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 245 /* NamedExports */: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 246 /* ExportSpecifier */: + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 247 /* ExternalModuleReference */: + case 248 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 248 /* JsxElement */: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 253 /* JsxAttributes */: - return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxSelfClosingElement */: + case 249 /* JsxElement */: + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + case 254 /* JsxAttributes */: + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + case 250 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 250 /* JsxOpeningElement */: + case 251 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 254 /* JsxSpreadAttribute */: + case 255 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 256 /* CaseClause */: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 257 /* DefaultClause */: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 258 /* HeritageClause */: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 259 /* CatchClause */: + case 257 /* CaseClause */: + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + case 258 /* DefaultClause */: + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 259 /* HeritageClause */: + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 260 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 263 /* EnumMember */: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 264 /* EnumMember */: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 264 /* SourceFile */: + case 265 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: return node; } } ts.visitEachChild = visitEachChild; + /** + * Extracts the single node from a NodeArray. + * + * @param nodes The NodeArray. + */ + function extractSingleNode(nodes) { + ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output."); + return ts.singleOrUndefined(nodes); + } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + function reduceNode(node, f, initial) { + return node ? f(initial, node) : initial; + } + function reduceNodeArray(nodes, f, initial) { + return nodes ? f(initial, nodes) : initial; + } + /** + * Similar to `reduceLeft`, performs a reduction against each child of a node. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. + * + * @param node The node containing the children to reduce. + * @param initial The initial value to supply to the reduction. + * @param f The callback function + */ + function reduceEachChild(node, initial, cbNode, cbNodeArray) { + if (node === undefined) { + return initial; + } + var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; + var cbNodes = cbNodeArray || cbNode; + var kind = node.kind; + // No need to visit nodes with no children. + if ((kind > 0 /* FirstToken */ && kind <= 142 /* LastToken */)) { + return initial; + } + // We do not yet support types. + if ((kind >= 158 /* TypePredicate */ && kind <= 173 /* LiteralType */)) { + return initial; + } + var result = initial; + switch (node.kind) { + // Leaf nodes + case 206 /* SemicolonClassElement */: + case 209 /* EmptyStatement */: + case 200 /* OmittedExpression */: + case 225 /* DebuggerStatement */: + case 295 /* NotEmittedStatement */: + // No need to visit nodes with no children. + break; + // Names + case 143 /* QualifiedName */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 144 /* ComputedPropertyName */: + result = reduceNode(node.expression, cbNode, result); + break; + // Signature elements + case 146 /* Parameter */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 147 /* Decorator */: + result = reduceNode(node.expression, cbNode, result); + break; + // Type member + case 149 /* PropertyDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 151 /* MethodDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 152 /* Constructor */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153 /* GetAccessor */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 154 /* SetAccessor */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + // Binding patterns + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 176 /* BindingElement */: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + // Expression + case 177 /* ArrayLiteralExpression */: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 178 /* ObjectLiteralExpression */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 179 /* PropertyAccessExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 180 /* ElementAccessExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 181 /* CallExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182 /* NewExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 183 /* TaggedTemplateExpression */: + result = reduceNode(node.tag, cbNode, result); + result = reduceNode(node.template, cbNode, result); + break; + case 184 /* TypeAssertionExpression */: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 186 /* FunctionExpression */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 187 /* ArrowFunction */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 185 /* ParenthesizedExpression */: + case 188 /* DeleteExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 191 /* AwaitExpression */: + case 197 /* YieldExpression */: + case 198 /* SpreadElement */: + case 203 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + result = reduceNode(node.operand, cbNode, result); + break; + case 194 /* BinaryExpression */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 195 /* ConditionalExpression */: + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.whenTrue, cbNode, result); + result = reduceNode(node.whenFalse, cbNode, result); + break; + case 196 /* TemplateExpression */: + result = reduceNode(node.head, cbNode, result); + result = reduceNodes(node.templateSpans, cbNodes, result); + break; + case 199 /* ClassExpression */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 201 /* ExpressionWithTypeArguments */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + break; + case 202 /* AsExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 203 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + // Misc + case 205 /* TemplateSpan */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.literal, cbNode, result); + break; + // Element + case 207 /* Block */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 208 /* VariableStatement */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.declarationList, cbNode, result); + break; + case 210 /* ExpressionStatement */: + result = reduceNode(node.expression, cbNode, result); + break; + case 211 /* IfStatement */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.thenStatement, cbNode, result); + result = reduceNode(node.elseStatement, cbNode, result); + break; + case 212 /* DoStatement */: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 213 /* WhileStatement */: + case 220 /* WithStatement */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 214 /* ForStatement */: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.incrementor, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 219 /* ReturnStatement */: + case 223 /* ThrowStatement */: + result = reduceNode(node.expression, cbNode, result); + break; + case 221 /* SwitchStatement */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.caseBlock, cbNode, result); + break; + case 222 /* LabeledStatement */: + result = reduceNode(node.label, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 224 /* TryStatement */: + result = reduceNode(node.tryBlock, cbNode, result); + result = reduceNode(node.catchClause, cbNode, result); + result = reduceNode(node.finallyBlock, cbNode, result); + break; + case 226 /* VariableDeclaration */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 227 /* VariableDeclarationList */: + result = reduceNodes(node.declarations, cbNodes, result); + break; + case 228 /* FunctionDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 229 /* ClassDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232 /* EnumDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 233 /* ModuleDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 234 /* ModuleBlock */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 235 /* CaseBlock */: + result = reduceNodes(node.clauses, cbNodes, result); + break; + case 237 /* ImportEqualsDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 238 /* ImportDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.importClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 239 /* ImportClause */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); + break; + case 240 /* NamespaceImport */: + result = reduceNode(node.name, cbNode, result); + break; + case 241 /* NamedImports */: + case 245 /* NamedExports */: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 243 /* ExportAssignment */: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 244 /* ExportDeclaration */: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.exportClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + // Module references + case 248 /* ExternalModuleReference */: + result = reduceNode(node.expression, cbNode, result); + break; + // JSX + case 249 /* JsxElement */: + result = reduceNode(node.openingElement, cbNode, result); + result = ts.reduceLeft(node.children, cbNode, result); + result = reduceNode(node.closingElement, cbNode, result); + break; + case 250 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 254 /* JsxAttributes */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252 /* JsxClosingElement */: + result = reduceNode(node.tagName, cbNode, result); + break; + case 253 /* JsxAttribute */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 255 /* JsxSpreadAttribute */: + result = reduceNode(node.expression, cbNode, result); + break; + case 256 /* JsxExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + // Clauses + case 257 /* CaseClause */: + result = reduceNode(node.expression, cbNode, result); + // falls through + case 258 /* DefaultClause */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 259 /* HeritageClause */: + result = reduceNodes(node.types, cbNodes, result); + break; + case 260 /* CatchClause */: + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); + break; + // Property assignments + case 261 /* PropertyAssignment */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 262 /* ShorthandPropertyAssignment */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); + break; + case 263 /* SpreadAssignment */: + result = reduceNode(node.expression, cbNode, result); + break; + // Enum + case 264 /* EnumMember */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + // Top-level nodes + case 265 /* SourceFile */: + result = reduceNodes(node.statements, cbNodes, result); + break; + // Transformation nodes + case 296 /* PartiallyEmittedExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + default: + break; + } + return result; + } + ts.reduceEachChild = reduceEachChild; function mergeLexicalEnvironment(statements, declarations) { if (!ts.some(declarations)) { return statements; @@ -46412,20 +48249,6 @@ var ts; : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; - function mergeFunctionBodyLexicalEnvironment(body, declarations) { - if (body && declarations !== undefined && declarations.length > 0) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); - } - else { - return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), - /*multiLine*/ true), - /*location*/ body); - } - } - return body; - } - ts.mergeFunctionBodyLexicalEnvironment = mergeFunctionBodyLexicalEnvironment; /** * Lifts a NodeArray containing only Statement nodes to a block. * @@ -46436,15 +48259,6 @@ var ts; return ts.singleOrUndefined(nodes) || ts.createBlock(nodes); } ts.liftToBlock = liftToBlock; - /** - * Extracts the single node from a NodeArray. - * - * @param nodes The NodeArray. - */ - function extractSingleNode(nodes) { - Debug.assert(nodes.length <= 1, "Too many nodes written to output."); - return ts.singleOrUndefined(nodes); - } /** * Aggregates the TransformFlags for a Node and its subtree. */ @@ -46490,7 +48304,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 200 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 201 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -46508,9 +48322,6 @@ var ts; } var Debug; (function (Debug) { - Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) - ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : ts.noop; @@ -46570,7 +48381,7 @@ var ts; var value; if (ts.isDestructuringAssignment(node)) { value = node.right; - while (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) { if (ts.isDestructuringAssignment(value)) { location = node = value; value = node.right; @@ -46584,6 +48395,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -46656,6 +48468,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -46808,7 +48621,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)) { + if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + // Read the elements of the iterable into an array + value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) + ? undefined + : numElements, location), + /*reuseIdentifierExpressions*/ false, location); + } + else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, @@ -46936,7 +48756,7 @@ var ts; return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement)); } function makeBindingElement(name) { - return ts.createBindingElement(/*propertyName*/ undefined, /*dotDotDotToken*/ undefined, name); + return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); } function makeAssignmentElement(name) { return name; @@ -46947,7 +48767,8 @@ var ts; text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement - * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ + * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` + */ function createRestCall(context, value, elements, computedTempVariables, location) { context.requestEmitHelper(restHelper); var propertyNames = []; @@ -46966,7 +48787,8 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [ + return ts.createCall(ts.getHelperName("__rest"), + /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) ]); @@ -47004,8 +48826,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(178 /* PropertyAccessExpression */); - context.enableSubstitution(179 /* ElementAccessExpression */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(180 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -47069,15 +48891,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 264 /* SourceFile */: - case 234 /* CaseBlock */: - case 233 /* ModuleBlock */: - case 206 /* Block */: + case 265 /* SourceFile */: + case 235 /* CaseBlock */: + case 234 /* ModuleBlock */: + case 207 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 228 /* ClassDeclaration */: - case 227 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + case 228 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -47124,13 +48946,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -47150,11 +48972,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 243 /* ExportDeclaration */ || - node.kind === 237 /* ImportDeclaration */ || - node.kind === 238 /* ImportClause */ || - (node.kind === 236 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 247 /* ExternalModuleReference */)) { + if (node.kind === 244 /* ExportDeclaration */ || + node.kind === 238 /* ImportDeclaration */ || + node.kind === 239 /* ImportClause */ || + (node.kind === 237 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 248 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -47184,19 +49006,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 151 /* Constructor */: + case 152 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 148 /* PropertyDeclaration */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 150 /* MethodDeclaration */: + case 149 /* PropertyDeclaration */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 151 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 205 /* SemicolonClassElement */: + case 206 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -47207,7 +49029,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 83 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { return undefined; } return node; @@ -47224,59 +49046,59 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 116 /* AbstractKeyword */: - case 75 /* ConstKeyword */: - case 123 /* DeclareKeyword */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 117 /* AbstractKeyword */: + case 76 /* ConstKeyword */: + case 124 /* DeclareKeyword */: + case 131 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 163 /* ArrayType */: - case 164 /* TupleType */: - case 162 /* TypeLiteral */: - case 157 /* TypePredicate */: - case 144 /* TypeParameter */: - case 118 /* AnyKeyword */: - case 121 /* BooleanKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 129 /* NeverKeyword */: - case 104 /* VoidKeyword */: - case 136 /* SymbolKeyword */: - case 160 /* ConstructorType */: - case 159 /* FunctionType */: - case 161 /* TypeQuery */: - case 158 /* TypeReference */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: - case 167 /* ParenthesizedType */: - case 168 /* ThisType */: - case 169 /* TypeOperator */: - case 170 /* IndexedAccessType */: - case 171 /* MappedType */: - case 172 /* LiteralType */: + case 164 /* ArrayType */: + case 165 /* TupleType */: + case 163 /* TypeLiteral */: + case 158 /* TypePredicate */: + case 145 /* TypeParameter */: + case 119 /* AnyKeyword */: + case 122 /* BooleanKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 130 /* NeverKeyword */: + case 105 /* VoidKeyword */: + case 137 /* SymbolKeyword */: + case 161 /* ConstructorType */: + case 160 /* FunctionType */: + case 162 /* TypeQuery */: + case 159 /* TypeReference */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: + case 168 /* ParenthesizedType */: + case 169 /* ThisType */: + case 170 /* TypeOperator */: + case 171 /* IndexedAccessType */: + case 172 /* MappedType */: + case 173 /* LiteralType */: // TypeScript type nodes are elided. - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: // TypeScript index signatures are elided. - case 146 /* Decorator */: + case 147 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; - case 151 /* Constructor */: + case 152 /* Constructor */: return visitConstructor(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -47287,7 +49109,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -47298,35 +49120,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 145 /* Parameter */: + case 146 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -47336,33 +49158,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return visitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return visitNewExpression(node); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -47371,7 +49193,8 @@ var ts; } } function visitSourceFile(node) { - var alwaysStrict = compilerOptions.alwaysStrict && !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && + !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -47411,9 +49234,10 @@ var ts; // emit name if // - node has a name // - node has static initializers + // - node has a member that is decorated // var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -47449,7 +49273,7 @@ var ts; if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -47609,7 +49433,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -47625,7 +49449,7 @@ var ts; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 32768 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -47755,7 +49579,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } // End the lexical environment. - ts.addRange(statements, endLexicalEnvironment()); + statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), /*multiLine*/ true), @@ -47771,13 +49595,13 @@ var ts; if (ctor.body) { var statements = ctor.body.statements; // add prologue directives to the list (if any) - var index = ts.addPrologueDirectives(result, statements, /*ensureUseStrict*/ false, visitor); + var index = ts.addPrologue(result, statements, /*ensureUseStrict*/ false, visitor); if (index === statements.length) { // list contains nothing but prologue directives (or empty) - exit return index; } var statement = statements[index]; - if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -47848,7 +49672,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 148 /* PropertyDeclaration */ + return member.kind === 149 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -47859,8 +49683,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { - var property = properties_8[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -47875,8 +49699,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -47983,12 +49807,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -48141,7 +49965,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 148 /* PropertyDeclaration */ + ? member.kind === 149 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -48238,13 +50062,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -48260,10 +50084,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 148 /* PropertyDeclaration */; + return kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 149 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -48273,7 +50097,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 150 /* MethodDeclaration */; + return node.kind === 151 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -48284,12 +50108,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return true; } return false; @@ -48301,15 +50125,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 148 /* PropertyDeclaration */: - case 145 /* Parameter */: - case 152 /* GetAccessor */: + case 149 /* PropertyDeclaration */: + case 146 /* Parameter */: + case 153 /* GetAccessor */: return serializeTypeNode(node.type); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 150 /* MethodDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 151 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -48346,7 +50170,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 152 /* GetAccessor */) { + if (container && node.kind === 153 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -48363,7 +50187,7 @@ var ts; if (ts.isFunctionLike(node) && node.type) { return serializeTypeNode(node.type); } - else if (ts.isAsyncFunctionLike(node)) { + else if (ts.isAsyncFunction(node)) { return ts.createIdentifier("Promise"); } return ts.createVoidZero(); @@ -48391,56 +50215,58 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 129 /* NeverKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 130 /* NeverKeyword */: return ts.createVoidZero(); - case 167 /* ParenthesizedType */: + case 168 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return ts.createIdentifier("Function"); - case 163 /* ArrayType */: - case 164 /* TupleType */: + case 164 /* ArrayType */: + case 165 /* TupleType */: return ts.createIdentifier("Array"); - case 157 /* TypePredicate */: - case 121 /* BooleanKeyword */: + case 158 /* TypePredicate */: + case 122 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 135 /* StringKeyword */: + case 136 /* StringKeyword */: return ts.createIdentifier("String"); - case 172 /* LiteralType */: + case 134 /* ObjectKeyword */: + return ts.createIdentifier("Object"); + case 173 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 132 /* NumberKeyword */: + case 133 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 136 /* SymbolKeyword */: + case 137 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return serializeTypeReferenceNode(node); - case 166 /* IntersectionType */: - case 165 /* UnionType */: + case 167 /* IntersectionType */: + case 166 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 161 /* TypeQuery */: - case 169 /* TypeOperator */: - case 170 /* IndexedAccessType */: - case 171 /* MappedType */: - case 162 /* TypeLiteral */: - case 118 /* AnyKeyword */: - case 168 /* ThisType */: + case 162 /* TypeQuery */: + case 170 /* TypeOperator */: + case 171 /* IndexedAccessType */: + case 172 /* MappedType */: + case 163 /* TypeLiteral */: + case 119 /* AnyKeyword */: + case 169 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -48525,7 +50351,7 @@ var ts; */ function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -48536,7 +50362,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -48549,7 +50375,7 @@ var ts; */ function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 70 /* Identifier */) { + if (node.left.kind === 71 /* Identifier */) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -48620,9 +50446,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 84 /* ExtendsKeyword */) { + if (node.token === 85 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(84 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); } return undefined; } @@ -48651,7 +50477,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - return ts.visitEachChild(node, visitor, context); + return ts.updateConstructor(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context)); } /** * Visits a method declaration of a class. @@ -48668,7 +50494,8 @@ var ts; return undefined; } var updated = ts.updateMethod(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), + /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context)); if (updated !== node) { @@ -48750,7 +50577,7 @@ var ts; return ts.createNotEmittedStatement(node); } var updated = ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); if (isNamespaceExport(node)) { @@ -48769,12 +50596,12 @@ var ts; * @param node The function expression node. */ function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { + if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createOmittedExpression(); } - var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, + var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context)); + /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); return updated; } /** @@ -48868,13 +50695,13 @@ var ts; // code if the casted expression has a lower precedence than the rest of the // expression. // + // To preserve comments, we return a "PartiallyEmittedExpression" here which will + // preserve the position information of the original expression. + // // Due to the auto-parenthesization rules used by the visitor and factory functions // we can safely elide the parentheses here, as a new synthetic // ParenthesizedExpression will be inserted if we remove parentheses too // aggressively. - // - // To preserve comments, we return a "PartiallyEmittedExpression" here which will - // preserve the position information of the original expression. return ts.createPartiallyEmittedExpression(expression, node); } return ts.visitEachChild(node, visitor, context); @@ -49075,7 +50902,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 231 /* EnumDeclaration */) { + if (node.kind === 232 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -49100,7 +50927,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 1024 /* NoTrailingComments */ | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -49110,7 +50937,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = ts.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -49194,7 +51021,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 233 /* ModuleBlock */) { + if (body.kind === 234 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -49240,13 +51067,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 233 /* ModuleBlock */) { + if (body.kind !== 234 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 233 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -49263,7 +51090,7 @@ var ts; return node; } // Elide the declaration if the import clause was elided. - var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, /*optional*/ true); + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause ? ts.updateImportDeclaration(node, /*decorators*/ undefined, @@ -49278,7 +51105,7 @@ var ts; function visitImportClause(node) { // Elide the import clause if we elide both its name and its named bindings. var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; - var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, /*optional*/ true); + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings); return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } /** @@ -49287,7 +51114,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 239 /* NamespaceImport */) { + if (node.kind === 240 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -49334,7 +51161,7 @@ var ts; return undefined; } // Elide the export declaration if all of its named exports are elided. - var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, /*optional*/ true); + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports); return exportClause ? ts.updateExportDeclaration(node, /*decorators*/ undefined, @@ -49500,7 +51327,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(71 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -49508,7 +51335,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(71 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -49518,17 +51345,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(261 /* ShorthandPropertyAssignment */); + context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(262 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(232 /* ModuleDeclaration */); + context.enableEmitNotification(233 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 232 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 233 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 231 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 232 /* EnumDeclaration */; } /** * Hook for node emit. @@ -49539,6 +51366,10 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSourceFile = currentSourceFile; + if (ts.isSourceFile(node)) { + currentSourceFile = node; + } if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; } @@ -49547,6 +51378,7 @@ var ts; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; + currentSourceFile = savedCurrentSourceFile; } /** * Hooks node substitutions. @@ -49582,11 +51414,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -49624,9 +51456,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 264 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 232 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 231 /* EnumDeclaration */); + if (container && container.kind !== 265 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 233 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 232 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -49644,16 +51476,15 @@ var ts; function substituteConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { + // track the constant value on the node for the printer in needsDotDotForPropertyAccess + ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); - ts.setSourceMapRange(substitute, node); - ts.setCommentRange(substitute, node); if (!compilerOptions.removeComments) { var propertyName = ts.isPropertyAccessExpression(node) ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - substitute.trailingComment = " " + propertyName + " "; + ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } - ts.setConstantValue(node, constantValue); return substitute; } return node; @@ -49668,42 +51499,7 @@ var ts; } } ts.transformTypeScript = transformTypeScript; - var paramHelper = { - name: "typescript:param", - scoped: false, - priority: 4, - text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" - }; - function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), - /*typeArguments*/ undefined, [ - ts.createLiteral(parameterOffset), - expression - ]), location); - } - var metadataHelper = { - name: "typescript:metadata", - scoped: false, - priority: 3, - text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" - }; - function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), - /*typeArguments*/ undefined, [ - ts.createLiteral(metadataKey), - metadataValue - ]); - } - var decorateHelper = { - name: "typescript:decorate", - scoped: false, - priority: 2, - text: "\n var __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 };" - }; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { - context.requestEmitHelper(decorateHelper); var argumentsArray = []; argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); argumentsArray.push(target); @@ -49713,17 +51509,415 @@ var ts; argumentsArray.push(descriptor); } } + context.requestEmitHelper(decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } + var decorateHelper = { + name: "typescript:decorate", + scoped: false, + priority: 2, + text: "\n var __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 };" + }; + function createMetadataHelper(context, metadataKey, metadataValue) { + context.requestEmitHelper(metadataHelper); + return ts.createCall(ts.getHelperName("__metadata"), + /*typeArguments*/ undefined, [ + ts.createLiteral(metadataKey), + metadataValue + ]); + } + var metadataHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" + }; + function createParamHelper(context, expression, parameterOffset, location) { + context.requestEmitHelper(paramHelper); + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + /*typeArguments*/ undefined, [ + ts.createLiteral(parameterOffset), + expression + ]), location); + } + var paramHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" + }; })(ts || (ts = {})); /// /// /*@internal*/ var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + function transformES2017(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + // These variables contain state that changes as we descend into the tree. + var currentSourceFile; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + var enabledSubstitutions; + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + var enclosingSuperContainerFlags = 0; + // Save the previous transformation hooks. + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; + } + function visitor(node) { + if ((node.transformFlags & 16 /* ContainsES2017 */) === 0) { + return node; + } + switch (node.kind) { + case 120 /* AsyncKeyword */: + // ES2017 async modifier should be elided for targets < ES2017 + return undefined; + case 191 /* AwaitExpression */: + return visitAwaitExpression(node); + case 151 /* MethodDeclaration */: + return visitMethodDeclaration(node); + case 228 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 186 /* FunctionExpression */: + return visitFunctionExpression(node); + case 187 /* ArrowFunction */: + return visitArrowFunction(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + /** + * Visits an AwaitExpression node. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The node to visit. + */ + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); + } + /** + * Visits a MethodDeclaration node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The node to visit. + */ + function visitMethodDeclaration(node) { + return ts.updateMethod(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*questionToken*/ undefined, + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + /** + * Visits a FunctionDeclaration node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + /** + * Visits a FunctionExpression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The node to visit. + */ + function visitFunctionExpression(node) { + return ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + /** + * Visits an ArrowFunction. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The node to visit. + */ + function visitArrowFunction(node) { + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function transformAsyncFunctionBody(node) { + resumeLexicalEnvironment(); + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; + var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 187 /* 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 + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(statements, /*multiLine*/ true); + ts.setTextRange(block, node.body); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; + } + else { + var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); + var declarations = endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(expression); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); + } + return expression; + } + } + function transformFunctionBodyWorker(body, start) { + if (ts.isBlock(body)) { + return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); + } + else { + startLexicalEnvironment(); + var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); + var declarations = endLexicalEnvironment(); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); + } + } + function getPromiseConstructor(type) { + var typeName = type && ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(181 /* CallExpression */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(180 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(229 /* ClassDeclaration */); + context.enableEmitNotification(151 /* MethodDeclaration */); + context.enableEmitNotification(153 /* GetAccessor */); + context.enableEmitNotification(154 /* SetAccessor */); + context.enableEmitNotification(152 /* Constructor */); + } + } + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint, node, emitCallback) { + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 180 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 181 /* CallExpression */: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 /* ClassDeclaration */ + || kind === 152 /* Constructor */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); + } + } + } + ts.transformES2017 = transformES2017; + var awaiterHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: "\n var __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 };" + }; + function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + context.requestEmitHelper(awaiterHelper); + var generatorFunc = ts.createFunctionExpression( + /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, body); + // Mark this node as originally an async function + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; + return ts.createCall(ts.getHelperName("__awaiter"), + /*typeArguments*/ undefined, [ + ts.createThis(), + hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), + promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), + generatorFunc + ]); + } + ts.asyncSuperHelper = { + name: "typescript:async-super", + scoped: true, + text: "\n const _super = name => super[name];\n " + }; + ts.advancedAsyncSuperHelper = { + name: "typescript:advanced-async-super", + scoped: true, + text: "\n const _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);\n " + }; +})(ts || (ts = {})); +/// +/// +/// +/*@internal*/ +var ts; +(function (ts) { + var ESNextSubstitutionFlags; + (function (ESNextSubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ESNextSubstitutionFlags[ESNextSubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ESNextSubstitutionFlags || (ESNextSubstitutionFlags = {})); function transformESNext(context) { - var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + var enabledSubstitutions; + var enclosingFunctionFlags; + var enclosingSuperContainerFlags = 0; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -49739,53 +51933,95 @@ var ts; function visitorNoDestructuringValue(node) { return visitorWorker(node, /*noDestructuringValue*/ true); } + function visitorNoAsyncModifier(node) { + if (node.kind === 120 /* AsyncKeyword */) { + return undefined; + } + return node; + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 8 /* ContainsESNext */) === 0) { return node; } switch (node.kind) { - case 177 /* ObjectLiteralExpression */: + case 191 /* AwaitExpression */: + return visitAwaitExpression(node); + case 197 /* YieldExpression */: + return visitYieldExpression(node); + case 222 /* LabeledStatement */: + return visitLabeledStatement(node); + case 178 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 215 /* ForOfStatement */: - return visitForOfStatement(node); - case 213 /* ForStatement */: + case 216 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForStatement */: return visitForStatement(node); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return visitVoidExpression(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return visitConstructorDeclaration(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return visitArrowFunction(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return visitParameter(node); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); } } + function visitAwaitExpression(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.createArrayLiteral([ts.createLiteral("await"), expression])), + /*location*/ node), node); + } + return ts.visitEachChild(node, visitor, context); + } + function visitYieldExpression(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.updateYield(node, node.asteriskToken, node.asteriskToken + ? createAsyncDelegatorHelper(context, expression, expression) + : ts.createArrayLiteral(expression + ? [ts.createLiteral("yield"), expression] + : [ts.createLiteral("yield")])); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + var statement = ts.unwrapInnermostStatementOfLabel(node); + if (statement.kind === 216 /* ForOfStatement */ && statement.awaitModifier) { + return visitForOfStatement(statement, node); + } + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), node); + } + return ts.visitEachChild(node, visitor, context); + } function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 262 /* SpreadAssignment */) { + if (e.kind === 263 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -49797,7 +52033,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 260 /* PropertyAssignment */) { + if (e.kind === 261 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -49819,7 +52055,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 177 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 178 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -49841,7 +52077,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576 /* ContainsObjectRest */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 25 /* CommaToken */) { + else if (node.operatorToken.kind === 26 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -49869,41 +52105,101 @@ var ts; * * @param node A ForOfStatement. */ - function visitForOfStatement(node) { - var leadingStatements; - var temp; - var initializer = ts.skipParentheses(node.initializer); - if (initializer.transformFlags & 1048576 /* ContainsObjectRest */) { - if (ts.isVariableDeclarationList(initializer)) { - temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var firstDeclaration = ts.firstOrUndefined(initializer.declarations); - var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1 /* ObjectRest */, temp, - /*doNotRecordTempVariablesInLine*/ false, - /*skipInitializer*/ true); - if (ts.some(declarations)) { - var statement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations)); - ts.setTextRange(statement, initializer); - leadingStatements = ts.append(leadingStatements, statement); - } - } - else if (ts.isAssignmentPattern(initializer)) { - temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1 /* ObjectRest */); - leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); - } + function visitForOfStatement(node, outermostLabeledStatement) { + if (node.initializer.transformFlags & 1048576 /* ContainsObjectRest */) { + node = transformForOfStatementWithObjectRest(node); } - if (temp) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) - : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), /*multiLine*/ true), statement); - return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + if (node.awaitModifier) { + return transformForAwaitOfStatement(node, outermostLabeledStatement); + } + else { + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); + } + } + function transformForOfStatementWithObjectRest(node) { + var initializerWithoutParens = ts.skipParentheses(node.initializer); + if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) { + var bodyLocation = void 0; + var statementsLocation = void 0; + var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); + var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)]; + if (ts.isBlock(node.statement)) { + ts.addRange(statements, node.statement.statements); + bodyLocation = node.statement; + statementsLocation = node.statement.statements; + } + return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), expression, block); + ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), + /*multiLine*/ true), bodyLocation)); } - return ts.visitEachChild(node, visitor, context); + return node; + } + function convertForOfStatementHead(node, boundValue) { + var binding = ts.createForOfBindingStatement(node.initializer, boundValue); + var bodyLocation; + var statementsLocation; + var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), + /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + } + function transformForAwaitOfStatement(node, outermostLabeledStatement) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(/*recordTempVariable*/ undefined); + var values = createAsyncValuesHelper(context, expression, /*location*/ node.expression); + var next = ts.createYield( + /*asteriskToken*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []) + ]) + : ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, [])); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor( + /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), + ts.createVariableDeclaration(result, /*type*/ undefined, next) + ]), node.expression), 2097152 /* NoHoisting */), + /*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")), + /*incrementor*/ ts.createAssignment(result, next), + /*statement*/ convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"))), + /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1 /* SingleLine */)), ts.createBlock([ + ts.createTry( + /*tryBlock*/ ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createYield( + /*asteriskToken*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createFunctionCall(returnMethod, iterator, []) + ]) + : ts.createFunctionCall(returnMethod, iterator, [])))), 1 /* SingleLine */) + ]), + /*catchClause*/ undefined, + /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1 /* SingleLine */) + ]), 1 /* SingleLine */)) + ])); } function visitParameter(node) { if (node.transformFlags & 1048576 /* ContainsObjectRest */) { @@ -49912,48 +52208,137 @@ var ts; return ts.updateParameter(node, /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), + /*questionToken*/ undefined, /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } function visitConstructorDeclaration(node) { - return ts.updateConstructor(node, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0 /* Normal */; + var updated = ts.updateConstructor(node, /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitGetAccessorDeclaration(node) { - return ts.updateGetAccessor(node, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0 /* Normal */; + var updated = ts.updateGetAccessor(node, /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitSetAccessorDeclaration(node) { - return ts.updateSetAccessor(node, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0 /* Normal */; + var updated = ts.updateSetAccessor(node, /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitMethodDeclaration(node) { - return ts.updateMethod(node, - /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateMethod(node, + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + ? undefined + : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + ? undefined + : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, node.modifiers, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateArrowFunction(node, node.modifiers, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, node.modifiers, node.name, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + ? undefined + : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; + } + function transformAsyncGeneratorFunctionBody(node) { + resumeLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + appendObjectRestAssignmentsIfNeeded(statements, node); + statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( + /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.updateBlock(node.body, statements); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; } function transformFunctionBody(node) { resumeLexicalEnvironment(); - var leadingStatements; + var statementOffset = 0; + var statements = []; + var body = ts.visitNode(node.body, visitor, ts.isConciseBody); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); + } + ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(/*statements*/ undefined, node)); + var trailingStatements = endLexicalEnvironment(); + if (statementOffset > 0 || ts.some(statements) || ts.some(trailingStatements)) { + var block = ts.convertToFunctionBody(body, /*multiLine*/ true); + ts.addRange(statements, block.statements.slice(statementOffset)); + ts.addRange(statements, trailingStatements); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); + } + return body; + } + function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; if (parameter.transformFlags & 1048576 /* ContainsObjectRest */) { @@ -49964,18 +52349,117 @@ var ts; if (ts.some(declarations)) { var statement = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(declarations)); - ts.setEmitFlags(statement, 524288 /* CustomPrologue */); - leadingStatements = ts.append(leadingStatements, statement); + ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + statements = ts.append(statements, statement); } } } - var body = ts.visitNode(node.body, visitor, ts.isConciseBody); - var trailingStatements = endLexicalEnvironment(); - if (ts.some(leadingStatements) || ts.some(trailingStatements)) { - var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); + return statements; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(181 /* CallExpression */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(180 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(229 /* ClassDeclaration */); + context.enableEmitNotification(151 /* MethodDeclaration */); + context.enableEmitNotification(153 /* GetAccessor */); + context.enableEmitNotification(154 /* SetAccessor */); + context.enableEmitNotification(152 /* Constructor */); + } + } + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. + */ + function onEmitNode(hint, node, emitCallback) { + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint The context for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 180 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 181 /* CallExpression */: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 /* ClassDeclaration */ + || kind === 152 /* Constructor */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); } - return body; } } ts.transformESNext = transformESNext; @@ -49995,6 +52479,43 @@ var ts; /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; + var asyncGeneratorHelper = { + name: "typescript:asyncGenerator", + scoped: false, + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + }; + function createAsyncGeneratorHelper(context, generatorFunc) { + context.requestEmitHelper(asyncGeneratorHelper); + // Mark this node as originally an async function + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; + return ts.createCall(ts.getHelperName("__asyncGenerator"), + /*typeArguments*/ undefined, [ + ts.createThis(), + ts.createIdentifier("arguments"), + generatorFunc + ]); + } + var asyncDelegator = { + name: "typescript:asyncDelegator", + scoped: false, + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " + }; + function createAsyncDelegatorHelper(context, expression, location) { + context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + /*typeArguments*/ undefined, [expression]), location); + } + var asyncValues = { + name: "typescript:asyncValues", + scoped: false, + text: "\n var __asyncValues = (this && this.__asyncIterator) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator];\n return m ? m.call(o) : typeof __values === \"function\" ? __values(o) : o[Symbol.iterator]();\n };\n " + }; + function createAsyncValuesHelper(context, expression, location) { + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + /*typeArguments*/ undefined, [expression]), location); + } })(ts || (ts = {})); /// /// @@ -50004,7 +52525,6 @@ var ts; (function (ts) { function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; return transformSourceFile; /** * Transform JSX-specific syntax in a SourceFile. @@ -50015,10 +52535,8 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -50031,11 +52549,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 248 /* JsxElement */: + case 249 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -50045,11 +52563,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return visitJsxExpression(node); - case 248 /* JsxElement */: + case 249 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -50110,7 +52628,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 255 /* JsxExpression */) { + else if (node.kind === 256 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -50202,7 +52720,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 248 /* JsxElement */) { + if (node.kind === 249 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -50494,375 +53012,6 @@ var ts; /// /*@internal*/ var ts; -(function (ts) { - var ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - /** Enables substitutions for async methods with `super` calls. */ - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); - function transformES2017(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var resolver = context.getEmitResolver(); - var compilerOptions = context.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - // These variables contain state that changes as we descend into the tree. - var currentSourceFile; - /** - * Keeps track of whether expression substitution has been enabled for specific edge cases. - * They are persisted between each SourceFile transformation and should not be reset. - */ - var enabledSubstitutions; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - var currentSuperContainer; - // Save the previous transformation hooks. - var previousOnEmitNode = context.onEmitNode; - var previousOnSubstituteNode = context.onSubstituteNode; - // Set new transformation hooks. - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - var visited = ts.visitEachChild(node, visitor, context); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; - return visited; - } - function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2017 */) === 0) { - return node; - } - switch (node.kind) { - case 119 /* AsyncKeyword */: - // ES2017 async modifier should be elided for targets < ES2017 - return undefined; - case 190 /* AwaitExpression */: - // ES2017 'await' expressions must be transformed for targets < ES2017. - return visitAwaitExpression(node); - case 150 /* MethodDeclaration */: - // ES2017 method declarations may be 'async' - return visitMethodDeclaration(node); - case 227 /* FunctionDeclaration */: - // ES2017 function declarations may be 'async' - return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: - // ES2017 function expressions may be 'async' - return visitFunctionExpression(node); - case 186 /* ArrowFunction */: - // ES2017 arrow functions may be 'async' - return visitArrowFunction(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - /** - * Visits an AwaitExpression node. - * - * This function will be called any time a ES2017 await expression is encountered. - * - * @param node The node to visit. - */ - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.setTextRange(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); - } - /** - * Visits a MethodDeclaration node. - * - * This function will be called when one of the following conditions are met: - * - The node is marked as async - * - * @param node The node to visit. - */ - function visitMethodDeclaration(node) { - return ts.updateMethod(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - /** - * Visits a FunctionDeclaration node. - * - * This function will be called when one of the following conditions are met: - * - The node is marked async - * - * @param node The node to visit. - */ - function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - /** - * Visits a FunctionExpression node. - * - * This function will be called when one of the following conditions are met: - * - The node is marked async - * - * @param node The node to visit. - */ - function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { - return ts.createOmittedExpression(); - } - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - /** - * Visits an ArrowFunction. - * - * This function will be called when one of the following conditions are met: - * - The node is marked async - * - * @param node The node to visit. - */ - function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function transformAsyncFunctionBody(node) { - resumeLexicalEnvironment(); - var original = ts.getOriginalNode(node, ts.isFunctionLike); - var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 186 /* 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 - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, /*multiLine*/ true); - ts.setTextRange(block, node.body); - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= 2 /* ES2015 */) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, advancedAsyncSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, asyncSuperHelper); - } - } - return block; - } - else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); - var declarations = endLexicalEnvironment(); - if (ts.some(declarations)) { - var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); - } - return expression; - } - } - function transformFunctionBodyWorker(body, start) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); - } - else { - startLexicalEnvironment(); - var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); - var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); - } - } - function getPromiseConstructor(type) { - var typeName = type && ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(180 /* CallExpression */); - context.enableSubstitution(178 /* PropertyAccessExpression */); - context.enableSubstitution(179 /* ElementAccessExpression */); - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(228 /* ClassDeclaration */); - context.enableEmitNotification(150 /* MethodDeclaration */); - context.enableEmitNotification(152 /* GetAccessor */); - context.enableEmitNotification(153 /* SetAccessor */); - context.enableEmitNotification(151 /* Constructor */); - } - } - function substituteExpression(node) { - switch (node.kind) { - case 178 /* PropertyAccessExpression */: - return substitutePropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: - return substituteElementAccessExpression(node); - case 180 /* CallExpression */: - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { - return substituteCallExpression(node); - } - break; - } - return node; - } - function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } - return node; - } - function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } - return node; - } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 228 /* ClassDeclaration */ - || kind === 151 /* Constructor */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */; - } - /** - * Hook for node emit. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(hint, node, emitCallback) { - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var savedCurrentSuperContainer = currentSuperContainer; - currentSuperContainer = node; - previousOnEmitNode(hint, node, emitCallback); - currentSuperContainer = savedCurrentSuperContainer; - } - else { - previousOnEmitNode(hint, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { - return substituteExpression(node); - } - return node; - } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value"), location); - } - else { - return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); - } - } - ts.transformES2017 = transformES2017; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); - var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(38 /* AsteriskToken */), - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, body); - // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 131072 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__awaiter"), - /*typeArguments*/ undefined, [ - ts.createThis(), - hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), - promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), - generatorFunc - ]); - } - var awaiterHelper = { - name: "typescript:awaiter", - scoped: false, - priority: 5, - text: "\n var __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 asyncSuperHelper = { - name: "typescript:async-super", - scoped: true, - text: "\n const _super = name => super[name];" - }; - var advancedAsyncSuperHelper = { - name: "typescript:advanced-async-super", - scoped: true, - text: "\n const _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);" - }; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; (function (ts) { function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; @@ -50878,7 +53027,7 @@ var ts; return node; } switch (node.kind) { - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -50886,9 +53035,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 61 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 39 /* AsteriskAsteriskToken */: + case 40 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -50930,6 +53079,7 @@ var ts; })(ts || (ts = {})); /// /// +/// /*@internal*/ var ts; (function (ts) { @@ -51053,6 +53203,7 @@ var ts; })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -51089,7 +53240,7 @@ var ts; * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. - **/ + */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; @@ -51101,13 +53252,13 @@ var ts; * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. - **/ + */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 218 /* ReturnStatement */ + && node.kind === 219 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { @@ -51131,100 +53282,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 96 /* SuperKeyword */) { + if (node.kind === 97 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 114 /* StaticKeyword */: + case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return visitClassDeclaration(node); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return visitClassExpression(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return visitParameter(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return visitArrowFunction(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 70 /* Identifier */: + case 71 /* Identifier */: return visitIdentifier(node); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return visitCaseBlock(node); - case 206 /* Block */: + case 207 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitLabeledStatement(node); - case 211 /* DoStatement */: - case 212 /* WhileStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return visitExpressionStatement(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return visitCatchClause(node); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return visitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return visitNewExpression(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 12 /* NoSubstitutionTemplateLiteral */: - case 13 /* TemplateHead */: - case 14 /* TemplateMiddle */: - case 15 /* TemplateTail */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* TemplateHead */: + case 15 /* TemplateMiddle */: + case 16 /* TemplateTail */: return visitTemplateLiteral(node); - case 182 /* TaggedTemplateExpression */: + case 9 /* StringLiteral */: + return visitStringLiteral(node); + case 8 /* NumericLiteral */: + return visitNumericLiteral(node); + case 183 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return visitTemplateExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return visitYieldExpression(node); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return visitSpreadElement(node); - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return visitMetaProperty(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return visitAccessorDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -51234,8 +53389,9 @@ var ts; var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); + var statementOffset = ts.addStandardPrologue(statements, node.statements, /*ensureUseStrict*/ false); addCaptureThisForNodeIfNeeded(statements, node); + statementOffset = ts.addCustomPrologue(statements, node.statements, statementOffset, visitor); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); @@ -51307,13 +53463,13 @@ var ts; // it is possible if either // - break/continue is 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 === 217 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 218 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 217 /* BreakStatement */) { + if (node.kind === 218 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -51324,7 +53480,7 @@ var ts; } } else { - if (node.kind === 217 /* BreakStatement */) { + if (node.kind === 218 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -51343,10 +53499,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 25 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 25 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -51386,10 +53542,10 @@ var ts; statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 2097152 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -51451,8 +53607,8 @@ var ts; // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - if (ts.getEmitFlags(node) & 32768 /* Indented */) { - ts.setEmitFlags(classFunction, 32768 /* Indented */); + if (ts.getEmitFlags(node) & 65536 /* Indented */) { + ts.setEmitFlags(classFunction, 65536 /* Indented */); } // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter @@ -51480,8 +53636,8 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); - var localName = ts.getLocalName(node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = ts.createPartiallyEmittedExpression(localName); @@ -51525,7 +53681,7 @@ var ts; var constructorFunction = ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*asteriskToken*/ undefined, ts.getDeclarationName(node), + /*asteriskToken*/ undefined, ts.getInternalName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); @@ -51572,17 +53728,20 @@ var ts; statementOffset = 0; } else if (constructor) { - // Otherwise, try to emit all potential prologue directives first. - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + statementOffset = ts.addStandardPrologue(statements, constructor.body.statements, /*ensureUseStrict*/ false); } if (constructor) { addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + if (!hasSynthesizedSuper) { + // If no super call has been synthesized, emit custom prologue directives. + statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor); + } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -51621,17 +53780,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 218 /* ReturnStatement */) { + if (statement.kind === 219 /* ReturnStatement */) { return true; } - else if (statement.kind === 210 /* IfStatement */) { + else if (statement.kind === 211 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 206 /* Block */) { + else if (statement.kind === 207 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -51689,7 +53848,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -51699,8 +53858,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 193 /* BinaryExpression */ - || superCallExpression.left.kind !== 180 /* CallExpression */) { + if (superCallExpression.kind !== 194 /* BinaryExpression */ + || superCallExpression.left.kind !== 181 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -51812,10 +53971,10 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 524288 /* CustomPrologue */)); + /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 524288 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -51833,7 +53992,7 @@ var ts; ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */)); statement.startsOnNewLine = true; ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 524288 /* CustomPrologue */); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */); statements.push(statement); } /** @@ -51845,7 +54004,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -51874,7 +54033,7 @@ var ts; ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) ])), - /*location*/ parameter), 524288 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -51886,7 +54045,7 @@ var ts; : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 524288 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); statements.push(forStatement); } @@ -51897,7 +54056,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 186 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 187 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -51908,7 +54067,7 @@ var ts; ts.createVariableDeclaration("_this", /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 524288 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); @@ -51917,25 +54076,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return statements; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 151 /* Constructor */: + case 152 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: ts.Debug.failBadSyntaxKind(node); @@ -51964,20 +54123,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 205 /* SemicolonClassElement */: + case 206 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 151 /* Constructor */: + case 152 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -52112,7 +54271,7 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; @@ -52127,7 +54286,7 @@ var ts; exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, name, + /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -52150,7 +54309,7 @@ var ts; exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -52169,7 +54328,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 228 /* FunctionDeclaration */ || node.kind === 186 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -52196,8 +54355,8 @@ var ts; resumeLexicalEnvironment(); if (ts.isBlock(body)) { // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + // addStandardPrologue will put already-existing directives at the beginning of the target statement-array + statementOffset = ts.addStandardPrologue(statements, body.statements, /*ensureUseStrict*/ false); } addCaptureThisForNodeIfNeeded(statements, node); addDefaultValueAssignmentsIfNeeded(statements, node); @@ -52207,6 +54366,8 @@ var ts; multiLine = true; } if (ts.isBlock(body)) { + // addCustomPrologue puts already-existing directives at the beginning of the target statement-array + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor); statementsLocation = body.statements; ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); // If the original body was a multi-line block, this must be a multi-line block. @@ -52215,7 +54376,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 186 /* ArrowFunction */); + ts.Debug.assert(node.kind === 187 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -52252,7 +54413,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -52282,9 +54443,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -52299,10 +54460,13 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { + // By default we always emit the RHS at the end of a flattened destructuring + // expression. If we are in a state where we do not need the destructuring value, + // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -52337,13 +54501,13 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } - (assignments || (assignments = [])).push(assignment); + assignments = ts.append(assignments, assignment); } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); })), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 26 /* CommaToken */, acc); })), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -52495,11 +54659,24 @@ var ts; if (convertedLoopState && !convertedLoopState.labels) { convertedLoopState.labels = ts.createMap(); } - var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); - return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 214 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 215 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 216 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } + } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); @@ -52516,9 +54693,74 @@ var ts; return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } - function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { + function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { + var statements = []; + if (ts.isVariableDeclarationList(node.initializer)) { + if (node.initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); + ts.setOriginalNode(declarationList, node.initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, declarationList)); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, boundValue) + ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = ts.createAssignment(node.initializer, boundValue); + if (ts.isDestructuringAssignment(assignment)) { + ts.aggregateTransformFlags(assignment); + statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + } + else { + assignment.end = node.initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), + /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + } + function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -52540,109 +54782,65 @@ var ts; // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; // In the case where the user wrote an identifier as the RHS, like this: // // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - var elementAccess = ts.createElementAccess(rhsReference, counter); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations); - ts.setOriginalNode(declarationList, initializer); - ts.setTextRange(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.setTextRange(ts.createVariableStatement( - /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, elementAccess); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(assignment, visitor, context, 0 /* All */))); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } + var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation)); - ts.setTextRange(body, bodyLocation); - ts.setEmitFlags(body, 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + var forStatement = ts.setTextRange(ts.createFor( + /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) - ]), node.expression), 1048576 /* NoHoisting */), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); + ]), node.expression), 2097152 /* NoHoisting */), + /*condition*/ ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), + /*incrementor*/ ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), + /*statement*/ convertForOfStatementHead(node, ts.createElementAccess(rhsReference, counter), convertedLoopBodyStatements)), + /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } - function visitIterationStatement(node, outermostLabeledStatement) { - switch (node.kind) { - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 213 /* ForStatement */: - return visitForStatement(node, outermostLabeledStatement); - case 214 /* ForInStatement */: - return visitForInStatement(node, outermostLabeledStatement); - case 215 /* ForOfStatement */: - return visitForOfStatement(node, outermostLabeledStatement); - } + function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(/*recordTempVariable*/ undefined); + var values = ts.createValuesHelper(context, expression, node.expression); + var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor( + /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), + ts.createVariableDeclaration(result, /*type*/ undefined, next) + ]), node.expression), 2097152 /* NoHoisting */), + /*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")), + /*incrementor*/ ts.createAssignment(result, next), + /*statement*/ convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), + /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1 /* SingleLine */)), ts.createBlock([ + ts.createTry( + /*tryBlock*/ ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ]), + /*catchClause*/ undefined, + /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1 /* SingleLine */) + ]), 1 /* SingleLine */)) + ])); } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -52663,7 +54861,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 143 /* ComputedPropertyName */) { + if (property.name.kind === 144 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -52677,7 +54875,7 @@ var ts; var temp = ts.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768 /* Indented */)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536 /* Indented */)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -52702,7 +54900,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -52735,11 +54933,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 226 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 227 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -52776,7 +54974,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -52794,24 +54992,24 @@ var ts; else { loopBody = ts.createBlock([loopBody], /*multiline*/ true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ - && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8 /* CapturesThis */; } if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 131072 /* AsyncFunctionBody */; + loopBodyFlags |= 262144 /* AsyncFunctionBody */; } var convertedLoopVariable = ts.createVariableStatement( /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) - ]), 1048576 /* NoHoisting */)); + ]), 2097152 /* NoHoisting */)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; // propagate state from the inner loop to the outer loop if necessary @@ -52874,7 +55072,7 @@ var ts; statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -52898,7 +55096,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 57 /* EqualsToken */, source); + return ts.createBinary(target, 58 /* EqualsToken */, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -52916,7 +55114,9 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38 /* AsteriskToken */), call) : call; + var callResult = isAsyncBlockContainingAwait + ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); @@ -52936,10 +55136,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -53017,20 +55217,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -53090,7 +55290,7 @@ var ts; var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { - var temp = ts.createTempVariable(undefined); + var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); @@ -53135,7 +55335,20 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var updated = ts.visitEachChild(node, visitor, context); + var updated; + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */) { + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (node.kind === 153 /* GetAccessor */) { + updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + } + else { + updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body); + } + } + else { + updated = ts.visitEachChild(node, visitor, context); + } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return updated; @@ -53195,7 +55408,7 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall; @@ -53228,7 +55441,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -53276,14 +55489,28 @@ var ts; var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 /* ArrayLiteralExpression */ - ? ts.createArraySlice(segments[0]) - : segments[0]; + if (compilerOptions.downlevelIteration) { + if (segments.length === 1) { + var firstSegment = segments[0]; + if (ts.isCallExpression(firstSegment) + && ts.isIdentifier(firstSegment.expression) + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) + && firstSegment.expression.text === "___spread") { + return segments[0]; + } + } + return ts.createSpreadHelper(context, segments); + } + else { + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 177 /* ArrayLiteralExpression */ + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + // Rewrite using the pattern .concat(, , ...) + return ts.createArrayConcat(segments.shift(), segments); } - // Rewrite using the pattern .concat(, , ...) - return ts.createArrayConcat(segments.shift(), segments); } function partitionSpread(node) { return ts.isSpreadExpression(node) @@ -53315,6 +55542,28 @@ var ts; function visitTemplateLiteral(node) { return ts.setTextRange(ts.createLiteral(node.text), node); } + /** + * Visits a string literal with an extended unicode escape. + * + * @param node A string literal. + */ + function visitStringLiteral(node) { + if (node.hasExtendedUnicodeEscape) { + return ts.setTextRange(ts.createLiteral(node.text), node); + } + return node; + } + /** + * Visits a binary or octal (ES6) numeric literal. + * + * @param node A string literal. + */ + function visitNumericLiteral(node) { + if (node.numericLiteralFlags & 48 /* BinaryOrOctalSpecifier */) { + return ts.setTextRange(ts.createNumericLiteral(node.text), node); + } + return node; + } /** * Visits a TaggedTemplateExpression node. * @@ -53367,7 +55616,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 12 /* NoSubstitutionTemplateLiteral */ || node.kind === 15 /* TemplateTail */; + var isLast = node.kind === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -53465,7 +55714,7 @@ var ts; : ts.createIdentifier("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (node.keywordToken === 94 /* NewKeyword */ && node.name.text === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -53502,7 +55751,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(71 /* Identifier */); } } /** @@ -53512,14 +55761,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(151 /* Constructor */); - context.enableEmitNotification(150 /* MethodDeclaration */); - context.enableEmitNotification(152 /* GetAccessor */); - context.enableEmitNotification(153 /* SetAccessor */); - context.enableEmitNotification(186 /* ArrowFunction */); - context.enableEmitNotification(185 /* FunctionExpression */); - context.enableEmitNotification(227 /* FunctionDeclaration */); + context.enableSubstitution(99 /* ThisKeyword */); + context.enableEmitNotification(152 /* Constructor */); + context.enableEmitNotification(151 /* MethodDeclaration */); + context.enableEmitNotification(153 /* GetAccessor */); + context.enableEmitNotification(154 /* SetAccessor */); + context.enableEmitNotification(187 /* ArrowFunction */); + context.enableEmitNotification(186 /* FunctionExpression */); + context.enableEmitNotification(228 /* FunctionDeclaration */); } } /** @@ -53544,10 +55793,10 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + return ts.setTextRange(ts.getGeneratedNameForNode(original), node); } } return node; @@ -53561,10 +55810,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 175 /* BindingElement */: - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 226 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -53577,9 +55826,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -53590,14 +55839,39 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { + return ts.setTextRange(ts.getGeneratedNameForNode(declaration.name), node); } } return node; } + function isPartOfClassBody(declaration, node) { + var currentNode = ts.getParseTreeNode(node); + if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) { + // if the node has no correlation to a parse tree node, its definitely not + // part of the body. + // if the node is outside of the document range of the declaration, its + // definitely not part of the body. + return false; + } + var blockScope = ts.getEnclosingBlockScopeContainer(declaration); + while (currentNode) { + if (currentNode === blockScope || currentNode === declaration) { + // if we are in the enclosing block scope of the declaration, we are definitely + // not inside the class body. + return false; + } + if (ts.isClassElement(currentNode) && currentNode.parent === declaration) { + // we are in the class body, but we treat static fields as outside of the class body + return currentNode.kind !== 149 /* PropertyDeclaration */ + || (ts.getModifierFlags(currentNode) & 32 /* Static */) === 0; + } + currentNode = currentNode.parent; + } + return false; + } /** * Substitutes `this` when contained within an arrow function. * @@ -53611,8 +55885,9 @@ var ts; return node; } function getClassMemberPrefix(node, member) { - var expression = ts.getLocalName(node); - return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + return ts.hasModifier(member, 32 /* Static */) + ? ts.getInternalName(node) + : ts.createPropertyAccess(ts.getInternalName(node), "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { if (!constructor || !hasExtendsClause) { @@ -53622,19 +55897,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 210 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 181 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 198 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -53675,15 +55950,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(250 /* JsxOpeningElement */); - context.enableEmitNotification(251 /* JsxClosingElement */); - context.enableEmitNotification(249 /* JsxSelfClosingElement */); + context.enableEmitNotification(251 /* JsxOpeningElement */); + context.enableEmitNotification(252 /* JsxClosingElement */); + context.enableEmitNotification(250 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178 /* PropertyAccessExpression */); - context.enableSubstitution(260 /* PropertyAssignment */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(261 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -53702,9 +55977,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 250 /* JsxOpeningElement */: - case 251 /* JsxClosingElement */: - case 249 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + case 252 /* JsxClosingElement */: + case 250 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -53761,7 +56036,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + if (token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -54041,13 +56316,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 211 /* DoStatement */: + case 212 /* DoStatement */: return visitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return visitWhileStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -54060,24 +56335,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return visitAccessorDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitForInStatement(node); - case 217 /* BreakStatement */: + case 218 /* BreakStatement */: return visitBreakStatement(node); - case 216 /* ContinueStatement */: + case 217 /* ContinueStatement */: return visitContinueStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -54098,21 +56373,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return visitConditionalExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return visitYieldExpression(node); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return visitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -54125,9 +56400,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -54145,7 +56420,7 @@ var ts; */ function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, /*asteriskToken*/ undefined, node.name, @@ -54183,7 +56458,7 @@ var ts; */ function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, @@ -54257,7 +56532,7 @@ var ts; state = ts.createTempVariable(/*recordTempVariable*/ undefined); // Build the generator resumeLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + var statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); ts.addRange(statements, endLexicalEnvironment()); @@ -54293,7 +56568,7 @@ var ts; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -54326,23 +56601,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 58 /* FirstCompoundAssignment */ - && kind <= 69 /* LastCompoundAssignment */; + return kind >= 59 /* FirstCompoundAssignment */ + && kind <= 70 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 58 /* PlusEqualsToken */: return 36 /* PlusToken */; - case 59 /* MinusEqualsToken */: return 37 /* MinusToken */; - case 60 /* AsteriskEqualsToken */: return 38 /* AsteriskToken */; - case 61 /* AsteriskAsteriskEqualsToken */: return 39 /* AsteriskAsteriskToken */; - case 62 /* SlashEqualsToken */: return 40 /* SlashToken */; - case 63 /* PercentEqualsToken */: return 41 /* PercentToken */; - case 64 /* LessThanLessThanEqualsToken */: return 44 /* LessThanLessThanToken */; - case 65 /* GreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanToken */; - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanGreaterThanToken */; - case 67 /* AmpersandEqualsToken */: return 47 /* AmpersandToken */; - case 68 /* BarEqualsToken */: return 48 /* BarToken */; - case 69 /* CaretEqualsToken */: return 49 /* CaretToken */; + case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; + case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; + case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; + case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; + case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; + case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; + case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; + case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; + case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; + case 69 /* BarEqualsToken */: return 49 /* BarToken */; + case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; } } /** @@ -54355,7 +56630,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -54367,7 +56642,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -54399,7 +56674,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 25 /* CommaToken */) { + else if (node.operatorToken.kind === 26 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -54454,7 +56729,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -54485,7 +56760,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -54548,11 +56823,13 @@ var ts; // .yield resumeLabel, (a()) // .mark resumeLabel // x = %sent%; - // NOTE: we are explicitly not handling YieldStar at this time. var resumeLabel = defineLabel(); var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { - emitYieldStar(expression, /*location*/ node); + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + ? ts.createValuesHelper(context, expression, /*location*/ node) + : expression; + emitYieldStar(iterator, /*location*/ node); } else { emitYield(expression, /*location*/ node); @@ -54586,25 +56863,27 @@ var ts; // .mark resumeLabel // ar = _a.concat([%sent%, 2]); var numInitialElements = countInitialNodesWithoutYield(elements); - var temp = declareLocal(); - var hasAssignedTemp = false; + var temp; if (numInitialElements > 0) { + temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement ? [leadingElement].concat(initialElements) : initialElements)); leadingElement = undefined; - hasAssignedTemp = true; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); - return hasAssignedTemp + return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { + var hasAssignedTemp = temp !== undefined; + if (!temp) { + temp = declareLocal(); + } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); - hasAssignedTemp = true; leadingElement = undefined; expressions = []; } @@ -54739,38 +57018,38 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 206 /* Block */: + case 207 /* Block */: return transformAndEmitBlock(node); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return transformAndEmitIfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return transformAndEmitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return transformAndEmitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 216 /* ContinueStatement */: + case 217 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 217 /* BreakStatement */: + case 218 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return transformAndEmitWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return transformAndEmitTryStatement(node); default: - return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); + return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); } } function transformAndEmitBlock(node) { @@ -54979,7 +57258,7 @@ var ts; beginScriptLoopBlock(); } var initializer = node.initializer; - if (ts.isVariableDeclarationList(initializer)) { + if (initializer && ts.isVariableDeclarationList(initializer)) { for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { var variable = _a[_i]; hoistVariableDeclaration(variable.name); @@ -54987,7 +57266,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = ts.updateFor(node, variables.length > 0 ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.incrementor, visitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -55079,7 +57358,7 @@ var ts; var variable = _a[_i]; hoistVariableDeclaration(variable.name); } - node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -55118,11 +57397,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function transformAndEmitReturnStatement(node) { - emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true), + emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node); } function visitReturnStatement(node) { - return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true), + return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node); } function transformAndEmitWithStatement(node) { @@ -55187,7 +57466,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 257 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 258 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -55200,7 +57479,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 256 /* CaseClause */) { + if (clause.kind === 257 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -55356,7 +57635,7 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { + if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); @@ -55375,7 +57654,7 @@ var ts; } function cacheExpression(node) { var temp; - if (ts.isGeneratedIdentifier(node)) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } temp = ts.createTempVariable(hoistVariableDeclaration); @@ -55503,15 +57782,23 @@ var ts; */ function beginCatchBlock(variable) { ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = []; - context.enableSubstitution(70 /* Identifier */); + // generated identifiers should already be unique within a file + var name; + if (ts.isGeneratedIdentifier(variable.name)) { + name = variable.name; + hoistVariableDeclaration(variable.name); + } + else { + var text = variable.name.text; + name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = []; + context.enableSubstitution(71 /* Identifier */); + } + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } - renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1 /* Catch */); var endLabel = exception.endLabel; @@ -55781,7 +58068,7 @@ var ts; */ function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = getInstructionName(instruction); + ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -55959,7 +58246,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 262144 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -56398,11 +58685,12 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); /// /// +/// /*@internal*/ var ts; (function (ts) { @@ -56424,12 +58712,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(194 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(192 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(193 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(262 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(265 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -56442,9 +58730,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (ts.isDeclarationFile(node) || !(ts.isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } currentSourceFile = node; @@ -56457,6 +58743,12 @@ var ts; currentModuleInfo = undefined; return ts.aggregateTransformFlags(updated); } + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) { + return true; + } + return false; + } /** * Transforms a SourceFile into a CommonJS module. * @@ -56465,16 +58757,19 @@ var ts; function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + ts.addRange(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. ts.addEmitHelper(updated, exportStarHelper); } return updated; @@ -56636,15 +58931,20 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); // Find the name of the module alias, if there is one var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); + // It is possible that externalModuleName is undefined if it is not string literal. + // This can happen in the invalid import syntax. + // E.g : "import * from alias from 'someLib';" + if (externalModuleName) { + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; @@ -56657,18 +58957,18 @@ var ts; function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var statementOffset = ts.addPrologue(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body // and merge any new lexical declarations. ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); var body = ts.createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues) { // If we have any `export * from ...` declarations @@ -56711,23 +59011,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return visitExportDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return visitClassDeclaration(node); - case 299 /* MergeDeclarationMarker */: + case 297 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 300 /* EndOfDeclarationMarker */: + case 298 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: // This visitor does not descend into the tree, as export/import statements @@ -57029,7 +59329,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -57041,7 +59341,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -57084,10 +59384,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240 /* NamedImports */: + case 241 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -57217,7 +59517,7 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), @@ -57225,11 +59525,11 @@ var ts; ts.createIdentifier("exports"), ts.createLiteral("__esModule"), ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) + ts.createPropertyAssignment("value", ts.createLiteral(/*value*/ true)) ]) ])); } - ts.setEmitFlags(statement, 524288 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); return statement; } /** @@ -57269,8 +59569,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: return undefined; } return node; @@ -57286,7 +59586,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -57348,12 +59648,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return substituteBinaryExpression(node); - case 192 /* PostfixUnaryExpression */: - case 191 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -57374,7 +59674,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 265 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -57442,15 +59742,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 193 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { @@ -57490,6 +59790,7 @@ var ts; })(ts || (ts = {})); /// /// +/// /*@internal*/ var ts; (function (ts) { @@ -57502,11 +59803,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(194 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(192 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(193 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(265 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -57601,18 +59902,20 @@ var ts; for (var i = 0; i < externalImports.length; i++) { var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - var groupIndex = groupIndices.get(text); - if (groupIndex !== undefined) { - // deduplicate/group entries in dependency list by the dependency name - dependencyGroups[groupIndex].externalImports.push(externalImport); - } - else { - groupIndices.set(text, dependencyGroups.length); - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); + if (externalModuleName) { + var text = externalModuleName.text; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { + // deduplicate/group entries in dependency list by the dependency name + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices.set(text, dependencyGroups.length); + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } } return dependencyGroups; @@ -57670,7 +59973,8 @@ var ts; // only in the outer module body and not in the inner one. startLexicalEnvironment(); // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); // var __moduleName = context_1 && context_1.id; statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ @@ -57678,7 +59982,7 @@ var ts; /*type*/ undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) ]))); // Visit the synthetic external helpers import declaration if present - ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); // Visit the statements of the source file, emitting any transformations into // the `executeStatements` array. We do this *before* we fill the `setters` array // as we both emit transformations as well as aggregate some data used when creating @@ -57726,7 +60030,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 243 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 244 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -57751,7 +60055,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 243 /* ExportDeclaration */) { + if (externalImport.kind !== 244 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -57830,19 +60134,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } - // fall-through - case 236 /* ImportEqualsDeclaration */: + // falls through + case 237 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -57892,15 +60196,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -57973,7 +60277,7 @@ var ts; */ function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1 /* Export */)) { - hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); } @@ -58075,8 +60379,8 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 264 /* SourceFile */ + return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 265 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -58140,7 +60444,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -58153,7 +60457,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -58196,10 +60500,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240 /* NamedImports */: + case 241 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -58378,43 +60682,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return visitClassDeclaration(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitForInStatement(node); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return visitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return visitWhileStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitLabeledStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return visitWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return visitCaseBlock(node); - case 256 /* CaseClause */: + case 257 /* CaseClause */: return visitCaseClause(node); - case 257 /* DefaultClause */: + case 258 /* DefaultClause */: return visitDefaultClause(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return visitTryStatement(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return visitCatchClause(node); - case 206 /* Block */: + case 207 /* Block */: return visitBlock(node); - case 299 /* MergeDeclarationMarker */: + case 297 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 300 /* EndOfDeclarationMarker */: + case 298 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -58428,7 +60732,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58440,7 +60744,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58452,7 +60756,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + node = ts.updateForOf(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58472,6 +60776,9 @@ var ts; * @param node The node to visit. */ function visitForInitializer(node) { + if (!node) { + return node; + } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -58490,7 +60797,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -58498,7 +60805,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -58506,7 +60813,7 @@ var ts; * @param node The node to visit. */ function visitLabeledStatement(node) { - return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } /** * Visits the body of a WithStatement to hoist declarations. @@ -58514,7 +60821,7 @@ var ts; * @param node The node to visit. */ function visitWithStatement(node) { - return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } /** * Visits the body of a SwitchStatement to hoist declarations. @@ -58594,7 +60901,7 @@ var ts; */ function destructuringVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 193 /* BinaryExpression */) { + && node.kind === 194 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048 /* ContainsDestructuringAssignment */) { @@ -58622,7 +60929,7 @@ var ts; * @param node The destructuring target. */ function hasExportedReferenceInDestructuringTarget(node) { - if (ts.isAssignmentExpression(node)) { + if (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { return hasExportedReferenceInDestructuringTarget(node.left); } else if (ts.isSpreadExpression(node)) { @@ -58642,7 +60949,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 264 /* SourceFile */; + return container !== undefined && container.kind === 265 /* SourceFile */; } else { return false; @@ -58658,8 +60965,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: return undefined; } return node; @@ -58675,7 +60982,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -58720,12 +61027,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return substituteBinaryExpression(node); - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -58811,22 +61118,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 /* PostfixUnaryExpression */ + var expression = node.kind === 193 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 192 /* PostfixUnaryExpression */) { - expression = node.operator === 42 /* PlusPlusToken */ + if (node.kind === 193 /* PostfixUnaryExpression */) { + expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -58847,7 +61154,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 265 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -58888,8 +61195,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(264 /* SourceFile */); - context.enableSubstitution(70 /* Identifier */); + context.enableEmitNotification(265 /* SourceFile */); + context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { @@ -58900,7 +61207,7 @@ var ts; var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); if (externalHelpersModuleName) { var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); + var statementOffset = ts.addPrologue(statements, node.statements); ts.append(statements, ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); @@ -58915,10 +61222,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -59000,16 +61307,24 @@ var ts; return ts.transformModule; } } + var TransformationState; + (function (TransformationState) { + TransformationState[TransformationState["Uninitialized"] = 0] = "Uninitialized"; + TransformationState[TransformationState["Initialized"] = 1] = "Initialized"; + TransformationState[TransformationState["Completed"] = 2] = "Completed"; + TransformationState[TransformationState["Disposed"] = 3] = "Disposed"; + })(TransformationState || (TransformationState = {})); var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); - function getTransformers(compilerOptions) { + function getTransformers(compilerOptions, customTransformers) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; + ts.addRange(transformers, customTransformers && customTransformers.before); transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -59033,6 +61348,7 @@ var ts; if (languageVersion < 1 /* ES5 */) { transformers.push(ts.transformES5); } + ts.addRange(transformers, customTransformers && customTransformers.after); return transformers; } ts.getTransformers = getTransformers; @@ -59040,13 +61356,14 @@ var ts; * Transforms an array of SourceFiles by passing them through each transformer. * * @param resolver The emit resolver provided by the checker. - * @param host The emit host. - * @param sourceFiles An array of source files - * @param transforms An array of Transformers. + * @param host The emit host object used to interact with the file system. + * @param options Compiler options to surface in the `TransformationContext`. + * @param nodes An array of nodes to transform. + * @param transforms An array of `TransformerFactory` callbacks. + * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ - function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(301 /* Count */); - var lexicalEnvironmentDisabled = false; + function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { + var enabledSyntaxKindFeatures = new Array(299 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -59054,10 +61371,13 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; + var onSubstituteNode = function (_, node) { return node; }; + var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var state = 0 /* Uninitialized */; // The transformation context is provided to each transformer as part of transformer // initialization. var context = { - getCompilerOptions: function () { return host.getCompilerOptions(); }, + getCompilerOptions: function () { return options; }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, startLexicalEnvironment: startLexicalEnvironment, @@ -59068,42 +61388,53 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, - isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, - isEmitNotificationEnabled: isEmitNotificationEnabled + isSubstitutionEnabled: isSubstitutionEnabled, + isEmitNotificationEnabled: isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode; }, + set onSubstituteNode(value) { + ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode; }, + set onEmitNode(value) { + ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + } }; + // Ensure the parse tree is clean before applying transformations + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } ts.performance.mark("beforeTransform"); // Chain together and initialize each transformer. var transformation = ts.chain.apply(void 0, transformers)(context); - // Transform each source file. - var transformed = ts.map(sourceFiles, transformSourceFile); - // Disable modification of the lexical environment. - lexicalEnvironmentDisabled = true; + // prevent modification of transformation hooks. + state = 1 /* Initialized */; + // Transform each node. + var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot); + // prevent modification of the lexical environment. + state = 2 /* Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, - emitNodeWithSubstitution: emitNodeWithSubstitution, - emitNodeWithNotification: emitNodeWithNotification + substituteNode: substituteNode, + emitNodeWithNotification: emitNodeWithNotification, + dispose: dispose }; - /** - * Transforms a source file. - * - * @param sourceFile The source file to transform. - */ - function transformSourceFile(sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return sourceFile; - } - return transformation(sourceFile); + function transformRoot(node) { + return node && (!ts.isSourceFile(node) || !ts.isDeclarationFile(node)) ? transformation(node) : node; } /** * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; } /** @@ -59120,18 +61451,15 @@ var ts; * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(hint, node, emitCallback) { - if (node) { - if (isSubstitutionEnabled(node)) { - node = context.onSubstituteNode(hint, node) || node; - } - emitCallback(hint, node); - } + function substituteNode(hint, node) { + ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; } /** @@ -59150,9 +61478,10 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { + ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(hint, node, emitCallback); + onEmitNode(hint, node, emitCallback); } else { emitCallback(hint, node); @@ -59163,7 +61492,8 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); var decl = ts.createVariableDeclaration(name); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; @@ -59176,7 +61506,8 @@ var ts; * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -59189,7 +61520,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -59203,13 +61535,15 @@ var ts; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -59218,7 +61552,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { @@ -59247,18 +61582,39 @@ var ts; return statements; } function requestEmitHelper(helper) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } + function dispose() { + if (state < 3 /* Disposed */) { + // Clean up emit nodes on parse tree + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } + // Release references to external entries for GC purposes. + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentVariableDeclarationsStack = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentFunctionDeclarationsStack = undefined; + onSubstituteNode = undefined; + onEmitNode = undefined; + emitHelpers = undefined; + // Prevent further use of the transformation result. + state = 3 /* Disposed */; + } + } } - ts.transformFiles = transformFiles; + ts.transformNodes = transformNodes; })(ts || (ts = {})); /// /* @internal */ @@ -59341,7 +61697,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 264 /* SourceFile */) { + if (sourceFileOrBundle.kind === 265 /* SourceFile */) { // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -59479,7 +61835,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 297 /* NotEmittedStatement */ + if (node.kind !== 295 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -59492,7 +61848,7 @@ var ts; else { emitCallback(hint, node); } - if (node.kind !== 297 /* NotEmittedStatement */ + if (node.kind !== 295 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -59655,24 +62011,19 @@ var ts; return; } if (node) { - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var emitFlags = ts.getEmitFlags(node); + hasWrittenComment = false; + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 295 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -59691,23 +62042,16 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 226 /* VariableDeclarationList */) { + if (node.kind === 227 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); if (extendedDiagnostics) { - ts.performance.mark("beginEmitNodeWithComment"); + ts.performance.mark("postEmitNodeWithComment"); } // Restore previous container state. containerPos = savedContainerPos; @@ -59719,11 +62063,75 @@ var ts; emitTrailingComments(end); } if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitNodeWithComment"); + ts.performance.measure("commentTime", "postEmitNodeWithComment"); } } } } + function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { + var leadingComments = emitNode && emitNode.leadingComments; + if (ts.some(leadingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("preEmitNodeWithSynthesizedComments"); + } + ts.forEach(leadingComments, emitLeadingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); + } + } + emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); + var trailingComments = emitNode && emitNode.trailingComments; + if (ts.some(trailingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("postEmitNodeWithSynthesizedComments"); + } + ts.forEach(trailingComments, emitTrailingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); + } + } + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.write(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.write(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { + if (emitFlags & 2048 /* NoNestedComments */) { + disabled = true; + emitCallback(hint, node); + disabled = false; + } + else { + emitCallback(hint, node); + } + } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { if (extendedDiagnostics) { ts.performance.mark("preEmitBodyWithDetachedComments"); @@ -59916,7 +62324,7 @@ var ts; * Determine if the given comment is a triple-slash * * @return true if the comment is a triple-slash comment else false - **/ + */ function isTripleSlashComment(commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments @@ -59948,8 +62356,8 @@ var ts; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { - var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; - var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; + var sourceFiles = sourceFileOrBundle.kind === 266 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 266 /* Bundle */; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -60023,7 +62431,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 237 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 238 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -60099,10 +62507,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 225 /* VariableDeclaration */) { + if (declaration.kind === 226 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 240 /* NamedImports */ || declaration.kind === 241 /* ImportSpecifier */ || declaration.kind === 238 /* ImportClause */) { + else if (declaration.kind === 241 /* NamedImports */ || declaration.kind === 242 /* ImportSpecifier */ || declaration.kind === 239 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -60120,7 +62528,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 === 237 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 238 /* 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; @@ -60130,12 +62538,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 233 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 233 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -60201,7 +62609,7 @@ var ts; write(": "); // use the checker's type, not the declared type, // for non-optional initialized parameters that aren't a parameter property - var shouldUseResolverType = declaration.kind === 145 /* Parameter */ && + var shouldUseResolverType = declaration.kind === 146 /* Parameter */ && resolver.isRequiredInitializedParameter(declaration); if (type && !shouldUseResolverType) { // Write the type @@ -60229,15 +62637,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var node = nodes_6[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { - var node = nodes_5[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -60264,60 +62672,60 @@ var ts; } function emitType(type) { switch (type.kind) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 133 /* ObjectKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 129 /* NeverKeyword */: - case 168 /* ThisType */: - case 172 /* LiteralType */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 134 /* ObjectKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 130 /* NeverKeyword */: + case 169 /* ThisType */: + case 173 /* LiteralType */: return writeTextOfNode(currentText, type); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return emitTypeReference(type); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return emitTypeQuery(type); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return emitArrayType(type); - case 164 /* TupleType */: + case 165 /* TupleType */: return emitTupleType(type); - case 165 /* UnionType */: + case 166 /* UnionType */: return emitUnionType(type); - case 166 /* IntersectionType */: + case 167 /* IntersectionType */: return emitIntersectionType(type); - case 167 /* ParenthesizedType */: + case 168 /* ParenthesizedType */: return emitParenType(type); - case 169 /* TypeOperator */: + case 170 /* TypeOperator */: return emitTypeOperator(type); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return emitIndexedAccessType(type); - case 171 /* MappedType */: + case 172 /* MappedType */: return emitMappedType(type); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return emitTypeLiteral(type); - case 70 /* Identifier */: + case 71 /* Identifier */: return emitEntityName(type); - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return emitEntityName(type); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 70 /* Identifier */) { + if (entityName.kind === 71 /* Identifier */) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 142 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 142 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 143 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 143 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -60326,14 +62734,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 236 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 237 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 178 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 71 /* Identifier */ || node.expression.kind === 179 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -60433,7 +62841,7 @@ var ts; currentIdentifiers = node.identifiers; isCurrentFileExternalModule = ts.isExternalModule(node); enclosingDeclaration = node; - ts.emitDetachedComments(currentText, currentLineMap, writer, ts.writeCommentRange, node, newLine, true /* remove comments */); + ts.emitDetachedComments(currentText, currentLineMap, writer, ts.writeCommentRange, node, newLine, /*removeComents*/ true); emitLines(node.statements); } // Return a temp variable name to be used in `export default` statements. @@ -60455,7 +62863,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 70 /* Identifier */) { + if (node.expression.kind === 71 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -60478,7 +62886,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 70 /* Identifier */) { + if (node.expression.kind === 71 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -60497,10 +62905,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 236 /* ImportEqualsDeclaration */ || - (node.parent.kind === 264 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 237 /* ImportEqualsDeclaration */ || + (node.parent.kind === 265 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 265 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -60510,7 +62918,7 @@ var ts; }); } else { - if (node.kind === 237 /* ImportDeclaration */) { + if (node.kind === 238 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -60528,23 +62936,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return writeVariableStatement(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return writeClassDeclaration(node); - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -60552,7 +62960,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 264 /* SourceFile */) { + if (node.parent.kind === 265 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -60561,7 +62969,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 229 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 230 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -60613,7 +63021,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 239 /* NamespaceImport */) { + if (namedBindings.kind === 240 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -60637,7 +63045,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 240 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -60658,13 +63066,13 @@ var ts; // 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 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 !== 232 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 233 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 236 /* ImportEqualsDeclaration */) { + if (parent.kind === 237 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 232 /* ModuleDeclaration */) { + else if (parent.kind === 233 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -60734,7 +63142,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 233 /* ModuleBlock */) { + while (node.body && node.body.kind !== 234 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -60804,7 +63212,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 150 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 151 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -60815,15 +63223,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || - node.parent.kind === 149 /* MethodSignature */ || - node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - node.parent.kind === 154 /* CallSignature */ || - node.parent.kind === 155 /* ConstructSignature */); + if (node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 163 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 151 /* MethodDeclaration */ || + node.parent.kind === 150 /* MethodSignature */ || + node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + node.parent.kind === 155 /* CallSignature */ || + node.parent.kind === 156 /* ConstructSignature */); emitType(node.constraint); } else { @@ -60832,15 +63240,15 @@ var ts; } if (node.default && !isPrivateMethodTypeParameter(node)) { write(" = "); - if (node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || - node.parent.kind === 149 /* MethodSignature */ || - node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - node.parent.kind === 154 /* CallSignature */ || - node.parent.kind === 155 /* ConstructSignature */); + if (node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 163 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 151 /* MethodDeclaration */ || + node.parent.kind === 150 /* MethodSignature */ || + node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + node.parent.kind === 155 /* CallSignature */ || + node.parent.kind === 156 /* ConstructSignature */); emitType(node.default); } else { @@ -60851,34 +63259,34 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* CallSignature */: + case 155 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.hasModifier(node.parent, 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 === 228 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 229 /* 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 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -60906,7 +63314,7 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 94 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 95 /* NullKeyword */) { write("null"); } else { @@ -60918,7 +63326,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 228 /* ClassDeclaration */) { + if (node.parent.parent.kind === 229 /* 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 : @@ -61006,7 +63414,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 !== 225 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 226 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -61017,11 +63425,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */ || - (node.kind === 145 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 149 /* PropertyDeclaration */ || node.kind === 148 /* PropertySignature */ || + (node.kind === 146 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) && node.parent.kind === 162 /* TypeLiteral */) { + if ((node.kind === 149 /* PropertyDeclaration */ || node.kind === 148 /* PropertySignature */) && node.parent.kind === 163 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -61034,14 +63442,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 225 /* VariableDeclaration */) { + if (node.kind === 226 /* 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 === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) { + else if (node.kind === 149 /* PropertyDeclaration */ || node.kind === 148 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -61050,7 +63458,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* 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 : @@ -61082,7 +63490,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 199 /* OmittedExpression */) { + if (element.kind !== 200 /* OmittedExpression */) { elements.push(element); } } @@ -61152,7 +63560,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 152 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 153 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -61165,7 +63573,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 152 /* GetAccessor */ + return accessor.kind === 153 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -61174,7 +63582,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 153 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 154 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -61224,17 +63632,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 227 /* FunctionDeclaration */) { + if (node.kind === 228 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 150 /* MethodDeclaration */ || node.kind === 151 /* Constructor */) { + else if (node.kind === 151 /* MethodDeclaration */ || node.kind === 152 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 227 /* FunctionDeclaration */) { + if (node.kind === 228 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 151 /* Constructor */) { + else if (node.kind === 152 /* Constructor */) { write("constructor"); } else { @@ -61254,17 +63662,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 155 /* ConstructSignature */ || node.kind === 160 /* ConstructorType */) { + if (node.kind === 156 /* ConstructSignature */ || node.kind === 161 /* ConstructorType */) { write("new "); } - else if (node.kind === 159 /* FunctionType */) { + else if (node.kind === 160 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -61279,22 +63687,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 159 /* FunctionType */ || node.kind === 160 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 162 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 160 /* FunctionType */ || node.kind === 161 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 163 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 151 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 152 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -61308,26 +63716,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named 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 154 /* CallSignature */: + case 155 /* CallSignature */: // Interfaces cannot have return types that cannot be named 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 156 /* IndexSignature */: + case 157 /* IndexSignature */: // Interfaces cannot have return types that cannot be named 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 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -61335,7 +63743,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* 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 : @@ -61349,7 +63757,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 227 /* FunctionDeclaration */: + case 228 /* 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 : @@ -61384,9 +63792,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - node.parent.parent.kind === 162 /* TypeLiteral */) { + if (node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + node.parent.parent.kind === 163 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -61402,29 +63810,29 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 151 /* Constructor */: + case 152 /* 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 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named 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 154 /* CallSignature */: + case 155 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named 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 156 /* IndexSignature */: + case 157 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -61432,7 +63840,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 228 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 229 /* 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 : @@ -61445,7 +63853,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 227 /* FunctionDeclaration */: + case 228 /* 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 : @@ -61457,12 +63865,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 === 173 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 174 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 175 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -61473,7 +63881,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 199 /* OmittedExpression */) { + if (bindingElement.kind === 200 /* 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) @@ -61482,7 +63890,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 175 /* BindingElement */) { + else if (bindingElement.kind === 176 /* 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" @@ -61505,7 +63913,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 70 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 71 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -61521,40 +63929,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: - case 232 /* ModuleDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 229 /* InterfaceDeclaration */: - case 228 /* ClassDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 231 /* EnumDeclaration */: + case 228 /* FunctionDeclaration */: + case 233 /* ModuleDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 230 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 232 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return emitExportDeclaration(node); - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return writeFunctionDeclaration(node); - case 155 /* ConstructSignature */: - case 154 /* CallSignature */: - case 156 /* IndexSignature */: + case 156 /* ConstructSignature */: + case 155 /* CallSignature */: + case 157 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return emitAccessorDeclaration(node); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return emitPropertyDeclaration(node); - case 263 /* EnumMember */: + case 264 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return emitExportAssignment(node); - case 264 /* SourceFile */: + case 265 /* SourceFile */: return emitSourceFile(node); } } @@ -61582,7 +63990,7 @@ var ts; return addedBundledEmitReference; function getDeclFileName(emitFileNames, sourceFileOrBundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path - var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; + var isBundledEmit = sourceFileOrBundle.kind === 266 /* Bundle */; if (isBundledEmit && !addBundledFileReference) { return; } @@ -61597,7 +64005,7 @@ var ts; var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { - var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var sourceFiles = sourceFileOrBundle.kind === 266 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -61631,14 +64039,13 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ // 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, emitOnlyDtsFiles) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers) { var compilerOptions = host.getCompilerOptions(); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var sourceMap = ts.createSourceMapWriter(host, writer); var currentSourceFile; @@ -61647,14 +64054,14 @@ var ts; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var transform = ts.transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, /*allowDtsFiles*/ false); // Create a printer to print the nodes var printer = createPrinter(compilerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, - onSubstituteNode: transform.emitNodeWithSubstitution, + substituteNode: transform.substituteNode, // sourcemap hooks onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, @@ -61668,10 +64075,7 @@ var ts; ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; - ts.disposeEmitNodes(sourceFile); - } + transform.dispose(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -61705,8 +64109,8 @@ var ts; } } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { - var bundle = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 264 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 266 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 265 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); if (bundle) { @@ -61746,7 +64150,7 @@ var ts; } function emitHelpers(node, writeLines) { var helpersEmitted = false; - var bundle = node.kind === 265 /* Bundle */ ? node : undefined; + var bundle = node.kind === 266 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -61791,9 +64195,8 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray; var newLine = ts.getNewLineCharacter(printerOptions); - var languageVersion = ts.getEmitScriptTarget(printerOptions); var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; var currentSourceFile; @@ -61828,8 +64231,8 @@ var ts; break; } switch (node.kind) { - case 264 /* SourceFile */: return printFile(node); - case 265 /* Bundle */: return printBundle(node); + case 265 /* SourceFile */: return printFile(node); + case 266 /* Bundle */: return printBundle(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -61852,6 +64255,8 @@ var ts; function writeBundle(bundle, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(bundle); + emitPrologueDirectivesIfNeeded(bundle); emitHelpersIndirect(bundle); for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { var sourceFile = _b[_a]; @@ -61863,6 +64268,8 @@ var ts; function writeFile(sourceFile, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(sourceFile); + emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; @@ -61899,9 +64306,8 @@ var ts; comments.reset(); setWriter(/*output*/ undefined); } - function emit(node, hint) { - if (hint === void 0) { hint = 3 /* Unspecified */; } - pipelineEmitWithNotification(hint, node); + function emit(node) { + pipelineEmitWithNotification(3 /* Unspecified */, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); @@ -61918,6 +64324,7 @@ var ts; } } function pipelineEmitWithComments(hint, node) { + node = trySubstituteNode(hint, node); if (emitNodeWithComments && hint !== 0 /* SourceFile */) { emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); } @@ -61927,15 +64334,7 @@ var ts; } function pipelineEmitWithSourceMap(hint, node) { if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { - onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); - } - else { - pipelineEmitWithSubstitution(hint, node); - } - } - function pipelineEmitWithSubstitution(hint, node) { - if (onSubstituteNode) { - onSubstituteNode(hint, node, pipelineEmitWithHint); + onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); } else { pipelineEmitWithHint(hint, node); @@ -61968,217 +64367,221 @@ var ts; } switch (kind) { // Pseudo-literals - case 13 /* TemplateHead */: - case 14 /* TemplateMiddle */: - case 15 /* TemplateTail */: + case 14 /* TemplateHead */: + case 15 /* TemplateMiddle */: + case 16 /* TemplateTail */: return emitLiteral(node); // Identifiers - case 70 /* Identifier */: + case 71 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return emitQualifiedName(node); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return emitTypeParameter(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return emitParameter(node); - case 146 /* Decorator */: + case 147 /* Decorator */: return emitDecorator(node); // Type members - case 147 /* PropertySignature */: + case 148 /* PropertySignature */: return emitPropertySignature(node); - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 149 /* MethodSignature */: + case 150 /* MethodSignature */: return emitMethodSignature(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return emitConstructor(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return emitAccessorDeclaration(node); - case 154 /* CallSignature */: + case 155 /* CallSignature */: return emitCallSignature(node); - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: return emitConstructSignature(node); - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return emitIndexSignature(node); // Types - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return emitTypePredicate(node); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return emitTypeReference(node); - case 159 /* FunctionType */: + case 160 /* FunctionType */: return emitFunctionType(node); - case 160 /* ConstructorType */: + case 161 /* ConstructorType */: return emitConstructorType(node); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return emitTypeQuery(node); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return emitTypeLiteral(node); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return emitArrayType(node); - case 164 /* TupleType */: + case 165 /* TupleType */: return emitTupleType(node); - case 165 /* UnionType */: + case 166 /* UnionType */: return emitUnionType(node); - case 166 /* IntersectionType */: + case 167 /* IntersectionType */: return emitIntersectionType(node); - case 167 /* ParenthesizedType */: + case 168 /* ParenthesizedType */: return emitParenthesizedType(node); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 168 /* ThisType */: + case 169 /* ThisType */: return emitThisType(); - case 169 /* TypeOperator */: + case 170 /* TypeOperator */: return emitTypeOperator(node); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 171 /* MappedType */: + case 172 /* MappedType */: return emitMappedType(node); - case 172 /* LiteralType */: + case 173 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 173 /* ObjectBindingPattern */: + case 174 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 174 /* ArrayBindingPattern */: + case 175 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 175 /* BindingElement */: + case 176 /* BindingElement */: return emitBindingElement(node); // Misc - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return emitTemplateSpan(node); - case 205 /* SemicolonClassElement */: + case 206 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 206 /* Block */: + case 207 /* Block */: return emitBlock(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return emitVariableStatement(node); - case 208 /* EmptyStatement */: + case 209 /* EmptyStatement */: return emitEmptyStatement(); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return emitExpressionStatement(node); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return emitIfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return emitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return emitWhileStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return emitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return emitForInStatement(node); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return emitForOfStatement(node); - case 216 /* ContinueStatement */: + case 217 /* ContinueStatement */: return emitContinueStatement(node); - case 217 /* BreakStatement */: + case 218 /* BreakStatement */: return emitBreakStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return emitReturnStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return emitWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return emitSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return emitLabeledStatement(node); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return emitThrowStatement(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return emitTryStatement(node); - case 224 /* DebuggerStatement */: + case 225 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return emitClassDeclaration(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: return emitModuleBlock(node); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return emitCaseBlock(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return emitImportDeclaration(node); - case 238 /* ImportClause */: + case 239 /* ImportClause */: return emitImportClause(node); - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: return emitNamespaceImport(node); - case 240 /* NamedImports */: + case 241 /* NamedImports */: return emitNamedImports(node); - case 241 /* ImportSpecifier */: + case 242 /* ImportSpecifier */: return emitImportSpecifier(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return emitExportAssignment(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return emitExportDeclaration(node); - case 244 /* NamedExports */: + case 245 /* NamedExports */: return emitNamedExports(node); - case 245 /* ExportSpecifier */: + case 246 /* ExportSpecifier */: return emitExportSpecifier(node); - case 246 /* MissingDeclaration */: + case 247 /* MissingDeclaration */: return; // Module references - case 247 /* ExternalModuleReference */: + case 248 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 250 /* JsxOpeningElement */: + case 251 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return emitJsxAttribute(node); - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return emitJsxAttributes(node); - case 254 /* JsxSpreadAttribute */: + case 255 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 256 /* CaseClause */: + case 257 /* CaseClause */: return emitCaseClause(node); - case 257 /* DefaultClause */: + case 258 /* DefaultClause */: return emitDefaultClause(node); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: return emitHeritageClause(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 263 /* EnumMember */: + case 264 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with // substitution. if (ts.isExpression(node)) { - return pipelineEmitWithSubstitution(1 /* Expression */, node); + return pipelineEmitExpression(trySubstituteNode(1 /* Expression */, node)); + } + if (ts.isToken(node)) { + writeTokenText(kind); + return; } } function pipelineEmitExpression(node) { @@ -62188,92 +64591,87 @@ var ts; case 8 /* NumericLiteral */: return emitNumericLiteral(node); case 9 /* StringLiteral */: - case 11 /* RegularExpressionLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 70 /* Identifier */: + case 71 /* Identifier */: return emitIdentifier(node); // Reserved words - case 85 /* FalseKeyword */: - case 94 /* NullKeyword */: - case 96 /* SuperKeyword */: - case 100 /* TrueKeyword */: - case 98 /* ThisKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 97 /* SuperKeyword */: + case 101 /* TrueKeyword */: + case 99 /* ThisKeyword */: writeTokenText(kind); return; // Expressions - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return emitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return emitNewExpression(node); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return emitFunctionExpression(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return emitArrowFunction(node); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return emitDeleteExpression(node); - case 188 /* TypeOfExpression */: + case 189 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return emitVoidExpression(node); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return emitAwaitExpression(node); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return emitBinaryExpression(node); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return emitConditionalExpression(node); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return emitTemplateExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return emitYieldExpression(node); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return emitSpreadExpression(node); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return emitClassExpression(node); - case 199 /* OmittedExpression */: + case 200 /* OmittedExpression */: return; - case 201 /* AsExpression */: + case 202 /* AsExpression */: return emitAsExpression(node); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return emitNonNullExpression(node); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 248 /* JsxElement */: + case 249 /* JsxElement */: return emitJsxElement(node); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } - function emitBodyIndirect(node, elements, emitCallback) { - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(node, elements, emitCallback); - } - else { - emitCallback(node); - } + function trySubstituteNode(hint, node) { + return node && substituteNode && substituteNode(hint, node) || node; } function emitHelpersIndirect(node) { if (onEmitHelpers) { @@ -62286,9 +64684,6 @@ var ts; // SyntaxKind.NumericLiteral function emitNumericLiteral(node) { emitLiteral(node); - if (node.trailingComment) { - write(" /*" + node.trailingComment + "*/"); - } } // SyntaxKind.StringLiteral // SyntaxKind.RegularExpressionLiteral @@ -62321,7 +64716,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { emitExpression(node); } else { @@ -62346,8 +64741,8 @@ var ts; writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator) { write("@"); @@ -62397,7 +64792,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 152 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 153 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -62567,12 +64962,12 @@ var ts; write("{}"); } else { - var indentedFlag = ts.getEmitFlags(node) & 32768 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; if (indentedFlag) { increaseIndent(); } var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; emitList(node, properties, 978 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -62582,10 +64977,10 @@ var ts; function emitPropertyAccessExpression(node) { var indentBeforeDot = false; var indentAfterDot = false; - if (!(ts.getEmitFlags(node) & 65536 /* NoIndentation */)) { + if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 23 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -62600,12 +64995,12 @@ var ts; // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression) { - if (expression.kind === 8 /* NumericLiteral */) { + expression = ts.skipPartiallyEmittedExpressions(expression); + if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression); - return ts.getNumericLiteralFlags(text, /*hint*/ 15 /* All */) === 0 /* None */ - && !expression.isOctalLiteral - && text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; + return !expression.numericLiteralFlags + && text.indexOf(ts.tokenToString(23 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -62700,16 +65095,16 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 191 /* PrefixUnaryExpression */ - && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) - || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); + return operand.kind === 192 /* PrefixUnaryExpression */ + && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) + || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 25 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -62783,18 +65178,18 @@ var ts; // function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); write(" "); - writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } else { - writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted increaseIndent(); emitLeadingCommentsOfPosition(node.statements.end); decreaseIndent(); - writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } function emitBlockStatements(node) { @@ -62818,16 +65213,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(89 /* IfKeyword */, node.pos, node); + var openParenPos = writeToken(90 /* IfKeyword */, node.pos, node); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos, node); + writeToken(19 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end, node); + writeToken(20 /* CloseParenToken */, node.expression.end, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 210 /* IfStatement */) { + writeToken(82 /* ElseKeyword */, node.thenStatement.end, node); + if (node.elseStatement.kind === 211 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -62856,9 +65251,9 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(87 /* ForKeyword */, node.pos); + var openParenPos = writeToken(88 /* ForKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos, /*contextNode*/ node); + writeToken(19 /* OpenParenToken */, openParenPos, /*contextNode*/ node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -62868,28 +65263,29 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(87 /* ForKeyword */, node.pos); + var openParenPos = writeToken(88 /* ForKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + writeToken(19 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end); + writeToken(20 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(87 /* ForKeyword */, node.pos); + var openParenPos = writeToken(88 /* ForKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + emitWithSuffix(node.awaitModifier, " "); + writeToken(19 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end); + writeToken(20 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 226 /* VariableDeclarationList */) { + if (node.kind === 227 /* VariableDeclarationList */) { emit(node); } else { @@ -62898,17 +65294,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(76 /* ContinueKeyword */, node.pos); + writeToken(77 /* ContinueKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(71 /* BreakKeyword */, node.pos); + writeToken(72 /* BreakKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(95 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + writeToken(96 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -62919,11 +65315,11 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); + var openParenPos = writeToken(98 /* SwitchKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + writeToken(19 /* OpenParenToken */, openParenPos); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end); + writeToken(20 /* CloseParenToken */, node.expression.end); write(" "); emit(node.caseBlock); } @@ -62951,7 +65347,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(77 /* DebuggerKeyword */, node.pos); + writeToken(78 /* DebuggerKeyword */, node.pos); write(";"); } // @@ -62976,22 +65372,35 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint, body) { + emitBlockFunctionBody(body); + } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 32768 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; if (indentedFlag) { increaseIndent(); } - if (ts.getEmitFlags(node) & 262144 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } if (indentedFlag) { @@ -63050,9 +65459,14 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - emitBodyIndirect(body, body.statements, emitBlockFunctionBody); + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); + } + else { + emitBlockFunctionBody(body); + } decreaseIndent(); - writeToken(17 /* CloseBraceToken */, body.statements.end, body); + writeToken(18 /* CloseBraceToken */, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -63079,7 +65493,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = ts.getEmitFlags(node) & 32768 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; if (indentedFlag) { increaseIndent(); } @@ -63130,7 +65544,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 232 /* ModuleDeclaration */) { + while (body.kind === 233 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -63145,16 +65559,15 @@ var ts; else { pushNameGenerationScope(); write("{"); - increaseIndent(); emitBlockStatements(node); write("}"); popNameGenerationScope(); } } function emitCaseBlock(node) { - writeToken(16 /* OpenBraceToken */, node.pos); + writeToken(17 /* OpenBraceToken */, node.pos); emitList(node, node.clauses, 65 /* CaseBlockClauses */); - writeToken(17 /* CloseBraceToken */, node.clauses.end); + writeToken(18 /* CloseBraceToken */, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -63165,7 +65578,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { emitExpression(node); } else { @@ -63303,7 +65716,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { emitExpression(node); } else { @@ -63345,11 +65758,11 @@ var ts; emitList(node, node.types, 272 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); + var openParenPos = writeToken(74 /* CatchKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + writeToken(19 /* OpenParenToken */, openParenPos); emit(node.variableDeclaration); - writeToken(19 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(20 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -63398,15 +65811,26 @@ var ts; // function emitSourceFile(node) { writeLine(); - emitShebang(); - emitBodyIndirect(node, node.statements, emitSourceFileWorker); + var statements = node.statements; + if (emitBodyWithDetachedComments) { + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; + } + } + emitSourceFileWorker(node); } function emitSourceFileWorker(node) { var statements = node.statements; - var statementOffset = emitPrologueDirectives(statements); pushNameGenerationScope(); emitHelpersIndirect(node); - emitList(node, statements, 1 /* MultiLine */, statementOffset); + var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); + emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); popNameGenerationScope(); } // Transformation nodes @@ -63417,13 +65841,20 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine) { + function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { for (var i = 0; i < statements.length; i++) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); + var statement = statements[i]; + if (ts.isPrologueDirective(statement)) { + var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; + if (shouldEmitPrologueDirective) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statement); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(statement.expression.text, statement.expression.text); + } } - emit(statements[i]); } else { // return index of the first non prologue directive @@ -63432,16 +65863,42 @@ var ts; } return statements.length; } + function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + setSourceFile(sourceFileOrBundle); + emitPrologueDirectives(sourceFileOrBundle.statements); + } + else { + var seenPrologueDirectives = ts.createMap(); + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + setSourceFile(sourceFile); + emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + } + } + } + function emitShebangIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + var shebang = ts.getShebang(sourceFileOrBundle.text); + if (shebang) { + write(shebang); + writeLine(); + return true; + } + } + else { + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + // Emit only the first encountered shebang + if (emitShebangIfNeeded(sourceFile)) { + break; + } + } + } + } // // Helpers // - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - writeLine(); - } - } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { emitList(node, modifiers, 256 /* Modifiers */); @@ -63524,6 +65981,9 @@ var ts; if (format & 7680 /* BracketsMask */) { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } if (isEmpty) { // Write a line terminator if the parent node was multi-line if (format & 1 /* MultiLine */) { @@ -63624,6 +66084,9 @@ var ts; write(" "); } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } if (format & 7680 /* BracketsMask */) { write(getClosingBracket(format)); } @@ -63685,7 +66148,7 @@ var ts; for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { var line = lines_1[_a]; for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) { if (indentation === undefined || i < indentation) { indentation = i; break; @@ -63813,7 +66276,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 184 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 185 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -63843,7 +66306,7 @@ var ts; return getLiteralTextOfNode(textSourceNode); } } - return ts.getLiteralText(node, currentSourceFile, languageVersion); + return ts.getLiteralText(node, currentSourceFile); } /** * Push a new name generation scope. @@ -63991,23 +66454,23 @@ var ts; */ function generateNameForNode(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 232 /* ModuleDeclaration */: - case 231 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 237 /* ImportDeclaration */: - case 243 /* ExportDeclaration */: + case 238 /* ImportDeclaration */: + case 244 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 227 /* FunctionDeclaration */: - case 228 /* ClassDeclaration */: - case 242 /* ExportAssignment */: + case 228 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + case 243 /* ExportAssignment */: return generateNameForExportDefault(); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return generateNameForClassExpression(); - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -64157,6 +66620,7 @@ var ts; var ts; (function (ts) { var emptyArray = []; + var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } while (true) { @@ -64225,8 +66689,6 @@ var ts; // otherwise use toLowerCase as a canonical form. return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - // returned by CScript sys environment - var unsupportedFileEncodingErrorCode = -2147024809; function getSourceFile(fileName, languageVersion, onError) { var text; try { @@ -64237,9 +66699,7 @@ var ts; } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } @@ -64403,6 +66863,8 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; + var cachedSemanticDiagnosticsForFile = {}; + var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules. @@ -64622,7 +67084,7 @@ var ts; // combine results of resolutions and predicted results var j = 0; for (var i = 0; i < result.length; i++) { - if (result[i] == predictedToResolveToAmbientModuleMarker) { + if (result[i] === predictedToResolveToAmbientModuleMarker) { result[i] = undefined; } else { @@ -64795,13 +67257,13 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -64833,7 +67295,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -64906,19 +67369,54 @@ var ts; } } function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. + // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a + // '/// ' directive. + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report semantic errors. - // Instead, we'll report errors for using TypeScript-only constructs from within a - // JavaScript file when we get syntactic diagnostics for the file. - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + // For JavaScript files, we don't want to report semantic errors unless explicitly requested. + var includeCheckDiagnostics = !ts.isSourceFileJavaScript(sourceFile) || ts.isCheckJsEnabledForFile(sourceFile, options); + var checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return ts.isSourceFileJavaScript(sourceFile) + ? ts.filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + /** + * Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines + */ + function shouldReportDiagnostic(diagnostic) { + var file = diagnostic.file, start = diagnostic.start; + if (file) { + var lineStarts = ts.getLineStarts(file); + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + while (line > 0) { + var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + // non-empty line + return true; + } + if (result[3]) { + // @ts-ignore + return false; + } + line--; + } + } + return true; + } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; @@ -64929,23 +67427,23 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - // Pass through - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 225 /* VariableDeclaration */: + // falls through + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 226 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -64953,35 +67451,35 @@ var ts; } } switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 107 /* ImplementsKeyword */) { + if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -64996,50 +67494,50 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, 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)); } switch (parent.kind) { - case 228 /* ClassDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - // pass through - case 207 /* VariableStatement */: + // falls through + case 208 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 207 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 208 /* VariableStatement */); } break; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 114 /* StaticKeyword */) { + if (modifier.kind !== 115 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 145 /* Parameter */: + case 146 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 200 /* ExpressionWithTypeArguments */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 201 /* ExpressionWithTypeArguments */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -65047,8 +67545,8 @@ var ts; } break; } - for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { - var node = nodes_6[_b]; + for (var _b = 0, nodes_8 = nodes; _b < nodes_8.length; _b++) { + var node = nodes_8[_b]; walk(node); } } @@ -65056,23 +67554,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 75 /* ConstKeyword */: + case 76 /* ConstKeyword */: if (isConstValid) { continue; } - // Fallthrough to report error - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 130 /* ReadonlyKeyword */: - case 123 /* DeclareKeyword */: - case 116 /* AbstractKeyword */: + // to report error, + // falls through + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 131 /* ReadonlyKeyword */: + case 124 /* DeclareKeyword */: + case 117 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 114 /* StaticKeyword */: - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 115 /* StaticKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: } } } @@ -65088,12 +67587,34 @@ var ts; }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } + function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) { + var cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + if (cachedResult) { + return cachedResult; + } + var result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = ts.createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } @@ -65137,7 +67658,7 @@ var ts; && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); - var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); + var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined); externalHelpersModuleReference.parent = importDecl; importDecl.parent = file; imports = [externalHelpersModuleReference]; @@ -65155,9 +67676,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 237 /* ImportDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 243 /* ExportDeclaration */: + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 244 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -65172,7 +67693,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -65272,7 +67793,7 @@ var ts; } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); @@ -65451,8 +67972,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var file = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var file = sourceFiles_2[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -65463,8 +67984,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var sourceFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -65558,7 +68079,7 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } - if (options.noImplicitUseStrict && options.alwaysStrict) { + if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); } var languageVersion = options.target || 0 /* ES3 */; @@ -65604,6 +68125,9 @@ var ts; if (!options.noEmit && options.allowJs && options.declaration) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); @@ -65699,40 +68223,13 @@ var ts; ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, + // CommandLine only options { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, }, { @@ -65740,53 +68237,70 @@ var ts; shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMapFromTemplate({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */ - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", + name: "project", + shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Watch_input_files, + }, + // Basic + { + name: "target", + shortName: "t", + type: ts.createMapFromTemplate({ + "es3": 0 /* ES3 */, + "es5": 1 /* ES5 */, + "es6": 2 /* ES2015 */, + "es2015": 2 /* ES2015 */, + "es2016": 3 /* ES2016 */, + "es2017": 4 /* ES2017 */, + "esnext": 5 /* ESNext */, + }), + paramType: ts.Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { name: "module", @@ -65800,300 +68314,10 @@ var ts; "es6": ts.ModuleKind.ES2015, "es2015": ts.ModuleKind.ES2015, }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMapFromTemplate({ - "crlf": 0 /* CarriageReturnLineFeed */, - "lf": 1 /* LineFeed */ - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - // for correct behaviour, please use outFile - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: ts.Diagnostics.FILE_OR_DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMapFromTemplate({ - "es3": 0 /* ES3 */, - "es5": 1 /* ES5 */, - "es6": 2 /* ES2015 */, - "es2015": 2 /* ES2015 */, - "es2016": 3 /* ES2016 */, - "es2017": 4 /* ES2017 */, - "esnext": 5 /* ESNext */, - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, - paramType: ts.Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMapFromTemplate({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - 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: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_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 - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -66108,6 +68332,7 @@ var ts; "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", // Host only "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", @@ -66127,29 +68352,477 @@ var ts; "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, + "react": 2 /* React */ + }), + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + // Strict Type Checks + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + // Additional Checks + { + name: "noUnusedLocals", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + // Module Resolution + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + paramType: ts.Diagnostics.STRATEGY, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: ts.Diagnostics.Module_Resolution_Options, + 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, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + // Source Maps + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + // Experimental + { + name: "experimentalDecorators", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + // Advanced + { + name: "jsxFactory", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + { + name: "out", + type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + category: ts.Diagnostics.Advanced_Options, + paramType: ts.Diagnostics.FILE, + description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0 /* CarriageReturnLineFeed */, + "lf": 1 /* LineFeed */ + }), + paramType: ts.Diagnostics.NEWLINE, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, { // A list of plugins to load in the language service name: "plugins", @@ -66158,7 +68831,8 @@ var ts; element: { name: "plugin", type: "object" - } + }, + description: ts.Diagnostics.List_of_language_service_plugins } ]; /* @internal */ @@ -66195,8 +68869,7 @@ var ts; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, - noImplicitAny: false, - sourceMap: false, + strict: true }; var optionNameMapCache; /* @internal */ @@ -66377,9 +69050,9 @@ var ts; } ts.parseCommandLine = parseCommandLine; /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ + * Read tsconfig.json file + * @param fileName The path to the config file + */ function readConfigFile(fileName, readFile) { var text = ""; try { @@ -66392,10 +69065,10 @@ var ts; } ts.readConfigFile = readConfigFile; /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ function parseConfigFileTextToJson(fileName, jsonText, stripComments) { if (stripComments === void 0) { stripComments = true; } try { @@ -66413,7 +69086,7 @@ var ts; * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - function generateTSConfig(options, fileNames) { + function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -66422,7 +69095,7 @@ var ts; // only set the files property if we have at least one file configurations.files = fileNames; } - return configurations; + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition) { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { // this is of a type CommandLineOptionOfPrimitiveType @@ -66450,44 +69123,117 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + continue; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return ts.arrayFrom(option.type.keys())[0]; + } + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + // Filter applicable options to place in the file + var categorizedOptions = ts.reduceLeft(ts.filter(ts.optionDeclarations, function (o) { return o.category !== ts.Diagnostics.Command_line_Options && o.category !== ts.Diagnostics.Advanced_Options; }), function (memo, value) { + if (value.category) { + var name = ts.getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, {}); + // Serialize all options and thier descriptions + var marginLength = 0; + var seenKnownKeys = 0; + var nameColumn = []; + var descriptionColumn = []; + var knownKeysCount = ts.getOwnKeys(configurations.compilerOptions).length; + for (var category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push("/* " + category + " */"); + descriptionColumn.push(""); + for (var _i = 0, _a = categorizedOptions[category]; _i < _a.length; _i++) { + var option = _a[_i]; + var optionName = void 0; + if (ts.hasProperty(configurations.compilerOptions, option.name)) { + optionName = "\"" + option.name + "\": " + JSON.stringify(configurations.compilerOptions[option.name]) + ((seenKnownKeys += 1) === knownKeysCount ? "" : ","); + } + else { + optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + } + nameColumn.push(optionName); + descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + marginLength = Math.max(optionName.length, marginLength); + } + } + // Write the output + var tab = makePadding(2); + var result = []; + result.push("{"); + result.push(tab + "\"compilerOptions\": {"); + // Print out each row, aligning all the descriptions on the same column. + for (var i = 0; i < nameColumn.length; i++) { + var optionName = nameColumn[i]; + var description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(tab + "},"); + result.push(tab + "\"files\": ["); + for (var i = 0; i < configurations.files.length; i++) { + result.push("" + tab + tab + JSON.stringify(configurations.files[i]) + (i === configurations.files.length - 1 ? "" : ",")); + } + result.push(tab + "]"); + } + else { + result.push(tab + "}"); + } + result.push("}"); + return result.join(newLine); + } } ts.generateTSConfig = generateTSConfig; /** @@ -66515,12 +69261,12 @@ var ts; return output; } /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { if (existingOptions === void 0) { existingOptions = {}; } if (resolutionStack === void 0) { resolutionStack = []; } @@ -66544,10 +69290,11 @@ var ts; // It should be removed in future releases - use typeAcquisition instead. var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -66567,6 +69314,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -66606,7 +69356,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -66966,7 +69716,6 @@ var ts; } } } - ; } return wildcardDirectories; } @@ -67158,8 +69907,7 @@ var ts; ScriptElementKind.typeElement = "type"; /** enum E */ ScriptElementKind.enumElement = "enum"; - // TODO: GH#9983 - ScriptElementKind.enumMemberElement = "const"; + ScriptElementKind.enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. @@ -67204,7 +69952,7 @@ var ts; ScriptElementKind.externalModuleName = "external module name"; /** * - **/ + */ ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; @@ -67291,34 +70039,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 145 /* Parameter */: - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: - case 263 /* EnumMember */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 259 /* CatchClause */: - case 252 /* JsxAttribute */: + case 146 /* Parameter */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: + case 264 /* EnumMember */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 260 /* CatchClause */: + case 253 /* JsxAttribute */: return 1 /* Value */; - case 144 /* TypeParameter */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 162 /* TypeLiteral */: + case 145 /* TypeParameter */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 163 /* TypeLiteral */: return 2 /* Type */; - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -67328,25 +70076,25 @@ var ts; else { return 4 /* Namespace */; } - case 240 /* NamedImports */: - case 241 /* ImportSpecifier */: - case 236 /* ImportEqualsDeclaration */: - case 237 /* ImportDeclaration */: - case 242 /* ExportAssignment */: - case 243 /* ExportDeclaration */: + case 241 /* NamedImports */: + case 242 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 238 /* ImportDeclaration */: + case 243 /* ExportAssignment */: + case 244 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 264 /* SourceFile */: + case 265 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 242 /* ExportAssignment */) { + else if (node.parent.kind === 243 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -67367,19 +70115,19 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 70 /* Identifier */); + ts.Debug.assert(node.kind === 71 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 142 /* QualifiedName */ && + if (node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 236 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 237 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 142 /* QualifiedName */) { + while (node.parent.kind === 143 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -67390,27 +70138,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 142 /* QualifiedName */) { - while (root.parent && root.parent.kind === 142 /* QualifiedName */) { + if (root.parent.kind === 143 /* QualifiedName */) { + while (root.parent && root.parent.kind === 143 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 158 /* TypeReference */ && !isLastClause; + return root.parent.kind === 159 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 178 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 178 /* PropertyAccessExpression */) { + if (root.parent.kind === 179 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 179 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 200 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 258 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 201 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 259 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 228 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 229 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 229 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 230 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -67418,17 +70166,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 158 /* TypeReference */ || - (node.parent.kind === 200 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 168 /* ThisType */; + return node.parent.kind === 159 /* TypeReference */ || + (node.parent.kind === 201 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 99 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || + node.kind === 169 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 181 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 181 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 182 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -67441,7 +70189,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 221 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 222 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -67450,14 +70198,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 70 /* Identifier */ && - (node.parent.kind === 217 /* BreakStatement */ || node.parent.kind === 216 /* ContinueStatement */) && + return node.kind === 71 /* Identifier */ && + (node.parent.kind === 218 /* BreakStatement */ || node.parent.kind === 217 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 70 /* Identifier */ && - node.parent.kind === 221 /* LabeledStatement */ && + return node.kind === 71 /* Identifier */ && + node.parent.kind === 222 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -67465,38 +70213,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 232 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 233 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 70 /* Identifier */ && + return node.kind === 71 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 260 /* PropertyAssignment */: - case 263 /* EnumMember */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 232 /* ModuleDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 264 /* EnumMember */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 233 /* ModuleDeclaration */: return node.parent.name === node; - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return true; } } @@ -67545,17 +70293,17 @@ var ts; return undefined; } switch (node.kind) { - case 264 /* SourceFile */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: + case 265 /* SourceFile */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: return node; } } @@ -67563,46 +70311,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 229 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 230 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 231 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 225 /* VariableDeclaration */: + case 230 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 231 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 232 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 226 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 175 /* BindingElement */: + case 176 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 152 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 153 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 153 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 154 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 156 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 155 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 154 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 151 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 144 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 263 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 145 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 236 /* ImportEqualsDeclaration */: - case 241 /* ImportSpecifier */: - case 238 /* ImportClause */: - case 245 /* ExportSpecifier */: - case 239 /* NamespaceImport */: + case 157 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 156 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 155 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 152 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 145 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 264 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 146 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 237 /* ImportEqualsDeclaration */: + case 242 /* ImportSpecifier */: + case 239 /* ImportClause */: + case 246 /* ExportSpecifier */: + case 240 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -67616,23 +70364,14 @@ var ts; } } ts.getNodeKind = getNodeKind; - function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 172 /* LiteralType */ ? node.parent : node; - var type = typeChecker.getTypeAtLocation(searchNode); - if (type && type.flags & 32 /* StringLiteral */) { - return type; - } - return undefined; - } - ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 70 /* Identifier */: + case 71 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 145 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 146 /* Parameter */; default: return false; } @@ -67641,7 +70380,7 @@ var ts; // Matches the beginning of a triple slash directive var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= node.end) { + if (c.kind === 294 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -67880,7 +70619,7 @@ var ts; if (includeJsDocComment === void 0) { includeJsDocComment = false; } var current = sourceFile; outer: while (true) { - if (isToken(current)) { + if (ts.isToken(current)) { // exit early return current; } @@ -67930,18 +70669,18 @@ var ts; } } /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } return findPrecedingToken(position, file); @@ -67950,7 +70689,7 @@ var ts; function findNextToken(previousToken, parent) { return find(parent); function find(n) { - if (isToken(n) && n.pos === previousToken.end) { + if (ts.isToken(n) && n.pos === previousToken.end) { // this is token that starts at the end of previous token - return it return n; } @@ -67973,7 +70712,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -67981,7 +70720,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -68010,7 +70749,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 264 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 265 /* 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. @@ -68065,21 +70804,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 255 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 256 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 255 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 256 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 252 /* JsxClosingElement */) { return true; } return false; @@ -68110,10 +70849,10 @@ var ts; // Internally, we represent the end of the comment at the newline and closing '/', respectively. return predicate ? ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + (c.kind === 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && predicate(c); }) : ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + (c.kind === 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); } return false; } @@ -68134,11 +70873,11 @@ var ts; */ function getJsDocTagAtPosition(sourceFile, position) { var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { + if (ts.isToken(node)) { switch (node.kind) { - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -68191,21 +70930,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 158 /* TypeReference */ || node.kind === 180 /* CallExpression */) { + if (node.kind === 159 /* TypeReference */ || node.kind === 181 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 228 /* ClassDeclaration */ || node.kind === 229 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 229 /* ClassDeclaration */ || node.kind === 230 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 141 /* LastToken */; - } - ts.isToken = isToken; function isWord(kind) { - return kind === 70 /* Identifier */ || ts.isKeyword(kind); + return kind === 71 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -68217,7 +70952,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 11 /* RegularExpressionLiteral */ + || kind === 12 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -68225,7 +70960,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 16 /* FirstPunctuation */ <= kind && kind <= 69 /* LastPunctuation */; + return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -68235,9 +70970,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: return true; } return false; @@ -68260,18 +70995,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 176 /* ArrayLiteralExpression */ || - node.kind === 177 /* ObjectLiteralExpression */) { + if (node.kind === 177 /* ArrayLiteralExpression */ || + node.kind === 178 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 193 /* BinaryExpression */ && + if (node.parent.kind === 194 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 57 /* EqualsToken */) { + node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 215 /* ForOfStatement */ && + if (node.parent.kind === 216 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -68279,7 +71014,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 261 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -68313,26 +71048,41 @@ var ts; ts.createTextSpanFromNode = createTextSpanFromNode; function isTypeKeyword(kind) { switch (kind) { - case 118 /* AnyKeyword */: - case 121 /* BooleanKeyword */: - case 129 /* NeverKeyword */: - case 132 /* NumberKeyword */: - case 133 /* ObjectKeyword */: - case 135 /* StringKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: + case 119 /* AnyKeyword */: + case 122 /* BooleanKeyword */: + case 130 /* NeverKeyword */: + case 133 /* NumberKeyword */: + case 134 /* ObjectKeyword */: + case 136 /* StringKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: return true; default: return false; } } ts.isTypeKeyword = isTypeKeyword; + /** True if the symbol is for an external module, as opposed to a namespace. */ + function isExternalModuleSymbol(moduleSymbol) { + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + return moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + } + ts.isExternalModuleSymbol = isExternalModuleSymbol; + /** Returns `true` the first time it encounters a node and `false` afterwards. */ + function nodeSeenTracker() { + var seen = []; + return function (node) { + var id = ts.getNodeId(node); + return !seen[id] && (seen[id] = true); + }; + } + ts.nodeSeenTracker = nodeSeenTracker; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 146 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -68510,23 +71260,18 @@ var ts; function getDeclaredName(typeChecker, symbol, location) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever is under the cursor. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 143 /* ComputedPropertyName */) { + if (isImportOrExportSpecifierName(location) || ts.isStringOrNumericLiteral(location) && location.parent.kind === 144 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' // since that symbol has the "true" name. var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; + return typeChecker.symbolToString(localExportDefaultSymbol || symbol); } ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 241 /* ImportSpecifier */ || location.parent.kind === 245 /* ExportSpecifier */) && + (location.parent.kind === 242 /* ImportSpecifier */ || location.parent.kind === 246 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -68542,7 +71287,6 @@ var ts; (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { return name.substring(1, length - 1); } - ; return name; } ts.stripQuotes = stripQuotes; @@ -68593,11 +71337,22 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); + function getFirstNonSpaceCharacterPosition(text, position) { + while (ts.isWhiteSpaceLike(text.charCodeAt(position))) { + position += 1; + } + return position; } - ts.getOpenBraceEnd = getOpenBraceEnd; + ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getOpenBrace(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile); + } + ts.getOpenBrace = getOpenBrace; + function getOpenBraceOfClassLike(declaration, sourceFile) { + return ts.getTokenAtPosition(sourceFile, declaration.members.pos - 1); + } + ts.getOpenBraceOfClassLike = getOpenBraceOfClassLike; })(ts || (ts = {})); var ts; (function (ts) { @@ -68609,18 +71364,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[70 /* Identifier */] = true; + noRegexTable[71 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; - noRegexTable[11 /* RegularExpressionLiteral */] = true; - noRegexTable[98 /* ThisKeyword */] = true; - noRegexTable[42 /* PlusPlusToken */] = true; - noRegexTable[43 /* MinusMinusToken */] = true; - noRegexTable[19 /* CloseParenToken */] = true; - noRegexTable[21 /* CloseBracketToken */] = true; - noRegexTable[17 /* CloseBraceToken */] = true; - noRegexTable[100 /* TrueKeyword */] = true; - noRegexTable[85 /* FalseKeyword */] = true; + noRegexTable[12 /* RegularExpressionLiteral */] = true; + noRegexTable[99 /* ThisKeyword */] = true; + noRegexTable[43 /* PlusPlusToken */] = true; + noRegexTable[44 /* MinusMinusToken */] = true; + noRegexTable[20 /* CloseParenToken */] = true; + noRegexTable[22 /* CloseBracketToken */] = true; + noRegexTable[18 /* CloseBraceToken */] = true; + noRegexTable[101 /* TrueKeyword */] = true; + noRegexTable[86 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -68645,10 +71400,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 134 /* SetKeyword */ || - keyword2 === 122 /* ConstructorKeyword */ || - keyword2 === 114 /* StaticKeyword */) { + if (keyword2 === 125 /* GetKeyword */ || + keyword2 === 135 /* SetKeyword */ || + keyword2 === 123 /* ConstructorKeyword */ || + keyword2 === 115 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -68667,7 +71422,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_4 = dense[i + 1]; + var length_5 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -68676,8 +71431,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_4, classification: convertClassification(type) }); - lastEnd = start + length_4; + entries.push({ length: length_5, classification: convertClassification(type) }); + lastEnd = start + length_5; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -68745,9 +71500,9 @@ var ts; case 5 /* InTemplateMiddleOrTail */: text = "}\n" + text; offset = 2; - // fallthrough + // falls through case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(13 /* TemplateHead */); + templateStack.push(14 /* TemplateHead */); break; } scanner.setText(text); @@ -68778,71 +71533,71 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 11 /* RegularExpressionLiteral */) { - token = 11 /* RegularExpressionLiteral */; + if ((token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + token = 12 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 22 /* DotToken */ && isKeyword(token)) { - token = 70 /* Identifier */; + else if (lastNonTriviaToken === 23 /* DotToken */ && isKeyword(token)) { + token = 71 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 70 /* Identifier */; + token = 71 /* Identifier */; } - else if (lastNonTriviaToken === 70 /* Identifier */ && - token === 26 /* LessThanToken */) { + else if (lastNonTriviaToken === 71 /* Identifier */ && + token === 27 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 28 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 29 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 118 /* AnyKeyword */ || - token === 135 /* StringKeyword */ || - token === 132 /* NumberKeyword */ || - token === 121 /* BooleanKeyword */ || - token === 136 /* SymbolKeyword */) { + else if (token === 119 /* AnyKeyword */ || + token === 136 /* StringKeyword */ || + token === 133 /* NumberKeyword */ || + token === 122 /* BooleanKeyword */ || + token === 137 /* 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, // causing a noisy experience for the user. - token = 70 /* Identifier */; + token = 71 /* Identifier */; } } - else if (token === 13 /* TemplateHead */) { + else if (token === 14 /* TemplateHead */) { templateStack.push(token); } - else if (token === 16 /* OpenBraceToken */) { + else if (token === 17 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 17 /* CloseBraceToken */) { + else if (token === 18 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 13 /* TemplateHead */) { + if (lastTemplateStackToken === 14 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 15 /* TemplateTail */) { + if (token === 16 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 14 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 15 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 16 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 17 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -68883,10 +71638,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 15 /* TemplateTail */) { + if (token === 16 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 12 /* NoSubstitutionTemplateLiteral */) { + else if (token === 13 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -68894,7 +71649,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 14 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -68924,43 +71679,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 38 /* AsteriskToken */: - case 40 /* SlashToken */: - case 41 /* PercentToken */: - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 44 /* LessThanLessThanToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: - case 26 /* LessThanToken */: - case 28 /* GreaterThanToken */: - case 29 /* LessThanEqualsToken */: - case 30 /* GreaterThanEqualsToken */: - case 92 /* InstanceOfKeyword */: - case 91 /* InKeyword */: - case 117 /* AsKeyword */: - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: - case 47 /* AmpersandToken */: - case 49 /* CaretToken */: - case 48 /* BarToken */: - case 52 /* AmpersandAmpersandToken */: - case 53 /* BarBarToken */: - case 68 /* BarEqualsToken */: - case 67 /* AmpersandEqualsToken */: - case 69 /* CaretEqualsToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 58 /* PlusEqualsToken */: - case 59 /* MinusEqualsToken */: - case 60 /* AsteriskEqualsToken */: - case 62 /* SlashEqualsToken */: - case 63 /* PercentEqualsToken */: - case 57 /* EqualsToken */: - case 25 /* CommaToken */: + case 39 /* AsteriskToken */: + case 41 /* SlashToken */: + case 42 /* PercentToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 45 /* LessThanLessThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 27 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 30 /* LessThanEqualsToken */: + case 31 /* GreaterThanEqualsToken */: + case 93 /* InstanceOfKeyword */: + case 92 /* InKeyword */: + case 118 /* AsKeyword */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: + case 48 /* AmpersandToken */: + case 50 /* CaretToken */: + case 49 /* BarToken */: + case 53 /* AmpersandAmpersandToken */: + case 54 /* BarBarToken */: + case 69 /* BarEqualsToken */: + case 68 /* AmpersandEqualsToken */: + case 70 /* CaretEqualsToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 59 /* PlusEqualsToken */: + case 60 /* MinusEqualsToken */: + case 61 /* AsteriskEqualsToken */: + case 63 /* SlashEqualsToken */: + case 64 /* PercentEqualsToken */: + case 58 /* EqualsToken */: + case 26 /* CommaToken */: return true; default: return false; @@ -68968,19 +71723,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: - case 42 /* PlusPlusToken */: - case 43 /* MinusMinusToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: + case 43 /* PlusPlusToken */: + case 44 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 141 /* LastKeyword */; + return token >= 72 /* FirstKeyword */ && token <= 142 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -68989,7 +71744,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 16 /* FirstPunctuation */ && token <= 69 /* LastPunctuation */) { + else if (token >= 17 /* FirstPunctuation */ && token <= 70 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -68997,7 +71752,7 @@ var ts; return 4 /* numericLiteral */; case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 11 /* RegularExpressionLiteral */: + case 12 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -69006,7 +71761,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 70 /* Identifier */: + case 71 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -69037,10 +71792,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 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 227 /* FunctionDeclaration */: + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 228 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -69091,7 +71846,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 232 /* ModuleDeclaration */ && + return declaration.kind === 233 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -69101,7 +71856,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 70 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 71 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -69255,16 +72010,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 285 /* JSDocParameterTag */: + case 286 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 288 /* JSDocTemplateTag */: + case 289 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 287 /* JSDocTypeTag */: + case 288 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 286 /* JSDocReturnTag */: + case 287 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -69351,22 +72106,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 250 /* JsxOpeningElement */: + case 251 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -69383,7 +72138,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 26 /* LessThanToken */ || tokenKind === 28 /* GreaterThanToken */) { + if (tokenKind === 27 /* LessThanToken */ || tokenKind === 29 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -69392,19 +72147,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 57 /* EqualsToken */) { + if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 225 /* VariableDeclaration */ || - token.parent.kind === 148 /* PropertyDeclaration */ || - token.parent.kind === 145 /* Parameter */ || - token.parent.kind === 252 /* JsxAttribute */) { + if (token.parent.kind === 226 /* VariableDeclaration */ || + token.parent.kind === 149 /* PropertyDeclaration */ || + token.parent.kind === 146 /* Parameter */ || + token.parent.kind === 253 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 193 /* BinaryExpression */ || - token.parent.kind === 191 /* PrefixUnaryExpression */ || - token.parent.kind === 192 /* PostfixUnaryExpression */ || - token.parent.kind === 194 /* ConditionalExpression */) { + if (token.parent.kind === 194 /* BinaryExpression */ || + token.parent.kind === 192 /* PrefixUnaryExpression */ || + token.parent.kind === 193 /* PostfixUnaryExpression */ || + token.parent.kind === 195 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -69414,9 +72169,9 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 252 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 253 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } - else if (tokenKind === 11 /* RegularExpressionLiteral */) { + else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -69427,35 +72182,35 @@ var ts; else if (tokenKind === 10 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 70 /* Identifier */) { + else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 145 /* Parameter */: + case 146 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -69486,12 +72241,490 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var Completions; + (function (Completions) { + var PathCompletions; + (function (PathCompletions) { + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + PathCompletions.getStringLiteralCompletionEntriesFromModuleNames = getStringLiteralCompletionEntriesFromModuleNames; + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + // Make all paths absolute/normalized if they are not already + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + // Determine the path to the directory containing the script relative to the root directory it is contained within + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + // Now find a path for each potential directory that is to be merged with the one containing the script + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + } + } + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]); + if (matches) { + var result = []; + // Trim away prefix and suffix + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_6 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_6))); + } + return result; + } + } + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + // Check If this is a nested module + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + // Get modules that the type checker picked up + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } + } + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); + } + else { + // Give completions based on the typings available + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + } + } + return completionInfo; + } + PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + // Check for typings specified in compiler options + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); + } + } + } + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + // Provide completions for all non @types dependencies + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName: moduleName, + moduleDir: moduleDir + }); + } + } + } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; + } + } + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); + } + } + } + } + } + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } + /** + * Matches a triple slash reference directive with an incomplete string literal for its path. Used + * to determine if the caret is currently within the string literal and capture the literal fragment + * for completions. + * For example, this matches + * + * /// +/* @internal */ +var ts; (function (ts) { var Completions; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); + return Completions.PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); @@ -69500,10 +72733,14 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; - if (isJsDocTagName) { + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, requestJsDocTagName = completionData.requestJsDocTagName, requestJsDocTag = completionData.requestJsDocTag; + if (requestJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getJSDocTagNameCompletions() }; + } + if (requestJsDocTag) { + // If the current position is a jsDoc tag, only tags should be provided for completion + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getJSDocTagCompletions() }; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { @@ -69513,7 +72750,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 251 /* JsxClosingElement */) { + location.parent && location.parent.kind === 252 /* 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: @@ -69533,7 +72770,7 @@ var ts; getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list - if (!isMemberCompletion && !isJsDocTagName) { + if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -69609,8 +72846,8 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 260 /* PropertyAssignment */ && - node.parent.parent.kind === 177 /* ObjectLiteralExpression */ && + if (node.parent.kind === 261 /* PropertyAssignment */ && + node.parent.parent.kind === 178 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -69635,12 +72872,12 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); } - else if (node.parent.kind === 237 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 238 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + return Completions.PathCompletions.getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); } else if (isEqualityExpression(node.parent)) { // Get completions from the type of the other operand @@ -69733,427 +72970,6 @@ var ts; }); } } - function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - var extensions = ts.getSupportedExtensions(compilerOptions); - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); - } - } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - // Make all paths absolute/normalized if they are not already - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - // Determine the path to the directory containing the script relative to the root directory it is contained within - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); - } - return result; - } - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles.get(foundFileName)) { - foundFiles.set(foundFileName, true); - } - } - ts.forEachKey(foundFiles, function (foundFile) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - }); - } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - // Trim away prefix and suffix - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { - // Check If this is a nested module - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - // Get modules that the type checker picked up - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { - return undefined; - } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); - } - else { - // Give completions based on the typings available - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; - } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - // Check for typings specified in compiler options - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir, host) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent = ts.getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - // Provide completions for all non @types dependencies - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); - } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); @@ -70165,13 +72981,14 @@ var ts; // completion entry. var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -70183,7 +73000,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -70205,7 +73023,10 @@ var ts; Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); - var isJsDocTagName = false; + // JsDoc tag-name is just the name of the JSDoc tagname (exclude "@") + var requestJsDocTagName = false; + // JsDoc tag includes both "@" and tag-name + var requestJsDocTag = false; var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (ts.timestamp() - start)); @@ -70214,10 +73035,32 @@ var ts; var insideComment = ts.isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); if (insideComment) { - // The current position is next to the '@' sign, when no tag name being provided yet. - // Provide a full list of tag names - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { - isJsDocTagName = true; + if (ts.hasDocComment(sourceFile, position)) { + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + requestJsDocTagName = true; + } + else { + // When completion is requested without "@", we will have check to make sure that + // there are no comments prefix the request position. We will only allow "*" and space. + // e.g + // /** |c| /* + // + // /** + // |c| + // */ + // + // /** + // * |c| + // */ + // + // /** + // * |c| + // */ + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + requestJsDocTag = !(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); + } } // Completion should work inside certain JsDoc tags. For example: // /** @type {number | string} */ @@ -70226,12 +73069,12 @@ var ts; var tag = ts.getJsDocTagAtPosition(sourceFile, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; + requestJsDocTagName = true; } switch (tag.kind) { - case 287 /* JSDocTypeTag */: - case 285 /* JSDocParameterTag */: - case 286 /* JSDocReturnTag */: + case 288 /* JSDocTypeTag */: + case 286 /* JSDocParameterTag */: + case 287 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -70239,8 +73082,8 @@ var ts; break; } } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + if (requestJsDocTagName || requestJsDocTag) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; } if (!insideJsDocTagExpression) { // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal @@ -70276,13 +73119,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent = contextToken.parent, kind = contextToken.kind; - if (kind === 22 /* DotToken */) { - if (parent.kind === 178 /* PropertyAccessExpression */) { + var parent = contextToken.parent; + if (contextToken.kind === 23 /* DotToken */) { + if (parent.kind === 179 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent.kind === 142 /* QualifiedName */) { + else if (parent.kind === 143 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -70293,23 +73136,30 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - switch (contextToken.parent.kind) { - case 251 /* JsxClosingElement */: - if (kind === 40 /* SlashToken */) { + // + // If the tagname is a property access expression, we will then walk up to the top most of property access expression. + // Then, try to get a JSX container and its associated attributes type. + if (parent && parent.kind === 179 /* PropertyAccessExpression */) { + contextToken = parent; + parent = parent.parent; + } + switch (parent.kind) { + case 252 /* JsxClosingElement */: + if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 193 /* BinaryExpression */: - if (!(contextToken.parent.left.flags & 32768 /* ThisNodeHasError */)) { + case 194 /* BinaryExpression */: + if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { // It has a left-hand side, so we're not in an opening JSX tag. break; } - // fall through - case 249 /* JsxSelfClosingElement */: - case 248 /* JsxElement */: - case 250 /* JsxOpeningElement */: - if (kind === 26 /* LessThanToken */) { + // falls through + case 250 /* JsxSelfClosingElement */: + case 249 /* JsxElement */: + case 251 /* JsxOpeningElement */: + if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } @@ -70354,13 +73204,13 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */) { + if (node.kind === 71 /* Identifier */ || node.kind === 143 /* QualifiedName */ || node.kind === 179 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -70416,7 +73266,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 249 /* JsxSelfClosingElement */) || (jsxContainer.kind === 250 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 250 /* JsxSelfClosingElement */) || (jsxContainer.kind === 251 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { @@ -70464,9 +73314,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 264 /* SourceFile */ || - scopeNode.kind === 195 /* TemplateExpression */ || - scopeNode.kind === 255 /* JsxExpression */ || + scopeNode.kind === 265 /* SourceFile */ || + scopeNode.kind === 196 /* TemplateExpression */ || + scopeNode.kind === 256 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -70498,12 +73348,12 @@ var ts; if (contextToken.kind === 10 /* JsxText */) { return true; } - if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 250 /* JsxOpeningElement */) { + if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 251 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 251 /* JsxClosingElement */ || contextToken.parent.kind === 249 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 248 /* JsxElement */; + if (contextToken.parent.kind === 252 /* JsxClosingElement */ || contextToken.parent.kind === 250 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 249 /* JsxElement */; } } return false; @@ -70512,41 +73362,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 25 /* CommaToken */: - return containingNodeKind === 180 /* CallExpression */ // func( a, | - || containingNodeKind === 151 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 181 /* NewExpression */ // new C(a, | - || containingNodeKind === 176 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 193 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 159 /* FunctionType */; // var x: (s: string, list| - case 18 /* OpenParenToken */: - return containingNodeKind === 180 /* CallExpression */ // func( | - || containingNodeKind === 151 /* Constructor */ // constructor( | - || containingNodeKind === 181 /* NewExpression */ // new C(a| - || containingNodeKind === 184 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 167 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 20 /* OpenBracketToken */: - return containingNodeKind === 176 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 156 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 143 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 127 /* ModuleKeyword */: // module | - case 128 /* NamespaceKeyword */: + case 26 /* CommaToken */: + return containingNodeKind === 181 /* CallExpression */ // func( a, | + || containingNodeKind === 152 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 182 /* NewExpression */ // new C(a, | + || containingNodeKind === 177 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 194 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 160 /* FunctionType */; // var x: (s: string, list| + case 19 /* OpenParenToken */: + return containingNodeKind === 181 /* CallExpression */ // func( | + || containingNodeKind === 152 /* Constructor */ // constructor( | + || containingNodeKind === 182 /* NewExpression */ // new C(a| + || containingNodeKind === 185 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 168 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 21 /* OpenBracketToken */: + return containingNodeKind === 177 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 157 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 144 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 128 /* ModuleKeyword */: // module | + case 129 /* NamespaceKeyword */: return true; - case 22 /* DotToken */: - return containingNodeKind === 232 /* ModuleDeclaration */; // module A.| - case 16 /* OpenBraceToken */: - return containingNodeKind === 228 /* ClassDeclaration */; // class A{ | - case 57 /* EqualsToken */: - return containingNodeKind === 225 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 193 /* BinaryExpression */; // x = a| - case 13 /* TemplateHead */: - return containingNodeKind === 195 /* TemplateExpression */; // `aa ${| - case 14 /* TemplateMiddle */: - return containingNodeKind === 204 /* TemplateSpan */; // `aa ${10} dd ${| - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - return containingNodeKind === 148 /* PropertyDeclaration */; // class A{ public | + case 23 /* DotToken */: + return containingNodeKind === 233 /* ModuleDeclaration */; // module A.| + case 17 /* OpenBraceToken */: + return containingNodeKind === 229 /* ClassDeclaration */; // class A{ | + case 58 /* EqualsToken */: + return containingNodeKind === 226 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 194 /* BinaryExpression */; // x = a| + case 14 /* TemplateHead */: + return containingNodeKind === 196 /* TemplateExpression */; // `aa ${| + case 15 /* TemplateMiddle */: + return containingNodeKind === 205 /* TemplateSpan */; // `aa ${10} dd ${| + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + return containingNodeKind === 149 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -70560,7 +73410,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 11 /* RegularExpressionLiteral */ + || contextToken.kind === 12 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -70573,7 +73423,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 11 /* RegularExpressionLiteral */; + || contextToken.kind === 12 /* RegularExpressionLiteral */; } } return false; @@ -70589,7 +73439,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 177 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 178 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -70599,7 +73449,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 173 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 174 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -70610,11 +73460,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 145 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 146 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 150 /* MethodDeclaration */ || rootDeclaration.parent.kind === 153 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 151 /* MethodDeclaration */ || rootDeclaration.parent.kind === 154 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -70656,9 +73506,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 240 /* NamedImports */ ? - 237 /* ImportDeclaration */ : - 243 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 241 /* NamedImports */ ? + 238 /* ImportDeclaration */ : + 244 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -70682,10 +73532,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16 /* OpenBraceToken */: // const x = { | - case 25 /* CommaToken */: + case 17 /* OpenBraceToken */: // const x = { | + case 26 /* CommaToken */: var parent = contextToken.parent; - if (parent && (parent.kind === 177 /* ObjectLiteralExpression */ || parent.kind === 173 /* ObjectBindingPattern */)) { + if (parent && (parent.kind === 178 /* ObjectLiteralExpression */ || parent.kind === 174 /* ObjectBindingPattern */)) { return parent; } break; @@ -70700,11 +73550,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16 /* OpenBraceToken */: // import { | - case 25 /* CommaToken */: + case 17 /* OpenBraceToken */: // import { | + case 26 /* CommaToken */: switch (contextToken.parent.kind) { - case 240 /* NamedImports */: - case 244 /* NamedExports */: + case 241 /* NamedImports */: + case 245 /* NamedExports */: return contextToken.parent; } } @@ -70715,16 +73565,17 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 27 /* LessThanSlashToken */: - case 40 /* SlashToken */: - case 70 /* Identifier */: - case 253 /* JsxAttributes */: - case 252 /* JsxAttribute */: - case 254 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 249 /* JsxSelfClosingElement */ || parent.kind === 250 /* JsxOpeningElement */)) { + case 28 /* LessThanSlashToken */: + case 41 /* SlashToken */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: + case 254 /* JsxAttributes */: + case 253 /* JsxAttribute */: + case 255 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 250 /* JsxSelfClosingElement */ || parent.kind === 251 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 252 /* JsxAttribute */) { + else if (parent.kind === 253 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70736,7 +73587,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 252 /* JsxAttribute */) || (parent.kind === 254 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 253 /* JsxAttribute */) || (parent.kind === 255 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70744,10 +73595,10 @@ var ts; return parent.parent.parent; } break; - case 17 /* CloseBraceToken */: + case 18 /* CloseBraceToken */: if (parent && - parent.kind === 255 /* JsxExpression */ && - parent.parent && parent.parent.kind === 252 /* JsxAttribute */) { + parent.kind === 256 /* JsxExpression */ && + parent.parent && parent.parent.kind === 253 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70755,7 +73606,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 254 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 255 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70768,20 +73619,17 @@ var ts; return undefined; } function isFunction(kind) { + if (!ts.isFunctionLikeKind(kind)) { + return false; + } switch (kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 152 /* Constructor */: + case 161 /* ConstructorType */: + case 160 /* FunctionType */: + return false; + default: return true; } - return false; } /** * @returns true if we are certain that the currently edited location must define a new location; false otherwise. @@ -70789,67 +73637,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 25 /* CommaToken */: - return containingNodeKind === 225 /* VariableDeclaration */ || - containingNodeKind === 226 /* VariableDeclarationList */ || - containingNodeKind === 207 /* VariableStatement */ || - containingNodeKind === 231 /* EnumDeclaration */ || + case 26 /* CommaToken */: + return containingNodeKind === 226 /* VariableDeclaration */ || + containingNodeKind === 227 /* VariableDeclarationList */ || + containingNodeKind === 208 /* VariableStatement */ || + containingNodeKind === 232 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 228 /* ClassDeclaration */ || - containingNodeKind === 198 /* ClassExpression */ || - containingNodeKind === 229 /* InterfaceDeclaration */ || - containingNodeKind === 174 /* ArrayBindingPattern */ || - containingNodeKind === 230 /* TypeAliasDeclaration */; // type Map, K, | - case 22 /* DotToken */: - return containingNodeKind === 174 /* ArrayBindingPattern */; // var [.| - case 55 /* ColonToken */: - return containingNodeKind === 175 /* BindingElement */; // var {x :html| - case 20 /* OpenBracketToken */: - return containingNodeKind === 174 /* ArrayBindingPattern */; // var [x| - case 18 /* OpenParenToken */: - return containingNodeKind === 259 /* CatchClause */ || + containingNodeKind === 229 /* ClassDeclaration */ || + containingNodeKind === 199 /* ClassExpression */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || + containingNodeKind === 175 /* ArrayBindingPattern */ || + containingNodeKind === 231 /* TypeAliasDeclaration */; // type Map, K, | + case 23 /* DotToken */: + return containingNodeKind === 175 /* ArrayBindingPattern */; // var [.| + case 56 /* ColonToken */: + return containingNodeKind === 176 /* BindingElement */; // var {x :html| + case 21 /* OpenBracketToken */: + return containingNodeKind === 175 /* ArrayBindingPattern */; // var [x| + case 19 /* OpenParenToken */: + return containingNodeKind === 260 /* CatchClause */ || isFunction(containingNodeKind); - case 16 /* OpenBraceToken */: - return containingNodeKind === 231 /* EnumDeclaration */ || - containingNodeKind === 229 /* InterfaceDeclaration */ || - containingNodeKind === 162 /* TypeLiteral */; // const x : { | - case 24 /* SemicolonToken */: - return containingNodeKind === 147 /* PropertySignature */ && + case 17 /* OpenBraceToken */: + return containingNodeKind === 232 /* EnumDeclaration */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || + containingNodeKind === 163 /* TypeLiteral */; // const x : { | + case 25 /* SemicolonToken */: + return containingNodeKind === 148 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 229 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 162 /* TypeLiteral */); // const x : { a; | - case 26 /* LessThanToken */: - return containingNodeKind === 228 /* ClassDeclaration */ || - containingNodeKind === 198 /* ClassExpression */ || - containingNodeKind === 229 /* InterfaceDeclaration */ || - containingNodeKind === 230 /* TypeAliasDeclaration */ || + (contextToken.parent.parent.kind === 230 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 163 /* TypeLiteral */); // const x : { a; | + case 27 /* LessThanToken */: + return containingNodeKind === 229 /* ClassDeclaration */ || + containingNodeKind === 199 /* ClassExpression */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || + containingNodeKind === 231 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 114 /* StaticKeyword */: - return containingNodeKind === 148 /* PropertyDeclaration */; - case 23 /* DotDotDotToken */: - return containingNodeKind === 145 /* Parameter */ || + case 115 /* StaticKeyword */: + return containingNodeKind === 149 /* PropertyDeclaration */; + case 24 /* DotDotDotToken */: + return containingNodeKind === 146 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 174 /* ArrayBindingPattern */); // var [...z| - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - return containingNodeKind === 145 /* Parameter */; - case 117 /* AsKeyword */: - return containingNodeKind === 241 /* ImportSpecifier */ || - containingNodeKind === 245 /* ExportSpecifier */ || - containingNodeKind === 239 /* NamespaceImport */; - case 74 /* ClassKeyword */: - case 82 /* EnumKeyword */: - case 108 /* InterfaceKeyword */: - case 88 /* FunctionKeyword */: - case 103 /* VarKeyword */: - case 124 /* GetKeyword */: - case 134 /* SetKeyword */: - case 90 /* ImportKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: - case 115 /* YieldKeyword */: - case 137 /* TypeKeyword */: + contextToken.parent.parent.kind === 175 /* ArrayBindingPattern */); // var [...z| + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + return containingNodeKind === 146 /* Parameter */; + case 118 /* AsKeyword */: + return containingNodeKind === 242 /* ImportSpecifier */ || + containingNodeKind === 246 /* ExportSpecifier */ || + containingNodeKind === 240 /* NamespaceImport */; + case 75 /* ClassKeyword */: + case 83 /* EnumKeyword */: + case 109 /* InterfaceKeyword */: + case 89 /* FunctionKeyword */: + case 104 /* VarKeyword */: + case 125 /* GetKeyword */: + case 135 /* SetKeyword */: + case 91 /* ImportKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: + case 116 /* YieldKeyword */: + case 138 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -70919,12 +73767,12 @@ 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 !== 260 /* PropertyAssignment */ && - m.kind !== 261 /* ShorthandPropertyAssignment */ && - m.kind !== 175 /* BindingElement */ && - m.kind !== 150 /* MethodDeclaration */ && - m.kind !== 152 /* GetAccessor */ && - m.kind !== 153 /* SetAccessor */) { + if (m.kind !== 261 /* PropertyAssignment */ && + m.kind !== 262 /* ShorthandPropertyAssignment */ && + m.kind !== 176 /* BindingElement */ && + m.kind !== 151 /* MethodDeclaration */ && + m.kind !== 153 /* GetAccessor */ && + m.kind !== 154 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -70932,9 +73780,9 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 175 /* BindingElement */ && m.propertyName) { + if (m.kind === 176 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 70 /* Identifier */) { + if (m.propertyName.kind === 71 /* Identifier */) { existingName = m.propertyName.text; } } @@ -70962,7 +73810,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 252 /* JsxAttribute */) { + if (attr.kind === 253 /* JsxAttribute */) { seenNames.set(attr.name.text, true); } } @@ -71012,7 +73860,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 141 /* LastKeyword */; i++) { + for (var i = 72 /* FirstKeyword */; i <= 142 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -71020,58 +73868,14 @@ var ts; sortText: "0" }); } - /** - * Matches a triple slash reference directive with an incomplete string literal for its path. Used - * to determine if the caret is currently within the string literal and capture the literal fragment - * for completions. - * For example, this matches - * - * /// = 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { break; } } @@ -71456,7 +74254,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */, 77 /* ContinueKeyword */); } }); return keywords; @@ -71465,13 +74263,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -71479,14 +74277,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 98 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 73 /* CaseKeyword */, 79 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */); } }); }); @@ -71494,13 +74292,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 102 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 87 /* FinallyKeyword */); } return keywords; } @@ -71511,13 +74309,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96 /* ReturnKeyword */); }); } return keywords; @@ -71525,36 +74323,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 206 /* Block */))) { + if (!(func && hasKind(func.body, 207 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100 /* ThrowKeyword */); }); return keywords; } function getIfElseOccurrences(ifStatement, sourceFile) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 210 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 211 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 90 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 82 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 210 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 211 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -71563,7 +74361,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 82 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -71594,7 +74392,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 221 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 222 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -71716,271 +74514,988 @@ var ts; } ts.createDocumentRegistry = createDocumentRegistry; })(ts || (ts = {})); +/* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ /* @internal */ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { - var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); + /** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */ + function createImportTracker(sourceFiles, checker, cancellationToken) { + var allDirectImports = getDirectImportsMap(sourceFiles, checker, cancellationToken); + return function (exportSymbol, exportInfo, isForRename) { + var _a = getImportersForExport(sourceFiles, allDirectImports, exportInfo, checker, cancellationToken), directImports = _a.directImports, indirectUsers = _a.indirectUsers; + return __assign({ indirectUsers: indirectUsers }, getSearchesFromDirectImports(directImports, exportSymbol, exportInfo.exportKind, checker, isForRename)); + }; } - FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function convertReferences(referenceSymbols) { - return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); - } - FindAllReferences.convertReferences = convertReferences; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { - if (!implementations) { - var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); - if (special) { - return special; + FindAllReferences.createImportTracker = createImportTracker; + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + })(ExportKind = FindAllReferences.ExportKind || (FindAllReferences.ExportKind = {})); + var ImportExport; + (function (ImportExport) { + ImportExport[ImportExport["Import"] = 0] = "Import"; + ImportExport[ImportExport["Export"] = 1] = "Export"; + })(ImportExport = FindAllReferences.ImportExport || (FindAllReferences.ImportExport = {})); + /** Returns import statements that directly reference the exporting module, and a list of files that may access the module through a namespace. */ + function getImportersForExport(sourceFiles, allDirectImports, _a, checker, cancellationToken) { + var exportingModuleSymbol = _a.exportingModuleSymbol, exportKind = _a.exportKind; + var markSeenDirectImport = ts.nodeSeenTracker(); + var markSeenIndirectUser = ts.nodeSeenTracker(); + var directImports = []; + var isAvailableThroughGlobal = !!exportingModuleSymbol.globalExports; + var indirectUserDeclarations = isAvailableThroughGlobal ? undefined : []; + handleDirectImports(exportingModuleSymbol); + return { directImports: directImports, indirectUsers: getIndirectUsers() }; + function getIndirectUsers() { + if (isAvailableThroughGlobal) { + // It has `export as namespace`, so anything could potentially use it. + return sourceFiles; } - } - // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, - // so we have to specify that we want the constructor symbol. - var symbol = typeChecker.getSymbolAtLocation(node); - // Could not find a symbol e.g. unknown identifier - if (!symbol) { - if (!implementations && node.kind === 9 /* StringLiteral */) { - return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + // Module augmentations may use this module's exports without importing it. + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl)) { + addIndirectUser(decl); + } } - // Can't have references to something that we have no symbol for. - return undefined; + // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. + return indirectUserDeclarations.map(ts.getSourceFileOfNode); } - var declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!declarations || !declarations.length) { - return undefined; + function handleDirectImports(exportingModuleSymbol) { + var theseDirectImports = getDirectImports(exportingModuleSymbol); + if (theseDirectImports) + for (var _i = 0, theseDirectImports_1 = theseDirectImports; _i < theseDirectImports_1.length; _i++) { + var direct = theseDirectImports_1[_i]; + if (!markSeenDirectImport(direct)) { + continue; + } + cancellationToken.throwIfCancellationRequested(); + switch (direct.kind) { + case 181 /* CallExpression */: + if (!isAvailableThroughGlobal) { + var parent = direct.parent; + if (exportKind === 2 /* ExportEquals */ && parent.kind === 226 /* VariableDeclaration */) { + var name = parent.name; + if (name.kind === 71 /* Identifier */) { + directImports.push(name); + break; + } + } + // Don't support re-exporting 'require()' calls, so just add a single indirect user. + addIndirectUser(direct.getSourceFile()); + } + break; + case 237 /* ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */)); + break; + case 238 /* ImportDeclaration */: + var namedBindings = direct.importClause && direct.importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { + handleNamespaceImport(direct, namedBindings.name); + } + else { + directImports.push(direct); + } + break; + case 244 /* ExportDeclaration */: + if (!direct.exportClause) { + // This is `export * from "foo"`, so imports of this module may import the export too. + handleDirectImports(getContainingModuleSymbol(direct, checker)); + } + else { + // This is `export { foo } from "foo"` and creates an alias symbol, so recursive search will get handle re-exports. + directImports.push(direct); + } + break; + } + } } - var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; - symbol = aliasedSymbol; - // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); - if (shorthandModuleSymbol) { - searchSymbols.push(shorthandModuleSymbol); - } - // Compute the meaning from the location and the symbol it references - var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); - var result = []; - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - var symbolToIndex = []; - var inheritsFromCache = ts.createMap(); - // Get the text to search for. - // Note: if this is an external module symbol, the name doesn't include quotes. - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - // Try to get the smallest valid scope that we can limit our search to; - // otherwise we'll need to search globally (i.e. include each file). - var scope = getSymbolScope(symbol); - if (scope) { - getRefs(scope, declaredName); - } - else { - var isDefault = ts.isExportDefaultSymbol(symbol); - var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; - cancellationToken.throwIfCancellationRequested(); - var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || - (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); - if (searchName !== undefined) { - getRefs(sourceFile, searchName); + function handleNamespaceImport(importDeclaration, name, isReExport) { + if (exportKind === 2 /* ExportEquals */) { + // This is a direct import, not import-as-namespace. + directImports.push(importDeclaration); + } + else if (!isAvailableThroughGlobal) { + var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); + ts.Debug.assert(sourceFileLike.kind === 265 /* SourceFile */ || sourceFileLike.kind === 233 /* ModuleDeclaration */); + if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { + addIndirectUsers(sourceFileLike); + } + else { + addIndirectUser(sourceFileLike); } } } - return result; - function getRefs(scope, searchName) { - getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); + function addIndirectUser(sourceFileLike) { + ts.Debug.assert(!isAvailableThroughGlobal); + var isNew = markSeenIndirectUser(sourceFileLike); + if (isNew) { + indirectUserDeclarations.push(sourceFileLike); + } + return isNew; + } + /** Adds a module and all of its transitive dependencies as possible indirect users. */ + function addIndirectUsers(sourceFileLike) { + if (!addIndirectUser(sourceFileLike)) { + return; + } + var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + var directImports = getDirectImports(moduleSymbol); + if (directImports) + for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { + var directImport = directImports_1[_i]; + addIndirectUsers(getSourceFileLikeForImportDeclaration(directImport)); + } + } + function getDirectImports(moduleSymbol) { + return allDirectImports.get(ts.getSymbolId(moduleSymbol).toString()); } } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - /** getReferencedSymbols for special node kinds. */ - function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { - if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + /** + * Given the set of direct imports of a module, we need to find which ones import the particular exported symbol. + * The returned `importSearches` will result in the entire source file being searched. + * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. + */ + function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { + var exportName = exportSymbol.name; + var importSearches = []; + var singleReferences = []; + function addSearch(location, symbol) { + importSearches.push([location, symbol]); } - // Labels - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); + if (directImports) + for (var _i = 0, directImports_2 = directImports; _i < directImports_2.length; _i++) { + var decl = directImports_2[_i]; + handleImport(decl); + } + return { importSearches: importSearches, singleReferences: singleReferences }; + function handleImport(decl) { + if (decl.kind === 237 /* ImportEqualsDeclaration */) { + if (isExternalModuleImportEquals(decl)) { + handleNamespaceImportLike(decl.name); + } + return; + } + if (decl.kind === 71 /* Identifier */) { + handleNamespaceImportLike(decl); + return; + } + // Ignore if there's a grammar error + if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { + return; + } + if (decl.kind === 244 /* ExportDeclaration */) { + searchForNamedImport(decl.exportClause); + return; + } + var importClause = decl.importClause; + var namedBindings = importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { + handleNamespaceImportLike(namedBindings.name); + return; + } + if (exportKind === 0 /* Named */) { + searchForNamedImport(namedBindings); } else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node, cancellationToken); + // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals + var name = importClause.name; + // If a default import has the same name as the default export, allow to rename it. + // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. + if (name && (!isForRename || name.text === symbolName(exportSymbol))) { + var defaultImportAlias = checker.getSymbolAtLocation(name); + addSearch(name, defaultImportAlias); + } + // 'default' might be accessed as a named import `{ default as foo }`. + if (!isForRename && exportKind === 1 /* Default */) { + ts.Debug.assert(exportName === "default"); + searchForNamedImport(namedBindings); + } } } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + /** + * `import x = require("./x") or `import * as x from "./x"`. + * An `export =` may be imported by this syntax, so it may be a direct import. + * If it's not a direct import, it will be in `indirectUsers`, so we don't have to do anything here. + */ + function handleNamespaceImportLike(importName) { + // Don't rename an import that already has a different name than the export. + if (exportKind === 2 /* ExportEquals */ && (!isForRename || importName.text === exportName)) { + addSearch(importName, checker.getSymbolAtLocation(importName)); + } } - if (node.kind === 96 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + function searchForNamedImport(namedBindings) { + if (namedBindings) + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if ((propertyName || name).text !== exportName) { + continue; + } + if (propertyName) { + // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. + singleReferences.push(propertyName); + if (!isForRename) { + // Search locally for `bar`. + addSearch(name, checker.getSymbolAtLocation(name)); + } + } + else { + var localSymbol = element.kind === 246 /* ExportSpecifier */ && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } + } } - return undefined; + } + /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ + function findNamespaceReExports(sourceFileLike, name, checker) { + var namespaceImportSymbol = checker.getSymbolAtLocation(name); + return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + if (statement.kind !== 244 /* ExportDeclaration */) + return; + var _a = statement, exportClause = _a.exportClause, moduleSpecifier = _a.moduleSpecifier; + if (moduleSpecifier || !exportClause) + return; + for (var _i = 0, _b = exportClause.elements; _i < _b.length; _i++) { + var element = _b[_i]; + if (checker.getExportSpecifierLocalTargetSymbol(element) === namespaceImportSymbol) { + return true; + } + } + }); + } + /** Returns a map from a module symbol Id to all import statements that directly reference the module. */ + function getDirectImportsMap(sourceFiles, checker, cancellationToken) { + var map = ts.createMap(); + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; + cancellationToken.throwIfCancellationRequested(); + forEachImport(sourceFile, function (importDecl, moduleSpecifier) { + var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); + if (moduleSymbol) { + var id = ts.getSymbolId(moduleSymbol).toString(); + var imports = map.get(id); + if (!imports) { + map.set(id, imports = []); + } + imports.push(importDecl); + } + }); + } + return map; + } + /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ + function forEachPossibleImportOrExportStatement(sourceFileLike, action) { + return ts.forEach(sourceFileLike.kind === 265 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); + }); + } + /** Calls `action` for each import, re-export, or require() in a file. */ + function forEachImport(sourceFile, action) { + if (sourceFile.externalModuleIndicator) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; + action(importerFromModuleSpecifier(moduleSpecifier), moduleSpecifier); + } + } + else { + forEachPossibleImportOrExportStatement(sourceFile, function (statement) { + switch (statement.kind) { + case 244 /* ExportDeclaration */: + case 238 /* ImportDeclaration */: { + var decl = statement; + if (decl.moduleSpecifier && decl.moduleSpecifier.kind === 9 /* StringLiteral */) { + action(decl, decl.moduleSpecifier); + } + break; + } + case 237 /* ImportEqualsDeclaration */: { + var decl = statement; + var moduleReference = decl.moduleReference; + if (moduleReference.kind === 248 /* ExternalModuleReference */ && + moduleReference.expression.kind === 9 /* StringLiteral */) { + action(decl, moduleReference.expression); + } + break; + } + } + }); + if (sourceFile.flags & 65536 /* JavaScriptFile */) { + // Find all 'require()' calls. + sourceFile.forEachChild(function recur(node) { + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + action(node, node.arguments[0]); + } + else { + node.forEachChild(recur); + } + }); + } + } + } + function importerFromModuleSpecifier(moduleSpecifier) { + var decl = moduleSpecifier.parent; + if (decl.kind === 238 /* ImportDeclaration */ || decl.kind === 244 /* ExportDeclaration */) { + return decl; + } + ts.Debug.assert(decl.kind === 248 /* ExternalModuleReference */); + return decl.parent; } /** - * Follows aliases to get to the original declaration of a symbol. - * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + * Given a local reference, we might notice that it's an import/export and recursively search for references of that. + * If at an import, look locally for the symbol it imports. + * If an an export, look for all imports of it. + * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. + * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ - function followAliases(symbol, node, typeChecker, isForRename) { - while (true) { - // When renaming a default import, only rename in the current file - if (isForRename && isImportDefaultSymbol(symbol)) { - return { symbol: symbol }; + function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { + return comingFromExport ? getExport() : getExport() || getImport(); + function getExport() { + var parent = node.parent; + if (symbol.flags & 7340032 /* Export */) { + if (parent.kind === 179 /* PropertyAccessExpression */) { + // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. + // So check that we are at the declaration. + return symbol.declarations.some(function (d) { return d === parent; }) && parent.parent.kind === 194 /* BinaryExpression */ + ? getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ false) + : undefined; + } + else { + var exportSymbol = symbol.exportSymbol; + ts.Debug.assert(!!exportSymbol); + return exportInfo(exportSymbol, getExportKindForDeclaration(parent)); + } } - var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); - // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. - if (!aliasedSymbol || !aliasedSymbol.declarations) { - return { symbol: symbol }; + else { + var exportNode = getExportNode(parent); + if (exportNode && ts.hasModifier(exportNode, 1 /* Export */)) { + if (exportNode.kind === 237 /* ImportEqualsDeclaration */ && exportNode.moduleReference === node) { + // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. + if (comingFromExport) { + return undefined; + } + var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); + return { kind: 0 /* Import */, symbol: lhsSymbol, isNamedImport: false }; + } + else { + return exportInfo(symbol, getExportKindForDeclaration(exportNode)); + } + } + else if (parent.kind === 243 /* ExportAssignment */) { + // Get the symbol for the `export =` node; its parent is the module it's the export of. + var exportingModuleSymbol = parent.symbol.parent; + ts.Debug.assert(!!exportingModuleSymbol); + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 /* ExportEquals */ } }; + } + else if (parent.kind === 194 /* BinaryExpression */) { + return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); + } + else if (parent.parent.kind === 194 /* BinaryExpression */) { + return getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ true); + } } - if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { - return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; - } - symbol = aliasedSymbol; - } - } - function sourceFileHasName(sourceFile, name) { - return ts.getNameTable(sourceFile).get(name) !== undefined; - } - /** - * Given a symbol, see if any of the imports in a source file reference it. - * Only call this if `symbol` is a default export. - */ - function getDefaultImportName(symbol, sourceFile, checker) { - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importSpecifier = _a[_i]; - var importDecl = importSpecifier.parent; - ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); - var defaultName = importDecl.importClause.name; - var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); - if (symbol === defaultReferencedSymbol) { - return defaultName.text; + function getSpecialPropertyExport(node, useLhsSymbol) { + var kind; + switch (ts.getSpecialPropertyAssignmentKind(node)) { + case 1 /* ExportsProperty */: + kind = 0 /* Named */; + break; + case 2 /* ModuleExports */: + kind = 2 /* ExportEquals */; + break; + default: + return undefined; + } + var sym = useLhsSymbol ? checker.getSymbolAtLocation(node.left.name) : symbol; + return sym && exportInfo(sym, kind); } } - return undefined; + function getImport() { + var isImport = isNodeImport(node); + if (!isImport) + return; + // A symbol being imported is always an alias. So get what that aliases to find the local symbol. + var importedSymbol = checker.getImmediateAliasedSymbol(symbol); + if (importedSymbol) { + // Search on the local symbol in the exporting module, not the exported symbol. + importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker); + // Similarly, skip past the symbol for 'export =' + if (importedSymbol.name === "export=") { + importedSymbol = checker.getImmediateAliasedSymbol(importedSymbol); + } + if (symbolName(importedSymbol) === symbol.name) { + return __assign({ kind: 0 /* Import */, symbol: importedSymbol }, isImport); + } + } + } + function exportInfo(symbol, kind) { + var exportInfo = getExportInfo(symbol, kind, checker); + return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + } + // Not meant for use with export specifiers or export assignment. + function getExportKindForDeclaration(node) { + return ts.hasModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + } } - function getDefinition(symbol, node, typeChecker) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; - var name = displayParts.map(function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { + FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; + // If a reference is a variable declaration, the exported node would be the variable statement. + function getExportNode(parent) { + if (parent.kind === 226 /* VariableDeclaration */) { + var p = parent; + return p.parent.kind === 260 /* CatchClause */ ? undefined : p.parent.parent.kind === 208 /* VariableStatement */ ? p.parent.parent : undefined; + } + else { + return parent; + } + } + function isNodeImport(node) { + var parent = node.parent; + switch (parent.kind) { + case 237 /* ImportEqualsDeclaration */: + return parent.name === node && isExternalModuleImportEquals(parent) + ? { isNamedImport: false } + : undefined; + case 242 /* ImportSpecifier */: + // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. + return parent.propertyName ? undefined : { isNamedImport: true }; + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + ts.Debug.assert(parent.name === node); + return { isNamedImport: false }; + default: + return undefined; + } + } + function getExportInfo(exportSymbol, exportKind, checker) { + var exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); // Need to get merged symbol in case there's an augmentation. + // `export` may appear in a namespace. In that case, just rely on global search. + return ts.isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } : undefined; + } + FindAllReferences.getExportInfo = getExportInfo; + function symbolName(symbol) { + if (symbol.name !== "default") { + return symbol.name; + } + var name = ts.forEach(symbol.declarations, function (_a) { + var name = _a.name; + return name && name.kind === 71 /* Identifier */ && name.text; + }); + ts.Debug.assert(!!name); + return name; + } + /** If at an export specifier, go to the symbol it refers to. */ + function skipExportSpecifierSymbol(symbol, checker) { + // For `export { foo } from './bar", there's nothing to skip, because it does not create a new alias. But `export { foo } does. + if (symbol.declarations) + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) { + return checker.getExportSpecifierLocalTargetSymbol(declaration); + } + } + return symbol; + } + function getContainingModuleSymbol(importer, checker) { + return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); + } + function getSourceFileLikeForImportDeclaration(node) { + if (node.kind === 181 /* CallExpression */) { + return node.getSourceFile(); + } + var parent = node.parent; + if (parent.kind === 265 /* SourceFile */) { + return parent; + } + ts.Debug.assert(parent.kind === 234 /* ModuleBlock */ && isAmbientModuleDeclaration(parent.parent)); + return parent.parent; + } + function isAmbientModuleDeclaration(node) { + return node.kind === 233 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + } + function isExternalModuleImportEquals(_a) { + var moduleReference = _a.moduleReference; + return moduleReference.kind === 248 /* ExternalModuleReference */ && moduleReference.expression.kind === 9 /* StringLiteral */; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + function nodeEntry(node, isInString) { + return { type: "node", node: node, isInString: isInString }; + } + FindAllReferences.nodeEntry = nodeEntry; + function findReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position) { + var referencedSymbols = findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position); + if (!referencedSymbols || !referencedSymbols.length) { return undefined; } + var out = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var _a = referencedSymbols_1[_i], definition = _a.definition, references = _a.references; + // Only include referenced symbols that have a valid definition. + if (definition) { + out.push({ definition: definitionToReferencedSymbolDefinitionInfo(definition, checker), references: references.map(toReferenceEntry) }); + } + } + return out; + } + FindAllReferences.findReferencedSymbols = findReferencedSymbols; + function getImplementationsAtPosition(checker, cancellationToken, sourceFiles, sourceFile, position) { + var node = ts.getTouchingPropertyName(sourceFile, position); + var referenceEntries = getImplementationReferenceEntries(checker, cancellationToken, sourceFiles, node); + return ts.map(referenceEntries, function (entry) { return toImplementationLocation(entry, checker); }); + } + FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; + function getImplementationReferenceEntries(typeChecker, cancellationToken, sourceFiles, node) { + // If invoked directly on a shorthand property assignment, then return + // the declaration of the symbol being assigned (not the symbol being assigned to). + if (node.parent.kind === 262 /* ShorthandPropertyAssignment */) { + var result_4 = []; + FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, function (node) { return result_4.push(nodeEntry(node)); }); + return result_4; + } + else if (node.kind === 97 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + // References to and accesses on the super keyword only have one possible implementation, so no + // need to "Find all References" + var symbol = typeChecker.getSymbolAtLocation(node); + return symbol.valueDeclaration && [nodeEntry(symbol.valueDeclaration)]; + } + else { + // Perform "Find all References" and retrieve only those that are implementations + return getReferenceEntriesForNode(node, sourceFiles, typeChecker, cancellationToken, { implementations: true }); + } + } + function findReferencedEntries(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var x = flattenEntries(findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options)); + return ts.map(x, toReferenceEntry); + } + FindAllReferences.findReferencedEntries = findReferencedEntries; + function getReferenceEntriesForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + return flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options)); + } + FindAllReferences.getReferenceEntriesForNode = getReferenceEntriesForNode; + function findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + return FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options); + } + function flattenEntries(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + function definitionToReferencedSymbolDefinitionInfo(def, checker) { + var info = (function () { + switch (def.type) { + case "symbol": { + var symbol = def.symbol, node_2 = def.node; + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; + var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + } + case "label": { + var node_3 = def.node; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + } + case "keyword": { + var node_4 = def.node; + var name_4 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; + } + case "this": { + var node_5 = def.node; + var symbol = checker.getSymbolAtLocation(node_5); + var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; + } + case "string": { + var node_6 = def.node; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + } + } + })(); + if (!info) { + return undefined; + } + var node = info.node, name = info.name, kind = info.kind, displayParts = info.displayParts; + var sourceFile = node.getSourceFile(); return { containerKind: "", containerName: "", + fileName: sourceFile.fileName, + kind: kind, name: name, - kind: symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + textSpan: ts.createTextSpanFromNode(node, sourceFile), displayParts: displayParts }; } - function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { - if (!(symbol.flags & 8388608 /* Alias */)) { - return undefined; + function getDefinitionKindAndDisplayParts(symbol, node, checker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + return { displayParts: displayParts, kind: symbolKind }; + } + function toReferenceEntry(entry) { + if (entry.type === "span") { + return { textSpan: entry.textSpan, fileName: entry.fileName, isWriteAccess: false, isDefinition: false }; } - // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 238 /* ImportClause */); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); + var node = entry.node, isInString = entry.isInString; + return { + fileName: node.getSourceFile().fileName, + textSpan: getTextSpan(node), + isWriteAccess: isWriteAccess(node), + isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isInString: isInString + }; + } + function toImplementationLocation(entry, checker) { + if (entry.type === "node") { + var node = entry.node; + return __assign({ textSpan: getTextSpan(node), fileName: node.getSourceFile().fileName }, implementationKindDisplayParts(node, checker)); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 /* ImportSpecifier */ || - declaration.kind === 245 /* ExportSpecifier */) ? declaration : undefined; }); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === 241 /* ImportSpecifier */ ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); + else { + var textSpan = entry.textSpan, fileName = entry.fileName; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } - function followAliasIfNecessary(symbol, location, typeChecker) { - return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); - return bindingElement && - bindingElement.parent.kind === 173 /* ObjectBindingPattern */ && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + function implementationKindDisplayParts(node, checker) { + var symbol = checker.getSymbolAtLocation(ts.isDeclaration(node) && node.name ? node.name : node); + if (symbol) { + return getDefinitionKindAndDisplayParts(symbol, node, checker); } - return undefined; - } - function getInternedName(symbol, location) { - // If this is an export or import specifier it could have been renamed using the 'as' syntax. - // If so we want to search for whatever under the cursor. - if (ts.isImportOrExportSpecifierName(location)) { - return location.text; + else if (node.kind === 178 /* ObjectLiteralExpression */) { + return { + kind: ts.ScriptElementKind.interfaceElement, + displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] + }; } - return ts.stripQuotes(symbol.name); - } - /** - * Determines the smallest scope in which a symbol may have named references. - * Note that not every construct has been accounted for. This function can - * probably be improved. - * - * @returns undefined if the scope cannot be determined, implying that - * a reference to a symbol can occur anywhere. - */ - function getSymbolScope(symbol) { - // 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 === 185 /* FunctionExpression */ || valueDeclaration.kind === 198 /* ClassExpression */)) { - return valueDeclaration; + else if (node.kind === 199 /* ClassExpression */) { + return { + kind: ts.ScriptElementKind.localClassElement, + displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] + }; } - // 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 228 /* ClassDeclaration */); + else { + return { kind: ts.getNodeKind(node), displayParts: [] }; + } + } + function toHighlightSpan(entry) { + if (entry.type === "span") { + var fileName_1 = entry.fileName, textSpan = entry.textSpan; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; + } + var node = entry.node, isInString = entry.isInString; + var fileName = entry.node.getSourceFile().fileName; + var writeAccess = isWriteAccess(node); + var span = { + textSpan: getTextSpan(node), + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, + isInString: isInString + }; + return { fileName: fileName, span: span }; + } + FindAllReferences.toHighlightSpan = toHighlightSpan; + function getTextSpan(node) { + var start = node.getStart(); + var end = node.getEnd(); + if (node.kind === 9 /* StringLiteral */) { + start += 1; + end -= 1; + } + return ts.createTextSpanFromBounds(start, end); + } + /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ + function isWriteAccess(node) { + if (node.kind === 71 /* Identifier */ && ts.isDeclarationName(node)) { + return true; + } + var parent = node.parent; + if (parent) { + if (parent.kind === 193 /* PostfixUnaryExpression */ || parent.kind === 192 /* PrefixUnaryExpression */) { + return true; + } + else if (parent.kind === 194 /* BinaryExpression */ && parent.left === node) { + var operator = parent.operatorToken.kind; + return 58 /* FirstAssignment */ <= operator && operator <= 70 /* LastAssignment */; } } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { + return false; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +/** Encapsulates the core find-all-references algorithm. */ +/* @internal */ +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + var Core; + (function (Core) { + /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ + function getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + if (node.kind === 265 /* SourceFile */) { + return undefined; + } + if (!options.implementations) { + var special = getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken); + if (special) { + return special; + } + } + var symbol = checker.getSymbolAtLocation(node); + // Could not find a symbol e.g. unknown identifier + if (!symbol) { + // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. + if (!options.implementations && node.kind === 9 /* StringLiteral */) { + return getReferencesForStringLiteral(node, sourceFiles, cancellationToken); + } + // Can't have references to something that we have no symbol for. + return undefined; + } + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol + if (!symbol.declarations || !symbol.declarations.length) { + return undefined; + } + return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options); + } + Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition); + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); + } + if (node.kind === 97 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node); + } return undefined; } - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + /** Core find-all-references algorithm for a normal symbol. */ + function getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options) { + symbol = skipPastExportOrImportSpecifier(symbol, node, checker); + // Compute the meaning from the location and the symbol it references + var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), symbol.declarations); + var result = []; + var state = createState(sourceFiles, node, checker, cancellationToken, searchMeaning, options, result); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: populateSearchSymbolSet(symbol, node, checker, options.implementations) }); + // Try to get the smallest valid scope that we can limit our search to; + // otherwise we'll need to search globally (i.e. include each file). + var scope = getSymbolScope(symbol); + if (scope) { + getReferencesInContainer(scope, scope.getSourceFile(), search, state); + } + else { + // Global search + for (var _i = 0, _a = state.sourceFiles; _i < _a.length; _i++) { + var sourceFile = _a[_i]; + state.cancellationToken.throwIfCancellationRequested(); + searchForName(sourceFile, search, state); + } + } + return result; + } + /** Handle a few special cases relating to export/import specifiers. */ + function skipPastExportOrImportSpecifier(symbol, node, checker) { + var parent = node.parent; + if (ts.isExportSpecifier(parent)) { + return getLocalSymbolForExportSpecifier(node, symbol, parent, checker); + } + if (ts.isImportSpecifier(parent) && parent.propertyName === node) { + // We're at `foo` in `import { foo as bar }`. Probably intended to find all refs on the original, not just on the import. + return checker.getImmediateAliasedSymbol(symbol); + } + return symbol; + } + function createState(sourceFiles, originalLocation, checker, cancellationToken, searchMeaning, options, result) { + var symbolIdToReferences = []; + var inheritsFromCache = ts.createMap(); + // Source file ID → symbol ID → Whether the symbol has been searched for in the source file. + var sourceFileToSeenSymbols = []; + var isForConstructor = originalLocation.kind === 123 /* ConstructorKeyword */; + var importTracker; + return __assign({}, options, { sourceFiles: sourceFiles, isForConstructor: isForConstructor, checker: checker, cancellationToken: cancellationToken, searchMeaning: searchMeaning, inheritsFromCache: inheritsFromCache, getImportSearches: getImportSearches, createSearch: createSearch, referenceAdder: referenceAdder, addStringOrCommentReference: addStringOrCommentReference, + markSearchedSymbol: markSearchedSymbol, markSeenContainingTypeReference: ts.nodeSeenTracker(), markSeenReExportRHS: ts.nodeSeenTracker() }); + function getImportSearches(exportSymbol, exportInfo) { + if (!importTracker) + importTracker = FindAllReferences.createImportTracker(sourceFiles, checker, cancellationToken); + return importTracker(exportSymbol, exportInfo, options.isForRename); + } + function createSearch(location, symbol, comingFrom, searchOptions) { + if (searchOptions === void 0) { searchOptions = {}; } + // Note: if this is an external module symbol, the name doesn't include quotes. + var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.getDeclaredName(checker, symbol, location)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? undefined : _b; + var escapedText = ts.escapeIdentifier(text); + var parents = options.implementations && getParentSymbolsOfPropertyAccess(location, symbol, checker); + return { location: location, symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, includes: includes }; + function includes(referenceSymbol) { + return allSearchSymbols ? ts.contains(allSearchSymbols, referenceSymbol) : referenceSymbol === symbol; + } + } + function referenceAdder(referenceSymbol, searchLocation) { + var symbolId = ts.getSymbolId(referenceSymbol); + var references = symbolIdToReferences[symbolId]; + if (!references) { + references = symbolIdToReferences[symbolId] = []; + result.push({ definition: { type: "symbol", symbol: referenceSymbol, node: searchLocation }, references: references }); + } + return function (node) { return references.push(FindAllReferences.nodeEntry(node)); }; + } + function addStringOrCommentReference(fileName, textSpan) { + result.push({ + definition: undefined, + references: [{ type: "span", fileName: fileName, textSpan: textSpan }] + }); + } + function markSearchedSymbol(sourceFile, symbol) { + var sourceId = ts.getNodeId(sourceFile); + var symbolId = ts.getSymbolId(symbol); + var seenSymbols = sourceFileToSeenSymbols[sourceId] || (sourceFileToSeenSymbols[sourceId] = []); + return !seenSymbols[symbolId] && (seenSymbols[symbolId] = true); + } + } + /** Search for all imports of a given exported symbol using `State.getImportSearches`. */ + function searchForImportsOfExport(exportLocation, exportSymbol, exportInfo, state) { + var _a = state.getImportSearches(exportSymbol, exportInfo), importSearches = _a.importSearches, singleReferences = _a.singleReferences, indirectUsers = _a.indirectUsers; + // For `import { foo as bar }` just add the reference to `foo`, and don't otherwise search in the file. + if (singleReferences.length) { + var addRef = state.referenceAdder(exportSymbol, exportLocation); + for (var _i = 0, singleReferences_1 = singleReferences; _i < singleReferences_1.length; _i++) { + var singleRef = singleReferences_1[_i]; + addRef(singleRef); + } + } + // For each import, find all references to that import in its source file. + for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { + var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + } + if (indirectUsers.length) { + var indirectSearch = void 0; + switch (exportInfo.exportKind) { + case 0 /* Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + break; + case 1 /* Default */: + // Search for a property access to '.default'. This can't be renamed. + indirectSearch = state.isForRename ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + break; + case 2 /* ExportEquals */: + break; + } + if (indirectSearch) { + for (var _d = 0, indirectUsers_1 = indirectUsers; _d < indirectUsers_1.length; _d++) { + var indirectUser = indirectUsers_1[_d]; + searchForName(indirectUser, indirectSearch, state); + } + } + } + } + // Go to the symbol we imported from and find references for it. + function searchForImportedSymbol(symbol, state) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + getReferencesInSourceFile(declaration.getSourceFile(), state.createSearch(declaration, symbol, 0 /* Import */), state); + } + } + /** Search for all occurences of an identifier in a source file (and filter out the ones that match). */ + function searchForName(sourceFile, search, state) { + if (ts.getNameTable(sourceFile).get(search.escapedText) !== undefined) { + getReferencesInSourceFile(sourceFile, search, state); + } + } + function getPropertySymbolOfDestructuringAssignment(location, checker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + checker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176 /* BindingElement */); + return bindingElement && + bindingElement.parent.kind === 174 /* ObjectBindingPattern */ && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176 /* BindingElement */); + var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } return undefined; } - // if this symbol is visible from its parent container, e.g. exported, then bail out - // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ + function getSymbolScope(symbol) { + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. + var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 186 /* FunctionExpression */ || valueDeclaration.kind === 199 /* ClassExpression */)) { + return valueDeclaration; + } + if (!declarations) { + return undefined; + } + // If this is private property or method, the scope is the containing class + if (flags & (4 /* Property */ | 8192 /* Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return !!(ts.getModifierFlags(d) & 8 /* Private */); }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 229 /* ClassDeclaration */); + } + } + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + // If the symbol has a parent, it's globally visible. + // Unless that parent is an external module, then we should only search in the module (and recurse on the export later). + // But if the parent is a module that has `export as namespace`, then the symbol *is* globally visible. + if (parent && !((parent.flags & 1536 /* Module */) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { + return undefined; + } + // If this is a synthetic property, it's a property and must be searched for globally. + if ((flags & 134217728 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */)) { + return undefined; + } + var scope; for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { var declaration = declarations_10[_i]; var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } if (scope && scope !== container) { // Different declarations have different containers, bail out return undefined; } - if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { + if (!container || container.kind === 265 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -71988,984 +75503,955 @@ var ts; // The search scope is the container node scope = container; } + // If symbol.parent, this means we are in an export of an external module. (Otherwise we would have returned `undefined` above.) + // For an export of a module, we may be in a declaration file, and it may be accessed elsewhere. E.g.: + // declare module "a" { export type T = number; } + // declare module "b" { import { T } from "a"; export const x: T; } + // So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.) + return parent ? scope.getSourceFile() : scope; } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { - var positions = []; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + // If we are past the end, stop looking + if (position > end) + break; + // We found a match. Make sure it's not part of a larger word (i.e. the char + // before and after it have to be a non-identifier char). + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } return positions; } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - // If we are past the end, stop looking - if (position > end) - break; - // We found a match. Make sure it's not part of a larger word (i.e. the char - // before and after it have to be a non-identifier char). - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { - // Found a real match. Keep searching. - positions.push(position); + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + continue; + } + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(FindAllReferences.nodeEntry(node)); + } } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + return [{ definition: { type: "label", node: targetLabel }, references: references }]; } - return positions; - } - function getLabelReferencesInNode(container, targetLabel, cancellationToken) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { + function isValidReferencePosition(node, searchSymbolName) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case 71 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, ts.tokenToString(keywordKind), references); + } + return references.length ? [{ definition: { type: "keyword", node: references[0].node }, references: references }] : undefined; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd()); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push(FindAllReferences.nodeEntry(referenceLocation)); + } + } + } + function getReferencesInSourceFile(sourceFile, search, state) { + state.cancellationToken.throwIfCancellationRequested(); + return getReferencesInContainer(sourceFile, sourceFile, search, state); + } + /** + * Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInContainer(container, sourceFile, search, state) { + if (!state.markSearchedSymbol(sourceFile, search.symbol)) { return; } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; - } - function isValidReferencePosition(node, searchSymbolName) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node && node.kind) { - case 70 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && - // For string literals we have two additional chars for the quotes - node.getWidth() === searchSymbolName.length + 2; - case 8 /* NumericLiteral */: - return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; - default: - return false; - } - } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { - var name = ts.tokenToString(keywordKind); - var references = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); - } - if (!references.length) - return undefined; - var definition = { - containerKind: "", - containerName: "", - fileName: references[0].fileName, - kind: ts.ScriptElementKind.keyword, - name: name, - textSpan: references[0].textSpan, - displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] - }; - return [{ definition: definition, references: references }]; - } - function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (referenceLocation.kind === kind) { - references.push({ - textSpan: ts.createTextSpanFromNode(referenceLocation), - fileName: sourceFile.fileName, - isWriteAccess: false, - isDefinition: false, - }); + var start = state.findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, search.text, start, container.getEnd()); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + getReferencesAtLocation(sourceFile, position, search, state); } } - } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); - var parents = getParentSymbolsOfPropertyAccess(); - for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { - var position = possiblePositions_2[_i]; - cancellationToken.throwIfCancellationRequested(); + function getReferencesAtLocation(sourceFile, position, search, state) { var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!isValidReferencePosition(referenceLocation, search.text)) { // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + if (!state.implementations && (state.findInStrings && ts.isInString(sourceFile, position) || state.findInComments && ts.isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); + state.addStringOrCommentReference(sourceFile.fileName, ts.createTextSpan(position, search.text.length)); } - continue; + return; } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - continue; + if (!(ts.getMeaningFromLocation(referenceLocation) & state.searchMeaning)) { + return; } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache, typeChecker); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + var referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation); + if (!referenceSymbol) { + return; + } + var parent = referenceLocation.parent; + if (ts.isImportSpecifier(parent) && parent.propertyName === referenceLocation) { + // This is added through `singleReferences` in ImportsResult. If we happen to see it again, don't add it again. + return; + } + if (ts.isExportSpecifier(parent)) { + ts.Debug.assert(referenceLocation.kind === 71 /* Identifier */); + getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state); + return; + } + var relatedSymbol = getRelatedSymbol(search, referenceSymbol, referenceLocation, state); + if (!relatedSymbol) { + getReferenceForShorthandProperty(referenceSymbol, search, state); + return; + } + if (state.isForConstructor) { + findConstructorReferences(referenceLocation, sourceFile, search, state); + } + else { + addReference(referenceLocation, relatedSymbol, search.location, state); + } + getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); + } + function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + var exportDeclaration = parent.parent; + var localSymbol = getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, state.checker); + if (!search.includes(localSymbol)) { + return; + } + if (!propertyName) { + addRef(); + } + else if (referenceLocation === propertyName) { + // For `export { foo as bar } from "baz"`, "`foo`" will be added from the singleReferences for import searches of the original export. + // For `export { foo as bar };`, where `foo` is a local, so add it now. + if (!exportDeclaration.moduleSpecifier) { + addRef(); } - else if (!(referenceSymbol.flags & 134217728 /* Transient */) && ts.contains(searchSymbols, shorthandValueSymbol)) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + if (!state.isForRename && state.markSeenReExportRHS(name)) { + addReference(name, referenceSymbol, name, state); } - else if (searchLocation.kind === 122 /* ConstructorKeyword */) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + else { + if (state.markSeenReExportRHS(referenceLocation)) { + addRef(); } } + // For `export { foo as bar }`, rename `foo`, but not `bar`. + if (!(referenceLocation === propertyName && state.isForRename)) { + var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; + var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); + ts.Debug.assert(!!exportInfo); + searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); + } + // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. + if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName) { + searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state); + } + function addRef() { + addReference(referenceLocation, localSymbol, search.location, state); + } } - return; - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608 /* UnionOrIntersection */) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } + function getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, checker) { + return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol; + } + function isExportSpecifierAlias(referenceLocation, exportSpecifier) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + ts.Debug.assert(propertyName === referenceLocation || name === referenceLocation); + if (propertyName) { + // Given `export { foo as bar } [from "someModule"]`: It's an alias at `foo`, but at `bar` it's a new symbol. + return propertyName === referenceLocation; + } + else { + // `export { foo } from "foo"` is a re-export. + // `export { foo };` is not a re-export, it creates an alias for the local variable `foo`. + return !parent.parent.moduleSpecifier; + } + } + function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + if (!importOrExport) + return; + var symbol = importOrExport.symbol; + if (importOrExport.kind === 0 /* Import */) { + if (!state.isForRename || importOrExport.isNamedImport) { + searchForImportedSymbol(symbol, state); } } + else { + // We don't check for `state.isForRename`, even for default exports, because importers that previously matched the export name should be updated to continue matching. + searchForImportsOfExport(referenceLocation, symbol, importOrExport.exportInfo, state); + } + } + function getReferenceForShorthandProperty(_a, search, state) { + var flags = _a.flags, valueDeclaration = _a.valueDeclaration; + var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + /* + * Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment + * has two meanings: property name and property value. Therefore when we do findAllReference at the position where + * an identifier is declared, the language service should return the position of the variable declaration as well as + * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the + * position of property accessing, the referenceEntry of such position will be handled in the first case. + */ + if (!(flags & 134217728 /* Transient */) && search.includes(shorthandValueSymbol)) { + addReference(valueDeclaration.name, shorthandValueSymbol, search.location, state); + } + } + function addReference(referenceLocation, relatedSymbol, searchLocation, state) { + var addRef = state.referenceAdder(relatedSymbol, searchLocation); + if (state.implementations) { + addImplementationReferences(referenceLocation, addRef, state); + } + else { + addRef(referenceLocation); + } } /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); + function findConstructorReferences(referenceLocation, sourceFile, search, state) { + if (ts.isNewExpressionTarget(referenceLocation)) { + addReference(referenceLocation, search.symbol, search.location, state); + } + var pusher = state.referenceAdder(search.symbol, search.location); + if (ts.isClassLike(referenceLocation.parent)) { + ts.Debug.assert(referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + findOwnConstructorReferences(search.symbol, sourceFile, pusher); } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); + if (classExtending && ts.isClassLike(classExtending)) { + findSuperConstructorAccesses(classExtending, pusher); } } } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol, searchLocation, typeChecker), - references: [] - }); + /** + * `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 152 /* Constructor */ && !!ctrKeyword); + addNode(ctrKeyword); } - return result[index]; + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 151 /* MethodDeclaration */) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + addNode(thisKeyword); + } + }); + } + } + }); } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references, typeChecker); + /** Find references to `super` in the constructor of an extending class. */ + function findSuperConstructorAccesses(cls, addNode) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return; } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol, sourceFile) { - var result = []; - for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 122 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 151 /* Constructor */ && !!ctrKeyword); - result.push(ctrKeyword); - } - classSymbol.exports.forEach(function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 150 /* MethodDeclaration */) { + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 152 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); + forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { + if (ts.isCallExpressionTarget(node)) { + addNode(node); } }); } } - }); - return result; - } - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor"); - if (!ctr) { - return []; } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 151 /* Constructor */); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); + function addImplementationReferences(refNode, addReference, state) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + addReference(refNode.parent); + return; } - } - ; - return result; - } - function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 261 /* ShorthandPropertyAssignment */) { + if (refNode.kind !== 71 /* Identifier */) { + return; + } + if (refNode.parent.kind === 262 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } // Check if the node is within an extends or implements clause var containingClass = getContainingClassIfInHeritageClause(refNode); if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); + addReference(containingClass); return; } // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { + if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { var parent = containingTypeReference.parent; if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); + addReference(parent.initializer); } else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - if (parent.body.kind === 206 /* Block */) { + if (parent.body.kind === 207 /* Block */) { ts.forEachReturnStatement(parent.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + addReference(returnStatement.expression); } }); } else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); + addReference(parent.body); } } else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); + addReference(parent.expression); } } } - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 201 /* ExpressionWithTypeArguments */ + && node.parent.kind === 259 /* HeritageClause */ + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 71 /* Identifier */ || node.kind === 179 /* PropertyAccessExpression */) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node) { + switch (node.kind) { + case 185 /* ParenthesizedExpression */: + return isImplementationExpression(node.expression); + case 187 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 178 /* ObjectLiteralExpression */: + case 199 /* ClassExpression */: + case 177 /* ArrayLiteralExpression */: + return true; + default: + return false; } } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 200 /* ExpressionWithTypeArguments */ - && node.parent.kind === 258 /* HeritageClause */ - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 /* Identifier */ || node.kind === 178 /* PropertyAccessExpression */) { - return getContainingClassIfInHeritageClause(node.parent); - } - } - return undefined; - } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node) { - switch (node.kind) { - case 184 /* ParenthesizedExpression */: - return isImplementationExpression(node.expression); - case 186 /* ArrowFunction */: - case 185 /* FunctionExpression */: - case 177 /* ObjectLiteralExpression */: - case 198 /* ClassExpression */: - case 176 /* ArrayLiteralExpression */: - return true; - default: - return false; - } - } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { - var parentIsInterface = parent.getFlags() & 64 /* Interface */; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - var cached = cachedResults.get(key); - if (cached !== undefined) { - return cached; - } - // Set the key so that we don't infinitely recurse - cachedResults.set(key, false); - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child, parent, cachedResults, checker) { + var parentIsInterface = parent.getFlags() & 64 /* Interface */; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } } } } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 229 /* InterfaceDeclaration */) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + else if (declaration.kind === 230 /* InterfaceDeclaration */) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; - }); - cachedResults.set(key, inherits); - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } } - return false; } - } - function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { - return undefined; - } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - default: + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { - var position = possiblePositions_3[_i]; - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96 /* SuperKeyword */) { - continue; } - var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - } - var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { + // Whether 'super' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - } - // fall through - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 264 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { + default: return undefined; - } - // Fall through - case 227 /* FunctionDeclaration */: - case 185 /* 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. - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 264 /* SourceFile */) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { + } + var references = []; var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: thisOrSuperKeyword.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 198 /* ClassExpression */: - case 228 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 264 /* SourceFile */: - if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - // nothing to do here. moving on - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromNode(node), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { var position = possiblePositions_4[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { - return; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97 /* SuperKeyword */) { + continue; } - var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_2 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(FindAllReferences.nodeEntry(node)); } } + return [{ definition: { type: "symbol", symbol: searchSpaceNode.symbol, node: superKeyword }, references: references }]; } - } - function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261 /* ShorthandPropertyAssignment */) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); - if (propertySymbol) { - result.push(propertySymbol); - } - } - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - /* Because in short-hand property assignment, location has two meaning : property name and as value of the property - * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * const name = "Foo"; - * const obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - // 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 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 === 145 /* Parameter */ && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); - } - } - return result; - } - /** - * 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 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 revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { - if (!symbol) { - return; - } - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (previousIterationSymbolsCache.has(symbol.name)) { - return; - } - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 229 /* InterfaceDeclaration */) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; } - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache.set(symbol.name, symbol); - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { - if (ts.contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); - } - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); - if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { - return propertySymbol; - } - } - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); - if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; - } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (ts.contains(searchSymbols, rootSymbol)) { - return rootSymbol; - } - // 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 we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { + // falls through + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 265 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); - return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); + // falls through + case 228 /* FunctionDeclaration */: + case 186 /* 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. + default: + return undefined; } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 143 /* 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)) { - return nameExpression.text; + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 265 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); } - return undefined; - } - return node.name.text; - } - /** Gets all symbols for one property. Does not get symbols for every property. */ - function getPropertySymbolsFromContextualType(node, typeChecker) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_4 = []; - var symbol = contextualType.getProperty(name); - if (symbol) { - result_4.push(symbol); + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_4.push(symbol); + return [{ + definition: { type: "this", node: thisOrSuperKeyword }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || !ts.isThis(node)) { + return; + } + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 199 /* ClassExpression */: + case 229 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 265 /* SourceFile */: + if (container.kind === 265 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; } }); } - return result_4; } - return undefined; - } - /** - * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - 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 - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. - // Remember the last meaning - lastIterationMeaning = meaning; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; + function getReferencesForStringLiteral(node, sourceFiles, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text, sourceFile.getStart(), sourceFile.getEnd()); + getReferencesForStringLiteralInFile(sourceFile, node.text, possiblePositions, references); + } + return [{ + definition: { type: "string", node: node }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchText, possiblePositions, references) { + for (var _i = 0, possiblePositions_5 = possiblePositions; _i < possiblePositions_5.length; _i++) { + var position = possiblePositions_5[_i]; + var node_7 = ts.getTouchingWord(sourceFile, position); + if (node_7 && node_7.kind === 9 /* StringLiteral */ && node_7.text === searchText) { + references.push(FindAllReferences.nodeEntry(node_7, /*isInString*/ true)); } } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - function isImplementation(node) { - if (!node) { - return false; - } - else if (ts.isVariableLike(node)) { - if (node.initializer) { - return true; - } - else if (node.kind === 225 /* VariableDeclaration */) { - var parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } } - else if (ts.isFunctionLike(node)) { - return !!node.body || ts.hasModifier(node, 2 /* Ambient */); - } - else { - switch (node.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: - return true; + // For certain symbol kinds, we need to include other symbols in the search set. + // This is not needed when searching for re-exports. + function populateSearchSymbolSet(symbol, location, checker, implementations) { + // The search set contains at least the current symbol + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement) { + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + if (containingObjectLiteralElement.kind !== 262 /* ShorthandPropertyAssignment */) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker), function (contextualSymbol) { + ts.addRange(result, checker.getRootSymbols(contextualSymbol)); + }); + /* Because in short-hand property assignment, location has two meaning : property name and as value of the property + * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * const name = "Foo"; + * const obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } } + // 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 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 === 146 /* Parameter */ && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, checker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), checker); + } + } + return result; } - return false; - } - function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 207 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 226 /* VariableDeclarationList */); - return node.parent.parent; - } - } - function getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result) { - var refSymbol = typeChecker.getSymbolAtLocation(node); - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); - if (shorthandSymbol) { - for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { - result.push(getReferenceEntryFromNode(declaration)); + /** + * 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 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 revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, checker) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 230 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = checker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, checker.getRootSymbols(propertySymbol)); + } + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, checker); + } } } } - } - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; - function getReferenceEntryFromNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { - start += 1; - end -= 1; - } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - }; - } - FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; - /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ - function isWriteAccess(node) { - if (node.kind === 70 /* Identifier */ && ts.isDeclarationName(node)) { - return true; - } - var parent = node.parent; - if (parent) { - if (parent.kind === 192 /* PostfixUnaryExpression */ || parent.kind === 191 /* PrefixUnaryExpression */) { - return true; + function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { + if (search.includes(referenceSymbol)) { + return referenceSymbol; } - else if (parent.kind === 193 /* BinaryExpression */ && parent.left === node) { - var operator = parent.operatorToken.kind; - return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, state.checker), function (contextualSymbol) { + return ts.find(state.checker.getRootSymbols(contextualSymbol), search.includes); + }); + if (contextualSymbol) { + return contextualSymbol; + } + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, state.checker); + if (propertySymbol && search.includes(propertySymbol)) { + return propertySymbol; + } + } + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); + if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { + // if it is in the list, then we are done + if (search.includes(rootSymbol)) { + return rootSymbol; + } + // 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 we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 144 /* 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)) { + return nameExpression.text; + } + return undefined; + } + return node.name.text; + } + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node, checker) { + var objectLiteral = node.parent; + var contextualType = checker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_5 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + }); + } + return result_5; + } + return undefined; + } + /** + * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + 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 + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + // Remember the last meaning + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + function isImplementation(node) { + if (!node) { + return false; + } + else if (ts.isVariableLike(node)) { + if (node.initializer) { + return true; + } + else if (node.kind === 226 /* VariableDeclaration */) { + var parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); + } + } + else if (ts.isFunctionLike(node)) { + return !!node.body || ts.hasModifier(node, 2 /* Ambient */); + } + else { + switch (node.kind) { + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: + return true; + } + } + return false; + } + function getParentStatementOfVariableDeclaration(node) { + if (node.parent && node.parent.parent && node.parent.parent.kind === 208 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 227 /* VariableDeclarationList */); + return node.parent.parent; } } - return false; - } - function forEachDescendantOfKind(node, kind, action) { - ts.forEachChild(node, function (child) { - if (child.kind === kind) { - action(child); + function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { + var refSymbol = checker.getSymbolAtLocation(node); + var shorthandSymbol = checker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + if (shorthandSymbol) { + for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + addReference(declaration); + } + } } - forEachDescendantOfKind(child, kind, action); - }); - } - /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ - function tryGetClassByExtendingIdentifier(node) { - return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9 /* StringLiteral */) { - return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); } - return false; - } - function isImportDefaultSymbol(symbol) { - return symbol.declarations[0].kind === 238 /* ImportClause */; - } + Core.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; + function forEachDescendantOfKind(node, kind, action) { + ts.forEachChild(node, function (child) { + if (child.kind === kind) { + action(child); + } + forEachDescendantOfKind(child, kind, action); + }); + } + /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ + function tryGetClassByExtendingIdentifier(node) { + return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9 /* StringLiteral */) { + return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + } + return false; + } + /** + * If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess(location, symbol, checker) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(location); + if (!propertyAccessExpression) { + return undefined; + } + var localParentType = checker.getTypeAtLocation(propertyAccessExpression.expression); + if (!localParentType) { + return undefined; + } + if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== symbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); /* @internal */ @@ -73022,9 +76508,9 @@ var ts; // (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 === 70 /* Identifier */ && + if (node.kind === 71 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 241 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 240 /* NamedImports */))) { + (declaration.kind === 242 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 241 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -73033,7 +76519,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 262 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -73093,13 +76579,13 @@ var ts; return undefined; } if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { - var result_5 = []; + var result_6 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result_5, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(/*to*/ result_6, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_5; + return result_6; } if (!type.symbol) { return undefined; @@ -73122,7 +76608,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (ts.isNewExpressionTarget(location) || location.kind === 122 /* ConstructorKeyword */) { + if (ts.isNewExpressionTarget(location) || location.kind === 123 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -73144,11 +76630,14 @@ var ts; return false; } function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + if (!signatureDeclarations) { + return false; + } var declarations = []; var definition; for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { var d = signatureDeclarations_1[_i]; - if (selectConstructors ? d.kind === 151 /* Constructor */ : isSignatureDeclaration(d)) { + if (selectConstructors ? d.kind === 152 /* Constructor */ : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; @@ -73163,10 +76652,10 @@ var ts; } function isSignatureDeclaration(node) { switch (node.kind) { - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return true; default: return false; @@ -73243,40 +76732,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var GoToImplementation; - (function (GoToImplementation) { - function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - // If invoked directly on a shorthand property assignment, then return - // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { - var result = []; - ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); - return result.length > 0 ? result : undefined; - } - else if (node.kind === 96 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { - // References to and accesses on the super keyword only have one possible implementation, so no - // need to "Find all References" - var symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; - } - else { - // Perform "Find all References" and retrieve only those that are implementations - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false, /*implementations*/ true); - var result = ts.flatMap(referencedSymbols, function (symbol) { - return ts.map(symbol.references, function (_a) { - var textSpan = _a.textSpan, fileName = _a.fileName; - return ({ textSpan: textSpan, fileName: fileName }); - }); - }); - return result && result.length > 0 ? result : undefined; - } - } - GoToImplementation.getImplementationAtPosition = getImplementationAtPosition; - })(GoToImplementation = ts.GoToImplementation || (ts.GoToImplementation = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var JsDoc; (function (JsDoc) { @@ -73322,7 +76777,8 @@ var ts; "prop", "version" ]; - var jsDocCompletionEntries; + var jsDocTagNameCompletionEntries; + var jsDocTagCompletionEntries; function getJsDocCommentsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times @@ -73349,6 +76805,30 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + // Only collect doc comments from duplicate declarations once. + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 284 /* JSDocTag */; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -73367,8 +76847,8 @@ var ts; } return undefined; } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + function getJSDocTagNameCompletions() { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, kind: ts.ScriptElementKind.keyword, @@ -73377,7 +76857,18 @@ var ts; }; })); } - JsDoc.getAllJsDocCompletionEntries = getAllJsDocCompletionEntries; + JsDoc.getJSDocTagNameCompletions = getJSDocTagNameCompletions; + function getJSDocTagCompletions() { + return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: "@" + tagName, + kind: ts.ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + JsDoc.getJSDocTagCompletions = getJSDocTagCompletions; /** * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. @@ -73416,19 +76907,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 151 /* Constructor */: - case 228 /* ClassDeclaration */: - case 207 /* VariableStatement */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: + case 229 /* ClassDeclaration */: + case 208 /* VariableStatement */: break findOwner; - case 264 /* SourceFile */: + case 265 /* SourceFile */: return undefined; - case 232 /* ModuleDeclaration */: + case 233 /* 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 === 232 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 233 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -73440,12 +76931,13 @@ var ts; var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // replace non-whitespace characters in prefix with spaces. + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 70 /* Identifier */ ? + var paramName = currentName.kind === 71 /* Identifier */ ? currentName.text : "param" + i; if (isJavaScriptFile) { @@ -73475,7 +76967,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 207 /* VariableStatement */) { + if (commentOwner.kind === 208 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -73493,17 +76985,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 184 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 185 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return rightHandSide.parameters; - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* Constructor */) { + if (member.kind === 152 /* Constructor */) { return member.parameters; } } @@ -73523,8 +77015,6 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - ; - ; // A map of loose file names to library names // that we are confident require typings var safeList; @@ -73580,8 +77070,10 @@ var ts; getTypingNamesFromJson(packageJsonPath, filesToWatch); var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components"); + getTypingNamesFromPackagesFolder(bowerComponentsPath); var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); + getTypingNamesFromPackagesFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); // add typings for unresolved imports @@ -73673,20 +77165,22 @@ var ts; } } /** - * Infer typing names from node_module folder - * @param nodeModulesPath is the path to the "node_modules" folder + * Infer typing names from packages folder (ex: node_module, bower_components) + * @param packagesFolderPath is the path to the packages folder */ - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + function getTypingNamesFromPackagesFolder(packagesFolderPath) { + filesToWatch.push(packagesFolderPath); // Todo: add support for ModuleResolutionHost too - if (!host.directoryExists(nodeModulesPath)) { + if (!host.directoryExists(packagesFolderPath)) { return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); + var fileNames = host.readDirectory(packagesFolderPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + var baseFileName = ts.getBaseFileName(normalizedFileName); + if (baseFileName !== "package.json" && baseFileName !== "bower.json") { continue; } var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); @@ -73697,7 +77191,7 @@ var ts; // npm 3's package.json contains a "_requiredBy" field // we should include all the top level module names for npm 2, and only module names whose // "_requiredBy" field starts with "#" or equals "/" for npm 3. - if (packageJson._requiredBy && + if (baseFileName === "package.json" && packageJson._requiredBy && ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { continue; } @@ -73763,14 +77257,14 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; _loop_4(sourceFile); } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 238 /* ImportClause */ || decl.kind === 241 /* ImportSpecifier */ || decl.kind === 236 /* ImportEqualsDeclaration */) { + if (decl.kind === 239 /* ImportClause */ || decl.kind === 242 /* ImportSpecifier */ || decl.kind === 237 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -73798,7 +77292,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 /* Identifier */ || + if (node.kind === 71 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -73812,7 +77306,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 143 /* ComputedPropertyName */) { + else if (declaration.name.kind === 144 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -73833,7 +77327,7 @@ var ts; } return true; } - if (expression.kind === 178 /* PropertyAccessExpression */) { + if (expression.kind === 179 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -73846,7 +77340,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 === 143 /* ComputedPropertyName */) { + if (declaration.name.kind === 144 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -73908,22 +77402,61 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { + /** + * Matches all whitespace characters in a string. Eg: + * + * "app. + * + * onactivated" + * + * matches because of the newline, whereas + * + * "app.onactivated" + * + * does not match. + */ + var whiteSpaceRegex = /\s+/g; + // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. + var curCancellationToken; + var curSourceFile; + /** + * For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. + * `parent` is the current parent and is *not* stored in parentsStack. + * `startNode` sets a new parent and `endNode` returns to the previous parent. + */ + var parentsStack = []; + var parent; + // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. + var emptyChildItemArray = []; + function getNavigationBarItems(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); - curSourceFile = undefined; - return result; + try { + return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + } + finally { + reset(); + } } NavigationBar.getNavigationBarItems = getNavigationBarItems; - function getNavigationTree(sourceFile) { + function getNavigationTree(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = convertToTree(rootNavigationBarNode(sourceFile)); - curSourceFile = undefined; - return result; + try { + return convertToTree(rootNavigationBarNode(sourceFile)); + } + finally { + reset(); + } } NavigationBar.getNavigationTree = getNavigationTree; - // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. - var curSourceFile; + function reset() { + curSourceFile = undefined; + curCancellationToken = undefined; + parentsStack = []; + parent = undefined; + emptyChildItemArray = []; + } function nodeText(node) { return node.getText(curSourceFile); } @@ -73938,13 +77471,6 @@ var ts; parent.children = [child]; } } - /* - For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. - `parent` is the current parent and is *not* stored in parentsStack. - `startNode` sets a new parent and `endNode` returns to the previous parent. - */ - var parentsStack = []; - var parent; function rootNavigationBarNode(sourceFile) { ts.Debug.assert(!parentsStack.length); var root = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; @@ -73995,11 +77521,12 @@ var ts; } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 151 /* Constructor */: + case 152 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -74011,21 +77538,21 @@ var ts; } } break; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 150 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 238 /* ImportClause */: + case 239 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -74037,7 +77564,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 239 /* NamespaceImport */) { + if (namedBindings.kind === 240 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -74048,8 +77575,8 @@ var ts; } } break; - case 175 /* BindingElement */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 226 /* VariableDeclaration */: var decl = node; var name = decl.name; if (ts.isBindingPattern(name)) { @@ -74063,12 +77590,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -74078,9 +77605,9 @@ var ts; } endNode(); break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -74088,21 +77615,21 @@ var ts; } endNode(); break; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 245 /* ExportSpecifier */: - case 236 /* ImportEqualsDeclaration */: - case 156 /* IndexSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 230 /* TypeAliasDeclaration */: + case 246 /* ExportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 157 /* IndexSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 231 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 289 /* JSDocTypedefTag */) { + if (tag.kind === 290 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -74153,14 +77680,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 232 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 233 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 232 /* ModuleDeclaration */) { + if (a.body.kind !== 233 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -74201,7 +77728,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 232 /* ModuleDeclaration */) { + if (node.kind === 233 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -74209,18 +77736,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 198 /* ClassExpression */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 199 /* ClassExpression */: return getFunctionOrClassName(node); - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 232 /* ModuleDeclaration */) { + if (node.kind === 233 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -74231,16 +77758,16 @@ var ts; } } switch (node.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -74248,15 +77775,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return "constructor"; - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: return "new()"; - case 154 /* CallSignature */: + case 155 /* CallSignature */: return "()"; - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return "[]"; - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -74268,10 +77795,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 207 /* VariableStatement */) { + if (parentNode && parentNode.kind === 208 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70 /* Identifier */) { + if (nameIdentifier.kind === 71 /* Identifier */) { return nameIdentifier.text; } } @@ -74297,24 +77824,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 231 /* EnumDeclaration */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 264 /* SourceFile */: - case 230 /* TypeAliasDeclaration */: - case 289 /* JSDocTypedefTag */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 232 /* EnumDeclaration */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 265 /* SourceFile */: + case 231 /* TypeAliasDeclaration */: + case 290 /* JSDocTypedefTag */: return true; - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 225 /* VariableDeclaration */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 226 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -74324,10 +77851,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 233 /* ModuleBlock */: - case 264 /* SourceFile */: - case 150 /* MethodDeclaration */: - case 151 /* Constructor */: + case 234 /* ModuleBlock */: + case 265 /* SourceFile */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -74336,13 +77863,11 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 225 /* VariableDeclaration */ && childKind !== 175 /* BindingElement */; + return childKind !== 226 /* VariableDeclaration */ && childKind !== 176 /* BindingElement */; }); } } } - // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. - var emptyChildItemArray = []; function convertToTree(n) { return { text: getItemName(n.node), @@ -74394,7 +77919,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 === 232 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 233 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -74405,18 +77930,18 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 232 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 233 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 143 /* ComputedPropertyName */; + return !member.name || member.name.kind === 144 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 264 /* SourceFile */ + return node.kind === 265 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 225 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 226 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -74425,14 +77950,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 225 /* VariableDeclaration */) { + else if (node.parent.kind === 226 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 193 /* BinaryExpression */ && - node.parent.operatorToken.kind === 57 /* EqualsToken */) { + else if (node.parent.kind === 194 /* BinaryExpression */ && + node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 261 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -74443,22 +77968,8 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */ || node.kind === 198 /* ClassExpression */; + return node.kind === 186 /* FunctionExpression */ || node.kind === 187 /* ArrowFunction */ || node.kind === 199 /* ClassExpression */; } - /** - * Matches all whitespace characters in a string. Eg: - * - * "app. - * - * onactivated" - * - * matches because of the newline, whereas - * - * "app.onactivated" - * - * does not match. - */ - var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -74466,29 +77977,29 @@ var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { - function collectElements(sourceFile) { + function collectElements(sourceFile, cancellationToken) { var elements = []; var collapseText = "..."; function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { if (hintSpanNode && startElement && endElement) { - var span_12 = { + var span_13 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_12); + elements.push(span_13); } } function addOutliningSpanComments(commentSpan, autoCollapse) { if (commentSpan) { - var span_13 = { + var span_14 = { textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_13); + elements.push(span_14); } } function addOutliningForLeadingCommentsForNode(n) { @@ -74500,6 +78011,7 @@ var ts; var singleLineCommentCount = 0; for (var _i = 0, comments_4 = comments; _i < comments_4.length; _i++) { var currentComment = comments_4[_i]; + cancellationToken.throwIfCancellationRequested(); // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { @@ -74525,19 +78037,20 @@ var ts; // Only outline spans of two or more consecutive single line comments if (count > 1) { var multipleSingleLineComments = { + kind: 2 /* SingleLineCommentTrivia */, pos: start, end: end, - kind: 2 /* SingleLineCommentTrivia */ }; addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 186 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 187 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; function walk(n) { + cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } @@ -74545,26 +78058,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 206 /* Block */: + case 207 /* Block */: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent.kind === 211 /* DoStatement */ || - parent.kind === 214 /* ForInStatement */ || - parent.kind === 215 /* ForOfStatement */ || - parent.kind === 213 /* ForStatement */ || - parent.kind === 210 /* IfStatement */ || - parent.kind === 212 /* WhileStatement */ || - parent.kind === 219 /* WithStatement */ || - parent.kind === 259 /* CatchClause */) { + if (parent.kind === 212 /* DoStatement */ || + parent.kind === 215 /* ForInStatement */ || + parent.kind === 216 /* ForOfStatement */ || + parent.kind === 214 /* ForStatement */ || + parent.kind === 211 /* IfStatement */ || + parent.kind === 213 /* WhileStatement */ || + parent.kind === 220 /* WithStatement */ || + parent.kind === 260 /* CatchClause */) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent.kind === 223 /* TryStatement */) { + if (parent.kind === 224 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent; if (tryStatement.tryBlock === n) { @@ -74572,7 +78085,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -74582,35 +78095,35 @@ var ts; } // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - var span_14 = ts.createTextSpanFromNode(n); + var span_15 = ts.createTextSpanFromNode(n); elements.push({ - textSpan: span_14, - hintSpan: span_14, + textSpan: span_15, + hintSpan: span_15, bannerText: collapseText, autoCollapse: autoCollapse(n) }); break; } - // Fallthrough. - case 233 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); + // falls through + case 234 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 177 /* ObjectLiteralExpression */: - case 234 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 178 /* ObjectLiteralExpression */: + case 235 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 176 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); + case 177 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 21 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -74736,10 +78249,10 @@ var ts; // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). var wordSpans = getWordSpans(candidate); for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { - var span_15 = wordSpans_1[_i]; - if (partStartsWith(candidate, span_15, chunk.text, /*ignoreCase:*/ true)) { + var span_16 = wordSpans_1[_i]; + if (partStartsWith(candidate, span_16, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span_15, chunk.text, /*ignoreCase:*/ false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span_16, chunk.text, /*ignoreCase:*/ false)); } } } @@ -75201,10 +78714,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 16 /* OpenBraceToken */) { + if (token === 17 /* OpenBraceToken */) { braceNesting++; } - else if (token === 17 /* CloseBraceToken */) { + else if (token === 18 /* CloseBraceToken */) { braceNesting--; } return token; @@ -75255,10 +78768,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 123 /* DeclareKeyword */) { + if (token === 124 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 127 /* ModuleKeyword */) { + if (token === 128 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -75273,7 +78786,7 @@ var ts; */ function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 90 /* ImportKeyword */) { + if (token === 91 /* ImportKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import "mod"; @@ -75281,9 +78794,9 @@ var ts; return true; } else { - if (token === 70 /* Identifier */ || ts.isKeyword(token)) { + if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -75291,12 +78804,12 @@ var ts; return true; } } - else if (token === 57 /* EqualsToken */) { + else if (token === 58 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 25 /* CommaToken */) { + else if (token === 26 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -75305,16 +78818,16 @@ var ts; return true; } } - if (token === 16 /* OpenBraceToken */) { + if (token === 17 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 17 /* CloseBraceToken */) { + if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -75324,13 +78837,13 @@ var ts; } } } - else if (token === 38 /* AsteriskToken */) { + else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 117 /* AsKeyword */) { + if (token === 118 /* AsKeyword */) { token = nextToken(); - if (token === 70 /* Identifier */ || ts.isKeyword(token)) { + if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -75348,19 +78861,19 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 83 /* ExportKeyword */) { + if (token === 84 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 16 /* OpenBraceToken */) { + if (token === 17 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 17 /* CloseBraceToken */) { + if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -75370,9 +78883,9 @@ var ts; } } } - else if (token === 38 /* AsteriskToken */) { + else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -75380,11 +78893,11 @@ var ts; } } } - else if (token === 90 /* ImportKeyword */) { + else if (token === 91 /* ImportKeyword */) { token = nextToken(); - if (token === 70 /* Identifier */ || ts.isKeyword(token)) { + if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 57 /* EqualsToken */) { + if (token === 58 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -75397,9 +78910,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 131 /* RequireKeyword */) { + if (token === 132 /* RequireKeyword */) { token = nextToken(); - if (token === 18 /* OpenParenToken */) { + if (token === 19 /* OpenParenToken */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // require("mod"); @@ -75412,16 +78925,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 70 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 71 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 18 /* OpenParenToken */) { + if (token !== 19 /* OpenParenToken */) { return true; } token = nextToken(); if (token === 9 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 25 /* CommaToken */) { + if (token === 26 /* CommaToken */) { token = nextToken(); } else { @@ -75430,14 +78943,14 @@ var ts; } } // should be start of dependency list - if (token !== 20 /* OpenBracketToken */) { + if (token !== 21 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); var i = 0; // scan until ']' or EOF - while (token !== 21 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); @@ -75550,20 +79063,23 @@ var ts; if (ts.some(declarations, isDefinedInLibraryFile)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + // Cannot rename `default` as in `import { default as foo } from "./someModule"; + if (node.kind === 71 /* Identifier */ && + node.originalKeywordKind === 79 /* DefaultKeyword */ && + symbol.parent.flags & 1536 /* Module */) { + return undefined; + } var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; } } else if (node.kind === 9 /* StringLiteral */) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - var displayName = ts.stripQuotes(type.text); - return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + var displayName = ts.stripQuotes(node.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -75599,7 +79115,8 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || + return node.kind === 71 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node); } @@ -75657,7 +79174,7 @@ var ts; // stack++; // break; // case TypeScript.SyntaxKind.CommaToken: - // if (stack == 0) { + // if (stack === 0) { // argumentIndex++; // } // break; @@ -75781,15 +79298,15 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 180 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 181 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 70 /* Identifier */ + var name = expression.kind === 71 /* Identifier */ ? expression - : expression.kind === 178 /* PropertyAccessExpression */ + : expression.kind === 179 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -75822,7 +79339,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 180 /* CallExpression */ || node.parent.kind === 181 /* NewExpression */) { + if (node.parent.kind === 181 /* CallExpression */ || node.parent.kind === 182 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a signature help session @@ -75838,8 +79355,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 26 /* LessThanToken */ || - node.kind === 18 /* OpenParenToken */) { + if (node.kind === 27 /* LessThanToken */ || + node.kind === 19 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -75876,27 +79393,27 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 182 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 183 /* 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, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 182 /* TaggedTemplateExpression */) { + else if (node.kind === 14 /* TemplateHead */ && node.parent.parent.kind === 183 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 196 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 204 /* TemplateSpan */ && node.parent.parent.parent.kind === 182 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 205 /* TemplateSpan */ && node.parent.parent.parent.kind === 183 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 196 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 16 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -75941,7 +79458,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 25 /* CommaToken */) { + if (child.kind !== 26 /* CommaToken */) { argumentIndex++; } } @@ -75960,8 +79477,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 26 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 26 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -75991,7 +79508,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 12 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 13 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -76029,7 +79546,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 === 195 /* TemplateExpression */) { + if (template.kind === 196 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -76038,7 +79555,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 264 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 265 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -76102,10 +79619,10 @@ var ts; var isVariadic; if (isTypeParameterList) { isVariadic = false; // type parameter lists are not variadic - prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(27 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(28 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -76117,10 +79634,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -76130,9 +79647,10 @@ var ts; isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(26 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -76182,9 +79700,9 @@ var ts; (function (SymbolDisplay) { // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { - var flags = symbol.getFlags(); + var flags = symbol.flags; if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 199 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -76194,12 +79712,12 @@ var ts; return ts.ScriptElementKind.interfaceElement; if (flags & 262144 /* TypeParameter */) return ts.ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); if (result === ts.ScriptElementKind.unknown) { if (flags & 262144 /* TypeParameter */) return ts.ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) - return ts.ScriptElementKind.variableElement; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608 /* Alias */) return ts.ScriptElementKind.alias; if (flags & 1536 /* Module */) @@ -76208,16 +79726,17 @@ var ts; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 98 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } + var flags = symbol.flags; if (flags & 3 /* Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return ts.ScriptElementKind.parameterElement; @@ -76241,7 +79760,7 @@ var ts; if (flags & 16384 /* Constructor */) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */) { + if (flags & 134217728 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); @@ -76279,10 +79798,11 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 98 /* ThisKeyword */ && ts.isExpression(location); + var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { @@ -76293,7 +79813,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 178 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 179 /* 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)) { @@ -76302,7 +79822,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpressionLike = void 0; - if (location.kind === 180 /* CallExpression */ || location.kind === 181 /* NewExpression */) { + if (location.kind === 181 /* CallExpression */ || location.kind === 182 /* NewExpression */) { callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -76318,7 +79838,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpressionLike.kind === 181 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 182 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* 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 @@ -76336,7 +79856,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93 /* NewKeyword */)); + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -76353,10 +79873,10 @@ var ts; case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(55 /* ColonToken */)); + displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93 /* NewKeyword */)); + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { @@ -76372,24 +79892,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 151 /* Constructor */)) { + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 152 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 151 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 152 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 151 /* Constructor */) { + if (functionDeclaration.kind === 152 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 155 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -76398,7 +79918,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 199 /* 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 @@ -76406,7 +79926,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(74 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(75 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -76414,45 +79934,45 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(108 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(109 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(138 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(75 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(82 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(83 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 232 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 233 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 129 /* NamespaceKeyword */ : 128 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -76463,28 +79983,28 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 144 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 145 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 155 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(93 /* NewKeyword */)); + if (declaration.kind === 156 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 154 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 155 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 230 /* TypeAliasDeclaration */) { + else if (declaration.kind === 231 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(138 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -76493,13 +80013,14 @@ var ts; } } if (symbolFlags & 8 /* EnumMember */) { + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 263 /* EnumMember */) { + if (declaration.kind === 264 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -76507,33 +80028,33 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 235 /* NamespaceExportDeclaration */) { - displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); + if (symbol.declarations[0].kind === 236 /* NamespaceExportDeclaration */) { + displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(129 /* NamespaceKeyword */)); } else { - displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(91 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 236 /* ImportEqualsDeclaration */) { + if (declaration.kind === 237 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(131 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(132 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -76547,7 +80068,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(98 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(99 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -76558,7 +80079,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(55 /* ColonToken */)); + displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -76588,14 +80109,15 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4 /* Property */) { - // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` + // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 265 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 193 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 194 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -76603,6 +80125,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -76610,7 +80133,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -76618,7 +80141,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91 /* InKeyword */)); + displayParts.push(ts.keywordPart(92 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbol, enclosingDeclaration) { @@ -76643,9 +80166,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); return; } } @@ -76653,14 +80176,15 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(36 /* PlusToken */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(37 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -76676,16 +80200,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 185 /* FunctionExpression */) { + if (declaration.kind === 186 /* FunctionExpression */) { return true; } - if (declaration.kind !== 225 /* VariableDeclaration */ && declaration.kind !== 227 /* FunctionDeclaration */) { + if (declaration.kind !== 226 /* VariableDeclaration */ && declaration.kind !== 228 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 264 /* SourceFile */ || parent.kind === 233 /* ModuleBlock */) { + if (parent.kind === 265 /* SourceFile */ || parent.kind === 234 /* ModuleBlock */) { return false; } } @@ -76790,6 +80314,7 @@ var ts; ts.transpile = transpile; var commandLineOptionsStringToEnum; /** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */ + /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { @@ -76819,6 +80344,7 @@ var ts; } return options; } + ts.fixupCompilerOptions = fixupCompilerOptions; })(ts || (ts = {})); /// /// @@ -76842,10 +80368,10 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(sourceFile, startPos, endPos) { + function getFormattingScanner(text, languageVariant, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; var leadingTrivia; @@ -76910,11 +80436,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 30 /* GreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanToken */: + case 31 /* GreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanToken */: return true; } } @@ -76923,11 +80449,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 252 /* JsxAttribute */: - case 250 /* JsxOpeningElement */: - case 251 /* JsxClosingElement */: - case 249 /* JsxSelfClosingElement */: - return node.kind === 70 /* Identifier */; + case 253 /* JsxAttribute */: + case 251 /* JsxOpeningElement */: + case 252 /* JsxClosingElement */: + case 250 /* JsxSelfClosingElement */: + return node.kind === 71 /* Identifier */; } } return false; @@ -76936,14 +80462,14 @@ var ts; return node && node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 11 /* RegularExpressionLiteral */; + return container.kind === 12 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 14 /* TemplateMiddle */ || - container.kind === 15 /* TemplateTail */; + return container.kind === 15 /* TemplateMiddle */ || + container.kind === 16 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 40 /* SlashToken */ || t === 62 /* SlashEqualsToken */; + return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -76984,7 +80510,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 28 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 29 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -76994,11 +80520,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 17 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 18 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 70 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 71 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -77047,8 +80573,8 @@ var ts; } function isOnToken() { ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } // when containing node in the tree is token @@ -77141,8 +80667,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 16 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 17 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 17 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 18 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -77330,129 +80856,129 @@ 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, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* 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, 54 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* 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(54 /* 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(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* 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, 55 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* 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(55 /* 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(55 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* 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(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 141 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 142 /* LastToken */, [20 /* CloseParenToken */])), 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(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseBraceToken */, 82 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseBraceToken */, 106 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([22 /* CloseBracketToken */, 26 /* CommaToken */, 25 /* 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, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* 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, 20 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* 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, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 3 /* MultiLineCommentTrivia */, 74 /* ClassKeyword */, 83 /* ExportKeyword */, 90 /* ImportKeyword */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([71 /* Identifier */, 3 /* MultiLineCommentTrivia */, 75 /* ClassKeyword */, 84 /* ExportKeyword */, 91 /* ImportKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([20 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 81 /* DoKeyword */, 102 /* TryKeyword */, 87 /* FinallyKeyword */, 82 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenBraceToken */, 18 /* 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(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* 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, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(44 /* 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, 43 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 44 /* 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(42 /* PlusPlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* MinusMinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 43 /* 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, 25 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103 /* VarKeyword */, 99 /* ThrowKeyword */, 93 /* NewKeyword */, 79 /* DeleteKeyword */, 95 /* ReturnKeyword */, 102 /* TypeOfKeyword */, 120 /* 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([109 /* LetKeyword */, 75 /* 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, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* 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(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* PlusPlusToken */, 37 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* PlusToken */, 37 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* PlusToken */, 43 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(44 /* MinusMinusToken */, 38 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* MinusToken */, 38 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* MinusToken */, 44 /* 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, 26 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104 /* VarKeyword */, 100 /* ThrowKeyword */, 94 /* NewKeyword */, 80 /* DeleteKeyword */, 96 /* ReturnKeyword */, 103 /* TypeOfKeyword */, 121 /* 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([110 /* LetKeyword */, 76 /* 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, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(89 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(105 /* 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(96 /* ReturnKeyword */, 25 /* 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([19 /* CloseParenToken */, 80 /* DoKeyword */, 81 /* ElseKeyword */, 72 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([20 /* CloseParenToken */, 81 /* DoKeyword */, 82 /* ElseKeyword */, 73 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, 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([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([102 /* TryKeyword */, 87 /* FinallyKeyword */]), 17 /* 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([124 /* GetKeyword */, 134 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* GetKeyword */, 135 /* SetKeyword */]), 71 /* 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.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.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123 /* ConstructorKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123 /* ConstructorKeyword */, 19 /* 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([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([128 /* ModuleKeyword */, 132 /* RequireKeyword */]), 19 /* 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([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 134 /* SetKeyword */, 114 /* StaticKeyword */, 137 /* TypeKeyword */, 139 /* FromKeyword */, 126 /* KeyOfKeyword */]), 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([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 139 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([117 /* AbstractKeyword */, 75 /* ClassKeyword */, 124 /* DeclareKeyword */, 79 /* DefaultKeyword */, 83 /* EnumKeyword */, 84 /* ExportKeyword */, 85 /* ExtendsKeyword */, 125 /* GetKeyword */, 108 /* ImplementsKeyword */, 91 /* ImportKeyword */, 109 /* InterfaceKeyword */, 128 /* ModuleKeyword */, 129 /* NamespaceKeyword */, 112 /* PrivateKeyword */, 114 /* PublicKeyword */, 113 /* ProtectedKeyword */, 131 /* ReadonlyKeyword */, 135 /* SetKeyword */, 115 /* StaticKeyword */, 138 /* TypeKeyword */, 140 /* FromKeyword */, 127 /* KeyOfKeyword */]), 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([85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 140 /* FromKeyword */])), 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 */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 17 /* 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, 35 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 36 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* 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(23 /* DotDotDotToken */, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(24 /* DotDotDotToken */, 71 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([20 /* CloseParenToken */, 26 /* 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, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* CloseParenToken */, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* 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, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([18 /* OpenParenToken */, 20 /* OpenBracketToken */, 28 /* GreaterThanToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 27 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* CloseParenToken */, 27 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* 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, 29 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(29 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([19 /* OpenParenToken */, 21 /* OpenBracketToken */, 29 /* GreaterThanToken */, 26 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenBraceToken */, 18 /* 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, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* 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([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 134 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* 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([115 /* YieldKeyword */, 38 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* 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([117 /* AbstractKeyword */, 71 /* Identifier */, 84 /* ExportKeyword */, 79 /* DefaultKeyword */, 75 /* ClassKeyword */, 115 /* StaticKeyword */, 114 /* PublicKeyword */, 112 /* PrivateKeyword */, 113 /* ProtectedKeyword */, 125 /* GetKeyword */, 135 /* SetKeyword */, 21 /* OpenBracketToken */, 39 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* FunctionKeyword */, 39 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([71 /* Identifier */, 19 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* YieldKeyword */, 39 /* 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([116 /* YieldKeyword */, 39 /* 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(119 /* AsyncKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 88 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(120 /* AsyncKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(120 /* AsyncKeyword */, 89 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70 /* Identifier */, formatting.Shared.TokenRange.FromTokens([12 /* NoSubstitutionTemplateLiteral */, 13 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(71 /* Identifier */, formatting.Shared.TokenRange.FromTokens([13 /* NoSubstitutionTemplateLiteral */, 14 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // jsx opening element - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 71 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 41 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* SlashToken */, 29 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 58 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(58 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space before non-null assertion operator - this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -77514,54 +81040,54 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 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.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, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17 /* 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(24 /* 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(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* 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(25 /* 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(18 /* 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, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* OpenParenToken */, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* 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, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* 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, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenParenToken */, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* 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, 20 /* 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(20 /* 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, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* OpenBracketToken */, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* 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, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* 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, 22 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* OpenBracketToken */, 22 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* 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, 22 /* 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([13 /* TemplateHead */, 14 /* 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([13 /* TemplateHead */, 14 /* 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([14 /* TemplateMiddle */, 15 /* 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([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([14 /* TemplateHead */, 15 /* 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([14 /* TemplateHead */, 15 /* 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([15 /* TemplateMiddle */, 16 /* 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([15 /* TemplateMiddle */, 16 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* FunctionKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* FunctionKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); // No space after type assertion - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -77576,44 +81102,44 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 213 /* ForStatement */; + return context.contextNode.kind === 214 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 193 /* BinaryExpression */: - case 194 /* ConditionalExpression */: - case 201 /* AsExpression */: - case 245 /* ExportSpecifier */: - case 241 /* ImportSpecifier */: - case 157 /* TypePredicate */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: + case 194 /* BinaryExpression */: + case 195 /* ConditionalExpression */: + case 202 /* AsExpression */: + case 246 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: + case 158 /* TypePredicate */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 175 /* BindingElement */: + case 176 /* BindingElement */: // equals in type X = ... - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: // equal in p = 0; - case 145 /* Parameter */: - case 263 /* EnumMember */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; + case 146 /* Parameter */: + case 264 /* EnumMember */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 144 /* TypeParameter */: - return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; + case 145 /* TypeParameter */: + return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 215 /* ForOfStatement */: - return context.currentTokenSpan.kind === 141 /* OfKeyword */ || context.nextTokenSpan.kind === 141 /* OfKeyword */; + case 216 /* ForOfStatement */: + return context.currentTokenSpan.kind === 142 /* OfKeyword */ || context.nextTokenSpan.kind === 142 /* OfKeyword */; } return false; }; @@ -77621,7 +81147,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 194 /* ConditionalExpression */; + return context.contextNode.kind === 195 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -77643,7 +81169,7 @@ var ts; return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 173 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 174 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { @@ -77668,70 +81194,70 @@ var ts; return true; } switch (node.kind) { - case 206 /* Block */: - case 234 /* CaseBlock */: - case 177 /* ObjectLiteralExpression */: - case 233 /* ModuleBlock */: + case 207 /* Block */: + case 235 /* CaseBlock */: + case 178 /* ObjectLiteralExpression */: + case 234 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 154 /* CallSignature */: - case 185 /* FunctionExpression */: - case 151 /* Constructor */: - case 186 /* ArrowFunction */: + case 155 /* CallSignature */: + case 186 /* FunctionExpression */: + case 152 /* Constructor */: + case 187 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 227 /* FunctionDeclaration */ || context.contextNode.kind === 185 /* FunctionExpression */; + return context.contextNode.kind === 228 /* FunctionDeclaration */ || context.contextNode.kind === 186 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 162 /* TypeLiteral */: - case 232 /* ModuleDeclaration */: - case 243 /* ExportDeclaration */: - case 244 /* NamedExports */: - case 237 /* ImportDeclaration */: - case 240 /* NamedImports */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 163 /* TypeLiteral */: + case 233 /* ModuleDeclaration */: + case 244 /* ExportDeclaration */: + case 245 /* NamedExports */: + case 238 /* ImportDeclaration */: + case 241 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 228 /* ClassDeclaration */: - case 232 /* ModuleDeclaration */: - case 231 /* EnumDeclaration */: - case 259 /* CatchClause */: - case 233 /* ModuleBlock */: - case 220 /* SwitchStatement */: + case 229 /* ClassDeclaration */: + case 233 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: + case 260 /* CatchClause */: + case 234 /* ModuleBlock */: + case 221 /* SwitchStatement */: return true; - case 206 /* Block */: { + case 207 /* Block */: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 186 /* ArrowFunction */ && - blockParent.kind !== 185 /* FunctionExpression */) { + if (blockParent.kind !== 187 /* ArrowFunction */ && + blockParent.kind !== 186 /* FunctionExpression */) { return true; } } @@ -77740,61 +81266,61 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* IfStatement */: - case 220 /* SwitchStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 212 /* WhileStatement */: - case 223 /* TryStatement */: - case 211 /* DoStatement */: - case 219 /* WithStatement */: + case 211 /* IfStatement */: + case 221 /* SwitchStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 213 /* WhileStatement */: + case 224 /* TryStatement */: + case 212 /* DoStatement */: + case 220 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 259 /* CatchClause */: + case 260 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 177 /* ObjectLiteralExpression */; + return context.contextNode.kind === 178 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 180 /* CallExpression */; + return context.contextNode.kind === 181 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 181 /* NewExpression */; + return context.contextNode.kind === 182 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 25 /* CommaToken */; + return context.currentTokenSpan.kind !== 26 /* CommaToken */; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 186 /* ArrowFunction */; + return context.contextNode.kind === 187 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 248 /* JsxElement */; + return context.contextNode.kind !== 249 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 255 /* JsxExpression */; + return context.contextNode.kind === 256 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 252 /* JsxAttribute */; + return context.nextTokenParent.kind === 253 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 252 /* JsxAttribute */; + return context.contextNode.kind === 253 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 249 /* JsxSelfClosingElement */; + return context.contextNode.kind === 250 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -77809,42 +81335,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 146 /* Decorator */; + return node.kind === 147 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 226 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 227 /* 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 === 232 /* ModuleDeclaration */; + return context.contextNode.kind === 233 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 162 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 163 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { + if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 158 /* TypeReference */: - case 183 /* TypeAssertionExpression */: - case 230 /* TypeAliasDeclaration */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 200 /* ExpressionWithTypeArguments */: + case 159 /* TypeReference */: + case 184 /* TypeAssertionExpression */: + case 231 /* TypeAliasDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 201 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -77855,16 +81381,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 183 /* TypeAssertionExpression */; + return context.contextNode.kind === 184 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 189 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 190 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 196 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 197 /* YieldExpression */ && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 202 /* NonNullExpression */; + return context.contextNode.kind === 203 /* NonNullExpression */; }; return Rules; }()); @@ -77888,7 +81414,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 141 /* LastToken */ + 1; + this.mapRowLength = 142 /* 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); @@ -77902,7 +81428,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 141 /* LastKeyword */ && column <= 141 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 142 /* LastKeyword */ && column <= 142 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -78083,7 +81609,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 141 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 142 /* LastToken */; token++) { result.push(token); } return result; @@ -78127,17 +81653,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 141 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 141 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(72 /* FirstKeyword */, 142 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([92 /* InKeyword */, 93 /* InstanceOfKeyword */, 142 /* OfKeyword */, 118 /* AsKeyword */, 126 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, 17 /* OpenBraceToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 135 /* StringKeyword */, 121 /* BooleanKeyword */, 136 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([71 /* Identifier */, 133 /* NumberKeyword */, 136 /* StringKeyword */, 122 /* BooleanKeyword */, 137 /* SymbolKeyword */, 105 /* VoidKeyword */, 119 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -78173,6 +81699,9 @@ var ts; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; + RulesProvider.prototype.getFormatOptions = function () { + return this.options; + }; RulesProvider.prototype.ensureUpToDate = function (options) { if (!this.options || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); @@ -78340,11 +81869,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 24 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 25 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 17 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 18 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -78408,17 +81937,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 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 233 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 264 /* SourceFile */: - case 206 /* Block */: - case 233 /* ModuleBlock */: + return body && body.kind === 234 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 265 /* SourceFile */: + case 207 /* Block */: + case 234 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -78438,9 +81967,9 @@ var ts; } } /** formatting is not applied to ranges that contain parse errors. - * This function will return a predicate that for a given text range will tell - * if there are any parse errors that overlap with the range. - */ + * This function will return a predicate that for a given text range will tell + * if there are any parse errors that overlap with the range. + */ function prepareRangeContainsErrorFunction(errors, originalRange) { if (!errors.length) { return rangeHasNoErrors; @@ -78478,10 +82007,10 @@ var ts; } } /** - * Start of the original range might fall inside the comment - scanner will not yield appropriate results - * This function will look for token that is located before the start of target range - * and return its end as start position for the scanner. - */ + * Start of the original range might fall inside the comment - scanner will not yield appropriate results + * This function will look for token that is located before the start of target range + * and return its end as start position for the scanner. + */ function getScanStartPosition(enclosingNode, originalRange, sourceFile) { var start = enclosingNode.getStart(sourceFile); if (start === originalRange.pos && enclosingNode.end === originalRange.end) { @@ -78531,14 +82060,21 @@ var ts; } return 0; } + /* @internal */ + function formatNode(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { + var range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + sourceFileLike); + } + formatting.formatNode = formatNode; function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - // formatting context is used by rules provider - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); // find the smallest node that fully wraps the range and compute the initial indentation for the node var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + } + function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { + // formatting context is used by rules provider + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var previousRangeHasError; var previousRange; var previousParent; @@ -78553,13 +82089,12 @@ var ts; if (enclosingNode.decorators) { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, undefined); + processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); trimTrailingWhitespacesForRemainingRange(); } } @@ -78567,12 +82102,12 @@ var ts; return edits; // local functions /** Tries to compute the indentation for a list element. - * If list element is not in range then - * function will pick its actual indentation - * so it can be pushed downstream as inherited indentation. - * If list element is in the range - its indentation will be equal - * to inherited indentation from its predecessors. - */ + * If list element is not in range then + * function will pick its actual indentation + * so it can be pushed downstream as inherited indentation. + * If list element is in the range - its indentation will be equal + * to inherited indentation from its predecessors. + */ function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { @@ -78623,20 +82158,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 228 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 229 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 227 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 231 /* EnumDeclaration */: return 231 /* EnumDeclaration */; - case 152 /* GetAccessor */: return 124 /* GetKeyword */; - case 153 /* SetAccessor */: return 134 /* SetKeyword */; - case 150 /* MethodDeclaration */: + case 229 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 230 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 228 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 232 /* EnumDeclaration */: return 232 /* EnumDeclaration */; + case 153 /* GetAccessor */: return 125 /* GetKeyword */; + case 154 /* SetAccessor */: return 135 /* SetKeyword */; + case 151 /* MethodDeclaration */: if (node.asteriskToken) { - return 38 /* AsteriskToken */; - } /* - fall-through - */ - case 148 /* PropertyDeclaration */: - case 145 /* Parameter */: + return 39 /* AsteriskToken */; + } + // falls through + case 149 /* PropertyDeclaration */: + case 146 /* Parameter */: return node.name.kind; } } @@ -78648,9 +82182,9 @@ var ts; // .. { // // comment // } - case 17 /* CloseBraceToken */: - case 21 /* CloseBracketToken */: - case 19 /* CloseParenToken */: + case 18 /* CloseBraceToken */: + case 22 /* CloseBracketToken */: + case 20 /* CloseParenToken */: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; @@ -78664,26 +82198,26 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 16 /* OpenBraceToken */: - case 17 /* CloseBraceToken */: - case 18 /* OpenParenToken */: - case 19 /* CloseParenToken */: - case 81 /* ElseKeyword */: - case 105 /* WhileKeyword */: - case 56 /* AtToken */: + case 17 /* OpenBraceToken */: + case 18 /* CloseBraceToken */: + case 19 /* OpenParenToken */: + case 20 /* CloseParenToken */: + case 82 /* ElseKeyword */: + case 106 /* WhileKeyword */: + case 57 /* AtToken */: return indentation; - case 40 /* SlashToken */: - case 28 /* GreaterThanToken */: { - if (container.kind === 250 /* JsxOpeningElement */ || - container.kind === 251 /* JsxClosingElement */ || - container.kind === 249 /* JsxSelfClosingElement */) { + case 41 /* SlashToken */: + case 29 /* GreaterThanToken */: { + if (container.kind === 251 /* JsxOpeningElement */ || + container.kind === 252 /* JsxClosingElement */ || + container.kind === 250 /* JsxSelfClosingElement */) { return indentation; } break; } - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: { - if (container.kind !== 171 /* MappedType */) { + case 21 /* OpenBracketToken */: + case 22 /* CloseBracketToken */: { + if (container.kind !== 172 /* MappedType */) { return indentation; } break; @@ -78713,7 +82247,7 @@ var ts; }; function getEffectiveDelta(delta, child) { // Delta value should be zero when the node explicitly prevents indentation of the child node - return formatting.SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0; + return formatting.SmartIndenter.nodeWillIndentChild(node, child, /*indentByDefault*/ true) ? delta : 0; } } function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { @@ -78793,11 +82327,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 146 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 147 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 176 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 177 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -79154,41 +82688,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 186 /* ArrowFunction */: + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 187 /* ArrowFunction */: if (node.typeParameters === list) { - return 26 /* LessThanToken */; + return 27 /* LessThanToken */; } else if (node.parameters === list) { - return 18 /* OpenParenToken */; + return 19 /* OpenParenToken */; } break; - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: if (node.typeArguments === list) { - return 26 /* LessThanToken */; + return 27 /* LessThanToken */; } else if (node.arguments === list) { - return 18 /* OpenParenToken */; + return 19 /* OpenParenToken */; } break; - case 158 /* TypeReference */: + case 159 /* TypeReference */: if (node.typeArguments === list) { - return 26 /* LessThanToken */; + return 27 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 18 /* OpenParenToken */: - return 19 /* CloseParenToken */; - case 26 /* LessThanToken */: - return 28 /* GreaterThanToken */; + case 19 /* OpenParenToken */: + return 20 /* CloseParenToken */; + case 27 /* LessThanToken */: + return 29 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -79256,7 +82790,20 @@ var ts; (function (Value) { Value[Value["Unknown"] = -1] = "Unknown"; })(Value || (Value = {})); - function getIndentation(position, sourceFile, options) { + /** + * Computed indentation for a given position in source file + * @param position - position in file + * @param sourceFile - target source file + * @param options - set of editor options that control indentation + * @param assumeNewLineBeforeCloseBrace - false when getIndentation is called on the text from the real source file. + * true - when we need to assume that position is on the newline. This is usefult for codefixes, i.e. + * function f() { + * |} + * when inserting some text after open brace we would like to get the value of indentation as if newline was already there. + * However by default indentation at position | will be 0 so 'assumeNewLineBeforeCloseBrace' allows to override this behavior, + */ + function getIndentation(position, sourceFile, options, assumeNewLineBeforeCloseBrace) { + if (assumeNewLineBeforeCloseBrace === void 0) { assumeNewLineBeforeCloseBrace = false; } if (position > sourceFile.text.length) { return getBaseIndentation(options); // past EOF } @@ -79284,7 +82831,7 @@ var ts; var current_1 = position; while (current_1 > 0) { var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char)) { + if (!ts.isWhiteSpaceLike(char)) { break; } current_1--; @@ -79292,7 +82839,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 193 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 194 /* 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 */) { @@ -79308,8 +82855,10 @@ var ts; while (current) { if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== 0 /* Unknown */) { + // handle cases when codefix is about to be inserted before the close brace + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; @@ -79415,22 +82964,28 @@ 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.isStatementButNotDeclaration(current)) && - (parent.kind === 264 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 265 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } + var NextTokenKind; + (function (NextTokenKind) { + NextTokenKind[NextTokenKind["Unknown"] = 0] = "Unknown"; + NextTokenKind[NextTokenKind["OpenBrace"] = 1] = "OpenBrace"; + NextTokenKind[NextTokenKind["CloseBrace"] = 2] = "CloseBrace"; + })(NextTokenKind || (NextTokenKind = {})); function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current); if (!nextToken) { - return false; + return 0 /* Unknown */; } - if (nextToken.kind === 16 /* OpenBraceToken */) { + if (nextToken.kind === 17 /* OpenBraceToken */) { // open braces are always indented at the parent level - return true; + return 1 /* OpenBrace */; } - else if (nextToken.kind === 17 /* CloseBraceToken */) { + else if (nextToken.kind === 18 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -79440,16 +82995,16 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; } - return false; + return 0 /* Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 210 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); + if (parent.kind === 211 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -79457,53 +83012,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getListIfStartEndIsInListRange(list, start, end) { + return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; + } function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 158 /* TypeReference */: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 177 /* ObjectLiteralExpression */: + case 159 /* TypeReference */: + return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd()); + case 178 /* ObjectLiteralExpression */: return node.parent.properties; - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return node.parent.elements; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 152 /* Constructor */: + case 161 /* ConstructorType */: + case 156 /* ConstructSignature */: { var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.parameters, start, node.getEnd()); } - case 181 /* NewExpression */: - case 180 /* CallExpression */: { + case 229 /* ClassDeclaration */: + return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), node.getEnd()); + case 182 /* NewExpression */: + case 181 /* CallExpression */: { var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.arguments, start, node.getEnd()); } + case 227 /* VariableDeclarationList */: + return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), node.getEnd()); + case 241 /* NamedImports */: + case 245 /* NamedExports */: + return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; } + SmartIndenter.getContainingList = getContainingList; function getActualIndentationForListItem(node, sourceFile, options) { var containingList = getContainingList(node, sourceFile); return containingList ? getActualIndentationFromList(containingList) : -1 /* Unknown */; @@ -79515,11 +83066,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 19 /* CloseParenToken */) { + if (node.kind === 20 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 180 /* CallExpression */ || - node.parent.kind === 181 /* NewExpression */) && + if (node.parent && (node.parent.kind === 181 /* CallExpression */ || + node.parent.kind === 182 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -79537,10 +83088,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: node = node.expression; break; default: @@ -79556,7 +83107,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 25 /* CommaToken */) { + if (list[i].kind === 26 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -79604,49 +83155,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 209 /* ExpressionStatement */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 176 /* ArrayLiteralExpression */: - case 206 /* Block */: - case 233 /* ModuleBlock */: - case 177 /* ObjectLiteralExpression */: - case 162 /* TypeLiteral */: - case 171 /* MappedType */: - case 164 /* TupleType */: - case 234 /* CaseBlock */: - case 257 /* DefaultClause */: - case 256 /* CaseClause */: - case 184 /* ParenthesizedExpression */: - case 178 /* PropertyAccessExpression */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 207 /* VariableStatement */: - case 225 /* VariableDeclaration */: - case 242 /* ExportAssignment */: - case 218 /* ReturnStatement */: - case 194 /* ConditionalExpression */: - case 174 /* ArrayBindingPattern */: - case 173 /* ObjectBindingPattern */: - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: - case 255 /* JsxExpression */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 145 /* Parameter */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 167 /* ParenthesizedType */: - case 182 /* TaggedTemplateExpression */: - case 190 /* AwaitExpression */: - case 244 /* NamedExports */: - case 240 /* NamedImports */: - case 245 /* ExportSpecifier */: - case 241 /* ImportSpecifier */: + case 210 /* ExpressionStatement */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 177 /* ArrayLiteralExpression */: + case 207 /* Block */: + case 234 /* ModuleBlock */: + case 178 /* ObjectLiteralExpression */: + case 163 /* TypeLiteral */: + case 172 /* MappedType */: + case 165 /* TupleType */: + case 235 /* CaseBlock */: + case 258 /* DefaultClause */: + case 257 /* CaseClause */: + case 185 /* ParenthesizedExpression */: + case 179 /* PropertyAccessExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 208 /* VariableStatement */: + case 226 /* VariableDeclaration */: + case 243 /* ExportAssignment */: + case 219 /* ReturnStatement */: + case 195 /* ConditionalExpression */: + case 175 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: + case 256 /* JsxExpression */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 146 /* Parameter */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 168 /* ParenthesizedType */: + case 183 /* TaggedTemplateExpression */: + case 191 /* AwaitExpression */: + case 245 /* NamedExports */: + case 241 /* NamedImports */: + case 246 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: return true; } return false; @@ -79655,27 +83206,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 213 /* ForStatement */: - case 210 /* IfStatement */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 186 /* ArrowFunction */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - return childKind !== 206 /* Block */; - case 243 /* ExportDeclaration */: - return childKind !== 244 /* NamedExports */; - case 237 /* ImportDeclaration */: - return childKind !== 238 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 240 /* NamedImports */); - case 248 /* JsxElement */: - return childKind !== 251 /* JsxClosingElement */; + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 214 /* ForStatement */: + case 211 /* IfStatement */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 187 /* ArrowFunction */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + return childKind !== 207 /* Block */; + case 244 /* ExportDeclaration */: + return childKind !== 245 /* NamedExports */; + case 238 /* ImportDeclaration */: + return childKind !== 239 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 241 /* NamedImports */); + case 249 /* JsxElement */: + return childKind !== 252 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -79693,6 +83244,585 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var textChanges; + (function (textChanges) { + /** + * Currently for simplicity we store recovered positions on the node itself. + * It can be changed to side-table later if we decide that current design is too invasive. + */ + function getPos(n) { + return n["__pos"]; + } + function setPos(n, pos) { + n["__pos"] = pos; + } + function getEnd(n) { + return n["__end"]; + } + function setEnd(n, end) { + n["__end"] = end; + } + var Position; + (function (Position) { + Position[Position["FullStart"] = 0] = "FullStart"; + Position[Position["Start"] = 1] = "Start"; + })(Position = textChanges.Position || (textChanges.Position = {})); + function skipWhitespacesAndLineBreaks(text, start) { + return ts.skipTrivia(text, start, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + } + function hasCommentsBeforeLineBreak(text, start) { + var i = start; + while (i < text.length) { + var ch = text.charCodeAt(i); + if (ts.isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === 47 /* slash */; + } + return false; + } + function getSeparatorCharacter(separator) { + return ts.tokenToString(separator.kind); + } + textChanges.getSeparatorCharacter = getSeparatorCharacter; + function getAdjustedStartPosition(sourceFile, node, options, position) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + var fullStart = node.getFullStart(); + var start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + var fullStartLine = ts.getLineStartPositionForPosition(fullStart, sourceFile); + var startLine = ts.getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + // full start and start of the node are on the same line + // a, b; + // ^ ^ + // | start + // fullstart + // when b is replaced - we usually want to keep the leading trvia + // when b is deleted - we delete it + return position === Position.Start ? start : fullStart; + } + // get start position of the line following the line that contains fullstart position + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // skip whitespaces/newlines + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); + return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + textChanges.getAdjustedStartPosition = getAdjustedStartPosition; + function getAdjustedEndPosition(sourceFile, node, options) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + var end = node.getEnd(); + var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); + // check if last character before newPos is linebreak + // if yes - considered all skipped trivia to be trailing trivia of the node + return newEnd !== end && ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + textChanges.getAdjustedEndPosition = getAdjustedEndPosition; + /** + * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element + */ + function isSeparator(node, candidate) { + return candidate && node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 178 /* ObjectLiteralExpression */)); + } + function spaces(count) { + var s = ""; + for (var i = 0; i < count; i++) { + s += " "; + } + return s; + } + var ChangeTracker = (function () { + function ChangeTracker(newLine, rulesProvider, validator) { + this.newLine = newLine; + this.rulesProvider = rulesProvider; + this.validator = validator; + this.changes = []; + this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); + } + ChangeTracker.fromCodeFixContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */, context.rulesProvider); + }; + ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ sourceFile: sourceFile, range: range }); + return this; + }; + ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { + var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + var nextToken = ts.getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + // find first non-whitespace position in the leading trivia of the node + var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + var nextElement = containingList[index + 1]; + /// find first non-whitespace position in the leading trivia of the next node + var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + }; + ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + return this; + }; + ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + return this; + }; + ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { + if (options === void 0) { options = {}; } + if ((ts.isStatementButNotDeclaration(after)) || + after.kind === 149 /* PropertyDeclaration */ || + after.kind === 148 /* PropertySignature */ || + after.kind === 150 /* MethodSignature */) { + // check if previous statement ends with semicolon + // if not - insert semicolon to preserve the code from changing the meaning due to ASI + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { + this.changes.push({ + sourceFile: sourceFile, + options: {}, + range: { pos: after.end, end: after.end }, + node: ts.createToken(25 /* SemicolonToken */) + }); + } + } + var endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + }; + /** + * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, + * i.e. arguments in arguments lists, parameters in parameter lists etc. + * Note that separators are part of the node in statements and class elements. + */ + ChangeTracker.prototype.insertNodeInListAfter = function (sourceFile, after, newNode) { + var containingList = ts.formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(after); + if (index < 0) { + return this; + } + var end = after.getEnd(); + if (index !== containingList.length - 1) { + // any element except the last one + // use next sibling as an anchor + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + // for list + // a, b, c + // create change for adding 'e' after 'a' as + // - find start of next element after a (it is b) + // - use this start as start and end position in final change + // - build text of change by formatting the text of node + separator + whitespace trivia of b + // in multiline case it will work as + // a, + // b, + // c, + // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') + // a,* + // ***insertedtext# + // ###b, + // c, + // find line and character of the next element + var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + // find line and character of the token that precedes next element (usually it is separator) + var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); + var prefix = void 0; + var startPos = void 0; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + // next element is located on the same line with separator: + // a,$$$$b + // ^ ^ + // | |-next element + // |-separator + // where $$$ is some leading trivia + // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces + // a, x,$$$$b + // ^ ^ ^ + // | | |-next element + // | |-new inserted node padded with spaces + // |-separator + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + // next element is located on different line that separator + // let insert position be the beginning of the line that contains next element + startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix: prefix, + // write separator and leading trivia of the next element as suffix + suffix: "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)) + } + }); + } + } + else { + var afterStart = after.getStart(sourceFile); + var afterStartLinePosition = ts.getLineStartPositionForPosition(afterStart, sourceFile); + var separator = void 0; + var multilineList = false; + // insert element after the last element in the list that has more than one item + // pick the element preceding the after element to: + // - pick the separator + // - determine if list is a multiline + if (containingList.length === 1) { + // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise + // i.e. var x = 1 // this is x + // | new element will be inserted at this position + separator = 26 /* CommaToken */; + } + else { + // element has more than one element, pick separator from the list + var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 26 /* CommaToken */; + // determine if list is multiline by checking lines of after element and element that precedes it. + var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + // in this case we'll always treat containing list as multiline + multilineList = true; + } + if (multilineList) { + // insert separator immediately following the 'after' node to preserve comments in trailing trivia + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: ts.createToken(separator), + options: {} + }); + // use the same indentation as 'after' item + var indentation = ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + // insert element before the line break on the line that contains 'after' element + var insertPos = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); + if (insertPos !== end && ts.isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos--; + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation: indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: newNode, + options: { prefix: ts.tokenToString(separator) + " " } + }); + } + } + return this; + }; + ChangeTracker.prototype.getChanges = function () { + var _this = this; + var changesPerFile = ts.createFileMap(); + // group changes per file + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var c = _a[_i]; + var changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + } + changesInFile.push(c); + } + // convert changes + var fileChangesList = []; + changesPerFile.forEachValue(function (path) { + var changesInFile = changesPerFile.get(path); + var sourceFile = changesInFile[0].sourceFile; + var fileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (var _i = 0, _a = ChangeTracker.normalize(changesInFile); _i < _a.length; _i++) { + var c = _a[_i]; + fileTextChanges.textChanges.push({ + span: _this.computeSpan(c, sourceFile), + newText: _this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + return fileChangesList; + }; + ChangeTracker.prototype.computeSpan = function (change, _sourceFile) { + return ts.createTextSpanFromBounds(change.range.pos, change.range.end); + }; + ChangeTracker.prototype.computeNewText = function (change, sourceFile) { + if (!change.node) { + // deletion case + return ""; + } + var options = change.options || {}; + var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var pos = change.range.pos; + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = change.options.indentation !== undefined + ? change.options.indentation + : change.useIndentationFromFile + ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) + : 0; + var delta = change.options.delta !== undefined + ? change.options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line + // however keep indentation if it is was forced + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); + }; + ChangeTracker.normalize = function (changes) { + // order changes by start position + var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); + // verify that change intervals do not overlap, except possibly at end points. + for (var i = 0; i < normalized.length - 2; i++) { + ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); + } + return normalized; + }; + return ChangeTracker; + }()); + textChanges.ChangeTracker = ChangeTracker; + function getNonformattedText(node, sourceFile, newLine) { + var options = { newLine: newLine, target: sourceFile.languageVersion }; + var writer = new Writer(ts.getNewLineCharacter(options)); + var printer = ts.createPrinter(options, writer); + printer.writeNode(3 /* Unspecified */, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + textChanges.getNonformattedText = getNonformattedText; + function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { + var lineMap = ts.computeLineStarts(nonFormattedText.text); + var file = { + text: nonFormattedText.text, + lineMap: lineMap, + getLineAndCharacterOfPosition: function (pos) { return ts.computeLineAndCharacterOfPosition(lineMap, pos); } + }; + var changes = ts.formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + textChanges.applyFormatting = applyFormatting; + function applyChanges(text, changes) { + for (var i = changes.length - 1; i >= 0; i--) { + var change = changes[i]; + text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + } + return text; + } + textChanges.applyChanges = applyChanges; + function isTrivia(s) { + return ts.skipTrivia(s, 0) === s.length; + } + var nullTransformationContext = { + enableEmitNotification: ts.noop, + enableSubstitution: ts.noop, + endLexicalEnvironment: function () { return undefined; }, + getCompilerOptions: ts.notImplemented, + getEmitHost: ts.notImplemented, + getEmitResolver: ts.notImplemented, + hoistFunctionDeclaration: ts.noop, + hoistVariableDeclaration: ts.noop, + isEmitNotificationEnabled: ts.notImplemented, + isSubstitutionEnabled: ts.notImplemented, + onEmitNode: ts.noop, + onSubstituteNode: ts.notImplemented, + readEmitHelpers: ts.notImplemented, + requestEmitHelper: ts.noop, + resumeLexicalEnvironment: ts.noop, + startLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop + }; + function assignPositionsToNode(node) { + var visited = ts.visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + // create proxy node for non synthesized nodes + var newNode = ts.nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new Proxy()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + function Proxy() { } + } + function assignPositionsToNodeArray(nodes, visitor, test, start, count) { + var visited = ts.visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + // clone nodearray if necessary + var nodeArray = visited === nodes ? ts.createNodeArray(visited.slice(0)) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + var Writer = (function () { + function Writer(newLine) { + var _this = this; + this.lastNonTriviaPosition = 0; + this.writer = ts.createTextWriter(newLine); + this.onEmitNode = function (hint, node, printCallback) { + if (node) { + setPos(node, _this.lastNonTriviaPosition); + } + printCallback(hint, node); + if (node) { + setEnd(node, _this.lastNonTriviaPosition); + } + }; + this.onBeforeEmitNodeArray = function (nodes) { + if (nodes) { + setPos(nodes, _this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = function (nodes) { + if (nodes) { + setEnd(nodes, _this.lastNonTriviaPosition); + } + }; + } + Writer.prototype.setLastNonTriviaPosition = function (s, force) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + var i = 0; + while (ts.isWhiteSpaceLike(s.charCodeAt(s.length - i - 1))) { + i++; + } + // trim trailing whitespaces + this.lastNonTriviaPosition -= i; + } + }; + Writer.prototype.write = function (s) { + this.writer.write(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; + Writer.prototype.writeTextOfNode = function (text, node) { + this.writer.writeTextOfNode(text, node); + }; + Writer.prototype.writeLine = function () { + this.writer.writeLine(); + }; + Writer.prototype.increaseIndent = function () { + this.writer.increaseIndent(); + }; + Writer.prototype.decreaseIndent = function () { + this.writer.decreaseIndent(); + }; + Writer.prototype.getText = function () { + return this.writer.getText(); + }; + Writer.prototype.rawWrite = function (s) { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; + Writer.prototype.writeLiteral = function (s) { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, /*force*/ true); + }; + Writer.prototype.getTextPos = function () { + return this.writer.getTextPos(); + }; + Writer.prototype.getLine = function () { + return this.writer.getLine(); + }; + Writer.prototype.getColumn = function () { + return this.writer.getColumn(); + }; + Writer.prototype.getIndent = function () { + return this.writer.getIndent(); + }; + Writer.prototype.isAtStartOfLine = function () { + return this.writer.isAtStartOfLine(); + }; + Writer.prototype.reset = function () { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + }; + return Writer; + }()); + })(textChanges = ts.textChanges || (ts.textChanges = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -79740,55 +83870,48 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); - var classDecl = ts.getContainingClass(token); - if (!classDecl) { + var classDeclaration = ts.getContainingClass(token); + if (!classDeclaration) { return undefined; } - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var classType = checker.getTypeAtLocation(classDeclaration); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDeclaration); var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); var result = []; for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { var implementedTypeNode = implementedTypeNodes_2[_i]; - var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. + var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); - var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); - insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); - insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var newNodes = []; + createAndAddMissingIndexSignatureDeclaration(implementedType, 1 /* Number */, hasNumericIndexSignature, newNodes); + createAndAddMissingIndexSignatureDeclaration(implementedType, 0 /* String */, hasStringIndexSignature, newNodes); + newNodes = newNodes.concat(codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker)); var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); - if (insertion) { - pushAction(result, insertion, message); + if (newNodes.length > 0) { + pushAction(result, newNodes, message); } } return result; - function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { - if (!hasIndexSigOfKind) { - var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); - if (IndexInfoOfKind) { - var writer = ts.getSingleLineStringWriter(); - checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_6 = writer.string(); - ts.releaseStringWriter(writer); - return result_6; - } + function createAndAddMissingIndexSignatureDeclaration(type, kind, hasIndexSigOfKind, newNodes) { + if (hasIndexSigOfKind) { + return; } - return ""; + var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (!indexInfoOfKind) { + return; + } + var newIndexSignatureDeclaration = checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration); + newNodes.push(newIndexSignatureDeclaration); } - function pushAction(result, insertion, description) { + function pushAction(result, newNodes, description) { var newAction = { description: description, - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: codefix.newNodesToChanges(newNodes, openBrace, context) }; result.push(newAction); } @@ -79797,6 +83920,117 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Property_0_does_not_exist_on_type_1.code], + getCodeActions: getActionsForAddMissingMember + }); + function getActionsForAddMissingMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier of the missing property. eg: + // this.missing = 1; + // ^^^^^^^ + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind !== 71 /* Identifier */) { + return undefined; + } + if (!ts.isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== 99 /* ThisKeyword */) { + return undefined; + } + var classMemberDeclaration = ts.getThisContainer(token, /*includeArrowFunctions*/ false); + if (!ts.isClassElement(classMemberDeclaration)) { + return undefined; + } + var classDeclaration = classMemberDeclaration.parent; + if (!classDeclaration || !ts.isClassLike(classDeclaration)) { + return undefined; + } + var isStatic = ts.hasModifier(classMemberDeclaration, 32 /* Static */); + return ts.isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + function getActionsForAddMissingMemberInJavaScriptFile() { + var memberName = token.getText(); + if (isStatic) { + if (classDeclaration.kind === 199 /* ClassExpression */) { + return undefined; + } + var className = classDeclaration.name.getText(); + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classDeclaration.getEnd(), length: 0 }, + newText: "" + context.newLineCharacter + className + "." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + else { + var classConstructor = ts.getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classConstructor.body.getEnd() - 1, length: 0 }, + newText: "this." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + } + function getActionsForAddMissingMemberInTypeScriptFile() { + var typeNode; + if (token.parent.parent.kind === 194 /* BinaryExpression */) { + var binaryExpression = token.parent.parent; + var checker = context.program.getTypeChecker(); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + } + typeNode = typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var property = ts.createProperty( + /*decorators*/ undefined, + /*modifiers*/ isStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, token.getText(sourceFile), + /*questionToken*/ undefined, typeNode, + /*initializer*/ undefined); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); + var actions = [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: propertyChangeTracker.getChanges() + }]; + if (!isStatic) { + var stringTypeNode = ts.createKeywordTypeNode(136 /* StringKeyword */); + var indexingParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "x", + /*questionToken*/ undefined, stringTypeNode, + /*initializer*/ undefined); + var indexSignature = ts.createIndexSignatureDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, [indexingParameter], typeNode); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); + actions.push({ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: indexSignatureChangeTracker.getChanges() + }); + } + return actions; + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -79816,25 +84050,19 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); if (ts.isClassLike(token.parent)) { - var classDecl = token.parent; - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var classDeclaration = token.parent; + var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); - var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); - if (insertion.length) { + var newNodes = codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); + var changes = codefix.newNodesToChanges(newNodes, ts.getOpenBraceOfClassLike(classDeclaration, sourceFile), context); + if (changes && changes.length > 0) { return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: changes }]; } } @@ -79858,7 +84086,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 98 /* ThisKeyword */) { + if (token.kind !== 99 /* ThisKeyword */) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -79866,9 +84094,9 @@ var ts; if (!superCall) { return undefined; } - // figure out if the this access is actuall inside the supercall + // figure out if the `this` access is actually inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 180 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind === 181 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -79876,23 +84104,15 @@ var ts; } } } - var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); - var changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes: changes + changes: changeTracker.getChanges() }]; function findSuperCall(n) { - if (n.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -79914,13 +84134,15 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { + if (token.kind !== 123 /* ConstructorKeyword */) { return undefined; } - var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var superCall = ts.createStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ ts.emptyArray)); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -79938,7 +84160,7 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var classDeclNode = ts.getContainingClass(token); - if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + if (!(token.kind === 71 /* Identifier */ && ts.isClassLike(classDeclNode))) { return undefined; } var heritageClauses = classDeclNode.heritageClauses; @@ -79946,27 +84168,21 @@ var ts; return undefined; } var extendsToken = heritageClauses[0].getFirstToken(); - if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + if (!(extendsToken && extendsToken.kind === 85 /* ExtendsKeyword */)) { return undefined; } - var changeStart = extendsToken.getStart(sourceFile); - var changeEnd = extendsToken.getEnd(); - var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); // We replace existing keywords with commas. for (var i = 1; i < heritageClauses.length; i++) { var keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, ts.createToken(26 /* CommaToken */)); } } var result = [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; } @@ -79983,10 +84199,14 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - var start = token.getStart(sourceFile); + if (token.kind !== 71 /* Identifier */) { + return undefined; + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -80007,165 +84227,158 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { + if (token.kind === 21 /* OpenBracketToken */) { token = ts.getTokenAtPosition(sourceFile, start + 1); } switch (token.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: switch (token.parent.kind) { - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: switch (token.parent.parent.parent.kind) { - case 213 /* ForStatement */: + case 214 /* ForStatement */: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { + if (forOfStatement.initializer.kind === 227 /* VariableDeclarationList */) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], ts.createObjectLiteral()); } break; - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: // There is no valid fix in the case of: // for .. in return undefined; - case 259 /* CatchClause */: + case 260 /* CatchClause */: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } - case 144 /* TypeParameter */: + // TODO: #14885 + // falls through + case 145 /* TypeParameter */: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== 27 /* LessThanToken */) { + return deleteRange(typeParameters); + } + var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== 29 /* GreaterThanToken */) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } - case 145 /* Parameter */: + case 146 /* Parameter */: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } // handle case where 'import a = A;' - case 236 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); - case 241 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + var importEquals = ts.getAncestor(token, 237 /* ImportEqualsDeclaration */); + return deleteNode(importEquals); + case 242 /* ImportSpecifier */: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + var importSpec = ts.getAncestor(token, 238 /* ImportDeclaration */); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); + // delete import specifier + return deleteNodeInList(token.parent); } // handle case where "import d, * as ns from './file'" // or "'import {a, b as ns} from './file'" - case 238 /* ImportClause */: + case 239 /* ImportClause */: var importClause = token.parent; if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); + var importDecl = ts.getAncestor(importClause, 238 /* ImportDeclaration */); + return deleteNode(importDecl); } else { // import |d,| * as ns from './file' - var start_4 = importClause.name.getStart(); - var end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === 44 /* comma */) { - end = findFirstNonSpaceCharPosStarting(end + 1); + var start_4 = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + return deleteRange({ pos: start_4, end: ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) }); + } + else { + return deleteNode(importClause.name); } - return createCodeFix("", start_4, end - start_4); } - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + if (namespaceImport.name === token && !namespaceImport.parent.name) { + var importDecl = ts.getAncestor(namespaceImport, 238 /* ImportDeclaration */); + return deleteNode(importDecl); } else { - var start_5 = namespaceImport.parent.name.end; - return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + var previousToken = ts.getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === 26 /* CommaToken */) { + var startPosition = ts.textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, ts.textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; - case 148 /* PropertyDeclaration */: - case 239 /* NamespaceImport */: - return createCodeFixToRemoveNode(token.parent); + case 149 /* PropertyDeclaration */: + case 240 /* NamespaceImport */: + return deleteNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 237 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; - } - return importDecl; + function deleteNode(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node) { - var end = node.getEnd(); - var endCharCode = sourceFile.text.charCodeAt(end); - var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (ts.isLineBreak(endCharCode)) { - end += 1; - } - // in the case of CR LF, you could have two consecutive new line characters for one new line. - // this needs to be differenciated from two LF LF chars that actually mean two new lines. - if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - var start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start) { - while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText, start, length) { + function deleteNodeRange(start, end) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + function replaceNode(n, newNode) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + function makeChange(changeTracker) { return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] + changes: changeTracker.getChanges() }]; } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); })(codefix = ts.codefix || (ts.codefix = {})); @@ -80208,12 +84421,13 @@ var ts; } switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) { case ModuleSpecifierComparison.Better: - // the new one is not worth considering if it is a new improt. + // the new one is not worth considering if it is a new import. // However if it is instead a insertion into existing import, the user might want to use // the module specifier even it is worse by our standards. So keep it. if (newAction.kind === "NewImport") { return; } + // falls through case ModuleSpecifierComparison.Equal: // the current one is safe. But it is still possible that the new one is worse // than another existing one. For example, you may have new imports from "./foo/bar" @@ -80287,21 +84501,21 @@ var ts; var symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map var cachedImportDeclarations = []; - var cachedNewImportInsertPosition; + var lastImportDeclaration; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); } - var allPotentialModules = checker.getAmbientModules(); + var candidateModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; if (otherSourceFile !== sourceFile && ts.isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { - var moduleSymbol = allPotentialModules_1[_a]; + for (var _a = 0, candidateModules_1 = candidateModules; _a < candidateModules_1.length; _a++) { + var moduleSymbol = candidateModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); @@ -80340,10 +84554,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 237 /* ImportDeclaration */) { + if (node.kind === 238 /* ImportDeclaration */) { return node; } - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -80389,9 +84603,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { var declaration = declarations_14[_i]; - if (declaration.kind === 237 /* ImportDeclaration */) { + if (declaration.kind === 238 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 239 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -80421,9 +84635,9 @@ var ts; * If the existing import declaration already has a named import list, just * insert the identifier into that list. */ - var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + var fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); - actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], textChange.newText, textChange.span, sourceFile.fileName, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); + actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); } else { // we need to create a new import statement, but the existing module specifier can be reused. @@ -80431,55 +84645,35 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 247 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 248 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); } function getTextChangeForImportClause(importClause) { - var newImportText = isDefault ? "default as " + name : name; var importList = importClause.namedBindings; + var newImportSpecifier = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); // case 1: // original text: import default from "module" // change to: import default, { name } from "module" - if (!importList && importClause.name) { - var start = importClause.name.getEnd(); - return { - newText: ", { " + newImportText + " }", - span: { start: start, length: 0 } - }; - } // case 2: // original text: import {} from "module" // change to: import { name } from "module" - if (importList.elements.length === 0) { - var start = importList.getStart(); - return { - newText: "{ " + newImportText + " }", - span: { start: start, length: importList.getEnd() - start } - }; + if (!importList || importList.elements.length === 0) { + var newImportClause = ts.createImportClause(importClause.name, ts.createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - // case 3: - // original text: import { foo, bar } from "module" - // change to: import { foo, bar, name } from "module" - var insertPoint = importList.elements[importList.elements.length - 1].getEnd(); /** * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element * import { * foo * } from "./module"; */ - var startLine = ts.getLineOfLocalPosition(sourceFile, importList.getStart()); - var endLine = ts.getLineOfLocalPosition(sourceFile, importList.getEnd()); - var oneImportPerLine = endLine - startLine > importList.elements.length; - return { - newText: "," + (oneImportPerLine ? context.newLineCharacter : " ") + newImportText, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter(sourceFile, importList.elements[importList.elements.length - 1], newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 237 /* ImportDeclaration */) { + if (declaration.kind === 238 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -80496,36 +84690,39 @@ var ts; * namespace instead of altering the import declaration. For example, "foo" would * become "ns.foo" */ - return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], namespacePrefix + ".", { start: token.getStart(), length: 0 }, sourceFile.fileName, "CodeChange"); + return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], createChangeTracker().replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange"); } } function getCodeActionForNewImport(moduleSpecifier) { - if (!cachedNewImportInsertPosition) { + if (!lastImportDeclaration) { // insert after any existing imports - var lastModuleSpecifierEnd = -1; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var moduleSpecifier_1 = _a[_i]; - var end = moduleSpecifier_1.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + for (var i = sourceFile.statements.length - 1; i >= 0; i--) { + var statement = sourceFile.statements[i]; + if (statement.kind === 237 /* ImportEqualsDeclaration */ || statement.kind === 238 /* ImportDeclaration */) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - var importStatementText = isDefault - ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + var changeTracker = createChangeTracker(); + var importClause = isDefault + ? ts.createImportClause(ts.createIdentifier(name), /*namedBindings*/ undefined) : isNamespaceImport - ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + ? ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(name))) + : ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name))])); + var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. - var newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter - : "" + context.newLineCharacter + importStatementText + ";"; - return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); + return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -80538,7 +84735,7 @@ var ts; tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 264 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 265 /* SourceFile */) { return moduleSymbol.name; } } @@ -80660,19 +84857,22 @@ var ts; return fileName; } function getRelativePathIfInDirectory(path, directoryPath) { - var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; } function getRelativePath(path, directoryPath) { - var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } } } - function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { + function createChangeTracker() { + return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + } + function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { description: ts.formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName: fileName, textChanges: [{ newText: newText, span: span }] }], + changes: changes, kind: kind, moduleSpecifier: moduleSpecifier }; @@ -80686,45 +84886,147 @@ var ts; (function (ts) { var codefix; (function (codefix) { + codefix.registerCodeFix({ + errorCodes: getApplicableDiagnosticCodes(), + getCodeActions: getDisableJsDiagnosticsCodeActions + }); + function getApplicableDiagnosticCodes() { + var allDiagnostcs = ts.Diagnostics; + return Object.keys(allDiagnostcs) + .filter(function (d) { return allDiagnostcs[d] && allDiagnostcs[d].category === ts.DiagnosticCategory.Error; }) + .map(function (d) { return allDiagnostcs[d].code; }); + } + function getIgnoreCommentLocationForLocation(sourceFile, position, newLineCharacter) { + var line = ts.getLineAndCharacterOfPosition(sourceFile, position).line; + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var startPosition = ts.getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + // First try to see if we can put the '// @ts-ignore' on the previous line. + // We need to make sure that we are not in the middle of a string literal or a comment. + // We also want to check if the previous line holds a comment for a node on the next line + // if so, we do not want to separate the node from its comment if we can. + if (!ts.isInComment(sourceFile, startPosition) && !ts.isInString(sourceFile, startPosition) && !ts.isInTemplateString(sourceFile, startPosition)) { + var token = ts.getTouchingToken(sourceFile, startPosition); + var tokenLeadingCommnets = ts.getLeadingCommentRangesOfNode(token, sourceFile); + if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { + return { + span: { start: startPosition, length: 0 }, + newText: "// @ts-ignore" + newLineCharacter + }; + } + } + // If all fails, add an extra new line immediatlly before the error span. + return { + span: { start: position, length: 0 }, + newText: (position === startPosition ? "" : newLineCharacter) + "// @ts-ignore" + newLineCharacter + }; + } + function getDisableJsDiagnosticsCodeActions(context) { + var sourceFile = context.sourceFile, program = context.program, newLineCharacter = context.newLineCharacter, span = context.span; + if (!ts.isInJavaScriptFile(sourceFile) || !ts.isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { + return undefined; + } + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Ignore_this_error_message), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + }] + }, + { + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Disable_checking_for_this_file), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { + start: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.pos : 0, + length: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.end - sourceFile.checkJsDirective.pos : 0 + }, + newText: "// @ts-nocheck" + newLineCharacter + }] + }] + }]; + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function newNodesToChanges(newNodes, insertAfter, context) { + var sourceFile = context.sourceFile; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { + var newNode = newNodes_1[_i]; + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); + } + var changes = changeTracker.getChanges(); + if (!ts.some(changes)) { + return changes; + } + ts.Debug.assert(changes.length === 1); + var consolidatedChanges = [{ + fileName: changes[0].fileName, + textChanges: [{ + span: changes[0].textChanges[0].span, + newText: changes[0].textChanges.reduce(function (prev, cur) { return prev + cur.newText; }, "") + }] + }]; + return consolidatedChanges; + } + codefix.newNodesToChanges = newNodesToChanges; /** * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. * @returns Empty string iff there are no member insertions. */ - function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, checker) { var classMembers = classDeclaration.symbol.members; var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); - var insertion = ""; + var newNodes = []; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; - insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + var newNode = createNewNodeForMemberSymbol(symbol, classDeclaration, checker); + if (newNode) { + if (Array.isArray(newNode)) { + newNodes = newNodes.concat(newNode); + } + else { + newNodes.push(newNode); + } + } } - return insertion; + return newNodes; } - codefix.getMissingMembersInsertion = getMissingMembersInsertion; + codefix.createMissingMemberNodes = createMissingMemberNodes; /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { - // const name = symbol.getName(); - var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + function createNewNodeForMemberSymbol(symbol, enclosingDeclaration, checker) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { - return ""; + return undefined; } var declaration = declarations[0]; - var name = declaration.name ? declaration.name.getText() : undefined; - var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + // Clone name to remove leading trivia. + var name = ts.getSynthesizedClone(declaration.name); + var visibilityModifier = createVisibilityModifier(ts.getModifierFlags(declaration)); + var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; + var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); + var optional = !!(symbol.flags & 67108864 /* Optional */); switch (declaration.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 147 /* PropertySignature */: - case 148 /* PropertyDeclaration */: - var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); - return "" + visibility + name + ": " + typeString + ";" + newlineChar; - case 149 /* MethodSignature */: - case 150 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 148 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); + var property = ts.createProperty( + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, + /*initializer*/ undefined); + return property; + case 150 /* MethodSignature */: + case 151 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -80733,95 +85035,118 @@ var ts; // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. var signatures = checker.getSignaturesOfType(type, 0 /* Call */); - if (!(signatures && signatures.length > 0)) { - return ""; + if (!ts.some(signatures)) { + return undefined; } if (declarations.length === 1) { ts.Debug.assert(signatures.length === 1); - var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); - return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + var signature = signatures[0]; + return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - var result = ""; + var signatureDeclarations = []; for (var i = 0; i < signatures.length; i++) { - var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); - result += "" + visibility + name + sigString_2 + ";" + newlineChar; + var signature = signatures[i]; + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } - // If there is a declaration with a body, it is the last declaration, - // and it isn't caught by `getSignaturesOfType`. - var bodySig = undefined; if (declarations.length > signatures.length) { - bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } else { ts.Debug.assert(declarations.length === signatures.length); - bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + var methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, optional, modifiers); + signatureDeclarations.push(methodImplementingSignatures); } - var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); - result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); - return result; + return signatureDeclarations; default: - return ""; + return undefined; + } + function signatureToMethodDeclaration(signature, enclosingDeclaration, body) { + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 151 /* MethodDeclaration */, enclosingDeclaration); + if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? ts.createToken(55 /* QuestionToken */) : undefined; + signatureDeclaration.body = body; + } + return signatureDeclaration; } } - function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(154 /* CallSignature */); - newSignatureDeclaration.parent = enclosingDeclaration; - newSignatureDeclaration.name = signatures[0].getDeclaration().name; - var maxNonRestArgs = -1; - var maxArgsIndex = 0; + function createMethodImplementingSignatures(signatures, name, optional, modifiers) { + /** This is *a* signature with the maximal number of arguments, + * such that if there is a "maximal" signature without rest arguments, + * this is one of them. + */ + var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; - var hasRestParameter = false; + var someSigHasRestParameter = false; for (var i = 0; i < signatures.length; i++) { var sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - hasRestParameter = hasRestParameter || sig.hasRestParameter; - var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength > maxNonRestArgs) { - maxNonRestArgs = nonRestLength; - maxArgsIndex = i; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + maxArgsSignature = sig; } } - var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); - var optionalToken = ts.createToken(54 /* QuestionToken */); - newSignatureDeclaration.parameters = ts.createNodeArray(); + var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.getName(); }); + var parameters = []; for (var i = 0; i < maxNonRestArgs; i++) { - var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); - newSignatureDeclaration.parameters.push(newParameter); + var anyType = ts.createKeywordTypeNode(119 /* AnyKeyword */); + var newParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, maxArgsParameterSymbolNames[i], + /*questionToken*/ i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyType, + /*initializer*/ undefined); + parameters.push(newParameter); } - if (hasRestParameter) { - var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); - restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); - newSignatureDeclaration.parameters.push(restParameter); - } - return checker.getSignatureFromDeclaration(newSignatureDeclaration); - function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(145 /* Parameter */); - newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); - newParameter.symbol.valueDeclaration = newParameter; - newParameter.symbol.declarations = [newParameter]; - newParameter.parent = enclosingSignatureDeclaration; - if (index >= minArgCount) { - newParameter.questionToken = optionalToken; - } - return newParameter; + if (someSigHasRestParameter) { + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); + var restParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyArrayType, + /*initializer*/ undefined); + parameters.push(restParameter); } + return createStubbedMethod(modifiers, name, optional, + /*typeParameters*/ undefined, parameters, + /*returnType*/ undefined); } - function getMethodBodyStub(newLineChar) { - return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType) { + return ts.createMethodDeclaration( + /*decorators*/ undefined, modifiers, + /*asteriskToken*/ undefined, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody()); } - function getVisibilityPrefix(flags) { + codefix.createStubbedMethod = createStubbedMethod; + function createStubbedMethodBody() { + return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), + /*typeArguments*/ undefined, [ts.createLiteral("Method not implemented.")]))], + /*multiline*/ true); + } + function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return "public "; + return ts.createToken(114 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return "protected "; + return ts.createToken(113 /* ProtectedKeyword */); } - return ""; + return undefined; } - var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /// +/// /// /// /// @@ -80829,6 +85154,7 @@ var ts; /// /// /// +/// /// /// /// @@ -80841,7 +85167,6 @@ var ts; /// /// /// -/// /// /// /// @@ -80855,6 +85180,7 @@ var ts; /// /// /// +/// /// /// var ts; @@ -80862,8 +85188,8 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 142 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : + var node = kind >= 143 /* FirstNode */ ? new NodeObject(kind, pos, end) : + kind === 71 /* Identifier */ ? new IdentifierObject(71 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -80920,11 +85246,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(294 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { - var node = nodes_7[_i]; + for (var _i = 0, nodes_9 = nodes; _i < nodes_9.length; _i++) { + var node = nodes_9[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -80939,11 +85265,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 142 /* FirstNode */) { + if (this.kind >= 143 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 282 /* FirstJSDocTagNode */ && this.kind <= 295 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 283 /* FirstJSDocTagNode */ && this.kind <= 293 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -81000,8 +85326,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 266 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; }); - return child.kind < 142 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 267 /* FirstJSDocNode */ || kid.kind > 293 /* LastJSDocNode */; }); + return child.kind < 143 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -81011,7 +85337,10 @@ var ts; if (!child) { return undefined; } - return child.kind < 142 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 143 /* FirstNode */ ? child : child.getLastToken(sourceFile); + }; + NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { + return ts.forEachChild(this, cbNode, cbNodeArray); }; return NodeObject; }()); @@ -81065,6 +85394,9 @@ var ts; TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; + TokenOrIdentifierObject.prototype.forEachChild = function () { + return undefined; + }; return TokenOrIdentifierObject; }()); var SymbolObject = (function () { @@ -81087,6 +85419,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -81105,7 +85443,7 @@ var ts; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 70 /* Identifier */; + IdentifierObject.prototype.kind = 71 /* Identifier */; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -81170,6 +85508,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -81232,9 +85576,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 143 /* ComputedPropertyName */) { + if (declaration.name.kind === 144 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 178 /* PropertyAccessExpression */) { + if (expr.kind === 179 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -81244,7 +85588,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 /* Identifier */ || + if (node.kind === 71 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -81254,10 +85598,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -81277,32 +85621,32 @@ var ts; } ts.forEachChild(node, visit); break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 245 /* ExportSpecifier */: - case 241 /* ImportSpecifier */: - case 236 /* ImportEqualsDeclaration */: - case 238 /* ImportClause */: - case 239 /* NamespaceImport */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 162 /* TypeLiteral */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 246 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 163 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 145 /* Parameter */: + case 146 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } - // fall through - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: { + // falls through + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -81311,19 +85655,20 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 263 /* EnumMember */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + // falls through + case 264 /* EnumMember */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: addDeclaration(node); break; - case 243 /* ExportDeclaration */: + case 244 /* 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 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -81335,7 +85680,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 240 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -81584,6 +85929,36 @@ var ts; }; return CancellationTokenObject; }()); + /* @internal */ + /** A cancellation that throttles calls to the host */ + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken, throttleWaitMilliseconds) { + if (throttleWaitMilliseconds === void 0) { throttleWaitMilliseconds = 20; } + this.hostCancellationToken = hostCancellationToken; + this.throttleWaitMilliseconds = throttleWaitMilliseconds; + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + // Check no more than once every throttle wait milliseconds + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return ThrottledCancellationToken; + }()); + ts.ThrottledCancellationToken = ThrottledCancellationToken; function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -81865,12 +86240,12 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { - case 70 /* Identifier */: - case 178 /* PropertyAccessExpression */: - case 142 /* QualifiedName */: - case 98 /* ThisKeyword */: - case 168 /* ThisType */: - case 96 /* SuperKeyword */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: + case 143 /* QualifiedName */: + case 99 /* ThisKeyword */: + case 169 /* ThisType */: + case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -81879,7 +86254,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -81891,7 +86267,8 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } /// Goto definition @@ -81899,15 +86276,16 @@ var ts; synchronizeHostData(); return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } - /// Goto implementation - function getImplementationAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); - } function getTypeDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); } + /// Goto implementation + function getImplementationAtPosition(fileName, position) { + synchronizeHostData(); + return ts.FindAllReferences.getImplementationsAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); + } + /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { @@ -81924,9 +86302,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program.getTypeChecker(), cancellationToken, sourceFile, position, sourceFilesToSearch); } - /// References and Occurrences function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); function convertDocumentHighlights(documentHighlights) { if (!documentHighlights) { @@ -81941,7 +86317,8 @@ var ts; fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, - isDefinition: false + isDefinition: false, + isInString: highlightSpan.isInString, }); } } @@ -81949,21 +86326,18 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/ true); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position); + } + function getReferences(fileName, position, options) { + synchronizeHostData(); + return ts.FindAllReferences.findReferencedEntries(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); - // Only include referenced symbols that have a valid definition. - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { @@ -81982,7 +86356,8 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); + var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -82012,16 +86387,16 @@ var ts; return; } switch (node.kind) { - case 178 /* PropertyAccessExpression */: - case 142 /* QualifiedName */: + case 179 /* PropertyAccessExpression */: + case 143 /* QualifiedName */: case 9 /* StringLiteral */: - case 85 /* FalseKeyword */: - case 100 /* TrueKeyword */: - case 94 /* NullKeyword */: - case 96 /* SuperKeyword */: - case 98 /* ThisKeyword */: - case 168 /* ThisType */: - case 70 /* Identifier */: + case 86 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 95 /* NullKeyword */: + case 97 /* SuperKeyword */: + case 99 /* ThisKeyword */: + case 169 /* ThisType */: + case 71 /* Identifier */: break; // Cant create the text span default: @@ -82037,7 +86412,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 === 232 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 233 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -82060,10 +86435,10 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName) { - return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName) { var kind = ts.getScriptKind(fileName, host); @@ -82096,7 +86471,7 @@ var ts; function getOutliningSpans(fileName) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); + return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -82128,14 +86503,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 16 /* OpenBraceToken */: return 17 /* CloseBraceToken */; - case 18 /* OpenParenToken */: return 19 /* CloseParenToken */; - case 20 /* OpenBracketToken */: return 21 /* CloseBracketToken */; - case 26 /* LessThanToken */: return 28 /* GreaterThanToken */; - case 17 /* CloseBraceToken */: return 16 /* OpenBraceToken */; - case 19 /* CloseParenToken */: return 18 /* OpenParenToken */; - case 21 /* CloseBracketToken */: return 20 /* OpenBracketToken */; - case 28 /* GreaterThanToken */: return 26 /* LessThanToken */; + case 17 /* OpenBraceToken */: return 18 /* CloseBraceToken */; + case 19 /* OpenParenToken */: return 20 /* CloseParenToken */; + case 21 /* OpenBracketToken */: return 22 /* CloseBracketToken */; + case 27 /* LessThanToken */: return 29 /* GreaterThanToken */; + case 18 /* CloseBraceToken */: return 17 /* OpenBraceToken */; + case 20 /* CloseParenToken */: return 19 /* OpenParenToken */; + case 22 /* CloseBracketToken */: return 21 /* OpenBracketToken */; + case 29 /* GreaterThanToken */: return 27 /* LessThanToken */; } return undefined; } @@ -82174,7 +86549,7 @@ var ts; } return []; } - function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = { start: start, length: end - start }; @@ -82189,7 +86564,8 @@ var ts; program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; var fixes = ts.codefix.getFixes(context); if (fixes) { @@ -82400,6 +86776,7 @@ var ts; } ts.createLanguageService = createLanguageService; /* @internal */ + /** Names in the name table are escaped, so an identifier `__foo` will have a name table entry `___foo`. */ function getNameTable(sourceFile) { if (!sourceFile.nameTable) { initializeNameTable(sourceFile); @@ -82413,7 +86790,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: setNameTable(node.text, node); break; case 9 /* StringLiteral */: @@ -82423,7 +86800,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 247 /* ExternalModuleReference */ || + node.parent.kind === 248 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { setNameTable(node.text, node); @@ -82445,13 +86822,13 @@ var ts; } function isObjectLiteralElement(node) { switch (node.kind) { - case 252 /* JsxAttribute */: - case 254 /* JsxSpreadAttribute */: - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 253 /* JsxAttribute */: + case 255 /* JsxSpreadAttribute */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return true; } return false; @@ -82464,13 +86841,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 143 /* ComputedPropertyName */) { + if (node.parent.kind === 144 /* ComputedPropertyName */) { return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } - // intentionally fall through - case 70 /* Identifier */: + // falls through + case 71 /* Identifier */: return isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 177 /* ObjectLiteralExpression */ || node.parent.parent.kind === 253 /* JsxAttributes */) && + (node.parent.parent.kind === 178 /* ObjectLiteralExpression */ || node.parent.parent.kind === 254 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -82504,14 +86881,14 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 179 /* ElementAccessExpression */ && + node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ function getDefaultLibFilePath(options) { // Check __dirname is defined and that we are on a node.js system. if (typeof __dirname !== "undefined") { @@ -82585,143 +86962,144 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 225 /* VariableDeclaration */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 226 /* VariableDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return spanInVariableDeclaration(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return spanInParameterDeclaration(node); - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 151 /* Constructor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 152 /* Constructor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 206 /* Block */: + case 207 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - // Fall through - case 233 /* ModuleBlock */: + // falls through + case 234 /* ModuleBlock */: return spanInBlock(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return spanInBlock(node.block); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 211 /* DoStatement */: + case 212 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 224 /* DebuggerStatement */: + case 225 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 210 /* IfStatement */: + case 211 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return spanInForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 256 /* CaseClause */: - case 257 /* DefaultClause */: + case 257 /* CaseClause */: + case 258 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 223 /* TryStatement */: + case 224 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 263 /* EnumMember */: - case 175 /* BindingElement */: + // falls through + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 264 /* EnumMember */: + case 176 /* BindingElement */: // span on complete node return textSpan(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 146 /* Decorator */: + case 147 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 24 /* SemicolonToken */: + case 25 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return spanInPreviousNode(node); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 17 /* CloseBraceToken */: + case 18 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 21 /* CloseBracketToken */: + case 22 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return spanInOpenParenToken(node); - case 19 /* CloseParenToken */: + case 20 /* CloseParenToken */: return spanInCloseParenToken(node); - case 55 /* ColonToken */: + case 56 /* ColonToken */: return spanInColonToken(node); - case 28 /* GreaterThanToken */: - case 26 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 27 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 105 /* WhileKeyword */: + case 106 /* WhileKeyword */: return spanInWhileKeyword(node); - case 81 /* ElseKeyword */: - case 73 /* CatchKeyword */: - case 86 /* FinallyKeyword */: + case 82 /* ElseKeyword */: + case 74 /* CatchKeyword */: + case 87 /* FinallyKeyword */: return spanInNextNode(node); - case 141 /* OfKeyword */: + case 142 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -82733,14 +87111,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern - if ((node.kind === 70 /* Identifier */ || - node.kind == 197 /* SpreadElement */ || - node.kind === 260 /* PropertyAssignment */ || - node.kind === 261 /* ShorthandPropertyAssignment */) && + if ((node.kind === 71 /* Identifier */ || + node.kind === 198 /* SpreadElement */ || + node.kind === 261 /* PropertyAssignment */ || + node.kind === 262 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 193 /* BinaryExpression */) { + if (node.kind === 194 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -82749,7 +87127,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 57 /* EqualsToken */ && + if (binaryExpression.operatorToken.kind === 58 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of @@ -82757,28 +87135,28 @@ var ts; // { a = expression, b, c } = someExpression return textSpan(node); } - if (binaryExpression.operatorToken.kind === 25 /* CommaToken */) { + if (binaryExpression.operatorToken.kind === 26 /* CommaToken */) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 211 /* DoStatement */: + case 212 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 146 /* Decorator */: + case 147 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 213 /* ForStatement */: - case 215 /* ForOfStatement */: + case 214 /* ForStatement */: + case 216 /* ForOfStatement */: return textSpan(node); - case 193 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 25 /* CommaToken */) { + case 194 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -82787,13 +87165,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 260 /* PropertyAssignment */ && + if (node.parent.kind === 261 /* 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 === 183 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 184 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -82801,8 +87179,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 225 /* VariableDeclaration */ || - node.parent.kind === 145 /* Parameter */)) { + if ((node.parent.kind === 226 /* VariableDeclaration */ || + node.parent.kind === 146 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -82810,7 +87188,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 193 /* BinaryExpression */) { + if (node.parent.kind === 194 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -82824,8 +87202,8 @@ var ts; } } function textSpanFromVariableDeclaration(variableDeclaration) { - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { + if (variableDeclaration.parent.kind === 227 /* VariableDeclarationList */ && + variableDeclaration.parent.declarations[0] === variableDeclaration) { // First declaration - include let keyword return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); } @@ -82836,7 +87214,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 214 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 215 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -82847,11 +87225,11 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 215 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 216 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { + if (variableDeclaration.parent.kind === 227 /* VariableDeclarationList */ && + variableDeclaration.parent.declarations[0] !== variableDeclaration) { // If we cannot set breakpoint on this declaration, set it on previous one // Because the variable declaration may be binding pattern and // we would like to set breakpoint in last binding element if that's the case, @@ -82887,7 +87265,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 228 /* ClassDeclaration */ && functionDeclaration.kind !== 151 /* Constructor */); + (functionDeclaration.parent.kind === 229 /* ClassDeclaration */ && functionDeclaration.kind !== 152 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -82910,25 +87288,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } + // falls through // Set on parent if on same line otherwise on first statement - case 212 /* WhileStatement */: - case 210 /* IfStatement */: - case 214 /* ForInStatement */: + case 213 /* WhileStatement */: + case 211 /* IfStatement */: + case 215 /* 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 213 /* ForStatement */: - case 215 /* ForOfStatement */: + case 214 /* ForStatement */: + case 216 /* 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(forLikeStatement) { - if (forLikeStatement.initializer.kind === 226 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 227 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -82953,23 +87332,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 200 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 175 /* BindingElement */) { + if (bindingPattern.parent.kind === 176 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 174 /* ArrayBindingPattern */ && node.kind !== 173 /* ObjectBindingPattern */); - var elements = node.kind === 176 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 175 /* ArrayBindingPattern */ && node.kind !== 174 /* ObjectBindingPattern */); + var elements = node.kind === 177 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 200 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -82977,18 +87356,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 === 193 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 194 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -82996,24 +87375,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 231 /* EnumDeclaration */: - case 228 /* ClassDeclaration */: + // falls through + case 232 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 206 /* Block */: + case 207 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } - // fall through - case 259 /* CatchClause */: + // falls through + case 260 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -83021,7 +87401,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 173 /* ObjectBindingPattern */: + case 174 /* 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); @@ -83037,7 +87417,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 174 /* ArrayBindingPattern */: + case 175 /* 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); @@ -83052,12 +87432,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 211 /* DoStatement */ || - node.parent.kind === 180 /* CallExpression */ || - node.parent.kind === 181 /* NewExpression */) { + if (node.parent.kind === 212 /* DoStatement */ || + node.parent.kind === 181 /* CallExpression */ || + node.parent.kind === 182 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 184 /* ParenthesizedExpression */) { + if (node.parent.kind === 185 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -83066,21 +87446,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 151 /* Constructor */: - case 212 /* WhileStatement */: - case 211 /* DoStatement */: - case 213 /* ForStatement */: - case 215 /* ForOfStatement */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 184 /* ParenthesizedExpression */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 152 /* Constructor */: + case 213 /* WhileStatement */: + case 212 /* DoStatement */: + case 214 /* ForStatement */: + case 216 /* ForOfStatement */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 185 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -83090,20 +87470,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 260 /* PropertyAssignment */ || - node.parent.kind === 145 /* Parameter */) { + node.parent.kind === 261 /* PropertyAssignment */ || + node.parent.kind === 146 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 183 /* TypeAssertionExpression */) { + if (node.parent.kind === 184 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 211 /* DoStatement */) { + if (node.parent.kind === 212 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -83111,7 +87491,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 215 /* ForOfStatement */) { + if (node.parent.kind === 216 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -83123,6 +87503,26 @@ var ts; BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); })(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + /** + * Transform one or more nodes using the supplied transformers. + * @param source A single `Node` or an array of `Node` objects. + * @param transformers An array of `TransformerFactory` callbacks used to process the transformation. + * @param compilerOptions Optional compiler options. + */ + function transform(source, transformers, compilerOptions) { + var diagnostics = []; + compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); + var nodes = ts.isArray(source) ? source : [source]; + var result = ts.transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true); + result.diagnostics = ts.concatenate(result.diagnostics, diagnostics); + return result; + } + ts.transform = transform; +})(ts || (ts = {})); // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -83164,8 +87564,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - // TODO: should this be '==='? - if (encoded == null) { + if (encoded === null) { return null; } var decoded = JSON.parse(encoded); @@ -83238,8 +87637,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); - // TODO: should this be '==='? - if (settingsJson == null || settingsJson == "") { + if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } var compilerOptions = JSON.parse(settingsJson); @@ -83268,7 +87666,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; } try { @@ -83281,7 +87679,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); + return new ts.ThrottledCancellationToken(hostCancellationToken); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -83305,27 +87703,6 @@ var ts; return LanguageServiceShimHostAdapter; }()); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - /** A cancellation that throttles calls to the host */ - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); var CoreServicesShimHostAdapter = (function () { function CoreServicesShimHostAdapter(shimHost) { var _this = this; @@ -83926,4 +88303,4 @@ 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 = "2.3"; +var toolsVersion = "2.4"; diff --git a/lib/typescriptServices.d.ts b/lib/typescriptServices.d.ts index 1be69fb2455..01d5540db54 100644 --- a/lib/typescriptServices.d.ts +++ b/lib/typescriptServices.d.ts @@ -24,7 +24,7 @@ declare namespace ts { } /** ES6 Map interface. */ interface Map { - get(key: string): T; + get(key: string): T | undefined; has(key: string): boolean; set(key: string, value: T): this; delete(key: string): boolean; @@ -73,326 +73,324 @@ declare namespace ts { NumericLiteral = 8, StringLiteral = 9, JsxText = 10, - RegularExpressionLiteral = 11, - NoSubstitutionTemplateLiteral = 12, - TemplateHead = 13, - TemplateMiddle = 14, - TemplateTail = 15, - OpenBraceToken = 16, - CloseBraceToken = 17, - OpenParenToken = 18, - CloseParenToken = 19, - OpenBracketToken = 20, - CloseBracketToken = 21, - DotToken = 22, - DotDotDotToken = 23, - SemicolonToken = 24, - CommaToken = 25, - LessThanToken = 26, - LessThanSlashToken = 27, - GreaterThanToken = 28, - LessThanEqualsToken = 29, - GreaterThanEqualsToken = 30, - EqualsEqualsToken = 31, - ExclamationEqualsToken = 32, - EqualsEqualsEqualsToken = 33, - ExclamationEqualsEqualsToken = 34, - EqualsGreaterThanToken = 35, - PlusToken = 36, - MinusToken = 37, - AsteriskToken = 38, - AsteriskAsteriskToken = 39, - SlashToken = 40, - PercentToken = 41, - PlusPlusToken = 42, - MinusMinusToken = 43, - LessThanLessThanToken = 44, - GreaterThanGreaterThanToken = 45, - GreaterThanGreaterThanGreaterThanToken = 46, - AmpersandToken = 47, - BarToken = 48, - CaretToken = 49, - ExclamationToken = 50, - TildeToken = 51, - AmpersandAmpersandToken = 52, - BarBarToken = 53, - QuestionToken = 54, - ColonToken = 55, - AtToken = 56, - EqualsToken = 57, - PlusEqualsToken = 58, - MinusEqualsToken = 59, - AsteriskEqualsToken = 60, - AsteriskAsteriskEqualsToken = 61, - SlashEqualsToken = 62, - PercentEqualsToken = 63, - LessThanLessThanEqualsToken = 64, - GreaterThanGreaterThanEqualsToken = 65, - GreaterThanGreaterThanGreaterThanEqualsToken = 66, - AmpersandEqualsToken = 67, - BarEqualsToken = 68, - CaretEqualsToken = 69, - Identifier = 70, - BreakKeyword = 71, - CaseKeyword = 72, - CatchKeyword = 73, - ClassKeyword = 74, - ConstKeyword = 75, - ContinueKeyword = 76, - DebuggerKeyword = 77, - DefaultKeyword = 78, - DeleteKeyword = 79, - DoKeyword = 80, - ElseKeyword = 81, - EnumKeyword = 82, - ExportKeyword = 83, - ExtendsKeyword = 84, - FalseKeyword = 85, - FinallyKeyword = 86, - ForKeyword = 87, - FunctionKeyword = 88, - IfKeyword = 89, - ImportKeyword = 90, - InKeyword = 91, - InstanceOfKeyword = 92, - NewKeyword = 93, - NullKeyword = 94, - ReturnKeyword = 95, - SuperKeyword = 96, - SwitchKeyword = 97, - ThisKeyword = 98, - ThrowKeyword = 99, - TrueKeyword = 100, - TryKeyword = 101, - TypeOfKeyword = 102, - VarKeyword = 103, - VoidKeyword = 104, - WhileKeyword = 105, - WithKeyword = 106, - ImplementsKeyword = 107, - InterfaceKeyword = 108, - LetKeyword = 109, - PackageKeyword = 110, - PrivateKeyword = 111, - ProtectedKeyword = 112, - PublicKeyword = 113, - StaticKeyword = 114, - YieldKeyword = 115, - AbstractKeyword = 116, - AsKeyword = 117, - AnyKeyword = 118, - AsyncKeyword = 119, - AwaitKeyword = 120, - BooleanKeyword = 121, - ConstructorKeyword = 122, - DeclareKeyword = 123, - GetKeyword = 124, - IsKeyword = 125, - KeyOfKeyword = 126, - ModuleKeyword = 127, - NamespaceKeyword = 128, - NeverKeyword = 129, - ReadonlyKeyword = 130, - RequireKeyword = 131, - NumberKeyword = 132, - ObjectKeyword = 133, - SetKeyword = 134, - StringKeyword = 135, - SymbolKeyword = 136, - TypeKeyword = 137, - UndefinedKeyword = 138, - FromKeyword = 139, - GlobalKeyword = 140, - OfKeyword = 141, - QualifiedName = 142, - ComputedPropertyName = 143, - TypeParameter = 144, - Parameter = 145, - Decorator = 146, - PropertySignature = 147, - PropertyDeclaration = 148, - MethodSignature = 149, - MethodDeclaration = 150, - Constructor = 151, - GetAccessor = 152, - SetAccessor = 153, - CallSignature = 154, - ConstructSignature = 155, - IndexSignature = 156, - TypePredicate = 157, - TypeReference = 158, - FunctionType = 159, - ConstructorType = 160, - TypeQuery = 161, - TypeLiteral = 162, - ArrayType = 163, - TupleType = 164, - UnionType = 165, - IntersectionType = 166, - ParenthesizedType = 167, - ThisType = 168, - TypeOperator = 169, - IndexedAccessType = 170, - MappedType = 171, - LiteralType = 172, - ObjectBindingPattern = 173, - ArrayBindingPattern = 174, - BindingElement = 175, - ArrayLiteralExpression = 176, - ObjectLiteralExpression = 177, - PropertyAccessExpression = 178, - ElementAccessExpression = 179, - CallExpression = 180, - NewExpression = 181, - TaggedTemplateExpression = 182, - TypeAssertionExpression = 183, - ParenthesizedExpression = 184, - FunctionExpression = 185, - ArrowFunction = 186, - DeleteExpression = 187, - TypeOfExpression = 188, - VoidExpression = 189, - AwaitExpression = 190, - PrefixUnaryExpression = 191, - PostfixUnaryExpression = 192, - BinaryExpression = 193, - ConditionalExpression = 194, - TemplateExpression = 195, - YieldExpression = 196, - SpreadElement = 197, - ClassExpression = 198, - OmittedExpression = 199, - ExpressionWithTypeArguments = 200, - AsExpression = 201, - NonNullExpression = 202, - MetaProperty = 203, - TemplateSpan = 204, - SemicolonClassElement = 205, - Block = 206, - VariableStatement = 207, - EmptyStatement = 208, - ExpressionStatement = 209, - IfStatement = 210, - DoStatement = 211, - WhileStatement = 212, - ForStatement = 213, - ForInStatement = 214, - ForOfStatement = 215, - ContinueStatement = 216, - BreakStatement = 217, - ReturnStatement = 218, - WithStatement = 219, - SwitchStatement = 220, - LabeledStatement = 221, - ThrowStatement = 222, - TryStatement = 223, - DebuggerStatement = 224, - VariableDeclaration = 225, - VariableDeclarationList = 226, - FunctionDeclaration = 227, - ClassDeclaration = 228, - InterfaceDeclaration = 229, - TypeAliasDeclaration = 230, - EnumDeclaration = 231, - ModuleDeclaration = 232, - ModuleBlock = 233, - CaseBlock = 234, - NamespaceExportDeclaration = 235, - ImportEqualsDeclaration = 236, - ImportDeclaration = 237, - ImportClause = 238, - NamespaceImport = 239, - NamedImports = 240, - ImportSpecifier = 241, - ExportAssignment = 242, - ExportDeclaration = 243, - NamedExports = 244, - ExportSpecifier = 245, - MissingDeclaration = 246, - ExternalModuleReference = 247, - JsxElement = 248, - JsxSelfClosingElement = 249, - JsxOpeningElement = 250, - JsxClosingElement = 251, - JsxAttribute = 252, - JsxAttributes = 253, - JsxSpreadAttribute = 254, - JsxExpression = 255, - CaseClause = 256, - DefaultClause = 257, - HeritageClause = 258, - CatchClause = 259, - PropertyAssignment = 260, - ShorthandPropertyAssignment = 261, - SpreadAssignment = 262, - EnumMember = 263, - SourceFile = 264, - Bundle = 265, - JSDocTypeExpression = 266, - JSDocAllType = 267, - JSDocUnknownType = 268, - JSDocArrayType = 269, - JSDocUnionType = 270, - JSDocTupleType = 271, - JSDocNullableType = 272, - JSDocNonNullableType = 273, - JSDocRecordType = 274, - JSDocRecordMember = 275, - JSDocTypeReference = 276, - JSDocOptionalType = 277, - JSDocFunctionType = 278, - JSDocVariadicType = 279, - JSDocConstructorType = 280, - JSDocThisType = 281, - JSDocComment = 282, - JSDocTag = 283, - JSDocAugmentsTag = 284, - JSDocParameterTag = 285, - JSDocReturnTag = 286, - JSDocTypeTag = 287, - JSDocTemplateTag = 288, - JSDocTypedefTag = 289, - JSDocPropertyTag = 290, - JSDocTypeLiteral = 291, - JSDocLiteralType = 292, - JSDocNullKeyword = 293, - JSDocUndefinedKeyword = 294, - JSDocNeverKeyword = 295, - SyntaxList = 296, - NotEmittedStatement = 297, - PartiallyEmittedExpression = 298, - MergeDeclarationMarker = 299, - EndOfDeclarationMarker = 300, - Count = 301, - FirstAssignment = 57, - LastAssignment = 69, - FirstCompoundAssignment = 58, - LastCompoundAssignment = 69, - FirstReservedWord = 71, - LastReservedWord = 106, - FirstKeyword = 71, - LastKeyword = 141, - FirstFutureReservedWord = 107, - LastFutureReservedWord = 115, - FirstTypeNode = 157, - LastTypeNode = 172, - FirstPunctuation = 16, - LastPunctuation = 69, + JsxTextAllWhiteSpaces = 11, + RegularExpressionLiteral = 12, + NoSubstitutionTemplateLiteral = 13, + TemplateHead = 14, + TemplateMiddle = 15, + TemplateTail = 16, + OpenBraceToken = 17, + CloseBraceToken = 18, + OpenParenToken = 19, + CloseParenToken = 20, + OpenBracketToken = 21, + CloseBracketToken = 22, + DotToken = 23, + DotDotDotToken = 24, + SemicolonToken = 25, + CommaToken = 26, + LessThanToken = 27, + LessThanSlashToken = 28, + GreaterThanToken = 29, + LessThanEqualsToken = 30, + GreaterThanEqualsToken = 31, + EqualsEqualsToken = 32, + ExclamationEqualsToken = 33, + EqualsEqualsEqualsToken = 34, + ExclamationEqualsEqualsToken = 35, + EqualsGreaterThanToken = 36, + PlusToken = 37, + MinusToken = 38, + AsteriskToken = 39, + AsteriskAsteriskToken = 40, + SlashToken = 41, + PercentToken = 42, + PlusPlusToken = 43, + MinusMinusToken = 44, + LessThanLessThanToken = 45, + GreaterThanGreaterThanToken = 46, + GreaterThanGreaterThanGreaterThanToken = 47, + AmpersandToken = 48, + BarToken = 49, + CaretToken = 50, + ExclamationToken = 51, + TildeToken = 52, + AmpersandAmpersandToken = 53, + BarBarToken = 54, + QuestionToken = 55, + ColonToken = 56, + AtToken = 57, + EqualsToken = 58, + PlusEqualsToken = 59, + MinusEqualsToken = 60, + AsteriskEqualsToken = 61, + AsteriskAsteriskEqualsToken = 62, + SlashEqualsToken = 63, + PercentEqualsToken = 64, + LessThanLessThanEqualsToken = 65, + GreaterThanGreaterThanEqualsToken = 66, + GreaterThanGreaterThanGreaterThanEqualsToken = 67, + AmpersandEqualsToken = 68, + BarEqualsToken = 69, + CaretEqualsToken = 70, + Identifier = 71, + BreakKeyword = 72, + CaseKeyword = 73, + CatchKeyword = 74, + ClassKeyword = 75, + ConstKeyword = 76, + ContinueKeyword = 77, + DebuggerKeyword = 78, + DefaultKeyword = 79, + DeleteKeyword = 80, + DoKeyword = 81, + ElseKeyword = 82, + EnumKeyword = 83, + ExportKeyword = 84, + ExtendsKeyword = 85, + FalseKeyword = 86, + FinallyKeyword = 87, + ForKeyword = 88, + FunctionKeyword = 89, + IfKeyword = 90, + ImportKeyword = 91, + InKeyword = 92, + InstanceOfKeyword = 93, + NewKeyword = 94, + NullKeyword = 95, + ReturnKeyword = 96, + SuperKeyword = 97, + SwitchKeyword = 98, + ThisKeyword = 99, + ThrowKeyword = 100, + TrueKeyword = 101, + TryKeyword = 102, + TypeOfKeyword = 103, + VarKeyword = 104, + VoidKeyword = 105, + WhileKeyword = 106, + WithKeyword = 107, + ImplementsKeyword = 108, + InterfaceKeyword = 109, + LetKeyword = 110, + PackageKeyword = 111, + PrivateKeyword = 112, + ProtectedKeyword = 113, + PublicKeyword = 114, + StaticKeyword = 115, + YieldKeyword = 116, + AbstractKeyword = 117, + AsKeyword = 118, + AnyKeyword = 119, + AsyncKeyword = 120, + AwaitKeyword = 121, + BooleanKeyword = 122, + ConstructorKeyword = 123, + DeclareKeyword = 124, + GetKeyword = 125, + IsKeyword = 126, + KeyOfKeyword = 127, + ModuleKeyword = 128, + NamespaceKeyword = 129, + NeverKeyword = 130, + ReadonlyKeyword = 131, + RequireKeyword = 132, + NumberKeyword = 133, + ObjectKeyword = 134, + SetKeyword = 135, + StringKeyword = 136, + SymbolKeyword = 137, + TypeKeyword = 138, + UndefinedKeyword = 139, + FromKeyword = 140, + GlobalKeyword = 141, + OfKeyword = 142, + QualifiedName = 143, + ComputedPropertyName = 144, + TypeParameter = 145, + Parameter = 146, + Decorator = 147, + PropertySignature = 148, + PropertyDeclaration = 149, + MethodSignature = 150, + MethodDeclaration = 151, + Constructor = 152, + GetAccessor = 153, + SetAccessor = 154, + CallSignature = 155, + ConstructSignature = 156, + IndexSignature = 157, + TypePredicate = 158, + TypeReference = 159, + FunctionType = 160, + ConstructorType = 161, + TypeQuery = 162, + TypeLiteral = 163, + ArrayType = 164, + TupleType = 165, + UnionType = 166, + IntersectionType = 167, + ParenthesizedType = 168, + ThisType = 169, + TypeOperator = 170, + IndexedAccessType = 171, + MappedType = 172, + LiteralType = 173, + ObjectBindingPattern = 174, + ArrayBindingPattern = 175, + BindingElement = 176, + ArrayLiteralExpression = 177, + ObjectLiteralExpression = 178, + PropertyAccessExpression = 179, + ElementAccessExpression = 180, + CallExpression = 181, + NewExpression = 182, + TaggedTemplateExpression = 183, + TypeAssertionExpression = 184, + ParenthesizedExpression = 185, + FunctionExpression = 186, + ArrowFunction = 187, + DeleteExpression = 188, + TypeOfExpression = 189, + VoidExpression = 190, + AwaitExpression = 191, + PrefixUnaryExpression = 192, + PostfixUnaryExpression = 193, + BinaryExpression = 194, + ConditionalExpression = 195, + TemplateExpression = 196, + YieldExpression = 197, + SpreadElement = 198, + ClassExpression = 199, + OmittedExpression = 200, + ExpressionWithTypeArguments = 201, + AsExpression = 202, + NonNullExpression = 203, + MetaProperty = 204, + TemplateSpan = 205, + SemicolonClassElement = 206, + Block = 207, + VariableStatement = 208, + EmptyStatement = 209, + ExpressionStatement = 210, + IfStatement = 211, + DoStatement = 212, + WhileStatement = 213, + ForStatement = 214, + ForInStatement = 215, + ForOfStatement = 216, + ContinueStatement = 217, + BreakStatement = 218, + ReturnStatement = 219, + WithStatement = 220, + SwitchStatement = 221, + LabeledStatement = 222, + ThrowStatement = 223, + TryStatement = 224, + DebuggerStatement = 225, + VariableDeclaration = 226, + VariableDeclarationList = 227, + FunctionDeclaration = 228, + ClassDeclaration = 229, + InterfaceDeclaration = 230, + TypeAliasDeclaration = 231, + EnumDeclaration = 232, + ModuleDeclaration = 233, + ModuleBlock = 234, + CaseBlock = 235, + NamespaceExportDeclaration = 236, + ImportEqualsDeclaration = 237, + ImportDeclaration = 238, + ImportClause = 239, + NamespaceImport = 240, + NamedImports = 241, + ImportSpecifier = 242, + ExportAssignment = 243, + ExportDeclaration = 244, + NamedExports = 245, + ExportSpecifier = 246, + MissingDeclaration = 247, + ExternalModuleReference = 248, + JsxElement = 249, + JsxSelfClosingElement = 250, + JsxOpeningElement = 251, + JsxClosingElement = 252, + JsxAttribute = 253, + JsxAttributes = 254, + JsxSpreadAttribute = 255, + JsxExpression = 256, + CaseClause = 257, + DefaultClause = 258, + HeritageClause = 259, + CatchClause = 260, + PropertyAssignment = 261, + ShorthandPropertyAssignment = 262, + SpreadAssignment = 263, + EnumMember = 264, + SourceFile = 265, + Bundle = 266, + JSDocTypeExpression = 267, + JSDocAllType = 268, + JSDocUnknownType = 269, + JSDocArrayType = 270, + JSDocUnionType = 271, + JSDocTupleType = 272, + JSDocNullableType = 273, + JSDocNonNullableType = 274, + JSDocRecordType = 275, + JSDocRecordMember = 276, + JSDocTypeReference = 277, + JSDocOptionalType = 278, + JSDocFunctionType = 279, + JSDocVariadicType = 280, + JSDocConstructorType = 281, + JSDocThisType = 282, + JSDocComment = 283, + JSDocTag = 284, + JSDocAugmentsTag = 285, + JSDocParameterTag = 286, + JSDocReturnTag = 287, + JSDocTypeTag = 288, + JSDocTemplateTag = 289, + JSDocTypedefTag = 290, + JSDocPropertyTag = 291, + JSDocTypeLiteral = 292, + JSDocLiteralType = 293, + SyntaxList = 294, + NotEmittedStatement = 295, + PartiallyEmittedExpression = 296, + MergeDeclarationMarker = 297, + EndOfDeclarationMarker = 298, + Count = 299, + FirstAssignment = 58, + LastAssignment = 70, + FirstCompoundAssignment = 59, + LastCompoundAssignment = 70, + FirstReservedWord = 72, + LastReservedWord = 107, + FirstKeyword = 72, + LastKeyword = 142, + FirstFutureReservedWord = 108, + LastFutureReservedWord = 116, + FirstTypeNode = 158, + LastTypeNode = 173, + FirstPunctuation = 17, + LastPunctuation = 70, FirstToken = 0, - LastToken = 141, + LastToken = 142, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 8, - LastLiteralToken = 12, - FirstTemplateToken = 12, - LastTemplateToken = 15, - FirstBinaryOperator = 26, - LastBinaryOperator = 69, - FirstNode = 142, - FirstJSDocNode = 266, - LastJSDocNode = 295, - FirstJSDocTagNode = 282, - LastJSDocTagNode = 295, + LastLiteralToken = 13, + FirstTemplateToken = 13, + LastTemplateToken = 16, + FirstBinaryOperator = 27, + LastBinaryOperator = 70, + FirstNode = 143, + FirstJSDocNode = 267, + LastJSDocNode = 293, + FirstJSDocTagNode = 283, + LastJSDocTagNode = 293, } enum NodeFlags { None = 0, @@ -471,6 +469,7 @@ declare namespace ts { type EndOfFileToken = Token; type AtToken = Token; type ReadonlyToken = Token; + type AwaitKeywordToken = Token; type Modifier = Token | Token | Token | Token | Token | Token | Token | Token | Token | Token | Token; type ModifiersArray = NodeArray; interface Identifier extends PrimaryExpression { @@ -507,6 +506,7 @@ declare namespace ts { } interface TypeParameterDeclaration extends Declaration { kind: SyntaxKind.TypeParameter; + parent?: DeclarationWithTypeParameters; name: Identifier; constraint?: TypeNode; default?: TypeNode; @@ -527,17 +527,19 @@ declare namespace ts { type BindingName = Identifier | BindingPattern; interface VariableDeclaration extends Declaration { kind: SyntaxKind.VariableDeclaration; - parent?: VariableDeclarationList; + parent?: VariableDeclarationList | CatchClause; name: BindingName; type?: TypeNode; initializer?: Expression; } interface VariableDeclarationList extends Node { kind: SyntaxKind.VariableDeclarationList; + parent?: VariableStatement | ForStatement | ForOfStatement | ForInStatement; declarations: NodeArray; } interface ParameterDeclaration extends Declaration { kind: SyntaxKind.Parameter; + parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; name: BindingName; questionToken?: QuestionToken; @@ -546,6 +548,7 @@ declare namespace ts { } interface BindingElement extends Declaration { kind: SyntaxKind.BindingElement; + parent?: BindingPattern; propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: BindingName; @@ -569,7 +572,7 @@ declare namespace ts { _objectLiteralBrandBrand: any; name?: PropertyName; } - type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | MethodDeclaration | AccessorDeclaration | SpreadAssignment; + type ObjectLiteralElementLike = PropertyAssignment | ShorthandPropertyAssignment | SpreadAssignment | MethodDeclaration | AccessorDeclaration; interface PropertyAssignment extends ObjectLiteralElement { kind: SyntaxKind.PropertyAssignment; name: PropertyName; @@ -600,10 +603,12 @@ declare namespace ts { } interface ObjectBindingPattern extends Node { kind: SyntaxKind.ObjectBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } interface ArrayBindingPattern extends Node { kind: SyntaxKind.ArrayBindingPattern; + parent?: VariableDeclaration | ParameterDeclaration | BindingElement; elements: NodeArray; } type BindingPattern = ObjectBindingPattern | ArrayBindingPattern; @@ -638,41 +643,45 @@ declare namespace ts { } interface ConstructorDeclaration extends FunctionLikeDeclaration, ClassElement { kind: SyntaxKind.Constructor; + parent?: ClassDeclaration | ClassExpression; body?: FunctionBody; } + /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ interface SemicolonClassElement extends ClassElement { kind: SyntaxKind.SemicolonClassElement; + parent?: ClassDeclaration | ClassExpression; } interface GetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.GetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } interface SetAccessorDeclaration extends FunctionLikeDeclaration, ClassElement, ObjectLiteralElement { kind: SyntaxKind.SetAccessor; + parent?: ClassDeclaration | ClassExpression | ObjectLiteralExpression; name: PropertyName; body: FunctionBody; } type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; interface IndexSignatureDeclaration extends SignatureDeclaration, ClassElement, TypeElement { kind: SyntaxKind.IndexSignature; + parent?: ClassDeclaration | ClassExpression | InterfaceDeclaration | TypeLiteralNode; } interface TypeNode extends Node { _typeNodeBrand: any; } interface KeywordTypeNode extends TypeNode { - kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.VoidKeyword; + kind: SyntaxKind.AnyKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.VoidKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.NullKeyword | SyntaxKind.NeverKeyword; } interface ThisTypeNode extends TypeNode { kind: SyntaxKind.ThisType; } - interface FunctionOrConstructorTypeNode extends TypeNode, SignatureDeclaration { - kind: SyntaxKind.FunctionType | SyntaxKind.ConstructorType; - } - interface FunctionTypeNode extends FunctionOrConstructorTypeNode { + type FunctionOrConstructorTypeNode = FunctionTypeNode | ConstructorTypeNode; + interface FunctionTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.FunctionType; } - interface ConstructorTypeNode extends FunctionOrConstructorTypeNode { + interface ConstructorTypeNode extends TypeNode, SignatureDeclaration { kind: SyntaxKind.ConstructorType; } interface TypeReferenceNode extends TypeNode { @@ -701,15 +710,14 @@ declare namespace ts { kind: SyntaxKind.TupleType; elementTypes: NodeArray; } - interface UnionOrIntersectionTypeNode extends TypeNode { - kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType; + type UnionOrIntersectionTypeNode = UnionTypeNode | IntersectionTypeNode; + interface UnionTypeNode extends TypeNode { + kind: SyntaxKind.UnionType; types: NodeArray; } - interface UnionTypeNode extends UnionOrIntersectionTypeNode { - kind: SyntaxKind.UnionType; - } - interface IntersectionTypeNode extends UnionOrIntersectionTypeNode { + interface IntersectionTypeNode extends TypeNode { kind: SyntaxKind.IntersectionType; + types: NodeArray; } interface ParenthesizedTypeNode extends TypeNode { kind: SyntaxKind.ParenthesizedType; @@ -727,6 +735,7 @@ declare namespace ts { } interface MappedTypeNode extends TypeNode, Declaration { kind: SyntaxKind.MappedType; + parent?: TypeAliasDeclaration; readonlyToken?: ReadonlyToken; typeParameter: TypeParameterDeclaration; questionToken?: QuestionToken; @@ -741,7 +750,6 @@ declare namespace ts { } interface Expression extends Node { _expressionBrand: any; - contextualType?: Type; } interface OmittedExpression extends Expression { kind: SyntaxKind.OmittedExpression; @@ -777,13 +785,13 @@ declare namespace ts { interface PrimaryExpression extends MemberExpression { _primaryExpressionBrand: any; } - interface NullLiteral extends PrimaryExpression { + interface NullLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.NullKeyword; } - interface BooleanLiteral extends PrimaryExpression { + interface BooleanLiteral extends PrimaryExpression, TypeNode { kind: SyntaxKind.TrueKeyword | SyntaxKind.FalseKeyword; } - interface ThisExpression extends PrimaryExpression { + interface ThisExpression extends PrimaryExpression, KeywordTypeNode { kind: SyntaxKind.ThisKeyword; } interface SuperExpression extends PrimaryExpression { @@ -891,16 +899,18 @@ declare namespace ts { } interface NumericLiteral extends LiteralExpression { kind: SyntaxKind.NumericLiteral; - trailingComment?: string; } interface TemplateHead extends LiteralLikeNode { kind: SyntaxKind.TemplateHead; + parent?: TemplateExpression; } interface TemplateMiddle extends LiteralLikeNode { kind: SyntaxKind.TemplateMiddle; + parent?: TemplateSpan; } interface TemplateTail extends LiteralLikeNode { kind: SyntaxKind.TemplateTail; + parent?: TemplateSpan; } type TemplateLiteral = TemplateExpression | NoSubstitutionTemplateLiteral; interface TemplateExpression extends PrimaryExpression { @@ -910,6 +920,7 @@ declare namespace ts { } interface TemplateSpan extends Node { kind: SyntaxKind.TemplateSpan; + parent?: TemplateExpression; expression: Expression; literal: TemplateMiddle | TemplateTail; } @@ -926,18 +937,18 @@ declare namespace ts { expression: Expression; } /** - * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to - * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be - * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type - * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) - **/ + * This interface is a base interface for ObjectLiteralExpression and JSXAttributes to extend from. JSXAttributes is similar to + * ObjectLiteralExpression in that it contains array of properties; however, JSXAttributes' properties can only be + * JSXAttribute or JSXSpreadAttribute. ObjectLiteralExpression, on the other hand, can only have properties of type + * ObjectLiteralElement (e.g. PropertyAssignment, ShorthandPropertyAssignment etc.) + */ interface ObjectLiteralExpressionBase extends PrimaryExpression, Declaration { properties: NodeArray; } interface ObjectLiteralExpression extends ObjectLiteralExpressionBase { kind: SyntaxKind.ObjectLiteralExpression; } - type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression; + type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression; type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; interface PropertyAccessExpression extends MemberExpression, Declaration { kind: SyntaxKind.PropertyAccessExpression; @@ -972,6 +983,7 @@ declare namespace ts { } interface ExpressionWithTypeArguments extends TypeNode { kind: SyntaxKind.ExpressionWithTypeArguments; + parent?: HeritageClause; expression: LeftHandSideExpression; typeArguments?: NodeArray; } @@ -979,7 +991,7 @@ declare namespace ts { kind: SyntaxKind.NewExpression; expression: LeftHandSideExpression; typeArguments?: NodeArray; - arguments: NodeArray; + arguments?: NodeArray; } interface TaggedTemplateExpression extends MemberExpression { kind: SyntaxKind.TaggedTemplateExpression; @@ -1017,9 +1029,11 @@ declare namespace ts { type JsxAttributeLike = JsxAttribute | JsxSpreadAttribute; type JsxTagNameExpression = PrimaryExpression | PropertyAccessExpression; interface JsxAttributes extends ObjectLiteralExpressionBase { + parent?: JsxOpeningLikeElement; } interface JsxOpeningElement extends Expression { kind: SyntaxKind.JsxOpeningElement; + parent?: JsxElement; tagName: JsxTagNameExpression; attributes: JsxAttributes; } @@ -1030,24 +1044,30 @@ declare namespace ts { } interface JsxAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxAttribute; + parent?: JsxAttributes; name: Identifier; initializer?: StringLiteral | JsxExpression; } interface JsxSpreadAttribute extends ObjectLiteralElement { kind: SyntaxKind.JsxSpreadAttribute; + parent?: JsxAttributes; expression: Expression; } interface JsxClosingElement extends Node { kind: SyntaxKind.JsxClosingElement; + parent?: JsxElement; tagName: JsxTagNameExpression; } interface JsxExpression extends Expression { kind: SyntaxKind.JsxExpression; + parent?: JsxElement | JsxAttributeLike; dotDotDotToken?: Token; expression?: Expression; } interface JsxText extends Node { kind: SyntaxKind.JsxText; + containsOnlyWhiteSpaces: boolean; + parent?: JsxElement; } type JsxChild = JsxText | JsxExpression | JsxElement | JsxSelfClosingElement; interface Statement extends Node { @@ -1110,6 +1130,7 @@ declare namespace ts { } interface ForOfStatement extends IterationStatement { kind: SyntaxKind.ForOfStatement; + awaitModifier?: AwaitKeywordToken; initializer: ForInitializer; expression: Expression; } @@ -1139,15 +1160,18 @@ declare namespace ts { } interface CaseBlock extends Node { kind: SyntaxKind.CaseBlock; + parent?: SwitchStatement; clauses: NodeArray; } interface CaseClause extends Node { kind: SyntaxKind.CaseClause; + parent?: CaseBlock; expression: Expression; statements: NodeArray; } interface DefaultClause extends Node { kind: SyntaxKind.DefaultClause; + parent?: CaseBlock; statements: NodeArray; } type CaseOrDefaultClause = CaseClause | DefaultClause; @@ -1168,6 +1192,7 @@ declare namespace ts { } interface CatchClause extends Node { kind: SyntaxKind.CatchClause; + parent?: TryStatement; variableDeclaration: VariableDeclaration; block: Block; } @@ -1203,8 +1228,9 @@ declare namespace ts { } interface HeritageClause extends Node { kind: SyntaxKind.HeritageClause; - token: SyntaxKind; - types?: NodeArray; + parent?: InterfaceDeclaration | ClassDeclaration | ClassExpression; + token: SyntaxKind.ExtendsKeyword | SyntaxKind.ImplementsKeyword; + types: NodeArray; } interface TypeAliasDeclaration extends DeclarationStatement { kind: SyntaxKind.TypeAliasDeclaration; @@ -1214,6 +1240,7 @@ declare namespace ts { } interface EnumMember extends Declaration { kind: SyntaxKind.EnumMember; + parent?: EnumDeclaration; name: PropertyName; initializer?: Expression; } @@ -1226,8 +1253,9 @@ declare namespace ts { type ModuleBody = NamespaceBody | JSDocNamespaceBody; interface ModuleDeclaration extends DeclarationStatement { kind: SyntaxKind.ModuleDeclaration; - name: Identifier | StringLiteral; - body?: ModuleBody | JSDocNamespaceDeclaration | Identifier; + parent?: ModuleBody | SourceFile; + name: ModuleName; + body?: ModuleBody | JSDocNamespaceDeclaration; } type NamespaceBody = ModuleBlock | NamespaceDeclaration; interface NamespaceDeclaration extends ModuleDeclaration { @@ -1241,74 +1269,101 @@ declare namespace ts { } interface ModuleBlock extends Node, Statement { kind: SyntaxKind.ModuleBlock; + parent?: ModuleDeclaration; statements: NodeArray; } type ModuleReference = EntityName | ExternalModuleReference; + /** + * One of: + * - import x = require("mod"); + * - import x = M.x; + */ interface ImportEqualsDeclaration extends DeclarationStatement { kind: SyntaxKind.ImportEqualsDeclaration; + parent?: SourceFile | ModuleBlock; name: Identifier; moduleReference: ModuleReference; } interface ExternalModuleReference extends Node { kind: SyntaxKind.ExternalModuleReference; + parent?: ImportEqualsDeclaration; expression?: Expression; } interface ImportDeclaration extends Statement { kind: SyntaxKind.ImportDeclaration; + parent?: SourceFile | ModuleBlock; importClause?: ImportClause; + /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier: Expression; } type NamedImportBindings = NamespaceImport | NamedImports; interface ImportClause extends Declaration { kind: SyntaxKind.ImportClause; + parent?: ImportDeclaration; name?: Identifier; namedBindings?: NamedImportBindings; } interface NamespaceImport extends Declaration { kind: SyntaxKind.NamespaceImport; + parent?: ImportClause; name: Identifier; } interface NamespaceExportDeclaration extends DeclarationStatement { kind: SyntaxKind.NamespaceExportDeclaration; name: Identifier; - moduleReference: LiteralLikeNode; } interface ExportDeclaration extends DeclarationStatement { kind: SyntaxKind.ExportDeclaration; + parent?: SourceFile | ModuleBlock; exportClause?: NamedExports; + /** If this is not a StringLiteral it will be a grammar error. */ moduleSpecifier?: Expression; } interface NamedImports extends Node { kind: SyntaxKind.NamedImports; + parent?: ImportClause; elements: NodeArray; } interface NamedExports extends Node { kind: SyntaxKind.NamedExports; + parent?: ExportDeclaration; elements: NodeArray; } type NamedImportsOrExports = NamedImports | NamedExports; interface ImportSpecifier extends Declaration { kind: SyntaxKind.ImportSpecifier; + parent?: NamedImports; propertyName?: Identifier; name: Identifier; } interface ExportSpecifier extends Declaration { kind: SyntaxKind.ExportSpecifier; + parent?: NamedExports; propertyName?: Identifier; name: Identifier; } type ImportOrExportSpecifier = ImportSpecifier | ExportSpecifier; interface ExportAssignment extends DeclarationStatement { kind: SyntaxKind.ExportAssignment; + parent?: SourceFile; isExportEquals?: boolean; expression: Expression; } interface FileReference extends TextRange { fileName: string; } + interface CheckJsDirective extends TextRange { + enabled: boolean; + } + type CommentKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia; interface CommentRange extends TextRange { hasTrailingNewLine?: boolean; - kind: SyntaxKind; + kind: CommentKind; + } + interface SynthesizedComment extends CommentRange { + text: string; + pos: -1; + end: -1; } interface JSDocTypeExpression extends Node { kind: SyntaxKind.JSDocTypeExpression; @@ -1509,7 +1564,6 @@ declare namespace ts { statements: NodeArray; endOfFileToken: Token; fileName: string; - path: Path; text: string; amdDependencies: AmdDependency[]; moduleName: string; @@ -1542,9 +1596,9 @@ declare namespace ts { useCaseSensitiveFileNames: boolean; readDirectory(rootDir: string, extensions: string[], excludes: string[], includes: string[]): string[]; /** - * Gets a value indicating whether the specified path exists and is a file. - * @param path The path to test. - */ + * Gets a value indicating whether the specified path exists and is a file. + * @param path The path to test. + */ fileExists(path: string): boolean; readFile(path: string): string; } @@ -1577,7 +1631,7 @@ declare namespace ts { * used for writing the JavaScript and declaration files. Otherwise, the writeFile parameter * will be invoked when writing the JavaScript and declaration files. */ - emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean): EmitResult; + emit(targetSourceFile?: SourceFile, writeFile?: WriteFileCallback, cancellationToken?: CancellationToken, emitOnlyDtsFiles?: boolean, customTransformers?: CustomTransformers): EmitResult; getOptionsDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getGlobalDiagnostics(cancellationToken?: CancellationToken): Diagnostic[]; getSyntacticDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -1588,6 +1642,12 @@ declare namespace ts { */ getTypeChecker(): TypeChecker; } + interface CustomTransformers { + /** Custom transformers to evaluate before built-in transformations. */ + before?: TransformerFactory[]; + /** Custom transformers to evaluate after built-in transformations. */ + after?: TransformerFactory[]; + } interface SourceMapSpan { /** Line number in the .js file. */ emittedLine: number; @@ -1635,8 +1695,16 @@ declare namespace ts { getSignaturesOfType(type: Type, kind: SignatureKind): Signature[]; getIndexTypeOfType(type: Type, kind: IndexKind): Type; getBaseTypes(type: InterfaceType): BaseType[]; + getBaseTypeOfLiteralType(type: Type): Type; + getWidenedType(type: Type): Type; getReturnTypeOfSignature(signature: Signature): Type; getNonNullableType(type: Type): Type; + /** Note that the resulting nodes cannot be checked. */ + typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode; + /** Note that the resulting nodes cannot be checked. */ + signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration; + /** Note that the resulting nodes cannot be checked. */ + indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; getSymbolAtLocation(node: Node): Symbol; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; @@ -1661,6 +1729,7 @@ declare namespace ts { isUnknownSymbol(symbol: Symbol): boolean; getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): number; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; + /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; getExportsOfModule(moduleSymbol: Symbol): Symbol[]; getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; @@ -1670,6 +1739,15 @@ declare namespace ts { tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; } + enum NodeBuilderFlags { + None = 0, + allowThisInObjectLiteral = 1, + allowQualifedNameInPlaceOfIdentifier = 2, + allowTypeParameterInQualifiedName = 4, + allowAnonymousIdentifier = 8, + allowEmptyUnionOrIntersection = 16, + allowEmptyTuple = 32, + } interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; @@ -1878,7 +1956,6 @@ declare namespace ts { ObjectLiteral = 128, EvolvingArray = 256, ObjectLiteralPatternWithComputedProperties = 512, - NonPrimitive = 1024, ClassOrInterface = 3, } interface ObjectType extends Type { @@ -1988,6 +2065,7 @@ declare namespace ts { messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; + source?: string; } enum DiagnosticCategory { Warning = 0, @@ -2010,9 +2088,11 @@ declare namespace ts { alwaysStrict?: boolean; baseUrl?: string; charset?: string; + checkJs?: boolean; declaration?: boolean; declarationDir?: string; disableSizeLimit?: boolean; + downlevelIteration?: boolean; emitBOM?: boolean; emitDecoratorMetadata?: boolean; experimentalDecorators?: boolean; @@ -2057,6 +2137,7 @@ declare namespace ts { skipDefaultLibCheck?: boolean; sourceMap?: boolean; sourceRoot?: string; + strict?: boolean; strictNullChecks?: boolean; suppressExcessPropertyErrors?: boolean; suppressImplicitAnyIndexErrors?: boolean; @@ -2239,13 +2320,15 @@ declare namespace ts { HelperName = 4096, ExportName = 8192, LocalName = 16384, - Indented = 32768, - NoIndentation = 65536, - AsyncFunctionBody = 131072, - ReuseTempVariableScope = 262144, - CustomPrologue = 524288, - NoHoisting = 1048576, - HasEndOfDeclarationMarker = 2097152, + InternalName = 32768, + Indented = 65536, + NoIndentation = 131072, + AsyncFunctionBody = 262144, + ReuseTempVariableScope = 524288, + CustomPrologue = 1048576, + NoHoisting = 2097152, + HasEndOfDeclarationMarker = 4194304, + Iterator = 8388608, } interface EmitHelper { readonly name: string; @@ -2259,6 +2342,95 @@ declare namespace ts { IdentifierName = 2, Unspecified = 3, } + interface TransformationContext { + /** Gets the compiler options supplied to the transformer. */ + getCompilerOptions(): CompilerOptions; + /** Starts a new lexical environment. */ + startLexicalEnvironment(): void; + /** Suspends the current lexical environment, usually after visiting a parameter list. */ + suspendLexicalEnvironment(): void; + /** Resumes a suspended lexical environment, usually before visiting a function body. */ + resumeLexicalEnvironment(): void; + /** Ends a lexical environment, returning any declarations. */ + endLexicalEnvironment(): Statement[]; + /** Hoists a function declaration to the containing scope. */ + hoistFunctionDeclaration(node: FunctionDeclaration): void; + /** Hoists a variable declaration to the containing scope. */ + hoistVariableDeclaration(node: Identifier): void; + /** Records a request for a non-scoped emit helper in the current context. */ + requestEmitHelper(helper: EmitHelper): void; + /** Gets and resets the requested non-scoped emit helpers. */ + readEmitHelpers(): EmitHelper[] | undefined; + /** Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ + enableSubstitution(kind: SyntaxKind): void; + /** Determines whether expression substitutions are enabled for the provided node. */ + isSubstitutionEnabled(node: Node): boolean; + /** + * Hook used by transformers to substitute expressions just before they + * are emitted by the pretty printer. + * + * NOTE: Transformation hooks should only be modified during `Transformer` initialization, + * before returning the `NodeTransformer` callback. + */ + onSubstituteNode: (hint: EmitHint, node: Node) => Node; + /** + * Enables before/after emit notifications in the pretty printer for the provided + * SyntaxKind. + */ + enableEmitNotification(kind: SyntaxKind): void; + /** + * Determines whether before/after emit notifications should be raised in the pretty + * printer when it emits a node. + */ + isEmitNotificationEnabled(node: Node): boolean; + /** + * Hook used to allow transformers to capture state before or after + * the printer emits a node. + * + * NOTE: Transformation hooks should only be modified during `Transformer` initialization, + * before returning the `NodeTransformer` callback. + */ + onEmitNode: (hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void) => void; + } + interface TransformationResult { + /** Gets the transformed source files. */ + transformed: T[]; + /** Gets diagnostics for the transformation. */ + diagnostics?: Diagnostic[]; + /** + * Gets a substitute for a node, if one is available; otherwise, returns the original node. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + substituteNode(hint: EmitHint, node: Node): Node; + /** + * Emits a node with possible notification. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emitCallback A callback used to emit the node. + */ + emitNodeWithNotification(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + /** + * Clean up EmitNode entries on any parse-tree nodes. + */ + dispose(): void; + } + /** + * A function that is used to initialize and return a `Transformer` callback, which in turn + * will be used to transform one or more nodes. + */ + type TransformerFactory = (context: TransformationContext) => Transformer; + /** + * A function that transforms a node. + */ + type Transformer = (node: T) => T; + /** + * A function that accepts and possibly transforms a node. + */ + type Visitor = (node: Node) => VisitResult; + type VisitResult = T | T[]; interface Printer { /** * Print a node and its subtree as-is, without any emit transformations. @@ -2311,26 +2483,22 @@ declare namespace ts { /** * A hook used by the Printer to perform just-in-time substitution of a node. This is * primarily used by node transformations that need to substitute one node for another, - * such as replacing `myExportedVar` with `exports.myExportedVar`. A compatible - * implementation **must** invoke `emitCallback` eith the provided `hint` and either - * the provided `node`, or its substitute. + * such as replacing `myExportedVar` with `exports.myExportedVar`. * @param hint A hint indicating the intended purpose of the node. * @param node The node to emit. - * @param emitCallback A callback that, when invoked, will emit the node. * @example * ```ts * var printer = createPrinter(printerOptions, { - * onSubstituteNode(hint, node, emitCallback) { + * substituteNode(hint, node) { * // perform substitution if necessary... - * emitCallback(hint, node); + * return node; * } * }); * ``` */ - onSubstituteNode?(hint: EmitHint, node: Node, emitCallback: (hint: EmitHint, node: Node) => void): void; + substituteNode?(hint: EmitHint, node: Node): Node; } interface PrinterOptions { - target?: ScriptTarget; removeComments?: boolean; newLine?: NewLineKind; } @@ -2348,7 +2516,7 @@ declare namespace ts { } declare namespace ts { /** The version of the TypeScript compiler release */ - const version = "2.3.0"; + const version = "2.4.0"; } declare function setTimeout(handler: (...args: any[]) => void, timeout: number): any; declare function clearTimeout(handle: any): void; @@ -2397,6 +2565,7 @@ declare namespace ts { directoryName: string; referenceCount: number; } + function getNodeMajorVersion(): number; let sys: System; } declare namespace ts { @@ -2437,15 +2606,15 @@ declare namespace ts { function tokenToString(t: SyntaxKind): string; function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number; function getLineAndCharacterOfPosition(sourceFile: SourceFile, position: number): LineAndCharacter; - function isWhiteSpace(ch: number): boolean; + function isWhiteSpaceLike(ch: number): boolean; /** Does not include line breaks. For that, see isWhiteSpaceLike. */ function isWhiteSpaceSingleLine(ch: number): boolean; function isLineBreak(ch: number): boolean; function couldStartTrivia(text: string, pos: number): boolean; - function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; - function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; - function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; - function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: SyntaxKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; + function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U; + function reduceEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; + function reduceEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T, memo: U) => U, state: T, initial: U): U; function getLeadingCommentRanges(text: string, pos: number): CommentRange[] | undefined; function getTrailingCommentRanges(text: string, pos: number): CommentRange[] | undefined; /** Optionally, get the shebang */ @@ -2487,9 +2656,9 @@ declare namespace ts { function getCombinedModifierFlags(node: Node): ModifierFlags; function getCombinedNodeFlags(node: Node): NodeFlags; /** - * Checks to see if the locale is in the appropriate format, - * and if it is, attempts to set the appropriate language. - */ + * Checks to see if the locale is in the appropriate format, + * and if it is, attempts to set the appropriate language. + */ function validateLocaleAndSetLanguage(locale: string, sys: { getExecutingFilePath(): string; resolvePath(path: string): string; @@ -2549,35 +2718,80 @@ declare namespace ts { /** Create a unique name generated for a node. */ function getGeneratedNameForNode(node: Node): Identifier; function createToken(token: TKind): Token; - function createSuper(): PrimaryExpression; - function createThis(): PrimaryExpression; - function createNull(): PrimaryExpression; - function createTrue(): BooleanLiteral; - function createFalse(): BooleanLiteral; + function createSuper(): SuperExpression; + function createThis(): ThisExpression & Token; + function createNull(): NullLiteral & Token; + function createTrue(): BooleanLiteral & Token; + function createFalse(): BooleanLiteral & Token; function createQualifiedName(left: EntityName, right: string | Identifier): QualifiedName; function updateQualifiedName(node: QualifiedName, left: EntityName, right: Identifier): QualifiedName; function createComputedPropertyName(expression: Expression): ComputedPropertyName; function updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; - function createParameter(decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: string | Identifier | BindingPattern, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - function updateParameter(node: ParameterDeclaration, decorators: Decorator[], modifiers: Modifier[], dotDotDotToken: DotDotDotToken, name: BindingName, type: TypeNode, initializer: Expression): ParameterDeclaration; + function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): SignatureDeclaration; + function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): FunctionTypeNode; + function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): FunctionTypeNode; + function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructorTypeNode; + function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; + function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; + function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined): MethodSignature; + function createKeywordTypeNode(kind: KeywordTypeNode["kind"]): KeywordTypeNode; + function createThisTypeNode(): ThisTypeNode; + function createLiteralTypeNode(literal: Expression): LiteralTypeNode; + function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression): LiteralTypeNode; + function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined): TypeReferenceNode; + function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined): TypeReferenceNode; + function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode; + function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode; + function createTypeQueryNode(exprName: EntityName): TypeQueryNode; + function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName): TypeQueryNode; + function createArrayTypeNode(elementType: TypeNode): ArrayTypeNode; + function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; + function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray): UnionOrIntersectionTypeNode; + function createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; + function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; + function createTypeLiteralNode(members: TypeElement[]): TypeLiteralNode; + function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray): TypeLiteralNode; + function createTupleTypeNode(elementTypes: TypeNode[]): TupleTypeNode; + function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]): TupleTypeNode; + function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode; + function createTypeOperatorNode(type: TypeNode): TypeOperatorNode; + function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode): TypeOperatorNode; + function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode): IndexedAccessTypeNode; + function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature; + function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + function updateParameter(node: ParameterDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; function createDecorator(expression: Expression): Decorator; function updateDecorator(node: Decorator, expression: Expression): Decorator; - function createProperty(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, questionToken: QuestionToken, type: TypeNode, initializer: Expression): PropertyDeclaration; - function updateProperty(node: PropertyDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, type: TypeNode, initializer: Expression): PropertyDeclaration; - function createMethod(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function updateMethod(node: MethodDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): MethodDeclaration; - function createConstructor(decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[], modifiers: Modifier[], parameters: ParameterDeclaration[], body: Block): ConstructorDeclaration; - function createGetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode, body: Block): GetAccessorDeclaration; - function createSetAccessor(decorators: Decorator[], modifiers: Modifier[], name: string | PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; - function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[], modifiers: Modifier[], name: PropertyName, parameters: ParameterDeclaration[], body: Block): SetAccessorDeclaration; + function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration; + function updateProperty(node: PropertyDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, type: TypeNode | undefined, initializer: Expression): PropertyDeclaration; + function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function updateMethod(node: MethodDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + function createConstructor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function updateConstructor(node: ConstructorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + function createGetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function updateGetAccessor(node: GetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + function createSetAccessor(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + function updateSetAccessor(node: SetAccessorDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: PropertyName, parameters: ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; function createObjectBindingPattern(elements: BindingElement[]): ObjectBindingPattern; function updateObjectBindingPattern(node: ObjectBindingPattern, elements: BindingElement[]): ObjectBindingPattern; function createArrayBindingPattern(elements: ArrayBindingElement[]): ArrayBindingPattern; function updateArrayBindingPattern(node: ArrayBindingPattern, elements: ArrayBindingElement[]): ArrayBindingPattern; - function createBindingElement(propertyName: string | PropertyName, dotDotDotToken: DotDotDotToken, name: string | BindingName, initializer?: Expression): BindingElement; - function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken, propertyName: PropertyName, name: BindingName, initializer: Expression): BindingElement; + function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression): BindingElement; + function updateBindingElement(node: BindingElement, dotDotDotToken: DotDotDotToken | undefined, propertyName: PropertyName | undefined, name: BindingName, initializer: Expression | undefined): BindingElement; function createArrayLiteral(elements?: Expression[], multiLine?: boolean): ArrayLiteralExpression; function updateArrayLiteral(node: ArrayLiteralExpression, elements: Expression[]): ArrayLiteralExpression; function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean): ObjectLiteralExpression; @@ -2586,20 +2800,20 @@ declare namespace ts { function updatePropertyAccess(node: PropertyAccessExpression, expression: Expression, name: Identifier): PropertyAccessExpression; function createElementAccess(expression: Expression, index: number | Expression): ElementAccessExpression; function updateElementAccess(node: ElementAccessExpression, expression: Expression, argumentExpression: Expression): ElementAccessExpression; - function createCall(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): CallExpression; - function createNew(expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; - function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[], argumentsArray: Expression[]): NewExpression; + function createCall(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]): CallExpression; + function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]): CallExpression; + function createNew(expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined): NewExpression; + function updateNew(node: NewExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[] | undefined): NewExpression; function createTaggedTemplate(tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; function createTypeAssertion(type: TypeNode, expression: Expression): TypeAssertion; function updateTypeAssertion(node: TypeAssertion, type: TypeNode, expression: Expression): TypeAssertion; function createParen(expression: Expression): ParenthesizedExpression; function updateParen(node: ParenthesizedExpression, expression: Expression): ParenthesizedExpression; - function createFunctionExpression(modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionExpression; - function createArrowFunction(modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; - function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[], typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: ConciseBody): ArrowFunction; + function createFunctionExpression(modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function updateFunctionExpression(node: FunctionExpression, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block): FunctionExpression; + function createArrowFunction(modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + function updateArrowFunction(node: ArrowFunction, modifiers: Modifier[] | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; function createDelete(expression: Expression): DeleteExpression; function updateDelete(node: DeleteExpression, expression: Expression): DeleteExpression; function createTypeOf(expression: Expression): TypeOfExpression; @@ -2621,11 +2835,11 @@ declare namespace ts { function updateTemplateExpression(node: TemplateExpression, head: TemplateHead, templateSpans: TemplateSpan[]): TemplateExpression; function createYield(expression?: Expression): YieldExpression; function createYield(asteriskToken: AsteriskToken, expression: Expression): YieldExpression; - function updateYield(node: YieldExpression, expression: Expression): YieldExpression; + function updateYield(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; function createSpread(expression: Expression): SpreadElement; function updateSpread(node: SpreadElement, expression: Expression): SpreadElement; - function createClassExpression(modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; - function updateClassExpression(node: ClassExpression, modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function createClassExpression(modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; + function updateClassExpression(node: ClassExpression, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassExpression; function createOmittedExpression(): OmittedExpression; function createExpressionWithTypeArguments(typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: TypeNode[], expression: Expression): ExpressionWithTypeArguments; @@ -2637,33 +2851,33 @@ declare namespace ts { function updateTemplateSpan(node: TemplateSpan, expression: Expression, literal: TemplateMiddle | TemplateTail): TemplateSpan; function createBlock(statements: Statement[], multiLine?: boolean): Block; function updateBlock(node: Block, statements: Statement[]): Block; - function createVariableStatement(modifiers: Modifier[], declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; - function updateVariableStatement(node: VariableStatement, modifiers: Modifier[], declarationList: VariableDeclarationList): VariableStatement; + function createVariableStatement(modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList | VariableDeclaration[]): VariableStatement; + function updateVariableStatement(node: VariableStatement, modifiers: Modifier[] | undefined, declarationList: VariableDeclarationList): VariableStatement; function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]): VariableDeclarationList; function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression): VariableDeclaration; - function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode, initializer: Expression): VariableDeclaration; + function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; function createEmptyStatement(): EmptyStatement; function createStatement(expression: Expression): ExpressionStatement; function updateStatement(node: ExpressionStatement, expression: Expression): ExpressionStatement; function createIf(expression: Expression, thenStatement: Statement, elseStatement?: Statement): IfStatement; - function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement): IfStatement; + function updateIf(node: IfStatement, expression: Expression, thenStatement: Statement, elseStatement: Statement | undefined): IfStatement; function createDo(statement: Statement, expression: Expression): DoStatement; function updateDo(node: DoStatement, statement: Statement, expression: Expression): DoStatement; function createWhile(expression: Expression, statement: Statement): WhileStatement; function updateWhile(node: WhileStatement, expression: Expression, statement: Statement): WhileStatement; - function createFor(initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; - function updateFor(node: ForStatement, initializer: ForInitializer, condition: Expression, incrementor: Expression, statement: Statement): ForStatement; + function createFor(initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; + function updateFor(node: ForStatement, initializer: ForInitializer | undefined, condition: Expression | undefined, incrementor: Expression | undefined, statement: Statement): ForStatement; function createForIn(initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; function updateForIn(node: ForInStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForInStatement; - function createForOf(initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; - function updateForOf(node: ForOfStatement, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function createForOf(awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; + function updateForOf(node: ForOfStatement, awaitModifier: AwaitKeywordToken, initializer: ForInitializer, expression: Expression, statement: Statement): ForOfStatement; function createContinue(label?: string | Identifier): ContinueStatement; - function updateContinue(node: ContinueStatement, label: Identifier): ContinueStatement; + function updateContinue(node: ContinueStatement, label: Identifier | undefined): ContinueStatement; function createBreak(label?: string | Identifier): BreakStatement; - function updateBreak(node: BreakStatement, label: Identifier): BreakStatement; + function updateBreak(node: BreakStatement, label: Identifier | undefined): BreakStatement; function createReturn(expression?: Expression): ReturnStatement; - function updateReturn(node: ReturnStatement, expression: Expression): ReturnStatement; + function updateReturn(node: ReturnStatement, expression: Expression | undefined): ReturnStatement; function createWith(expression: Expression, statement: Statement): WithStatement; function updateWith(node: WithStatement, expression: Expression, statement: Statement): WithStatement; function createSwitch(expression: Expression, caseBlock: CaseBlock): SwitchStatement; @@ -2672,40 +2886,40 @@ declare namespace ts { function updateLabel(node: LabeledStatement, label: Identifier, statement: Statement): LabeledStatement; function createThrow(expression: Expression): ThrowStatement; function updateThrow(node: ThrowStatement, expression: Expression): ThrowStatement; - function createTry(tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause, finallyBlock: Block): TryStatement; - function createFunctionDeclaration(decorators: Decorator[], modifiers: Modifier[], asteriskToken: AsteriskToken, name: string | Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], parameters: ParameterDeclaration[], type: TypeNode, body: Block): FunctionDeclaration; - function createClassDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, typeParameters: TypeParameterDeclaration[], heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; - function createEnumDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, members: EnumMember[]): EnumDeclaration; - function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, members: EnumMember[]): EnumDeclaration; - function createModuleDeclaration(decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody, flags?: NodeFlags): ModuleDeclaration; - function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[], modifiers: Modifier[], name: ModuleName, body: ModuleBody): ModuleDeclaration; + function createTry(tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; + function updateTry(node: TryStatement, tryBlock: Block, catchClause: CatchClause | undefined, finallyBlock: Block | undefined): TryStatement; + function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function updateFunctionDeclaration(node: FunctionDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + function createClassDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function updateClassDeclaration(node: ClassDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[], members: ClassElement[]): ClassDeclaration; + function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]): EnumDeclaration; + function updateEnumDeclaration(node: EnumDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, members: EnumMember[]): EnumDeclaration; + function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + function updateModuleDeclaration(node: ModuleDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; function createModuleBlock(statements: Statement[]): ModuleBlock; function updateModuleBlock(node: ModuleBlock, statements: Statement[]): ModuleBlock; function createCaseBlock(clauses: CaseOrDefaultClause[]): CaseBlock; function updateCaseBlock(node: CaseBlock, clauses: CaseOrDefaultClause[]): CaseBlock; - function createImportEqualsDeclaration(decorators: Decorator[], modifiers: Modifier[], name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[], modifiers: Modifier[], name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - function createImportDeclaration(decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier?: Expression): ImportDeclaration; - function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[], modifiers: Modifier[], importClause: ImportClause, moduleSpecifier: Expression): ImportDeclaration; + function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + function createImportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier?: Expression): ImportDeclaration; + function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined): ImportDeclaration; function createImportClause(name: Identifier, namedBindings: NamedImportBindings): ImportClause; function updateImportClause(node: ImportClause, name: Identifier, namedBindings: NamedImportBindings): ImportClause; function createNamespaceImport(name: Identifier): NamespaceImport; function updateNamespaceImport(node: NamespaceImport, name: Identifier): NamespaceImport; function createNamedImports(elements: ImportSpecifier[]): NamedImports; function updateNamedImports(node: NamedImports, elements: ImportSpecifier[]): NamedImports; - function createImportSpecifier(propertyName: Identifier, name: Identifier): ImportSpecifier; - function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier, name: Identifier): ImportSpecifier; - function createExportAssignment(decorators: Decorator[], modifiers: Modifier[], isExportEquals: boolean, expression: Expression): ExportAssignment; - function updateExportAssignment(node: ExportAssignment, decorators: Decorator[], modifiers: Modifier[], expression: Expression): ExportAssignment; - function createExportDeclaration(decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier?: Expression): ExportDeclaration; - function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[], modifiers: Modifier[], exportClause: NamedExports, moduleSpecifier: Expression): ExportDeclaration; + function createImportSpecifier(propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + function updateImportSpecifier(node: ImportSpecifier, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; + function createExportAssignment(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, isExportEquals: boolean, expression: Expression): ExportAssignment; + function updateExportAssignment(node: ExportAssignment, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, expression: Expression): ExportAssignment; + function createExportDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier?: Expression): ExportDeclaration; + function updateExportDeclaration(node: ExportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, exportClause: NamedExports | undefined, moduleSpecifier: Expression | undefined): ExportDeclaration; function createNamedExports(elements: ExportSpecifier[]): NamedExports; function updateNamedExports(node: NamedExports, elements: ExportSpecifier[]): NamedExports; - function createExportSpecifier(name: string | Identifier, propertyName?: string | Identifier): ExportSpecifier; - function updateExportSpecifier(node: ExportSpecifier, name: Identifier, propertyName: Identifier): ExportSpecifier; + function createExportSpecifier(propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; + function updateExportSpecifier(node: ExportSpecifier, propertyName: Identifier | undefined, name: Identifier): ExportSpecifier; function createExternalModuleReference(expression: Expression): ExternalModuleReference; function updateExternalModuleReference(node: ExternalModuleReference, expression: Expression): ExternalModuleReference; function createJsxElement(openingElement: JsxOpeningElement, children: JsxChild[], closingElement: JsxClosingElement): JsxElement; @@ -2722,9 +2936,9 @@ declare namespace ts { function updateJsxAttribute(node: JsxAttribute, name: Identifier, initializer: StringLiteral | JsxExpression): JsxAttribute; function createJsxSpreadAttribute(expression: Expression): JsxSpreadAttribute; function updateJsxSpreadAttribute(node: JsxSpreadAttribute, expression: Expression): JsxSpreadAttribute; - function createJsxExpression(expression: Expression, dotDotDotToken: DotDotDotToken): JsxExpression; - function updateJsxExpression(node: JsxExpression, expression: Expression): JsxExpression; - function createHeritageClause(token: SyntaxKind, types: ExpressionWithTypeArguments[]): HeritageClause; + function createJsxExpression(dotDotDotToken: DotDotDotToken | undefined, expression: Expression | undefined): JsxExpression; + function updateJsxExpression(node: JsxExpression, expression: Expression | undefined): JsxExpression; + function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]): HeritageClause; function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]): HeritageClause; function createCaseClause(expression: Expression, statements: Statement[]): CaseClause; function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]): CaseClause; @@ -2734,9 +2948,9 @@ declare namespace ts { function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block): CatchClause; function createPropertyAssignment(name: string | PropertyName, initializer: Expression): PropertyAssignment; function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression): PropertyAssignment; - function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; + function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression): ShorthandPropertyAssignment; + function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined): ShorthandPropertyAssignment; function createSpreadAssignment(expression: Expression): SpreadAssignment; - function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression): ShorthandPropertyAssignment; function updateSpreadAssignment(node: SpreadAssignment, expression: Expression): SpreadAssignment; function createEnumMember(name: string | PropertyName, initializer?: Expression): EnumMember; function updateEnumMember(node: EnumMember, name: PropertyName, initializer: Expression | undefined): EnumMember; @@ -2788,7 +3002,7 @@ declare namespace ts { /** * Gets flags that control emit behavior of a node. */ - function getEmitFlags(node: Node): EmitFlags; + function getEmitFlags(node: Node): EmitFlags | undefined; /** * Sets flags that control emit behavior of a node. */ @@ -2800,15 +3014,15 @@ declare namespace ts { /** * Sets a custom text range to use when emitting source maps. */ - function setSourceMapRange(node: T, range: TextRange): T; + function setSourceMapRange(node: T, range: TextRange | undefined): T; /** * Gets the TextRange to use for source maps for a token of a node. */ - function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange; + function getTokenSourceMapRange(node: Node, token: SyntaxKind): TextRange | undefined; /** * Sets the TextRange to use for source maps for a token of a node. */ - function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange): T; + function setTokenSourceMapRange(node: T, token: SyntaxKind, range: TextRange | undefined): T; /** * Gets a custom text range to use when emitting comments. */ @@ -2817,6 +3031,12 @@ declare namespace ts { * Sets a custom text range to use when emitting comments. */ function setCommentRange(node: T, range: TextRange): T; + function getSyntheticLeadingComments(node: Node): SynthesizedComment[] | undefined; + function setSyntheticLeadingComments(node: T, comments: SynthesizedComment[]): T; + function addSyntheticLeadingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; + function getSyntheticTrailingComments(node: Node): SynthesizedComment[] | undefined; + function setSyntheticTrailingComments(node: T, comments: SynthesizedComment[]): T; + function addSyntheticTrailingComment(node: T, kind: SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia, text: string, hasTrailingNewLine?: boolean): T; /** * Gets the constant value to emit for an expression. */ @@ -2845,7 +3065,7 @@ declare namespace ts { * Moves matching emit helpers from a source node to a target node. */ function moveEmitHelpers(source: Node, target: Node, predicate: (helper: EmitHelper) => boolean): void; - function setOriginalNode(node: T, original: Node): T; + function setOriginalNode(node: T, original: Node | undefined): T; } declare namespace ts { function createNode(kind: SyntaxKind, pos?: number, end?: number): Node; @@ -2872,13 +3092,13 @@ declare namespace ts { */ function resolveTypeReferenceDirective(typeReferenceDirectiveName: string, containingFile: string | undefined, options: CompilerOptions, host: ModuleResolutionHost): ResolvedTypeReferenceDirectiveWithFailedLookupLocations; /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ function getAutomaticTypeDirectiveNames(options: CompilerOptions, host: ModuleResolutionHost): string[]; /** * Cached module resolutions per containing directory. @@ -2903,6 +3123,87 @@ declare namespace ts { function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations; function classicNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: NonRelativeModuleNameResolutionCache): ResolvedModuleWithFailedLookupLocations; } +declare namespace ts { + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node: T, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T; + /** + * Visits a Node using the supplied visitor, possibly returning a new Node in its place. + * + * @param node The Node to visit. + * @param visitor The callback used to visit the Node. + * @param test A callback to execute to verify the Node is valid. + * @param lift An optional callback to execute to lift a NodeArray into a valid Node. + */ + function visitNode(node: T | undefined, visitor: Visitor, test?: (node: Node) => boolean, lift?: (node: NodeArray) => T): T | undefined; + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes: NodeArray, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray; + /** + * Visits a NodeArray using the supplied visitor, possibly returning a new NodeArray in its place. + * + * @param nodes The NodeArray to visit. + * @param visitor The callback used to visit a Node. + * @param test A node test to execute for each node. + * @param start An optional value indicating the starting offset at which to start visiting. + * @param count An optional value indicating the maximum number of nodes to visit. + */ + function visitNodes(nodes: NodeArray | undefined, visitor: Visitor, test?: (node: Node) => boolean, start?: number, count?: number): NodeArray | undefined; + /** + * Starts a new lexical environment and visits a statement list, ending the lexical environment + * and merging hoisted declarations upon completion. + */ + function visitLexicalEnvironment(statements: NodeArray, visitor: Visitor, context: TransformationContext, start?: number, ensureUseStrict?: boolean): NodeArray; + /** + * Starts a new lexical environment and visits a parameter list, suspending the lexical + * environment upon completion. + */ + function visitParameterList(nodes: NodeArray, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes): NodeArray; + /** + * Resumes a suspended lexical environment and visits a function body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + function visitFunctionBody(node: FunctionBody, visitor: Visitor, context: TransformationContext): FunctionBody; + /** + * Resumes a suspended lexical environment and visits a function body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + function visitFunctionBody(node: FunctionBody | undefined, visitor: Visitor, context: TransformationContext): FunctionBody | undefined; + /** + * Resumes a suspended lexical environment and visits a concise body, ending the lexical + * environment and merging hoisted declarations upon completion. + */ + function visitFunctionBody(node: ConciseBody, visitor: Visitor, context: TransformationContext): ConciseBody; + /** + * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. + * + * @param node The Node whose children will be visited. + * @param visitor The callback used to visit each child. + * @param context A lexical environment context for the visitor. + */ + function visitEachChild(node: T, visitor: Visitor, context: TransformationContext): T; + /** + * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. + * + * @param node The Node whose children will be visited. + * @param visitor The callback used to visit each child. + * @param context A lexical environment context for the visitor. + */ + function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; +} declare namespace ts { function createPrinter(printerOptions?: PrinterOptions, handlers?: PrintHandlers): Printer; } @@ -2923,31 +3224,31 @@ declare namespace ts { declare namespace ts { function parseCommandLine(commandLine: string[], readFile?: (path: string) => string): ParsedCommandLine; /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ + * Read tsconfig.json file + * @param fileName The path to the config file + */ function readConfigFile(fileName: string, readFile: (path: string) => string): { config?: any; error?: Diagnostic; }; /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ function parseConfigFileTextToJson(fileName: string, jsonText: string, stripComments?: boolean): { config?: any; error?: Diagnostic; }; /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @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, configFileName?: string, resolutionStack?: Path[], extraFileExtensions?: JsFileExtensionInfo[]): ParsedCommandLine; - function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean; + function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined; function convertCompilerOptionsFromJson(jsonOptions: any, basePath: string, configFileName?: string): { options: CompilerOptions; errors: Diagnostic[]; @@ -2973,12 +3274,14 @@ declare namespace ts { getText(sourceFile?: SourceFile): string; getFirstToken(sourceFile?: SourceFile): Node; getLastToken(sourceFile?: SourceFile): Node; + forEachChild(cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T; } interface Symbol { getFlags(): SymbolFlags; getName(): string; getDeclarations(): Declaration[]; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface Type { getFlags(): TypeFlags; @@ -2995,10 +3298,11 @@ declare namespace ts { } interface Signature { getDeclaration(): SignatureDeclaration; - getTypeParameters(): Type[]; + getTypeParameters(): TypeParameter[]; getParameters(): Symbol[]; getReturnType(): Type; getDocumentationComment(): SymbolDisplayPart[]; + getJsDocTags(): JSDocTagInfo[]; } interface SourceFile { getLineAndCharacterOfPosition(pos: number): LineAndCharacter; @@ -3007,6 +3311,9 @@ declare namespace ts { getPositionOfLineAndCharacter(line: number, character: number): number; update(newText: string, textChangeRange: TextChangeRange): SourceFile; } + interface SourceFileLike { + getLineAndCharacterOfPosition(pos: number): LineAndCharacter; + } /** * Represents an immutable snapshot of a script at a specified time.Once acquired, the * snapshot is observably immutable. i.e. the same calls with the same parameters will return @@ -3065,6 +3372,10 @@ declare namespace ts { resolveTypeReferenceDirectives?(typeDirectiveNames: string[], containingFile: string): ResolvedTypeReferenceDirective[]; directoryExists?(directoryName: string): boolean; getDirectories?(directoryName: string): string[]; + /** + * Gets a set of custom transformers to use during emit. + */ + getCustomTransformers?(): CustomTransformers | undefined; } interface LanguageService { cleanupSemanticCache(): void; @@ -3110,7 +3421,7 @@ declare namespace ts { getFormattingEditsAfterKeystroke(fileName: string, position: number, key: string, options: FormatCodeOptions | FormatCodeSettings): TextChange[]; getDocCommentTemplateAtPosition(fileName: string, position: number): TextInsertion; isValidBraceCompletionAtPosition(fileName: string, position: number, openingBrace: number): boolean; - getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[]): CodeAction[]; + getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: number[], formatOptions: FormatCodeSettings): CodeAction[]; getEmitOutput(fileName: string, emitOnlyDtsFiles?: boolean): EmitOutput; getProgram(): Program; dispose(): void; @@ -3186,19 +3497,20 @@ declare namespace ts { /** The position in newText the caret should point to after the insertion. */ caretOffset: number; } - interface RenameLocation { + interface DocumentSpan { textSpan: TextSpan; fileName: string; } - interface ReferenceEntry { - textSpan: TextSpan; - fileName: string; + interface RenameLocation extends DocumentSpan { + } + interface ReferenceEntry extends DocumentSpan { isWriteAccess: boolean; isDefinition: boolean; + isInString?: true; } - interface ImplementationLocation { - textSpan: TextSpan; - fileName: string; + interface ImplementationLocation extends DocumentSpan { + kind: string; + displayParts: SymbolDisplayPart[]; } interface DocumentHighlights { fileName: string; @@ -3212,6 +3524,7 @@ declare namespace ts { } interface HighlightSpan { fileName?: string; + isInString?: true; textSpan: TextSpan; kind: string; } @@ -3324,12 +3637,17 @@ declare namespace ts { text: string; kind: string; } + interface JSDocTagInfo { + name: string; + text?: string; + } interface QuickInfo { kind: string; kindModifiers: string; textSpan: TextSpan; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface RenameInfo { canRename: boolean; @@ -3360,6 +3678,7 @@ declare namespace ts { separatorDisplayParts: SymbolDisplayPart[]; parameters: SignatureHelpParameter[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } /** * Represents a set of signature help items, and the preferred item that should be selected. @@ -3386,10 +3705,10 @@ declare namespace ts { kindModifiers: string; sortText: string; /** - * An optional span that indicates the text to be replaced by this completion item. It will be - * set if the required span differs from the one generated by the default replacement behavior and should - * be used in that case - */ + * An optional span that indicates the text to be replaced by this completion item. It will be + * set if the required span differs from the one generated by the default replacement behavior and should + * be used in that case + */ replacementSpan?: TextSpan; } interface CompletionEntryDetails { @@ -3398,6 +3717,7 @@ declare namespace ts { kindModifiers: string; displayParts: SymbolDisplayPart[]; documentation: SymbolDisplayPart[]; + tags: JSDocTagInfo[]; } interface OutliningSpan { /** The span of the document to actually collapse. */ @@ -3407,9 +3727,9 @@ declare namespace ts { /** The text to display in the editor for the collapsed region. */ bannerText: string; /** - * Whether or not this region should be automatically collapsed when - * the 'Collapse to Definitions' command is invoked. - */ + * Whether or not this region should be automatically collapsed when + * the 'Collapse to Definitions' command is invoked. + */ autoCollapse: boolean; } interface EmitOutput { @@ -3497,7 +3817,7 @@ declare namespace ts { const typeElement = "type"; /** enum E */ const enumElement = "enum"; - const enumMemberElement = "const"; + const enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. @@ -3542,7 +3862,7 @@ declare namespace ts { const externalModuleName = "external module name"; /** * - **/ + */ const jsxAttribute = "JSX attribute"; } namespace ScriptElementKindModifier { @@ -3612,61 +3932,61 @@ declare namespace ts { } declare namespace ts { /** - * The document registry represents a store of SourceFile objects that can be shared between - * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) - * of files in the context. - * SourceFile objects account for most of the memory usage by the language service. Sharing - * the same DocumentRegistry instance between different instances of LanguageService allow - * for more efficient memory utilization since all projects will share at least the library - * file (lib.d.ts). - * - * A more advanced use of the document registry is to serialize sourceFile objects to disk - * and re-hydrate them when needed. - * - * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it - * to all subsequent createLanguageService calls. - */ + * The document registry represents a store of SourceFile objects that can be shared between + * multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) + * of files in the context. + * SourceFile objects account for most of the memory usage by the language service. Sharing + * the same DocumentRegistry instance between different instances of LanguageService allow + * for more efficient memory utilization since all projects will share at least the library + * file (lib.d.ts). + * + * A more advanced use of the document registry is to serialize sourceFile objects to disk + * and re-hydrate them when needed. + * + * To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it + * to all subsequent createLanguageService calls. + */ interface DocumentRegistry { /** - * Request a stored SourceFile with a given fileName and compilationSettings. - * The first call to acquire will call createLanguageServiceSourceFile to generate - * the SourceFile if was not found in the registry. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @parm scriptSnapshot Text of the file. Only used if the file was not found - * in the registry and a new one was created. - * @parm version Current version of the file. Only used if the file was not found - * in the registry and a new one was created. - */ + * Request a stored SourceFile with a given fileName and compilationSettings. + * The first call to acquire will call createLanguageServiceSourceFile to generate + * the SourceFile if was not found in the registry. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @parm scriptSnapshot Text of the file. Only used if the file was not found + * in the registry and a new one was created. + * @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, scriptKind?: ScriptKind): SourceFile; acquireDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, 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 - * to get an updated SourceFile. - * - * @param fileName The name of the file requested - * @param compilationSettings Some compilation settings like target affects the - * shape of a the resulting SourceFile. This allows the DocumentRegistry to store - * multiple copies of the same file for different compilation settings. - * @param scriptSnapshot Text of the file. - * @param version Current version of the file. - */ + * Request an updated version of an already existing SourceFile with a given fileName + * and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile + * to get an updated SourceFile. + * + * @param fileName The name of the file requested + * @param compilationSettings Some compilation settings like target affects the + * shape of a the resulting SourceFile. This allows the DocumentRegistry to store + * multiple copies of the same file for different compilation settings. + * @param scriptSnapshot Text of the file. + * @param version Current version of the file. + */ updateDocument(fileName: string, compilationSettings: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; updateDocumentWithKey(fileName: string, path: Path, compilationSettings: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: string, scriptKind?: ScriptKind): SourceFile; getKeyForCompilationSettings(settings: CompilerOptions): DocumentRegistryBucketKey; /** - * Informs the DocumentRegistry that a file is not needed any longer. - * - * Note: It is not allowed to call release on a SourceFile that was not acquired from - * this registry originally. - * - * @param fileName The name of the file to be released - * @param compilationSettings The compilation settings used to acquire the file - */ + * Informs the DocumentRegistry that a file is not needed any longer. + * + * Note: It is not allowed to call release on a SourceFile that was not acquired from + * this registry originally. + * + * @param fileName The name of the file to be released + * @param compilationSettings The compilation settings used to acquire the file + */ releaseDocument(fileName: string, compilationSettings: CompilerOptions): void; releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey): void; reportStats(): string; @@ -3710,9 +4030,18 @@ declare namespace ts { function updateLanguageServiceSourceFile(sourceFile: SourceFile, scriptSnapshot: IScriptSnapshot, version: string, textChangeRange: TextChangeRange, aggressiveChecks?: boolean): SourceFile; function createLanguageService(host: LanguageServiceHost, documentRegistry?: DocumentRegistry): LanguageService; /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ function getDefaultLibFilePath(options: CompilerOptions): string; } +declare namespace ts { + /** + * Transform one or more nodes using the supplied transformers. + * @param source A single `Node` or an array of `Node` objects. + * @param transformers An array of `TransformerFactory` callbacks used to process the transformation. + * @param compilerOptions Optional compiler options. + */ + function transform(source: T | T[], transformers: TransformerFactory[], compilerOptions?: CompilerOptions): TransformationResult; +} diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index a8db5a7997f..4fe0eb9bf25 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -13,6 +13,14 @@ See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */ +var __assign = (this && this.__assign) || Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; +}; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || @@ -44,355 +52,353 @@ var ts; SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; SyntaxKind[SyntaxKind["StringLiteral"] = 9] = "StringLiteral"; SyntaxKind[SyntaxKind["JsxText"] = 10] = "JsxText"; - SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 11] = "RegularExpressionLiteral"; - SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 12] = "NoSubstitutionTemplateLiteral"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 11] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 12] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 13] = "NoSubstitutionTemplateLiteral"; // Pseudo-literals - SyntaxKind[SyntaxKind["TemplateHead"] = 13] = "TemplateHead"; - SyntaxKind[SyntaxKind["TemplateMiddle"] = 14] = "TemplateMiddle"; - SyntaxKind[SyntaxKind["TemplateTail"] = 15] = "TemplateTail"; + SyntaxKind[SyntaxKind["TemplateHead"] = 14] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 15] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 16] = "TemplateTail"; // Punctuation - SyntaxKind[SyntaxKind["OpenBraceToken"] = 16] = "OpenBraceToken"; - SyntaxKind[SyntaxKind["CloseBraceToken"] = 17] = "CloseBraceToken"; - SyntaxKind[SyntaxKind["OpenParenToken"] = 18] = "OpenParenToken"; - SyntaxKind[SyntaxKind["CloseParenToken"] = 19] = "CloseParenToken"; - SyntaxKind[SyntaxKind["OpenBracketToken"] = 20] = "OpenBracketToken"; - SyntaxKind[SyntaxKind["CloseBracketToken"] = 21] = "CloseBracketToken"; - SyntaxKind[SyntaxKind["DotToken"] = 22] = "DotToken"; - SyntaxKind[SyntaxKind["DotDotDotToken"] = 23] = "DotDotDotToken"; - SyntaxKind[SyntaxKind["SemicolonToken"] = 24] = "SemicolonToken"; - SyntaxKind[SyntaxKind["CommaToken"] = 25] = "CommaToken"; - SyntaxKind[SyntaxKind["LessThanToken"] = 26] = "LessThanToken"; - SyntaxKind[SyntaxKind["LessThanSlashToken"] = 27] = "LessThanSlashToken"; - SyntaxKind[SyntaxKind["GreaterThanToken"] = 28] = "GreaterThanToken"; - SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 29] = "LessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 30] = "GreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 31] = "EqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 32] = "ExclamationEqualsToken"; - SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 33] = "EqualsEqualsEqualsToken"; - SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 34] = "ExclamationEqualsEqualsToken"; - SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 35] = "EqualsGreaterThanToken"; - SyntaxKind[SyntaxKind["PlusToken"] = 36] = "PlusToken"; - SyntaxKind[SyntaxKind["MinusToken"] = 37] = "MinusToken"; - SyntaxKind[SyntaxKind["AsteriskToken"] = 38] = "AsteriskToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 39] = "AsteriskAsteriskToken"; - SyntaxKind[SyntaxKind["SlashToken"] = 40] = "SlashToken"; - SyntaxKind[SyntaxKind["PercentToken"] = 41] = "PercentToken"; - SyntaxKind[SyntaxKind["PlusPlusToken"] = 42] = "PlusPlusToken"; - SyntaxKind[SyntaxKind["MinusMinusToken"] = 43] = "MinusMinusToken"; - SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 44] = "LessThanLessThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 45] = "GreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanGreaterThanToken"; - SyntaxKind[SyntaxKind["AmpersandToken"] = 47] = "AmpersandToken"; - SyntaxKind[SyntaxKind["BarToken"] = 48] = "BarToken"; - SyntaxKind[SyntaxKind["CaretToken"] = 49] = "CaretToken"; - SyntaxKind[SyntaxKind["ExclamationToken"] = 50] = "ExclamationToken"; - SyntaxKind[SyntaxKind["TildeToken"] = 51] = "TildeToken"; - SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 52] = "AmpersandAmpersandToken"; - SyntaxKind[SyntaxKind["BarBarToken"] = 53] = "BarBarToken"; - SyntaxKind[SyntaxKind["QuestionToken"] = 54] = "QuestionToken"; - SyntaxKind[SyntaxKind["ColonToken"] = 55] = "ColonToken"; - SyntaxKind[SyntaxKind["AtToken"] = 56] = "AtToken"; + SyntaxKind[SyntaxKind["OpenBraceToken"] = 17] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 18] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 19] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 20] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 21] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 22] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 23] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 24] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 25] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 26] = "CommaToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 27] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 28] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 29] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 30] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 31] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 32] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 33] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 34] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 35] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 36] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 37] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 38] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 39] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 40] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 41] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 42] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 43] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 44] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 45] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 46] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 47] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 48] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 49] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 50] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 51] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 52] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 53] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 54] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 55] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 56] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 57] = "AtToken"; // Assignments - SyntaxKind[SyntaxKind["EqualsToken"] = 57] = "EqualsToken"; - SyntaxKind[SyntaxKind["PlusEqualsToken"] = 58] = "PlusEqualsToken"; - SyntaxKind[SyntaxKind["MinusEqualsToken"] = 59] = "MinusEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 60] = "AsteriskEqualsToken"; - SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 61] = "AsteriskAsteriskEqualsToken"; - SyntaxKind[SyntaxKind["SlashEqualsToken"] = 62] = "SlashEqualsToken"; - SyntaxKind[SyntaxKind["PercentEqualsToken"] = 63] = "PercentEqualsToken"; - SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 64] = "LessThanLessThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 65] = "GreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanGreaterThanEqualsToken"; - SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 67] = "AmpersandEqualsToken"; - SyntaxKind[SyntaxKind["BarEqualsToken"] = 68] = "BarEqualsToken"; - SyntaxKind[SyntaxKind["CaretEqualsToken"] = 69] = "CaretEqualsToken"; + SyntaxKind[SyntaxKind["EqualsToken"] = 58] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 59] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 60] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 61] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 62] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 63] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 64] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 65] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 66] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 67] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 68] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 69] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 70] = "CaretEqualsToken"; // Identifiers - SyntaxKind[SyntaxKind["Identifier"] = 70] = "Identifier"; + SyntaxKind[SyntaxKind["Identifier"] = 71] = "Identifier"; // Reserved words - SyntaxKind[SyntaxKind["BreakKeyword"] = 71] = "BreakKeyword"; - SyntaxKind[SyntaxKind["CaseKeyword"] = 72] = "CaseKeyword"; - SyntaxKind[SyntaxKind["CatchKeyword"] = 73] = "CatchKeyword"; - SyntaxKind[SyntaxKind["ClassKeyword"] = 74] = "ClassKeyword"; - SyntaxKind[SyntaxKind["ConstKeyword"] = 75] = "ConstKeyword"; - SyntaxKind[SyntaxKind["ContinueKeyword"] = 76] = "ContinueKeyword"; - SyntaxKind[SyntaxKind["DebuggerKeyword"] = 77] = "DebuggerKeyword"; - SyntaxKind[SyntaxKind["DefaultKeyword"] = 78] = "DefaultKeyword"; - SyntaxKind[SyntaxKind["DeleteKeyword"] = 79] = "DeleteKeyword"; - SyntaxKind[SyntaxKind["DoKeyword"] = 80] = "DoKeyword"; - SyntaxKind[SyntaxKind["ElseKeyword"] = 81] = "ElseKeyword"; - SyntaxKind[SyntaxKind["EnumKeyword"] = 82] = "EnumKeyword"; - SyntaxKind[SyntaxKind["ExportKeyword"] = 83] = "ExportKeyword"; - SyntaxKind[SyntaxKind["ExtendsKeyword"] = 84] = "ExtendsKeyword"; - SyntaxKind[SyntaxKind["FalseKeyword"] = 85] = "FalseKeyword"; - SyntaxKind[SyntaxKind["FinallyKeyword"] = 86] = "FinallyKeyword"; - SyntaxKind[SyntaxKind["ForKeyword"] = 87] = "ForKeyword"; - SyntaxKind[SyntaxKind["FunctionKeyword"] = 88] = "FunctionKeyword"; - SyntaxKind[SyntaxKind["IfKeyword"] = 89] = "IfKeyword"; - SyntaxKind[SyntaxKind["ImportKeyword"] = 90] = "ImportKeyword"; - SyntaxKind[SyntaxKind["InKeyword"] = 91] = "InKeyword"; - SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 92] = "InstanceOfKeyword"; - SyntaxKind[SyntaxKind["NewKeyword"] = 93] = "NewKeyword"; - SyntaxKind[SyntaxKind["NullKeyword"] = 94] = "NullKeyword"; - SyntaxKind[SyntaxKind["ReturnKeyword"] = 95] = "ReturnKeyword"; - SyntaxKind[SyntaxKind["SuperKeyword"] = 96] = "SuperKeyword"; - SyntaxKind[SyntaxKind["SwitchKeyword"] = 97] = "SwitchKeyword"; - SyntaxKind[SyntaxKind["ThisKeyword"] = 98] = "ThisKeyword"; - SyntaxKind[SyntaxKind["ThrowKeyword"] = 99] = "ThrowKeyword"; - SyntaxKind[SyntaxKind["TrueKeyword"] = 100] = "TrueKeyword"; - SyntaxKind[SyntaxKind["TryKeyword"] = 101] = "TryKeyword"; - SyntaxKind[SyntaxKind["TypeOfKeyword"] = 102] = "TypeOfKeyword"; - SyntaxKind[SyntaxKind["VarKeyword"] = 103] = "VarKeyword"; - SyntaxKind[SyntaxKind["VoidKeyword"] = 104] = "VoidKeyword"; - SyntaxKind[SyntaxKind["WhileKeyword"] = 105] = "WhileKeyword"; - SyntaxKind[SyntaxKind["WithKeyword"] = 106] = "WithKeyword"; + SyntaxKind[SyntaxKind["BreakKeyword"] = 72] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 73] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 74] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 75] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 76] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 77] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 78] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 79] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 80] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 81] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 82] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 83] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 84] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 85] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 86] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 87] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 88] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 89] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 90] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 91] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 92] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 93] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 94] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 95] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 96] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 97] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 98] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 99] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 100] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 101] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 102] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 103] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 104] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 105] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 106] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 107] = "WithKeyword"; // Strict mode reserved words - SyntaxKind[SyntaxKind["ImplementsKeyword"] = 107] = "ImplementsKeyword"; - SyntaxKind[SyntaxKind["InterfaceKeyword"] = 108] = "InterfaceKeyword"; - SyntaxKind[SyntaxKind["LetKeyword"] = 109] = "LetKeyword"; - SyntaxKind[SyntaxKind["PackageKeyword"] = 110] = "PackageKeyword"; - SyntaxKind[SyntaxKind["PrivateKeyword"] = 111] = "PrivateKeyword"; - SyntaxKind[SyntaxKind["ProtectedKeyword"] = 112] = "ProtectedKeyword"; - SyntaxKind[SyntaxKind["PublicKeyword"] = 113] = "PublicKeyword"; - SyntaxKind[SyntaxKind["StaticKeyword"] = 114] = "StaticKeyword"; - SyntaxKind[SyntaxKind["YieldKeyword"] = 115] = "YieldKeyword"; + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 108] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 109] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 110] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 111] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 112] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 113] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 114] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 115] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 116] = "YieldKeyword"; // Contextual keywords - SyntaxKind[SyntaxKind["AbstractKeyword"] = 116] = "AbstractKeyword"; - SyntaxKind[SyntaxKind["AsKeyword"] = 117] = "AsKeyword"; - SyntaxKind[SyntaxKind["AnyKeyword"] = 118] = "AnyKeyword"; - SyntaxKind[SyntaxKind["AsyncKeyword"] = 119] = "AsyncKeyword"; - SyntaxKind[SyntaxKind["AwaitKeyword"] = 120] = "AwaitKeyword"; - SyntaxKind[SyntaxKind["BooleanKeyword"] = 121] = "BooleanKeyword"; - SyntaxKind[SyntaxKind["ConstructorKeyword"] = 122] = "ConstructorKeyword"; - SyntaxKind[SyntaxKind["DeclareKeyword"] = 123] = "DeclareKeyword"; - SyntaxKind[SyntaxKind["GetKeyword"] = 124] = "GetKeyword"; - SyntaxKind[SyntaxKind["IsKeyword"] = 125] = "IsKeyword"; - SyntaxKind[SyntaxKind["KeyOfKeyword"] = 126] = "KeyOfKeyword"; - SyntaxKind[SyntaxKind["ModuleKeyword"] = 127] = "ModuleKeyword"; - SyntaxKind[SyntaxKind["NamespaceKeyword"] = 128] = "NamespaceKeyword"; - SyntaxKind[SyntaxKind["NeverKeyword"] = 129] = "NeverKeyword"; - SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 130] = "ReadonlyKeyword"; - SyntaxKind[SyntaxKind["RequireKeyword"] = 131] = "RequireKeyword"; - SyntaxKind[SyntaxKind["NumberKeyword"] = 132] = "NumberKeyword"; - SyntaxKind[SyntaxKind["ObjectKeyword"] = 133] = "ObjectKeyword"; - SyntaxKind[SyntaxKind["SetKeyword"] = 134] = "SetKeyword"; - SyntaxKind[SyntaxKind["StringKeyword"] = 135] = "StringKeyword"; - SyntaxKind[SyntaxKind["SymbolKeyword"] = 136] = "SymbolKeyword"; - SyntaxKind[SyntaxKind["TypeKeyword"] = 137] = "TypeKeyword"; - SyntaxKind[SyntaxKind["UndefinedKeyword"] = 138] = "UndefinedKeyword"; - SyntaxKind[SyntaxKind["FromKeyword"] = 139] = "FromKeyword"; - SyntaxKind[SyntaxKind["GlobalKeyword"] = 140] = "GlobalKeyword"; - SyntaxKind[SyntaxKind["OfKeyword"] = 141] = "OfKeyword"; + SyntaxKind[SyntaxKind["AbstractKeyword"] = 117] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 118] = "AsKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 119] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 120] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 121] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 122] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 123] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 124] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 125] = "GetKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 126] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 127] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 128] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 129] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 130] = "NeverKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 131] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 132] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 133] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 134] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 135] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 136] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 137] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 138] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 139] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 140] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 141] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 142] = "OfKeyword"; // Parse tree nodes // Names - SyntaxKind[SyntaxKind["QualifiedName"] = 142] = "QualifiedName"; - SyntaxKind[SyntaxKind["ComputedPropertyName"] = 143] = "ComputedPropertyName"; + SyntaxKind[SyntaxKind["QualifiedName"] = 143] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 144] = "ComputedPropertyName"; // Signature elements - SyntaxKind[SyntaxKind["TypeParameter"] = 144] = "TypeParameter"; - SyntaxKind[SyntaxKind["Parameter"] = 145] = "Parameter"; - SyntaxKind[SyntaxKind["Decorator"] = 146] = "Decorator"; + SyntaxKind[SyntaxKind["TypeParameter"] = 145] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 146] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 147] = "Decorator"; // TypeMember - SyntaxKind[SyntaxKind["PropertySignature"] = 147] = "PropertySignature"; - SyntaxKind[SyntaxKind["PropertyDeclaration"] = 148] = "PropertyDeclaration"; - SyntaxKind[SyntaxKind["MethodSignature"] = 149] = "MethodSignature"; - SyntaxKind[SyntaxKind["MethodDeclaration"] = 150] = "MethodDeclaration"; - SyntaxKind[SyntaxKind["Constructor"] = 151] = "Constructor"; - SyntaxKind[SyntaxKind["GetAccessor"] = 152] = "GetAccessor"; - SyntaxKind[SyntaxKind["SetAccessor"] = 153] = "SetAccessor"; - SyntaxKind[SyntaxKind["CallSignature"] = 154] = "CallSignature"; - SyntaxKind[SyntaxKind["ConstructSignature"] = 155] = "ConstructSignature"; - SyntaxKind[SyntaxKind["IndexSignature"] = 156] = "IndexSignature"; + SyntaxKind[SyntaxKind["PropertySignature"] = 148] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 149] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 150] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 151] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 152] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 153] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 154] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 155] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 156] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 157] = "IndexSignature"; // Type - SyntaxKind[SyntaxKind["TypePredicate"] = 157] = "TypePredicate"; - SyntaxKind[SyntaxKind["TypeReference"] = 158] = "TypeReference"; - SyntaxKind[SyntaxKind["FunctionType"] = 159] = "FunctionType"; - SyntaxKind[SyntaxKind["ConstructorType"] = 160] = "ConstructorType"; - SyntaxKind[SyntaxKind["TypeQuery"] = 161] = "TypeQuery"; - SyntaxKind[SyntaxKind["TypeLiteral"] = 162] = "TypeLiteral"; - SyntaxKind[SyntaxKind["ArrayType"] = 163] = "ArrayType"; - SyntaxKind[SyntaxKind["TupleType"] = 164] = "TupleType"; - SyntaxKind[SyntaxKind["UnionType"] = 165] = "UnionType"; - SyntaxKind[SyntaxKind["IntersectionType"] = 166] = "IntersectionType"; - SyntaxKind[SyntaxKind["ParenthesizedType"] = 167] = "ParenthesizedType"; - SyntaxKind[SyntaxKind["ThisType"] = 168] = "ThisType"; - SyntaxKind[SyntaxKind["TypeOperator"] = 169] = "TypeOperator"; - SyntaxKind[SyntaxKind["IndexedAccessType"] = 170] = "IndexedAccessType"; - SyntaxKind[SyntaxKind["MappedType"] = 171] = "MappedType"; - SyntaxKind[SyntaxKind["LiteralType"] = 172] = "LiteralType"; + SyntaxKind[SyntaxKind["TypePredicate"] = 158] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 159] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 160] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 161] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 162] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 163] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 164] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 165] = "TupleType"; + SyntaxKind[SyntaxKind["UnionType"] = 166] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 167] = "IntersectionType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 168] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 169] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 170] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 171] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 172] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 173] = "LiteralType"; // Binding patterns - SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 173] = "ObjectBindingPattern"; - SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 174] = "ArrayBindingPattern"; - SyntaxKind[SyntaxKind["BindingElement"] = 175] = "BindingElement"; + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 174] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 175] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 176] = "BindingElement"; // Expression - SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 176] = "ArrayLiteralExpression"; - SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 177] = "ObjectLiteralExpression"; - SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 178] = "PropertyAccessExpression"; - SyntaxKind[SyntaxKind["ElementAccessExpression"] = 179] = "ElementAccessExpression"; - SyntaxKind[SyntaxKind["CallExpression"] = 180] = "CallExpression"; - SyntaxKind[SyntaxKind["NewExpression"] = 181] = "NewExpression"; - SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 182] = "TaggedTemplateExpression"; - SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 183] = "TypeAssertionExpression"; - SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 184] = "ParenthesizedExpression"; - SyntaxKind[SyntaxKind["FunctionExpression"] = 185] = "FunctionExpression"; - SyntaxKind[SyntaxKind["ArrowFunction"] = 186] = "ArrowFunction"; - SyntaxKind[SyntaxKind["DeleteExpression"] = 187] = "DeleteExpression"; - SyntaxKind[SyntaxKind["TypeOfExpression"] = 188] = "TypeOfExpression"; - SyntaxKind[SyntaxKind["VoidExpression"] = 189] = "VoidExpression"; - SyntaxKind[SyntaxKind["AwaitExpression"] = 190] = "AwaitExpression"; - SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 191] = "PrefixUnaryExpression"; - SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 192] = "PostfixUnaryExpression"; - SyntaxKind[SyntaxKind["BinaryExpression"] = 193] = "BinaryExpression"; - SyntaxKind[SyntaxKind["ConditionalExpression"] = 194] = "ConditionalExpression"; - SyntaxKind[SyntaxKind["TemplateExpression"] = 195] = "TemplateExpression"; - SyntaxKind[SyntaxKind["YieldExpression"] = 196] = "YieldExpression"; - SyntaxKind[SyntaxKind["SpreadElement"] = 197] = "SpreadElement"; - SyntaxKind[SyntaxKind["ClassExpression"] = 198] = "ClassExpression"; - SyntaxKind[SyntaxKind["OmittedExpression"] = 199] = "OmittedExpression"; - SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 200] = "ExpressionWithTypeArguments"; - SyntaxKind[SyntaxKind["AsExpression"] = 201] = "AsExpression"; - SyntaxKind[SyntaxKind["NonNullExpression"] = 202] = "NonNullExpression"; - SyntaxKind[SyntaxKind["MetaProperty"] = 203] = "MetaProperty"; + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 177] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 178] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 179] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 180] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 181] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 182] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 183] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 184] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 185] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 186] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 187] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 188] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 189] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 190] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 191] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 192] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 193] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 194] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 195] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 196] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 197] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 198] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 199] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 200] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 201] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 202] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 203] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 204] = "MetaProperty"; // Misc - SyntaxKind[SyntaxKind["TemplateSpan"] = 204] = "TemplateSpan"; - SyntaxKind[SyntaxKind["SemicolonClassElement"] = 205] = "SemicolonClassElement"; + SyntaxKind[SyntaxKind["TemplateSpan"] = 205] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 206] = "SemicolonClassElement"; // Element - SyntaxKind[SyntaxKind["Block"] = 206] = "Block"; - SyntaxKind[SyntaxKind["VariableStatement"] = 207] = "VariableStatement"; - SyntaxKind[SyntaxKind["EmptyStatement"] = 208] = "EmptyStatement"; - SyntaxKind[SyntaxKind["ExpressionStatement"] = 209] = "ExpressionStatement"; - SyntaxKind[SyntaxKind["IfStatement"] = 210] = "IfStatement"; - SyntaxKind[SyntaxKind["DoStatement"] = 211] = "DoStatement"; - SyntaxKind[SyntaxKind["WhileStatement"] = 212] = "WhileStatement"; - SyntaxKind[SyntaxKind["ForStatement"] = 213] = "ForStatement"; - SyntaxKind[SyntaxKind["ForInStatement"] = 214] = "ForInStatement"; - SyntaxKind[SyntaxKind["ForOfStatement"] = 215] = "ForOfStatement"; - SyntaxKind[SyntaxKind["ContinueStatement"] = 216] = "ContinueStatement"; - SyntaxKind[SyntaxKind["BreakStatement"] = 217] = "BreakStatement"; - SyntaxKind[SyntaxKind["ReturnStatement"] = 218] = "ReturnStatement"; - SyntaxKind[SyntaxKind["WithStatement"] = 219] = "WithStatement"; - SyntaxKind[SyntaxKind["SwitchStatement"] = 220] = "SwitchStatement"; - SyntaxKind[SyntaxKind["LabeledStatement"] = 221] = "LabeledStatement"; - SyntaxKind[SyntaxKind["ThrowStatement"] = 222] = "ThrowStatement"; - SyntaxKind[SyntaxKind["TryStatement"] = 223] = "TryStatement"; - SyntaxKind[SyntaxKind["DebuggerStatement"] = 224] = "DebuggerStatement"; - SyntaxKind[SyntaxKind["VariableDeclaration"] = 225] = "VariableDeclaration"; - SyntaxKind[SyntaxKind["VariableDeclarationList"] = 226] = "VariableDeclarationList"; - SyntaxKind[SyntaxKind["FunctionDeclaration"] = 227] = "FunctionDeclaration"; - SyntaxKind[SyntaxKind["ClassDeclaration"] = 228] = "ClassDeclaration"; - SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 229] = "InterfaceDeclaration"; - SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 230] = "TypeAliasDeclaration"; - SyntaxKind[SyntaxKind["EnumDeclaration"] = 231] = "EnumDeclaration"; - SyntaxKind[SyntaxKind["ModuleDeclaration"] = 232] = "ModuleDeclaration"; - SyntaxKind[SyntaxKind["ModuleBlock"] = 233] = "ModuleBlock"; - SyntaxKind[SyntaxKind["CaseBlock"] = 234] = "CaseBlock"; - SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 235] = "NamespaceExportDeclaration"; - SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 236] = "ImportEqualsDeclaration"; - SyntaxKind[SyntaxKind["ImportDeclaration"] = 237] = "ImportDeclaration"; - SyntaxKind[SyntaxKind["ImportClause"] = 238] = "ImportClause"; - SyntaxKind[SyntaxKind["NamespaceImport"] = 239] = "NamespaceImport"; - SyntaxKind[SyntaxKind["NamedImports"] = 240] = "NamedImports"; - SyntaxKind[SyntaxKind["ImportSpecifier"] = 241] = "ImportSpecifier"; - SyntaxKind[SyntaxKind["ExportAssignment"] = 242] = "ExportAssignment"; - SyntaxKind[SyntaxKind["ExportDeclaration"] = 243] = "ExportDeclaration"; - SyntaxKind[SyntaxKind["NamedExports"] = 244] = "NamedExports"; - SyntaxKind[SyntaxKind["ExportSpecifier"] = 245] = "ExportSpecifier"; - SyntaxKind[SyntaxKind["MissingDeclaration"] = 246] = "MissingDeclaration"; + SyntaxKind[SyntaxKind["Block"] = 207] = "Block"; + SyntaxKind[SyntaxKind["VariableStatement"] = 208] = "VariableStatement"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 209] = "EmptyStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 210] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 211] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 212] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 213] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 214] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 215] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 216] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 217] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 218] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 219] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 220] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 221] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 222] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 223] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 224] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 225] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 226] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 227] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 228] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 229] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 230] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 231] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 232] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 233] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 234] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 235] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 236] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 237] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 238] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 239] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 240] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 241] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 242] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 243] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 244] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 245] = "NamedExports"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 246] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 247] = "MissingDeclaration"; // Module references - SyntaxKind[SyntaxKind["ExternalModuleReference"] = 247] = "ExternalModuleReference"; + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 248] = "ExternalModuleReference"; // JSX - SyntaxKind[SyntaxKind["JsxElement"] = 248] = "JsxElement"; - SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 249] = "JsxSelfClosingElement"; - SyntaxKind[SyntaxKind["JsxOpeningElement"] = 250] = "JsxOpeningElement"; - SyntaxKind[SyntaxKind["JsxClosingElement"] = 251] = "JsxClosingElement"; - SyntaxKind[SyntaxKind["JsxAttribute"] = 252] = "JsxAttribute"; - SyntaxKind[SyntaxKind["JsxAttributes"] = 253] = "JsxAttributes"; - SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 254] = "JsxSpreadAttribute"; - SyntaxKind[SyntaxKind["JsxExpression"] = 255] = "JsxExpression"; + SyntaxKind[SyntaxKind["JsxElement"] = 249] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 250] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 251] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 252] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 253] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 254] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 255] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 256] = "JsxExpression"; // Clauses - SyntaxKind[SyntaxKind["CaseClause"] = 256] = "CaseClause"; - SyntaxKind[SyntaxKind["DefaultClause"] = 257] = "DefaultClause"; - SyntaxKind[SyntaxKind["HeritageClause"] = 258] = "HeritageClause"; - SyntaxKind[SyntaxKind["CatchClause"] = 259] = "CatchClause"; + SyntaxKind[SyntaxKind["CaseClause"] = 257] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 258] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 259] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 260] = "CatchClause"; // Property assignments - SyntaxKind[SyntaxKind["PropertyAssignment"] = 260] = "PropertyAssignment"; - SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 261] = "ShorthandPropertyAssignment"; - SyntaxKind[SyntaxKind["SpreadAssignment"] = 262] = "SpreadAssignment"; + SyntaxKind[SyntaxKind["PropertyAssignment"] = 261] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 262] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 263] = "SpreadAssignment"; // Enum - SyntaxKind[SyntaxKind["EnumMember"] = 263] = "EnumMember"; + SyntaxKind[SyntaxKind["EnumMember"] = 264] = "EnumMember"; // Top-level nodes - SyntaxKind[SyntaxKind["SourceFile"] = 264] = "SourceFile"; - SyntaxKind[SyntaxKind["Bundle"] = 265] = "Bundle"; + SyntaxKind[SyntaxKind["SourceFile"] = 265] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 266] = "Bundle"; // JSDoc nodes - SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 266] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 267] = "JSDocTypeExpression"; // The * type - SyntaxKind[SyntaxKind["JSDocAllType"] = 267] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 268] = "JSDocAllType"; // The ? type - SyntaxKind[SyntaxKind["JSDocUnknownType"] = 268] = "JSDocUnknownType"; - SyntaxKind[SyntaxKind["JSDocArrayType"] = 269] = "JSDocArrayType"; - SyntaxKind[SyntaxKind["JSDocUnionType"] = 270] = "JSDocUnionType"; - SyntaxKind[SyntaxKind["JSDocTupleType"] = 271] = "JSDocTupleType"; - SyntaxKind[SyntaxKind["JSDocNullableType"] = 272] = "JSDocNullableType"; - SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 273] = "JSDocNonNullableType"; - SyntaxKind[SyntaxKind["JSDocRecordType"] = 274] = "JSDocRecordType"; - SyntaxKind[SyntaxKind["JSDocRecordMember"] = 275] = "JSDocRecordMember"; - SyntaxKind[SyntaxKind["JSDocTypeReference"] = 276] = "JSDocTypeReference"; - SyntaxKind[SyntaxKind["JSDocOptionalType"] = 277] = "JSDocOptionalType"; - SyntaxKind[SyntaxKind["JSDocFunctionType"] = 278] = "JSDocFunctionType"; - SyntaxKind[SyntaxKind["JSDocVariadicType"] = 279] = "JSDocVariadicType"; - SyntaxKind[SyntaxKind["JSDocConstructorType"] = 280] = "JSDocConstructorType"; - SyntaxKind[SyntaxKind["JSDocThisType"] = 281] = "JSDocThisType"; - SyntaxKind[SyntaxKind["JSDocComment"] = 282] = "JSDocComment"; - SyntaxKind[SyntaxKind["JSDocTag"] = 283] = "JSDocTag"; - SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 284] = "JSDocAugmentsTag"; - SyntaxKind[SyntaxKind["JSDocParameterTag"] = 285] = "JSDocParameterTag"; - SyntaxKind[SyntaxKind["JSDocReturnTag"] = 286] = "JSDocReturnTag"; - SyntaxKind[SyntaxKind["JSDocTypeTag"] = 287] = "JSDocTypeTag"; - SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 288] = "JSDocTemplateTag"; - SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 289] = "JSDocTypedefTag"; - SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 290] = "JSDocPropertyTag"; - SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 291] = "JSDocTypeLiteral"; - SyntaxKind[SyntaxKind["JSDocLiteralType"] = 292] = "JSDocLiteralType"; - SyntaxKind[SyntaxKind["JSDocNullKeyword"] = 293] = "JSDocNullKeyword"; - SyntaxKind[SyntaxKind["JSDocUndefinedKeyword"] = 294] = "JSDocUndefinedKeyword"; - SyntaxKind[SyntaxKind["JSDocNeverKeyword"] = 295] = "JSDocNeverKeyword"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 269] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocArrayType"] = 270] = "JSDocArrayType"; + SyntaxKind[SyntaxKind["JSDocUnionType"] = 271] = "JSDocUnionType"; + SyntaxKind[SyntaxKind["JSDocTupleType"] = 272] = "JSDocTupleType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 273] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 274] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocRecordType"] = 275] = "JSDocRecordType"; + SyntaxKind[SyntaxKind["JSDocRecordMember"] = 276] = "JSDocRecordMember"; + SyntaxKind[SyntaxKind["JSDocTypeReference"] = 277] = "JSDocTypeReference"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 278] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 279] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 280] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocConstructorType"] = 281] = "JSDocConstructorType"; + SyntaxKind[SyntaxKind["JSDocThisType"] = 282] = "JSDocThisType"; + SyntaxKind[SyntaxKind["JSDocComment"] = 283] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocTag"] = 284] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 285] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 286] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 287] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 288] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 289] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 290] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 291] = "JSDocPropertyTag"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 292] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocLiteralType"] = 293] = "JSDocLiteralType"; // Synthesized list - SyntaxKind[SyntaxKind["SyntaxList"] = 296] = "SyntaxList"; + SyntaxKind[SyntaxKind["SyntaxList"] = 294] = "SyntaxList"; // Transformation nodes - SyntaxKind[SyntaxKind["NotEmittedStatement"] = 297] = "NotEmittedStatement"; - SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 298] = "PartiallyEmittedExpression"; - SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 299] = "MergeDeclarationMarker"; - SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 300] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 295] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 296] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 297] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 298] = "EndOfDeclarationMarker"; // Enum value count - SyntaxKind[SyntaxKind["Count"] = 301] = "Count"; + SyntaxKind[SyntaxKind["Count"] = 299] = "Count"; // Markers - SyntaxKind[SyntaxKind["FirstAssignment"] = 57] = "FirstAssignment"; - SyntaxKind[SyntaxKind["LastAssignment"] = 69] = "LastAssignment"; - SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 58] = "FirstCompoundAssignment"; - SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 69] = "LastCompoundAssignment"; - SyntaxKind[SyntaxKind["FirstReservedWord"] = 71] = "FirstReservedWord"; - SyntaxKind[SyntaxKind["LastReservedWord"] = 106] = "LastReservedWord"; - SyntaxKind[SyntaxKind["FirstKeyword"] = 71] = "FirstKeyword"; - SyntaxKind[SyntaxKind["LastKeyword"] = 141] = "LastKeyword"; - SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 107] = "FirstFutureReservedWord"; - SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 115] = "LastFutureReservedWord"; - SyntaxKind[SyntaxKind["FirstTypeNode"] = 157] = "FirstTypeNode"; - SyntaxKind[SyntaxKind["LastTypeNode"] = 172] = "LastTypeNode"; - SyntaxKind[SyntaxKind["FirstPunctuation"] = 16] = "FirstPunctuation"; - SyntaxKind[SyntaxKind["LastPunctuation"] = 69] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstAssignment"] = 58] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 70] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 59] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 70] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 72] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 107] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 72] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 142] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 108] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 116] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 158] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 173] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 17] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 70] = "LastPunctuation"; SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; - SyntaxKind[SyntaxKind["LastToken"] = 141] = "LastToken"; + SyntaxKind[SyntaxKind["LastToken"] = 142] = "LastToken"; SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; - SyntaxKind[SyntaxKind["LastLiteralToken"] = 12] = "LastLiteralToken"; - SyntaxKind[SyntaxKind["FirstTemplateToken"] = 12] = "FirstTemplateToken"; - SyntaxKind[SyntaxKind["LastTemplateToken"] = 15] = "LastTemplateToken"; - SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 26] = "FirstBinaryOperator"; - SyntaxKind[SyntaxKind["LastBinaryOperator"] = 69] = "LastBinaryOperator"; - SyntaxKind[SyntaxKind["FirstNode"] = 142] = "FirstNode"; - SyntaxKind[SyntaxKind["FirstJSDocNode"] = 266] = "FirstJSDocNode"; - SyntaxKind[SyntaxKind["LastJSDocNode"] = 295] = "LastJSDocNode"; - SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 282] = "FirstJSDocTagNode"; - SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 295] = "LastJSDocTagNode"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 13] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 13] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 16] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 27] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 70] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstNode"] = 143] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 267] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 293] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 283] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 293] = "LastJSDocTagNode"; })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); var NodeFlags; (function (NodeFlags) { @@ -471,6 +477,17 @@ var ts; GeneratedIdentifierKind[GeneratedIdentifierKind["Unique"] = 3] = "Unique"; GeneratedIdentifierKind[GeneratedIdentifierKind["Node"] = 4] = "Node"; })(GeneratedIdentifierKind = ts.GeneratedIdentifierKind || (ts.GeneratedIdentifierKind = {})); + /* @internal */ + var NumericLiteralFlags; + (function (NumericLiteralFlags) { + NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; + NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 2] = "Scientific"; + NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; + NumericLiteralFlags[NumericLiteralFlags["HexSpecifier"] = 8] = "HexSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinarySpecifier"] = 16] = "BinarySpecifier"; + NumericLiteralFlags[NumericLiteralFlags["OctalSpecifier"] = 32] = "OctalSpecifier"; + NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalSpecifier"] = 48] = "BinaryOrOctalSpecifier"; + })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); var FlowFlags; (function (FlowFlags) { FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; @@ -507,6 +524,16 @@ var ts; // Diagnostics were produced and outputs were generated in spite of them. ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + NodeBuilderFlags[NodeBuilderFlags["allowThisInObjectLiteral"] = 1] = "allowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["allowQualifedNameInPlaceOfIdentifier"] = 2] = "allowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowTypeParameterInQualifiedName"] = 4] = "allowTypeParameterInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["allowAnonymousIdentifier"] = 8] = "allowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyUnionOrIntersection"] = 16] = "allowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyTuple"] = 32] = "allowEmptyTuple"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); var TypeFormatFlags; (function (TypeFormatFlags) { TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; @@ -555,8 +582,7 @@ var ts; TypePredicateKind[TypePredicateKind["This"] = 0] = "This"; TypePredicateKind[TypePredicateKind["Identifier"] = 1] = "Identifier"; })(TypePredicateKind = ts.TypePredicateKind || (ts.TypePredicateKind = {})); - /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator - * metadata */ + /** Indicates how to serialize the name for a TypeReferenceNode when emitting decorator metadata */ /* @internal */ var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { @@ -655,13 +681,15 @@ var ts; (function (CheckFlags) { CheckFlags[CheckFlags["Instantiated"] = 1] = "Instantiated"; CheckFlags[CheckFlags["SyntheticProperty"] = 2] = "SyntheticProperty"; - CheckFlags[CheckFlags["Readonly"] = 4] = "Readonly"; - CheckFlags[CheckFlags["Partial"] = 8] = "Partial"; - CheckFlags[CheckFlags["HasNonUniformType"] = 16] = "HasNonUniformType"; - CheckFlags[CheckFlags["ContainsPublic"] = 32] = "ContainsPublic"; - CheckFlags[CheckFlags["ContainsProtected"] = 64] = "ContainsProtected"; - CheckFlags[CheckFlags["ContainsPrivate"] = 128] = "ContainsPrivate"; - CheckFlags[CheckFlags["ContainsStatic"] = 256] = "ContainsStatic"; + CheckFlags[CheckFlags["SyntheticMethod"] = 4] = "SyntheticMethod"; + CheckFlags[CheckFlags["Readonly"] = 8] = "Readonly"; + CheckFlags[CheckFlags["Partial"] = 16] = "Partial"; + CheckFlags[CheckFlags["HasNonUniformType"] = 32] = "HasNonUniformType"; + CheckFlags[CheckFlags["ContainsPublic"] = 64] = "ContainsPublic"; + CheckFlags[CheckFlags["ContainsProtected"] = 128] = "ContainsProtected"; + CheckFlags[CheckFlags["ContainsPrivate"] = 256] = "ContainsPrivate"; + CheckFlags[CheckFlags["ContainsStatic"] = 512] = "ContainsStatic"; + CheckFlags[CheckFlags["Synthetic"] = 6] = "Synthetic"; })(CheckFlags = ts.CheckFlags || (ts.CheckFlags = {})); /* @internal */ var NodeCheckFlags; @@ -761,7 +789,6 @@ var ts; ObjectFlags[ObjectFlags["ObjectLiteral"] = 128] = "ObjectLiteral"; ObjectFlags[ObjectFlags["EvolvingArray"] = 256] = "EvolvingArray"; ObjectFlags[ObjectFlags["ObjectLiteralPatternWithComputedProperties"] = 512] = "ObjectLiteralPatternWithComputedProperties"; - ObjectFlags[ObjectFlags["NonPrimitive"] = 1024] = "NonPrimitive"; ObjectFlags[ObjectFlags["ClassOrInterface"] = 3] = "ClassOrInterface"; })(ObjectFlags = ts.ObjectFlags || (ts.ObjectFlags = {})); var SignatureKind; @@ -786,6 +813,8 @@ var ts; SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["PrototypeProperty"] = 3] = "PrototypeProperty"; /// this.name = expr SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["ThisProperty"] = 4] = "ThisProperty"; + // F.name = expr + SpecialPropertyAssignmentKind[SpecialPropertyAssignmentKind["Property"] = 5] = "Property"; })(SpecialPropertyAssignmentKind = ts.SpecialPropertyAssignmentKind || (ts.SpecialPropertyAssignmentKind = {})); var DiagnosticCategory; (function (DiagnosticCategory) { @@ -1081,13 +1110,15 @@ var ts; EmitFlags[EmitFlags["HelperName"] = 4096] = "HelperName"; EmitFlags[EmitFlags["ExportName"] = 8192] = "ExportName"; EmitFlags[EmitFlags["LocalName"] = 16384] = "LocalName"; - EmitFlags[EmitFlags["Indented"] = 32768] = "Indented"; - EmitFlags[EmitFlags["NoIndentation"] = 65536] = "NoIndentation"; - EmitFlags[EmitFlags["AsyncFunctionBody"] = 131072] = "AsyncFunctionBody"; - EmitFlags[EmitFlags["ReuseTempVariableScope"] = 262144] = "ReuseTempVariableScope"; - EmitFlags[EmitFlags["CustomPrologue"] = 524288] = "CustomPrologue"; - EmitFlags[EmitFlags["NoHoisting"] = 1048576] = "NoHoisting"; - EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 2097152] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["InternalName"] = 32768] = "InternalName"; + EmitFlags[EmitFlags["Indented"] = 65536] = "Indented"; + EmitFlags[EmitFlags["NoIndentation"] = 131072] = "NoIndentation"; + EmitFlags[EmitFlags["AsyncFunctionBody"] = 262144] = "AsyncFunctionBody"; + EmitFlags[EmitFlags["ReuseTempVariableScope"] = 524288] = "ReuseTempVariableScope"; + EmitFlags[EmitFlags["CustomPrologue"] = 1048576] = "CustomPrologue"; + EmitFlags[EmitFlags["NoHoisting"] = 2097152] = "NoHoisting"; + EmitFlags[EmitFlags["HasEndOfDeclarationMarker"] = 4194304] = "HasEndOfDeclarationMarker"; + EmitFlags[EmitFlags["Iterator"] = 8388608] = "Iterator"; })(EmitFlags = ts.EmitFlags || (ts.EmitFlags = {})); /** * Used by the checker, this enum keeps track of external emit helpers that should be type @@ -1104,8 +1135,20 @@ var ts; ExternalEmitHelpers[ExternalEmitHelpers["Param"] = 32] = "Param"; ExternalEmitHelpers[ExternalEmitHelpers["Awaiter"] = 64] = "Awaiter"; ExternalEmitHelpers[ExternalEmitHelpers["Generator"] = 128] = "Generator"; + ExternalEmitHelpers[ExternalEmitHelpers["Values"] = 256] = "Values"; + ExternalEmitHelpers[ExternalEmitHelpers["Read"] = 512] = "Read"; + ExternalEmitHelpers[ExternalEmitHelpers["Spread"] = 1024] = "Spread"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncGenerator"] = 2048] = "AsyncGenerator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncDelegator"] = 4096] = "AsyncDelegator"; + ExternalEmitHelpers[ExternalEmitHelpers["AsyncValues"] = 8192] = "AsyncValues"; + // Helpers included by ES2015 for..of + ExternalEmitHelpers[ExternalEmitHelpers["ForOfIncludes"] = 256] = "ForOfIncludes"; + // Helpers included by ES2017 for..await..of + ExternalEmitHelpers[ExternalEmitHelpers["ForAwaitOfIncludes"] = 8192] = "ForAwaitOfIncludes"; + // Helpers included by ES2015 spread + ExternalEmitHelpers[ExternalEmitHelpers["SpreadIncludes"] = 1536] = "SpreadIncludes"; ExternalEmitHelpers[ExternalEmitHelpers["FirstEmitHelper"] = 1] = "FirstEmitHelper"; - ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 128] = "LastEmitHelper"; + ExternalEmitHelpers[ExternalEmitHelpers["LastEmitHelper"] = 8192] = "LastEmitHelper"; })(ExternalEmitHelpers = ts.ExternalEmitHelpers || (ts.ExternalEmitHelpers = {})); var EmitHint; (function (EmitHint) { @@ -1214,7 +1257,7 @@ var ts; var ts; (function (ts) { /** The version of the TypeScript compiler release */ - ts.version = "2.3.0"; + ts.version = "2.4.0"; })(ts || (ts = {})); /* @internal */ (function (ts) { @@ -1239,7 +1282,7 @@ var ts; ts.localeCompareIsCorrect = ts.collator && ts.collator.compare("a", "B") < 0; /** Create a MapLike with good performance. */ function createDictionaryObject() { - var map = Object.create(null); // tslint:disable-line:no-null-keyword + var map = Object.create(/*prototype*/ null); // tslint:disable-line:no-null-keyword // Using 'delete' on an object causes V8 to put the object in dictionary mode. // This disables creation of hidden classes, which are expensive when an object is // constantly changing shape. @@ -1407,6 +1450,26 @@ var ts; return undefined; } ts.forEach = forEach; + /** + * Iterates through the parent chain of a node and performs the callback on each parent until the callback + * returns a truthy value, then returns that value. + * If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit" + * At that point findAncestor returns undefined. + */ + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; function zipWith(arrayA, arrayB, callback) { Debug.assert(arrayA.length === arrayB.length); for (var i = 0; i < arrayA.length; i++) { @@ -2062,11 +2125,10 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - /** Shims `Array.from`. */ - function arrayFrom(iterator) { + function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { - result.push(value); + result.push(map ? map(value) : value); } return result; var _b; @@ -2125,10 +2187,10 @@ var ts; } for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { var arg = args_1[_a]; - for (var _b = 0, _c = getOwnKeys(arg); _b < _c.length; _b++) { - var p = _c[_b]; - t[p] = arg[p]; - } + for (var p in arg) + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } } return t; } @@ -2484,7 +2546,7 @@ var ts; ts.normalizeSlashes = normalizeSlashes; /** * Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files") - */ + */ function getRootLength(path) { if (path.charCodeAt(0) === 47 /* slash */) { if (path.charCodeAt(1) !== 47 /* slash */) @@ -3427,144 +3489,30 @@ var ts; } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; + function isCheckJsEnabledForFile(sourceFile, compilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; })(ts || (ts = {})); /// var ts; (function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var shell = new ActiveXObject("WScript.Shell"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2 /*text*/; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1 /*binary*/; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - // Load file and read the first two bytes into a string with no interpretation - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - // Position must be at 0 before encoding can be changed - fileStream.Position = 0; - // [0xFF,0xFE] and [0xFE,0xFF] mean utf-16 (little or big endian), otherwise default to utf-8 - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - // ReadText method always strips byte order mark from resulting string - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - // Write characters in UTF-8 encoding - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - // If we don't want the BOM, then skip it by setting the starting location to 3 (size of BOM). - // If not, start from position 0, as the BOM will be added automatically when charset==utf8. - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2 /*overwrite*/); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function getDirectories(path) { - var folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - function getAccessibleFileSystemEntries(path) { - try { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - var directories = getNames(folder.subfolders); - return { files: files, directories: directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function readDirectory(path, extensions, excludes, includes) { - return ts.matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - var wscriptSystem = { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return shell.CurrentDirectory; - }, - getDirectories: getDirectories, - getEnvironmentVariable: function (name) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings("%" + name + "%"); - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; + function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; } + var version = process.version; + if (!version) { + return undefined; + } + var dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + ts.getNodeMajorVersion = getNodeMajorVersion; + ts.sys = (function () { function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); @@ -3631,9 +3579,8 @@ var ts; } } var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } + var nodeVersion = getNodeMajorVersion(); + var isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive() { // win32\win64 are case insensitive platforms if (platform === "win32" || platform === "win64") { @@ -3654,7 +3601,7 @@ var ts; if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) { // Big endian UTF-16 byte order mark detected. Since big endian is not supported by node.js, // flip all byte pairs and treat as little endian. - len &= ~1; + len &= ~1; // Round down to a multiple of 2 for (var i = 0; i < len; i += 2) { var temp = buffer[i]; buffer[i] = buffer[i + 1]; @@ -3681,7 +3628,7 @@ var ts; var fd; try { fd = _fs.openSync(fileName, "w"); - _fs.writeSync(fd, data, undefined, "utf8"); + _fs.writeSync(fd, data, /*position*/ undefined, "utf8"); } finally { if (fd !== undefined) { @@ -3785,13 +3732,11 @@ var ts; // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643) var options; - if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { - // do nothing if either - // - target folder does not exist - // - this is UNC path on Windows (https://github.com/Microsoft/TypeScript/issues/13874) + if (!directoryExists(directoryName)) { + // do nothing if target folder does not exist return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { @@ -3805,11 +3750,7 @@ var ts; // When deleting a file, the passed baseFileName is null callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName))); } - ; }); - function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 /* slash */ && s.charCodeAt(1) === 47 /* slash */; - } }, resolvePath: function (path) { return _path.resolve(path); @@ -3928,9 +3869,6 @@ var ts; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { // process and process.nextTick checks if current environment is node-like // process.browser check excludes webpack and browserify @@ -4005,11 +3943,11 @@ var ts; Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", message: "The return type of an async function must either be a valid promise or must not contain a callable 'then' member." }, + A_promise_must_have_a_then_method: { code: 1059, category: ts.DiagnosticCategory.Error, key: "A_promise_must_have_a_then_method_1059", message: "A promise must have a 'then' method." }, + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: { code: 1060, category: ts.DiagnosticCategory.Error, key: "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", message: "The first parameter of the 'then' method of a promise must be a callback." }, 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." }, + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "Type 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." }, @@ -4034,6 +3972,7 @@ var ts; Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: { code: 1103, category: ts.DiagnosticCategory.Error, key: "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", message: "A 'for-await-of' statement is only allowed within an async function or async generator." }, A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, @@ -4041,7 +3980,7 @@ var ts; Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'." }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, @@ -4073,9 +4012,9 @@ var ts; 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_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." }, - 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" }, + 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" }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized." }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, @@ -4124,8 +4063,8 @@ var ts; Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_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." }, @@ -4177,6 +4116,9 @@ var ts; A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1320, category: ts.DiagnosticCategory.Error, key: "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", message: "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1321, category: ts.DiagnosticCategory.Error, key: "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", message: "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1322, category: ts.DiagnosticCategory.Error, key: "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", message: "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -4238,13 +4180,13 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'." }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, @@ -4284,12 +4226,12 @@ var ts; The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class." }, The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - 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_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}'." }, 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}'." }, @@ -4298,19 +4240,19 @@ var ts; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, 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}'" }, + 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_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}'" }, + 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." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged." }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged." }, Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name." }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'." }, Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'." }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, @@ -4319,18 +4261,20 @@ 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." }, + Class_0_used_before_its_declaration: { code: 2449, category: ts.DiagnosticCategory.Error, key: "Class_0_used_before_its_declaration_2449", message: "Class '{0}' used before its declaration." }, + Enum_0_used_before_its_declaration: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Enum_0_used_before_its_declaration_2450", message: "Enum '{0}' used before its declaration." }, 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." }, Variable_0_is_used_before_being_assigned: { code: 2454, category: ts.DiagnosticCategory.Error, key: "Variable_0_is_used_before_being_assigned_2454", message: "Variable '{0}' is used before being assigned." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'." }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern." }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -4351,13 +4295,13 @@ var ts; let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, 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}'" }, + 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_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, 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." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause." }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, @@ -4369,6 +4313,7 @@ var ts; A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: { code: 2504, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", message: "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, @@ -4383,6 +4328,7 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, + An_async_iterator_must_have_a_next_method: { code: 2519, category: ts.DiagnosticCategory.Error, key: "An_async_iterator_must_have_a_next_method_2519", message: "An async iterator must have a 'next()' method." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", message: "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method." }, @@ -4410,25 +4356,29 @@ var ts; Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, + The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: { code: 2547, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", message: "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property." }, + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2548, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", message: "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2549, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", message: "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: { code: 2550, category: ts.DiagnosticCategory.Error, key: "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", message: "Generic type instantiation is excessively deep and possibly infinite." }, 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." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'." }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property." }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property." }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React." }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, - Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element." }, + Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'." }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", message: "Cannot export '{0}'. Only local declarations can be exported from a module." }, @@ -4460,7 +4410,6 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, - A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { code: 2693, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", message: "'{0}' only refers to a type, but is being used as a value here." }, @@ -4473,11 +4422,14 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, - The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference." }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property." }, An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, + Cannot_use_namespace_0_as_a_value: { code: 2708, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_value_2708", message: "Cannot use namespace '{0}' as a value." }, + Cannot_use_namespace_0_as_a_type: { code: 2709, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_type_2709", message: "Cannot use namespace '{0}' as a type." }, + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: { code: 2710, category: ts.DiagnosticCategory.Error, key: "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", message: "'{0}' are specified twice. The attribute named '{0}' will be overwritten." }, 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}'." }, @@ -4557,12 +4509,11 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { code: 5011, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011", message: "File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}." }, Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", message: "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, @@ -4571,12 +4522,12 @@ var ts; A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, 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}'" }, + 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}'." }, 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" }, + 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." }, Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." }, Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, @@ -4594,11 +4545,11 @@ var ts; Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'." }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -4618,7 +4569,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_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}" }, + Argument_for_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}." }, 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}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, @@ -4640,18 +4591,18 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context (experimental)." }, Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'." }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, 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}." }, 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." }, - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", message: "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit" }, Enable_tracing_of_the_name_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_name_resolution_process_6085", message: "Enable tracing of the name 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}'." }, @@ -4673,12 +4624,12 @@ var ts; 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_0_field_in_package_json_to_be_string_got_1: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", message: "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'." }, - 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" }, + 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." }, Enable_strict_null_checks: { code: 6113, category: ts.DiagnosticCategory.Message, key: "Enable_strict_null_checks_6113", message: "Enable strict null checks." }, Unknown_option_excludes_Did_you_mean_exclude: { code: 6114, category: ts.DiagnosticCategory.Error, key: "Unknown_option_excludes_Did_you_mean_exclude_6114", message: "Unknown option 'excludes'. Did you mean 'exclude'?" }, @@ -4688,26 +4639,26 @@ var ts; Resolving_from_node_modules_folder: { code: 6118, category: ts.DiagnosticCategory.Message, key: "Resolving_from_node_modules_folder_6118", message: "Resolving from node_modules folder..." }, Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { code: 6119, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", message: "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========" }, Type_reference_directive_0_was_not_resolved: { code: 6120, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_not_resolved_6120", message: "======== Type reference directive '{0}' was not resolved. ========" }, - Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'" }, + Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'." }, Root_directory_cannot_be_determined_skipping_primary_search_paths: { code: 6122, category: ts.DiagnosticCategory.Message, key: "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", message: "Root directory cannot be determined, skipping primary search paths." }, Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { code: 6123, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", message: "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========" }, Type_declaration_files_to_be_included_in_compilation: { code: 6124, category: ts.DiagnosticCategory.Message, key: "Type_declaration_files_to_be_included_in_compilation_6124", message: "Type declaration files to be included in compilation." }, - Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'" }, + Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'." }, Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { code: 6126, category: ts.DiagnosticCategory.Message, key: "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", message: "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { code: 6127, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", message: "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========" }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" }, The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." }, - Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, + Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'." }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, - File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it." }, _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files." }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file." }, Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, @@ -4715,6 +4666,40 @@ var ts; Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, + Show_diagnostic_information: { code: 6149, category: ts.DiagnosticCategory.Message, key: "Show_diagnostic_information_6149", message: "Show diagnostic information." }, + Show_verbose_diagnostic_information: { code: 6150, category: ts.DiagnosticCategory.Message, key: "Show_verbose_diagnostic_information_6150", message: "Show verbose diagnostic information." }, + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: { code: 6151, category: ts.DiagnosticCategory.Message, key: "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", message: "Emit a single file with source maps instead of having a separate file." }, + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: { code: 6152, category: ts.DiagnosticCategory.Message, key: "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", message: "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set." }, + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: { code: 6153, category: ts.DiagnosticCategory.Message, key: "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", message: "Transpile each file as a separate module (similar to 'ts.transpileModule')." }, + Print_names_of_generated_files_part_of_the_compilation: { code: 6154, category: ts.DiagnosticCategory.Message, key: "Print_names_of_generated_files_part_of_the_compilation_6154", message: "Print names of generated files part of the compilation." }, + Print_names_of_files_part_of_the_compilation: { code: 6155, category: ts.DiagnosticCategory.Message, key: "Print_names_of_files_part_of_the_compilation_6155", message: "Print names of files part of the compilation." }, + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: { code: 6156, category: ts.DiagnosticCategory.Message, key: "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", message: "The locale used when displaying messages to the user (e.g. 'en-us')" }, + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: { code: 6157, category: ts.DiagnosticCategory.Message, key: "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", message: "Do not generate custom helper functions like '__extends' in compiled output." }, + Do_not_include_the_default_library_file_lib_d_ts: { code: 6158, category: ts.DiagnosticCategory.Message, key: "Do_not_include_the_default_library_file_lib_d_ts_6158", message: "Do not include the default library file (lib.d.ts)." }, + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: { code: 6159, category: ts.DiagnosticCategory.Message, key: "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", message: "Do not add triple-slash references or imported modules to the list of compiled files." }, + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: { code: 6160, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", message: "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files." }, + List_of_folders_to_include_type_definitions_from: { code: 6161, category: ts.DiagnosticCategory.Message, key: "List_of_folders_to_include_type_definitions_from_6161", message: "List of folders to include type definitions from." }, + Disable_size_limitations_on_JavaScript_projects: { code: 6162, category: ts.DiagnosticCategory.Message, key: "Disable_size_limitations_on_JavaScript_projects_6162", message: "Disable size limitations on JavaScript projects." }, + The_character_set_of_the_input_files: { code: 6163, category: ts.DiagnosticCategory.Message, key: "The_character_set_of_the_input_files_6163", message: "The character set of the input files." }, + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: { code: 6164, category: ts.DiagnosticCategory.Message, key: "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", message: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." }, + Do_not_truncate_error_messages: { code: 6165, category: ts.DiagnosticCategory.Message, key: "Do_not_truncate_error_messages_6165", message: "Do not truncate error messages." }, + Output_directory_for_generated_declaration_files: { code: 6166, category: ts.DiagnosticCategory.Message, key: "Output_directory_for_generated_declaration_files_6166", message: "Output directory for generated declaration files." }, + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: { code: 6167, category: ts.DiagnosticCategory.Message, key: "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", message: "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'." }, + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: { code: 6168, category: ts.DiagnosticCategory.Message, key: "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", message: "List of root folders whose combined content represents the structure of the project at runtime." }, + Show_all_compiler_options: { code: 6169, category: ts.DiagnosticCategory.Message, key: "Show_all_compiler_options_6169", message: "Show all compiler options." }, + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: { code: 6170, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", message: "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file" }, + Command_line_Options: { code: 6171, category: ts.DiagnosticCategory.Message, key: "Command_line_Options_6171", message: "Command-line Options" }, + Basic_Options: { code: 6172, category: ts.DiagnosticCategory.Message, key: "Basic_Options_6172", message: "Basic Options" }, + Strict_Type_Checking_Options: { code: 6173, category: ts.DiagnosticCategory.Message, key: "Strict_Type_Checking_Options_6173", message: "Strict Type-Checking Options" }, + Module_Resolution_Options: { code: 6174, category: ts.DiagnosticCategory.Message, key: "Module_Resolution_Options_6174", message: "Module Resolution Options" }, + Source_Map_Options: { code: 6175, category: ts.DiagnosticCategory.Message, key: "Source_Map_Options_6175", message: "Source Map Options" }, + Additional_Checks: { code: 6176, category: ts.DiagnosticCategory.Message, key: "Additional_Checks_6176", message: "Additional Checks" }, + Experimental_Options: { code: 6177, category: ts.DiagnosticCategory.Message, key: "Experimental_Options_6177", message: "Experimental Options" }, + Advanced_Options: { code: 6178, category: ts.DiagnosticCategory.Message, key: "Advanced_Options_6178", message: "Advanced Options" }, + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: { code: 6179, category: ts.DiagnosticCategory.Message, key: "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", message: "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'." }, + Enable_all_strict_type_checking_options: { code: 6180, category: ts.DiagnosticCategory.Message, key: "Enable_all_strict_type_checking_options_6180", message: "Enable all strict type-checking options." }, + List_of_language_service_plugins: { code: 6181, category: ts.DiagnosticCategory.Message, key: "List_of_language_service_plugins_6181", message: "List of language service plugins." }, + Scoped_package_detected_looking_in_0: { code: 6182, category: ts.DiagnosticCategory.Message, key: "Scoped_package_detected_looking_in_0_6182", message: "Scoped package detected, looking in '{0}'" }, 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." }, @@ -4732,7 +4717,7 @@ var ts; _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists." }, Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, @@ -4741,6 +4726,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, + Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: { code: 7035, category: ts.DiagnosticCategory.Error, key: "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", message: "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -4764,14 +4750,14 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + 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." }, 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." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" }, Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, @@ -4780,17 +4766,24 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: '{0}'." }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig." }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, - Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, - Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, - Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}." }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}." }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." }, + Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." }, + Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'." }, + Disable_checking_for_this_file: { code: 90018, category: ts.DiagnosticCategory.Message, key: "Disable_checking_for_this_file_90018", message: "Disable checking for this file." }, + Ignore_this_error_message: { code: 90019, category: ts.DiagnosticCategory.Message, key: "Ignore_this_error_message_90019", message: "Ignore this error message." }, + Initialize_property_0_in_the_constructor: { code: 90020, category: ts.DiagnosticCategory.Message, key: "Initialize_property_0_in_the_constructor_90020", message: "Initialize property '{0}' in the constructor." }, + Initialize_static_property_0: { code: 90021, category: ts.DiagnosticCategory.Message, key: "Initialize_static_property_0_90021", message: "Initialize static property '{0}'." }, Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, + Report_errors_in_js_files: { code: 8019, category: ts.DiagnosticCategory.Message, key: "Report_errors_in_js_files_8019", message: "Report errors in .js files." }, }; })(ts || (ts = {})); /// @@ -4799,135 +4792,135 @@ var ts; (function (ts) { /* @internal */ function tokenIsIdentifierOrKeyword(token) { - return token >= 70 /* Identifier */; + return token >= 71 /* Identifier */; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMapFromTemplate({ - "abstract": 116 /* AbstractKeyword */, - "any": 118 /* AnyKeyword */, - "as": 117 /* AsKeyword */, - "boolean": 121 /* BooleanKeyword */, - "break": 71 /* BreakKeyword */, - "case": 72 /* CaseKeyword */, - "catch": 73 /* CatchKeyword */, - "class": 74 /* ClassKeyword */, - "continue": 76 /* ContinueKeyword */, - "const": 75 /* ConstKeyword */, - "constructor": 122 /* ConstructorKeyword */, - "debugger": 77 /* DebuggerKeyword */, - "declare": 123 /* DeclareKeyword */, - "default": 78 /* DefaultKeyword */, - "delete": 79 /* DeleteKeyword */, - "do": 80 /* DoKeyword */, - "else": 81 /* ElseKeyword */, - "enum": 82 /* EnumKeyword */, - "export": 83 /* ExportKeyword */, - "extends": 84 /* ExtendsKeyword */, - "false": 85 /* FalseKeyword */, - "finally": 86 /* FinallyKeyword */, - "for": 87 /* ForKeyword */, - "from": 139 /* FromKeyword */, - "function": 88 /* FunctionKeyword */, - "get": 124 /* GetKeyword */, - "if": 89 /* IfKeyword */, - "implements": 107 /* ImplementsKeyword */, - "import": 90 /* ImportKeyword */, - "in": 91 /* InKeyword */, - "instanceof": 92 /* InstanceOfKeyword */, - "interface": 108 /* InterfaceKeyword */, - "is": 125 /* IsKeyword */, - "keyof": 126 /* KeyOfKeyword */, - "let": 109 /* LetKeyword */, - "module": 127 /* ModuleKeyword */, - "namespace": 128 /* NamespaceKeyword */, - "never": 129 /* NeverKeyword */, - "new": 93 /* NewKeyword */, - "null": 94 /* NullKeyword */, - "number": 132 /* NumberKeyword */, - "object": 133 /* ObjectKeyword */, - "package": 110 /* PackageKeyword */, - "private": 111 /* PrivateKeyword */, - "protected": 112 /* ProtectedKeyword */, - "public": 113 /* PublicKeyword */, - "readonly": 130 /* ReadonlyKeyword */, - "require": 131 /* RequireKeyword */, - "global": 140 /* GlobalKeyword */, - "return": 95 /* ReturnKeyword */, - "set": 134 /* SetKeyword */, - "static": 114 /* StaticKeyword */, - "string": 135 /* StringKeyword */, - "super": 96 /* SuperKeyword */, - "switch": 97 /* SwitchKeyword */, - "symbol": 136 /* SymbolKeyword */, - "this": 98 /* ThisKeyword */, - "throw": 99 /* ThrowKeyword */, - "true": 100 /* TrueKeyword */, - "try": 101 /* TryKeyword */, - "type": 137 /* TypeKeyword */, - "typeof": 102 /* TypeOfKeyword */, - "undefined": 138 /* UndefinedKeyword */, - "var": 103 /* VarKeyword */, - "void": 104 /* VoidKeyword */, - "while": 105 /* WhileKeyword */, - "with": 106 /* WithKeyword */, - "yield": 115 /* YieldKeyword */, - "async": 119 /* AsyncKeyword */, - "await": 120 /* AwaitKeyword */, - "of": 141 /* OfKeyword */, - "{": 16 /* OpenBraceToken */, - "}": 17 /* CloseBraceToken */, - "(": 18 /* OpenParenToken */, - ")": 19 /* CloseParenToken */, - "[": 20 /* OpenBracketToken */, - "]": 21 /* CloseBracketToken */, - ".": 22 /* DotToken */, - "...": 23 /* DotDotDotToken */, - ";": 24 /* SemicolonToken */, - ",": 25 /* CommaToken */, - "<": 26 /* LessThanToken */, - ">": 28 /* GreaterThanToken */, - "<=": 29 /* LessThanEqualsToken */, - ">=": 30 /* GreaterThanEqualsToken */, - "==": 31 /* EqualsEqualsToken */, - "!=": 32 /* ExclamationEqualsToken */, - "===": 33 /* EqualsEqualsEqualsToken */, - "!==": 34 /* ExclamationEqualsEqualsToken */, - "=>": 35 /* EqualsGreaterThanToken */, - "+": 36 /* PlusToken */, - "-": 37 /* MinusToken */, - "**": 39 /* AsteriskAsteriskToken */, - "*": 38 /* AsteriskToken */, - "/": 40 /* SlashToken */, - "%": 41 /* PercentToken */, - "++": 42 /* PlusPlusToken */, - "--": 43 /* MinusMinusToken */, - "<<": 44 /* LessThanLessThanToken */, - ">": 45 /* GreaterThanGreaterThanToken */, - ">>>": 46 /* GreaterThanGreaterThanGreaterThanToken */, - "&": 47 /* AmpersandToken */, - "|": 48 /* BarToken */, - "^": 49 /* CaretToken */, - "!": 50 /* ExclamationToken */, - "~": 51 /* TildeToken */, - "&&": 52 /* AmpersandAmpersandToken */, - "||": 53 /* BarBarToken */, - "?": 54 /* QuestionToken */, - ":": 55 /* ColonToken */, - "=": 57 /* EqualsToken */, - "+=": 58 /* PlusEqualsToken */, - "-=": 59 /* MinusEqualsToken */, - "*=": 60 /* AsteriskEqualsToken */, - "**=": 61 /* AsteriskAsteriskEqualsToken */, - "/=": 62 /* SlashEqualsToken */, - "%=": 63 /* PercentEqualsToken */, - "<<=": 64 /* LessThanLessThanEqualsToken */, - ">>=": 65 /* GreaterThanGreaterThanEqualsToken */, - ">>>=": 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */, - "&=": 67 /* AmpersandEqualsToken */, - "|=": 68 /* BarEqualsToken */, - "^=": 69 /* CaretEqualsToken */, - "@": 56 /* AtToken */, + "abstract": 117 /* AbstractKeyword */, + "any": 119 /* AnyKeyword */, + "as": 118 /* AsKeyword */, + "boolean": 122 /* BooleanKeyword */, + "break": 72 /* BreakKeyword */, + "case": 73 /* CaseKeyword */, + "catch": 74 /* CatchKeyword */, + "class": 75 /* ClassKeyword */, + "continue": 77 /* ContinueKeyword */, + "const": 76 /* ConstKeyword */, + "constructor": 123 /* ConstructorKeyword */, + "debugger": 78 /* DebuggerKeyword */, + "declare": 124 /* DeclareKeyword */, + "default": 79 /* DefaultKeyword */, + "delete": 80 /* DeleteKeyword */, + "do": 81 /* DoKeyword */, + "else": 82 /* ElseKeyword */, + "enum": 83 /* EnumKeyword */, + "export": 84 /* ExportKeyword */, + "extends": 85 /* ExtendsKeyword */, + "false": 86 /* FalseKeyword */, + "finally": 87 /* FinallyKeyword */, + "for": 88 /* ForKeyword */, + "from": 140 /* FromKeyword */, + "function": 89 /* FunctionKeyword */, + "get": 125 /* GetKeyword */, + "if": 90 /* IfKeyword */, + "implements": 108 /* ImplementsKeyword */, + "import": 91 /* ImportKeyword */, + "in": 92 /* InKeyword */, + "instanceof": 93 /* InstanceOfKeyword */, + "interface": 109 /* InterfaceKeyword */, + "is": 126 /* IsKeyword */, + "keyof": 127 /* KeyOfKeyword */, + "let": 110 /* LetKeyword */, + "module": 128 /* ModuleKeyword */, + "namespace": 129 /* NamespaceKeyword */, + "never": 130 /* NeverKeyword */, + "new": 94 /* NewKeyword */, + "null": 95 /* NullKeyword */, + "number": 133 /* NumberKeyword */, + "object": 134 /* ObjectKeyword */, + "package": 111 /* PackageKeyword */, + "private": 112 /* PrivateKeyword */, + "protected": 113 /* ProtectedKeyword */, + "public": 114 /* PublicKeyword */, + "readonly": 131 /* ReadonlyKeyword */, + "require": 132 /* RequireKeyword */, + "global": 141 /* GlobalKeyword */, + "return": 96 /* ReturnKeyword */, + "set": 135 /* SetKeyword */, + "static": 115 /* StaticKeyword */, + "string": 136 /* StringKeyword */, + "super": 97 /* SuperKeyword */, + "switch": 98 /* SwitchKeyword */, + "symbol": 137 /* SymbolKeyword */, + "this": 99 /* ThisKeyword */, + "throw": 100 /* ThrowKeyword */, + "true": 101 /* TrueKeyword */, + "try": 102 /* TryKeyword */, + "type": 138 /* TypeKeyword */, + "typeof": 103 /* TypeOfKeyword */, + "undefined": 139 /* UndefinedKeyword */, + "var": 104 /* VarKeyword */, + "void": 105 /* VoidKeyword */, + "while": 106 /* WhileKeyword */, + "with": 107 /* WithKeyword */, + "yield": 116 /* YieldKeyword */, + "async": 120 /* AsyncKeyword */, + "await": 121 /* AwaitKeyword */, + "of": 142 /* OfKeyword */, + "{": 17 /* OpenBraceToken */, + "}": 18 /* CloseBraceToken */, + "(": 19 /* OpenParenToken */, + ")": 20 /* CloseParenToken */, + "[": 21 /* OpenBracketToken */, + "]": 22 /* CloseBracketToken */, + ".": 23 /* DotToken */, + "...": 24 /* DotDotDotToken */, + ";": 25 /* SemicolonToken */, + ",": 26 /* CommaToken */, + "<": 27 /* LessThanToken */, + ">": 29 /* GreaterThanToken */, + "<=": 30 /* LessThanEqualsToken */, + ">=": 31 /* GreaterThanEqualsToken */, + "==": 32 /* EqualsEqualsToken */, + "!=": 33 /* ExclamationEqualsToken */, + "===": 34 /* EqualsEqualsEqualsToken */, + "!==": 35 /* ExclamationEqualsEqualsToken */, + "=>": 36 /* EqualsGreaterThanToken */, + "+": 37 /* PlusToken */, + "-": 38 /* MinusToken */, + "**": 40 /* AsteriskAsteriskToken */, + "*": 39 /* AsteriskToken */, + "/": 41 /* SlashToken */, + "%": 42 /* PercentToken */, + "++": 43 /* PlusPlusToken */, + "--": 44 /* MinusMinusToken */, + "<<": 45 /* LessThanLessThanToken */, + ">": 46 /* GreaterThanGreaterThanToken */, + ">>>": 47 /* GreaterThanGreaterThanGreaterThanToken */, + "&": 48 /* AmpersandToken */, + "|": 49 /* BarToken */, + "^": 50 /* CaretToken */, + "!": 51 /* ExclamationToken */, + "~": 52 /* TildeToken */, + "&&": 53 /* AmpersandAmpersandToken */, + "||": 54 /* BarBarToken */, + "?": 55 /* QuestionToken */, + ":": 56 /* ColonToken */, + "=": 58 /* EqualsToken */, + "+=": 59 /* PlusEqualsToken */, + "-=": 60 /* MinusEqualsToken */, + "*=": 61 /* AsteriskEqualsToken */, + "**=": 62 /* AsteriskAsteriskEqualsToken */, + "/=": 63 /* SlashEqualsToken */, + "%=": 64 /* PercentEqualsToken */, + "<<=": 65 /* LessThanLessThanEqualsToken */, + ">>=": 66 /* GreaterThanGreaterThanEqualsToken */, + ">>>=": 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */, + "&=": 68 /* AmpersandEqualsToken */, + "|=": 69 /* BarEqualsToken */, + "^=": 70 /* CaretEqualsToken */, + "@": 57 /* AtToken */, }); /* As per ECMAScript Language Specification 3th Edition, Section 7.6: Identifiers @@ -5041,6 +5034,7 @@ var ts; if (text.charCodeAt(pos) === 10 /* lineFeed */) { pos++; } + // falls through case 10 /* lineFeed */: result.push(lineStart); lineStart = pos; @@ -5099,10 +5093,10 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function isWhiteSpace(ch) { + function isWhiteSpaceLike(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - ts.isWhiteSpace = isWhiteSpace; + ts.isWhiteSpaceLike = isWhiteSpaceLike; /** Does not include line breaks. For that, see isWhiteSpaceLike. */ function isWhiteSpaceSingleLine(ch) { // Note: nextLine is in the Zs space, and should be considered to be a whitespace. @@ -5185,6 +5179,7 @@ var ts; if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { pos++; } + // falls through case 10 /* lineFeed */: pos++; if (stopAfterLineBreak) { @@ -5238,7 +5233,7 @@ var ts; } break; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch))) { + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -5339,6 +5334,7 @@ var ts; if (text.charCodeAt(pos + 1) === 10 /* lineFeed */) { pos++; } + // falls through case 10 /* lineFeed */: pos++; if (trailing) { @@ -5399,7 +5395,7 @@ var ts; } break scan; default: - if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpace(ch))) { + if (ch > 127 /* maxAsciiCharacter */ && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -5434,15 +5430,15 @@ var ts; if (!comments) { comments = []; } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine }); return comments; } function getLeadingCommentRanges(text, pos) { - return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined); + return reduceEachLeadingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined); } ts.getLeadingCommentRanges = getLeadingCommentRanges; function getTrailingCommentRanges(text, pos) { - return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined); + return reduceEachTrailingCommentRange(text, pos, appendCommentRange, /*state*/ undefined, /*initial*/ undefined); } ts.getTrailingCommentRanges = getTrailingCommentRanges; /** Optionally, get the shebang */ @@ -5493,6 +5489,7 @@ var ts; var precedingLineBreak; var hasExtendedUnicodeEscape; var tokenIsUnterminated; + var numericLiteralFlags; setText(text, start, length); return { getStartPos: function () { return startPos; }, @@ -5503,9 +5500,10 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 70 /* Identifier */ || token > 106 /* LastReservedWord */; }, - isReservedWord: function () { return token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */; }, + isIdentifier: function () { return token === 71 /* Identifier */ || token > 107 /* LastReservedWord */; }, + isReservedWord: function () { return token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */; }, isUnterminated: function () { return tokenIsUnterminated; }, + getNumericLiteralFlags: function () { return numericLiteralFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, @@ -5542,6 +5540,7 @@ var ts; var end = pos; if (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */) { pos++; + numericLiteralFlags = 2 /* Scientific */; if (text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) pos++; if (isDigit(text.charCodeAt(pos))) { @@ -5652,7 +5651,7 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; + resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; break; } var currChar = text.charCodeAt(pos); @@ -5660,14 +5659,14 @@ var ts; if (currChar === 96 /* backtick */) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 12 /* NoSubstitutionTemplateLiteral */ : 15 /* TemplateTail */; + resultingToken = startedWithBacktick ? 13 /* NoSubstitutionTemplateLiteral */ : 16 /* TemplateTail */; break; } // '${' if (currChar === 36 /* $ */ && pos + 1 < end && text.charCodeAt(pos + 1) === 123 /* openBrace */) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 13 /* TemplateHead */ : 14 /* TemplateMiddle */; + resultingToken = startedWithBacktick ? 14 /* TemplateHead */ : 15 /* TemplateMiddle */; break; } // Escape character @@ -5740,7 +5739,7 @@ var ts; if (pos < end && text.charCodeAt(pos) === 10 /* lineFeed */) { pos++; } - // fall through + // falls through case 10 /* lineFeed */: case 8232 /* lineSeparator */: case 8233 /* paragraphSeparator */: @@ -5848,7 +5847,7 @@ var ts; } } } - return token = 70 /* Identifier */; + return token = 71 /* Identifier */; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -5877,6 +5876,7 @@ var ts; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -5928,12 +5928,12 @@ var ts; case 33 /* exclamation */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 34 /* ExclamationEqualsEqualsToken */; + return pos += 3, token = 35 /* ExclamationEqualsEqualsToken */; } - return pos += 2, token = 32 /* ExclamationEqualsToken */; + return pos += 2, token = 33 /* ExclamationEqualsToken */; } pos++; - return token = 50 /* ExclamationToken */; + return token = 51 /* ExclamationToken */; case 34 /* doubleQuote */: case 39 /* singleQuote */: tokenValue = scanString(); @@ -5942,68 +5942,68 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37 /* percent */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 63 /* PercentEqualsToken */; + return pos += 2, token = 64 /* PercentEqualsToken */; } pos++; - return token = 41 /* PercentToken */; + return token = 42 /* PercentToken */; case 38 /* ampersand */: if (text.charCodeAt(pos + 1) === 38 /* ampersand */) { - return pos += 2, token = 52 /* AmpersandAmpersandToken */; + return pos += 2, token = 53 /* AmpersandAmpersandToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 67 /* AmpersandEqualsToken */; + return pos += 2, token = 68 /* AmpersandEqualsToken */; } pos++; - return token = 47 /* AmpersandToken */; + return token = 48 /* AmpersandToken */; case 40 /* openParen */: pos++; - return token = 18 /* OpenParenToken */; + return token = 19 /* OpenParenToken */; case 41 /* closeParen */: pos++; - return token = 19 /* CloseParenToken */; + return token = 20 /* CloseParenToken */; case 42 /* asterisk */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 60 /* AsteriskEqualsToken */; + return pos += 2, token = 61 /* AsteriskEqualsToken */; } if (text.charCodeAt(pos + 1) === 42 /* asterisk */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 61 /* AsteriskAsteriskEqualsToken */; + return pos += 3, token = 62 /* AsteriskAsteriskEqualsToken */; } - return pos += 2, token = 39 /* AsteriskAsteriskToken */; + return pos += 2, token = 40 /* AsteriskAsteriskToken */; } pos++; - return token = 38 /* AsteriskToken */; + return token = 39 /* AsteriskToken */; case 43 /* plus */: if (text.charCodeAt(pos + 1) === 43 /* plus */) { - return pos += 2, token = 42 /* PlusPlusToken */; + return pos += 2, token = 43 /* PlusPlusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 58 /* PlusEqualsToken */; + return pos += 2, token = 59 /* PlusEqualsToken */; } pos++; - return token = 36 /* PlusToken */; + return token = 37 /* PlusToken */; case 44 /* comma */: pos++; - return token = 25 /* CommaToken */; + return token = 26 /* CommaToken */; case 45 /* minus */: if (text.charCodeAt(pos + 1) === 45 /* minus */) { - return pos += 2, token = 43 /* MinusMinusToken */; + return pos += 2, token = 44 /* MinusMinusToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 59 /* MinusEqualsToken */; + return pos += 2, token = 60 /* MinusEqualsToken */; } pos++; - return token = 37 /* MinusToken */; + return token = 38 /* MinusToken */; case 46 /* dot */: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8 /* NumericLiteral */; } if (text.charCodeAt(pos + 1) === 46 /* dot */ && text.charCodeAt(pos + 2) === 46 /* dot */) { - return pos += 3, token = 23 /* DotDotDotToken */; + return pos += 3, token = 24 /* DotDotDotToken */; } pos++; - return token = 22 /* DotToken */; + return token = 23 /* DotToken */; case 47 /* slash */: // Single-line comment if (text.charCodeAt(pos + 1) === 47 /* slash */) { @@ -6049,10 +6049,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 62 /* SlashEqualsToken */; + return pos += 2, token = 63 /* SlashEqualsToken */; } pos++; - return token = 40 /* SlashToken */; + return token = 41 /* SlashToken */; case 48 /* _0 */: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 /* X */ || text.charCodeAt(pos + 1) === 120 /* x */)) { pos += 2; @@ -6062,6 +6062,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 8 /* HexSpecifier */; return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 /* B */ || text.charCodeAt(pos + 1) === 98 /* b */)) { @@ -6072,6 +6073,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 16 /* BinarySpecifier */; return token = 8 /* NumericLiteral */; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 /* O */ || text.charCodeAt(pos + 1) === 111 /* o */)) { @@ -6082,16 +6084,19 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 32 /* OctalSpecifier */; return token = 8 /* NumericLiteral */; } // Try to parse as an octal if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = 4 /* Octal */; return token = 8 /* NumericLiteral */; } // This fall-through is a deviation from the EcmaScript grammar. The grammar says that a leading zero // can only be followed by an octal digit, a dot, or the end of the number literal. However, we are being // permissive and allowing decimal digits of the form 08* and 09* (which many browsers also do). + // falls through case 49 /* _1 */: case 50 /* _2 */: case 51 /* _3 */: @@ -6105,10 +6110,10 @@ var ts; return token = 8 /* NumericLiteral */; case 58 /* colon */: pos++; - return token = 55 /* ColonToken */; + return token = 56 /* ColonToken */; case 59 /* semicolon */: pos++; - return token = 24 /* SemicolonToken */; + return token = 25 /* SemicolonToken */; case 60 /* lessThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6121,20 +6126,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60 /* lessThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 64 /* LessThanLessThanEqualsToken */; + return pos += 3, token = 65 /* LessThanLessThanEqualsToken */; } - return pos += 2, token = 44 /* LessThanLessThanToken */; + return pos += 2, token = 45 /* LessThanLessThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 29 /* LessThanEqualsToken */; + return pos += 2, token = 30 /* LessThanEqualsToken */; } if (languageVariant === 1 /* JSX */ && text.charCodeAt(pos + 1) === 47 /* slash */ && text.charCodeAt(pos + 2) !== 42 /* asterisk */) { - return pos += 2, token = 27 /* LessThanSlashToken */; + return pos += 2, token = 28 /* LessThanSlashToken */; } pos++; - return token = 26 /* LessThanToken */; + return token = 27 /* LessThanToken */; case 61 /* equals */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6147,15 +6152,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 33 /* EqualsEqualsEqualsToken */; + return pos += 3, token = 34 /* EqualsEqualsEqualsToken */; } - return pos += 2, token = 31 /* EqualsEqualsToken */; + return pos += 2, token = 32 /* EqualsEqualsToken */; } if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { - return pos += 2, token = 35 /* EqualsGreaterThanToken */; + return pos += 2, token = 36 /* EqualsGreaterThanToken */; } pos++; - return token = 57 /* EqualsToken */; + return token = 58 /* EqualsToken */; case 62 /* greaterThan */: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -6167,43 +6172,43 @@ var ts; } } pos++; - return token = 28 /* GreaterThanToken */; + return token = 29 /* GreaterThanToken */; case 63 /* question */: pos++; - return token = 54 /* QuestionToken */; + return token = 55 /* QuestionToken */; case 91 /* openBracket */: pos++; - return token = 20 /* OpenBracketToken */; + return token = 21 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 21 /* CloseBracketToken */; + return token = 22 /* CloseBracketToken */; case 94 /* caret */: if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 69 /* CaretEqualsToken */; + return pos += 2, token = 70 /* CaretEqualsToken */; } pos++; - return token = 49 /* CaretToken */; + return token = 50 /* CaretToken */; case 123 /* openBrace */: pos++; - return token = 16 /* OpenBraceToken */; + return token = 17 /* OpenBraceToken */; case 124 /* bar */: if (text.charCodeAt(pos + 1) === 124 /* bar */) { - return pos += 2, token = 53 /* BarBarToken */; + return pos += 2, token = 54 /* BarBarToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 68 /* BarEqualsToken */; + return pos += 2, token = 69 /* BarEqualsToken */; } pos++; - return token = 48 /* BarToken */; + return token = 49 /* BarToken */; case 125 /* closeBrace */: pos++; - return token = 17 /* CloseBraceToken */; + return token = 18 /* CloseBraceToken */; case 126 /* tilde */: pos++; - return token = 51 /* TildeToken */; + return token = 52 /* TildeToken */; case 64 /* at */: pos++; - return token = 56 /* AtToken */; + return token = 57 /* AtToken */; case 92 /* backslash */: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -6241,29 +6246,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 28 /* GreaterThanToken */) { + if (token === 29 /* GreaterThanToken */) { if (text.charCodeAt(pos) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 1) === 62 /* greaterThan */) { if (text.charCodeAt(pos + 2) === 61 /* equals */) { - return pos += 3, token = 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */; + return pos += 3, token = 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */; } - return pos += 2, token = 46 /* GreaterThanGreaterThanGreaterThanToken */; + return pos += 2, token = 47 /* GreaterThanGreaterThanGreaterThanToken */; } if (text.charCodeAt(pos + 1) === 61 /* equals */) { - return pos += 2, token = 65 /* GreaterThanGreaterThanEqualsToken */; + return pos += 2, token = 66 /* GreaterThanGreaterThanEqualsToken */; } pos++; - return token = 45 /* GreaterThanGreaterThanToken */; + return token = 46 /* GreaterThanGreaterThanToken */; } if (text.charCodeAt(pos) === 61 /* equals */) { pos++; - return token = 30 /* GreaterThanEqualsToken */; + return token = 31 /* GreaterThanEqualsToken */; } } return token; } function reScanSlashToken() { - if (token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) { + if (token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -6308,7 +6313,7 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 11 /* RegularExpressionLiteral */; + token = 12 /* RegularExpressionLiteral */; } return token; } @@ -6316,7 +6321,7 @@ var ts; * Unconditionally back up and scan a template expression portion. */ function reScanTemplateToken() { - ts.Debug.assert(token === 17 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 18 /* CloseBraceToken */, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -6333,23 +6338,46 @@ var ts; if (char === 60 /* lessThan */) { if (text.charCodeAt(pos + 1) === 47 /* slash */) { pos += 2; - return token = 27 /* LessThanSlashToken */; + return token = 28 /* LessThanSlashToken */; } pos++; - return token = 26 /* LessThanToken */; + return token = 27 /* LessThanToken */; } if (char === 123 /* openBrace */) { pos++; - return token = 16 /* OpenBraceToken */; + return token = 17 /* OpenBraceToken */; } + // First non-whitespace character on this line. + var firstNonWhitespace = 0; + // These initial values are special because the first line is: + // firstNonWhitespace = 0 to indicate that we want leading whitspace, while (pos < end) { - pos++; char = text.charCodeAt(pos); - if ((char === 123 /* openBrace */) || (char === 60 /* lessThan */)) { + if (char === 123 /* openBrace */) { break; } + if (char === 60 /* lessThan */) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = 7 /* ConflictMarkerTrivia */; + } + break; + } + // FirstNonWhitespace is 0, then we only see whitespaces so far. If we see a linebreak, we want to ignore that whitespaces. + // i.e (- : whitespace) + //
---- + //
becomes
+ // + //
----
becomes
----
+ if (isLineBreak(char) && firstNonWhitespace === 0) { + firstNonWhitespace = -1; + } + else if (!isWhiteSpaceLike(char)) { + firstNonWhitespace = pos; + } + pos++; } - return token = 10 /* JsxText */; + return firstNonWhitespace === -1 ? 11 /* JsxTextAllWhiteSpaces */ : 10 /* JsxText */; } // Scans a JSX identifier; these differ from normal identifiers in that // they allow dashes @@ -6399,42 +6427,42 @@ var ts; return token = 5 /* WhitespaceTrivia */; case 64 /* at */: pos++; - return token = 56 /* AtToken */; + return token = 57 /* AtToken */; case 10 /* lineFeed */: case 13 /* carriageReturn */: pos++; return token = 4 /* NewLineTrivia */; case 42 /* asterisk */: pos++; - return token = 38 /* AsteriskToken */; + return token = 39 /* AsteriskToken */; case 123 /* openBrace */: pos++; - return token = 16 /* OpenBraceToken */; + return token = 17 /* OpenBraceToken */; case 125 /* closeBrace */: pos++; - return token = 17 /* CloseBraceToken */; + return token = 18 /* CloseBraceToken */; case 91 /* openBracket */: pos++; - return token = 20 /* OpenBracketToken */; + return token = 21 /* OpenBracketToken */; case 93 /* closeBracket */: pos++; - return token = 21 /* CloseBracketToken */; + return token = 22 /* CloseBracketToken */; case 61 /* equals */: pos++; - return token = 57 /* EqualsToken */; + return token = 58 /* EqualsToken */; case 44 /* comma */: pos++; - return token = 25 /* CommaToken */; + return token = 26 /* CommaToken */; case 46 /* dot */: pos++; - return token = 22 /* DotToken */; + return token = 23 /* DotToken */; } if (isIdentifierStart(ch, 5 /* Latest */)) { pos++; while (isIdentifierPart(text.charCodeAt(pos), 5 /* Latest */) && pos < end) { pos++; } - return token = 70 /* Identifier */; + return token = 71 /* Identifier */; } else { return pos += 1, token = 0 /* Unknown */; @@ -6666,7 +6694,7 @@ var ts; } } function getSourceFileOfNode(node) { - while (node && node.kind !== 264 /* SourceFile */) { + while (node && node.kind !== 265 /* SourceFile */) { node = node.parent; } return node; @@ -6674,11 +6702,11 @@ var ts; ts.getSourceFileOfNode = getSourceFileOfNode; function isStatementWithLocals(node) { switch (node.kind) { - case 206 /* Block */: - case 234 /* CaseBlock */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 207 /* Block */: + case 235 /* CaseBlock */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: return true; } return false; @@ -6753,6 +6781,10 @@ var ts; return !nodeIsMissing(node); } ts.nodeIsPresent = nodeIsPresent; + function isToken(n) { + return n.kind >= 0 /* FirstToken */ && n.kind <= 142 /* LastToken */; + } + ts.isToken = isToken; function getTokenPosOfNode(node, sourceFile, includeJsDoc) { // With nodes that have no width (i.e. 'Missing' nodes), we actually *don't* // want to skip trivia because this will launch us forward to the next token. @@ -6769,18 +6801,18 @@ var ts; // the syntax list itself considers them as normal trivia. Therefore if we simply skip // trivia for the list, we may have skipped the JSDocComment as well. So we should process its // first child to determine the actual position of its first token. - if (node.kind === 296 /* SyntaxList */ && node._children.length > 0) { + if (node.kind === 294 /* SyntaxList */ && node._children.length > 0) { return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc); } return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos); } ts.getTokenPosOfNode = getTokenPosOfNode; function isJSDocNode(node) { - return node.kind >= 266 /* FirstJSDocNode */ && node.kind <= 295 /* LastJSDocNode */; + return node.kind >= 267 /* FirstJSDocNode */ && node.kind <= 293 /* LastJSDocNode */; } ts.isJSDocNode = isJSDocNode; function isJSDocTag(node) { - return node.kind >= 282 /* FirstJSDocTagNode */ && node.kind <= 295 /* LastJSDocTagNode */; + return node.kind >= 283 /* FirstJSDocTagNode */ && node.kind <= 293 /* LastJSDocTagNode */; } ts.isJSDocTag = isJSDocTag; function getNonDecoratorTokenPosOfNode(node, sourceFile) { @@ -6811,33 +6843,24 @@ var ts; return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia); } ts.getTextOfNode = getTextOfNode; - function getLiteralText(node, sourceFile, languageVersion) { - // Any template literal or string literal with an extended escape - // (e.g. "\u{0067}") will need to be downleveled as a escaped string literal. - if (languageVersion < 2 /* ES2015 */ && (isTemplateLiteralKind(node.kind) || node.hasExtendedUnicodeEscape)) { - return getQuotedEscapedLiteralText('"', node.text, '"'); - } + function getLiteralText(node, sourceFile) { // If we don't need to downlevel and we can reach the original source text using // the node's parent reference, then simply get the text as it was originally written. if (!nodeIsSynthesized(node) && node.parent) { - var text = getSourceTextOfNodeFromSourceFile(sourceFile, node); - if (languageVersion < 2 /* ES2015 */ && isBinaryOrOctalIntegerLiteral(node, text)) { - return node.text; - } - return text; + return getSourceTextOfNodeFromSourceFile(sourceFile, node); } // If we can't reach the original source text, use the canonical form if it's a number, // or an escaped quoted form of the original text if it's string-like. switch (node.kind) { case 9 /* StringLiteral */: return getQuotedEscapedLiteralText('"', node.text, '"'); - case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return getQuotedEscapedLiteralText("`", node.text, "`"); - case 13 /* TemplateHead */: + case 14 /* TemplateHead */: return getQuotedEscapedLiteralText("`", node.text, "${"); - case 14 /* TemplateMiddle */: + case 15 /* TemplateMiddle */: return getQuotedEscapedLiteralText("}", node.text, "${"); - case 15 /* TemplateTail */: + case 16 /* TemplateTail */: return getQuotedEscapedLiteralText("}", node.text, "`"); case 8 /* NumericLiteral */: return node.text; @@ -6845,53 +6868,6 @@ var ts; ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for."); } ts.getLiteralText = getLiteralText; - function isBinaryOrOctalIntegerLiteral(node, text) { - return node.kind === 8 /* NumericLiteral */ - && (getNumericLiteralFlags(text, /*hint*/ 6 /* BinaryOrOctal */) & 6 /* BinaryOrOctal */) !== 0; - } - ts.isBinaryOrOctalIntegerLiteral = isBinaryOrOctalIntegerLiteral; - var NumericLiteralFlags; - (function (NumericLiteralFlags) { - NumericLiteralFlags[NumericLiteralFlags["None"] = 0] = "None"; - NumericLiteralFlags[NumericLiteralFlags["Hexadecimal"] = 1] = "Hexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["Binary"] = 2] = "Binary"; - NumericLiteralFlags[NumericLiteralFlags["Octal"] = 4] = "Octal"; - NumericLiteralFlags[NumericLiteralFlags["Scientific"] = 8] = "Scientific"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctal"] = 6] = "BinaryOrOctal"; - NumericLiteralFlags[NumericLiteralFlags["BinaryOrOctalOrHexadecimal"] = 7] = "BinaryOrOctalOrHexadecimal"; - NumericLiteralFlags[NumericLiteralFlags["All"] = 15] = "All"; - })(NumericLiteralFlags = ts.NumericLiteralFlags || (ts.NumericLiteralFlags = {})); - /** - * Scans a numeric literal string to determine the form of the number. - * @param text Numeric literal text - * @param hint If `Scientific` or `All` is specified, performs a more expensive check to scan for scientific notation. - */ - function getNumericLiteralFlags(text, hint) { - if (text.length > 1) { - switch (text.charCodeAt(1)) { - case 98 /* b */: - case 66 /* B */: - return 2 /* Binary */; - case 111 /* o */: - case 79 /* O */: - return 4 /* Octal */; - case 120 /* x */: - case 88 /* X */: - return 1 /* Hexadecimal */; - } - if (hint & 8 /* Scientific */) { - for (var i = text.length - 1; i >= 0; i--) { - switch (text.charCodeAt(i)) { - case 101 /* e */: - case 69 /* E */: - return 8 /* Scientific */; - } - } - } - } - return 0 /* None */; - } - ts.getNumericLiteralFlags = getNumericLiteralFlags; function getQuotedEscapedLiteralText(leftQuote, text, rightQuote) { return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; } @@ -6913,26 +6889,26 @@ var ts; ts.isBlockOrCatchScoped = isBlockOrCatchScoped; function isCatchClauseVariableDeclarationOrBindingElement(declaration) { var node = getRootDeclaration(declaration); - return node.kind === 225 /* VariableDeclaration */ && node.parent.kind === 259 /* CatchClause */; + return node.kind === 226 /* VariableDeclaration */ && node.parent.kind === 260 /* CatchClause */; } ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement; function isAmbientModule(node) { - return node && node.kind === 232 /* ModuleDeclaration */ && + return node && node.kind === 233 /* ModuleDeclaration */ && (node.name.kind === 9 /* StringLiteral */ || isGlobalScopeAugmentation(node)); } ts.isAmbientModule = isAmbientModule; - /** Given a symbol for a module, checks that it is either an untyped import or a shorthand ambient module. */ + /** Given a symbol for a module, checks that it is a shorthand ambient module. */ function isShorthandAmbientModuleSymbol(moduleSymbol) { return isShorthandAmbientModule(moduleSymbol.valueDeclaration); } ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol; function isShorthandAmbientModule(node) { // The only kind of module that can be missing a body is a shorthand ambient module. - return node && node.kind === 232 /* ModuleDeclaration */ && (!node.body); + return node && node.kind === 233 /* ModuleDeclaration */ && (!node.body); } function isBlockScopedContainerTopLevel(node) { - return node.kind === 264 /* SourceFile */ || - node.kind === 232 /* ModuleDeclaration */ || + return node.kind === 265 /* SourceFile */ || + node.kind === 233 /* ModuleDeclaration */ || isFunctionLike(node); } ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel; @@ -6948,9 +6924,9 @@ var ts; return false; } switch (node.parent.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: return ts.isExternalModule(node.parent); - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: return isAmbientModule(node.parent.parent) && !ts.isExternalModule(node.parent.parent.parent); } return false; @@ -6962,22 +6938,22 @@ var ts; ts.isEffectiveExternalModule = isEffectiveExternalModule; function isBlockScope(node, parentNode) { switch (node.kind) { - case 264 /* SourceFile */: - case 234 /* CaseBlock */: - case 259 /* CatchClause */: - case 232 /* ModuleDeclaration */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 265 /* SourceFile */: + case 235 /* CaseBlock */: + case 260 /* CatchClause */: + case 233 /* ModuleDeclaration */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return true; - case 206 /* Block */: + case 207 /* Block */: // function block is not considered block-scope container // see comment in binder.ts: bind(...), case for SyntaxKind.Block return parentNode && !isFunctionLike(parentNode); @@ -7004,14 +6980,18 @@ var ts; return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } ts.declarationNameToString = declarationNameToString; + function getNameFromIndexInfo(info) { + return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; + } + ts.getNameFromIndexInfo = getNameFromIndexInfo; function getTextOfPropertyName(name) { switch (name.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return name.text; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: return name.text; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: if (isStringOrNumericLiteral(name.expression)) { return name.expression.text; } @@ -7021,11 +7001,11 @@ var ts; ts.getTextOfPropertyName = getTextOfPropertyName; function entityNameToString(name) { switch (name.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return getFullWidth(name) === 0 ? ts.unescapeIdentifier(name.text) : getTextOfNode(name); - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return entityNameToString(name.left) + "." + entityNameToString(name.right); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return entityNameToString(name.expression) + "." + entityNameToString(name.name); } } @@ -7062,7 +7042,7 @@ var ts; ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition; function getErrorSpanForArrowFunction(sourceFile, node) { var pos = ts.skipTrivia(sourceFile.text, node.pos); - if (node.body && node.body.kind === 206 /* Block */) { + if (node.body && node.body.kind === 207 /* Block */) { var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line; var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line; if (startLine < endLine) { @@ -7076,7 +7056,7 @@ var ts; function getErrorSpanForNode(sourceFile, node) { var errorNode = node; switch (node.kind) { - case 264 /* SourceFile */: + case 265 /* 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 @@ -7085,23 +7065,23 @@ var ts; return getSpanOfTokenAtPosition(sourceFile, pos_1); // This list is a work in progress. Add missing node kinds to improve their error // spans. - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 231 /* EnumDeclaration */: - case 263 /* EnumMember */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 230 /* TypeAliasDeclaration */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: + case 264 /* EnumMember */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 231 /* TypeAliasDeclaration */: errorNode = node.name; break; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return getErrorSpanForArrowFunction(sourceFile, node); } if (errorNode === undefined) { @@ -7124,7 +7104,7 @@ var ts; } ts.isDeclarationFile = isDeclarationFile; function isConstEnumDeclaration(node) { - return node.kind === 231 /* EnumDeclaration */ && isConst(node); + return node.kind === 232 /* EnumDeclaration */ && isConst(node); } ts.isConstEnumDeclaration = isConstEnumDeclaration; function isConst(node) { @@ -7137,11 +7117,11 @@ var ts; } ts.isLet = isLet; function isSuperCall(n) { - return n.kind === 180 /* CallExpression */ && n.expression.kind === 96 /* SuperKeyword */; + return n.kind === 181 /* CallExpression */ && n.expression.kind === 97 /* SuperKeyword */; } ts.isSuperCall = isSuperCall; function isPrologueDirective(node) { - return node.kind === 209 /* ExpressionStatement */ + return node.kind === 210 /* ExpressionStatement */ && node.expression.kind === 9 /* StringLiteral */; } ts.isPrologueDirective = isPrologueDirective; @@ -7154,10 +7134,10 @@ var ts; } ts.getLeadingCommentRangesOfNodeFromText = getLeadingCommentRangesOfNodeFromText; function getJSDocCommentRanges(node, text) { - var commentRanges = (node.kind === 145 /* Parameter */ || - node.kind === 144 /* TypeParameter */ || - node.kind === 185 /* FunctionExpression */ || - node.kind === 186 /* ArrowFunction */) ? + var commentRanges = (node.kind === 146 /* Parameter */ || + node.kind === 145 /* TypeParameter */ || + node.kind === 186 /* FunctionExpression */ || + node.kind === 187 /* ArrowFunction */) ? ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) : getLeadingCommentRangesOfNodeFromText(node, text); // True if the comment starts with '/**' but not if it is '/**/' @@ -7172,79 +7152,80 @@ var ts; ts.fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*/; ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*/; function isPartOfTypeNode(node) { - if (157 /* FirstTypeNode */ <= node.kind && node.kind <= 172 /* LastTypeNode */) { + if (158 /* FirstTypeNode */ <= node.kind && node.kind <= 173 /* LastTypeNode */) { return true; } switch (node.kind) { - case 118 /* AnyKeyword */: - case 132 /* NumberKeyword */: - case 135 /* StringKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 138 /* UndefinedKeyword */: - case 129 /* NeverKeyword */: + case 119 /* AnyKeyword */: + case 133 /* NumberKeyword */: + case 136 /* StringKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 139 /* UndefinedKeyword */: + case 130 /* NeverKeyword */: return true; - case 104 /* VoidKeyword */: - return node.parent.kind !== 189 /* VoidExpression */; - case 200 /* ExpressionWithTypeArguments */: + case 105 /* VoidKeyword */: + return node.parent.kind !== 190 /* VoidExpression */; + case 201 /* 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 70 /* Identifier */: + case 71 /* Identifier */: // If the identifier is the RHS of a qualified name, then it's a type iff its parent is. - if (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) { + if (node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node) { node = node.parent; } - else if (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node) { + else if (node.parent.kind === 179 /* 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 === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); - case 142 /* QualifiedName */: - case 178 /* PropertyAccessExpression */: - case 98 /* ThisKeyword */: + ts.Debug.assert(node.kind === 71 /* Identifier */ || node.kind === 143 /* QualifiedName */ || node.kind === 179 /* PropertyAccessExpression */, "'node' was expected to be a qualified name, identifier or property access in 'isPartOfTypeNode'."); + // falls through + case 143 /* QualifiedName */: + case 179 /* PropertyAccessExpression */: + case 99 /* ThisKeyword */: var parent = node.parent; - if (parent.kind === 161 /* TypeQuery */) { + if (parent.kind === 162 /* TypeQuery */) { return false; } // Do not recursively call isPartOfTypeNode on the parent. In the example: // // let a: A.B.C; // - // Calling isPartOfTypeNode would consider the qualified name A.B a type node. Only C or - // A.B.C is a type node. - if (157 /* FirstTypeNode */ <= parent.kind && parent.kind <= 172 /* LastTypeNode */) { + // Calling isPartOfTypeNode would consider the qualified name A.B a type node. + // Only C and A.B.C are type nodes. + if (158 /* FirstTypeNode */ <= parent.kind && parent.kind <= 173 /* LastTypeNode */) { return true; } switch (parent.kind) { - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return !isExpressionWithTypeArgumentsInClassExtendsClause(parent); - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return node === parent.constraint; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 145 /* Parameter */: - case 225 /* VariableDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 146 /* Parameter */: + case 226 /* VariableDeclaration */: return node === parent.type; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return node === parent.type; - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: return node === parent.type; - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return node === parent.type; - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return parent.typeArguments && ts.indexOf(parent.typeArguments, node) >= 0; - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: // TODO (drosen): TaggedTemplateExpressions may eventually support type arguments. return false; } @@ -7263,7 +7244,7 @@ var ts; } ts.isChildOfNodeWithKind = isChildOfNodeWithKind; function isPrefixUnaryExpression(node) { - return node.kind === 191 /* PrefixUnaryExpression */; + return node.kind === 192 /* PrefixUnaryExpression */; } ts.isPrefixUnaryExpression = isPrefixUnaryExpression; // Warning: This has the same semantics as the forEach family of functions, @@ -7272,23 +7253,23 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitor(node); - case 234 /* CaseBlock */: - case 206 /* Block */: - case 210 /* IfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 219 /* WithStatement */: - case 220 /* SwitchStatement */: - case 256 /* CaseClause */: - case 257 /* DefaultClause */: - case 221 /* LabeledStatement */: - case 223 /* TryStatement */: - case 259 /* CatchClause */: + case 235 /* CaseBlock */: + case 207 /* Block */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 220 /* WithStatement */: + case 221 /* SwitchStatement */: + case 257 /* CaseClause */: + case 258 /* DefaultClause */: + case 222 /* LabeledStatement */: + case 224 /* TryStatement */: + case 260 /* CatchClause */: return ts.forEachChild(node, traverse); } } @@ -7298,18 +7279,19 @@ var ts; return traverse(body); function traverse(node) { switch (node.kind) { - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: visitor(node); var operand = node.expression; if (operand) { traverse(operand); } - case 231 /* EnumDeclaration */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + return; + case 232 /* EnumDeclaration */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* 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. @@ -7317,7 +7299,7 @@ var ts; default: if (isFunctionLike(node)) { var name = node.name; - if (name && name.kind === 143 /* ComputedPropertyName */) { + if (name && name.kind === 144 /* 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.expression); @@ -7340,10 +7322,10 @@ var ts; * @param node The type node. */ function getRestParameterElementType(node) { - if (node && node.kind === 163 /* ArrayType */) { + if (node && node.kind === 164 /* ArrayType */) { return node.elementType; } - else if (node && node.kind === 158 /* TypeReference */) { + else if (node && node.kind === 159 /* TypeReference */) { return ts.singleOrUndefined(node.typeArguments); } else { @@ -7354,14 +7336,14 @@ var ts; function isVariableLike(node) { if (node) { switch (node.kind) { - case 175 /* BindingElement */: - case 263 /* EnumMember */: - case 145 /* Parameter */: - case 260 /* PropertyAssignment */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 261 /* ShorthandPropertyAssignment */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 264 /* EnumMember */: + case 146 /* Parameter */: + case 261 /* PropertyAssignment */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 262 /* ShorthandPropertyAssignment */: + case 226 /* VariableDeclaration */: return true; } } @@ -7369,11 +7351,11 @@ var ts; } ts.isVariableLike = isVariableLike; function isAccessor(node) { - return node && (node.kind === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */); + return node && (node.kind === 153 /* GetAccessor */ || node.kind === 154 /* SetAccessor */); } ts.isAccessor = isAccessor; function isClassLike(node) { - return node && (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */); + return node && (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */); } ts.isClassLike = isClassLike; function isFunctionLike(node) { @@ -7382,19 +7364,19 @@ var ts; ts.isFunctionLike = isFunctionLike; function isFunctionLikeKind(kind) { switch (kind) { - case 151 /* Constructor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 152 /* Constructor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return true; } return false; @@ -7402,13 +7384,13 @@ var ts; ts.isFunctionLikeKind = isFunctionLikeKind; function introducesArgumentsExoticObject(node) { switch (node.kind) { - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return true; } return false; @@ -7416,42 +7398,42 @@ var ts; ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject; function isIterationStatement(node, lookInLabeledStatements) { switch (node.kind) { - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: return true; - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements); } return false; } ts.isIterationStatement = isIterationStatement; - function unwrapInnermostStatmentOfLabel(node, beforeUnwrapLabelCallback) { + function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) { while (true) { if (beforeUnwrapLabelCallback) { beforeUnwrapLabelCallback(node); } - if (node.statement.kind !== 221 /* LabeledStatement */) { + if (node.statement.kind !== 222 /* LabeledStatement */) { return node.statement; } node = node.statement; } } - ts.unwrapInnermostStatmentOfLabel = unwrapInnermostStatmentOfLabel; + ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel; function isFunctionBlock(node) { - return node && node.kind === 206 /* Block */ && isFunctionLike(node.parent); + return node && node.kind === 207 /* Block */ && isFunctionLike(node.parent); } ts.isFunctionBlock = isFunctionBlock; function isObjectLiteralMethod(node) { - return node && node.kind === 150 /* MethodDeclaration */ && node.parent.kind === 177 /* ObjectLiteralExpression */; + return node && node.kind === 151 /* MethodDeclaration */ && node.parent.kind === 178 /* ObjectLiteralExpression */; } ts.isObjectLiteralMethod = isObjectLiteralMethod; function isObjectLiteralOrClassExpressionMethod(node) { - return node.kind === 150 /* MethodDeclaration */ && - (node.parent.kind === 177 /* ObjectLiteralExpression */ || - node.parent.kind === 198 /* ClassExpression */); + return node.kind === 151 /* MethodDeclaration */ && + (node.parent.kind === 178 /* ObjectLiteralExpression */ || + node.parent.kind === 199 /* ClassExpression */); } ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod; function isIdentifierTypePredicate(predicate) { @@ -7487,7 +7469,7 @@ var ts; return undefined; } switch (node.kind) { - case 143 /* ComputedPropertyName */: + case 144 /* 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 @@ -7502,9 +7484,9 @@ var ts; // the *body* of the container. node = node.parent; break; - case 146 /* Decorator */: + case 147 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 145 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 146 /* 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; @@ -7515,26 +7497,26 @@ var ts; node = node.parent; } break; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: if (!includeArrowFunctions) { continue; } - // Fall through - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 232 /* ModuleDeclaration */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 231 /* EnumDeclaration */: - case 264 /* SourceFile */: + // falls through + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 233 /* ModuleDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 232 /* EnumDeclaration */: + case 265 /* SourceFile */: return node; } } @@ -7544,9 +7526,9 @@ var ts; var container = getThisContainer(node, /*includeArrowFunctions*/ false); if (container) { switch (container.kind) { - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return container; } } @@ -7554,13 +7536,13 @@ var ts; } ts.getNewTargetContainer = getNewTargetContainer; /** - * Given an super call/property node, returns the closest node where - * - a super call/property access is legal in the node and not legal in the parent node the node. - * i.e. super call is legal in constructor but not legal in the class body. - * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) - * - a super call/property is definitely illegal in the container (but might be legal in some subnode) - * i.e. super property access is illegal in function declaration but can be legal in the statement list - */ + * Given an super call/property node, returns the closest node where + * - a super call/property access is legal in the node and not legal in the parent node the node. + * i.e. super call is legal in constructor but not legal in the class body. + * - the container is an arrow function (so caller might need to call getSuperContainer again in case it needs to climb higher) + * - a super call/property is definitely illegal in the container (but might be legal in some subnode) + * i.e. super property access is illegal in function declaration but can be legal in the statement list + */ function getSuperContainer(node, stopOnFunctions) { while (true) { node = node.parent; @@ -7568,26 +7550,27 @@ var ts; return node; } switch (node.kind) { - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: node = node.parent; break; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: if (!stopOnFunctions) { continue; } - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + // falls through + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return node; - case 146 /* Decorator */: + case 147 /* Decorator */: // Decorators are always applied outside of the body of a class or method. - if (node.parent.kind === 145 /* Parameter */ && isClassElement(node.parent.parent)) { + if (node.parent.kind === 146 /* 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; @@ -7603,14 +7586,14 @@ var ts; } ts.getSuperContainer = getSuperContainer; function getImmediatelyInvokedFunctionExpression(func) { - if (func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */) { + if (func.kind === 186 /* FunctionExpression */ || func.kind === 187 /* ArrowFunction */) { var prev = func; var parent = func.parent; - while (parent.kind === 184 /* ParenthesizedExpression */) { + while (parent.kind === 185 /* ParenthesizedExpression */) { prev = parent; parent = parent.parent; } - if (parent.kind === 180 /* CallExpression */ && parent.expression === prev) { + if (parent.kind === 181 /* CallExpression */ && parent.expression === prev) { return parent; } } @@ -7621,21 +7604,21 @@ var ts; */ function isSuperProperty(node) { var kind = node.kind; - return (kind === 178 /* PropertyAccessExpression */ || kind === 179 /* ElementAccessExpression */) - && node.expression.kind === 96 /* SuperKeyword */; + return (kind === 179 /* PropertyAccessExpression */ || kind === 180 /* ElementAccessExpression */) + && node.expression.kind === 97 /* SuperKeyword */; } ts.isSuperProperty = isSuperProperty; function getEntityNameFromTypeNode(node) { switch (node.kind) { - case 158 /* TypeReference */: - case 276 /* JSDocTypeReference */: + case 159 /* TypeReference */: + case 277 /* JSDocTypeReference */: return node.typeName; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return isEntityNameExpression(node.expression) ? node.expression : undefined; - case 70 /* Identifier */: - case 142 /* QualifiedName */: + case 71 /* Identifier */: + case 143 /* QualifiedName */: return node; } return undefined; @@ -7643,12 +7626,12 @@ var ts; ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode; function isCallLikeExpression(node) { switch (node.kind) { - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 182 /* TaggedTemplateExpression */: - case 146 /* Decorator */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 183 /* TaggedTemplateExpression */: + case 147 /* Decorator */: return true; default: return false; @@ -7656,7 +7639,7 @@ var ts; } ts.isCallLikeExpression = isCallLikeExpression; function getInvokedExpression(node) { - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* TaggedTemplateExpression */) { return node.tag; } else if (isJsxOpeningLikeElement(node)) { @@ -7668,25 +7651,25 @@ var ts; ts.getInvokedExpression = getInvokedExpression; function nodeCanBeDecorated(node) { switch (node.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: // classes are valid targets return true; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // property declarations are valid if their parent is a class declaration. - return node.parent.kind === 228 /* ClassDeclaration */; - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 150 /* MethodDeclaration */: + return node.parent.kind === 229 /* ClassDeclaration */; + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 151 /* 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 === 228 /* ClassDeclaration */; - case 145 /* Parameter */: + && node.parent.kind === 229 /* ClassDeclaration */; + case 146 /* 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 === 151 /* Constructor */ - || node.parent.kind === 150 /* MethodDeclaration */ - || node.parent.kind === 153 /* SetAccessor */) - && node.parent.parent.kind === 228 /* ClassDeclaration */; + && (node.parent.kind === 152 /* Constructor */ + || node.parent.kind === 151 /* MethodDeclaration */ + || node.parent.kind === 154 /* SetAccessor */) + && node.parent.parent.kind === 229 /* ClassDeclaration */; } return false; } @@ -7702,19 +7685,19 @@ var ts; ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated; function childIsDecorated(node) { switch (node.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return ts.forEach(node.members, nodeOrChildIsDecorated); - case 150 /* MethodDeclaration */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 154 /* SetAccessor */: return ts.forEach(node.parameters, nodeIsDecorated); } } ts.childIsDecorated = childIsDecorated; function isJSXTagName(node) { var parent = node.parent; - if (parent.kind === 250 /* JsxOpeningElement */ || - parent.kind === 249 /* JsxSelfClosingElement */ || - parent.kind === 251 /* JsxClosingElement */) { + if (parent.kind === 251 /* JsxOpeningElement */ || + parent.kind === 250 /* JsxSelfClosingElement */ || + parent.kind === 252 /* JsxClosingElement */) { return parent.tagName === node; } return false; @@ -7722,100 +7705,100 @@ var ts; ts.isJSXTagName = isJSXTagName; function isPartOfExpression(node) { switch (node.kind) { - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: - case 11 /* RegularExpressionLiteral */: - case 176 /* ArrayLiteralExpression */: - case 177 /* ObjectLiteralExpression */: - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 182 /* TaggedTemplateExpression */: - case 201 /* AsExpression */: - case 183 /* TypeAssertionExpression */: - case 202 /* NonNullExpression */: - case 184 /* ParenthesizedExpression */: - case 185 /* FunctionExpression */: - case 198 /* ClassExpression */: - case 186 /* ArrowFunction */: - case 189 /* VoidExpression */: - case 187 /* DeleteExpression */: - case 188 /* TypeOfExpression */: - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: - case 193 /* BinaryExpression */: - case 194 /* ConditionalExpression */: - case 197 /* SpreadElement */: - case 195 /* TemplateExpression */: - case 12 /* NoSubstitutionTemplateLiteral */: - case 199 /* OmittedExpression */: - case 248 /* JsxElement */: - case 249 /* JsxSelfClosingElement */: - case 196 /* YieldExpression */: - case 190 /* AwaitExpression */: - case 203 /* MetaProperty */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 12 /* RegularExpressionLiteral */: + case 177 /* ArrayLiteralExpression */: + case 178 /* ObjectLiteralExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 183 /* TaggedTemplateExpression */: + case 202 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 203 /* NonNullExpression */: + case 185 /* ParenthesizedExpression */: + case 186 /* FunctionExpression */: + case 199 /* ClassExpression */: + case 187 /* ArrowFunction */: + case 190 /* VoidExpression */: + case 188 /* DeleteExpression */: + case 189 /* TypeOfExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + case 194 /* BinaryExpression */: + case 195 /* ConditionalExpression */: + case 198 /* SpreadElement */: + case 196 /* TemplateExpression */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 200 /* OmittedExpression */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 197 /* YieldExpression */: + case 191 /* AwaitExpression */: + case 204 /* MetaProperty */: return true; - case 142 /* QualifiedName */: - while (node.parent.kind === 142 /* QualifiedName */) { + case 143 /* QualifiedName */: + while (node.parent.kind === 143 /* QualifiedName */) { node = node.parent; } - return node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node); - case 70 /* Identifier */: - if (node.parent.kind === 161 /* TypeQuery */ || isJSXTagName(node)) { + return node.parent.kind === 162 /* TypeQuery */ || isJSXTagName(node); + case 71 /* Identifier */: + if (node.parent.kind === 162 /* TypeQuery */ || isJSXTagName(node)) { return true; } - // fall through + // falls through case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: var parent = node.parent; switch (parent.kind) { - case 225 /* VariableDeclaration */: - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 263 /* EnumMember */: - case 260 /* PropertyAssignment */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 264 /* EnumMember */: + case 261 /* PropertyAssignment */: + case 176 /* BindingElement */: return parent.initializer === node; - case 209 /* ExpressionStatement */: - case 210 /* IfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 218 /* ReturnStatement */: - case 219 /* WithStatement */: - case 220 /* SwitchStatement */: - case 256 /* CaseClause */: - case 222 /* ThrowStatement */: - case 220 /* SwitchStatement */: + case 210 /* ExpressionStatement */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 219 /* ReturnStatement */: + case 220 /* WithStatement */: + case 221 /* SwitchStatement */: + case 257 /* CaseClause */: + case 223 /* ThrowStatement */: + case 221 /* SwitchStatement */: return parent.expression === node; - case 213 /* ForStatement */: + case 214 /* ForStatement */: var forStatement = parent; - return (forStatement.initializer === node && forStatement.initializer.kind !== 226 /* VariableDeclarationList */) || + return (forStatement.initializer === node && forStatement.initializer.kind !== 227 /* VariableDeclarationList */) || forStatement.condition === node || forStatement.incrementor === node; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: var forInStatement = parent; - return (forInStatement.initializer === node && forInStatement.initializer.kind !== 226 /* VariableDeclarationList */) || + return (forInStatement.initializer === node && forInStatement.initializer.kind !== 227 /* VariableDeclarationList */) || forInStatement.expression === node; - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: return node === parent.expression; - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return node === parent.expression; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return node === parent.expression; - case 146 /* Decorator */: - case 255 /* JsxExpression */: - case 254 /* JsxSpreadAttribute */: - case 262 /* SpreadAssignment */: + case 147 /* Decorator */: + case 256 /* JsxExpression */: + case 255 /* JsxSpreadAttribute */: + case 263 /* SpreadAssignment */: return true; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent); default: if (isPartOfExpression(parent)) { @@ -7833,7 +7816,7 @@ var ts; } ts.isInstantiatedModule = isInstantiatedModule; function isExternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */; + return node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 248 /* ExternalModuleReference */; } ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration; function getExternalModuleImportEqualsDeclarationExpression(node) { @@ -7842,7 +7825,7 @@ var ts; } ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression; function isInternalModuleImportEqualsDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 247 /* ExternalModuleReference */; + return node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind !== 248 /* ExternalModuleReference */; } ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration; function isSourceFileJavaScript(file) { @@ -7855,16 +7838,22 @@ var ts; ts.isInJavaScriptFile = isInJavaScriptFile; /** * Returns true if the node is a CallExpression to the identifier 'require' with - * exactly one argument. + * exactly one argument (of the form 'require("name")'). * This function does not test if the node is in a JavaScript file or not. - */ - function isRequireCall(expression, checkArgumentIsStringLiteral) { - // of the form 'require("name")' - var isRequire = expression.kind === 180 /* CallExpression */ && - expression.expression.kind === 70 /* Identifier */ && - expression.expression.text === "require" && - expression.arguments.length === 1; - return isRequire && (!checkArgumentIsStringLiteral || expression.arguments[0].kind === 9 /* StringLiteral */); + */ + function isRequireCall(callExpression, checkArgumentIsStringLiteral) { + if (callExpression.kind !== 181 /* CallExpression */) { + return false; + } + var _a = callExpression, expression = _a.expression, args = _a.arguments; + if (expression.kind !== 71 /* Identifier */ || expression.text !== "require") { + return false; + } + if (args.length !== 1) { + return false; + } + var arg = args[0]; + return !checkArgumentIsStringLiteral || arg.kind === 9 /* StringLiteral */ || arg.kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isRequireCall = isRequireCall; function isSingleOrDoubleQuote(charCode) { @@ -7875,29 +7864,41 @@ var ts; * Returns true if the node is a variable declaration whose initializer is a function expression. * This function does not test if the node is in a JavaScript file or not. */ - function isDeclarationOfFunctionExpression(s) { - if (s.valueDeclaration && s.valueDeclaration.kind === 225 /* VariableDeclaration */) { + function isDeclarationOfFunctionOrClassExpression(s) { + if (s.valueDeclaration && s.valueDeclaration.kind === 226 /* VariableDeclaration */) { var declaration = s.valueDeclaration; - return declaration.initializer && declaration.initializer.kind === 185 /* FunctionExpression */; + return declaration.initializer && (declaration.initializer.kind === 186 /* FunctionExpression */ || declaration.initializer.kind === 199 /* ClassExpression */); } return false; } - ts.isDeclarationOfFunctionExpression = isDeclarationOfFunctionExpression; + ts.isDeclarationOfFunctionOrClassExpression = isDeclarationOfFunctionOrClassExpression; + function getRightMostAssignedExpression(node) { + while (isAssignmentExpression(node, /*excludeCompoundAssignements*/ true)) { + node = node.right; + } + return node; + } + ts.getRightMostAssignedExpression = getRightMostAssignedExpression; + function isExportsIdentifier(node) { + return isIdentifier(node) && node.text === "exports"; + } + ts.isExportsIdentifier = isExportsIdentifier; + function isModuleExportsPropertyAccessExpression(node) { + return isPropertyAccessExpression(node) && isIdentifier(node.expression) && node.expression.text === "module" && node.name.text === "exports"; + } + ts.isModuleExportsPropertyAccessExpression = isModuleExportsPropertyAccessExpression; /// Given a BinaryExpression, returns SpecialPropertyAssignmentKind for the various kinds of property /// assignments we treat as special in the binder function getSpecialPropertyAssignmentKind(expression) { if (!isInJavaScriptFile(expression)) { return 0 /* None */; } - if (expression.kind !== 193 /* BinaryExpression */) { - return 0 /* None */; - } var expr = expression; - if (expr.operatorToken.kind !== 57 /* EqualsToken */ || expr.left.kind !== 178 /* PropertyAccessExpression */) { + if (expr.operatorToken.kind !== 58 /* EqualsToken */ || expr.left.kind !== 179 /* PropertyAccessExpression */) { return 0 /* None */; } var lhs = expr.left; - if (lhs.expression.kind === 70 /* Identifier */) { + if (lhs.expression.kind === 71 /* Identifier */) { var lhsId = lhs.expression; if (lhsId.text === "exports") { // exports.name = expr @@ -7907,14 +7908,18 @@ var ts; // module.exports = expr return 2 /* ModuleExports */; } + else { + // F.x = expr + return 5 /* Property */; + } } - else if (lhs.expression.kind === 98 /* ThisKeyword */) { + else if (lhs.expression.kind === 99 /* ThisKeyword */) { return 4 /* ThisProperty */; } - else if (lhs.expression.kind === 178 /* PropertyAccessExpression */) { + else if (lhs.expression.kind === 179 /* PropertyAccessExpression */) { // chained dot, e.g. x.y.z = expr; this var is the 'x.y' part var innerPropertyAccess = lhs.expression; - if (innerPropertyAccess.expression.kind === 70 /* Identifier */) { + if (innerPropertyAccess.expression.kind === 71 /* Identifier */) { // module.exports.name = expr var innerPropertyAccessIdentifier = innerPropertyAccess.expression; if (innerPropertyAccessIdentifier.text === "module" && innerPropertyAccess.name.text === "exports") { @@ -7929,35 +7934,35 @@ var ts; } ts.getSpecialPropertyAssignmentKind = getSpecialPropertyAssignmentKind; function getExternalModuleName(node) { - if (node.kind === 237 /* ImportDeclaration */) { + if (node.kind === 238 /* ImportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { var reference = node.moduleReference; - if (reference.kind === 247 /* ExternalModuleReference */) { + if (reference.kind === 248 /* ExternalModuleReference */) { return reference.expression; } } - if (node.kind === 243 /* ExportDeclaration */) { + if (node.kind === 244 /* ExportDeclaration */) { return node.moduleSpecifier; } - if (node.kind === 232 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { + if (node.kind === 233 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */) { return node.name; } } ts.getExternalModuleName = getExternalModuleName; function getNamespaceDeclarationNode(node) { - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { return node; } var importClause = node.importClause; - if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (importClause && importClause.namedBindings && importClause.namedBindings.kind === 240 /* NamespaceImport */) { return importClause.namedBindings; } } ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode; function isDefaultImport(node) { - return node.kind === 237 /* ImportDeclaration */ + return node.kind === 238 /* ImportDeclaration */ && node.importClause && !!node.importClause.name; } @@ -7965,13 +7970,13 @@ var ts; function hasQuestionToken(node) { if (node) { switch (node.kind) { - case 145 /* Parameter */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 261 /* ShorthandPropertyAssignment */: - case 260 /* PropertyAssignment */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 146 /* Parameter */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 262 /* ShorthandPropertyAssignment */: + case 261 /* PropertyAssignment */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return node.questionToken !== undefined; } } @@ -7979,9 +7984,9 @@ var ts; } ts.hasQuestionToken = hasQuestionToken; function isJSDocConstructSignature(node) { - return node.kind === 278 /* JSDocFunctionType */ && + return node.kind === 279 /* JSDocFunctionType */ && node.parameters.length > 0 && - node.parameters[0].type.kind === 280 /* JSDocConstructorType */; + node.parameters[0].type.kind === 281 /* JSDocConstructorType */; } ts.isJSDocConstructSignature = isJSDocConstructSignature; function getCommentsFromJSDoc(node) { @@ -7989,7 +7994,7 @@ var ts; } ts.getCommentsFromJSDoc = getCommentsFromJSDoc; function hasJSDocParameterTags(node) { - var parameterTags = getJSDocTags(node, 285 /* JSDocParameterTag */); + var parameterTags = getJSDocTags(node, 286 /* JSDocParameterTag */); return parameterTags && parameterTags.length > 0; } ts.hasJSDocParameterTags = hasJSDocParameterTags; @@ -7999,13 +8004,16 @@ var ts; var result = []; for (var _i = 0, docs_1 = docs; _i < docs_1.length; _i++) { var doc = docs_1[_i]; - if (doc.kind === 285 /* JSDocParameterTag */) { + if (doc.kind === 286 /* JSDocParameterTag */) { if (doc.kind === kind) { result.push(doc); } } else { - result.push.apply(result, ts.filter(doc.tags, function (tag) { return tag.kind === kind; })); + var tags = doc.tags; + if (tags) { + result.push.apply(result, ts.filter(tags, function (tag) { return tag.kind === kind; })); + } } } return result; @@ -8031,9 +8039,9 @@ var ts; // var x = function(name) { return name.length; } var isInitializerOfVariableDeclarationInStatement = isVariableLike(parent) && parent.initializer === node && - parent.parent.parent.kind === 207 /* VariableStatement */; + parent.parent.parent.kind === 208 /* VariableStatement */; var isVariableOfVariableDeclarationStatement = isVariableLike(node) && - parent.parent.kind === 207 /* VariableStatement */; + parent.parent.kind === 208 /* VariableStatement */; var variableStatementNode = isInitializerOfVariableDeclarationInStatement ? parent.parent.parent : isVariableOfVariableDeclarationStatement ? parent.parent : undefined; @@ -8042,20 +8050,20 @@ var ts; } // Also recognize when the node is the RHS of an assignment expression var isSourceOfAssignmentExpressionStatement = parent && parent.parent && - parent.kind === 193 /* BinaryExpression */ && - parent.operatorToken.kind === 57 /* EqualsToken */ && - parent.parent.kind === 209 /* ExpressionStatement */; + parent.kind === 194 /* BinaryExpression */ && + parent.operatorToken.kind === 58 /* EqualsToken */ && + parent.parent.kind === 210 /* ExpressionStatement */; if (isSourceOfAssignmentExpressionStatement) { getJSDocsWorker(parent.parent); } - var isModuleDeclaration = node.kind === 232 /* ModuleDeclaration */ && - parent && parent.kind === 232 /* ModuleDeclaration */; - var isPropertyAssignmentExpression = parent && parent.kind === 260 /* PropertyAssignment */; + var isModuleDeclaration = node.kind === 233 /* ModuleDeclaration */ && + parent && parent.kind === 233 /* ModuleDeclaration */; + var isPropertyAssignmentExpression = parent && parent.kind === 261 /* PropertyAssignment */; if (isModuleDeclaration || isPropertyAssignmentExpression) { getJSDocsWorker(parent); } // Pull parameter comments from declaring function as well - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { cache = ts.concatenate(cache, getJSDocParameterTags(node)); } if (isVariableLike(node) && node.initializer) { @@ -8064,23 +8072,24 @@ var ts; cache = ts.concatenate(cache, node.jsDoc); } } + ts.getJSDocs = getJSDocs; function getJSDocParameterTags(param) { if (!isParameter(param)) { return undefined; } var func = param.parent; - var tags = getJSDocTags(func, 285 /* JSDocParameterTag */); + var tags = getJSDocTags(func, 286 /* JSDocParameterTag */); if (!param.name) { // this is an anonymous jsdoc param from a `function(type1, type2): type3` specification var i = func.parameters.indexOf(param); - var paramTags = ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */; }); + var paramTags = ts.filter(tags, function (tag) { return tag.kind === 286 /* JSDocParameterTag */; }); if (paramTags && 0 <= i && i < paramTags.length) { return [paramTags[i]]; } } - else if (param.name.kind === 70 /* Identifier */) { + else if (param.name.kind === 71 /* Identifier */) { var name_1 = param.name.text; - return ts.filter(tags, function (tag) { return tag.kind === 285 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); + return ts.filter(tags, function (tag) { return tag.kind === 286 /* JSDocParameterTag */ && tag.parameterName.text === name_1; }); } else { // TODO: it's a destructured parameter, so it should look up an "object type" series of multiple lines @@ -8090,8 +8099,8 @@ var ts; } ts.getJSDocParameterTags = getJSDocParameterTags; function getJSDocType(node) { - var tag = getFirstJSDocTag(node, 287 /* JSDocTypeTag */); - if (!tag && node.kind === 145 /* Parameter */) { + var tag = getFirstJSDocTag(node, 288 /* JSDocTypeTag */); + if (!tag && node.kind === 146 /* Parameter */) { var paramTags = getJSDocParameterTags(node); if (paramTags) { tag = ts.find(paramTags, function (tag) { return !!tag.typeExpression; }); @@ -8101,15 +8110,15 @@ var ts; } ts.getJSDocType = getJSDocType; function getJSDocAugmentsTag(node) { - return getFirstJSDocTag(node, 284 /* JSDocAugmentsTag */); + return getFirstJSDocTag(node, 285 /* JSDocAugmentsTag */); } ts.getJSDocAugmentsTag = getJSDocAugmentsTag; function getJSDocReturnTag(node) { - return getFirstJSDocTag(node, 286 /* JSDocReturnTag */); + return getFirstJSDocTag(node, 287 /* JSDocReturnTag */); } ts.getJSDocReturnTag = getJSDocReturnTag; function getJSDocTemplateTag(node) { - return getFirstJSDocTag(node, 288 /* JSDocTemplateTag */); + return getFirstJSDocTag(node, 289 /* JSDocTemplateTag */); } ts.getJSDocTemplateTag = getJSDocTemplateTag; function hasRestParameter(s) { @@ -8122,8 +8131,8 @@ var ts; ts.hasDeclaredRestParameter = hasDeclaredRestParameter; function isRestParameter(node) { if (node && (node.flags & 65536 /* JavaScriptFile */)) { - if (node.type && node.type.kind === 279 /* JSDocVariadicType */ || - ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 279 /* JSDocVariadicType */; })) { + if (node.type && node.type.kind === 280 /* JSDocVariadicType */ || + ts.forEach(getJSDocParameterTags(node), function (t) { return t.typeExpression && t.typeExpression.type.kind === 280 /* JSDocVariadicType */; })) { return true; } } @@ -8144,30 +8153,30 @@ var ts; var parent = node.parent; while (true) { switch (parent.kind) { - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: var binaryOperator = parent.operatorToken.kind; return isAssignmentOperator(binaryOperator) && parent.left === node ? - binaryOperator === 57 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : + binaryOperator === 58 /* EqualsToken */ ? 1 /* Definite */ : 2 /* Compound */ : 0 /* None */; - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: var unaryOperator = parent.operator; - return unaryOperator === 42 /* PlusPlusToken */ || unaryOperator === 43 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + return unaryOperator === 43 /* PlusPlusToken */ || unaryOperator === 44 /* MinusMinusToken */ ? 2 /* Compound */ : 0 /* None */; + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: return parent.initializer === node ? 1 /* Definite */ : 0 /* None */; - case 184 /* ParenthesizedExpression */: - case 176 /* ArrayLiteralExpression */: - case 197 /* SpreadElement */: + case 185 /* ParenthesizedExpression */: + case 177 /* ArrayLiteralExpression */: + case 198 /* SpreadElement */: node = parent; break; - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: if (parent.name !== node) { return 0 /* None */; } node = parent.parent; break; - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: if (parent.name === node) { return 0 /* None */; } @@ -8190,14 +8199,14 @@ var ts; ts.isAssignmentTarget = isAssignmentTarget; // a node is delete target iff. it is PropertyAccessExpression/ElementAccessExpression with parentheses skipped function isDeleteTarget(node) { - if (node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { + if (node.kind !== 179 /* PropertyAccessExpression */ && node.kind !== 180 /* ElementAccessExpression */) { return false; } node = node.parent; - while (node && node.kind === 184 /* ParenthesizedExpression */) { + while (node && node.kind === 185 /* ParenthesizedExpression */) { node = node.parent; } - return node && node.kind === 187 /* DeleteExpression */; + return node && node.kind === 188 /* DeleteExpression */; } ts.isDeleteTarget = isDeleteTarget; function isNodeDescendantOf(node, ancestor) { @@ -8211,7 +8220,7 @@ var ts; ts.isNodeDescendantOf = isNodeDescendantOf; function isInAmbientContext(node) { while (node) { - if (hasModifier(node, 2 /* Ambient */) || (node.kind === 264 /* SourceFile */ && node.isDeclarationFile)) { + if (hasModifier(node, 2 /* Ambient */) || (node.kind === 265 /* SourceFile */ && node.isDeclarationFile)) { return true; } node = node.parent; @@ -8221,11 +8230,11 @@ var ts; ts.isInAmbientContext = isInAmbientContext; // True if the given identifier, string literal, or number literal is the name of a declaration node function isDeclarationName(name) { - if (name.kind !== 70 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { + if (name.kind !== 71 /* Identifier */ && name.kind !== 9 /* StringLiteral */ && name.kind !== 8 /* NumericLiteral */) { return false; } var parent = name.parent; - if (parent.kind === 241 /* ImportSpecifier */ || parent.kind === 245 /* ExportSpecifier */) { + if (parent.kind === 242 /* ImportSpecifier */ || parent.kind === 246 /* ExportSpecifier */) { if (parent.propertyName) { return true; } @@ -8238,7 +8247,7 @@ var ts; ts.isDeclarationName = isDeclarationName; function isLiteralComputedPropertyDeclarationName(node) { return (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) && - node.parent.kind === 143 /* ComputedPropertyName */ && + node.parent.kind === 144 /* ComputedPropertyName */ && isDeclaration(node.parent.parent); } ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName; @@ -8246,31 +8255,31 @@ var ts; function isIdentifierName(node) { var parent = node.parent; switch (parent.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 263 /* EnumMember */: - case 260 /* PropertyAssignment */: - case 178 /* PropertyAccessExpression */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 264 /* EnumMember */: + case 261 /* PropertyAssignment */: + case 179 /* PropertyAccessExpression */: // Name in member declaration or property name in property access return parent.name === node; - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: // Name on right hand side of dot in a type query if (parent.right === node) { - while (parent.kind === 142 /* QualifiedName */) { + while (parent.kind === 143 /* QualifiedName */) { parent = parent.parent; } - return parent.kind === 161 /* TypeQuery */; + return parent.kind === 162 /* TypeQuery */; } return false; - case 175 /* BindingElement */: - case 241 /* ImportSpecifier */: + case 176 /* BindingElement */: + case 242 /* ImportSpecifier */: // Property name in binding element or import specifier return parent.propertyName === node; - case 245 /* ExportSpecifier */: + case 246 /* ExportSpecifier */: // Any name in an export specifier return true; } @@ -8286,13 +8295,13 @@ var ts; // export = // export default function isAliasSymbolDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */ || - node.kind === 235 /* NamespaceExportDeclaration */ || - node.kind === 238 /* ImportClause */ && !!node.name || - node.kind === 239 /* NamespaceImport */ || - node.kind === 241 /* ImportSpecifier */ || - node.kind === 245 /* ExportSpecifier */ || - node.kind === 242 /* ExportAssignment */ && exportAssignmentIsAlias(node); + return node.kind === 237 /* ImportEqualsDeclaration */ || + node.kind === 236 /* NamespaceExportDeclaration */ || + node.kind === 239 /* ImportClause */ && !!node.name || + node.kind === 240 /* NamespaceImport */ || + node.kind === 242 /* ImportSpecifier */ || + node.kind === 246 /* ExportSpecifier */ || + node.kind === 243 /* ExportAssignment */ && exportAssignmentIsAlias(node); } ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration; function exportAssignmentIsAlias(node) { @@ -8300,17 +8309,17 @@ var ts; } ts.exportAssignmentIsAlias = exportAssignmentIsAlias; function getClassExtendsHeritageClauseElement(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined; } ts.getClassExtendsHeritageClauseElement = getClassExtendsHeritageClauseElement; function getClassImplementsHeritageClauseElements(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 107 /* ImplementsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 108 /* ImplementsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getClassImplementsHeritageClauseElements = getClassImplementsHeritageClauseElements; function getInterfaceBaseTypeNodes(node) { - var heritageClause = getHeritageClause(node.heritageClauses, 84 /* ExtendsKeyword */); + var heritageClause = getHeritageClause(node.heritageClauses, 85 /* ExtendsKeyword */); return heritageClause ? heritageClause.types : undefined; } ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes; @@ -8378,17 +8387,62 @@ var ts; } ts.getFileReferenceFromReferencePath = getFileReferenceFromReferencePath; function isKeyword(token) { - return 71 /* FirstKeyword */ <= token && token <= 141 /* LastKeyword */; + return 72 /* FirstKeyword */ <= token && token <= 142 /* LastKeyword */; } ts.isKeyword = isKeyword; function isTrivia(token) { return 2 /* FirstTriviaToken */ <= token && token <= 7 /* LastTriviaToken */; } ts.isTrivia = isTrivia; - function isAsyncFunctionLike(node) { - return isFunctionLike(node) && hasModifier(node, 256 /* Async */) && !isAccessor(node); + var FunctionFlags; + (function (FunctionFlags) { + FunctionFlags[FunctionFlags["Normal"] = 0] = "Normal"; + FunctionFlags[FunctionFlags["Generator"] = 1] = "Generator"; + FunctionFlags[FunctionFlags["Async"] = 2] = "Async"; + FunctionFlags[FunctionFlags["AsyncOrAsyncGenerator"] = 3] = "AsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["Invalid"] = 4] = "Invalid"; + FunctionFlags[FunctionFlags["InvalidAsyncOrAsyncGenerator"] = 7] = "InvalidAsyncOrAsyncGenerator"; + FunctionFlags[FunctionFlags["InvalidGenerator"] = 5] = "InvalidGenerator"; + })(FunctionFlags = ts.FunctionFlags || (ts.FunctionFlags = {})); + function getFunctionFlags(node) { + var flags = 0 /* Normal */; + switch (node.kind) { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + if (node.asteriskToken) { + flags |= 1 /* Generator */; + } + // falls through + case 187 /* ArrowFunction */: + if (hasModifier(node, 256 /* Async */)) { + flags |= 2 /* Async */; + } + break; + } + if (!node.body) { + flags |= 4 /* Invalid */; + } + return flags; } - ts.isAsyncFunctionLike = isAsyncFunctionLike; + ts.getFunctionFlags = getFunctionFlags; + function isAsyncFunction(node) { + switch (node.kind) { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + return node.body !== undefined + && node.asteriskToken === undefined + && hasModifier(node, 256 /* Async */); + } + return false; + } + ts.isAsyncFunction = isAsyncFunction; + function isNumericLiteral(node) { + return node.kind === 8 /* NumericLiteral */; + } + ts.isNumericLiteral = isNumericLiteral; function isStringOrNumericLiteral(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ @@ -8407,7 +8461,7 @@ var ts; } ts.hasDynamicName = hasDynamicName; function isDynamicName(name) { - return name.kind === 143 /* ComputedPropertyName */ && + return name.kind === 144 /* ComputedPropertyName */ && !isStringOrNumericLiteral(name.expression) && !isWellKnownSymbolSyntactically(name.expression); } @@ -8422,10 +8476,10 @@ var ts; } ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically; function getPropertyNameForPropertyNameNode(name) { - if (name.kind === 70 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 145 /* Parameter */) { + if (name.kind === 71 /* Identifier */ || name.kind === 9 /* StringLiteral */ || name.kind === 8 /* NumericLiteral */ || name.kind === 146 /* Parameter */) { return name.text; } - if (name.kind === 143 /* ComputedPropertyName */) { + if (name.kind === 144 /* ComputedPropertyName */) { var nameExpression = name.expression; if (isWellKnownSymbolSyntactically(nameExpression)) { var rightHandSideName = nameExpression.name.text; @@ -8446,7 +8500,7 @@ var ts; * Includes the word "Symbol" with unicode escapes */ function isESSymbolIdentifier(node) { - return node.kind === 70 /* Identifier */ && node.text === "Symbol"; + return node.kind === 71 /* Identifier */ && node.text === "Symbol"; } ts.isESSymbolIdentifier = isESSymbolIdentifier; function isPushOrUnshiftIdentifier(node) { @@ -8455,17 +8509,17 @@ var ts; ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier; function isModifierKind(token) { switch (token) { - case 116 /* AbstractKeyword */: - case 119 /* AsyncKeyword */: - case 75 /* ConstKeyword */: - case 123 /* DeclareKeyword */: - case 78 /* DefaultKeyword */: - case 83 /* ExportKeyword */: - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 130 /* ReadonlyKeyword */: - case 114 /* StaticKeyword */: + case 117 /* AbstractKeyword */: + case 120 /* AsyncKeyword */: + case 76 /* ConstKeyword */: + case 124 /* DeclareKeyword */: + case 79 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 131 /* ReadonlyKeyword */: + case 115 /* StaticKeyword */: return true; } return false; @@ -8473,11 +8527,11 @@ var ts; ts.isModifierKind = isModifierKind; function isParameterDeclaration(node) { var root = getRootDeclaration(node); - return root.kind === 145 /* Parameter */; + return root.kind === 146 /* Parameter */; } ts.isParameterDeclaration = isParameterDeclaration; function getRootDeclaration(node) { - while (node.kind === 175 /* BindingElement */) { + while (node.kind === 176 /* BindingElement */) { node = node.parent.parent; } return node; @@ -8485,15 +8539,15 @@ var ts; ts.getRootDeclaration = getRootDeclaration; function nodeStartsNewLexicalEnvironment(node) { var kind = node.kind; - return kind === 151 /* Constructor */ - || kind === 185 /* FunctionExpression */ - || kind === 227 /* FunctionDeclaration */ - || kind === 186 /* ArrowFunction */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 232 /* ModuleDeclaration */ - || kind === 264 /* SourceFile */; + return kind === 152 /* Constructor */ + || kind === 186 /* FunctionExpression */ + || kind === 228 /* FunctionDeclaration */ + || kind === 187 /* ArrowFunction */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 233 /* ModuleDeclaration */ + || kind === 265 /* SourceFile */; } ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment; function nodeIsSynthesized(node) { @@ -8502,7 +8556,7 @@ var ts; } ts.nodeIsSynthesized = nodeIsSynthesized; function getOriginalSourceFileOrBundle(sourceFileOrBundle) { - if (sourceFileOrBundle.kind === 265 /* Bundle */) { + if (sourceFileOrBundle.kind === 266 /* Bundle */) { return ts.updateBundle(sourceFileOrBundle, ts.sameMap(sourceFileOrBundle.sourceFiles, getOriginalSourceFile)); } return getOriginalSourceFile(sourceFileOrBundle); @@ -8527,38 +8581,38 @@ var ts; })(Associativity = ts.Associativity || (ts.Associativity = {})); function getExpressionAssociativity(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 /* NewExpression */ && expression.arguments !== undefined; return getOperatorAssociativity(expression.kind, operator, hasArguments); } ts.getExpressionAssociativity = getExpressionAssociativity; function getOperatorAssociativity(kind, operator, hasArguments) { switch (kind) { - case 181 /* NewExpression */: + case 182 /* NewExpression */: return hasArguments ? 0 /* Left */ : 1 /* Right */; - case 191 /* PrefixUnaryExpression */: - case 188 /* TypeOfExpression */: - case 189 /* VoidExpression */: - case 187 /* DeleteExpression */: - case 190 /* AwaitExpression */: - case 194 /* ConditionalExpression */: - case 196 /* YieldExpression */: + case 192 /* PrefixUnaryExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 188 /* DeleteExpression */: + case 191 /* AwaitExpression */: + case 195 /* ConditionalExpression */: + case 197 /* YieldExpression */: return 1 /* Right */; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (operator) { - case 39 /* AsteriskAsteriskToken */: - case 57 /* EqualsToken */: - case 58 /* PlusEqualsToken */: - case 59 /* MinusEqualsToken */: - case 61 /* AsteriskAsteriskEqualsToken */: - case 60 /* AsteriskEqualsToken */: - case 62 /* SlashEqualsToken */: - case 63 /* PercentEqualsToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 67 /* AmpersandEqualsToken */: - case 69 /* CaretEqualsToken */: - case 68 /* BarEqualsToken */: + case 40 /* AsteriskAsteriskToken */: + case 58 /* EqualsToken */: + case 59 /* PlusEqualsToken */: + case 60 /* MinusEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: + case 61 /* AsteriskEqualsToken */: + case 63 /* SlashEqualsToken */: + case 64 /* PercentEqualsToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 68 /* AmpersandEqualsToken */: + case 70 /* CaretEqualsToken */: + case 69 /* BarEqualsToken */: return 1 /* Right */; } } @@ -8567,15 +8621,15 @@ var ts; ts.getOperatorAssociativity = getOperatorAssociativity; function getExpressionPrecedence(expression) { var operator = getOperator(expression); - var hasArguments = expression.kind === 181 /* NewExpression */ && expression.arguments !== undefined; + var hasArguments = expression.kind === 182 /* NewExpression */ && expression.arguments !== undefined; return getOperatorPrecedence(expression.kind, operator, hasArguments); } ts.getExpressionPrecedence = getExpressionPrecedence; function getOperator(expression) { - if (expression.kind === 193 /* BinaryExpression */) { + if (expression.kind === 194 /* BinaryExpression */) { return expression.operatorToken.kind; } - else if (expression.kind === 191 /* PrefixUnaryExpression */ || expression.kind === 192 /* PostfixUnaryExpression */) { + else if (expression.kind === 192 /* PrefixUnaryExpression */ || expression.kind === 193 /* PostfixUnaryExpression */) { return expression.operator; } else { @@ -8585,106 +8639,106 @@ var ts; ts.getOperator = getOperator; function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) { switch (nodeKind) { - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 70 /* Identifier */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 71 /* Identifier */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 176 /* ArrayLiteralExpression */: - case 177 /* ObjectLiteralExpression */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 198 /* ClassExpression */: - case 248 /* JsxElement */: - case 249 /* JsxSelfClosingElement */: - case 11 /* RegularExpressionLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: - case 195 /* TemplateExpression */: - case 184 /* ParenthesizedExpression */: - case 199 /* OmittedExpression */: + case 177 /* ArrayLiteralExpression */: + case 178 /* ObjectLiteralExpression */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 199 /* ClassExpression */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 196 /* TemplateExpression */: + case 185 /* ParenthesizedExpression */: + case 200 /* OmittedExpression */: return 19; - case 182 /* TaggedTemplateExpression */: - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: + case 183 /* TaggedTemplateExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: return 18; - case 181 /* NewExpression */: + case 182 /* NewExpression */: return hasArguments ? 18 : 17; - case 180 /* CallExpression */: + case 181 /* CallExpression */: return 17; - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return 16; - case 191 /* PrefixUnaryExpression */: - case 188 /* TypeOfExpression */: - case 189 /* VoidExpression */: - case 187 /* DeleteExpression */: - case 190 /* AwaitExpression */: + case 192 /* PrefixUnaryExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 188 /* DeleteExpression */: + case 191 /* AwaitExpression */: return 15; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (operatorKind) { - case 50 /* ExclamationToken */: - case 51 /* TildeToken */: + case 51 /* ExclamationToken */: + case 52 /* TildeToken */: return 15; - case 39 /* AsteriskAsteriskToken */: - case 38 /* AsteriskToken */: - case 40 /* SlashToken */: - case 41 /* PercentToken */: + case 40 /* AsteriskAsteriskToken */: + case 39 /* AsteriskToken */: + case 41 /* SlashToken */: + case 42 /* PercentToken */: return 14; - case 36 /* PlusToken */: - case 37 /* MinusToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: return 13; - case 44 /* LessThanLessThanToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* LessThanLessThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: return 12; - case 26 /* LessThanToken */: - case 29 /* LessThanEqualsToken */: - case 28 /* GreaterThanToken */: - case 30 /* GreaterThanEqualsToken */: - case 91 /* InKeyword */: - case 92 /* InstanceOfKeyword */: + case 27 /* LessThanToken */: + case 30 /* LessThanEqualsToken */: + case 29 /* GreaterThanToken */: + case 31 /* GreaterThanEqualsToken */: + case 92 /* InKeyword */: + case 93 /* InstanceOfKeyword */: return 11; - case 31 /* EqualsEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: return 10; - case 47 /* AmpersandToken */: + case 48 /* AmpersandToken */: return 9; - case 49 /* CaretToken */: + case 50 /* CaretToken */: return 8; - case 48 /* BarToken */: + case 49 /* BarToken */: return 7; - case 52 /* AmpersandAmpersandToken */: + case 53 /* AmpersandAmpersandToken */: return 6; - case 53 /* BarBarToken */: + case 54 /* BarBarToken */: return 5; - case 57 /* EqualsToken */: - case 58 /* PlusEqualsToken */: - case 59 /* MinusEqualsToken */: - case 61 /* AsteriskAsteriskEqualsToken */: - case 60 /* AsteriskEqualsToken */: - case 62 /* SlashEqualsToken */: - case 63 /* PercentEqualsToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 67 /* AmpersandEqualsToken */: - case 69 /* CaretEqualsToken */: - case 68 /* BarEqualsToken */: + case 58 /* EqualsToken */: + case 59 /* PlusEqualsToken */: + case 60 /* MinusEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: + case 61 /* AsteriskEqualsToken */: + case 63 /* SlashEqualsToken */: + case 64 /* PercentEqualsToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 68 /* AmpersandEqualsToken */: + case 70 /* CaretEqualsToken */: + case 69 /* BarEqualsToken */: return 3; - case 25 /* CommaToken */: + case 26 /* CommaToken */: return 0; default: return -1; } - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return 4; - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return 2; - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return 1; default: return -1; @@ -8980,7 +9034,7 @@ var ts; if (sourceFiles.length) { var jsFilePath = options.outFile || options.out; var sourceMapFilePath = getSourceMapFilePath(jsFilePath, options); - var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : undefined; + var declarationFilePath = options.declaration ? ts.removeFileExtension(jsFilePath) + ".d.ts" : ""; action({ jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath }, ts.createBundle(sourceFiles), emitOnlyDtsFiles); } } @@ -9039,7 +9093,7 @@ var ts; ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap; function getFirstConstructorWithBody(node) { return ts.forEach(node.members, function (member) { - if (member.kind === 151 /* Constructor */ && nodeIsPresent(member.body)) { + if (member.kind === 152 /* Constructor */ && nodeIsPresent(member.body)) { return member; } }); @@ -9067,11 +9121,11 @@ var ts; } ts.parameterIsThisKeyword = parameterIsThisKeyword; function isThisIdentifier(node) { - return node && node.kind === 70 /* Identifier */ && identifierIsThisKeyword(node); + return node && node.kind === 71 /* Identifier */ && identifierIsThisKeyword(node); } ts.isThisIdentifier = isThisIdentifier; function identifierIsThisKeyword(id) { - return id.originalKeywordKind === 98 /* ThisKeyword */; + return id.originalKeywordKind === 99 /* ThisKeyword */; } ts.identifierIsThisKeyword = identifierIsThisKeyword; function getAllAccessorDeclarations(declarations, accessor) { @@ -9081,10 +9135,10 @@ var ts; var setAccessor; if (hasDynamicName(accessor)) { firstAccessor = accessor; - if (accessor.kind === 152 /* GetAccessor */) { + if (accessor.kind === 153 /* GetAccessor */) { getAccessor = accessor; } - else if (accessor.kind === 153 /* SetAccessor */) { + else if (accessor.kind === 154 /* SetAccessor */) { setAccessor = accessor; } else { @@ -9093,7 +9147,7 @@ var ts; } else { ts.forEach(declarations, function (member) { - if ((member.kind === 152 /* GetAccessor */ || member.kind === 153 /* SetAccessor */) + if ((member.kind === 153 /* GetAccessor */ || member.kind === 154 /* SetAccessor */) && hasModifier(member, 32 /* Static */) === hasModifier(accessor, 32 /* Static */)) { var memberName = getPropertyNameForPropertyNameNode(member.name); var accessorName = getPropertyNameForPropertyNameNode(accessor.name); @@ -9104,10 +9158,10 @@ var ts; else if (!secondAccessor) { secondAccessor = member; } - if (member.kind === 152 /* GetAccessor */ && !getAccessor) { + if (member.kind === 153 /* GetAccessor */ && !getAccessor) { getAccessor = member; } - if (member.kind === 153 /* SetAccessor */ && !setAccessor) { + if (member.kind === 154 /* SetAccessor */ && !setAccessor) { setAccessor = member; } } @@ -9334,7 +9388,7 @@ var ts; flags |= modifierToFlag(modifier.kind); } } - if (node.flags & 4 /* NestedNamespace */ || (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace)) { + if (node.flags & 4 /* NestedNamespace */ || (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace)) { flags |= 1 /* Export */; } node.modifierFlagsCache = flags | 536870912 /* HasComputedFlags */; @@ -9343,35 +9397,35 @@ var ts; ts.getModifierFlags = getModifierFlags; function modifierToFlag(token) { switch (token) { - case 114 /* StaticKeyword */: return 32 /* Static */; - case 113 /* PublicKeyword */: return 4 /* Public */; - case 112 /* ProtectedKeyword */: return 16 /* Protected */; - case 111 /* PrivateKeyword */: return 8 /* Private */; - case 116 /* AbstractKeyword */: return 128 /* Abstract */; - case 83 /* ExportKeyword */: return 1 /* Export */; - case 123 /* DeclareKeyword */: return 2 /* Ambient */; - case 75 /* ConstKeyword */: return 2048 /* Const */; - case 78 /* DefaultKeyword */: return 512 /* Default */; - case 119 /* AsyncKeyword */: return 256 /* Async */; - case 130 /* ReadonlyKeyword */: return 64 /* Readonly */; + case 115 /* StaticKeyword */: return 32 /* Static */; + case 114 /* PublicKeyword */: return 4 /* Public */; + case 113 /* ProtectedKeyword */: return 16 /* Protected */; + case 112 /* PrivateKeyword */: return 8 /* Private */; + case 117 /* AbstractKeyword */: return 128 /* Abstract */; + case 84 /* ExportKeyword */: return 1 /* Export */; + case 124 /* DeclareKeyword */: return 2 /* Ambient */; + case 76 /* ConstKeyword */: return 2048 /* Const */; + case 79 /* DefaultKeyword */: return 512 /* Default */; + case 120 /* AsyncKeyword */: return 256 /* Async */; + case 131 /* ReadonlyKeyword */: return 64 /* Readonly */; } return 0 /* None */; } ts.modifierToFlag = modifierToFlag; function isLogicalOperator(token) { - return token === 53 /* BarBarToken */ - || token === 52 /* AmpersandAmpersandToken */ - || token === 50 /* ExclamationToken */; + return token === 54 /* BarBarToken */ + || token === 53 /* AmpersandAmpersandToken */ + || token === 51 /* ExclamationToken */; } ts.isLogicalOperator = isLogicalOperator; function isAssignmentOperator(token) { - return token >= 57 /* FirstAssignment */ && token <= 69 /* LastAssignment */; + return token >= 58 /* FirstAssignment */ && token <= 70 /* LastAssignment */; } ts.isAssignmentOperator = isAssignmentOperator; /** Get `C` given `N` if `N` is in the position `class C extends N` where `N` is an ExpressionWithTypeArguments. */ function tryGetClassExtendingExpressionWithTypeArguments(node) { - if (node.kind === 200 /* ExpressionWithTypeArguments */ && - node.parent.token === 84 /* ExtendsKeyword */ && + if (node.kind === 201 /* ExpressionWithTypeArguments */ && + node.parent.token === 85 /* ExtendsKeyword */ && isClassLike(node.parent.parent)) { return node.parent.parent; } @@ -9380,7 +9434,7 @@ var ts; function isAssignmentExpression(node, excludeCompoundAssignment) { return isBinaryExpression(node) && (excludeCompoundAssignment - ? node.operatorToken.kind === 57 /* EqualsToken */ + ? node.operatorToken.kind === 58 /* EqualsToken */ : isAssignmentOperator(node.operatorToken.kind)) && isLeftHandSideExpression(node.left); } @@ -9388,8 +9442,8 @@ var ts; function isDestructuringAssignment(node) { if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { var kind = node.left.kind; - return kind === 177 /* ObjectLiteralExpression */ - || kind === 176 /* ArrayLiteralExpression */; + return kind === 178 /* ObjectLiteralExpression */ + || kind === 177 /* ArrayLiteralExpression */; } return false; } @@ -9401,7 +9455,7 @@ var ts; } ts.isSupportedExpressionWithTypeArguments = isSupportedExpressionWithTypeArguments; function isSupportedExpressionWithTypeArgumentsRest(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { return true; } else if (isPropertyAccessExpression(node)) { @@ -9415,27 +9469,35 @@ var ts; return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined; } ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause; + function isExpressionWithTypeArgumentsInClassImplementsClause(node) { + return node.kind === 201 /* ExpressionWithTypeArguments */ + && isEntityNameExpression(node.expression) + && node.parent + && node.parent.token === 108 /* ImplementsKeyword */ + && node.parent.parent + && isClassLike(node.parent.parent); + } + ts.isExpressionWithTypeArgumentsInClassImplementsClause = isExpressionWithTypeArgumentsInClassImplementsClause; function isEntityNameExpression(node) { - return node.kind === 70 /* Identifier */ || - node.kind === 178 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); + return node.kind === 71 /* Identifier */ || + node.kind === 179 /* PropertyAccessExpression */ && isEntityNameExpression(node.expression); } ts.isEntityNameExpression = isEntityNameExpression; function isRightSideOfQualifiedNameOrPropertyAccess(node) { - return (node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node) || - (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node); + return (node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node) || + (node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.name === node); } ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess; - function isEmptyObjectLiteralOrArrayLiteral(expression) { - var kind = expression.kind; - if (kind === 177 /* ObjectLiteralExpression */) { - return expression.properties.length === 0; - } - if (kind === 176 /* ArrayLiteralExpression */) { - return expression.elements.length === 0; - } - return false; + function isEmptyObjectLiteral(expression) { + return expression.kind === 178 /* ObjectLiteralExpression */ && + expression.properties.length === 0; } - ts.isEmptyObjectLiteralOrArrayLiteral = isEmptyObjectLiteralOrArrayLiteral; + ts.isEmptyObjectLiteral = isEmptyObjectLiteral; + function isEmptyArrayLiteral(expression) { + return expression.kind === 177 /* ArrayLiteralExpression */ && + expression.elements.length === 0; + } + ts.isEmptyArrayLiteral = isEmptyArrayLiteral; function getLocalSymbolForExportDefault(symbol) { return isExportDefaultSymbol(symbol) ? symbol.valueDeclaration.localSymbol : undefined; } @@ -9443,7 +9505,6 @@ var ts; function isExportDefaultSymbol(symbol) { return symbol && symbol.valueDeclaration && hasModifier(symbol.valueDeclaration, 512 /* Default */); } - ts.isExportDefaultSymbol = isExportDefaultSymbol; /** Return ".ts", ".d.ts", or ".tsx", if that is the extension. */ function tryExtractTypeScriptExtension(fileName) { return ts.find(ts.supportedTypescriptExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); }); @@ -9545,49 +9606,49 @@ var ts; var kind = node.kind; if (kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 11 /* RegularExpressionLiteral */ - || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 70 /* Identifier */ - || kind === 98 /* ThisKeyword */ - || kind === 96 /* SuperKeyword */ - || kind === 100 /* TrueKeyword */ - || kind === 85 /* FalseKeyword */ - || kind === 94 /* NullKeyword */) { + || kind === 12 /* RegularExpressionLiteral */ + || kind === 13 /* NoSubstitutionTemplateLiteral */ + || kind === 71 /* Identifier */ + || kind === 99 /* ThisKeyword */ + || kind === 97 /* SuperKeyword */ + || kind === 101 /* TrueKeyword */ + || kind === 86 /* FalseKeyword */ + || kind === 95 /* NullKeyword */) { return true; } - else if (kind === 178 /* PropertyAccessExpression */) { + else if (kind === 179 /* PropertyAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 179 /* ElementAccessExpression */) { + else if (kind === 180 /* ElementAccessExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1) && isSimpleExpressionWorker(node.argumentExpression, depth + 1); } - else if (kind === 191 /* PrefixUnaryExpression */ - || kind === 192 /* PostfixUnaryExpression */) { + else if (kind === 192 /* PrefixUnaryExpression */ + || kind === 193 /* PostfixUnaryExpression */) { return isSimpleExpressionWorker(node.operand, depth + 1); } - else if (kind === 193 /* BinaryExpression */) { - return node.operatorToken.kind !== 39 /* AsteriskAsteriskToken */ + else if (kind === 194 /* BinaryExpression */) { + return node.operatorToken.kind !== 40 /* AsteriskAsteriskToken */ && isSimpleExpressionWorker(node.left, depth + 1) && isSimpleExpressionWorker(node.right, depth + 1); } - else if (kind === 194 /* ConditionalExpression */) { + else if (kind === 195 /* ConditionalExpression */) { return isSimpleExpressionWorker(node.condition, depth + 1) && isSimpleExpressionWorker(node.whenTrue, depth + 1) && isSimpleExpressionWorker(node.whenFalse, depth + 1); } - else if (kind === 189 /* VoidExpression */ - || kind === 188 /* TypeOfExpression */ - || kind === 187 /* DeleteExpression */) { + else if (kind === 190 /* VoidExpression */ + || kind === 189 /* TypeOfExpression */ + || kind === 188 /* DeleteExpression */) { return isSimpleExpressionWorker(node.expression, depth + 1); } - else if (kind === 176 /* ArrayLiteralExpression */) { + else if (kind === 177 /* ArrayLiteralExpression */) { return node.elements.length === 0; } - else if (kind === 177 /* ObjectLiteralExpression */) { + else if (kind === 178 /* ObjectLiteralExpression */) { return node.properties.length === 0; } - else if (kind === 180 /* CallExpression */) { + else if (kind === 181 /* CallExpression */) { if (!isSimpleExpressionWorker(node.expression, depth + 1)) { return false; } @@ -9765,8 +9826,8 @@ var ts; var parseNode = ts.getParseTreeNode(node); if (parseNode) { switch (parseNode.parent.kind) { - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: return parseNode === parseNode.parent.name; } } @@ -9787,7 +9848,7 @@ var ts; if (node.symbol) { for (var _i = 0, _a = node.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 228 /* ClassDeclaration */ && declaration !== node) { + if (declaration.kind === 229 /* ClassDeclaration */ && declaration !== node) { return true; } } @@ -9817,15 +9878,15 @@ var ts; ts.isNodeArray = isNodeArray; // Literals function isNoSubstitutionTemplateLiteral(node) { - return node.kind === 12 /* NoSubstitutionTemplateLiteral */; + return node.kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral; function isLiteralKind(kind) { - return 8 /* FirstLiteralToken */ <= kind && kind <= 12 /* LastLiteralToken */; + return 8 /* FirstLiteralToken */ <= kind && kind <= 13 /* LastLiteralToken */; } ts.isLiteralKind = isLiteralKind; function isTextualLiteralKind(kind) { - return kind === 9 /* StringLiteral */ || kind === 12 /* NoSubstitutionTemplateLiteral */; + return kind === 9 /* StringLiteral */ || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTextualLiteralKind = isTextualLiteralKind; function isLiteralExpression(node) { @@ -9834,26 +9895,26 @@ var ts; ts.isLiteralExpression = isLiteralExpression; // Pseudo-literals function isTemplateLiteralKind(kind) { - return 12 /* FirstTemplateToken */ <= kind && kind <= 15 /* LastTemplateToken */; + return 13 /* FirstTemplateToken */ <= kind && kind <= 16 /* LastTemplateToken */; } ts.isTemplateLiteralKind = isTemplateLiteralKind; function isTemplateHead(node) { - return node.kind === 13 /* TemplateHead */; + return node.kind === 14 /* TemplateHead */; } ts.isTemplateHead = isTemplateHead; function isTemplateMiddleOrTemplateTail(node) { var kind = node.kind; - return kind === 14 /* TemplateMiddle */ - || kind === 15 /* TemplateTail */; + return kind === 15 /* TemplateMiddle */ + || kind === 16 /* TemplateTail */; } ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail; // Identifiers function isIdentifier(node) { - return node.kind === 70 /* Identifier */; + return node.kind === 71 /* Identifier */; } ts.isIdentifier = isIdentifier; function isVoidExpression(node) { - return node.kind === 189 /* VoidExpression */; + return node.kind === 190 /* VoidExpression */; } ts.isVoidExpression = isVoidExpression; function isGeneratedIdentifier(node) { @@ -9868,91 +9929,95 @@ var ts; ts.isModifier = isModifier; // Names function isQualifiedName(node) { - return node.kind === 142 /* QualifiedName */; + return node.kind === 143 /* QualifiedName */; } ts.isQualifiedName = isQualifiedName; function isComputedPropertyName(node) { - return node.kind === 143 /* ComputedPropertyName */; + return node.kind === 144 /* ComputedPropertyName */; } ts.isComputedPropertyName = isComputedPropertyName; function isEntityName(node) { var kind = node.kind; - return kind === 142 /* QualifiedName */ - || kind === 70 /* Identifier */; + return kind === 143 /* QualifiedName */ + || kind === 71 /* Identifier */; } ts.isEntityName = isEntityName; function isPropertyName(node) { var kind = node.kind; - return kind === 70 /* Identifier */ + return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */ || kind === 8 /* NumericLiteral */ - || kind === 143 /* ComputedPropertyName */; + || kind === 144 /* ComputedPropertyName */; } ts.isPropertyName = isPropertyName; function isModuleName(node) { var kind = node.kind; - return kind === 70 /* Identifier */ + return kind === 71 /* Identifier */ || kind === 9 /* StringLiteral */; } ts.isModuleName = isModuleName; function isBindingName(node) { var kind = node.kind; - return kind === 70 /* Identifier */ - || kind === 173 /* ObjectBindingPattern */ - || kind === 174 /* ArrayBindingPattern */; + return kind === 71 /* Identifier */ + || kind === 174 /* ObjectBindingPattern */ + || kind === 175 /* ArrayBindingPattern */; } ts.isBindingName = isBindingName; // Signature elements function isTypeParameter(node) { - return node.kind === 144 /* TypeParameter */; + return node.kind === 145 /* TypeParameter */; } ts.isTypeParameter = isTypeParameter; function isParameter(node) { - return node.kind === 145 /* Parameter */; + return node.kind === 146 /* Parameter */; } ts.isParameter = isParameter; function isDecorator(node) { - return node.kind === 146 /* Decorator */; + return node.kind === 147 /* Decorator */; } ts.isDecorator = isDecorator; // Type members function isMethodDeclaration(node) { - return node.kind === 150 /* MethodDeclaration */; + return node.kind === 151 /* MethodDeclaration */; } ts.isMethodDeclaration = isMethodDeclaration; function isClassElement(node) { var kind = node.kind; - return kind === 151 /* Constructor */ - || kind === 148 /* PropertyDeclaration */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 156 /* IndexSignature */ - || kind === 205 /* SemicolonClassElement */; + return kind === 152 /* Constructor */ + || kind === 149 /* PropertyDeclaration */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 157 /* IndexSignature */ + || kind === 206 /* SemicolonClassElement */; } ts.isClassElement = isClassElement; function isObjectLiteralElementLike(node) { var kind = node.kind; - return kind === 260 /* PropertyAssignment */ - || kind === 261 /* ShorthandPropertyAssignment */ - || kind === 262 /* SpreadAssignment */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 246 /* MissingDeclaration */; + return kind === 261 /* PropertyAssignment */ + || kind === 262 /* ShorthandPropertyAssignment */ + || kind === 263 /* SpreadAssignment */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 247 /* MissingDeclaration */; } ts.isObjectLiteralElementLike = isObjectLiteralElementLike; // Type function isTypeNodeKind(kind) { - return (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) - || kind === 118 /* AnyKeyword */ - || kind === 132 /* NumberKeyword */ - || kind === 121 /* BooleanKeyword */ - || kind === 135 /* StringKeyword */ - || kind === 136 /* SymbolKeyword */ - || kind === 104 /* VoidKeyword */ - || kind === 129 /* NeverKeyword */ - || kind === 200 /* ExpressionWithTypeArguments */; + return (kind >= 158 /* FirstTypeNode */ && kind <= 173 /* LastTypeNode */) + || kind === 119 /* AnyKeyword */ + || kind === 133 /* NumberKeyword */ + || kind === 134 /* ObjectKeyword */ + || kind === 122 /* BooleanKeyword */ + || kind === 136 /* StringKeyword */ + || kind === 137 /* SymbolKeyword */ + || kind === 99 /* ThisKeyword */ + || kind === 105 /* VoidKeyword */ + || kind === 139 /* UndefinedKeyword */ + || kind === 95 /* NullKeyword */ + || kind === 130 /* NeverKeyword */ + || kind === 201 /* ExpressionWithTypeArguments */; } /** * Node test that determines whether a node is a valid type node. @@ -9965,36 +10030,36 @@ var ts; ts.isTypeNode = isTypeNode; // Binding patterns function isArrayBindingPattern(node) { - return node.kind === 174 /* ArrayBindingPattern */; + return node.kind === 175 /* ArrayBindingPattern */; } ts.isArrayBindingPattern = isArrayBindingPattern; function isObjectBindingPattern(node) { - return node.kind === 173 /* ObjectBindingPattern */; + return node.kind === 174 /* ObjectBindingPattern */; } ts.isObjectBindingPattern = isObjectBindingPattern; function isBindingPattern(node) { if (node) { var kind = node.kind; - return kind === 174 /* ArrayBindingPattern */ - || kind === 173 /* ObjectBindingPattern */; + return kind === 175 /* ArrayBindingPattern */ + || kind === 174 /* ObjectBindingPattern */; } return false; } ts.isBindingPattern = isBindingPattern; function isAssignmentPattern(node) { var kind = node.kind; - return kind === 176 /* ArrayLiteralExpression */ - || kind === 177 /* ObjectLiteralExpression */; + return kind === 177 /* ArrayLiteralExpression */ + || kind === 178 /* ObjectLiteralExpression */; } ts.isAssignmentPattern = isAssignmentPattern; function isBindingElement(node) { - return node.kind === 175 /* BindingElement */; + return node.kind === 176 /* BindingElement */; } ts.isBindingElement = isBindingElement; function isArrayBindingElement(node) { var kind = node.kind; - return kind === 175 /* BindingElement */ - || kind === 199 /* OmittedExpression */; + return kind === 176 /* BindingElement */ + || kind === 200 /* OmittedExpression */; } ts.isArrayBindingElement = isArrayBindingElement; /** @@ -10002,9 +10067,9 @@ var ts; */ function isDeclarationBindingElement(bindingElement) { switch (bindingElement.kind) { - case 225 /* VariableDeclaration */: - case 145 /* Parameter */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 176 /* BindingElement */: return true; } return false; @@ -10023,8 +10088,8 @@ var ts; */ function isObjectBindingOrAssignmentPattern(node) { switch (node.kind) { - case 173 /* ObjectBindingPattern */: - case 177 /* ObjectLiteralExpression */: + case 174 /* ObjectBindingPattern */: + case 178 /* ObjectLiteralExpression */: return true; } return false; @@ -10035,8 +10100,8 @@ var ts; */ function isArrayBindingOrAssignmentPattern(node) { switch (node.kind) { - case 174 /* ArrayBindingPattern */: - case 176 /* ArrayLiteralExpression */: + case 175 /* ArrayBindingPattern */: + case 177 /* ArrayLiteralExpression */: return true; } return false; @@ -10044,86 +10109,92 @@ var ts; ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern; // Expression function isArrayLiteralExpression(node) { - return node.kind === 176 /* ArrayLiteralExpression */; + return node.kind === 177 /* ArrayLiteralExpression */; } ts.isArrayLiteralExpression = isArrayLiteralExpression; function isObjectLiteralExpression(node) { - return node.kind === 177 /* ObjectLiteralExpression */; + return node.kind === 178 /* ObjectLiteralExpression */; } ts.isObjectLiteralExpression = isObjectLiteralExpression; function isPropertyAccessExpression(node) { - return node.kind === 178 /* PropertyAccessExpression */; + return node.kind === 179 /* PropertyAccessExpression */; } ts.isPropertyAccessExpression = isPropertyAccessExpression; + function isPropertyAccessOrQualifiedName(node) { + var kind = node.kind; + return kind === 179 /* PropertyAccessExpression */ + || kind === 143 /* QualifiedName */; + } + ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName; function isElementAccessExpression(node) { - return node.kind === 179 /* ElementAccessExpression */; + return node.kind === 180 /* ElementAccessExpression */; } ts.isElementAccessExpression = isElementAccessExpression; function isBinaryExpression(node) { - return node.kind === 193 /* BinaryExpression */; + return node.kind === 194 /* BinaryExpression */; } ts.isBinaryExpression = isBinaryExpression; function isConditionalExpression(node) { - return node.kind === 194 /* ConditionalExpression */; + return node.kind === 195 /* ConditionalExpression */; } ts.isConditionalExpression = isConditionalExpression; function isCallExpression(node) { - return node.kind === 180 /* CallExpression */; + return node.kind === 181 /* CallExpression */; } ts.isCallExpression = isCallExpression; function isTemplateLiteral(node) { var kind = node.kind; - return kind === 195 /* TemplateExpression */ - || kind === 12 /* NoSubstitutionTemplateLiteral */; + return kind === 196 /* TemplateExpression */ + || kind === 13 /* NoSubstitutionTemplateLiteral */; } ts.isTemplateLiteral = isTemplateLiteral; function isSpreadExpression(node) { - return node.kind === 197 /* SpreadElement */; + return node.kind === 198 /* SpreadElement */; } ts.isSpreadExpression = isSpreadExpression; function isExpressionWithTypeArguments(node) { - return node.kind === 200 /* ExpressionWithTypeArguments */; + return node.kind === 201 /* ExpressionWithTypeArguments */; } ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments; function isLeftHandSideExpressionKind(kind) { - return kind === 178 /* PropertyAccessExpression */ - || kind === 179 /* ElementAccessExpression */ - || kind === 181 /* NewExpression */ - || kind === 180 /* CallExpression */ - || kind === 248 /* JsxElement */ - || kind === 249 /* JsxSelfClosingElement */ - || kind === 182 /* TaggedTemplateExpression */ - || kind === 176 /* ArrayLiteralExpression */ - || kind === 184 /* ParenthesizedExpression */ - || kind === 177 /* ObjectLiteralExpression */ - || kind === 198 /* ClassExpression */ - || kind === 185 /* FunctionExpression */ - || kind === 70 /* Identifier */ - || kind === 11 /* RegularExpressionLiteral */ + return kind === 179 /* PropertyAccessExpression */ + || kind === 180 /* ElementAccessExpression */ + || kind === 182 /* NewExpression */ + || kind === 181 /* CallExpression */ + || kind === 249 /* JsxElement */ + || kind === 250 /* JsxSelfClosingElement */ + || kind === 183 /* TaggedTemplateExpression */ + || kind === 177 /* ArrayLiteralExpression */ + || kind === 185 /* ParenthesizedExpression */ + || kind === 178 /* ObjectLiteralExpression */ + || kind === 199 /* ClassExpression */ + || kind === 186 /* FunctionExpression */ + || kind === 71 /* Identifier */ + || kind === 12 /* RegularExpressionLiteral */ || kind === 8 /* NumericLiteral */ || kind === 9 /* StringLiteral */ - || kind === 12 /* NoSubstitutionTemplateLiteral */ - || kind === 195 /* TemplateExpression */ - || kind === 85 /* FalseKeyword */ - || kind === 94 /* NullKeyword */ - || kind === 98 /* ThisKeyword */ - || kind === 100 /* TrueKeyword */ - || kind === 96 /* SuperKeyword */ - || kind === 202 /* NonNullExpression */ - || kind === 203 /* MetaProperty */; + || kind === 13 /* NoSubstitutionTemplateLiteral */ + || kind === 196 /* TemplateExpression */ + || kind === 86 /* FalseKeyword */ + || kind === 95 /* NullKeyword */ + || kind === 99 /* ThisKeyword */ + || kind === 101 /* TrueKeyword */ + || kind === 97 /* SuperKeyword */ + || kind === 203 /* NonNullExpression */ + || kind === 204 /* MetaProperty */; } function isLeftHandSideExpression(node) { return isLeftHandSideExpressionKind(ts.skipPartiallyEmittedExpressions(node).kind); } ts.isLeftHandSideExpression = isLeftHandSideExpression; function isUnaryExpressionKind(kind) { - return kind === 191 /* PrefixUnaryExpression */ - || kind === 192 /* PostfixUnaryExpression */ - || kind === 187 /* DeleteExpression */ - || kind === 188 /* TypeOfExpression */ - || kind === 189 /* VoidExpression */ - || kind === 190 /* AwaitExpression */ - || kind === 183 /* TypeAssertionExpression */ + return kind === 192 /* PrefixUnaryExpression */ + || kind === 193 /* PostfixUnaryExpression */ + || kind === 188 /* DeleteExpression */ + || kind === 189 /* TypeOfExpression */ + || kind === 190 /* VoidExpression */ + || kind === 191 /* AwaitExpression */ + || kind === 184 /* TypeAssertionExpression */ || isLeftHandSideExpressionKind(kind); } function isUnaryExpression(node) { @@ -10131,13 +10202,13 @@ var ts; } ts.isUnaryExpression = isUnaryExpression; function isExpressionKind(kind) { - return kind === 194 /* ConditionalExpression */ - || kind === 196 /* YieldExpression */ - || kind === 186 /* ArrowFunction */ - || kind === 193 /* BinaryExpression */ - || kind === 197 /* SpreadElement */ - || kind === 201 /* AsExpression */ - || kind === 199 /* OmittedExpression */ + return kind === 195 /* ConditionalExpression */ + || kind === 197 /* YieldExpression */ + || kind === 187 /* ArrowFunction */ + || kind === 194 /* BinaryExpression */ + || kind === 198 /* SpreadElement */ + || kind === 202 /* AsExpression */ + || kind === 200 /* OmittedExpression */ || isUnaryExpressionKind(kind); } function isExpression(node) { @@ -10146,16 +10217,16 @@ var ts; ts.isExpression = isExpression; function isAssertionExpression(node) { var kind = node.kind; - return kind === 183 /* TypeAssertionExpression */ - || kind === 201 /* AsExpression */; + return kind === 184 /* TypeAssertionExpression */ + || kind === 202 /* AsExpression */; } ts.isAssertionExpression = isAssertionExpression; function isPartiallyEmittedExpression(node) { - return node.kind === 298 /* PartiallyEmittedExpression */; + return node.kind === 296 /* PartiallyEmittedExpression */; } ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression; function isNotEmittedStatement(node) { - return node.kind === 297 /* NotEmittedStatement */; + return node.kind === 295 /* NotEmittedStatement */; } ts.isNotEmittedStatement = isNotEmittedStatement; function isNotEmittedOrPartiallyEmittedNode(node) { @@ -10164,17 +10235,17 @@ var ts; } ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode; function isOmittedExpression(node) { - return node.kind === 199 /* OmittedExpression */; + return node.kind === 200 /* OmittedExpression */; } ts.isOmittedExpression = isOmittedExpression; // Misc function isTemplateSpan(node) { - return node.kind === 204 /* TemplateSpan */; + return node.kind === 205 /* TemplateSpan */; } ts.isTemplateSpan = isTemplateSpan; // Element function isBlock(node) { - return node.kind === 206 /* Block */; + return node.kind === 207 /* Block */; } ts.isBlock = isBlock; function isConciseBody(node) { @@ -10192,135 +10263,135 @@ var ts; } ts.isForInitializer = isForInitializer; function isVariableDeclaration(node) { - return node.kind === 225 /* VariableDeclaration */; + return node.kind === 226 /* VariableDeclaration */; } ts.isVariableDeclaration = isVariableDeclaration; function isVariableDeclarationList(node) { - return node.kind === 226 /* VariableDeclarationList */; + return node.kind === 227 /* VariableDeclarationList */; } ts.isVariableDeclarationList = isVariableDeclarationList; function isCaseBlock(node) { - return node.kind === 234 /* CaseBlock */; + return node.kind === 235 /* CaseBlock */; } ts.isCaseBlock = isCaseBlock; function isModuleBody(node) { var kind = node.kind; - return kind === 233 /* ModuleBlock */ - || kind === 232 /* ModuleDeclaration */ - || kind === 70 /* Identifier */; + return kind === 234 /* ModuleBlock */ + || kind === 233 /* ModuleDeclaration */ + || kind === 71 /* Identifier */; } ts.isModuleBody = isModuleBody; function isNamespaceBody(node) { var kind = node.kind; - return kind === 233 /* ModuleBlock */ - || kind === 232 /* ModuleDeclaration */; + return kind === 234 /* ModuleBlock */ + || kind === 233 /* ModuleDeclaration */; } ts.isNamespaceBody = isNamespaceBody; function isJSDocNamespaceBody(node) { var kind = node.kind; - return kind === 70 /* Identifier */ - || kind === 232 /* ModuleDeclaration */; + return kind === 71 /* Identifier */ + || kind === 233 /* ModuleDeclaration */; } ts.isJSDocNamespaceBody = isJSDocNamespaceBody; function isImportEqualsDeclaration(node) { - return node.kind === 236 /* ImportEqualsDeclaration */; + return node.kind === 237 /* ImportEqualsDeclaration */; } ts.isImportEqualsDeclaration = isImportEqualsDeclaration; function isImportClause(node) { - return node.kind === 238 /* ImportClause */; + return node.kind === 239 /* ImportClause */; } ts.isImportClause = isImportClause; function isNamedImportBindings(node) { var kind = node.kind; - return kind === 240 /* NamedImports */ - || kind === 239 /* NamespaceImport */; + return kind === 241 /* NamedImports */ + || kind === 240 /* NamespaceImport */; } ts.isNamedImportBindings = isNamedImportBindings; function isImportSpecifier(node) { - return node.kind === 241 /* ImportSpecifier */; + return node.kind === 242 /* ImportSpecifier */; } ts.isImportSpecifier = isImportSpecifier; function isNamedExports(node) { - return node.kind === 244 /* NamedExports */; + return node.kind === 245 /* NamedExports */; } ts.isNamedExports = isNamedExports; function isExportSpecifier(node) { - return node.kind === 245 /* ExportSpecifier */; + return node.kind === 246 /* ExportSpecifier */; } ts.isExportSpecifier = isExportSpecifier; function isModuleOrEnumDeclaration(node) { - return node.kind === 232 /* ModuleDeclaration */ || node.kind === 231 /* EnumDeclaration */; + return node.kind === 233 /* ModuleDeclaration */ || node.kind === 232 /* EnumDeclaration */; } ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration; function isDeclarationKind(kind) { - return kind === 186 /* ArrowFunction */ - || kind === 175 /* BindingElement */ - || kind === 228 /* ClassDeclaration */ - || kind === 198 /* ClassExpression */ - || kind === 151 /* Constructor */ - || kind === 231 /* EnumDeclaration */ - || kind === 263 /* EnumMember */ - || kind === 245 /* ExportSpecifier */ - || kind === 227 /* FunctionDeclaration */ - || kind === 185 /* FunctionExpression */ - || kind === 152 /* GetAccessor */ - || kind === 238 /* ImportClause */ - || kind === 236 /* ImportEqualsDeclaration */ - || kind === 241 /* ImportSpecifier */ - || kind === 229 /* InterfaceDeclaration */ - || kind === 252 /* JsxAttribute */ - || kind === 150 /* MethodDeclaration */ - || kind === 149 /* MethodSignature */ - || kind === 232 /* ModuleDeclaration */ - || kind === 235 /* NamespaceExportDeclaration */ - || kind === 239 /* NamespaceImport */ - || kind === 145 /* Parameter */ - || kind === 260 /* PropertyAssignment */ - || kind === 148 /* PropertyDeclaration */ - || kind === 147 /* PropertySignature */ - || kind === 153 /* SetAccessor */ - || kind === 261 /* ShorthandPropertyAssignment */ - || kind === 230 /* TypeAliasDeclaration */ - || kind === 144 /* TypeParameter */ - || kind === 225 /* VariableDeclaration */ - || kind === 289 /* JSDocTypedefTag */; + return kind === 187 /* ArrowFunction */ + || kind === 176 /* BindingElement */ + || kind === 229 /* ClassDeclaration */ + || kind === 199 /* ClassExpression */ + || kind === 152 /* Constructor */ + || kind === 232 /* EnumDeclaration */ + || kind === 264 /* EnumMember */ + || kind === 246 /* ExportSpecifier */ + || kind === 228 /* FunctionDeclaration */ + || kind === 186 /* FunctionExpression */ + || kind === 153 /* GetAccessor */ + || kind === 239 /* ImportClause */ + || kind === 237 /* ImportEqualsDeclaration */ + || kind === 242 /* ImportSpecifier */ + || kind === 230 /* InterfaceDeclaration */ + || kind === 253 /* JsxAttribute */ + || kind === 151 /* MethodDeclaration */ + || kind === 150 /* MethodSignature */ + || kind === 233 /* ModuleDeclaration */ + || kind === 236 /* NamespaceExportDeclaration */ + || kind === 240 /* NamespaceImport */ + || kind === 146 /* Parameter */ + || kind === 261 /* PropertyAssignment */ + || kind === 149 /* PropertyDeclaration */ + || kind === 148 /* PropertySignature */ + || kind === 154 /* SetAccessor */ + || kind === 262 /* ShorthandPropertyAssignment */ + || kind === 231 /* TypeAliasDeclaration */ + || kind === 145 /* TypeParameter */ + || kind === 226 /* VariableDeclaration */ + || kind === 290 /* JSDocTypedefTag */; } function isDeclarationStatementKind(kind) { - return kind === 227 /* FunctionDeclaration */ - || kind === 246 /* MissingDeclaration */ - || kind === 228 /* ClassDeclaration */ - || kind === 229 /* InterfaceDeclaration */ - || kind === 230 /* TypeAliasDeclaration */ - || kind === 231 /* EnumDeclaration */ - || kind === 232 /* ModuleDeclaration */ - || kind === 237 /* ImportDeclaration */ - || kind === 236 /* ImportEqualsDeclaration */ - || kind === 243 /* ExportDeclaration */ - || kind === 242 /* ExportAssignment */ - || kind === 235 /* NamespaceExportDeclaration */; + return kind === 228 /* FunctionDeclaration */ + || kind === 247 /* MissingDeclaration */ + || kind === 229 /* ClassDeclaration */ + || kind === 230 /* InterfaceDeclaration */ + || kind === 231 /* TypeAliasDeclaration */ + || kind === 232 /* EnumDeclaration */ + || kind === 233 /* ModuleDeclaration */ + || kind === 238 /* ImportDeclaration */ + || kind === 237 /* ImportEqualsDeclaration */ + || kind === 244 /* ExportDeclaration */ + || kind === 243 /* ExportAssignment */ + || kind === 236 /* NamespaceExportDeclaration */; } function isStatementKindButNotDeclarationKind(kind) { - return kind === 217 /* BreakStatement */ - || kind === 216 /* ContinueStatement */ - || kind === 224 /* DebuggerStatement */ - || kind === 211 /* DoStatement */ - || kind === 209 /* ExpressionStatement */ - || kind === 208 /* EmptyStatement */ - || kind === 214 /* ForInStatement */ - || kind === 215 /* ForOfStatement */ - || kind === 213 /* ForStatement */ - || kind === 210 /* IfStatement */ - || kind === 221 /* LabeledStatement */ - || kind === 218 /* ReturnStatement */ - || kind === 220 /* SwitchStatement */ - || kind === 222 /* ThrowStatement */ - || kind === 223 /* TryStatement */ - || kind === 207 /* VariableStatement */ - || kind === 212 /* WhileStatement */ - || kind === 219 /* WithStatement */ - || kind === 297 /* NotEmittedStatement */ - || kind === 300 /* EndOfDeclarationMarker */ - || kind === 299 /* MergeDeclarationMarker */; + return kind === 218 /* BreakStatement */ + || kind === 217 /* ContinueStatement */ + || kind === 225 /* DebuggerStatement */ + || kind === 212 /* DoStatement */ + || kind === 210 /* ExpressionStatement */ + || kind === 209 /* EmptyStatement */ + || kind === 215 /* ForInStatement */ + || kind === 216 /* ForOfStatement */ + || kind === 214 /* ForStatement */ + || kind === 211 /* IfStatement */ + || kind === 222 /* LabeledStatement */ + || kind === 219 /* ReturnStatement */ + || kind === 221 /* SwitchStatement */ + || kind === 223 /* ThrowStatement */ + || kind === 224 /* TryStatement */ + || kind === 208 /* VariableStatement */ + || kind === 213 /* WhileStatement */ + || kind === 220 /* WithStatement */ + || kind === 295 /* NotEmittedStatement */ + || kind === 298 /* EndOfDeclarationMarker */ + || kind === 297 /* MergeDeclarationMarker */; } function isDeclaration(node) { return isDeclarationKind(node.kind); @@ -10341,102 +10412,104 @@ var ts; var kind = node.kind; return isStatementKindButNotDeclarationKind(kind) || isDeclarationStatementKind(kind) - || kind === 206 /* Block */; + || kind === 207 /* Block */; } ts.isStatement = isStatement; // Module references function isModuleReference(node) { var kind = node.kind; - return kind === 247 /* ExternalModuleReference */ - || kind === 142 /* QualifiedName */ - || kind === 70 /* Identifier */; + return kind === 248 /* ExternalModuleReference */ + || kind === 143 /* QualifiedName */ + || kind === 71 /* Identifier */; } ts.isModuleReference = isModuleReference; // JSX function isJsxOpeningElement(node) { - return node.kind === 250 /* JsxOpeningElement */; + return node.kind === 251 /* JsxOpeningElement */; } ts.isJsxOpeningElement = isJsxOpeningElement; function isJsxClosingElement(node) { - return node.kind === 251 /* JsxClosingElement */; + return node.kind === 252 /* JsxClosingElement */; } ts.isJsxClosingElement = isJsxClosingElement; function isJsxTagNameExpression(node) { var kind = node.kind; - return kind === 98 /* ThisKeyword */ - || kind === 70 /* Identifier */ - || kind === 178 /* PropertyAccessExpression */; + return kind === 99 /* ThisKeyword */ + || kind === 71 /* Identifier */ + || kind === 179 /* PropertyAccessExpression */; } ts.isJsxTagNameExpression = isJsxTagNameExpression; function isJsxChild(node) { var kind = node.kind; - return kind === 248 /* JsxElement */ - || kind === 255 /* JsxExpression */ - || kind === 249 /* JsxSelfClosingElement */ + return kind === 249 /* JsxElement */ + || kind === 256 /* JsxExpression */ + || kind === 250 /* JsxSelfClosingElement */ || kind === 10 /* JsxText */; } ts.isJsxChild = isJsxChild; function isJsxAttributes(node) { var kind = node.kind; - return kind === 253 /* JsxAttributes */; + return kind === 254 /* JsxAttributes */; } ts.isJsxAttributes = isJsxAttributes; function isJsxAttributeLike(node) { var kind = node.kind; - return kind === 252 /* JsxAttribute */ - || kind === 254 /* JsxSpreadAttribute */; + return kind === 253 /* JsxAttribute */ + || kind === 255 /* JsxSpreadAttribute */; } ts.isJsxAttributeLike = isJsxAttributeLike; function isJsxSpreadAttribute(node) { - return node.kind === 254 /* JsxSpreadAttribute */; + return node.kind === 255 /* JsxSpreadAttribute */; } ts.isJsxSpreadAttribute = isJsxSpreadAttribute; function isJsxAttribute(node) { - return node.kind === 252 /* JsxAttribute */; + return node.kind === 253 /* JsxAttribute */; } ts.isJsxAttribute = isJsxAttribute; - function isJsxOpeningLikeElement(node) { - return node.kind === 250 /* JsxOpeningElement */ || node.kind === 249 /* JsxSelfClosingElement */; - } - ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; function isStringLiteralOrJsxExpression(node) { var kind = node.kind; return kind === 9 /* StringLiteral */ - || kind === 255 /* JsxExpression */; + || kind === 256 /* JsxExpression */; } ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression; + function isJsxOpeningLikeElement(node) { + var kind = node.kind; + return kind === 251 /* JsxOpeningElement */ + || kind === 250 /* JsxSelfClosingElement */; + } + ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement; // Clauses function isCaseOrDefaultClause(node) { var kind = node.kind; - return kind === 256 /* CaseClause */ - || kind === 257 /* DefaultClause */; + return kind === 257 /* CaseClause */ + || kind === 258 /* DefaultClause */; } ts.isCaseOrDefaultClause = isCaseOrDefaultClause; function isHeritageClause(node) { - return node.kind === 258 /* HeritageClause */; + return node.kind === 259 /* HeritageClause */; } ts.isHeritageClause = isHeritageClause; function isCatchClause(node) { - return node.kind === 259 /* CatchClause */; + return node.kind === 260 /* CatchClause */; } ts.isCatchClause = isCatchClause; // Property assignments function isPropertyAssignment(node) { - return node.kind === 260 /* PropertyAssignment */; + return node.kind === 261 /* PropertyAssignment */; } ts.isPropertyAssignment = isPropertyAssignment; function isShorthandPropertyAssignment(node) { - return node.kind === 261 /* ShorthandPropertyAssignment */; + return node.kind === 262 /* ShorthandPropertyAssignment */; } ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment; // Enum function isEnumMember(node) { - return node.kind === 263 /* EnumMember */; + return node.kind === 264 /* EnumMember */; } ts.isEnumMember = isEnumMember; // Top-level nodes function isSourceFile(node) { - return node.kind === 264 /* SourceFile */; + return node.kind === 265 /* SourceFile */; } ts.isSourceFile = isSourceFile; function isWatchSet(options) { @@ -10449,12 +10522,13 @@ var ts; function getDefaultLibFileName(options) { switch (options.target) { case 5 /* ESNext */: + return "lib.esnext.full.d.ts"; case 4 /* ES2017 */: - return "lib.es2017.d.ts"; + return "lib.es2017.full.d.ts"; case 3 /* ES2016 */: - return "lib.es2016.d.ts"; + return "lib.es2016.full.d.ts"; case 2 /* ES2015 */: - return "lib.es6.d.ts"; + return "lib.es6.d.ts"; // We don't use lib.es2015.full.d.ts due to breaking change. default: return "lib.d.ts"; } @@ -10662,13 +10736,13 @@ var ts; oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1)); newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2)); } - return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN); + return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength*/ newEndN - oldStartN); } ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions; function getTypeParameterOwner(d) { - if (d && d.kind === 144 /* TypeParameter */) { + if (d && d.kind === 145 /* TypeParameter */) { for (var current = d; current; current = current.parent) { - if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 229 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(current) || ts.isClassLike(current) || current.kind === 230 /* InterfaceDeclaration */) { return current; } } @@ -10676,11 +10750,11 @@ var ts; } ts.getTypeParameterOwner = getTypeParameterOwner; function isParameterPropertyDeclaration(node) { - return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 151 /* Constructor */ && ts.isClassLike(node.parent.parent); + return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) && node.parent.kind === 152 /* Constructor */ && ts.isClassLike(node.parent.parent); } ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration; function walkUpBindingElementsAndPatterns(node) { - while (node && (node.kind === 175 /* BindingElement */ || ts.isBindingPattern(node))) { + while (node && (node.kind === 176 /* BindingElement */ || ts.isBindingPattern(node))) { node = node.parent; } return node; @@ -10688,14 +10762,14 @@ var ts; function getCombinedModifierFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = ts.getModifierFlags(node); - if (node.kind === 225 /* VariableDeclaration */) { + if (node.kind === 226 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 226 /* VariableDeclarationList */) { + if (node && node.kind === 227 /* VariableDeclarationList */) { flags |= ts.getModifierFlags(node); node = node.parent; } - if (node && node.kind === 207 /* VariableStatement */) { + if (node && node.kind === 208 /* VariableStatement */) { flags |= ts.getModifierFlags(node); } return flags; @@ -10711,23 +10785,23 @@ var ts; function getCombinedNodeFlags(node) { node = walkUpBindingElementsAndPatterns(node); var flags = node.flags; - if (node.kind === 225 /* VariableDeclaration */) { + if (node.kind === 226 /* VariableDeclaration */) { node = node.parent; } - if (node && node.kind === 226 /* VariableDeclarationList */) { + if (node && node.kind === 227 /* VariableDeclarationList */) { flags |= node.flags; node = node.parent; } - if (node && node.kind === 207 /* VariableStatement */) { + if (node && node.kind === 208 /* VariableStatement */) { flags |= node.flags; } return flags; } ts.getCombinedNodeFlags = getCombinedNodeFlags; /** - * Checks to see if the locale is in the appropriate format, - * and if it is, attempts to set the appropriate language. - */ + * Checks to see if the locale is in the appropriate format, + * and if it is, attempts to set the appropriate language. + */ function validateLocaleAndSetLanguage(locale, sys, errors) { var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(locale.toLowerCase()); if (!matchResult) { @@ -10797,7 +10871,7 @@ var ts; } ts.isParseTreeNode = isParseTreeNode; function getParseTreeNode(node, nodeTest) { - if (isParseTreeNode(node)) { + if (node === undefined || isParseTreeNode(node)) { return node; } node = getOriginalNode(node); @@ -10895,6 +10969,7 @@ var ts; function createNumericLiteral(value) { var node = createSynthesizedNode(8 /* NumericLiteral */); node.text = value; + node.numericLiteralFlags = 0; return node; } ts.createNumericLiteral = createNumericLiteral; @@ -10910,7 +10985,7 @@ var ts; } // Identifiers function createIdentifier(text) { - var node = createSynthesizedNode(70 /* Identifier */); + var node = createSynthesizedNode(71 /* Identifier */); node.text = ts.escapeIdentifier(text); node.originalKeywordKind = text ? ts.stringToToken(text) : 0 /* Unknown */; node.autoGenerateKind = 0 /* None */; @@ -10966,28 +11041,28 @@ var ts; ts.createToken = createToken; // Reserved words function createSuper() { - return createSynthesizedNode(96 /* SuperKeyword */); + return createSynthesizedNode(97 /* SuperKeyword */); } ts.createSuper = createSuper; function createThis() { - return createSynthesizedNode(98 /* ThisKeyword */); + return createSynthesizedNode(99 /* ThisKeyword */); } ts.createThis = createThis; function createNull() { - return createSynthesizedNode(94 /* NullKeyword */); + return createSynthesizedNode(95 /* NullKeyword */); } ts.createNull = createNull; function createTrue() { - return createSynthesizedNode(100 /* TrueKeyword */); + return createSynthesizedNode(101 /* TrueKeyword */); } ts.createTrue = createTrue; function createFalse() { - return createSynthesizedNode(85 /* FalseKeyword */); + return createSynthesizedNode(86 /* FalseKeyword */); } ts.createFalse = createFalse; // Names function createQualifiedName(left, right) { - var node = createSynthesizedNode(142 /* QualifiedName */); + var node = createSynthesizedNode(143 /* QualifiedName */); node.left = left; node.right = asName(right); return node; @@ -11001,7 +11076,7 @@ var ts; } ts.updateQualifiedName = updateQualifiedName; function createComputedPropertyName(expression) { - var node = createSynthesizedNode(143 /* ComputedPropertyName */); + var node = createSynthesizedNode(144 /* ComputedPropertyName */); node.expression = expression; return node; } @@ -11012,9 +11087,290 @@ var ts; : node; } ts.updateComputedPropertyName = updateComputedPropertyName; + // Type Elements + function createSignatureDeclaration(kind, typeParameters, parameters, type) { + var signatureDeclaration = createSynthesizedNode(kind); + signatureDeclaration.typeParameters = asNodeArray(typeParameters); + signatureDeclaration.parameters = asNodeArray(parameters); + signatureDeclaration.type = type; + return signatureDeclaration; + } + ts.createSignatureDeclaration = createSignatureDeclaration; + function updateSignatureDeclaration(node, typeParameters, parameters, type) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + function createFunctionTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(160 /* FunctionType */, typeParameters, parameters, type); + } + ts.createFunctionTypeNode = createFunctionTypeNode; + function updateFunctionTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateFunctionTypeNode = updateFunctionTypeNode; + function createConstructorTypeNode(typeParameters, parameters, type) { + return createSignatureDeclaration(161 /* ConstructorType */, typeParameters, parameters, type); + } + ts.createConstructorTypeNode = createConstructorTypeNode; + function updateConstructorTypeNode(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructorTypeNode = updateConstructorTypeNode; + function createCallSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(155 /* CallSignature */, typeParameters, parameters, type); + } + ts.createCallSignatureDeclaration = createCallSignatureDeclaration; + function updateCallSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateCallSignatureDeclaration = updateCallSignatureDeclaration; + function createConstructSignatureDeclaration(typeParameters, parameters, type) { + return createSignatureDeclaration(156 /* ConstructSignature */, typeParameters, parameters, type); + } + ts.createConstructSignatureDeclaration = createConstructSignatureDeclaration; + function updateConstructSignatureDeclaration(node, typeParameters, parameters, type) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + ts.updateConstructSignatureDeclaration = updateConstructSignatureDeclaration; + function createMethodSignature(typeParameters, parameters, type, name, questionToken) { + var methodSignature = createSignatureDeclaration(150 /* MethodSignature */, typeParameters, parameters, type); + methodSignature.name = asName(name); + methodSignature.questionToken = questionToken; + return methodSignature; + } + ts.createMethodSignature = createMethodSignature; + function updateMethodSignature(node, typeParameters, parameters, type, name, questionToken) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + ts.updateMethodSignature = updateMethodSignature; + // Types + function createKeywordTypeNode(kind) { + return createSynthesizedNode(kind); + } + ts.createKeywordTypeNode = createKeywordTypeNode; + function createThisTypeNode() { + return createSynthesizedNode(169 /* ThisType */); + } + ts.createThisTypeNode = createThisTypeNode; + function createLiteralTypeNode(literal) { + var literalTypeNode = createSynthesizedNode(173 /* LiteralType */); + literalTypeNode.literal = literal; + return literalTypeNode; + } + ts.createLiteralTypeNode = createLiteralTypeNode; + function updateLiteralTypeNode(node, literal) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + ts.updateLiteralTypeNode = updateLiteralTypeNode; + function createTypeReferenceNode(typeName, typeArguments) { + var typeReference = createSynthesizedNode(159 /* TypeReference */); + typeReference.typeName = asName(typeName); + typeReference.typeArguments = asNodeArray(typeArguments); + return typeReference; + } + ts.createTypeReferenceNode = createTypeReferenceNode; + function updateTypeReferenceNode(node, typeName, typeArguments) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + ts.updateTypeReferenceNode = updateTypeReferenceNode; + function createTypePredicateNode(parameterName, type) { + var typePredicateNode = createSynthesizedNode(158 /* TypePredicate */); + typePredicateNode.parameterName = asName(parameterName); + typePredicateNode.type = type; + return typePredicateNode; + } + ts.createTypePredicateNode = createTypePredicateNode; + function updateTypePredicateNode(node, parameterName, type) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + ts.updateTypePredicateNode = updateTypePredicateNode; + function createTypeQueryNode(exprName) { + var typeQueryNode = createSynthesizedNode(162 /* TypeQuery */); + typeQueryNode.exprName = exprName; + return typeQueryNode; + } + ts.createTypeQueryNode = createTypeQueryNode; + function updateTypeQueryNode(node, exprName) { + return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; + } + ts.updateTypeQueryNode = updateTypeQueryNode; + function createArrayTypeNode(elementType) { + var arrayTypeNode = createSynthesizedNode(164 /* ArrayType */); + arrayTypeNode.elementType = elementType; + return arrayTypeNode; + } + ts.createArrayTypeNode = createArrayTypeNode; + function updateArrayTypeNode(node, elementType) { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + ts.updateArrayTypeNode = updateArrayTypeNode; + function createUnionOrIntersectionTypeNode(kind, types) { + var unionTypeNode = createSynthesizedNode(kind); + unionTypeNode.types = createNodeArray(types); + return unionTypeNode; + } + ts.createUnionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode; + function updateUnionOrIntersectionTypeNode(node, types) { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + ts.updateUnionOrIntersectionTypeNode = updateUnionOrIntersectionTypeNode; + function createParenthesizedType(type) { + var node = createSynthesizedNode(168 /* ParenthesizedType */); + node.type = type; + return node; + } + ts.createParenthesizedType = createParenthesizedType; + function updateParenthesizedType(node, type) { + return node.type !== type + ? updateNode(createParenthesizedType(type), node) + : node; + } + ts.updateParenthesizedType = updateParenthesizedType; + function createTypeLiteralNode(members) { + var typeLiteralNode = createSynthesizedNode(163 /* TypeLiteral */); + typeLiteralNode.members = createNodeArray(members); + return typeLiteralNode; + } + ts.createTypeLiteralNode = createTypeLiteralNode; + function updateTypeLiteralNode(node, members) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + ts.updateTypeLiteralNode = updateTypeLiteralNode; + function createTupleTypeNode(elementTypes) { + var tupleTypeNode = createSynthesizedNode(165 /* TupleType */); + tupleTypeNode.elementTypes = createNodeArray(elementTypes); + return tupleTypeNode; + } + ts.createTupleTypeNode = createTupleTypeNode; + function updateTypleTypeNode(node, elementTypes) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + ts.updateTypleTypeNode = updateTypleTypeNode; + function createMappedTypeNode(readonlyToken, typeParameter, questionToken, type) { + var mappedTypeNode = createSynthesizedNode(172 /* MappedType */); + mappedTypeNode.readonlyToken = readonlyToken; + mappedTypeNode.typeParameter = typeParameter; + mappedTypeNode.questionToken = questionToken; + mappedTypeNode.type = type; + return mappedTypeNode; + } + ts.createMappedTypeNode = createMappedTypeNode; + function updateMappedTypeNode(node, readonlyToken, typeParameter, questionToken, type) { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + ts.updateMappedTypeNode = updateMappedTypeNode; + function createTypeOperatorNode(type) { + var typeOperatorNode = createSynthesizedNode(170 /* TypeOperator */); + typeOperatorNode.operator = 127 /* KeyOfKeyword */; + typeOperatorNode.type = type; + return typeOperatorNode; + } + ts.createTypeOperatorNode = createTypeOperatorNode; + function updateTypeOperatorNode(node, type) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + ts.updateTypeOperatorNode = updateTypeOperatorNode; + function createIndexedAccessTypeNode(objectType, indexType) { + var indexedAccessTypeNode = createSynthesizedNode(171 /* IndexedAccessType */); + indexedAccessTypeNode.objectType = objectType; + indexedAccessTypeNode.indexType = indexType; + return indexedAccessTypeNode; + } + ts.createIndexedAccessTypeNode = createIndexedAccessTypeNode; + function updateIndexedAccessTypeNode(node, objectType, indexType) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + ts.updateIndexedAccessTypeNode = updateIndexedAccessTypeNode; + // Type Declarations + function createTypeParameterDeclaration(name, constraint, defaultType) { + var typeParameter = createSynthesizedNode(145 /* TypeParameter */); + typeParameter.name = asName(name); + typeParameter.constraint = constraint; + typeParameter.default = defaultType; + return typeParameter; + } + ts.createTypeParameterDeclaration = createTypeParameterDeclaration; + function updateTypeParameterDeclaration(node, name, constraint, defaultType) { + return node.name !== name + || node.constraint !== constraint + || node.default !== defaultType + ? updateNode(createTypeParameterDeclaration(name, constraint, defaultType), node) + : node; + } + ts.updateTypeParameterDeclaration = updateTypeParameterDeclaration; + // Signature elements + function createPropertySignature(name, questionToken, type, initializer) { + var propertySignature = createSynthesizedNode(148 /* PropertySignature */); + propertySignature.name = asName(name); + propertySignature.questionToken = questionToken; + propertySignature.type = type; + propertySignature.initializer = initializer; + return propertySignature; + } + ts.createPropertySignature = createPropertySignature; + function updatePropertySignature(node, name, questionToken, type, initializer) { + return node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) + : node; + } + ts.updatePropertySignature = updatePropertySignature; + function createIndexSignatureDeclaration(decorators, modifiers, parameters, type) { + var indexSignature = createSynthesizedNode(157 /* IndexSignature */); + indexSignature.decorators = asNodeArray(decorators); + indexSignature.modifiers = asNodeArray(modifiers); + indexSignature.parameters = createNodeArray(parameters); + indexSignature.type = type; + return indexSignature; + } + ts.createIndexSignatureDeclaration = createIndexSignatureDeclaration; + function updateIndexSignatureDeclaration(node, decorators, modifiers, parameters, type) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) + : node; + } + ts.updateIndexSignatureDeclaration = updateIndexSignatureDeclaration; // Signature elements function createParameter(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { - var node = createSynthesizedNode(145 /* Parameter */); + var node = createSynthesizedNode(146 /* Parameter */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.dotDotDotToken = dotDotDotToken; @@ -11025,11 +11381,12 @@ var ts; return node; } ts.createParameter = createParameter; - function updateParameter(node, decorators, modifiers, dotDotDotToken, name, type, initializer) { + function updateParameter(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) { return node.decorators !== decorators || node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name + || node.questionToken !== questionToken || node.type !== type || node.initializer !== initializer ? updateNode(createParameter(decorators, modifiers, dotDotDotToken, name, node.questionToken, type, initializer), node) @@ -11037,7 +11394,7 @@ var ts; } ts.updateParameter = updateParameter; function createDecorator(expression) { - var node = createSynthesizedNode(146 /* Decorator */); + var node = createSynthesizedNode(147 /* Decorator */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -11050,7 +11407,7 @@ var ts; ts.updateDecorator = updateDecorator; // Type members function createProperty(decorators, modifiers, name, questionToken, type, initializer) { - var node = createSynthesizedNode(148 /* PropertyDeclaration */); + var node = createSynthesizedNode(149 /* PropertyDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11070,33 +11427,35 @@ var ts; : node; } ts.updateProperty = updateProperty; - function createMethod(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(150 /* MethodDeclaration */); + function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { + var node = createSynthesizedNode(151 /* MethodDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); + node.questionToken = questionToken; node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; node.body = body; return node; } - ts.createMethod = createMethod; - function updateMethod(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + ts.createMethodDeclaration = createMethodDeclaration; + function updateMethod(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethod(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } ts.updateMethod = updateMethod; function createConstructor(decorators, modifiers, parameters, body) { - var node = createSynthesizedNode(151 /* Constructor */); + var node = createSynthesizedNode(152 /* Constructor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.typeParameters = undefined; @@ -11116,7 +11475,7 @@ var ts; } ts.updateConstructor = updateConstructor; function createGetAccessor(decorators, modifiers, name, parameters, type, body) { - var node = createSynthesizedNode(152 /* GetAccessor */); + var node = createSynthesizedNode(153 /* GetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11139,7 +11498,7 @@ var ts; } ts.updateGetAccessor = updateGetAccessor; function createSetAccessor(decorators, modifiers, name, parameters, body) { - var node = createSynthesizedNode(153 /* SetAccessor */); + var node = createSynthesizedNode(154 /* SetAccessor */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11161,7 +11520,7 @@ var ts; ts.updateSetAccessor = updateSetAccessor; // Binding Patterns function createObjectBindingPattern(elements) { - var node = createSynthesizedNode(173 /* ObjectBindingPattern */); + var node = createSynthesizedNode(174 /* ObjectBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -11173,7 +11532,7 @@ var ts; } ts.updateObjectBindingPattern = updateObjectBindingPattern; function createArrayBindingPattern(elements) { - var node = createSynthesizedNode(174 /* ArrayBindingPattern */); + var node = createSynthesizedNode(175 /* ArrayBindingPattern */); node.elements = createNodeArray(elements); return node; } @@ -11184,10 +11543,10 @@ var ts; : node; } ts.updateArrayBindingPattern = updateArrayBindingPattern; - function createBindingElement(propertyName, dotDotDotToken, name, initializer) { - var node = createSynthesizedNode(175 /* BindingElement */); - node.propertyName = asName(propertyName); + function createBindingElement(dotDotDotToken, propertyName, name, initializer) { + var node = createSynthesizedNode(176 /* BindingElement */); node.dotDotDotToken = dotDotDotToken; + node.propertyName = asName(propertyName); node.name = asName(name); node.initializer = initializer; return node; @@ -11198,13 +11557,13 @@ var ts; || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.initializer !== initializer - ? updateNode(createBindingElement(propertyName, dotDotDotToken, name, initializer), node) + ? updateNode(createBindingElement(dotDotDotToken, propertyName, name, initializer), node) : node; } ts.updateBindingElement = updateBindingElement; // Expression function createArrayLiteral(elements, multiLine) { - var node = createSynthesizedNode(176 /* ArrayLiteralExpression */); + var node = createSynthesizedNode(177 /* ArrayLiteralExpression */); node.elements = ts.parenthesizeListElements(createNodeArray(elements)); if (multiLine) { node.multiLine = true; @@ -11219,7 +11578,7 @@ var ts; } ts.updateArrayLiteral = updateArrayLiteral; function createObjectLiteral(properties, multiLine) { - var node = createSynthesizedNode(177 /* ObjectLiteralExpression */); + var node = createSynthesizedNode(178 /* ObjectLiteralExpression */); node.properties = createNodeArray(properties); if (multiLine) { node.multiLine = true; @@ -11234,10 +11593,10 @@ var ts; } ts.updateObjectLiteral = updateObjectLiteral; function createPropertyAccess(expression, name) { - var node = createSynthesizedNode(178 /* PropertyAccessExpression */); + var node = createSynthesizedNode(179 /* PropertyAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.name = asName(name); - setEmitFlags(node, 65536 /* NoIndentation */); + setEmitFlags(node, 131072 /* NoIndentation */); return node; } ts.createPropertyAccess = createPropertyAccess; @@ -11251,7 +11610,7 @@ var ts; } ts.updatePropertyAccess = updatePropertyAccess; function createElementAccess(expression, index) { - var node = createSynthesizedNode(179 /* ElementAccessExpression */); + var node = createSynthesizedNode(180 /* ElementAccessExpression */); node.expression = ts.parenthesizeForAccess(expression); node.argumentExpression = asExpression(index); return node; @@ -11265,7 +11624,7 @@ var ts; } ts.updateElementAccess = updateElementAccess; function createCall(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(180 /* CallExpression */); + var node = createSynthesizedNode(181 /* CallExpression */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = ts.parenthesizeListElements(createNodeArray(argumentsArray)); @@ -11281,7 +11640,7 @@ var ts; } ts.updateCall = updateCall; function createNew(expression, typeArguments, argumentsArray) { - var node = createSynthesizedNode(181 /* NewExpression */); + var node = createSynthesizedNode(182 /* NewExpression */); node.expression = ts.parenthesizeForNew(expression); node.typeArguments = asNodeArray(typeArguments); node.arguments = argumentsArray ? ts.parenthesizeListElements(createNodeArray(argumentsArray)) : undefined; @@ -11297,7 +11656,7 @@ var ts; } ts.updateNew = updateNew; function createTaggedTemplate(tag, template) { - var node = createSynthesizedNode(182 /* TaggedTemplateExpression */); + var node = createSynthesizedNode(183 /* TaggedTemplateExpression */); node.tag = ts.parenthesizeForAccess(tag); node.template = template; return node; @@ -11311,7 +11670,7 @@ var ts; } ts.updateTaggedTemplate = updateTaggedTemplate; function createTypeAssertion(type, expression) { - var node = createSynthesizedNode(183 /* TypeAssertionExpression */); + var node = createSynthesizedNode(184 /* TypeAssertionExpression */); node.type = type; node.expression = ts.parenthesizePrefixOperand(expression); return node; @@ -11325,7 +11684,7 @@ var ts; } ts.updateTypeAssertion = updateTypeAssertion; function createParen(expression) { - var node = createSynthesizedNode(184 /* ParenthesizedExpression */); + var node = createSynthesizedNode(185 /* ParenthesizedExpression */); node.expression = expression; return node; } @@ -11337,7 +11696,7 @@ var ts; } ts.updateParen = updateParen; function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(185 /* FunctionExpression */); + var node = createSynthesizedNode(186 /* FunctionExpression */); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; node.name = asName(name); @@ -11348,24 +11707,25 @@ var ts; return node; } ts.createFunctionExpression = createFunctionExpression; - function updateFunctionExpression(node, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.name !== name || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionExpression(modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionExpression = updateFunctionExpression; function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) { - var node = createSynthesizedNode(186 /* ArrowFunction */); + var node = createSynthesizedNode(187 /* ArrowFunction */); node.modifiers = asNodeArray(modifiers); node.typeParameters = asNodeArray(typeParameters); node.parameters = createNodeArray(parameters); node.type = type; - node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(35 /* EqualsGreaterThanToken */); + node.equalsGreaterThanToken = equalsGreaterThanToken || createToken(36 /* EqualsGreaterThanToken */); node.body = ts.parenthesizeConciseBody(body); return node; } @@ -11381,7 +11741,7 @@ var ts; } ts.updateArrowFunction = updateArrowFunction; function createDelete(expression) { - var node = createSynthesizedNode(187 /* DeleteExpression */); + var node = createSynthesizedNode(188 /* DeleteExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11393,7 +11753,7 @@ var ts; } ts.updateDelete = updateDelete; function createTypeOf(expression) { - var node = createSynthesizedNode(188 /* TypeOfExpression */); + var node = createSynthesizedNode(189 /* TypeOfExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11405,7 +11765,7 @@ var ts; } ts.updateTypeOf = updateTypeOf; function createVoid(expression) { - var node = createSynthesizedNode(189 /* VoidExpression */); + var node = createSynthesizedNode(190 /* VoidExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11417,7 +11777,7 @@ var ts; } ts.updateVoid = updateVoid; function createAwait(expression) { - var node = createSynthesizedNode(190 /* AwaitExpression */); + var node = createSynthesizedNode(191 /* AwaitExpression */); node.expression = ts.parenthesizePrefixOperand(expression); return node; } @@ -11429,7 +11789,7 @@ var ts; } ts.updateAwait = updateAwait; function createPrefix(operator, operand) { - var node = createSynthesizedNode(191 /* PrefixUnaryExpression */); + var node = createSynthesizedNode(192 /* PrefixUnaryExpression */); node.operator = operator; node.operand = ts.parenthesizePrefixOperand(operand); return node; @@ -11442,7 +11802,7 @@ var ts; } ts.updatePrefix = updatePrefix; function createPostfix(operand, operator) { - var node = createSynthesizedNode(192 /* PostfixUnaryExpression */); + var node = createSynthesizedNode(193 /* PostfixUnaryExpression */); node.operand = ts.parenthesizePostfixOperand(operand); node.operator = operator; return node; @@ -11455,7 +11815,7 @@ var ts; } ts.updatePostfix = updatePostfix; function createBinary(left, operator, right) { - var node = createSynthesizedNode(193 /* BinaryExpression */); + var node = createSynthesizedNode(194 /* BinaryExpression */); var operatorToken = asToken(operator); var operatorKind = operatorToken.kind; node.left = ts.parenthesizeBinaryOperand(operatorKind, left, /*isLeftSideOfBinary*/ true, /*leftOperand*/ undefined); @@ -11472,11 +11832,11 @@ var ts; } ts.updateBinary = updateBinary; function createConditional(condition, questionTokenOrWhenTrue, whenTrueOrWhenFalse, colonToken, whenFalse) { - var node = createSynthesizedNode(194 /* ConditionalExpression */); + var node = createSynthesizedNode(195 /* ConditionalExpression */); node.condition = ts.parenthesizeForConditionalHead(condition); - node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(54 /* QuestionToken */); + node.questionToken = whenFalse ? questionTokenOrWhenTrue : createToken(55 /* QuestionToken */); node.whenTrue = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenTrueOrWhenFalse : questionTokenOrWhenTrue); - node.colonToken = whenFalse ? colonToken : createToken(55 /* ColonToken */); + node.colonToken = whenFalse ? colonToken : createToken(56 /* ColonToken */); node.whenFalse = ts.parenthesizeSubexpressionOfConditionalExpression(whenFalse ? whenFalse : whenTrueOrWhenFalse); return node; } @@ -11490,7 +11850,7 @@ var ts; } ts.updateConditional = updateConditional; function createTemplateExpression(head, templateSpans) { - var node = createSynthesizedNode(195 /* TemplateExpression */); + var node = createSynthesizedNode(196 /* TemplateExpression */); node.head = head; node.templateSpans = createNodeArray(templateSpans); return node; @@ -11504,20 +11864,21 @@ var ts; } ts.updateTemplateExpression = updateTemplateExpression; function createYield(asteriskTokenOrExpression, expression) { - var node = createSynthesizedNode(196 /* YieldExpression */); - node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 38 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; - node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 38 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; + var node = createSynthesizedNode(197 /* YieldExpression */); + node.asteriskToken = asteriskTokenOrExpression && asteriskTokenOrExpression.kind === 39 /* AsteriskToken */ ? asteriskTokenOrExpression : undefined; + node.expression = asteriskTokenOrExpression && asteriskTokenOrExpression.kind !== 39 /* AsteriskToken */ ? asteriskTokenOrExpression : expression; return node; } ts.createYield = createYield; - function updateYield(node, expression) { + function updateYield(node, asteriskToken, expression) { return node.expression !== expression - ? updateNode(createYield(node.asteriskToken, expression), node) + || node.asteriskToken !== asteriskToken + ? updateNode(createYield(asteriskToken, expression), node) : node; } ts.updateYield = updateYield; function createSpread(expression) { - var node = createSynthesizedNode(197 /* SpreadElement */); + var node = createSynthesizedNode(198 /* SpreadElement */); node.expression = ts.parenthesizeExpressionForList(expression); return node; } @@ -11529,7 +11890,7 @@ var ts; } ts.updateSpread = updateSpread; function createClassExpression(modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(198 /* ClassExpression */); + var node = createSynthesizedNode(199 /* ClassExpression */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11550,11 +11911,11 @@ var ts; } ts.updateClassExpression = updateClassExpression; function createOmittedExpression() { - return createSynthesizedNode(199 /* OmittedExpression */); + return createSynthesizedNode(200 /* OmittedExpression */); } ts.createOmittedExpression = createOmittedExpression; function createExpressionWithTypeArguments(typeArguments, expression) { - var node = createSynthesizedNode(200 /* ExpressionWithTypeArguments */); + var node = createSynthesizedNode(201 /* ExpressionWithTypeArguments */); node.expression = ts.parenthesizeForAccess(expression); node.typeArguments = asNodeArray(typeArguments); return node; @@ -11568,7 +11929,7 @@ var ts; } ts.updateExpressionWithTypeArguments = updateExpressionWithTypeArguments; function createAsExpression(expression, type) { - var node = createSynthesizedNode(201 /* AsExpression */); + var node = createSynthesizedNode(202 /* AsExpression */); node.expression = expression; node.type = type; return node; @@ -11582,7 +11943,7 @@ var ts; } ts.updateAsExpression = updateAsExpression; function createNonNullExpression(expression) { - var node = createSynthesizedNode(202 /* NonNullExpression */); + var node = createSynthesizedNode(203 /* NonNullExpression */); node.expression = ts.parenthesizeForAccess(expression); return node; } @@ -11595,7 +11956,7 @@ var ts; ts.updateNonNullExpression = updateNonNullExpression; // Misc function createTemplateSpan(expression, literal) { - var node = createSynthesizedNode(204 /* TemplateSpan */); + var node = createSynthesizedNode(205 /* TemplateSpan */); node.expression = expression; node.literal = literal; return node; @@ -11610,7 +11971,7 @@ var ts; ts.updateTemplateSpan = updateTemplateSpan; // Element function createBlock(statements, multiLine) { - var block = createSynthesizedNode(206 /* Block */); + var block = createSynthesizedNode(207 /* Block */); block.statements = createNodeArray(statements); if (multiLine) block.multiLine = multiLine; @@ -11624,7 +11985,7 @@ var ts; } ts.updateBlock = updateBlock; function createVariableStatement(modifiers, declarationList) { - var node = createSynthesizedNode(207 /* VariableStatement */); + var node = createSynthesizedNode(208 /* VariableStatement */); node.decorators = undefined; node.modifiers = asNodeArray(modifiers); node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; @@ -11639,7 +12000,7 @@ var ts; } ts.updateVariableStatement = updateVariableStatement; function createVariableDeclarationList(declarations, flags) { - var node = createSynthesizedNode(226 /* VariableDeclarationList */); + var node = createSynthesizedNode(227 /* VariableDeclarationList */); node.flags |= flags; node.declarations = createNodeArray(declarations); return node; @@ -11652,7 +12013,7 @@ var ts; } ts.updateVariableDeclarationList = updateVariableDeclarationList; function createVariableDeclaration(name, type, initializer) { - var node = createSynthesizedNode(225 /* VariableDeclaration */); + var node = createSynthesizedNode(226 /* VariableDeclaration */); node.name = asName(name); node.type = type; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -11668,11 +12029,11 @@ var ts; } ts.updateVariableDeclaration = updateVariableDeclaration; function createEmptyStatement() { - return createSynthesizedNode(208 /* EmptyStatement */); + return createSynthesizedNode(209 /* EmptyStatement */); } ts.createEmptyStatement = createEmptyStatement; function createStatement(expression) { - var node = createSynthesizedNode(209 /* ExpressionStatement */); + var node = createSynthesizedNode(210 /* ExpressionStatement */); node.expression = ts.parenthesizeExpressionForExpressionStatement(expression); return node; } @@ -11684,7 +12045,7 @@ var ts; } ts.updateStatement = updateStatement; function createIf(expression, thenStatement, elseStatement) { - var node = createSynthesizedNode(210 /* IfStatement */); + var node = createSynthesizedNode(211 /* IfStatement */); node.expression = expression; node.thenStatement = thenStatement; node.elseStatement = elseStatement; @@ -11700,7 +12061,7 @@ var ts; } ts.updateIf = updateIf; function createDo(statement, expression) { - var node = createSynthesizedNode(211 /* DoStatement */); + var node = createSynthesizedNode(212 /* DoStatement */); node.statement = statement; node.expression = expression; return node; @@ -11714,7 +12075,7 @@ var ts; } ts.updateDo = updateDo; function createWhile(expression, statement) { - var node = createSynthesizedNode(212 /* WhileStatement */); + var node = createSynthesizedNode(213 /* WhileStatement */); node.expression = expression; node.statement = statement; return node; @@ -11728,7 +12089,7 @@ var ts; } ts.updateWhile = updateWhile; function createFor(initializer, condition, incrementor, statement) { - var node = createSynthesizedNode(213 /* ForStatement */); + var node = createSynthesizedNode(214 /* ForStatement */); node.initializer = initializer; node.condition = condition; node.incrementor = incrementor; @@ -11746,7 +12107,7 @@ var ts; } ts.updateFor = updateFor; function createForIn(initializer, expression, statement) { - var node = createSynthesizedNode(214 /* ForInStatement */); + var node = createSynthesizedNode(215 /* ForInStatement */); node.initializer = initializer; node.expression = expression; node.statement = statement; @@ -11761,24 +12122,26 @@ var ts; : node; } ts.updateForIn = updateForIn; - function createForOf(initializer, expression, statement) { - var node = createSynthesizedNode(215 /* ForOfStatement */); + function createForOf(awaitModifier, initializer, expression, statement) { + var node = createSynthesizedNode(216 /* ForOfStatement */); + node.awaitModifier = awaitModifier; node.initializer = initializer; node.expression = expression; node.statement = statement; return node; } ts.createForOf = createForOf; - function updateForOf(node, initializer, expression, statement) { - return node.initializer !== initializer + function updateForOf(node, awaitModifier, initializer, expression, statement) { + return node.awaitModifier !== awaitModifier + || node.initializer !== initializer || node.expression !== expression || node.statement !== statement - ? updateNode(createForOf(initializer, expression, statement), node) + ? updateNode(createForOf(awaitModifier, initializer, expression, statement), node) : node; } ts.updateForOf = updateForOf; function createContinue(label) { - var node = createSynthesizedNode(216 /* ContinueStatement */); + var node = createSynthesizedNode(217 /* ContinueStatement */); node.label = asName(label); return node; } @@ -11790,7 +12153,7 @@ var ts; } ts.updateContinue = updateContinue; function createBreak(label) { - var node = createSynthesizedNode(217 /* BreakStatement */); + var node = createSynthesizedNode(218 /* BreakStatement */); node.label = asName(label); return node; } @@ -11802,7 +12165,7 @@ var ts; } ts.updateBreak = updateBreak; function createReturn(expression) { - var node = createSynthesizedNode(218 /* ReturnStatement */); + var node = createSynthesizedNode(219 /* ReturnStatement */); node.expression = expression; return node; } @@ -11814,7 +12177,7 @@ var ts; } ts.updateReturn = updateReturn; function createWith(expression, statement) { - var node = createSynthesizedNode(219 /* WithStatement */); + var node = createSynthesizedNode(220 /* WithStatement */); node.expression = expression; node.statement = statement; return node; @@ -11828,7 +12191,7 @@ var ts; } ts.updateWith = updateWith; function createSwitch(expression, caseBlock) { - var node = createSynthesizedNode(220 /* SwitchStatement */); + var node = createSynthesizedNode(221 /* SwitchStatement */); node.expression = ts.parenthesizeExpressionForList(expression); node.caseBlock = caseBlock; return node; @@ -11842,7 +12205,7 @@ var ts; } ts.updateSwitch = updateSwitch; function createLabel(label, statement) { - var node = createSynthesizedNode(221 /* LabeledStatement */); + var node = createSynthesizedNode(222 /* LabeledStatement */); node.label = asName(label); node.statement = statement; return node; @@ -11856,7 +12219,7 @@ var ts; } ts.updateLabel = updateLabel; function createThrow(expression) { - var node = createSynthesizedNode(222 /* ThrowStatement */); + var node = createSynthesizedNode(223 /* ThrowStatement */); node.expression = expression; return node; } @@ -11868,7 +12231,7 @@ var ts; } ts.updateThrow = updateThrow; function createTry(tryBlock, catchClause, finallyBlock) { - var node = createSynthesizedNode(223 /* TryStatement */); + var node = createSynthesizedNode(224 /* TryStatement */); node.tryBlock = tryBlock; node.catchClause = catchClause; node.finallyBlock = finallyBlock; @@ -11884,7 +12247,7 @@ var ts; } ts.updateTry = updateTry; function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { - var node = createSynthesizedNode(227 /* FunctionDeclaration */); + var node = createSynthesizedNode(228 /* FunctionDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.asteriskToken = asteriskToken; @@ -11896,20 +12259,21 @@ var ts; return node; } ts.createFunctionDeclaration = createFunctionDeclaration; - function updateFunctionDeclaration(node, decorators, modifiers, name, typeParameters, parameters, type, body) { + function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) { return node.decorators !== decorators || node.modifiers !== modifiers + || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createFunctionDeclaration(decorators, modifiers, node.asteriskToken, name, typeParameters, parameters, type, body), node) + ? updateNode(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } ts.updateFunctionDeclaration = updateFunctionDeclaration; function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) { - var node = createSynthesizedNode(228 /* ClassDeclaration */); + var node = createSynthesizedNode(229 /* ClassDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11931,7 +12295,7 @@ var ts; } ts.updateClassDeclaration = updateClassDeclaration; function createEnumDeclaration(decorators, modifiers, name, members) { - var node = createSynthesizedNode(231 /* EnumDeclaration */); + var node = createSynthesizedNode(232 /* EnumDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -11949,7 +12313,7 @@ var ts; } ts.updateEnumDeclaration = updateEnumDeclaration; function createModuleDeclaration(decorators, modifiers, name, body, flags) { - var node = createSynthesizedNode(232 /* ModuleDeclaration */); + var node = createSynthesizedNode(233 /* ModuleDeclaration */); node.flags |= flags; node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -11968,7 +12332,7 @@ var ts; } ts.updateModuleDeclaration = updateModuleDeclaration; function createModuleBlock(statements) { - var node = createSynthesizedNode(234 /* CaseBlock */); + var node = createSynthesizedNode(234 /* ModuleBlock */); node.statements = createNodeArray(statements); return node; } @@ -11980,7 +12344,7 @@ var ts; } ts.updateModuleBlock = updateModuleBlock; function createCaseBlock(clauses) { - var node = createSynthesizedNode(234 /* CaseBlock */); + var node = createSynthesizedNode(235 /* CaseBlock */); node.clauses = createNodeArray(clauses); return node; } @@ -11992,7 +12356,7 @@ var ts; } ts.updateCaseBlock = updateCaseBlock; function createImportEqualsDeclaration(decorators, modifiers, name, moduleReference) { - var node = createSynthesizedNode(236 /* ImportEqualsDeclaration */); + var node = createSynthesizedNode(237 /* ImportEqualsDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = asName(name); @@ -12010,7 +12374,7 @@ var ts; } ts.updateImportEqualsDeclaration = updateImportEqualsDeclaration; function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) { - var node = createSynthesizedNode(237 /* ImportDeclaration */); + var node = createSynthesizedNode(238 /* ImportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.importClause = importClause; @@ -12027,7 +12391,7 @@ var ts; } ts.updateImportDeclaration = updateImportDeclaration; function createImportClause(name, namedBindings) { - var node = createSynthesizedNode(238 /* ImportClause */); + var node = createSynthesizedNode(239 /* ImportClause */); node.name = name; node.namedBindings = namedBindings; return node; @@ -12041,7 +12405,7 @@ var ts; } ts.updateImportClause = updateImportClause; function createNamespaceImport(name) { - var node = createSynthesizedNode(239 /* NamespaceImport */); + var node = createSynthesizedNode(240 /* NamespaceImport */); node.name = name; return node; } @@ -12053,7 +12417,7 @@ var ts; } ts.updateNamespaceImport = updateNamespaceImport; function createNamedImports(elements) { - var node = createSynthesizedNode(240 /* NamedImports */); + var node = createSynthesizedNode(241 /* NamedImports */); node.elements = createNodeArray(elements); return node; } @@ -12065,7 +12429,7 @@ var ts; } ts.updateNamedImports = updateNamedImports; function createImportSpecifier(propertyName, name) { - var node = createSynthesizedNode(241 /* ImportSpecifier */); + var node = createSynthesizedNode(242 /* ImportSpecifier */); node.propertyName = propertyName; node.name = name; return node; @@ -12079,7 +12443,7 @@ var ts; } ts.updateImportSpecifier = updateImportSpecifier; function createExportAssignment(decorators, modifiers, isExportEquals, expression) { - var node = createSynthesizedNode(242 /* ExportAssignment */); + var node = createSynthesizedNode(243 /* ExportAssignment */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; @@ -12096,7 +12460,7 @@ var ts; } ts.updateExportAssignment = updateExportAssignment; function createExportDeclaration(decorators, modifiers, exportClause, moduleSpecifier) { - var node = createSynthesizedNode(243 /* ExportDeclaration */); + var node = createSynthesizedNode(244 /* ExportDeclaration */); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.exportClause = exportClause; @@ -12114,7 +12478,7 @@ var ts; } ts.updateExportDeclaration = updateExportDeclaration; function createNamedExports(elements) { - var node = createSynthesizedNode(244 /* NamedExports */); + var node = createSynthesizedNode(245 /* NamedExports */); node.elements = createNodeArray(elements); return node; } @@ -12125,22 +12489,23 @@ var ts; : node; } ts.updateNamedExports = updateNamedExports; - function createExportSpecifier(name, propertyName) { - var node = createSynthesizedNode(245 /* ExportSpecifier */); - node.name = asName(name); + function createExportSpecifier(propertyName, name) { + var node = createSynthesizedNode(246 /* ExportSpecifier */); node.propertyName = asName(propertyName); + node.name = asName(name); return node; } ts.createExportSpecifier = createExportSpecifier; - function updateExportSpecifier(node, name, propertyName) { - return node.name !== name || node.propertyName !== propertyName - ? updateNode(createExportSpecifier(name, propertyName), node) + function updateExportSpecifier(node, propertyName, name) { + return node.propertyName !== propertyName + || node.name !== name + ? updateNode(createExportSpecifier(propertyName, name), node) : node; } ts.updateExportSpecifier = updateExportSpecifier; // Module references function createExternalModuleReference(expression) { - var node = createSynthesizedNode(247 /* ExternalModuleReference */); + var node = createSynthesizedNode(248 /* ExternalModuleReference */); node.expression = expression; return node; } @@ -12153,7 +12518,7 @@ var ts; ts.updateExternalModuleReference = updateExternalModuleReference; // JSX function createJsxElement(openingElement, children, closingElement) { - var node = createSynthesizedNode(248 /* JsxElement */); + var node = createSynthesizedNode(249 /* JsxElement */); node.openingElement = openingElement; node.children = createNodeArray(children); node.closingElement = closingElement; @@ -12169,7 +12534,7 @@ var ts; } ts.updateJsxElement = updateJsxElement; function createJsxSelfClosingElement(tagName, attributes) { - var node = createSynthesizedNode(249 /* JsxSelfClosingElement */); + var node = createSynthesizedNode(250 /* JsxSelfClosingElement */); node.tagName = tagName; node.attributes = attributes; return node; @@ -12183,7 +12548,7 @@ var ts; } ts.updateJsxSelfClosingElement = updateJsxSelfClosingElement; function createJsxOpeningElement(tagName, attributes) { - var node = createSynthesizedNode(250 /* JsxOpeningElement */); + var node = createSynthesizedNode(251 /* JsxOpeningElement */); node.tagName = tagName; node.attributes = attributes; return node; @@ -12197,7 +12562,7 @@ var ts; } ts.updateJsxOpeningElement = updateJsxOpeningElement; function createJsxClosingElement(tagName) { - var node = createSynthesizedNode(251 /* JsxClosingElement */); + var node = createSynthesizedNode(252 /* JsxClosingElement */); node.tagName = tagName; return node; } @@ -12209,7 +12574,7 @@ var ts; } ts.updateJsxClosingElement = updateJsxClosingElement; function createJsxAttributes(properties) { - var jsxAttributes = createSynthesizedNode(253 /* JsxAttributes */); + var jsxAttributes = createSynthesizedNode(254 /* JsxAttributes */); jsxAttributes.properties = createNodeArray(properties); return jsxAttributes; } @@ -12222,7 +12587,7 @@ var ts; } ts.updateJsxAttributes = updateJsxAttributes; function createJsxAttribute(name, initializer) { - var node = createSynthesizedNode(252 /* JsxAttribute */); + var node = createSynthesizedNode(253 /* JsxAttribute */); node.name = name; node.initializer = initializer; return node; @@ -12236,7 +12601,7 @@ var ts; } ts.updateJsxAttribute = updateJsxAttribute; function createJsxSpreadAttribute(expression) { - var node = createSynthesizedNode(254 /* JsxSpreadAttribute */); + var node = createSynthesizedNode(255 /* JsxSpreadAttribute */); node.expression = expression; return node; } @@ -12247,8 +12612,8 @@ var ts; : node; } ts.updateJsxSpreadAttribute = updateJsxSpreadAttribute; - function createJsxExpression(expression, dotDotDotToken) { - var node = createSynthesizedNode(255 /* JsxExpression */); + function createJsxExpression(dotDotDotToken, expression) { + var node = createSynthesizedNode(256 /* JsxExpression */); node.dotDotDotToken = dotDotDotToken; node.expression = expression; return node; @@ -12256,13 +12621,13 @@ var ts; ts.createJsxExpression = createJsxExpression; function updateJsxExpression(node, expression) { return node.expression !== expression - ? updateNode(createJsxExpression(expression, node.dotDotDotToken), node) + ? updateNode(createJsxExpression(node.dotDotDotToken, expression), node) : node; } ts.updateJsxExpression = updateJsxExpression; // Clauses function createHeritageClause(token, types) { - var node = createSynthesizedNode(258 /* HeritageClause */); + var node = createSynthesizedNode(259 /* HeritageClause */); node.token = token; node.types = createNodeArray(types); return node; @@ -12276,7 +12641,7 @@ var ts; } ts.updateHeritageClause = updateHeritageClause; function createCaseClause(expression, statements) { - var node = createSynthesizedNode(256 /* CaseClause */); + var node = createSynthesizedNode(257 /* CaseClause */); node.expression = ts.parenthesizeExpressionForList(expression); node.statements = createNodeArray(statements); return node; @@ -12290,7 +12655,7 @@ var ts; } ts.updateCaseClause = updateCaseClause; function createDefaultClause(statements) { - var node = createSynthesizedNode(257 /* DefaultClause */); + var node = createSynthesizedNode(258 /* DefaultClause */); node.statements = createNodeArray(statements); return node; } @@ -12303,7 +12668,7 @@ var ts; } ts.updateDefaultClause = updateDefaultClause; function createCatchClause(variableDeclaration, block) { - var node = createSynthesizedNode(259 /* CatchClause */); + var node = createSynthesizedNode(260 /* CatchClause */); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; node.block = block; return node; @@ -12318,7 +12683,7 @@ var ts; ts.updateCatchClause = updateCatchClause; // Property assignments function createPropertyAssignment(name, initializer) { - var node = createSynthesizedNode(260 /* PropertyAssignment */); + var node = createSynthesizedNode(261 /* PropertyAssignment */); node.name = asName(name); node.questionToken = undefined; node.initializer = initializer !== undefined ? ts.parenthesizeExpressionForList(initializer) : undefined; @@ -12333,18 +12698,12 @@ var ts; } ts.updatePropertyAssignment = updatePropertyAssignment; function createShorthandPropertyAssignment(name, objectAssignmentInitializer) { - var node = createSynthesizedNode(261 /* ShorthandPropertyAssignment */); + var node = createSynthesizedNode(262 /* ShorthandPropertyAssignment */); node.name = asName(name); node.objectAssignmentInitializer = objectAssignmentInitializer !== undefined ? ts.parenthesizeExpressionForList(objectAssignmentInitializer) : undefined; return node; } ts.createShorthandPropertyAssignment = createShorthandPropertyAssignment; - function createSpreadAssignment(expression) { - var node = createSynthesizedNode(262 /* SpreadAssignment */); - node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; - return node; - } - ts.createSpreadAssignment = createSpreadAssignment; function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) { if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); @@ -12352,6 +12711,12 @@ var ts; return node; } ts.updateShorthandPropertyAssignment = updateShorthandPropertyAssignment; + function createSpreadAssignment(expression) { + var node = createSynthesizedNode(263 /* SpreadAssignment */); + node.expression = expression !== undefined ? ts.parenthesizeExpressionForList(expression) : undefined; + return node; + } + ts.createSpreadAssignment = createSpreadAssignment; function updateSpreadAssignment(node, expression) { if (node.expression !== expression) { return updateNode(createSpreadAssignment(expression), node); @@ -12361,7 +12726,7 @@ var ts; ts.updateSpreadAssignment = updateSpreadAssignment; // Enum function createEnumMember(name, initializer) { - var node = createSynthesizedNode(263 /* EnumMember */); + var node = createSynthesizedNode(264 /* EnumMember */); node.name = asName(name); node.initializer = initializer && ts.parenthesizeExpressionForList(initializer); return node; @@ -12377,7 +12742,7 @@ var ts; // Top-level nodes function updateSourceFileNode(node, statements) { if (node.statements !== statements) { - var updated = createSynthesizedNode(264 /* SourceFile */); + var updated = createSynthesizedNode(265 /* SourceFile */); updated.flags |= node.flags; updated.statements = createNodeArray(statements); updated.endOfFileToken = node.endOfFileToken; @@ -12456,7 +12821,7 @@ var ts; * @param original The original statement. */ function createNotEmittedStatement(original) { - var node = createSynthesizedNode(297 /* NotEmittedStatement */); + var node = createSynthesizedNode(295 /* NotEmittedStatement */); node.original = original; setTextRange(node, original); return node; @@ -12468,7 +12833,7 @@ var ts; */ /* @internal */ function createEndOfDeclarationMarker(original) { - var node = createSynthesizedNode(300 /* EndOfDeclarationMarker */); + var node = createSynthesizedNode(298 /* EndOfDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12480,7 +12845,7 @@ var ts; */ /* @internal */ function createMergeDeclarationMarker(original) { - var node = createSynthesizedNode(299 /* MergeDeclarationMarker */); + var node = createSynthesizedNode(297 /* MergeDeclarationMarker */); node.emitNode = {}; node.original = original; return node; @@ -12495,7 +12860,7 @@ var ts; * @param location The location for the expression. Defaults to the positions from "original" if provided. */ function createPartiallyEmittedExpression(expression, original) { - var node = createSynthesizedNode(298 /* PartiallyEmittedExpression */); + var node = createSynthesizedNode(296 /* PartiallyEmittedExpression */); node.expression = expression; node.original = original; setTextRange(node, original); @@ -12510,7 +12875,7 @@ var ts; } ts.updatePartiallyEmittedExpression = updatePartiallyEmittedExpression; function createBundle(sourceFiles) { - var node = ts.createNode(265 /* Bundle */); + var node = ts.createNode(266 /* Bundle */); node.sourceFiles = sourceFiles; return node; } @@ -12524,47 +12889,47 @@ var ts; ts.updateBundle = updateBundle; // Compound nodes function createComma(left, right) { - return createBinary(left, 25 /* CommaToken */, right); + return createBinary(left, 26 /* CommaToken */, right); } ts.createComma = createComma; function createLessThan(left, right) { - return createBinary(left, 26 /* LessThanToken */, right); + return createBinary(left, 27 /* LessThanToken */, right); } ts.createLessThan = createLessThan; function createAssignment(left, right) { - return createBinary(left, 57 /* EqualsToken */, right); + return createBinary(left, 58 /* EqualsToken */, right); } ts.createAssignment = createAssignment; function createStrictEquality(left, right) { - return createBinary(left, 33 /* EqualsEqualsEqualsToken */, right); + return createBinary(left, 34 /* EqualsEqualsEqualsToken */, right); } ts.createStrictEquality = createStrictEquality; function createStrictInequality(left, right) { - return createBinary(left, 34 /* ExclamationEqualsEqualsToken */, right); + return createBinary(left, 35 /* ExclamationEqualsEqualsToken */, right); } ts.createStrictInequality = createStrictInequality; function createAdd(left, right) { - return createBinary(left, 36 /* PlusToken */, right); + return createBinary(left, 37 /* PlusToken */, right); } ts.createAdd = createAdd; function createSubtract(left, right) { - return createBinary(left, 37 /* MinusToken */, right); + return createBinary(left, 38 /* MinusToken */, right); } ts.createSubtract = createSubtract; function createPostfixIncrement(operand) { - return createPostfix(operand, 42 /* PlusPlusToken */); + return createPostfix(operand, 43 /* PlusPlusToken */); } ts.createPostfixIncrement = createPostfixIncrement; function createLogicalAnd(left, right) { - return createBinary(left, 52 /* AmpersandAmpersandToken */, right); + return createBinary(left, 53 /* AmpersandAmpersandToken */, right); } ts.createLogicalAnd = createLogicalAnd; function createLogicalOr(left, right) { - return createBinary(left, 53 /* BarBarToken */, right); + return createBinary(left, 54 /* BarBarToken */, right); } ts.createLogicalOr = createLogicalOr; function createLogicalNot(operand) { - return createPrefix(50 /* ExclamationToken */, operand); + return createPrefix(51 /* ExclamationToken */, operand); } ts.createLogicalNot = createLogicalNot; function createVoidZero() { @@ -12576,7 +12941,7 @@ var ts; } ts.createExportDefault = createExportDefault; function createExternalModuleExport(exportName) { - return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(exportName)])); + return createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, createNamedExports([createExportSpecifier(/*propertyName*/ undefined, exportName)])); } ts.createExternalModuleExport = createExternalModuleExport; function asName(name) { @@ -12624,7 +12989,7 @@ var ts; // To avoid holding onto transformation artifacts, we keep track of any // parse tree node we are annotating. This allows us to clean them up after // all transformations have completed. - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { return node.emitNode = { annotatedNodes: [node] }; } var sourceFile = ts.getSourceFileOfNode(node); @@ -12710,6 +13075,34 @@ var ts; return node; } ts.setCommentRange = setCommentRange; + function getSyntheticLeadingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.leadingComments; + } + ts.getSyntheticLeadingComments = getSyntheticLeadingComments; + function setSyntheticLeadingComments(node, comments) { + getOrCreateEmitNode(node).leadingComments = comments; + return node; + } + ts.setSyntheticLeadingComments = setSyntheticLeadingComments; + function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticLeadingComment = addSyntheticLeadingComment; + function getSyntheticTrailingComments(node) { + var emitNode = node.emitNode; + return emitNode && emitNode.trailingComments; + } + ts.getSyntheticTrailingComments = getSyntheticTrailingComments; + function setSyntheticTrailingComments(node, comments) { + getOrCreateEmitNode(node).trailingComments = comments; + return node; + } + ts.setSyntheticTrailingComments = setSyntheticTrailingComments; + function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) { + return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text })); + } + ts.addSyntheticTrailingComment = addSyntheticTrailingComment; /** * Gets the constant value to emit for an expression. */ @@ -12825,9 +13218,13 @@ var ts; } ts.setOriginalNode = setOriginalNode; function mergeEmitNode(sourceEmitNode, destEmitNode) { - var flags = sourceEmitNode.flags, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; + var flags = sourceEmitNode.flags, leadingComments = sourceEmitNode.leadingComments, trailingComments = sourceEmitNode.trailingComments, commentRange = sourceEmitNode.commentRange, sourceMapRange = sourceEmitNode.sourceMapRange, tokenSourceMapRanges = sourceEmitNode.tokenSourceMapRanges, constantValue = sourceEmitNode.constantValue, helpers = sourceEmitNode.helpers; if (!destEmitNode) destEmitNode = {}; + if (leadingComments) + destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments); + if (trailingComments) + destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments); if (flags) destEmitNode.flags = flags; if (commentRange) @@ -12962,12 +13359,72 @@ var ts; return ts.setEmitFlags(ts.createIdentifier(name), 4096 /* HelperName */ | 2 /* AdviseOnEmitNode */); } ts.getHelperName = getHelperName; + var valuesHelper = { + name: "typescript:values", + scoped: false, + text: "\n var __values = (this && this.__values) || function (o) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\n if (m) return m.call(o);\n return {\n next: function () {\n if (o && i >= o.length) o = void 0;\n return { value: o && o[i++], done: !o };\n }\n };\n };\n " + }; + function createValuesHelper(context, expression, location) { + context.requestEmitHelper(valuesHelper); + return ts.setTextRange(ts.createCall(getHelperName("__values"), + /*typeArguments*/ undefined, [expression]), location); + } + ts.createValuesHelper = createValuesHelper; + var readHelper = { + name: "typescript:read", + scoped: false, + text: "\n var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n };\n " + }; + function createReadHelper(context, iteratorRecord, count, location) { + context.requestEmitHelper(readHelper); + return ts.setTextRange(ts.createCall(getHelperName("__read"), + /*typeArguments*/ undefined, count !== undefined + ? [iteratorRecord, ts.createLiteral(count)] + : [iteratorRecord]), location); + } + ts.createReadHelper = createReadHelper; + var spreadHelper = { + name: "typescript:spread", + scoped: false, + text: "\n var __spread = (this && this.__spread) || function () {\n for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));\n return ar;\n };" + }; + function createSpreadHelper(context, argumentList, location) { + context.requestEmitHelper(readHelper); + context.requestEmitHelper(spreadHelper); + return ts.setTextRange(ts.createCall(getHelperName("__spread"), + /*typeArguments*/ undefined, argumentList), location); + } + ts.createSpreadHelper = createSpreadHelper; // Utilities + function createForOfBindingStatement(node, boundValue) { + if (ts.isVariableDeclarationList(node)) { + var firstDeclaration = ts.firstOrUndefined(node.declarations); + var updatedDeclaration = ts.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, + /*typeNode*/ undefined, boundValue); + return ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.updateVariableDeclarationList(node, [updatedDeclaration])), + /*location*/ node); + } + else { + var updatedExpression = ts.setTextRange(ts.createAssignment(node, boundValue), /*location*/ node); + return ts.setTextRange(ts.createStatement(updatedExpression), /*location*/ node); + } + } + ts.createForOfBindingStatement = createForOfBindingStatement; + function insertLeadingStatement(dest, source) { + if (ts.isBlock(dest)) { + return ts.updateBlock(dest, ts.setTextRange(ts.createNodeArray([source].concat(dest.statements)), dest.statements)); + } + else { + return ts.createBlock(ts.createNodeArray([dest, source]), /*multiLine*/ true); + } + } + ts.insertLeadingStatement = insertLeadingStatement; function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) { if (!outermostLabeledStatement) { return node; } - var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 221 /* LabeledStatement */ + var updated = ts.updateLabel(outermostLabeledStatement, outermostLabeledStatement.label, outermostLabeledStatement.statement.kind === 222 /* LabeledStatement */ ? restoreEnclosingLabel(node, outermostLabeledStatement.statement) : node); if (afterRestoreLabelCallback) { @@ -12979,19 +13436,19 @@ var ts; function shouldBeCapturedInTempVariable(node, cacheIdentifiers) { var target = skipParentheses(node); switch (target.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return cacheIdentifiers; - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return false; - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: var elements = target.elements; if (elements.length === 0) { return false; } return true; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return target.properties.length > 0; default: return true; @@ -13005,15 +13462,19 @@ var ts; thisArg = ts.createThis(); target = callee; } - else if (callee.kind === 96 /* SuperKeyword */) { + else if (callee.kind === 97 /* SuperKeyword */) { thisArg = ts.createThis(); target = languageVersion < 2 /* ES2015 */ ? ts.setTextRange(ts.createIdentifier("_super"), callee) : callee; } + else if (ts.getEmitFlags(callee) & 4096 /* HelperName */) { + thisArg = ts.createVoidZero(); + target = parenthesizeForAccess(callee); + } else { switch (callee.kind) { - case 178 /* PropertyAccessExpression */: { + case 179 /* PropertyAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a.b()` target is `(_a = a).b` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -13026,7 +13487,7 @@ var ts; } break; } - case 179 /* ElementAccessExpression */: { + case 180 /* ElementAccessExpression */: { if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) { // for `a[b]()` target is `(_a = a)[b]` and thisArg is `_a` thisArg = ts.createTempVariable(recordTempVariable); @@ -13079,14 +13540,14 @@ var ts; ts.createExpressionForPropertyName = createExpressionForPropertyName; function createExpressionForObjectLiteralElementLike(node, property, receiver) { switch (property.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return createExpressionForAccessorDeclaration(node.properties, property, receiver, node.multiLine); - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return createExpressionForPropertyAssignment(property, receiver); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return createExpressionForShorthandPropertyAssignment(property, receiver); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return createExpressionForMethodDeclaration(property, receiver); } } @@ -13148,6 +13609,28 @@ var ts; /*location*/ method), /*original*/ method)); } + /** + * Gets the internal name of a declaration. This is primarily used for declarations that can be + * referred to by name in the body of an ES5 class function body. An internal name will *never* + * be prefixed with an module or namespace export modifier like "exports." when emitted as an + * expression. An internal name will also *never* be renamed due to a collision with a block + * scoped variable. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + function getInternalName(node, allowComments, allowSourceMaps) { + return getName(node, allowComments, allowSourceMaps, 16384 /* LocalName */ | 32768 /* InternalName */); + } + ts.getInternalName = getInternalName; + /** + * Gets whether an identifier should only be referred to by its internal name. + */ + function isInternalName(node) { + return (ts.getEmitFlags(node) & 32768 /* InternalName */) !== 0; + } + ts.isInternalName = isInternalName; /** * Gets the local name of a declaration. This is primarily used for declarations that can be * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A @@ -13273,7 +13756,18 @@ var ts; * @param ensureUseStrict: boolean determining whether the function need to add prologue-directives * @param visitor: Optional callback used to visit any custom prologue directives. */ - function addPrologueDirectives(target, source, ensureUseStrict, visitor) { + function addPrologue(target, source, ensureUseStrict, visitor) { + var offset = addStandardPrologue(target, source, ensureUseStrict); + return addCustomPrologue(target, source, offset, visitor); + } + ts.addPrologue = addPrologue; + /** + * Add just the standard (string-expression) prologue-directives into target statement-array. + * The function needs to be called during each transformation step. + * This function needs to be called whenever we transform the statement + * list of a source file, namespace, or function-like body. + */ + function addStandardPrologue(target, source, ensureUseStrict) { ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array"); var foundUseStrict = false; var statementOffset = 0; @@ -13294,9 +13788,20 @@ var ts; if (ensureUseStrict && !foundUseStrict) { target.push(startOnNewLine(ts.createStatement(ts.createLiteral("use strict")))); } + return statementOffset; + } + ts.addStandardPrologue = addStandardPrologue; + /** + * Add just the custom prologue-directives into target statement-array. + * The function needs to be called during each transformation step. + * This function needs to be called whenever we transform the statement + * list of a source file, namespace, or function-like body. + */ + function addCustomPrologue(target, source, statementOffset, visitor) { + var numStatements = source.length; while (statementOffset < numStatements) { var statement = source[statementOffset]; - if (ts.getEmitFlags(statement) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(statement) & 1048576 /* CustomPrologue */) { target.push(visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement); } else { @@ -13306,7 +13811,7 @@ var ts; } return statementOffset; } - ts.addPrologueDirectives = addPrologueDirectives; + ts.addCustomPrologue = addCustomPrologue; function startsWithUseStrict(statements) { var firstStatement = ts.firstOrUndefined(statements); return firstStatement !== undefined @@ -13341,6 +13846,16 @@ var ts; return statements; } ts.ensureUseStrict = ensureUseStrict; + function parenthesizeConditionalHead(condition) { + var conditionalPrecedence = ts.getOperatorPrecedence(195 /* ConditionalExpression */, 55 /* QuestionToken */); + var emittedCondition = skipPartiallyEmittedExpressions(condition); + var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); + if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { + return ts.createParen(condition); + } + return condition; + } + ts.parenthesizeConditionalHead = parenthesizeConditionalHead; /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. @@ -13353,7 +13868,7 @@ var ts; function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) { var skipped = skipPartiallyEmittedExpressions(operand); // If the resulting expression is already parenthesized, we do not need to do any further processing. - if (skipped.kind === 184 /* ParenthesizedExpression */) { + if (skipped.kind === 185 /* ParenthesizedExpression */) { return operand; } return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) @@ -13387,8 +13902,8 @@ var ts; // // If `a ** d` is on the left of operator `**`, we need to parenthesize to preserve // the intended order of operations: `(a ** b) ** c` - var binaryOperatorPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, binaryOperator); - var binaryOperatorAssociativity = ts.getOperatorAssociativity(193 /* BinaryExpression */, binaryOperator); + var binaryOperatorPrecedence = ts.getOperatorPrecedence(194 /* BinaryExpression */, binaryOperator); + var binaryOperatorAssociativity = ts.getOperatorAssociativity(194 /* BinaryExpression */, binaryOperator); var emittedOperand = skipPartiallyEmittedExpressions(operand); var operandPrecedence = ts.getExpressionPrecedence(emittedOperand); switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) { @@ -13397,7 +13912,7 @@ var ts; // and is a yield expression, then we do not need parentheses. if (!isLeftSideOfBinary && binaryOperatorAssociativity === 1 /* Right */ - && operand.kind === 196 /* YieldExpression */) { + && operand.kind === 197 /* YieldExpression */) { return false; } return true; @@ -13434,7 +13949,7 @@ var ts; // the same kind (recursively). // "a"+(1+2) => "a"+(1+2) // "a"+("b"+"c") => "a"+"b"+"c" - if (binaryOperator === 36 /* PlusToken */) { + if (binaryOperator === 37 /* PlusToken */) { var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0 /* Unknown */; if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) { return false; @@ -13469,10 +13984,10 @@ var ts; // // While addition is associative in mathematics, JavaScript's `+` is not // guaranteed to be associative as it is overloaded with string concatenation. - return binaryOperator === 38 /* AsteriskToken */ - || binaryOperator === 48 /* BarToken */ - || binaryOperator === 47 /* AmpersandToken */ - || binaryOperator === 49 /* CaretToken */; + return binaryOperator === 39 /* AsteriskToken */ + || binaryOperator === 49 /* BarToken */ + || binaryOperator === 48 /* AmpersandToken */ + || binaryOperator === 50 /* CaretToken */; } /** * This function determines whether an expression consists of a homogeneous set of @@ -13485,7 +14000,7 @@ var ts; if (ts.isLiteralKind(node.kind)) { return node.kind; } - if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 36 /* PlusToken */) { + if (node.kind === 194 /* BinaryExpression */ && node.operatorToken.kind === 37 /* PlusToken */) { if (node.cachedLiteralKind !== undefined) { return node.cachedLiteralKind; } @@ -13500,7 +14015,7 @@ var ts; return 0 /* Unknown */; } function parenthesizeForConditionalHead(condition) { - var conditionalPrecedence = ts.getOperatorPrecedence(194 /* ConditionalExpression */, 54 /* QuestionToken */); + var conditionalPrecedence = ts.getOperatorPrecedence(195 /* ConditionalExpression */, 55 /* QuestionToken */); var emittedCondition = skipPartiallyEmittedExpressions(condition); var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition); if (ts.compareValues(conditionPrecedence, conditionalPrecedence) === -1 /* LessThan */) { @@ -13513,7 +14028,7 @@ var ts; // per ES grammar both 'whenTrue' and 'whenFalse' parts of conditional expression are assignment expressions // so in case when comma expression is introduced as a part of previous transformations // if should be wrapped in parens since comma operator has the lowest precedence - return e.kind === 193 /* BinaryExpression */ && e.operatorToken.kind === 25 /* CommaToken */ + return e.kind === 194 /* BinaryExpression */ && e.operatorToken.kind === 26 /* CommaToken */ ? ts.createParen(e) : e; } @@ -13527,9 +14042,9 @@ var ts; function parenthesizeForNew(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); switch (emittedExpression.kind) { - case 180 /* CallExpression */: + case 181 /* CallExpression */: return ts.createParen(expression); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return emittedExpression.arguments ? expression : ts.createParen(expression); @@ -13545,17 +14060,14 @@ var ts; */ function parenthesizeForAccess(expression) { // isLeftHandSideExpression is almost the correct criterion for when it is not necessary - // to parenthesize the expression before a dot. The known exceptions are: + // to parenthesize the expression before a dot. The known exception is: // // NewExpression: // new C.x -> not the same as (new C).x - // NumericLiteral - // 1.x -> not the same as (1).x // var emittedExpression = skipPartiallyEmittedExpressions(expression); if (ts.isLeftHandSideExpression(emittedExpression) - && (emittedExpression.kind !== 181 /* NewExpression */ || emittedExpression.arguments) - && emittedExpression.kind !== 8 /* NumericLiteral */) { + && (emittedExpression.kind !== 182 /* NewExpression */ || emittedExpression.arguments)) { return expression; } return ts.setTextRange(ts.createParen(expression), expression); @@ -13593,7 +14105,7 @@ var ts; function parenthesizeExpressionForList(expression) { var emittedExpression = skipPartiallyEmittedExpressions(expression); var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression); - var commaPrecedence = ts.getOperatorPrecedence(193 /* BinaryExpression */, 25 /* CommaToken */); + var commaPrecedence = ts.getOperatorPrecedence(194 /* BinaryExpression */, 26 /* CommaToken */); return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(ts.createParen(expression), expression); @@ -13604,7 +14116,7 @@ var ts; if (ts.isCallExpression(emittedExpression)) { var callee = emittedExpression.expression; var kind = skipPartiallyEmittedExpressions(callee).kind; - if (kind === 185 /* FunctionExpression */ || kind === 186 /* ArrowFunction */) { + if (kind === 186 /* FunctionExpression */ || kind === 187 /* ArrowFunction */) { var mutableCall = ts.getMutableClone(emittedExpression); mutableCall.expression = ts.setTextRange(ts.createParen(callee), callee); return recreatePartiallyEmittedExpressions(expression, mutableCall); @@ -13612,7 +14124,7 @@ var ts; } else { var leftmostExpressionKind = getLeftmostExpression(emittedExpression).kind; - if (leftmostExpressionKind === 177 /* ObjectLiteralExpression */ || leftmostExpressionKind === 185 /* FunctionExpression */) { + if (leftmostExpressionKind === 178 /* ObjectLiteralExpression */ || leftmostExpressionKind === 186 /* FunctionExpression */) { return ts.setTextRange(ts.createParen(expression), expression); } } @@ -13636,21 +14148,21 @@ var ts; function getLeftmostExpression(node) { while (true) { switch (node.kind) { - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: node = node.operand; continue; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: node = node.left; continue; - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: node = node.condition; continue; - case 180 /* CallExpression */: - case 179 /* ElementAccessExpression */: - case 178 /* PropertyAccessExpression */: + case 181 /* CallExpression */: + case 180 /* ElementAccessExpression */: + case 179 /* PropertyAccessExpression */: node = node.expression; continue; - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: node = node.expression; continue; } @@ -13658,8 +14170,7 @@ var ts; } } function parenthesizeConciseBody(body) { - var emittedBody = skipPartiallyEmittedExpressions(body); - if (emittedBody.kind === 177 /* ObjectLiteralExpression */) { + if (!ts.isBlock(body) && getLeftmostExpression(body).kind === 178 /* ObjectLiteralExpression */) { return ts.setTextRange(ts.createParen(body), body); } return body; @@ -13691,7 +14202,7 @@ var ts; } ts.skipOuterExpressions = skipOuterExpressions; function skipParentheses(node) { - while (node.kind === 184 /* ParenthesizedExpression */) { + while (node.kind === 185 /* ParenthesizedExpression */) { node = node.expression; } return node; @@ -13705,7 +14216,7 @@ var ts; } ts.skipAssertions = skipAssertions; function skipPartiallyEmittedExpressions(node) { - while (node.kind === 298 /* PartiallyEmittedExpression */) { + while (node.kind === 296 /* PartiallyEmittedExpression */) { node = node.expression; } return node; @@ -13751,10 +14262,10 @@ var ts; var name = namespaceDeclaration.name; return ts.isGeneratedIdentifier(name) ? name : ts.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, namespaceDeclaration.name)); } - if (node.kind === 237 /* ImportDeclaration */ && node.importClause) { + if (node.kind === 238 /* ImportDeclaration */ && node.importClause) { return ts.getGeneratedNameForNode(node); } - if (node.kind === 243 /* ExportDeclaration */ && node.moduleSpecifier) { + if (node.kind === 244 /* ExportDeclaration */ && node.moduleSpecifier) { return ts.getGeneratedNameForNode(node); } return undefined; @@ -13872,7 +14383,7 @@ var ts; } if (ts.isObjectLiteralElementLike(bindingElement)) { switch (bindingElement.kind) { - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: // `b` in `({ a: b } = ...)` // `b` in `({ a: b = 1 } = ...)` // `{b}` in `({ a: {b} } = ...)` @@ -13884,11 +14395,11 @@ var ts; // `b[0]` in `({ a: b[0] } = ...)` // `b[0]` in `({ a: b[0] = 1 } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.initializer); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: // `a` in `({ a } = ...)` // `a` in `({ a = 1 } = ...)` return bindingElement.name; - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return getTargetOfBindingOrAssignmentElement(bindingElement.expression); } @@ -13920,12 +14431,12 @@ var ts; */ function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 145 /* Parameter */: - case 175 /* BindingElement */: + case 146 /* Parameter */: + case 176 /* BindingElement */: // `...` in `let [...a] = ...` return bindingElement.dotDotDotToken; - case 197 /* SpreadElement */: - case 262 /* SpreadAssignment */: + case 198 /* SpreadElement */: + case 263 /* SpreadAssignment */: // `...` in `[...a] = ...` return bindingElement; } @@ -13937,7 +14448,7 @@ var ts; */ function getPropertyNameOfBindingOrAssignmentElement(bindingElement) { switch (bindingElement.kind) { - case 175 /* BindingElement */: + case 176 /* BindingElement */: // `a` in `let { a: b } = ...` // `[a]` in `let { [a]: b } = ...` // `"a"` in `let { "a": b } = ...` @@ -13949,7 +14460,7 @@ var ts; : propertyName; } break; - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: // `a` in `({ a: b } = ...)` // `[a]` in `({ [a]: b } = ...)` // `"a"` in `({ "a": b } = ...)` @@ -13961,7 +14472,7 @@ var ts; : propertyName; } break; - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: // `a` in `({ ...a } = ...)` return bindingElement.name; } @@ -13979,13 +14490,13 @@ var ts; */ function getElementsOfBindingOrAssignmentPattern(name) { switch (name.kind) { - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: - case 176 /* ArrayLiteralExpression */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: + case 177 /* ArrayLiteralExpression */: // `a` in `{a}` // `a` in `[a]` return name.elements; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: // `a` in `{a}` return name.properties; } @@ -14025,11 +14536,11 @@ var ts; ts.convertToObjectAssignmentElement = convertToObjectAssignmentElement; function convertToAssignmentPattern(node) { switch (node.kind) { - case 174 /* ArrayBindingPattern */: - case 176 /* ArrayLiteralExpression */: + case 175 /* ArrayBindingPattern */: + case 177 /* ArrayLiteralExpression */: return convertToArrayAssignmentPattern(node); - case 173 /* ObjectBindingPattern */: - case 177 /* ObjectLiteralExpression */: + case 174 /* ObjectBindingPattern */: + case 178 /* ObjectLiteralExpression */: return convertToObjectAssignmentPattern(node); } } @@ -14077,20 +14588,20 @@ var ts; for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) { var node = _a[_i]; switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: // import "mod" // import x from "mod" // import * as x from "mod" // import { x, y } from "mod" externalImports.push(node); break; - case 236 /* ImportEqualsDeclaration */: - if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { + case 237 /* ImportEqualsDeclaration */: + if (node.moduleReference.kind === 248 /* ExternalModuleReference */) { // import x = require("mod") externalImports.push(node); } break; - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: if (node.moduleSpecifier) { if (!node.exportClause) { // export * from "mod" @@ -14120,13 +14631,13 @@ var ts; } } break; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: if (node.isExportEquals && !exportEquals) { // export = x exportEquals = node; } break; - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: if (ts.hasModifier(node, 1 /* Export */)) { for (var _d = 0, _e = node.declarationList.declarations; _d < _e.length; _d++) { var decl = _e[_d]; @@ -14134,7 +14645,7 @@ var ts; } } break; - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default function() { } @@ -14154,7 +14665,7 @@ var ts; } } break; - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: if (ts.hasModifier(node, 1 /* Export */)) { if (ts.hasModifier(node, 512 /* Default */)) { // export default class { } @@ -14218,13 +14729,13 @@ var ts; var IdentifierConstructor; var SourceFileConstructor; function createNode(kind, pos, end) { - if (kind === 264 /* SourceFile */) { + if (kind === 265 /* SourceFile */) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, pos, end); } - else if (kind === 70 /* Identifier */) { + else if (kind === 71 /* Identifier */) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, pos, end); } - else if (kind < 142 /* FirstNode */) { + else if (kind < 143 /* FirstNode */) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, pos, end); } else { @@ -14267,29 +14778,29 @@ var ts; var visitNodes = cbNodeArray ? visitNodeArray : visitEachNode; var cbNodes = cbNodeArray || cbNode; switch (node.kind) { - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.right); - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.constraint) || visitNode(cbNode, node.default) || visitNode(cbNode, node.expression); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* 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 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: return visitNode(cbNode, node.expression); - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 260 /* PropertyAssignment */: - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.propertyName) || @@ -14298,24 +14809,24 @@ var ts; visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type) || visitNode(cbNode, node.initializer); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNodes(cbNodes, node.typeParameters) || visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.asteriskToken) || @@ -14326,325 +14837,326 @@ var ts; visitNode(cbNode, node.type) || visitNode(cbNode, node.equalsGreaterThanToken) || visitNode(cbNode, node.body); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return visitNode(cbNode, node.typeName) || visitNodes(cbNodes, node.typeArguments); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return visitNode(cbNode, node.parameterName) || visitNode(cbNode, node.type); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return visitNode(cbNode, node.exprName); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return visitNodes(cbNodes, node.members); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return visitNode(cbNode, node.elementType); - case 164 /* TupleType */: + case 165 /* TupleType */: return visitNodes(cbNodes, node.elementTypes); - case 165 /* UnionType */: - case 166 /* IntersectionType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: return visitNodes(cbNodes, node.types); - case 167 /* ParenthesizedType */: - case 169 /* TypeOperator */: + case 168 /* ParenthesizedType */: + case 170 /* TypeOperator */: return visitNode(cbNode, node.type); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return visitNode(cbNode, node.objectType) || visitNode(cbNode, node.indexType); - case 171 /* MappedType */: + case 172 /* MappedType */: return visitNode(cbNode, node.readonlyToken) || visitNode(cbNode, node.typeParameter) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.type); - case 172 /* LiteralType */: + case 173 /* LiteralType */: return visitNode(cbNode, node.literal); - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: return visitNodes(cbNodes, node.elements); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return visitNodes(cbNodes, node.elements); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return visitNodes(cbNodes, node.properties); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.name); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.argumentExpression); - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments) || visitNodes(cbNodes, node.arguments); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return visitNode(cbNode, node.tag) || visitNode(cbNode, node.template); - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return visitNode(cbNode, node.type) || visitNode(cbNode, node.expression); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return visitNode(cbNode, node.expression); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return visitNode(cbNode, node.expression); - case 188 /* TypeOfExpression */: + case 189 /* TypeOfExpression */: return visitNode(cbNode, node.expression); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return visitNode(cbNode, node.expression); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return visitNode(cbNode, node.operand); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return visitNode(cbNode, node.asteriskToken) || visitNode(cbNode, node.expression); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return visitNode(cbNode, node.expression); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return visitNode(cbNode, node.operand); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitNode(cbNode, node.left) || visitNode(cbNode, node.operatorToken) || visitNode(cbNode, node.right); - case 201 /* AsExpression */: + case 202 /* AsExpression */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.type); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return visitNode(cbNode, node.expression); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return visitNode(cbNode, node.name); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return visitNode(cbNode, node.condition) || visitNode(cbNode, node.questionToken) || visitNode(cbNode, node.whenTrue) || visitNode(cbNode, node.colonToken) || visitNode(cbNode, node.whenFalse); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return visitNode(cbNode, node.expression); - case 206 /* Block */: - case 233 /* ModuleBlock */: + case 207 /* Block */: + case 234 /* ModuleBlock */: return visitNodes(cbNodes, node.statements); - case 264 /* SourceFile */: + case 265 /* SourceFile */: return visitNodes(cbNodes, node.statements) || visitNode(cbNode, node.endOfFileToken); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.declarationList); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return visitNodes(cbNodes, node.declarations); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return visitNode(cbNode, node.expression); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.thenStatement) || visitNode(cbNode, node.elseStatement); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return visitNode(cbNode, node.statement) || visitNode(cbNode, node.expression); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.condition) || visitNode(cbNode, node.incrementor) || visitNode(cbNode, node.statement); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 215 /* ForOfStatement */: - return visitNode(cbNode, node.initializer) || + case 216 /* ForOfStatement */: + return visitNode(cbNode, node.awaitModifier) || + visitNode(cbNode, node.initializer) || visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 216 /* ContinueStatement */: - case 217 /* BreakStatement */: + case 217 /* ContinueStatement */: + case 218 /* BreakStatement */: return visitNode(cbNode, node.label); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitNode(cbNode, node.expression); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.statement); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.caseBlock); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return visitNodes(cbNodes, node.clauses); - case 256 /* CaseClause */: + case 257 /* CaseClause */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.statements); - case 257 /* DefaultClause */: + case 258 /* DefaultClause */: return visitNodes(cbNodes, node.statements); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitNode(cbNode, node.label) || visitNode(cbNode, node.statement); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return visitNode(cbNode, node.expression); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return visitNode(cbNode, node.tryBlock) || visitNode(cbNode, node.catchClause) || visitNode(cbNode, node.finallyBlock); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return visitNode(cbNode, node.variableDeclaration) || visitNode(cbNode, node.block); - case 146 /* Decorator */: + case 147 /* Decorator */: return visitNode(cbNode, node.expression); - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* 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 229 /* InterfaceDeclaration */: + case 230 /* 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 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeParameters) || visitNode(cbNode, node.type); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNodes(cbNodes, node.members); - case 263 /* EnumMember */: + case 264 /* EnumMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.body); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.name) || visitNode(cbNode, node.moduleReference); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.importClause) || visitNode(cbNode, node.moduleSpecifier); - case 238 /* ImportClause */: + case 239 /* ImportClause */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.namedBindings); - case 235 /* NamespaceExportDeclaration */: + case 236 /* NamespaceExportDeclaration */: return visitNode(cbNode, node.name); - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: return visitNode(cbNode, node.name); - case 240 /* NamedImports */: - case 244 /* NamedExports */: + case 241 /* NamedImports */: + case 245 /* NamedExports */: return visitNodes(cbNodes, node.elements); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.exportClause) || visitNode(cbNode, node.moduleSpecifier); - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: return visitNode(cbNode, node.propertyName) || visitNode(cbNode, node.name); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitNodes(cbNodes, node.decorators) || visitNodes(cbNodes, node.modifiers) || visitNode(cbNode, node.expression); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return visitNode(cbNode, node.head) || visitNodes(cbNodes, node.templateSpans); - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return visitNode(cbNode, node.expression); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: return visitNodes(cbNodes, node.types); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return visitNode(cbNode, node.expression) || visitNodes(cbNodes, node.typeArguments); - case 247 /* ExternalModuleReference */: + case 248 /* ExternalModuleReference */: return visitNode(cbNode, node.expression); - case 246 /* MissingDeclaration */: + case 247 /* MissingDeclaration */: return visitNodes(cbNodes, node.decorators); - case 248 /* JsxElement */: + case 249 /* JsxElement */: return visitNode(cbNode, node.openingElement) || visitNodes(cbNodes, node.children) || visitNode(cbNode, node.closingElement); - case 249 /* JsxSelfClosingElement */: - case 250 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: return visitNode(cbNode, node.tagName) || visitNode(cbNode, node.attributes); - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return visitNodes(cbNodes, node.properties); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.initializer); - case 254 /* JsxSpreadAttribute */: + case 255 /* JsxSpreadAttribute */: return visitNode(cbNode, node.expression); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return visitNode(cbNode, node.dotDotDotToken) || visitNode(cbNode, node.expression); - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: return visitNode(cbNode, node.tagName); - case 266 /* JSDocTypeExpression */: + case 267 /* JSDocTypeExpression */: return visitNode(cbNode, node.type); - case 270 /* JSDocUnionType */: + case 271 /* JSDocUnionType */: return visitNodes(cbNodes, node.types); - case 271 /* JSDocTupleType */: + case 272 /* JSDocTupleType */: return visitNodes(cbNodes, node.types); - case 269 /* JSDocArrayType */: + case 270 /* JSDocArrayType */: return visitNode(cbNode, node.elementType); - case 273 /* JSDocNonNullableType */: + case 274 /* JSDocNonNullableType */: return visitNode(cbNode, node.type); - case 272 /* JSDocNullableType */: + case 273 /* JSDocNullableType */: return visitNode(cbNode, node.type); - case 274 /* JSDocRecordType */: + case 275 /* JSDocRecordType */: return visitNode(cbNode, node.literal); - case 276 /* JSDocTypeReference */: + case 277 /* JSDocTypeReference */: return visitNode(cbNode, node.name) || visitNodes(cbNodes, node.typeArguments); - case 277 /* JSDocOptionalType */: + case 278 /* JSDocOptionalType */: return visitNode(cbNode, node.type); - case 278 /* JSDocFunctionType */: + case 279 /* JSDocFunctionType */: return visitNodes(cbNodes, node.parameters) || visitNode(cbNode, node.type); - case 279 /* JSDocVariadicType */: + case 280 /* JSDocVariadicType */: return visitNode(cbNode, node.type); - case 280 /* JSDocConstructorType */: + case 281 /* JSDocConstructorType */: return visitNode(cbNode, node.type); - case 281 /* JSDocThisType */: + case 282 /* JSDocThisType */: return visitNode(cbNode, node.type); - case 275 /* JSDocRecordMember */: + case 276 /* JSDocRecordMember */: return visitNode(cbNode, node.name) || visitNode(cbNode, node.type); - case 282 /* JSDocComment */: + case 283 /* JSDocComment */: return visitNodes(cbNodes, node.tags); - case 285 /* JSDocParameterTag */: + case 286 /* JSDocParameterTag */: return visitNode(cbNode, node.preParameterName) || visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.postParameterName); - case 286 /* JSDocReturnTag */: + case 287 /* JSDocReturnTag */: return visitNode(cbNode, node.typeExpression); - case 287 /* JSDocTypeTag */: + case 288 /* JSDocTypeTag */: return visitNode(cbNode, node.typeExpression); - case 284 /* JSDocAugmentsTag */: + case 285 /* JSDocAugmentsTag */: return visitNode(cbNode, node.typeExpression); - case 288 /* JSDocTemplateTag */: + case 289 /* JSDocTemplateTag */: return visitNodes(cbNodes, node.typeParameters); - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.fullName) || visitNode(cbNode, node.name) || visitNode(cbNode, node.jsDocTypeLiteral); - case 291 /* JSDocTypeLiteral */: + case 292 /* JSDocTypeLiteral */: return visitNodes(cbNodes, node.jsDocPropertyTags); - case 290 /* JSDocPropertyTag */: + case 291 /* JSDocPropertyTag */: return visitNode(cbNode, node.typeExpression) || visitNode(cbNode, node.name); - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: return visitNode(cbNode, node.expression); - case 292 /* JSDocLiteralType */: + case 293 /* JSDocLiteralType */: return visitNode(cbNode, node.literal); } } @@ -14662,6 +15174,7 @@ var ts; return Parser.parseIsolatedEntityName(text, languageVersion); } ts.parseIsolatedEntityName = parseIsolatedEntityName; + // See also `isExternalOrCommonJsModule` in utilities.ts function isExternalModule(file) { return file.externalModuleIndicator !== undefined; } @@ -14916,7 +15429,7 @@ var ts; 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(264 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); + var sourceFile = new SourceFileConstructor(265 /* SourceFile */, /*pos*/ 0, /* end */ sourceText.length); nodeCount++; sourceFile.text = sourceText; sourceFile.bindDiagnostics = []; @@ -15120,20 +15633,20 @@ var ts; } // Ignore strict mode flag because we will report an error in type checker instead. function isIdentifier() { - if (token() === 70 /* Identifier */) { + if (token() === 71 /* Identifier */) { return true; } // If we have a 'yield' keyword, and we're in the [yield] context, then 'yield' is // considered a keyword and is not an identifier. - if (token() === 115 /* YieldKeyword */ && inYieldContext()) { + if (token() === 116 /* YieldKeyword */ && inYieldContext()) { return false; } // If we have a 'await' keyword, and we're in the [Await] context, then 'await' is // considered a keyword and is not an identifier. - if (token() === 120 /* AwaitKeyword */ && inAwaitContext()) { + if (token() === 121 /* AwaitKeyword */ && inAwaitContext()) { return false; } - return token() > 106 /* LastReservedWord */; + return token() > 107 /* LastReservedWord */; } function parseExpected(kind, diagnosticMessage, shouldAdvance) { if (shouldAdvance === void 0) { shouldAdvance = true; } @@ -15176,22 +15689,22 @@ var ts; } function canParseSemicolon() { // If there's a real semicolon, then we can always parse it out. - if (token() === 24 /* SemicolonToken */) { + if (token() === 25 /* SemicolonToken */) { return true; } // We can parse out an optional semicolon in ASI cases in the following cases. - return token() === 17 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); + return token() === 18 /* CloseBraceToken */ || token() === 1 /* EndOfFileToken */ || scanner.hasPrecedingLineBreak(); } function parseSemicolon() { if (canParseSemicolon()) { - if (token() === 24 /* SemicolonToken */) { + if (token() === 25 /* SemicolonToken */) { // consume the semicolon if it was explicitly provided. nextToken(); } return true; } else { - return parseExpected(24 /* SemicolonToken */); + return parseExpected(25 /* SemicolonToken */); } } // note: this function creates only node @@ -15200,8 +15713,8 @@ var ts; if (!(pos >= 0)) { pos = scanner.getStartPos(); } - return kind >= 142 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : - kind === 70 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : + return kind >= 143 /* FirstNode */ ? new NodeConstructor(kind, pos, pos) : + kind === 71 /* Identifier */ ? new IdentifierConstructor(kind, pos, pos) : new TokenConstructor(kind, pos, pos); } function createNodeArray(elements, pos) { @@ -15252,16 +15765,16 @@ var ts; function createIdentifier(isIdentifier, diagnosticMessage) { identifierCount++; if (isIdentifier) { - var node = createNode(70 /* Identifier */); + var node = createNode(71 /* Identifier */); // Store original token kind if it is not just an Identifier so we can report appropriate error later in type checker - if (token() !== 70 /* Identifier */) { + if (token() !== 71 /* Identifier */) { node.originalKeywordKind = token(); } node.text = internIdentifier(scanner.getTokenValue()); nextToken(); return finishNode(node); } - return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); + return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ false, diagnosticMessage || ts.Diagnostics.Identifier_expected); } function parseIdentifier(diagnosticMessage) { return createIdentifier(isIdentifier(), diagnosticMessage); @@ -15278,7 +15791,7 @@ var ts; if (token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */) { return parseLiteralNode(/*internName*/ true); } - if (allowComputedPropertyNames && token() === 20 /* OpenBracketToken */) { + if (allowComputedPropertyNames && token() === 21 /* OpenBracketToken */) { return parseComputedPropertyName(); } return parseIdentifierName(); @@ -15296,13 +15809,13 @@ var ts; // PropertyName [Yield]: // LiteralPropertyName // ComputedPropertyName[?Yield] - var node = createNode(143 /* ComputedPropertyName */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(144 /* ComputedPropertyName */); + parseExpected(21 /* OpenBracketToken */); // We parse any expression (including a comma expression). But the grammar // says that only an assignment expression is allowed, so the grammar checker // will error if it sees a comma expression. node.expression = allowInAnd(parseExpression); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(node); } function parseContextualModifier(t) { @@ -15316,21 +15829,21 @@ var ts; return canFollowModifier(); } function nextTokenCanFollowModifier() { - if (token() === 75 /* ConstKeyword */) { + if (token() === 76 /* ConstKeyword */) { // 'const' is only a modifier if followed by 'enum'. - return nextToken() === 82 /* EnumKeyword */; + return nextToken() === 83 /* EnumKeyword */; } - if (token() === 83 /* ExportKeyword */) { + if (token() === 84 /* ExportKeyword */) { nextToken(); - if (token() === 78 /* DefaultKeyword */) { + if (token() === 79 /* DefaultKeyword */) { return lookAhead(nextTokenIsClassOrFunctionOrAsync); } - return token() !== 38 /* AsteriskToken */ && token() !== 117 /* AsKeyword */ && token() !== 16 /* OpenBraceToken */ && canFollowModifier(); + return token() !== 39 /* AsteriskToken */ && token() !== 118 /* AsKeyword */ && token() !== 17 /* OpenBraceToken */ && canFollowModifier(); } - if (token() === 78 /* DefaultKeyword */) { + if (token() === 79 /* DefaultKeyword */) { return nextTokenIsClassOrFunctionOrAsync(); } - if (token() === 114 /* StaticKeyword */) { + if (token() === 115 /* StaticKeyword */) { nextToken(); return canFollowModifier(); } @@ -15340,16 +15853,17 @@ var ts; return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier); } function canFollowModifier() { - return token() === 20 /* OpenBracketToken */ - || token() === 16 /* OpenBraceToken */ - || token() === 38 /* AsteriskToken */ - || token() === 23 /* DotDotDotToken */ + return token() === 21 /* OpenBracketToken */ + || token() === 17 /* OpenBraceToken */ + || token() === 39 /* AsteriskToken */ + || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); } function nextTokenIsClassOrFunctionOrAsync() { nextToken(); - return token() === 74 /* ClassKeyword */ || token() === 88 /* FunctionKeyword */ || - (token() === 119 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); + return token() === 75 /* ClassKeyword */ || token() === 89 /* FunctionKeyword */ || + (token() === 117 /* AbstractKeyword */ && lookAhead(nextTokenIsClassKeywordOnSameLine)) || + (token() === 120 /* AsyncKeyword */ && lookAhead(nextTokenIsFunctionKeywordOnSameLine)); } // True if positioned at the start of a list element function isListElement(parsingContext, inErrorRecovery) { @@ -15367,9 +15881,9 @@ var ts; // we're parsing. For example, if we have a semicolon in the middle of a class, then // we really don't want to assume the class is over and we're on a statement in the // outer module. We just want to consume and move on. - return !(token() === 24 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); + return !(token() === 25 /* SemicolonToken */ && inErrorRecovery) && isStartOfStatement(); case 2 /* SwitchClauses */: - return token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; + return token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; case 4 /* TypeMembers */: return lookAhead(isTypeMemberStart); case 5 /* ClassMembers */: @@ -15377,21 +15891,21 @@ var ts; // not in error recovery. If we're in error recovery, we don't want an errant // semicolon to be treated as a class member (since they're almost always used // for statements. - return lookAhead(isClassMemberStart) || (token() === 24 /* SemicolonToken */ && !inErrorRecovery); + return lookAhead(isClassMemberStart) || (token() === 25 /* SemicolonToken */ && !inErrorRecovery); case 6 /* EnumMembers */: // Include open bracket computed properties. This technically also lets in indexers, // which would be a candidate for improved error reporting. - return token() === 20 /* OpenBracketToken */ || isLiteralPropertyName(); + return token() === 21 /* OpenBracketToken */ || isLiteralPropertyName(); case 12 /* ObjectLiteralMembers */: - return token() === 20 /* OpenBracketToken */ || token() === 38 /* AsteriskToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 21 /* OpenBracketToken */ || token() === 39 /* AsteriskToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); case 17 /* RestProperties */: return isLiteralPropertyName(); case 9 /* ObjectBindingElements */: - return token() === 20 /* OpenBracketToken */ || token() === 23 /* DotDotDotToken */ || isLiteralPropertyName(); + return token() === 21 /* OpenBracketToken */ || token() === 24 /* DotDotDotToken */ || isLiteralPropertyName(); case 7 /* HeritageClauseElement */: - // If we see { } then only consume it as an expression if it is followed by , or { + // If we see `{ ... }` then only consume it as an expression if it is followed by `,` or `{` // That way we won't consume the body of a class in its heritage clause. - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return lookAhead(isValidHeritageClauseObjectLiteral); } if (!inErrorRecovery) { @@ -15406,23 +15920,23 @@ var ts; case 8 /* VariableDeclarations */: return isIdentifierOrPattern(); case 10 /* ArrayBindingElements */: - return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern(); + return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern(); case 18 /* TypeParameters */: return isIdentifier(); case 11 /* ArgumentExpressions */: case 15 /* ArrayLiteralMembers */: - return token() === 25 /* CommaToken */ || token() === 23 /* DotDotDotToken */ || isStartOfExpression(); + return token() === 26 /* CommaToken */ || token() === 24 /* DotDotDotToken */ || isStartOfExpression(); case 16 /* Parameters */: return isStartOfParameter(); case 19 /* TypeArguments */: case 20 /* TupleElementTypes */: - return token() === 25 /* CommaToken */ || isStartOfType(); + return token() === 26 /* CommaToken */ || isStartOfType(); case 21 /* HeritageClauses */: return isHeritageClause(); case 22 /* ImportOrExportSpecifiers */: return ts.tokenIsIdentifierOrKeyword(token()); case 13 /* JsxAttributes */: - return ts.tokenIsIdentifierOrKeyword(token()) || token() === 16 /* OpenBraceToken */; + return ts.tokenIsIdentifierOrKeyword(token()) || token() === 17 /* OpenBraceToken */; case 14 /* JsxChildren */: return true; case 23 /* JSDocFunctionParameters */: @@ -15435,8 +15949,8 @@ var ts; ts.Debug.fail("Non-exhaustive case in 'isListElement'."); } function isValidHeritageClauseObjectLiteral() { - ts.Debug.assert(token() === 16 /* OpenBraceToken */); - if (nextToken() === 17 /* CloseBraceToken */) { + ts.Debug.assert(token() === 17 /* OpenBraceToken */); + if (nextToken() === 18 /* CloseBraceToken */) { // if we see "extends {}" then only treat the {} as what we're extending (and not // the class body) if we have: // @@ -15445,7 +15959,7 @@ var ts; // extends {} extends // extends {} implements var next = nextToken(); - return next === 25 /* CommaToken */ || next === 16 /* OpenBraceToken */ || next === 84 /* ExtendsKeyword */ || next === 107 /* ImplementsKeyword */; + return next === 26 /* CommaToken */ || next === 17 /* OpenBraceToken */ || next === 85 /* ExtendsKeyword */ || next === 108 /* ImplementsKeyword */; } return true; } @@ -15458,8 +15972,8 @@ var ts; return ts.tokenIsIdentifierOrKeyword(token()); } function isHeritageClauseExtendsOrImplementsKeyword() { - if (token() === 107 /* ImplementsKeyword */ || - token() === 84 /* ExtendsKeyword */) { + if (token() === 108 /* ImplementsKeyword */ || + token() === 85 /* ExtendsKeyword */) { return lookAhead(nextTokenIsStartOfExpression); } return false; @@ -15483,44 +15997,44 @@ var ts; case 12 /* ObjectLiteralMembers */: case 9 /* ObjectBindingElements */: case 22 /* ImportOrExportSpecifiers */: - return token() === 17 /* CloseBraceToken */; + return token() === 18 /* CloseBraceToken */; case 3 /* SwitchClauseStatements */: - return token() === 17 /* CloseBraceToken */ || token() === 72 /* CaseKeyword */ || token() === 78 /* DefaultKeyword */; + return token() === 18 /* CloseBraceToken */ || token() === 73 /* CaseKeyword */ || token() === 79 /* DefaultKeyword */; case 7 /* HeritageClauseElement */: - return token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; + return token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; case 8 /* VariableDeclarations */: return isVariableDeclaratorListTerminator(); case 18 /* TypeParameters */: // Tokens other than '>' are here for better error recovery - return token() === 28 /* GreaterThanToken */ || token() === 18 /* OpenParenToken */ || token() === 16 /* OpenBraceToken */ || token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; + return token() === 29 /* GreaterThanToken */ || token() === 19 /* OpenParenToken */ || token() === 17 /* OpenBraceToken */ || token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; case 11 /* ArgumentExpressions */: // Tokens other than ')' are here for better error recovery - return token() === 19 /* CloseParenToken */ || token() === 24 /* SemicolonToken */; + return token() === 20 /* CloseParenToken */ || token() === 25 /* SemicolonToken */; case 15 /* ArrayLiteralMembers */: case 20 /* TupleElementTypes */: case 10 /* ArrayBindingElements */: - return token() === 21 /* CloseBracketToken */; + return token() === 22 /* CloseBracketToken */; case 16 /* Parameters */: case 17 /* RestProperties */: // Tokens other than ')' and ']' (the latter for index signatures) are here for better error recovery - return token() === 19 /* CloseParenToken */ || token() === 21 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; + return token() === 20 /* CloseParenToken */ || token() === 22 /* CloseBracketToken */ /*|| token === SyntaxKind.OpenBraceToken*/; case 19 /* TypeArguments */: // All other tokens should cause the type-argument to terminate except comma token - return token() !== 25 /* CommaToken */; + return token() !== 26 /* CommaToken */; case 21 /* HeritageClauses */: - return token() === 16 /* OpenBraceToken */ || token() === 17 /* CloseBraceToken */; + return token() === 17 /* OpenBraceToken */ || token() === 18 /* CloseBraceToken */; case 13 /* JsxAttributes */: - return token() === 28 /* GreaterThanToken */ || token() === 40 /* SlashToken */; + return token() === 29 /* GreaterThanToken */ || token() === 41 /* SlashToken */; case 14 /* JsxChildren */: - return token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsSlash); + return token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsSlash); case 23 /* JSDocFunctionParameters */: - return token() === 19 /* CloseParenToken */ || token() === 55 /* ColonToken */ || token() === 17 /* CloseBraceToken */; + return token() === 20 /* CloseParenToken */ || token() === 56 /* ColonToken */ || token() === 18 /* CloseBraceToken */; case 24 /* JSDocTypeArguments */: - return token() === 28 /* GreaterThanToken */ || token() === 17 /* CloseBraceToken */; + return token() === 29 /* GreaterThanToken */ || token() === 18 /* CloseBraceToken */; case 26 /* JSDocTupleTypes */: - return token() === 21 /* CloseBracketToken */ || token() === 17 /* CloseBraceToken */; + return token() === 22 /* CloseBracketToken */ || token() === 18 /* CloseBraceToken */; case 25 /* JSDocRecordMembers */: - return token() === 17 /* CloseBraceToken */; + return token() === 18 /* CloseBraceToken */; } } function isVariableDeclaratorListTerminator() { @@ -15538,7 +16052,7 @@ var ts; // For better error recovery, if we see an '=>' then we just stop immediately. We've got an // arrow function here and it's going to be very unlikely that we'll resynchronize and get // another variable declaration. - if (token() === 35 /* EqualsGreaterThanToken */) { + if (token() === 36 /* EqualsGreaterThanToken */) { return true; } // Keep trying to parse out variable declarators. @@ -15703,20 +16217,20 @@ var ts; function isReusableClassMember(node) { if (node) { switch (node.kind) { - case 151 /* Constructor */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 148 /* PropertyDeclaration */: - case 205 /* SemicolonClassElement */: + case 152 /* Constructor */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 149 /* PropertyDeclaration */: + case 206 /* SemicolonClassElement */: return true; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: // Method declarations are not necessarily reusable. An object-literal // may have a method calls "constructor(...)" and we must reparse that // into an actual .ConstructorDeclaration. var methodDeclaration = node; - var nameIsConstructor = methodDeclaration.name.kind === 70 /* Identifier */ && - methodDeclaration.name.originalKeywordKind === 122 /* ConstructorKeyword */; + var nameIsConstructor = methodDeclaration.name.kind === 71 /* Identifier */ && + methodDeclaration.name.originalKeywordKind === 123 /* ConstructorKeyword */; return !nameIsConstructor; } } @@ -15725,8 +16239,8 @@ var ts; function isReusableSwitchClause(node) { if (node) { switch (node.kind) { - case 256 /* CaseClause */: - case 257 /* DefaultClause */: + case 257 /* CaseClause */: + case 258 /* DefaultClause */: return true; } } @@ -15735,58 +16249,58 @@ var ts; function isReusableStatement(node) { if (node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: - case 207 /* VariableStatement */: - case 206 /* Block */: - case 210 /* IfStatement */: - case 209 /* ExpressionStatement */: - case 222 /* ThrowStatement */: - case 218 /* ReturnStatement */: - case 220 /* SwitchStatement */: - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 213 /* ForStatement */: - case 212 /* WhileStatement */: - case 219 /* WithStatement */: - case 208 /* EmptyStatement */: - case 223 /* TryStatement */: - case 221 /* LabeledStatement */: - case 211 /* DoStatement */: - case 224 /* DebuggerStatement */: - case 237 /* ImportDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 243 /* ExportDeclaration */: - case 242 /* ExportAssignment */: - case 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 228 /* FunctionDeclaration */: + case 208 /* VariableStatement */: + case 207 /* Block */: + case 211 /* IfStatement */: + case 210 /* ExpressionStatement */: + case 223 /* ThrowStatement */: + case 219 /* ReturnStatement */: + case 221 /* SwitchStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 214 /* ForStatement */: + case 213 /* WhileStatement */: + case 220 /* WithStatement */: + case 209 /* EmptyStatement */: + case 224 /* TryStatement */: + case 222 /* LabeledStatement */: + case 212 /* DoStatement */: + case 225 /* DebuggerStatement */: + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 244 /* ExportDeclaration */: + case 243 /* ExportAssignment */: + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 231 /* TypeAliasDeclaration */: return true; } } return false; } function isReusableEnumMember(node) { - return node.kind === 263 /* EnumMember */; + return node.kind === 264 /* EnumMember */; } function isReusableTypeMember(node) { if (node) { switch (node.kind) { - case 155 /* ConstructSignature */: - case 149 /* MethodSignature */: - case 156 /* IndexSignature */: - case 147 /* PropertySignature */: - case 154 /* CallSignature */: + case 156 /* ConstructSignature */: + case 150 /* MethodSignature */: + case 157 /* IndexSignature */: + case 148 /* PropertySignature */: + case 155 /* CallSignature */: return true; } } return false; } function isReusableVariableDeclaration(node) { - if (node.kind !== 225 /* VariableDeclaration */) { + if (node.kind !== 226 /* VariableDeclaration */) { return false; } // Very subtle incremental parsing bug. Consider the following code: @@ -15807,7 +16321,7 @@ var ts; return variableDeclarator.initializer === undefined; } function isReusableParameter(node) { - if (node.kind !== 145 /* Parameter */) { + if (node.kind !== 146 /* Parameter */) { return false; } // See the comment in isReusableVariableDeclaration for why we do this. @@ -15854,7 +16368,6 @@ var ts; case 25 /* JSDocRecordMembers */: return ts.Diagnostics.Property_assignment_expected; } } - ; // Parses a comma-delimited list of elements function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) { var saveParsingContext = parsingContext; @@ -15865,7 +16378,7 @@ var ts; if (isListElement(kind, /*inErrorRecovery*/ false)) { result.push(parseListElement(kind, parseElement)); commaStart = scanner.getTokenPos(); - if (parseOptional(25 /* CommaToken */)) { + if (parseOptional(26 /* CommaToken */)) { continue; } commaStart = -1; // Back to the state where the last token was not a comma @@ -15874,13 +16387,13 @@ var ts; } // We didn't get a comma, and the list wasn't terminated, explicitly parse // out a comma so we give a good error message. - parseExpected(25 /* CommaToken */); + parseExpected(26 /* CommaToken */); // If the token was a semicolon, and the caller allows that, then skip it and // continue. This ensures we get back on track and don't result in tons of // parse errors. For example, this can happen when people do things like use // a semicolon to delimit object literal members. Note: we'll have already // reported an error when we called parseExpected above. - if (considerSemicolonAsDelimiter && token() === 24 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { + if (considerSemicolonAsDelimiter && token() === 25 /* SemicolonToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); } continue; @@ -15919,8 +16432,8 @@ var ts; // The allowReservedWords parameter controls whether reserved words are permitted after the first dot function parseEntityName(allowReservedWords, diagnosticMessage) { var entity = parseIdentifier(diagnosticMessage); - while (parseOptional(22 /* DotToken */)) { - var node = createNode(142 /* QualifiedName */, entity.pos); // !!! + while (parseOptional(23 /* DotToken */)) { + var node = createNode(143 /* QualifiedName */, entity.pos); // !!! node.left = entity; node.right = parseRightSideOfDot(allowReservedWords); entity = finishNode(node); @@ -15953,33 +16466,33 @@ var ts; // Report that we need an identifier. However, report it right after the dot, // and not on the next token. This is because the next token might actually // be an identifier and the error would be quite confusing. - return createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); + return createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Identifier_expected); } } return allowIdentifierNames ? parseIdentifierName() : parseIdentifier(); } function parseTemplateExpression() { - var template = createNode(195 /* TemplateExpression */); + var template = createNode(196 /* TemplateExpression */); template.head = parseTemplateHead(); - ts.Debug.assert(template.head.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(template.head.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); var templateSpans = createNodeArray(); do { templateSpans.push(parseTemplateSpan()); - } while (ts.lastOrUndefined(templateSpans).literal.kind === 14 /* TemplateMiddle */); + } while (ts.lastOrUndefined(templateSpans).literal.kind === 15 /* TemplateMiddle */); templateSpans.end = getNodeEnd(); template.templateSpans = templateSpans; return finishNode(template); } function parseTemplateSpan() { - var span = createNode(204 /* TemplateSpan */); + var span = createNode(205 /* TemplateSpan */); span.expression = allowInAnd(parseExpression); var literal; - if (token() === 17 /* CloseBraceToken */) { + if (token() === 18 /* CloseBraceToken */) { reScanTemplateToken(); literal = parseTemplateMiddleOrTemplateTail(); } else { - literal = parseExpectedToken(15 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(17 /* CloseBraceToken */)); + literal = parseExpectedToken(16 /* TemplateTail */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(18 /* CloseBraceToken */)); } span.literal = literal; return finishNode(span); @@ -15989,12 +16502,12 @@ var ts; } function parseTemplateHead() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 13 /* TemplateHead */, "Template head has wrong token kind"); + ts.Debug.assert(fragment.kind === 14 /* TemplateHead */, "Template head has wrong token kind"); return fragment; } function parseTemplateMiddleOrTemplateTail() { var fragment = parseLiteralLikeNode(token(), /*internName*/ false); - ts.Debug.assert(fragment.kind === 14 /* TemplateMiddle */ || fragment.kind === 15 /* TemplateTail */, "Template fragment has wrong token kind"); + ts.Debug.assert(fragment.kind === 15 /* TemplateMiddle */ || fragment.kind === 16 /* TemplateTail */, "Template fragment has wrong token kind"); return fragment; } function parseLiteralLikeNode(kind, internName) { @@ -16007,54 +16520,50 @@ var ts; if (scanner.isUnterminated()) { node.isUnterminated = true; } - var tokenPos = scanner.getTokenPos(); - nextToken(); - finishNode(node); // Octal literals are not allowed in strict mode or ES5 // Note that theoretically the following condition would hold true literals like 009, // which is not octal.But because of how the scanner separates the tokens, we would // never get a token like this. Instead, we would get 00 and 9 as two separate tokens. // We also do not need to check for negatives because any prefix operator would be part of a // parent unary expression. - if (node.kind === 8 /* NumericLiteral */ - && sourceText.charCodeAt(tokenPos) === 48 /* _0 */ - && ts.isOctalDigit(sourceText.charCodeAt(tokenPos + 1))) { - node.isOctalLiteral = true; + if (node.kind === 8 /* NumericLiteral */) { + node.numericLiteralFlags = scanner.getNumericLiteralFlags(); } + nextToken(); + finishNode(node); return node; } // TYPES function parseTypeReference() { - var typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); - var node = createNode(158 /* TypeReference */, typeName.pos); - node.typeName = typeName; - if (!scanner.hasPrecedingLineBreak() && token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + var node = createNode(159 /* TypeReference */); + node.typeName = parseEntityName(/*allowReservedWords*/ false, ts.Diagnostics.Type_expected); + if (!scanner.hasPrecedingLineBreak() && token() === 27 /* LessThanToken */) { + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); } return finishNode(node); } function parseThisTypePredicate(lhs) { nextToken(); - var node = createNode(157 /* TypePredicate */, lhs.pos); + var node = createNode(158 /* TypePredicate */, lhs.pos); node.parameterName = lhs; node.type = parseType(); return finishNode(node); } function parseThisTypeNode() { - var node = createNode(168 /* ThisType */); + var node = createNode(169 /* ThisType */); nextToken(); return finishNode(node); } function parseTypeQuery() { - var node = createNode(161 /* TypeQuery */); - parseExpected(102 /* TypeOfKeyword */); + var node = createNode(162 /* TypeQuery */); + parseExpected(103 /* TypeOfKeyword */); node.exprName = parseEntityName(/*allowReservedWords*/ true); return finishNode(node); } function parseTypeParameter() { - var node = createNode(144 /* TypeParameter */); + var node = createNode(145 /* TypeParameter */); node.name = parseIdentifier(); - if (parseOptional(84 /* ExtendsKeyword */)) { + if (parseOptional(85 /* ExtendsKeyword */)) { // It's not uncommon for people to write improper constraints to a generic. If the // user writes a constraint that is an expression and not an actual type, then parse // it out as an expression (so we can recover well), but report that a type is needed @@ -16073,35 +16582,35 @@ var ts; node.expression = parseUnaryExpressionOrHigher(); } } - if (parseOptional(57 /* EqualsToken */)) { + if (parseOptional(58 /* EqualsToken */)) { node.default = parseType(); } return finishNode(node); } function parseTypeParameters() { - if (token() === 26 /* LessThanToken */) { - return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + if (token() === 27 /* LessThanToken */) { + return parseBracketedList(18 /* TypeParameters */, parseTypeParameter, 27 /* LessThanToken */, 29 /* GreaterThanToken */); } } function parseParameterType() { - if (parseOptional(55 /* ColonToken */)) { + if (parseOptional(56 /* ColonToken */)) { return parseType(); } return undefined; } function isStartOfParameter() { - return token() === 23 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 56 /* AtToken */ || token() === 98 /* ThisKeyword */; + return token() === 24 /* DotDotDotToken */ || isIdentifierOrPattern() || ts.isModifierKind(token()) || token() === 57 /* AtToken */ || token() === 99 /* ThisKeyword */; } function parseParameter() { - var node = createNode(145 /* Parameter */); - if (token() === 98 /* ThisKeyword */) { - node.name = createIdentifier(/*isIdentifier*/ true, undefined); + var node = createNode(146 /* Parameter */); + if (token() === 99 /* ThisKeyword */) { + node.name = createIdentifier(/*isIdentifier*/ true); node.type = parseParameterType(); return finishNode(node); } node.decorators = parseDecorators(); node.modifiers = parseModifiers(); - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] node.name = parseIdentifierOrPattern(); @@ -16116,7 +16625,7 @@ var ts; // to avoid this we'll advance cursor to the next token. nextToken(); } - node.questionToken = parseOptionalToken(54 /* QuestionToken */); + node.questionToken = parseOptionalToken(55 /* QuestionToken */); node.type = parseParameterType(); node.initializer = parseBindingElementInitializer(/*inParameter*/ true); // Do not check for initializers in an ambient context for parameters. This is not @@ -16136,7 +16645,7 @@ var ts; return parseInitializer(/*inParameter*/ true); } function fillSignature(returnToken, yieldContext, awaitContext, requireCompleteParameterList, signature) { - var returnTokenRequired = returnToken === 35 /* EqualsGreaterThanToken */; + var returnTokenRequired = returnToken === 36 /* EqualsGreaterThanToken */; signature.typeParameters = parseTypeParameters(); signature.parameters = parseParameterList(yieldContext, awaitContext, requireCompleteParameterList); if (returnTokenRequired) { @@ -16161,7 +16670,7 @@ var ts; // // SingleNameBinding [Yield,Await]: // BindingIdentifier[?Yield,?Await]Initializer [In, ?Yield,?Await] opt - if (parseExpected(18 /* OpenParenToken */)) { + if (parseExpected(19 /* OpenParenToken */)) { var savedYieldContext = inYieldContext(); var savedAwaitContext = inAwaitContext(); setYieldContext(yieldContext); @@ -16169,7 +16678,7 @@ var ts; var result = parseDelimitedList(16 /* Parameters */, parseParameter); setYieldContext(savedYieldContext); setAwaitContext(savedAwaitContext); - if (!parseExpected(19 /* CloseParenToken */) && requireCompleteParameterList) { + if (!parseExpected(20 /* CloseParenToken */) && requireCompleteParameterList) { // Caller insisted that we had to end with a ) We didn't. So just return // undefined here. return undefined; @@ -16184,7 +16693,7 @@ var ts; function parseTypeMemberSemicolon() { // We allow type members to be separated by commas or (possibly ASI) semicolons. // First check if it was a comma. If so, we're done with the member. - if (parseOptional(25 /* CommaToken */)) { + if (parseOptional(26 /* CommaToken */)) { return; } // Didn't have a comma. We must have a (possible ASI) semicolon. @@ -16192,15 +16701,15 @@ var ts; } function parseSignatureMember(kind) { var node = createNode(kind); - if (kind === 155 /* ConstructSignature */) { - parseExpected(93 /* NewKeyword */); + if (kind === 156 /* ConstructSignature */) { + parseExpected(94 /* NewKeyword */); } - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(node)); } function isIndexSignature() { - if (token() !== 20 /* OpenBracketToken */) { + if (token() !== 21 /* OpenBracketToken */) { return false; } return lookAhead(isUnambiguouslyIndexSignature); @@ -16223,7 +16732,7 @@ var ts; // [] // nextToken(); - if (token() === 23 /* DotDotDotToken */ || token() === 21 /* CloseBracketToken */) { + if (token() === 24 /* DotDotDotToken */ || token() === 22 /* CloseBracketToken */) { return true; } if (ts.isModifierKind(token())) { @@ -16242,49 +16751,49 @@ var ts; // A colon signifies a well formed indexer // A comma should be a badly formed indexer because comma expressions are not allowed // in computed properties. - if (token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */) { + if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */) { return true; } // Question mark could be an indexer with an optional property, // or it could be a conditional expression in a computed property. - if (token() !== 54 /* QuestionToken */) { + if (token() !== 55 /* QuestionToken */) { return false; } // If any of the following tokens are after the question mark, it cannot // be a conditional expression, so treat it as an indexer. nextToken(); - return token() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || token() === 21 /* CloseBracketToken */; + return token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || token() === 22 /* CloseBracketToken */; } function parseIndexSignatureDeclaration(fullStart, decorators, modifiers) { - var node = createNode(156 /* IndexSignature */, fullStart); + var node = createNode(157 /* IndexSignature */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); + node.parameters = parseBracketedList(16 /* Parameters */, parseParameter, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); node.type = parseTypeAnnotation(); parseTypeMemberSemicolon(); return finishNode(node); } function parsePropertyOrMethodSignature(fullStart, modifiers) { var name = parsePropertyName(); - var questionToken = parseOptionalToken(54 /* QuestionToken */); - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - var method = createNode(149 /* MethodSignature */, fullStart); + var questionToken = parseOptionalToken(55 /* QuestionToken */); + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + var method = createNode(150 /* MethodSignature */, fullStart); method.modifiers = modifiers; method.name = name; method.questionToken = questionToken; // Method signatures don't exist in expression contexts. So they have neither // [Yield] nor [Await] - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, method); parseTypeMemberSemicolon(); return addJSDocComment(finishNode(method)); } else { - var property = createNode(147 /* PropertySignature */, fullStart); + var property = createNode(148 /* PropertySignature */, fullStart); property.modifiers = modifiers; property.name = name; property.questionToken = questionToken; property.type = parseTypeAnnotation(); - if (token() === 57 /* EqualsToken */) { + if (token() === 58 /* EqualsToken */) { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. @@ -16295,43 +16804,43 @@ var ts; } } function isTypeMemberStart() { - var idToken; // Return true if we have the start of a signature member - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return true; } + var idToken; // Eat up all modifiers, but hold on to the last one in case it is actually an identifier while (ts.isModifierKind(token())) { - idToken = token(); + idToken = true; nextToken(); } // Index signatures and computed property names are type members - if (token() === 20 /* OpenBracketToken */) { + if (token() === 21 /* OpenBracketToken */) { return true; } // Try to get the first property-like token following all modifiers if (isLiteralPropertyName()) { - idToken = token(); + idToken = true; nextToken(); } // If we were able to get any potential identifier, check that it is // the start of a member declaration if (idToken) { - return token() === 18 /* OpenParenToken */ || - token() === 26 /* LessThanToken */ || - token() === 54 /* QuestionToken */ || - token() === 55 /* ColonToken */ || - token() === 25 /* CommaToken */ || + return token() === 19 /* OpenParenToken */ || + token() === 27 /* LessThanToken */ || + token() === 55 /* QuestionToken */ || + token() === 56 /* ColonToken */ || + token() === 26 /* CommaToken */ || canParseSemicolon(); } return false; } function parseTypeMember() { - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { - return parseSignatureMember(154 /* CallSignature */); + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { + return parseSignatureMember(155 /* CallSignature */); } - if (token() === 93 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { - return parseSignatureMember(155 /* ConstructSignature */); + if (token() === 94 /* NewKeyword */ && lookAhead(isStartOfConstructSignature)) { + return parseSignatureMember(156 /* ConstructSignature */); } var fullStart = getNodePos(); var modifiers = parseModifiers(); @@ -16342,18 +16851,18 @@ var ts; } function isStartOfConstructSignature() { nextToken(); - return token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */; + return token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */; } function parseTypeLiteral() { - var node = createNode(162 /* TypeLiteral */); + var node = createNode(163 /* TypeLiteral */); node.members = parseObjectTypeMembers(); return finishNode(node); } function parseObjectTypeMembers() { var members; - if (parseExpected(16 /* OpenBraceToken */)) { + if (parseExpected(17 /* OpenBraceToken */)) { members = parseList(4 /* TypeMembers */, parseTypeMember); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { members = createMissingList(); @@ -16362,57 +16871,57 @@ var ts; } function isStartOfMappedType() { nextToken(); - if (token() === 130 /* ReadonlyKeyword */) { + if (token() === 131 /* ReadonlyKeyword */) { nextToken(); } - return token() === 20 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 91 /* InKeyword */; + return token() === 21 /* OpenBracketToken */ && nextTokenIsIdentifier() && nextToken() === 92 /* InKeyword */; } function parseMappedTypeParameter() { - var node = createNode(144 /* TypeParameter */); + var node = createNode(145 /* TypeParameter */); node.name = parseIdentifier(); - parseExpected(91 /* InKeyword */); + parseExpected(92 /* InKeyword */); node.constraint = parseType(); return finishNode(node); } function parseMappedType() { - var node = createNode(171 /* MappedType */); - parseExpected(16 /* OpenBraceToken */); - node.readonlyToken = parseOptionalToken(130 /* ReadonlyKeyword */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(172 /* MappedType */); + parseExpected(17 /* OpenBraceToken */); + node.readonlyToken = parseOptionalToken(131 /* ReadonlyKeyword */); + parseExpected(21 /* OpenBracketToken */); node.typeParameter = parseMappedTypeParameter(); - parseExpected(21 /* CloseBracketToken */); - node.questionToken = parseOptionalToken(54 /* QuestionToken */); + parseExpected(22 /* CloseBracketToken */); + node.questionToken = parseOptionalToken(55 /* QuestionToken */); node.type = parseTypeAnnotation(); parseSemicolon(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseTupleType() { - var node = createNode(164 /* TupleType */); - node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 20 /* OpenBracketToken */, 21 /* CloseBracketToken */); + var node = createNode(165 /* TupleType */); + node.elementTypes = parseBracketedList(20 /* TupleElementTypes */, parseType, 21 /* OpenBracketToken */, 22 /* CloseBracketToken */); return finishNode(node); } function parseParenthesizedType() { - var node = createNode(167 /* ParenthesizedType */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(168 /* ParenthesizedType */); + parseExpected(19 /* OpenParenToken */); node.type = parseType(); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseFunctionOrConstructorType(kind) { var node = createNode(kind); - if (kind === 160 /* ConstructorType */) { - parseExpected(93 /* NewKeyword */); + if (kind === 161 /* ConstructorType */) { + parseExpected(94 /* NewKeyword */); } - fillSignature(35 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(36 /* EqualsGreaterThanToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); return finishNode(node); } function parseKeywordAndNoDot() { var node = parseTokenNode(); - return token() === 22 /* DotToken */ ? undefined : node; + return token() === 23 /* DotToken */ ? undefined : node; } function parseLiteralTypeNode() { - var node = createNode(172 /* LiteralType */); + var node = createNode(173 /* LiteralType */); node.literal = parseSimpleUnaryExpression(); finishNode(node); return node; @@ -16422,43 +16931,43 @@ var ts; } function parseNonArrayType() { switch (token()) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 138 /* UndefinedKeyword */: - case 129 /* NeverKeyword */: - case 133 /* ObjectKeyword */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 139 /* UndefinedKeyword */: + case 130 /* NeverKeyword */: + case 134 /* ObjectKeyword */: // If these are followed by a dot, then parse these out as a dotted type reference instead. var node = tryParse(parseKeywordAndNoDot); return node || parseTypeReference(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return parseLiteralTypeNode(); - case 37 /* MinusToken */: + case 38 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral) ? parseLiteralTypeNode() : parseTypeReference(); - case 104 /* VoidKeyword */: - case 94 /* NullKeyword */: + case 105 /* VoidKeyword */: + case 95 /* NullKeyword */: return parseTokenNode(); - case 98 /* ThisKeyword */: { + case 99 /* ThisKeyword */: { var thisKeyword = parseThisTypeNode(); - if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { return parseThisTypePredicate(thisKeyword); } else { return thisKeyword; } } - case 102 /* TypeOfKeyword */: + case 103 /* TypeOfKeyword */: return parseTypeQuery(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral(); - case 20 /* OpenBracketToken */: + case 21 /* OpenBracketToken */: return parseTupleType(); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return parseParenthesizedType(); default: return parseTypeReference(); @@ -16466,32 +16975,32 @@ var ts; } function isStartOfType() { switch (token()) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 98 /* ThisKeyword */: - case 102 /* TypeOfKeyword */: - case 129 /* NeverKeyword */: - case 16 /* OpenBraceToken */: - case 20 /* OpenBracketToken */: - case 26 /* LessThanToken */: - case 48 /* BarToken */: - case 47 /* AmpersandToken */: - case 93 /* NewKeyword */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 99 /* ThisKeyword */: + case 103 /* TypeOfKeyword */: + case 130 /* NeverKeyword */: + case 17 /* OpenBraceToken */: + case 21 /* OpenBracketToken */: + case 27 /* LessThanToken */: + case 49 /* BarToken */: + case 48 /* AmpersandToken */: + case 94 /* NewKeyword */: case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: - case 133 /* ObjectKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 134 /* ObjectKeyword */: return true; - case 37 /* MinusToken */: + case 38 /* MinusToken */: return lookAhead(nextTokenIsNumericLiteral); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: // Only consider '(' the start of a type if followed by ')', '...', an identifier, a modifier, // or something that starts a type. We don't want to consider things like '(1)' a type. return lookAhead(isStartOfParenthesizedOrFunctionType); @@ -16501,29 +17010,29 @@ var ts; } function isStartOfParenthesizedOrFunctionType() { nextToken(); - return token() === 19 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); + return token() === 20 /* CloseParenToken */ || isStartOfParameter() || isStartOfType(); } function parseArrayTypeOrHigher() { var type = parseNonArrayType(); - while (!scanner.hasPrecedingLineBreak() && parseOptional(20 /* OpenBracketToken */)) { + while (!scanner.hasPrecedingLineBreak() && parseOptional(21 /* OpenBracketToken */)) { if (isStartOfType()) { - var node = createNode(170 /* IndexedAccessType */, type.pos); + var node = createNode(171 /* IndexedAccessType */, type.pos); node.objectType = type; node.indexType = parseType(); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } else { - var node = createNode(163 /* ArrayType */, type.pos); + var node = createNode(164 /* ArrayType */, type.pos); node.elementType = type; - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); type = finishNode(node); } } return type; } function parseTypeOperator(operator) { - var node = createNode(169 /* TypeOperator */); + var node = createNode(170 /* TypeOperator */); parseExpected(operator); node.operator = operator; node.type = parseTypeOperatorOrHigher(); @@ -16531,8 +17040,8 @@ var ts; } function parseTypeOperatorOrHigher() { switch (token()) { - case 126 /* KeyOfKeyword */: - return parseTypeOperator(126 /* KeyOfKeyword */); + case 127 /* KeyOfKeyword */: + return parseTypeOperator(127 /* KeyOfKeyword */); } return parseArrayTypeOrHigher(); } @@ -16552,27 +17061,27 @@ var ts; return type; } function parseIntersectionTypeOrHigher() { - return parseUnionOrIntersectionType(166 /* IntersectionType */, parseTypeOperatorOrHigher, 47 /* AmpersandToken */); + return parseUnionOrIntersectionType(167 /* IntersectionType */, parseTypeOperatorOrHigher, 48 /* AmpersandToken */); } function parseUnionTypeOrHigher() { - return parseUnionOrIntersectionType(165 /* UnionType */, parseIntersectionTypeOrHigher, 48 /* BarToken */); + return parseUnionOrIntersectionType(166 /* UnionType */, parseIntersectionTypeOrHigher, 49 /* BarToken */); } function isStartOfFunctionType() { - if (token() === 26 /* LessThanToken */) { + if (token() === 27 /* LessThanToken */) { return true; } - return token() === 18 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); + return token() === 19 /* OpenParenToken */ && lookAhead(isUnambiguouslyStartOfFunctionType); } function skipParameterStart() { if (ts.isModifierKind(token())) { // Skip modifiers parseModifiers(); } - if (isIdentifier() || token() === 98 /* ThisKeyword */) { + if (isIdentifier() || token() === 99 /* ThisKeyword */) { nextToken(); return true; } - if (token() === 20 /* OpenBracketToken */ || token() === 16 /* OpenBraceToken */) { + if (token() === 21 /* OpenBracketToken */ || token() === 17 /* OpenBraceToken */) { // Return true if we can parse an array or object binding pattern with no errors var previousErrorCount = parseDiagnostics.length; parseIdentifierOrPattern(); @@ -16582,7 +17091,7 @@ var ts; } function isUnambiguouslyStartOfFunctionType() { nextToken(); - if (token() === 19 /* CloseParenToken */ || token() === 23 /* DotDotDotToken */) { + if (token() === 20 /* CloseParenToken */ || token() === 24 /* DotDotDotToken */) { // ( ) // ( ... return true; @@ -16590,17 +17099,17 @@ var ts; 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() === 55 /* ColonToken */ || token() === 25 /* CommaToken */ || - token() === 54 /* QuestionToken */ || token() === 57 /* EqualsToken */) { + if (token() === 56 /* ColonToken */ || token() === 26 /* CommaToken */ || + token() === 55 /* QuestionToken */ || token() === 58 /* EqualsToken */) { // ( xxx : // ( xxx , // ( xxx ? // ( xxx = return true; } - if (token() === 19 /* CloseParenToken */) { + if (token() === 20 /* CloseParenToken */) { nextToken(); - if (token() === 35 /* EqualsGreaterThanToken */) { + if (token() === 36 /* EqualsGreaterThanToken */) { // ( xxx ) => return true; } @@ -16612,7 +17121,7 @@ var ts; var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix); var type = parseType(); if (typePredicateVariable) { - var node = createNode(157 /* TypePredicate */, typePredicateVariable.pos); + var node = createNode(158 /* TypePredicate */, typePredicateVariable.pos); node.parameterName = typePredicateVariable; node.type = type; return finishNode(node); @@ -16623,7 +17132,7 @@ var ts; } function parseTypePredicatePrefix() { var id = parseIdentifier(); - if (token() === 125 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 126 /* IsKeyword */ && !scanner.hasPrecedingLineBreak()) { nextToken(); return id; } @@ -16635,37 +17144,37 @@ var ts; } function parseTypeWorker() { if (isStartOfFunctionType()) { - return parseFunctionOrConstructorType(159 /* FunctionType */); + return parseFunctionOrConstructorType(160 /* FunctionType */); } - if (token() === 93 /* NewKeyword */) { - return parseFunctionOrConstructorType(160 /* ConstructorType */); + if (token() === 94 /* NewKeyword */) { + return parseFunctionOrConstructorType(161 /* ConstructorType */); } return parseUnionTypeOrHigher(); } function parseTypeAnnotation() { - return parseOptional(55 /* ColonToken */) ? parseType() : undefined; + return parseOptional(56 /* ColonToken */) ? parseType() : undefined; } // EXPRESSIONS function isStartOfLeftHandSideExpression() { switch (token()) { - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: - case 13 /* TemplateHead */: - case 18 /* OpenParenToken */: - case 20 /* OpenBracketToken */: - case 16 /* OpenBraceToken */: - case 88 /* FunctionKeyword */: - case 74 /* ClassKeyword */: - case 93 /* NewKeyword */: - case 40 /* SlashToken */: - case 62 /* SlashEqualsToken */: - case 70 /* Identifier */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* TemplateHead */: + case 19 /* OpenParenToken */: + case 21 /* OpenBracketToken */: + case 17 /* OpenBraceToken */: + case 89 /* FunctionKeyword */: + case 75 /* ClassKeyword */: + case 94 /* NewKeyword */: + case 41 /* SlashToken */: + case 63 /* SlashEqualsToken */: + case 71 /* Identifier */: return true; default: return isIdentifier(); @@ -16676,18 +17185,18 @@ var ts; return true; } switch (token()) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: - case 79 /* DeleteKeyword */: - case 102 /* TypeOfKeyword */: - case 104 /* VoidKeyword */: - case 42 /* PlusPlusToken */: - case 43 /* MinusMinusToken */: - case 26 /* LessThanToken */: - case 120 /* AwaitKeyword */: - case 115 /* YieldKeyword */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: + case 80 /* DeleteKeyword */: + case 103 /* TypeOfKeyword */: + case 105 /* VoidKeyword */: + case 43 /* PlusPlusToken */: + case 44 /* MinusMinusToken */: + case 27 /* LessThanToken */: + case 121 /* AwaitKeyword */: + case 116 /* YieldKeyword */: // Yield/await always starts an expression. Either it is an identifier (in which case // it is definitely an expression). Or it's a keyword (either because we're in // a generator or async function, or in strict mode (or both)) and it started a yield or await expression. @@ -16705,10 +17214,10 @@ var ts; } function isStartOfExpressionStatement() { // As per the grammar, none of '{' or 'function' or 'class' can start an expression statement. - return token() !== 16 /* OpenBraceToken */ && - token() !== 88 /* FunctionKeyword */ && - token() !== 74 /* ClassKeyword */ && - token() !== 56 /* AtToken */ && + return token() !== 17 /* OpenBraceToken */ && + token() !== 89 /* FunctionKeyword */ && + token() !== 75 /* ClassKeyword */ && + token() !== 57 /* AtToken */ && isStartOfExpression(); } function parseExpression() { @@ -16722,7 +17231,7 @@ var ts; } var expr = parseAssignmentExpressionOrHigher(); var operatorToken; - while ((operatorToken = parseOptionalToken(25 /* CommaToken */))) { + while ((operatorToken = parseOptionalToken(26 /* CommaToken */))) { expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher()); } if (saveDecoratorContext) { @@ -16731,7 +17240,7 @@ var ts; return expr; } function parseInitializer(inParameter) { - if (token() !== 57 /* EqualsToken */) { + if (token() !== 58 /* EqualsToken */) { // It's not uncommon during typing for the user to miss writing the '=' token. Check if // there is no newline after the last token and if we're on an expression. If so, parse // this as an equals-value clause with a missing equals. @@ -16740,7 +17249,7 @@ var ts; // it's more likely that a { would be a allowed (as an object literal). While this // is also allowed for parameters, the risk is that we consume the { as an object // literal when it really will be for the block following the parameter. - if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 16 /* OpenBraceToken */) || !isStartOfExpression()) { + if (scanner.hasPrecedingLineBreak() || (inParameter && token() === 17 /* OpenBraceToken */) || !isStartOfExpression()) { // preceding line break, open brace in a parameter (likely a function body) or current token is not an expression - // do not try to parse initializer return undefined; @@ -16748,7 +17257,7 @@ var ts; } // Initializer[In, Yield] : // = AssignmentExpression[?In, ?Yield] - parseExpected(57 /* EqualsToken */); + parseExpected(58 /* EqualsToken */); return parseAssignmentExpressionOrHigher(); } function parseAssignmentExpressionOrHigher() { @@ -16794,7 +17303,7 @@ var ts; // To avoid a look-ahead, we did not handle the case of an arrow function with a single un-parenthesized // parameter ('x => ...') above. We handle it here by checking if the parsed expression was a single // identifier and the current token is an arrow. - if (expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { + if (expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { return parseSimpleArrowFunctionExpression(expr); } // Now see if we might be in cases '2' or '3'. @@ -16810,7 +17319,7 @@ var ts; return parseConditionalExpressionRest(expr); } function isYieldExpression() { - if (token() === 115 /* YieldKeyword */) { + if (token() === 116 /* YieldKeyword */) { // 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()) { @@ -16839,15 +17348,15 @@ var ts; return !scanner.hasPrecedingLineBreak() && isIdentifier(); } function parseYieldExpression() { - var node = createNode(196 /* YieldExpression */); + var node = createNode(197 /* YieldExpression */); // YieldExpression[In] : // yield // yield [no LineTerminator here] [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] // yield [no LineTerminator here] * [Lexical goal InputElementRegExp]AssignmentExpression[?In, Yield] nextToken(); if (!scanner.hasPrecedingLineBreak() && - (token() === 38 /* AsteriskToken */ || isStartOfExpression())) { - node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + (token() === 39 /* AsteriskToken */ || isStartOfExpression())) { + node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -16858,21 +17367,21 @@ var ts; } } function parseSimpleArrowFunctionExpression(identifier, asyncModifier) { - ts.Debug.assert(token() === 35 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); + ts.Debug.assert(token() === 36 /* EqualsGreaterThanToken */, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); var node; if (asyncModifier) { - node = createNode(186 /* ArrowFunction */, asyncModifier.pos); + node = createNode(187 /* ArrowFunction */, asyncModifier.pos); node.modifiers = asyncModifier; } else { - node = createNode(186 /* ArrowFunction */, identifier.pos); + node = createNode(187 /* ArrowFunction */, identifier.pos); } - var parameter = createNode(145 /* Parameter */, identifier.pos); + var parameter = createNode(146 /* Parameter */, identifier.pos); parameter.name = identifier; finishNode(parameter); node.parameters = createNodeArray([parameter], parameter.pos); node.parameters.end = parameter.end; - node.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + node.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); node.body = parseArrowFunctionExpressionBody(/*isAsync*/ !!asyncModifier); return addJSDocComment(finishNode(node)); } @@ -16897,8 +17406,8 @@ var ts; // If we have an arrow, then try to parse the body. Even if not, try to parse if we // have an opening brace, just in case we're in an error state. var lastToken = token(); - arrowFunction.equalsGreaterThanToken = parseExpectedToken(35 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); - arrowFunction.body = (lastToken === 35 /* EqualsGreaterThanToken */ || lastToken === 16 /* OpenBraceToken */) + arrowFunction.equalsGreaterThanToken = parseExpectedToken(36 /* EqualsGreaterThanToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, "=>"); + arrowFunction.body = (lastToken === 36 /* EqualsGreaterThanToken */ || lastToken === 17 /* OpenBraceToken */) ? parseArrowFunctionExpressionBody(isAsync) : parseIdentifier(); return addJSDocComment(finishNode(arrowFunction)); @@ -16908,10 +17417,10 @@ var ts; // Unknown -> There *might* be a parenthesized arrow function here. // Speculatively look ahead to be sure, and rollback if not. function isParenthesizedArrowFunctionExpression() { - if (token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */ || token() === 119 /* AsyncKeyword */) { + if (token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */ || token() === 120 /* AsyncKeyword */) { return lookAhead(isParenthesizedArrowFunctionExpressionWorker); } - if (token() === 35 /* EqualsGreaterThanToken */) { + if (token() === 36 /* EqualsGreaterThanToken */) { // ERROR RECOVERY TWEAK: // If we see a standalone => try to parse it as an arrow function expression as that's // likely what the user intended to write. @@ -16921,28 +17430,28 @@ var ts; return 0 /* False */; } function isParenthesizedArrowFunctionExpressionWorker() { - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { nextToken(); if (scanner.hasPrecedingLineBreak()) { return 0 /* False */; } - if (token() !== 18 /* OpenParenToken */ && token() !== 26 /* LessThanToken */) { + if (token() !== 19 /* OpenParenToken */ && token() !== 27 /* LessThanToken */) { return 0 /* False */; } } var first = token(); var second = nextToken(); - if (first === 18 /* OpenParenToken */) { - if (second === 19 /* CloseParenToken */) { + if (first === 19 /* OpenParenToken */) { + if (second === 20 /* CloseParenToken */) { // Simple cases: "() =>", "(): ", and "() {". // This is an arrow function with no parameters. // The last one is not actually an arrow function, // but this is probably what the user intended. var third = nextToken(); switch (third) { - case 35 /* EqualsGreaterThanToken */: - case 55 /* ColonToken */: - case 16 /* OpenBraceToken */: + case 36 /* EqualsGreaterThanToken */: + case 56 /* ColonToken */: + case 17 /* OpenBraceToken */: return 1 /* True */; default: return 0 /* False */; @@ -16954,12 +17463,12 @@ var ts; // ({ x }) => { } // ([ x ]) // ({ x }) - if (second === 20 /* OpenBracketToken */ || second === 16 /* OpenBraceToken */) { + if (second === 21 /* OpenBracketToken */ || second === 17 /* OpenBraceToken */) { return 2 /* Unknown */; } // Simple case: "(..." // This is an arrow function with a rest parameter. - if (second === 23 /* DotDotDotToken */) { + if (second === 24 /* DotDotDotToken */) { return 1 /* True */; } // If we had "(" followed by something that's not an identifier, @@ -16972,7 +17481,7 @@ var ts; } // If we have something like "(a:", then we must have a // type-annotated parameter in an arrow function expression. - if (nextToken() === 55 /* ColonToken */) { + if (nextToken() === 56 /* ColonToken */) { return 1 /* True */; } // This *could* be a parenthesized arrow function. @@ -16980,7 +17489,7 @@ var ts; return 2 /* Unknown */; } else { - ts.Debug.assert(first === 26 /* LessThanToken */); + ts.Debug.assert(first === 27 /* LessThanToken */); // If we have "<" not followed by an identifier, // then this definitely is not an arrow function. if (!isIdentifier()) { @@ -16990,17 +17499,17 @@ var ts; if (sourceFile.languageVariant === 1 /* JSX */) { var isArrowFunctionInJsx = lookAhead(function () { var third = nextToken(); - if (third === 84 /* ExtendsKeyword */) { + if (third === 85 /* ExtendsKeyword */) { var fourth = nextToken(); switch (fourth) { - case 57 /* EqualsToken */: - case 28 /* GreaterThanToken */: + case 58 /* EqualsToken */: + case 29 /* GreaterThanToken */: return false; default: return true; } } - else if (third === 25 /* CommaToken */) { + else if (third === 26 /* CommaToken */) { return true; } return false; @@ -17019,7 +17528,7 @@ var ts; } function tryParseAsyncSimpleArrowFunctionExpression() { // We do a check here so that we won't be doing unnecessarily call to "lookAhead" - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { var isUnParenthesizedAsyncArrowFunction = lookAhead(isUnParenthesizedAsyncArrowFunctionWorker); if (isUnParenthesizedAsyncArrowFunction === 1 /* True */) { var asyncModifier = parseModifiersForArrowFunction(); @@ -17033,23 +17542,23 @@ var ts; // AsyncArrowFunctionExpression: // 1) async[no LineTerminator here]AsyncArrowBindingIdentifier[?Yield][no LineTerminator here]=>AsyncConciseBody[?In] // 2) CoverCallExpressionAndAsyncArrowHead[?Yield, ?Await][no LineTerminator here]=>AsyncConciseBody[?In] - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { nextToken(); // If the "async" is followed by "=>" token then it is not a begining of an async arrow-function // but instead a simple arrow-function which will be parsed inside "parseAssignmentExpressionOrHigher" - if (scanner.hasPrecedingLineBreak() || token() === 35 /* EqualsGreaterThanToken */) { + if (scanner.hasPrecedingLineBreak() || token() === 36 /* EqualsGreaterThanToken */) { return 0 /* False */; } // Check for un-parenthesized AsyncArrowFunction var expr = parseBinaryExpressionOrHigher(/*precedence*/ 0); - if (!scanner.hasPrecedingLineBreak() && expr.kind === 70 /* Identifier */ && token() === 35 /* EqualsGreaterThanToken */) { + if (!scanner.hasPrecedingLineBreak() && expr.kind === 71 /* Identifier */ && token() === 36 /* EqualsGreaterThanToken */) { return 1 /* True */; } } return 0 /* False */; } function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity) { - var node = createNode(186 /* ArrowFunction */); + var node = createNode(187 /* ArrowFunction */); node.modifiers = parseModifiersForArrowFunction(); var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); // Arrow functions are never generators. @@ -17059,7 +17568,7 @@ var ts; // a => (b => c) // And think that "(b =>" was actually a parenthesized arrow function with a missing // close paren. - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ !allowAmbiguity, node); // If we couldn't get parameters, we definitely could not parse out an arrow function. if (!node.parameters) { return undefined; @@ -17072,19 +17581,19 @@ var ts; // - "a ? (b): c" will have "(b):" parsed as a signature with a return type annotation. // // So we need just a bit of lookahead to ensure that it can only be a signature. - if (!allowAmbiguity && token() !== 35 /* EqualsGreaterThanToken */ && token() !== 16 /* OpenBraceToken */) { + if (!allowAmbiguity && token() !== 36 /* EqualsGreaterThanToken */ && token() !== 17 /* OpenBraceToken */) { // Returning undefined here will cause our caller to rewind to where we started from. return undefined; } return node; } function parseArrowFunctionExpressionBody(isAsync) { - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return parseFunctionBlock(/*allowYield*/ false, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); } - if (token() !== 24 /* SemicolonToken */ && - token() !== 88 /* FunctionKeyword */ && - token() !== 74 /* ClassKeyword */ && + if (token() !== 25 /* SemicolonToken */ && + token() !== 89 /* FunctionKeyword */ && + token() !== 75 /* ClassKeyword */ && isStartOfStatement() && !isStartOfExpressionStatement()) { // Check if we got a plain statement (i.e. no expression-statements, no function/class expressions/declarations) @@ -17109,17 +17618,17 @@ var ts; } function parseConditionalExpressionRest(leftOperand) { // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher. - var questionToken = parseOptionalToken(54 /* QuestionToken */); + var questionToken = parseOptionalToken(55 /* QuestionToken */); if (!questionToken) { return leftOperand; } // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. - var node = createNode(194 /* ConditionalExpression */, leftOperand.pos); + var node = createNode(195 /* ConditionalExpression */, leftOperand.pos); node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher); - node.colonToken = parseExpectedToken(55 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(55 /* ColonToken */)); + node.colonToken = parseExpectedToken(56 /* ColonToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(56 /* ColonToken */)); node.whenFalse = parseAssignmentExpressionOrHigher(); return finishNode(node); } @@ -17128,7 +17637,7 @@ var ts; return parseBinaryExpressionRest(precedence, leftOperand); } function isInOrOfKeyword(t) { - return t === 91 /* InKeyword */ || t === 141 /* OfKeyword */; + return t === 92 /* InKeyword */ || t === 142 /* OfKeyword */; } function parseBinaryExpressionRest(precedence, leftOperand) { while (true) { @@ -17157,16 +17666,16 @@ var ts; // ^^token; leftOperand = b. Return b ** c to the caller as a rightOperand // a ** b - c // ^token; leftOperand = b. Return b to the caller as a rightOperand - var consumeCurrentOperator = token() === 39 /* AsteriskAsteriskToken */ ? + var consumeCurrentOperator = token() === 40 /* AsteriskAsteriskToken */ ? newPrecedence >= precedence : newPrecedence > precedence; if (!consumeCurrentOperator) { break; } - if (token() === 91 /* InKeyword */ && inDisallowInContext()) { + if (token() === 92 /* InKeyword */ && inDisallowInContext()) { break; } - if (token() === 117 /* AsKeyword */) { + if (token() === 118 /* AsKeyword */) { // Make sure we *do* perform ASI for constructs like this: // var x = foo // as (Bar) @@ -17187,48 +17696,48 @@ var ts; return leftOperand; } function isBinaryOperator() { - if (inDisallowInContext() && token() === 91 /* InKeyword */) { + if (inDisallowInContext() && token() === 92 /* InKeyword */) { return false; } return getBinaryOperatorPrecedence() > 0; } function getBinaryOperatorPrecedence() { switch (token()) { - case 53 /* BarBarToken */: + case 54 /* BarBarToken */: return 1; - case 52 /* AmpersandAmpersandToken */: + case 53 /* AmpersandAmpersandToken */: return 2; - case 48 /* BarToken */: + case 49 /* BarToken */: return 3; - case 49 /* CaretToken */: + case 50 /* CaretToken */: return 4; - case 47 /* AmpersandToken */: + case 48 /* AmpersandToken */: return 5; - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: return 6; - case 26 /* LessThanToken */: - case 28 /* GreaterThanToken */: - case 29 /* LessThanEqualsToken */: - case 30 /* GreaterThanEqualsToken */: - case 92 /* InstanceOfKeyword */: - case 91 /* InKeyword */: - case 117 /* AsKeyword */: + case 27 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 30 /* LessThanEqualsToken */: + case 31 /* GreaterThanEqualsToken */: + case 93 /* InstanceOfKeyword */: + case 92 /* InKeyword */: + case 118 /* AsKeyword */: return 7; - case 44 /* LessThanLessThanToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: + case 45 /* LessThanLessThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: return 8; - case 36 /* PlusToken */: - case 37 /* MinusToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: return 9; - case 38 /* AsteriskToken */: - case 40 /* SlashToken */: - case 41 /* PercentToken */: + case 39 /* AsteriskToken */: + case 41 /* SlashToken */: + case 42 /* PercentToken */: return 10; - case 39 /* AsteriskAsteriskToken */: + case 40 /* AsteriskAsteriskToken */: return 11; } // -1 is lower than all other precedences. Returning it will cause binary expression @@ -17236,45 +17745,45 @@ var ts; return -1; } function makeBinaryExpression(left, operatorToken, right) { - var node = createNode(193 /* BinaryExpression */, left.pos); + var node = createNode(194 /* BinaryExpression */, left.pos); node.left = left; node.operatorToken = operatorToken; node.right = right; return finishNode(node); } function makeAsExpression(left, right) { - var node = createNode(201 /* AsExpression */, left.pos); + var node = createNode(202 /* AsExpression */, left.pos); node.expression = left; node.type = right; return finishNode(node); } function parsePrefixUnaryExpression() { - var node = createNode(191 /* PrefixUnaryExpression */); + var node = createNode(192 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseSimpleUnaryExpression(); return finishNode(node); } function parseDeleteExpression() { - var node = createNode(187 /* DeleteExpression */); + var node = createNode(188 /* DeleteExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseTypeOfExpression() { - var node = createNode(188 /* TypeOfExpression */); + var node = createNode(189 /* TypeOfExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseVoidExpression() { - var node = createNode(189 /* VoidExpression */); + var node = createNode(190 /* VoidExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function isAwaitExpression() { - if (token() === 120 /* AwaitKeyword */) { + if (token() === 121 /* AwaitKeyword */) { if (inAwaitContext()) { return true; } @@ -17284,7 +17793,7 @@ var ts; return false; } function parseAwaitExpression() { - var node = createNode(190 /* AwaitExpression */); + var node = createNode(191 /* AwaitExpression */); nextToken(); node.expression = parseSimpleUnaryExpression(); return finishNode(node); @@ -17308,7 +17817,7 @@ var ts; */ if (isUpdateExpression()) { var incrementExpression = parseIncrementExpression(); - return token() === 39 /* AsteriskAsteriskToken */ ? + return token() === 40 /* AsteriskAsteriskToken */ ? parseBinaryExpressionRest(getBinaryOperatorPrecedence(), incrementExpression) : incrementExpression; } @@ -17325,9 +17834,9 @@ var ts; */ var unaryOperator = token(); var simpleUnaryExpression = parseSimpleUnaryExpression(); - if (token() === 39 /* AsteriskAsteriskToken */) { + if (token() === 40 /* AsteriskAsteriskToken */) { var start = ts.skipTrivia(sourceText, simpleUnaryExpression.pos); - if (simpleUnaryExpression.kind === 183 /* TypeAssertionExpression */) { + if (simpleUnaryExpression.kind === 184 /* 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 { @@ -17352,26 +17861,27 @@ var ts; */ function parseSimpleUnaryExpression() { switch (token()) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: return parsePrefixUnaryExpression(); - case 79 /* DeleteKeyword */: + case 80 /* DeleteKeyword */: return parseDeleteExpression(); - case 102 /* TypeOfKeyword */: + case 103 /* TypeOfKeyword */: return parseTypeOfExpression(); - case 104 /* VoidKeyword */: + case 105 /* VoidKeyword */: return parseVoidExpression(); - case 26 /* LessThanToken */: + case 27 /* LessThanToken */: // This is modified UnaryExpression grammar in TypeScript // UnaryExpression (modified): // < type > UnaryExpression return parseTypeAssertion(); - case 120 /* AwaitKeyword */: + case 121 /* AwaitKeyword */: if (isAwaitExpression()) { return parseAwaitExpression(); } + // falls through default: return parseIncrementExpression(); } @@ -17390,22 +17900,22 @@ var ts; // This function is called inside parseUnaryExpression to decide // whether to call parseSimpleUnaryExpression or call parseIncrementExpression directly switch (token()) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: - case 79 /* DeleteKeyword */: - case 102 /* TypeOfKeyword */: - case 104 /* VoidKeyword */: - case 120 /* AwaitKeyword */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: + case 80 /* DeleteKeyword */: + case 103 /* TypeOfKeyword */: + case 105 /* VoidKeyword */: + case 121 /* AwaitKeyword */: return false; - case 26 /* LessThanToken */: + case 27 /* LessThanToken */: // If we are not in JSX context, we are parsing TypeAssertion which is an UnaryExpression if (sourceFile.languageVariant !== 1 /* JSX */) { return false; } // We are in JSX context and the token is part of JSXElement. - // Fall through + // falls through default: return true; } @@ -17422,21 +17932,21 @@ var ts; * In TypeScript (2), (3) are parsed as PostfixUnaryExpression. (4), (5) are parsed as PrefixUnaryExpression */ function parseIncrementExpression() { - if (token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) { - var node = createNode(191 /* PrefixUnaryExpression */); + if (token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) { + var node = createNode(192 /* PrefixUnaryExpression */); node.operator = token(); nextToken(); node.operand = parseLeftHandSideExpressionOrHigher(); return finishNode(node); } - else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 26 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { + else if (sourceFile.languageVariant === 1 /* JSX */ && token() === 27 /* LessThanToken */ && lookAhead(nextTokenIsIdentifierOrKeyword)) { // JSXElement is part of primaryExpression return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); } var expression = parseLeftHandSideExpressionOrHigher(); ts.Debug.assert(ts.isLeftHandSideExpression(expression)); - if ((token() === 42 /* PlusPlusToken */ || token() === 43 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { - var node = createNode(192 /* PostfixUnaryExpression */, expression.pos); + if ((token() === 43 /* PlusPlusToken */ || token() === 44 /* MinusMinusToken */) && !scanner.hasPrecedingLineBreak()) { + var node = createNode(193 /* PostfixUnaryExpression */, expression.pos); node.operand = expression; node.operator = token(); nextToken(); @@ -17475,7 +17985,7 @@ var ts; // the last two CallExpression productions. Or we have a MemberExpression which either // completes the LeftHandSideExpression, or starts the beginning of the first four // CallExpression productions. - var expression = token() === 96 /* SuperKeyword */ + var expression = token() === 97 /* SuperKeyword */ ? parseSuperExpression() : parseMemberExpressionOrHigher(); // Now, we *may* be complete. However, we might have consumed the start of a @@ -17535,14 +18045,14 @@ var ts; } function parseSuperExpression() { var expression = parseTokenNode(); - if (token() === 18 /* OpenParenToken */ || token() === 22 /* DotToken */ || token() === 20 /* OpenBracketToken */) { + if (token() === 19 /* OpenParenToken */ || token() === 23 /* DotToken */ || token() === 21 /* OpenBracketToken */) { return expression; } // If we have seen "super" it must be followed by '(' or '.'. // If it wasn't then just try to parse out a '.' and report an error. - var node = createNode(178 /* PropertyAccessExpression */, expression.pos); + var node = createNode(179 /* PropertyAccessExpression */, expression.pos); node.expression = expression; - parseExpectedToken(22 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); + parseExpectedToken(23 /* DotToken */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access); node.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); return finishNode(node); } @@ -17550,10 +18060,10 @@ var ts; if (lhs.kind !== rhs.kind) { return false; } - if (lhs.kind === 70 /* Identifier */) { + if (lhs.kind === 71 /* Identifier */) { return lhs.text === rhs.text; } - if (lhs.kind === 98 /* ThisKeyword */) { + if (lhs.kind === 99 /* ThisKeyword */) { return true; } // If we are at this statement then we must have PropertyAccessExpression and because tag name in Jsx element can only @@ -17565,8 +18075,8 @@ var ts; function parseJsxElementOrSelfClosingElement(inExpressionContext) { var opening = parseJsxOpeningOrSelfClosingElement(inExpressionContext); var result; - if (opening.kind === 250 /* JsxOpeningElement */) { - var node = createNode(248 /* JsxElement */, opening.pos); + if (opening.kind === 251 /* JsxOpeningElement */) { + var node = createNode(249 /* JsxElement */, opening.pos); node.openingElement = opening; node.children = parseJsxChildren(node.openingElement.tagName); node.closingElement = parseJsxClosingElement(inExpressionContext); @@ -17576,7 +18086,7 @@ var ts; result = finishNode(node); } else { - ts.Debug.assert(opening.kind === 249 /* JsxSelfClosingElement */); + ts.Debug.assert(opening.kind === 250 /* JsxSelfClosingElement */); // Nothing else to do for self-closing elements result = opening; } @@ -17587,15 +18097,15 @@ var ts; // does less damage and we can report a better error. // Since JSX elements are invalid < operands anyway, this lookahead parse will only occur in error scenarios // of one sort or another. - if (inExpressionContext && token() === 26 /* LessThanToken */) { + if (inExpressionContext && token() === 27 /* LessThanToken */) { var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ true); }); if (invalidElement) { parseErrorAtCurrentToken(ts.Diagnostics.JSX_expressions_must_have_one_parent_element); - var badNode = createNode(193 /* BinaryExpression */, result.pos); + var badNode = createNode(194 /* BinaryExpression */, result.pos); badNode.end = invalidElement.end; badNode.left = result; badNode.right = invalidElement; - badNode.operatorToken = createMissingNode(25 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); + badNode.operatorToken = createMissingNode(26 /* CommaToken */, /*reportAtCurrentPosition*/ false, /*diagnosticMessage*/ undefined); badNode.operatorToken.pos = badNode.operatorToken.end = badNode.right.pos; return badNode; } @@ -17604,16 +18114,18 @@ var ts; } function parseJsxText() { var node = createNode(10 /* JsxText */, scanner.getStartPos()); + node.containsOnlyWhiteSpaces = currentToken === 11 /* JsxTextAllWhiteSpaces */; currentToken = scanner.scanJsxToken(); return finishNode(node); } function parseJsxChild() { switch (token()) { case 10 /* JsxText */: + case 11 /* JsxTextAllWhiteSpaces */: return parseJsxText(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseJsxExpression(/*inExpressionContext*/ false); - case 26 /* LessThanToken */: + case 27 /* LessThanToken */: return parseJsxElementOrSelfClosingElement(/*inExpressionContext*/ false); } ts.Debug.fail("Unknown JSX child kind " + token()); @@ -17624,7 +18136,7 @@ var ts; parsingContext |= 1 << 14 /* JsxChildren */; while (true) { currentToken = scanner.reScanJsxToken(); - if (token() === 27 /* LessThanSlashToken */) { + if (token() === 28 /* LessThanSlashToken */) { // Closing tag break; } @@ -17634,40 +18146,46 @@ var ts; parseErrorAtPosition(openingTagName.pos, openingTagName.end - openingTagName.pos, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTagName)); break; } - result.push(parseJsxChild()); + else if (token() === 7 /* ConflictMarkerTrivia */) { + break; + } + var child = parseJsxChild(); + if (child) { + result.push(child); + } } result.end = scanner.getTokenPos(); parsingContext = saveParsingContext; return result; } function parseJsxAttributes() { - var jsxAttributes = createNode(253 /* JsxAttributes */); + var jsxAttributes = createNode(254 /* JsxAttributes */); jsxAttributes.properties = parseList(13 /* JsxAttributes */, parseJsxAttribute); return finishNode(jsxAttributes); } function parseJsxOpeningOrSelfClosingElement(inExpressionContext) { var fullStart = scanner.getStartPos(); - parseExpected(26 /* LessThanToken */); + parseExpected(27 /* LessThanToken */); var tagName = parseJsxElementName(); var attributes = parseJsxAttributes(); var node; - if (token() === 28 /* GreaterThanToken */) { + if (token() === 29 /* GreaterThanToken */) { // Closing tag, so scan the immediately-following text with the JSX scanning instead // of regular scanning to avoid treating illegal characters (e.g. '#') as immediate // scanning errors - node = createNode(250 /* JsxOpeningElement */, fullStart); + node = createNode(251 /* JsxOpeningElement */, fullStart); scanJsxText(); } else { - parseExpected(40 /* SlashToken */); + parseExpected(41 /* SlashToken */); if (inExpressionContext) { - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); } else { - parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } - node = createNode(249 /* JsxSelfClosingElement */, fullStart); + node = createNode(250 /* JsxSelfClosingElement */, fullStart); } node.tagName = tagName; node.attributes = attributes; @@ -17680,10 +18198,10 @@ var ts; // primaryExpression in the form of an identifier and "this" keyword // We can't just simply use parseLeftHandSideExpressionOrHigher because then we will start consider class,function etc as a keyword // We only want to consider "this" as a primaryExpression - var expression = token() === 98 /* ThisKeyword */ ? + var expression = token() === 99 /* ThisKeyword */ ? parseTokenNode() : parseIdentifierName(); - while (parseOptional(22 /* DotToken */)) { - var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); + while (parseOptional(23 /* DotToken */)) { + var propertyAccess = createNode(179 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); @@ -17691,29 +18209,29 @@ var ts; return expression; } function parseJsxExpression(inExpressionContext) { - var node = createNode(255 /* JsxExpression */); - parseExpected(16 /* OpenBraceToken */); - if (token() !== 17 /* CloseBraceToken */) { - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var node = createNode(256 /* JsxExpression */); + parseExpected(17 /* OpenBraceToken */); + if (token() !== 18 /* CloseBraceToken */) { + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); } if (inExpressionContext) { - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { - parseExpected(17 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); + parseExpected(18 /* CloseBraceToken */, /*message*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseJsxAttribute() { - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return parseJsxSpreadAttribute(); } scanJsxIdentifier(); - var node = createNode(252 /* JsxAttribute */); + var node = createNode(253 /* JsxAttribute */); node.name = parseIdentifierName(); - if (token() === 57 /* EqualsToken */) { + if (token() === 58 /* EqualsToken */) { switch (scanJsxAttributeValue()) { case 9 /* StringLiteral */: node.initializer = parseLiteralNode(); @@ -17726,72 +18244,72 @@ var ts; return finishNode(node); } function parseJsxSpreadAttribute() { - var node = createNode(254 /* JsxSpreadAttribute */); - parseExpected(16 /* OpenBraceToken */); - parseExpected(23 /* DotDotDotToken */); + var node = createNode(255 /* JsxSpreadAttribute */); + parseExpected(17 /* OpenBraceToken */); + parseExpected(24 /* DotDotDotToken */); node.expression = parseExpression(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseJsxClosingElement(inExpressionContext) { - var node = createNode(251 /* JsxClosingElement */); - parseExpected(27 /* LessThanSlashToken */); + var node = createNode(252 /* JsxClosingElement */); + parseExpected(28 /* LessThanSlashToken */); node.tagName = parseJsxElementName(); if (inExpressionContext) { - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); } else { - parseExpected(28 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); + parseExpected(29 /* GreaterThanToken */, /*diagnostic*/ undefined, /*shouldAdvance*/ false); scanJsxText(); } return finishNode(node); } function parseTypeAssertion() { - var node = createNode(183 /* TypeAssertionExpression */); - parseExpected(26 /* LessThanToken */); + var node = createNode(184 /* TypeAssertionExpression */); + parseExpected(27 /* LessThanToken */); node.type = parseType(); - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); node.expression = parseSimpleUnaryExpression(); return finishNode(node); } function parseMemberExpressionRest(expression) { while (true) { - var dotToken = parseOptionalToken(22 /* DotToken */); + var dotToken = parseOptionalToken(23 /* DotToken */); if (dotToken) { - var propertyAccess = createNode(178 /* PropertyAccessExpression */, expression.pos); + var propertyAccess = createNode(179 /* PropertyAccessExpression */, expression.pos); propertyAccess.expression = expression; propertyAccess.name = parseRightSideOfDot(/*allowIdentifierNames*/ true); expression = finishNode(propertyAccess); continue; } - if (token() === 50 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { + if (token() === 51 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) { nextToken(); - var nonNullExpression = createNode(202 /* NonNullExpression */, expression.pos); + var nonNullExpression = createNode(203 /* NonNullExpression */, expression.pos); nonNullExpression.expression = expression; expression = finishNode(nonNullExpression); continue; } // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName - if (!inDecoratorContext() && parseOptional(20 /* OpenBracketToken */)) { - var indexedAccess = createNode(179 /* ElementAccessExpression */, expression.pos); + if (!inDecoratorContext() && parseOptional(21 /* OpenBracketToken */)) { + var indexedAccess = createNode(180 /* ElementAccessExpression */, expression.pos); indexedAccess.expression = expression; // It's not uncommon for a user to write: "new Type[]". // Check for that common pattern and report a better error message. - if (token() !== 21 /* CloseBracketToken */) { + if (token() !== 22 /* CloseBracketToken */) { indexedAccess.argumentExpression = allowInAnd(parseExpression); if (indexedAccess.argumentExpression.kind === 9 /* StringLiteral */ || indexedAccess.argumentExpression.kind === 8 /* NumericLiteral */) { var literal = indexedAccess.argumentExpression; literal.text = internIdentifier(literal.text); } } - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); expression = finishNode(indexedAccess); continue; } - if (token() === 12 /* NoSubstitutionTemplateLiteral */ || token() === 13 /* TemplateHead */) { - var tagExpression = createNode(182 /* TaggedTemplateExpression */, expression.pos); + if (token() === 13 /* NoSubstitutionTemplateLiteral */ || token() === 14 /* TemplateHead */) { + var tagExpression = createNode(183 /* TaggedTemplateExpression */, expression.pos); tagExpression.tag = expression; - tagExpression.template = token() === 12 /* NoSubstitutionTemplateLiteral */ + tagExpression.template = token() === 13 /* NoSubstitutionTemplateLiteral */ ? parseLiteralNode() : parseTemplateExpression(); expression = finishNode(tagExpression); @@ -17803,7 +18321,7 @@ var ts; function parseCallExpressionRest(expression) { while (true) { expression = parseMemberExpressionRest(expression); - if (token() === 26 /* LessThanToken */) { + if (token() === 27 /* LessThanToken */) { // See if this is the start of a generic invocation. If so, consume it and // keep checking for postfix expressions. Otherwise, it's just a '<' that's // part of an arithmetic expression. Break out so we consume it higher in the @@ -17812,15 +18330,15 @@ var ts; if (!typeArguments) { return expression; } - var callExpr = createNode(180 /* CallExpression */, expression.pos); + var callExpr = createNode(181 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.typeArguments = typeArguments; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); continue; } - else if (token() === 18 /* OpenParenToken */) { - var callExpr = createNode(180 /* CallExpression */, expression.pos); + else if (token() === 19 /* OpenParenToken */) { + var callExpr = createNode(181 /* CallExpression */, expression.pos); callExpr.expression = expression; callExpr.arguments = parseArgumentList(); expression = finishNode(callExpr); @@ -17830,17 +18348,17 @@ var ts; } } function parseArgumentList() { - parseExpected(18 /* OpenParenToken */); + parseExpected(19 /* OpenParenToken */); var result = parseDelimitedList(11 /* ArgumentExpressions */, parseArgumentExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return result; } function parseTypeArgumentsInExpression() { - if (!parseOptional(26 /* LessThanToken */)) { + if (!parseOptional(27 /* LessThanToken */)) { return undefined; } var typeArguments = parseDelimitedList(19 /* TypeArguments */, parseType); - if (!parseExpected(28 /* GreaterThanToken */)) { + if (!parseExpected(29 /* GreaterThanToken */)) { // If it doesn't have the closing > then it's definitely not an type argument list. return undefined; } @@ -17852,32 +18370,32 @@ var ts; } function canFollowTypeArgumentsInExpression() { switch (token()) { - case 18 /* OpenParenToken */: // foo( + case 19 /* OpenParenToken */: // foo( // this case are the only case where this token can legally follow a type argument // list. So we definitely want to treat this as a type arg list. - case 22 /* DotToken */: // foo. - case 19 /* CloseParenToken */: // foo) - case 21 /* CloseBracketToken */: // foo] - case 55 /* ColonToken */: // foo: - case 24 /* SemicolonToken */: // foo; - case 54 /* QuestionToken */: // foo? - case 31 /* EqualsEqualsToken */: // foo == - case 33 /* EqualsEqualsEqualsToken */: // foo === - case 32 /* ExclamationEqualsToken */: // foo != - case 34 /* ExclamationEqualsEqualsToken */: // foo !== - case 52 /* AmpersandAmpersandToken */: // foo && - case 53 /* BarBarToken */: // foo || - case 49 /* CaretToken */: // foo ^ - case 47 /* AmpersandToken */: // foo & - case 48 /* BarToken */: // foo | - case 17 /* CloseBraceToken */: // foo } + case 23 /* DotToken */: // foo. + case 20 /* CloseParenToken */: // foo) + case 22 /* CloseBracketToken */: // foo] + case 56 /* ColonToken */: // foo: + case 25 /* SemicolonToken */: // foo; + case 55 /* QuestionToken */: // foo? + case 32 /* EqualsEqualsToken */: // foo == + case 34 /* EqualsEqualsEqualsToken */: // foo === + case 33 /* ExclamationEqualsToken */: // foo != + case 35 /* ExclamationEqualsEqualsToken */: // foo !== + case 53 /* AmpersandAmpersandToken */: // foo && + case 54 /* BarBarToken */: // foo || + case 50 /* CaretToken */: // foo ^ + case 48 /* AmpersandToken */: // foo & + case 49 /* BarToken */: // foo | + case 18 /* CloseBraceToken */: // foo } case 1 /* EndOfFileToken */: // these cases can't legally follow a type arg list. However, they're not legal // expressions either. The user is probably in the middle of a generic type. So // treat it as such. return true; - case 25 /* CommaToken */: // foo, - case 16 /* OpenBraceToken */: // foo { + case 26 /* CommaToken */: // foo, + case 17 /* OpenBraceToken */: // foo { // We don't want to treat these as type arguments. Otherwise we'll parse this // as an invocation expression. Instead, we want to parse out the expression // in isolation from the type arguments. @@ -17890,21 +18408,21 @@ var ts; switch (token()) { case 8 /* NumericLiteral */: case 9 /* StringLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return parseLiteralNode(); - case 98 /* ThisKeyword */: - case 96 /* SuperKeyword */: - case 94 /* NullKeyword */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 95 /* NullKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return parseTokenNode(); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return parseParenthesizedExpression(); - case 20 /* OpenBracketToken */: + case 21 /* OpenBracketToken */: return parseArrayLiteralExpression(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseObjectLiteralExpression(); - case 119 /* AsyncKeyword */: + case 120 /* AsyncKeyword */: // Async arrow functions are parsed earlier in parseAssignmentExpressionOrHigher. // If we encounter `async [no LineTerminator here] function` then this is an async // function; otherwise, its an identifier. @@ -17912,68 +18430,68 @@ var ts; break; } return parseFunctionExpression(); - case 74 /* ClassKeyword */: + case 75 /* ClassKeyword */: return parseClassExpression(); - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseFunctionExpression(); - case 93 /* NewKeyword */: + case 94 /* NewKeyword */: return parseNewExpression(); - case 40 /* SlashToken */: - case 62 /* SlashEqualsToken */: - if (reScanSlashToken() === 11 /* RegularExpressionLiteral */) { + case 41 /* SlashToken */: + case 63 /* SlashEqualsToken */: + if (reScanSlashToken() === 12 /* RegularExpressionLiteral */) { return parseLiteralNode(); } break; - case 13 /* TemplateHead */: + case 14 /* TemplateHead */: return parseTemplateExpression(); } return parseIdentifier(ts.Diagnostics.Expression_expected); } function parseParenthesizedExpression() { - var node = createNode(184 /* ParenthesizedExpression */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(185 /* ParenthesizedExpression */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseSpreadElement() { - var node = createNode(197 /* SpreadElement */); - parseExpected(23 /* DotDotDotToken */); + var node = createNode(198 /* SpreadElement */); + parseExpected(24 /* DotDotDotToken */); node.expression = parseAssignmentExpressionOrHigher(); return finishNode(node); } function parseArgumentOrArrayLiteralElement() { - return token() === 23 /* DotDotDotToken */ ? parseSpreadElement() : - token() === 25 /* CommaToken */ ? createNode(199 /* OmittedExpression */) : + return token() === 24 /* DotDotDotToken */ ? parseSpreadElement() : + token() === 26 /* CommaToken */ ? createNode(200 /* OmittedExpression */) : parseAssignmentExpressionOrHigher(); } function parseArgumentExpression() { return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement); } function parseArrayLiteralExpression() { - var node = createNode(176 /* ArrayLiteralExpression */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(177 /* ArrayLiteralExpression */); + parseExpected(21 /* OpenBracketToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.elements = parseDelimitedList(15 /* ArrayLiteralMembers */, parseArgumentOrArrayLiteralElement); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(node); } function tryParseAccessorDeclaration(fullStart, decorators, modifiers) { - if (parseContextualModifier(124 /* GetKeyword */)) { - return parseAccessorDeclaration(152 /* GetAccessor */, fullStart, decorators, modifiers); + if (parseContextualModifier(125 /* GetKeyword */)) { + return parseAccessorDeclaration(153 /* GetAccessor */, fullStart, decorators, modifiers); } - else if (parseContextualModifier(134 /* SetKeyword */)) { - return parseAccessorDeclaration(153 /* SetAccessor */, fullStart, decorators, modifiers); + else if (parseContextualModifier(135 /* SetKeyword */)) { + return parseAccessorDeclaration(154 /* SetAccessor */, fullStart, decorators, modifiers); } return undefined; } function parseObjectLiteralElement() { var fullStart = scanner.getStartPos(); - var dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); if (dotDotDotToken) { - var spreadElement = createNode(262 /* SpreadAssignment */, fullStart); + var spreadElement = createNode(263 /* SpreadAssignment */, fullStart); spreadElement.expression = parseAssignmentExpressionOrHigher(); return addJSDocComment(finishNode(spreadElement)); } @@ -17983,12 +18501,12 @@ var ts; if (accessor) { return accessor; } - var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); // Disallowing of optional property assignments happens in the grammar checker. - var questionToken = parseOptionalToken(54 /* QuestionToken */); - if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var questionToken = parseOptionalToken(55 /* QuestionToken */); + if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, propertyName, questionToken); } // check if it is short-hand property assignment or normal property assignment @@ -17996,12 +18514,12 @@ var ts; // CoverInitializedName[Yield] : // IdentifierReference[?Yield] Initializer[In, ?Yield] // this is necessary because ObjectLiteral productions are also used to cover grammar for ObjectAssignmentPattern - var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 25 /* CommaToken */ || token() === 17 /* CloseBraceToken */ || token() === 57 /* EqualsToken */); + var isShorthandPropertyAssignment = tokenIsIdentifier && (token() === 26 /* CommaToken */ || token() === 18 /* CloseBraceToken */ || token() === 58 /* EqualsToken */); if (isShorthandPropertyAssignment) { - var shorthandDeclaration = createNode(261 /* ShorthandPropertyAssignment */, fullStart); + var shorthandDeclaration = createNode(262 /* ShorthandPropertyAssignment */, fullStart); shorthandDeclaration.name = propertyName; shorthandDeclaration.questionToken = questionToken; - var equalsToken = parseOptionalToken(57 /* EqualsToken */); + var equalsToken = parseOptionalToken(58 /* EqualsToken */); if (equalsToken) { shorthandDeclaration.equalsToken = equalsToken; shorthandDeclaration.objectAssignmentInitializer = allowInAnd(parseAssignmentExpressionOrHigher); @@ -18009,23 +18527,23 @@ var ts; return addJSDocComment(finishNode(shorthandDeclaration)); } else { - var propertyAssignment = createNode(260 /* PropertyAssignment */, fullStart); + var propertyAssignment = createNode(261 /* PropertyAssignment */, fullStart); propertyAssignment.modifiers = modifiers; propertyAssignment.name = propertyName; propertyAssignment.questionToken = questionToken; - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); propertyAssignment.initializer = allowInAnd(parseAssignmentExpressionOrHigher); return addJSDocComment(finishNode(propertyAssignment)); } } function parseObjectLiteralExpression() { - var node = createNode(177 /* ObjectLiteralExpression */); - parseExpected(16 /* OpenBraceToken */); + var node = createNode(178 /* ObjectLiteralExpression */); + parseExpected(17 /* OpenBraceToken */); if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.properties = parseDelimitedList(12 /* ObjectLiteralMembers */, parseObjectLiteralElement, /*considerSemicolonAsDelimiter*/ true); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseFunctionExpression() { @@ -18038,10 +18556,10 @@ var ts; if (saveDecoratorContext) { setDecoratorContext(/*val*/ false); } - var node = createNode(185 /* FunctionExpression */); + var node = createNode(186 /* FunctionExpression */); node.modifiers = parseModifiers(); - parseExpected(88 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + parseExpected(89 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var isGenerator = !!node.asteriskToken; var isAsync = !!(ts.getModifierFlags(node) & 256 /* Async */); node.name = @@ -18049,7 +18567,7 @@ var ts; isGenerator ? doInYieldContext(parseOptionalIdentifier) : isAsync ? doInAwaitContext(parseOptionalIdentifier) : parseOptionalIdentifier(); - fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlock(/*allowYield*/ isGenerator, /*allowAwait*/ isAsync, /*ignoreMissingOpenBrace*/ false); if (saveDecoratorContext) { setDecoratorContext(/*val*/ true); @@ -18061,30 +18579,30 @@ var ts; } function parseNewExpression() { var fullStart = scanner.getStartPos(); - parseExpected(93 /* NewKeyword */); - if (parseOptional(22 /* DotToken */)) { - var node_1 = createNode(203 /* MetaProperty */, fullStart); - node_1.keywordToken = 93 /* NewKeyword */; + parseExpected(94 /* NewKeyword */); + if (parseOptional(23 /* DotToken */)) { + var node_1 = createNode(204 /* MetaProperty */, fullStart); + node_1.keywordToken = 94 /* NewKeyword */; node_1.name = parseIdentifierName(); return finishNode(node_1); } - var node = createNode(181 /* NewExpression */, fullStart); + var node = createNode(182 /* NewExpression */, fullStart); node.expression = parseMemberExpressionOrHigher(); node.typeArguments = tryParse(parseTypeArgumentsInExpression); - if (node.typeArguments || token() === 18 /* OpenParenToken */) { + if (node.typeArguments || token() === 19 /* OpenParenToken */) { node.arguments = parseArgumentList(); } return finishNode(node); } // STATEMENTS function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) { - var node = createNode(206 /* Block */); - if (parseExpected(16 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { + var node = createNode(207 /* Block */); + if (parseExpected(17 /* OpenBraceToken */, diagnosticMessage) || ignoreMissingOpenBrace) { if (scanner.hasPrecedingLineBreak()) { node.multiLine = true; } node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -18111,51 +18629,52 @@ var ts; return block; } function parseEmptyStatement() { - var node = createNode(208 /* EmptyStatement */); - parseExpected(24 /* SemicolonToken */); + var node = createNode(209 /* EmptyStatement */); + parseExpected(25 /* SemicolonToken */); return finishNode(node); } function parseIfStatement() { - var node = createNode(210 /* IfStatement */); - parseExpected(89 /* IfKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(211 /* IfStatement */); + parseExpected(90 /* IfKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); node.thenStatement = parseStatement(); - node.elseStatement = parseOptional(81 /* ElseKeyword */) ? parseStatement() : undefined; + node.elseStatement = parseOptional(82 /* ElseKeyword */) ? parseStatement() : undefined; return finishNode(node); } function parseDoStatement() { - var node = createNode(211 /* DoStatement */); - parseExpected(80 /* DoKeyword */); + var node = createNode(212 /* DoStatement */); + parseExpected(81 /* DoKeyword */); node.statement = parseStatement(); - parseExpected(105 /* WhileKeyword */); - parseExpected(18 /* OpenParenToken */); + parseExpected(106 /* WhileKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); // From: https://mail.mozilla.org/pipermail/es-discuss/2011-August/016188.html // 157 min --- All allen at wirfs-brock.com CONF --- "do{;}while(false)false" prohibited in // spec but allowed in consensus reality. Approved -- this is the de-facto standard whereby // do;while(0)x will have a semicolon inserted before x. - parseOptional(24 /* SemicolonToken */); + parseOptional(25 /* SemicolonToken */); return finishNode(node); } function parseWhileStatement() { - var node = createNode(212 /* WhileStatement */); - parseExpected(105 /* WhileKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(213 /* WhileStatement */); + parseExpected(106 /* WhileKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseForOrForInOrForOfStatement() { var pos = getNodePos(); - parseExpected(87 /* ForKeyword */); - parseExpected(18 /* OpenParenToken */); + parseExpected(88 /* ForKeyword */); + var awaitToken = parseOptionalToken(121 /* AwaitKeyword */); + parseExpected(19 /* OpenParenToken */); var initializer = undefined; - if (token() !== 24 /* SemicolonToken */) { - if (token() === 103 /* VarKeyword */ || token() === 109 /* LetKeyword */ || token() === 75 /* ConstKeyword */) { + if (token() !== 25 /* SemicolonToken */) { + if (token() === 104 /* VarKeyword */ || token() === 110 /* LetKeyword */ || token() === 76 /* ConstKeyword */) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -18163,32 +18682,33 @@ var ts; } } var forOrForInOrForOfStatement; - if (parseOptional(91 /* InKeyword */)) { - var forInStatement = createNode(214 /* ForInStatement */, pos); - forInStatement.initializer = initializer; - forInStatement.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); - forOrForInOrForOfStatement = forInStatement; - } - else if (parseOptional(141 /* OfKeyword */)) { - var forOfStatement = createNode(215 /* ForOfStatement */, pos); + if (awaitToken ? parseExpected(142 /* OfKeyword */) : parseOptional(142 /* OfKeyword */)) { + var forOfStatement = createNode(216 /* ForOfStatement */, pos); + forOfStatement.awaitModifier = awaitToken; forOfStatement.initializer = initializer; forOfStatement.expression = allowInAnd(parseAssignmentExpressionOrHigher); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forOfStatement; } + else if (parseOptional(92 /* InKeyword */)) { + var forInStatement = createNode(215 /* ForInStatement */, pos); + forInStatement.initializer = initializer; + forInStatement.expression = allowInAnd(parseExpression); + parseExpected(20 /* CloseParenToken */); + forOrForInOrForOfStatement = forInStatement; + } else { - var forStatement = createNode(213 /* ForStatement */, pos); + var forStatement = createNode(214 /* ForStatement */, pos); forStatement.initializer = initializer; - parseExpected(24 /* SemicolonToken */); - if (token() !== 24 /* SemicolonToken */ && token() !== 19 /* CloseParenToken */) { + parseExpected(25 /* SemicolonToken */); + if (token() !== 25 /* SemicolonToken */ && token() !== 20 /* CloseParenToken */) { forStatement.condition = allowInAnd(parseExpression); } - parseExpected(24 /* SemicolonToken */); - if (token() !== 19 /* CloseParenToken */) { + parseExpected(25 /* SemicolonToken */); + if (token() !== 20 /* CloseParenToken */) { forStatement.incrementor = allowInAnd(parseExpression); } - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); forOrForInOrForOfStatement = forStatement; } forOrForInOrForOfStatement.statement = parseStatement(); @@ -18196,7 +18716,7 @@ var ts; } function parseBreakOrContinueStatement(kind) { var node = createNode(kind); - parseExpected(kind === 217 /* BreakStatement */ ? 71 /* BreakKeyword */ : 76 /* ContinueKeyword */); + parseExpected(kind === 218 /* BreakStatement */ ? 72 /* BreakKeyword */ : 77 /* ContinueKeyword */); if (!canParseSemicolon()) { node.label = parseIdentifier(); } @@ -18204,8 +18724,8 @@ var ts; return finishNode(node); } function parseReturnStatement() { - var node = createNode(218 /* ReturnStatement */); - parseExpected(95 /* ReturnKeyword */); + var node = createNode(219 /* ReturnStatement */); + parseExpected(96 /* ReturnKeyword */); if (!canParseSemicolon()) { node.expression = allowInAnd(parseExpression); } @@ -18213,42 +18733,42 @@ var ts; return finishNode(node); } function parseWithStatement() { - var node = createNode(219 /* WithStatement */); - parseExpected(106 /* WithKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(220 /* WithStatement */); + parseExpected(107 /* WithKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); node.statement = parseStatement(); return finishNode(node); } function parseCaseClause() { - var node = createNode(256 /* CaseClause */); - parseExpected(72 /* CaseKeyword */); + var node = createNode(257 /* CaseClause */); + parseExpected(73 /* CaseKeyword */); node.expression = allowInAnd(parseExpression); - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseDefaultClause() { - var node = createNode(257 /* DefaultClause */); - parseExpected(78 /* DefaultKeyword */); - parseExpected(55 /* ColonToken */); + var node = createNode(258 /* DefaultClause */); + parseExpected(79 /* DefaultKeyword */); + parseExpected(56 /* ColonToken */); node.statements = parseList(3 /* SwitchClauseStatements */, parseStatement); return finishNode(node); } function parseCaseOrDefaultClause() { - return token() === 72 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); + return token() === 73 /* CaseKeyword */ ? parseCaseClause() : parseDefaultClause(); } function parseSwitchStatement() { - var node = createNode(220 /* SwitchStatement */); - parseExpected(97 /* SwitchKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(221 /* SwitchStatement */); + parseExpected(98 /* SwitchKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = allowInAnd(parseExpression); - parseExpected(19 /* CloseParenToken */); - var caseBlock = createNode(234 /* CaseBlock */, scanner.getStartPos()); - parseExpected(16 /* OpenBraceToken */); + parseExpected(20 /* CloseParenToken */); + var caseBlock = createNode(235 /* CaseBlock */, scanner.getStartPos()); + parseExpected(17 /* OpenBraceToken */); caseBlock.clauses = parseList(2 /* SwitchClauses */, parseCaseOrDefaultClause); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); node.caseBlock = finishNode(caseBlock); return finishNode(node); } @@ -18260,39 +18780,39 @@ var ts; // directly as that might consume an expression on the following line. // We just return 'undefined' in that case. The actual error will be reported in the // grammar walker. - var node = createNode(222 /* ThrowStatement */); - parseExpected(99 /* ThrowKeyword */); + var node = createNode(223 /* ThrowStatement */); + parseExpected(100 /* ThrowKeyword */); node.expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression); parseSemicolon(); return finishNode(node); } // TODO: Review for error recovery function parseTryStatement() { - var node = createNode(223 /* TryStatement */); - parseExpected(101 /* TryKeyword */); + var node = createNode(224 /* TryStatement */); + parseExpected(102 /* TryKeyword */); node.tryBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); - node.catchClause = token() === 73 /* CatchKeyword */ ? parseCatchClause() : undefined; + node.catchClause = token() === 74 /* CatchKeyword */ ? parseCatchClause() : undefined; // If we don't have a catch clause, then we must have a finally clause. Try to parse // one out no matter what. - if (!node.catchClause || token() === 86 /* FinallyKeyword */) { - parseExpected(86 /* FinallyKeyword */); + if (!node.catchClause || token() === 87 /* FinallyKeyword */) { + parseExpected(87 /* FinallyKeyword */); node.finallyBlock = parseBlock(/*ignoreMissingOpenBrace*/ false); } return finishNode(node); } function parseCatchClause() { - var result = createNode(259 /* CatchClause */); - parseExpected(73 /* CatchKeyword */); - if (parseExpected(18 /* OpenParenToken */)) { + var result = createNode(260 /* CatchClause */); + parseExpected(74 /* CatchKeyword */); + if (parseExpected(19 /* OpenParenToken */)) { result.variableDeclaration = parseVariableDeclaration(); } - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); result.block = parseBlock(/*ignoreMissingOpenBrace*/ false); return finishNode(result); } function parseDebuggerStatement() { - var node = createNode(224 /* DebuggerStatement */); - parseExpected(77 /* DebuggerKeyword */); + var node = createNode(225 /* DebuggerStatement */); + parseExpected(78 /* DebuggerKeyword */); parseSemicolon(); return finishNode(node); } @@ -18302,14 +18822,14 @@ var ts; // a colon. var fullStart = scanner.getStartPos(); var expression = allowInAnd(parseExpression); - if (expression.kind === 70 /* Identifier */ && parseOptional(55 /* ColonToken */)) { - var labeledStatement = createNode(221 /* LabeledStatement */, fullStart); + if (expression.kind === 71 /* Identifier */ && parseOptional(56 /* ColonToken */)) { + var labeledStatement = createNode(222 /* LabeledStatement */, fullStart); labeledStatement.label = expression; labeledStatement.statement = parseStatement(); return addJSDocComment(finishNode(labeledStatement)); } else { - var expressionStatement = createNode(209 /* ExpressionStatement */, fullStart); + var expressionStatement = createNode(210 /* ExpressionStatement */, fullStart); expressionStatement.expression = expression; parseSemicolon(); return addJSDocComment(finishNode(expressionStatement)); @@ -18319,9 +18839,13 @@ var ts; nextToken(); return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak(); } + function nextTokenIsClassKeywordOnSameLine() { + nextToken(); + return token() === 75 /* ClassKeyword */ && !scanner.hasPrecedingLineBreak(); + } function nextTokenIsFunctionKeywordOnSameLine() { nextToken(); - return token() === 88 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); + return token() === 89 /* FunctionKeyword */ && !scanner.hasPrecedingLineBreak(); } function nextTokenIsIdentifierOrKeywordOrNumberOnSameLine() { nextToken(); @@ -18330,12 +18854,12 @@ var ts; function isDeclaration() { while (true) { switch (token()) { - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: - case 88 /* FunctionKeyword */: - case 74 /* ClassKeyword */: - case 82 /* EnumKeyword */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: + case 89 /* FunctionKeyword */: + case 75 /* ClassKeyword */: + case 83 /* EnumKeyword */: return true; // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -18358,41 +18882,41 @@ var ts; // I {} // // could be legal, it would add complexity for very little gain. - case 108 /* InterfaceKeyword */: - case 137 /* TypeKeyword */: + case 109 /* InterfaceKeyword */: + case 138 /* TypeKeyword */: return nextTokenIsIdentifierOnSameLine(); - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: return nextTokenIsIdentifierOrStringLiteralOnSameLine(); - case 116 /* AbstractKeyword */: - case 119 /* AsyncKeyword */: - case 123 /* DeclareKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 130 /* ReadonlyKeyword */: + case 117 /* AbstractKeyword */: + case 120 /* AsyncKeyword */: + case 124 /* DeclareKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 114 /* PublicKeyword */: + case 131 /* ReadonlyKeyword */: nextToken(); // ASI takes effect for this modifier. if (scanner.hasPrecedingLineBreak()) { return false; } continue; - case 140 /* GlobalKeyword */: + case 141 /* GlobalKeyword */: nextToken(); - return token() === 16 /* OpenBraceToken */ || token() === 70 /* Identifier */ || token() === 83 /* ExportKeyword */; - case 90 /* ImportKeyword */: + return token() === 17 /* OpenBraceToken */ || token() === 71 /* Identifier */ || token() === 84 /* ExportKeyword */; + case 91 /* ImportKeyword */: nextToken(); - return token() === 9 /* StringLiteral */ || token() === 38 /* AsteriskToken */ || - token() === 16 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); - case 83 /* ExportKeyword */: + return token() === 9 /* StringLiteral */ || token() === 39 /* AsteriskToken */ || + token() === 17 /* OpenBraceToken */ || ts.tokenIsIdentifierOrKeyword(token()); + case 84 /* ExportKeyword */: nextToken(); - if (token() === 57 /* EqualsToken */ || token() === 38 /* AsteriskToken */ || - token() === 16 /* OpenBraceToken */ || token() === 78 /* DefaultKeyword */ || - token() === 117 /* AsKeyword */) { + if (token() === 58 /* EqualsToken */ || token() === 39 /* AsteriskToken */ || + token() === 17 /* OpenBraceToken */ || token() === 79 /* DefaultKeyword */ || + token() === 118 /* AsKeyword */) { return true; } continue; - case 114 /* StaticKeyword */: + case 115 /* StaticKeyword */: nextToken(); continue; default: @@ -18405,49 +18929,49 @@ var ts; } function isStartOfStatement() { switch (token()) { - case 56 /* AtToken */: - case 24 /* SemicolonToken */: - case 16 /* OpenBraceToken */: - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 88 /* FunctionKeyword */: - case 74 /* ClassKeyword */: - case 82 /* EnumKeyword */: - case 89 /* IfKeyword */: - case 80 /* DoKeyword */: - case 105 /* WhileKeyword */: - case 87 /* ForKeyword */: - case 76 /* ContinueKeyword */: - case 71 /* BreakKeyword */: - case 95 /* ReturnKeyword */: - case 106 /* WithKeyword */: - case 97 /* SwitchKeyword */: - case 99 /* ThrowKeyword */: - case 101 /* TryKeyword */: - case 77 /* DebuggerKeyword */: + case 57 /* AtToken */: + case 25 /* SemicolonToken */: + case 17 /* OpenBraceToken */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 89 /* FunctionKeyword */: + case 75 /* ClassKeyword */: + case 83 /* EnumKeyword */: + case 90 /* IfKeyword */: + case 81 /* DoKeyword */: + case 106 /* WhileKeyword */: + case 88 /* ForKeyword */: + case 77 /* ContinueKeyword */: + case 72 /* BreakKeyword */: + case 96 /* ReturnKeyword */: + case 107 /* WithKeyword */: + case 98 /* SwitchKeyword */: + case 100 /* ThrowKeyword */: + case 102 /* TryKeyword */: + case 78 /* DebuggerKeyword */: // 'catch' and 'finally' do not actually indicate that the code is part of a statement, // however, we say they are here so that we may gracefully parse them and error later. - case 73 /* CatchKeyword */: - case 86 /* FinallyKeyword */: + case 74 /* CatchKeyword */: + case 87 /* FinallyKeyword */: return true; - case 75 /* ConstKeyword */: - case 83 /* ExportKeyword */: - case 90 /* ImportKeyword */: + case 76 /* ConstKeyword */: + case 84 /* ExportKeyword */: + case 91 /* ImportKeyword */: return isStartOfDeclaration(); - case 119 /* AsyncKeyword */: - case 123 /* DeclareKeyword */: - case 108 /* InterfaceKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 137 /* TypeKeyword */: - case 140 /* GlobalKeyword */: + case 120 /* AsyncKeyword */: + case 124 /* DeclareKeyword */: + case 109 /* InterfaceKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: + case 138 /* TypeKeyword */: + case 141 /* GlobalKeyword */: // When these don't start a declaration, they're an identifier in an expression statement return true; - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 114 /* StaticKeyword */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 115 /* StaticKeyword */: + case 131 /* 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); @@ -18457,7 +18981,7 @@ var ts; } function nextTokenIsIdentifierOrStartOfDestructuring() { nextToken(); - return isIdentifier() || token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */; + return isIdentifier() || token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */; } function isLetDeclaration() { // In ES6 'let' always starts a lexical declaration if followed by an identifier or { @@ -18466,67 +18990,67 @@ var ts; } function parseStatement() { switch (token()) { - case 24 /* SemicolonToken */: + case 25 /* SemicolonToken */: return parseEmptyStatement(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseBlock(/*ignoreMissingOpenBrace*/ false); - case 103 /* VarKeyword */: + case 104 /* VarKeyword */: return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 109 /* LetKeyword */: + case 110 /* LetKeyword */: if (isLetDeclaration()) { return parseVariableStatement(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); } break; - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseFunctionDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 74 /* ClassKeyword */: + case 75 /* ClassKeyword */: return parseClassDeclaration(scanner.getStartPos(), /*decorators*/ undefined, /*modifiers*/ undefined); - case 89 /* IfKeyword */: + case 90 /* IfKeyword */: return parseIfStatement(); - case 80 /* DoKeyword */: + case 81 /* DoKeyword */: return parseDoStatement(); - case 105 /* WhileKeyword */: + case 106 /* WhileKeyword */: return parseWhileStatement(); - case 87 /* ForKeyword */: + case 88 /* ForKeyword */: return parseForOrForInOrForOfStatement(); - case 76 /* ContinueKeyword */: - return parseBreakOrContinueStatement(216 /* ContinueStatement */); - case 71 /* BreakKeyword */: - return parseBreakOrContinueStatement(217 /* BreakStatement */); - case 95 /* ReturnKeyword */: + case 77 /* ContinueKeyword */: + return parseBreakOrContinueStatement(217 /* ContinueStatement */); + case 72 /* BreakKeyword */: + return parseBreakOrContinueStatement(218 /* BreakStatement */); + case 96 /* ReturnKeyword */: return parseReturnStatement(); - case 106 /* WithKeyword */: + case 107 /* WithKeyword */: return parseWithStatement(); - case 97 /* SwitchKeyword */: + case 98 /* SwitchKeyword */: return parseSwitchStatement(); - case 99 /* ThrowKeyword */: + case 100 /* ThrowKeyword */: return parseThrowStatement(); - case 101 /* TryKeyword */: + case 102 /* TryKeyword */: // Include 'catch' and 'finally' for error recovery. - case 73 /* CatchKeyword */: - case 86 /* FinallyKeyword */: + case 74 /* CatchKeyword */: + case 87 /* FinallyKeyword */: return parseTryStatement(); - case 77 /* DebuggerKeyword */: + case 78 /* DebuggerKeyword */: return parseDebuggerStatement(); - case 56 /* AtToken */: + case 57 /* AtToken */: return parseDeclaration(); - case 119 /* AsyncKeyword */: - case 108 /* InterfaceKeyword */: - case 137 /* TypeKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: - case 123 /* DeclareKeyword */: - case 75 /* ConstKeyword */: - case 82 /* EnumKeyword */: - case 83 /* ExportKeyword */: - case 90 /* ImportKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 113 /* PublicKeyword */: - case 116 /* AbstractKeyword */: - case 114 /* StaticKeyword */: - case 130 /* ReadonlyKeyword */: - case 140 /* GlobalKeyword */: + case 120 /* AsyncKeyword */: + case 109 /* InterfaceKeyword */: + case 138 /* TypeKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: + case 124 /* DeclareKeyword */: + case 76 /* ConstKeyword */: + case 83 /* EnumKeyword */: + case 84 /* ExportKeyword */: + case 91 /* ImportKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 114 /* PublicKeyword */: + case 117 /* AbstractKeyword */: + case 115 /* StaticKeyword */: + case 131 /* ReadonlyKeyword */: + case 141 /* GlobalKeyword */: if (isStartOfDeclaration()) { return parseDeclaration(); } @@ -18539,33 +19063,33 @@ var ts; var decorators = parseDecorators(); var modifiers = parseModifiers(); switch (token()) { - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: return parseVariableStatement(fullStart, decorators, modifiers); - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseFunctionDeclaration(fullStart, decorators, modifiers); - case 74 /* ClassKeyword */: + case 75 /* ClassKeyword */: return parseClassDeclaration(fullStart, decorators, modifiers); - case 108 /* InterfaceKeyword */: + case 109 /* InterfaceKeyword */: return parseInterfaceDeclaration(fullStart, decorators, modifiers); - case 137 /* TypeKeyword */: + case 138 /* TypeKeyword */: return parseTypeAliasDeclaration(fullStart, decorators, modifiers); - case 82 /* EnumKeyword */: + case 83 /* EnumKeyword */: return parseEnumDeclaration(fullStart, decorators, modifiers); - case 140 /* GlobalKeyword */: - case 127 /* ModuleKeyword */: - case 128 /* NamespaceKeyword */: + case 141 /* GlobalKeyword */: + case 128 /* ModuleKeyword */: + case 129 /* NamespaceKeyword */: return parseModuleDeclaration(fullStart, decorators, modifiers); - case 90 /* ImportKeyword */: + case 91 /* ImportKeyword */: return parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers); - case 83 /* ExportKeyword */: + case 84 /* ExportKeyword */: nextToken(); switch (token()) { - case 78 /* DefaultKeyword */: - case 57 /* EqualsToken */: + case 79 /* DefaultKeyword */: + case 58 /* EqualsToken */: return parseExportAssignment(fullStart, decorators, modifiers); - case 117 /* AsKeyword */: + case 118 /* AsKeyword */: return parseNamespaceExportDeclaration(fullStart, decorators, modifiers); default: return parseExportDeclaration(fullStart, decorators, modifiers); @@ -18574,7 +19098,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(246 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var node = createMissingNode(247 /* MissingDeclaration */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); node.pos = fullStart; node.decorators = decorators; node.modifiers = modifiers; @@ -18587,7 +19111,7 @@ var ts; return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 9 /* StringLiteral */); } function parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage) { - if (token() !== 16 /* OpenBraceToken */ && canParseSemicolon()) { + if (token() !== 17 /* OpenBraceToken */ && canParseSemicolon()) { parseSemicolon(); return; } @@ -18595,25 +19119,25 @@ var ts; } // DECLARATIONS function parseArrayBindingElement() { - if (token() === 25 /* CommaToken */) { - return createNode(199 /* OmittedExpression */); + if (token() === 26 /* CommaToken */) { + return createNode(200 /* OmittedExpression */); } - var node = createNode(175 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var node = createNode(176 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); node.name = parseIdentifierOrPattern(); node.initializer = parseBindingElementInitializer(/*inParameter*/ false); return finishNode(node); } function parseObjectBindingElement() { - var node = createNode(175 /* BindingElement */); - node.dotDotDotToken = parseOptionalToken(23 /* DotDotDotToken */); + var node = createNode(176 /* BindingElement */); + node.dotDotDotToken = parseOptionalToken(24 /* DotDotDotToken */); var tokenIsIdentifier = isIdentifier(); var propertyName = parsePropertyName(); - if (tokenIsIdentifier && token() !== 55 /* ColonToken */) { + if (tokenIsIdentifier && token() !== 56 /* ColonToken */) { node.name = propertyName; } else { - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); node.propertyName = propertyName; node.name = parseIdentifierOrPattern(); } @@ -18621,33 +19145,33 @@ var ts; return finishNode(node); } function parseObjectBindingPattern() { - var node = createNode(173 /* ObjectBindingPattern */); - parseExpected(16 /* OpenBraceToken */); + var node = createNode(174 /* ObjectBindingPattern */); + parseExpected(17 /* OpenBraceToken */); node.elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); return finishNode(node); } function parseArrayBindingPattern() { - var node = createNode(174 /* ArrayBindingPattern */); - parseExpected(20 /* OpenBracketToken */); + var node = createNode(175 /* ArrayBindingPattern */); + parseExpected(21 /* OpenBracketToken */); node.elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(node); } function isIdentifierOrPattern() { - return token() === 16 /* OpenBraceToken */ || token() === 20 /* OpenBracketToken */ || isIdentifier(); + return token() === 17 /* OpenBraceToken */ || token() === 21 /* OpenBracketToken */ || isIdentifier(); } function parseIdentifierOrPattern() { - if (token() === 20 /* OpenBracketToken */) { + if (token() === 21 /* OpenBracketToken */) { return parseArrayBindingPattern(); } - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { return parseObjectBindingPattern(); } return parseIdentifier(); } function parseVariableDeclaration() { - var node = createNode(225 /* VariableDeclaration */); + var node = createNode(226 /* VariableDeclaration */); node.name = parseIdentifierOrPattern(); node.type = parseTypeAnnotation(); if (!isInOrOfKeyword(token())) { @@ -18656,14 +19180,14 @@ var ts; return finishNode(node); } function parseVariableDeclarationList(inForStatementInitializer) { - var node = createNode(226 /* VariableDeclarationList */); + var node = createNode(227 /* VariableDeclarationList */); switch (token()) { - case 103 /* VarKeyword */: + case 104 /* VarKeyword */: break; - case 109 /* LetKeyword */: + case 110 /* LetKeyword */: node.flags |= 1 /* Let */; break; - case 75 /* ConstKeyword */: + case 76 /* ConstKeyword */: node.flags |= 2 /* Const */; break; default: @@ -18679,7 +19203,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() === 141 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { + if (token() === 142 /* OfKeyword */ && lookAhead(canFollowContextualOfKeyword)) { node.declarations = createMissingList(); } else { @@ -18691,10 +19215,10 @@ var ts; return finishNode(node); } function canFollowContextualOfKeyword() { - return nextTokenIsIdentifier() && nextToken() === 19 /* CloseParenToken */; + return nextTokenIsIdentifier() && nextToken() === 20 /* CloseParenToken */; } function parseVariableStatement(fullStart, decorators, modifiers) { - var node = createNode(207 /* VariableStatement */, fullStart); + var node = createNode(208 /* VariableStatement */, fullStart); node.decorators = decorators; node.modifiers = modifiers; node.declarationList = parseVariableDeclarationList(/*inForStatementInitializer*/ false); @@ -18702,29 +19226,29 @@ var ts; return addJSDocComment(finishNode(node)); } function parseFunctionDeclaration(fullStart, decorators, modifiers) { - var node = createNode(227 /* FunctionDeclaration */, fullStart); + var node = createNode(228 /* FunctionDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(88 /* FunctionKeyword */); - node.asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + parseExpected(89 /* FunctionKeyword */); + node.asteriskToken = parseOptionalToken(39 /* AsteriskToken */); node.name = ts.hasModifier(node, 512 /* Default */) ? parseOptionalIdentifier() : parseIdentifier(); var isGenerator = !!node.asteriskToken; var isAsync = ts.hasModifier(node, 256 /* Async */); - fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseConstructorDeclaration(pos, decorators, modifiers) { - var node = createNode(151 /* Constructor */, pos); + var node = createNode(152 /* Constructor */, pos); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(122 /* ConstructorKeyword */); - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + parseExpected(123 /* ConstructorKeyword */); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false, ts.Diagnostics.or_expected); return addJSDocComment(finishNode(node)); } function parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, diagnosticMessage) { - var method = createNode(150 /* MethodDeclaration */, fullStart); + var method = createNode(151 /* MethodDeclaration */, fullStart); method.decorators = decorators; method.modifiers = modifiers; method.asteriskToken = asteriskToken; @@ -18732,12 +19256,12 @@ var ts; method.questionToken = questionToken; var isGenerator = !!asteriskToken; var isAsync = ts.hasModifier(method, 256 /* Async */); - fillSignature(55 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); + fillSignature(56 /* ColonToken */, /*yieldContext*/ isGenerator, /*awaitContext*/ isAsync, /*requireCompleteParameterList*/ false, method); method.body = parseFunctionBlockOrSemicolon(isGenerator, isAsync, diagnosticMessage); return addJSDocComment(finishNode(method)); } function parsePropertyDeclaration(fullStart, decorators, modifiers, name, questionToken) { - var property = createNode(148 /* PropertyDeclaration */, fullStart); + var property = createNode(149 /* PropertyDeclaration */, fullStart); property.decorators = decorators; property.modifiers = modifiers; property.name = name; @@ -18759,12 +19283,12 @@ var ts; return addJSDocComment(finishNode(property)); } function parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers) { - var asteriskToken = parseOptionalToken(38 /* AsteriskToken */); + var asteriskToken = parseOptionalToken(39 /* AsteriskToken */); var name = parsePropertyName(); // Note: this is not legal as per the grammar. But we allow it in the parser and // report an error in the grammar checker. - var questionToken = parseOptionalToken(54 /* QuestionToken */); - if (asteriskToken || token() === 18 /* OpenParenToken */ || token() === 26 /* LessThanToken */) { + var questionToken = parseOptionalToken(55 /* QuestionToken */); + if (asteriskToken || token() === 19 /* OpenParenToken */ || token() === 27 /* LessThanToken */) { return parseMethodDeclaration(fullStart, decorators, modifiers, asteriskToken, name, questionToken, ts.Diagnostics.or_expected); } else { @@ -18779,17 +19303,17 @@ var ts; node.decorators = decorators; node.modifiers = modifiers; node.name = parsePropertyName(); - fillSignature(55 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); + fillSignature(56 /* ColonToken */, /*yieldContext*/ false, /*awaitContext*/ false, /*requireCompleteParameterList*/ false, node); node.body = parseFunctionBlockOrSemicolon(/*isGenerator*/ false, /*isAsync*/ false); return addJSDocComment(finishNode(node)); } function isClassMemberModifier(idToken) { switch (idToken) { - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 114 /* StaticKeyword */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 115 /* StaticKeyword */: + case 131 /* ReadonlyKeyword */: return true; default: return false; @@ -18797,7 +19321,7 @@ var ts; } function isClassMemberStart() { var idToken; - if (token() === 56 /* AtToken */) { + if (token() === 57 /* AtToken */) { return true; } // Eat up all modifiers, but hold on to the last one in case it is actually an identifier. @@ -18814,7 +19338,7 @@ var ts; } nextToken(); } - if (token() === 38 /* AsteriskToken */) { + if (token() === 39 /* AsteriskToken */) { return true; } // Try to get the first property-like token following all modifiers. @@ -18824,23 +19348,23 @@ var ts; nextToken(); } // Index signatures and computed properties are class members; we can parse. - if (token() === 20 /* OpenBracketToken */) { + if (token() === 21 /* OpenBracketToken */) { return true; } // If we were able to get any potential identifier... if (idToken !== undefined) { // If we have a non-keyword identifier, or if we have an accessor, then it's safe to parse. - if (!ts.isKeyword(idToken) || idToken === 134 /* SetKeyword */ || idToken === 124 /* GetKeyword */) { + if (!ts.isKeyword(idToken) || idToken === 135 /* SetKeyword */ || idToken === 125 /* GetKeyword */) { return true; } // If it *is* a keyword, but not an accessor, check a little farther along // to see if it should actually be parsed as a class member. switch (token()) { - case 18 /* OpenParenToken */: // Method declaration - case 26 /* LessThanToken */: // Generic Method declaration - case 55 /* ColonToken */: // Type Annotation for declaration - case 57 /* EqualsToken */: // Initializer for declaration - case 54 /* QuestionToken */: + case 19 /* OpenParenToken */: // Method declaration + case 27 /* LessThanToken */: // Generic Method declaration + case 56 /* ColonToken */: // Type Annotation for declaration + case 58 /* EqualsToken */: // Initializer for declaration + case 55 /* QuestionToken */: return true; default: // Covers @@ -18857,10 +19381,10 @@ var ts; var decorators; while (true) { var decoratorStart = getNodePos(); - if (!parseOptional(56 /* AtToken */)) { + if (!parseOptional(57 /* AtToken */)) { break; } - var decorator = createNode(146 /* Decorator */, decoratorStart); + var decorator = createNode(147 /* Decorator */, decoratorStart); decorator.expression = doInDecoratorContext(parseLeftHandSideExpressionOrHigher); finishNode(decorator); if (!decorators) { @@ -18887,7 +19411,7 @@ var ts; while (true) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); - if (token() === 75 /* ConstKeyword */ && permitInvalidConstAsModifier) { + if (token() === 76 /* ConstKeyword */ && permitInvalidConstAsModifier) { // We need to ensure that any subsequent modifiers appear on the same line // so that when 'const' is a standalone declaration, we don't issue an error. if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) { @@ -18914,7 +19438,7 @@ var ts; } function parseModifiersForArrowFunction() { var modifiers; - if (token() === 119 /* AsyncKeyword */) { + if (token() === 120 /* AsyncKeyword */) { var modifierStart = scanner.getStartPos(); var modifierKind = token(); nextToken(); @@ -18925,8 +19449,8 @@ var ts; return modifiers; } function parseClassElement() { - if (token() === 24 /* SemicolonToken */) { - var result = createNode(205 /* SemicolonClassElement */); + if (token() === 25 /* SemicolonToken */) { + var result = createNode(206 /* SemicolonClassElement */); nextToken(); return finishNode(result); } @@ -18937,7 +19461,7 @@ var ts; if (accessor) { return accessor; } - if (token() === 122 /* ConstructorKeyword */) { + if (token() === 123 /* ConstructorKeyword */) { return parseConstructorDeclaration(fullStart, decorators, modifiers); } if (isIndexSignature()) { @@ -18948,13 +19472,13 @@ var ts; if (ts.tokenIsIdentifierOrKeyword(token()) || token() === 9 /* StringLiteral */ || token() === 8 /* NumericLiteral */ || - token() === 38 /* AsteriskToken */ || - token() === 20 /* OpenBracketToken */) { + token() === 39 /* AsteriskToken */ || + token() === 21 /* OpenBracketToken */) { return parsePropertyOrMethodDeclaration(fullStart, decorators, modifiers); } if (decorators || modifiers) { // treat this as a property declaration with a missing name. - var name = createMissingNode(70 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); + var name = createMissingNode(71 /* Identifier */, /*reportAtCurrentPosition*/ true, ts.Diagnostics.Declaration_expected); return parsePropertyDeclaration(fullStart, decorators, modifiers, name, /*questionToken*/ undefined); } // 'isClassMemberStart' should have hinted not to attempt parsing. @@ -18964,24 +19488,24 @@ var ts; return parseClassDeclarationOrExpression( /*fullStart*/ scanner.getStartPos(), /*decorators*/ undefined, - /*modifiers*/ undefined, 198 /* ClassExpression */); + /*modifiers*/ undefined, 199 /* ClassExpression */); } function parseClassDeclaration(fullStart, decorators, modifiers) { - return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 228 /* ClassDeclaration */); + return parseClassDeclarationOrExpression(fullStart, decorators, modifiers, 229 /* ClassDeclaration */); } function parseClassDeclarationOrExpression(fullStart, decorators, modifiers, kind) { var node = createNode(kind, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(74 /* ClassKeyword */); + parseExpected(75 /* ClassKeyword */); node.name = parseNameOfClassDeclarationOrExpression(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); - if (parseExpected(16 /* OpenBraceToken */)) { + if (parseExpected(17 /* OpenBraceToken */)) { // ClassTail[Yield,Await] : (Modified) See 14.5 // ClassHeritage[?Yield,?Await]opt { ClassBody[?Yield,?Await]opt } node.members = parseClassMembers(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -18999,7 +19523,7 @@ var ts; : undefined; } function isImplementsClause() { - return token() === 107 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); + return token() === 108 /* ImplementsKeyword */ && lookAhead(nextTokenIsIdentifierOrKeyword); } function parseHeritageClauses() { // ClassTail[Yield,Await] : (Modified) See 14.5 @@ -19010,9 +19534,10 @@ var ts; return undefined; } function parseHeritageClause() { - if (token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */) { - var node = createNode(258 /* HeritageClause */); - node.token = token(); + var tok = token(); + if (tok === 85 /* ExtendsKeyword */ || tok === 108 /* ImplementsKeyword */) { + var node = createNode(259 /* HeritageClause */); + node.token = tok; nextToken(); node.types = parseDelimitedList(7 /* HeritageClauseElement */, parseExpressionWithTypeArguments); return finishNode(node); @@ -19020,24 +19545,24 @@ var ts; return undefined; } function parseExpressionWithTypeArguments() { - var node = createNode(200 /* ExpressionWithTypeArguments */); + var node = createNode(201 /* ExpressionWithTypeArguments */); node.expression = parseLeftHandSideExpressionOrHigher(); - if (token() === 26 /* LessThanToken */) { - node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 26 /* LessThanToken */, 28 /* GreaterThanToken */); + if (token() === 27 /* LessThanToken */) { + node.typeArguments = parseBracketedList(19 /* TypeArguments */, parseType, 27 /* LessThanToken */, 29 /* GreaterThanToken */); } return finishNode(node); } function isHeritageClause() { - return token() === 84 /* ExtendsKeyword */ || token() === 107 /* ImplementsKeyword */; + return token() === 85 /* ExtendsKeyword */ || token() === 108 /* ImplementsKeyword */; } function parseClassMembers() { return parseList(5 /* ClassMembers */, parseClassElement); } function parseInterfaceDeclaration(fullStart, decorators, modifiers) { - var node = createNode(229 /* InterfaceDeclaration */, fullStart); + var node = createNode(230 /* InterfaceDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(108 /* InterfaceKeyword */); + parseExpected(109 /* InterfaceKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); node.heritageClauses = parseHeritageClauses(); @@ -19045,13 +19570,13 @@ var ts; return addJSDocComment(finishNode(node)); } function parseTypeAliasDeclaration(fullStart, decorators, modifiers) { - var node = createNode(230 /* TypeAliasDeclaration */, fullStart); + var node = createNode(231 /* TypeAliasDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(137 /* TypeKeyword */); + parseExpected(138 /* TypeKeyword */); node.name = parseIdentifier(); node.typeParameters = parseTypeParameters(); - parseExpected(57 /* EqualsToken */); + parseExpected(58 /* EqualsToken */); node.type = parseType(); parseSemicolon(); return addJSDocComment(finishNode(node)); @@ -19061,20 +19586,20 @@ var ts; // ConstantEnumMemberSection, which starts at the beginning of an enum declaration // or any time an integer literal initializer is encountered. function parseEnumMember() { - var node = createNode(263 /* EnumMember */, scanner.getStartPos()); + var node = createNode(264 /* EnumMember */, scanner.getStartPos()); node.name = parsePropertyName(); node.initializer = allowInAnd(parseNonParameterInitializer); return addJSDocComment(finishNode(node)); } function parseEnumDeclaration(fullStart, decorators, modifiers) { - var node = createNode(231 /* EnumDeclaration */, fullStart); + var node = createNode(232 /* EnumDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - parseExpected(82 /* EnumKeyword */); + parseExpected(83 /* EnumKeyword */); node.name = parseIdentifier(); - if (parseExpected(16 /* OpenBraceToken */)) { + if (parseExpected(17 /* OpenBraceToken */)) { node.members = parseDelimitedList(6 /* EnumMembers */, parseEnumMember); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.members = createMissingList(); @@ -19082,10 +19607,10 @@ var ts; return addJSDocComment(finishNode(node)); } function parseModuleBlock() { - var node = createNode(233 /* ModuleBlock */, scanner.getStartPos()); - if (parseExpected(16 /* OpenBraceToken */)) { + var node = createNode(234 /* ModuleBlock */, scanner.getStartPos()); + if (parseExpected(17 /* OpenBraceToken */)) { node.statements = parseList(1 /* BlockStatements */, parseStatement); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); } else { node.statements = createMissingList(); @@ -19093,7 +19618,7 @@ var ts; return finishNode(node); } function parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags) { - var node = createNode(232 /* ModuleDeclaration */, fullStart); + var node = createNode(233 /* 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 & 16 /* Namespace */; @@ -19101,16 +19626,16 @@ var ts; node.modifiers = modifiers; node.flags |= flags; node.name = parseIdentifier(); - node.body = parseOptional(22 /* DotToken */) + node.body = parseOptional(23 /* DotToken */) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*decorators*/ undefined, /*modifiers*/ undefined, 4 /* NestedNamespace */ | namespaceFlag) : parseModuleBlock(); return addJSDocComment(finishNode(node)); } function parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers) { - var node = createNode(232 /* ModuleDeclaration */, fullStart); + var node = createNode(233 /* ModuleDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (token() === 140 /* GlobalKeyword */) { + if (token() === 141 /* GlobalKeyword */) { // parse 'global' as name of global scope augmentation node.name = parseIdentifier(); node.flags |= 512 /* GlobalAugmentation */; @@ -19118,7 +19643,7 @@ var ts; else { node.name = parseLiteralNode(/*internName*/ true); } - if (token() === 16 /* OpenBraceToken */) { + if (token() === 17 /* OpenBraceToken */) { node.body = parseModuleBlock(); } else { @@ -19128,15 +19653,15 @@ var ts; } function parseModuleDeclaration(fullStart, decorators, modifiers) { var flags = 0; - if (token() === 140 /* GlobalKeyword */) { + if (token() === 141 /* GlobalKeyword */) { // global augmentation return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } - else if (parseOptional(128 /* NamespaceKeyword */)) { + else if (parseOptional(129 /* NamespaceKeyword */)) { flags |= 16 /* Namespace */; } else { - parseExpected(127 /* ModuleKeyword */); + parseExpected(128 /* ModuleKeyword */); if (token() === 9 /* StringLiteral */) { return parseAmbientExternalModuleDeclaration(fullStart, decorators, modifiers); } @@ -19144,62 +19669,62 @@ var ts; return parseModuleOrNamespaceDeclaration(fullStart, decorators, modifiers, flags); } function isExternalModuleReference() { - return token() === 131 /* RequireKeyword */ && + return token() === 132 /* RequireKeyword */ && lookAhead(nextTokenIsOpenParen); } function nextTokenIsOpenParen() { - return nextToken() === 18 /* OpenParenToken */; + return nextToken() === 19 /* OpenParenToken */; } function nextTokenIsSlash() { - return nextToken() === 40 /* SlashToken */; + return nextToken() === 41 /* SlashToken */; } function parseNamespaceExportDeclaration(fullStart, decorators, modifiers) { - var exportDeclaration = createNode(235 /* NamespaceExportDeclaration */, fullStart); + var exportDeclaration = createNode(236 /* NamespaceExportDeclaration */, fullStart); exportDeclaration.decorators = decorators; exportDeclaration.modifiers = modifiers; - parseExpected(117 /* AsKeyword */); - parseExpected(128 /* NamespaceKeyword */); + parseExpected(118 /* AsKeyword */); + parseExpected(129 /* NamespaceKeyword */); exportDeclaration.name = parseIdentifier(); parseSemicolon(); return finishNode(exportDeclaration); } function parseImportDeclarationOrImportEqualsDeclaration(fullStart, decorators, modifiers) { - parseExpected(90 /* ImportKeyword */); + parseExpected(91 /* ImportKeyword */); var afterImportPos = scanner.getStartPos(); var identifier; if (isIdentifier()) { identifier = parseIdentifier(); - if (token() !== 25 /* CommaToken */ && token() !== 139 /* FromKeyword */) { - // ImportEquals declaration of type: - // import x = require("mod"); or - // import x = M.x; - var importEqualsDeclaration = createNode(236 /* ImportEqualsDeclaration */, fullStart); - importEqualsDeclaration.decorators = decorators; - importEqualsDeclaration.modifiers = modifiers; - importEqualsDeclaration.name = identifier; - parseExpected(57 /* EqualsToken */); - importEqualsDeclaration.moduleReference = parseModuleReference(); - parseSemicolon(); - return addJSDocComment(finishNode(importEqualsDeclaration)); + if (token() !== 26 /* CommaToken */ && token() !== 140 /* FromKeyword */) { + return parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier); } } // Import statement - var importDeclaration = createNode(237 /* ImportDeclaration */, fullStart); + var importDeclaration = createNode(238 /* ImportDeclaration */, fullStart); importDeclaration.decorators = decorators; importDeclaration.modifiers = modifiers; // ImportDeclaration: // import ImportClause from ModuleSpecifier ; // import ModuleSpecifier; if (identifier || - token() === 38 /* AsteriskToken */ || - token() === 16 /* OpenBraceToken */) { + token() === 39 /* AsteriskToken */ || + token() === 17 /* OpenBraceToken */) { importDeclaration.importClause = parseImportClause(identifier, afterImportPos); - parseExpected(139 /* FromKeyword */); + parseExpected(140 /* FromKeyword */); } importDeclaration.moduleSpecifier = parseModuleSpecifier(); parseSemicolon(); return finishNode(importDeclaration); } + function parseImportEqualsDeclaration(fullStart, decorators, modifiers, identifier) { + var importEqualsDeclaration = createNode(237 /* ImportEqualsDeclaration */, fullStart); + importEqualsDeclaration.decorators = decorators; + importEqualsDeclaration.modifiers = modifiers; + importEqualsDeclaration.name = identifier; + parseExpected(58 /* EqualsToken */); + importEqualsDeclaration.moduleReference = parseModuleReference(); + parseSemicolon(); + return addJSDocComment(finishNode(importEqualsDeclaration)); + } function parseImportClause(identifier, fullStart) { // ImportClause: // ImportedDefaultBinding @@ -19207,7 +19732,7 @@ var ts; // NamedImports // ImportedDefaultBinding, NameSpaceImport // ImportedDefaultBinding, NamedImports - var importClause = createNode(238 /* ImportClause */, fullStart); + var importClause = createNode(239 /* ImportClause */, fullStart); if (identifier) { // ImportedDefaultBinding: // ImportedBinding @@ -19216,8 +19741,8 @@ var ts; // If there was no default import or if there is comma token after default import // parse namespace or named imports if (!importClause.name || - parseOptional(25 /* CommaToken */)) { - importClause.namedBindings = token() === 38 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(240 /* NamedImports */); + parseOptional(26 /* CommaToken */)) { + importClause.namedBindings = token() === 39 /* AsteriskToken */ ? parseNamespaceImport() : parseNamedImportsOrExports(241 /* NamedImports */); } return finishNode(importClause); } @@ -19227,11 +19752,11 @@ var ts; : parseEntityName(/*allowReservedWords*/ false); } function parseExternalModuleReference() { - var node = createNode(247 /* ExternalModuleReference */); - parseExpected(131 /* RequireKeyword */); - parseExpected(18 /* OpenParenToken */); + var node = createNode(248 /* ExternalModuleReference */); + parseExpected(132 /* RequireKeyword */); + parseExpected(19 /* OpenParenToken */); node.expression = parseModuleSpecifier(); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(node); } function parseModuleSpecifier() { @@ -19250,9 +19775,9 @@ var ts; function parseNamespaceImport() { // NameSpaceImport: // * as ImportedBinding - var namespaceImport = createNode(239 /* NamespaceImport */); - parseExpected(38 /* AsteriskToken */); - parseExpected(117 /* AsKeyword */); + var namespaceImport = createNode(240 /* NamespaceImport */); + parseExpected(39 /* AsteriskToken */); + parseExpected(118 /* AsKeyword */); namespaceImport.name = parseIdentifier(); return finishNode(namespaceImport); } @@ -19265,14 +19790,14 @@ var ts; // ImportsList: // ImportSpecifier // ImportsList, ImportSpecifier - node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 240 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 16 /* OpenBraceToken */, 17 /* CloseBraceToken */); + node.elements = parseBracketedList(22 /* ImportOrExportSpecifiers */, kind === 241 /* NamedImports */ ? parseImportSpecifier : parseExportSpecifier, 17 /* OpenBraceToken */, 18 /* CloseBraceToken */); return finishNode(node); } function parseExportSpecifier() { - return parseImportOrExportSpecifier(245 /* ExportSpecifier */); + return parseImportOrExportSpecifier(246 /* ExportSpecifier */); } function parseImportSpecifier() { - return parseImportOrExportSpecifier(241 /* ImportSpecifier */); + return parseImportOrExportSpecifier(242 /* ImportSpecifier */); } function parseImportOrExportSpecifier(kind) { var node = createNode(kind); @@ -19286,9 +19811,9 @@ var ts; var checkIdentifierStart = scanner.getTokenPos(); var checkIdentifierEnd = scanner.getTextPos(); var identifierName = parseIdentifierName(); - if (token() === 117 /* AsKeyword */) { + if (token() === 118 /* AsKeyword */) { node.propertyName = identifierName; - parseExpected(117 /* AsKeyword */); + parseExpected(118 /* AsKeyword */); checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier(); checkIdentifierStart = scanner.getTokenPos(); checkIdentifierEnd = scanner.getTextPos(); @@ -19297,27 +19822,27 @@ var ts; else { node.name = identifierName; } - if (kind === 241 /* ImportSpecifier */ && checkIdentifierIsKeyword) { + if (kind === 242 /* 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(243 /* ExportDeclaration */, fullStart); + var node = createNode(244 /* ExportDeclaration */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(38 /* AsteriskToken */)) { - parseExpected(139 /* FromKeyword */); + if (parseOptional(39 /* AsteriskToken */)) { + parseExpected(140 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } else { - node.exportClause = parseNamedImportsOrExports(244 /* NamedExports */); + node.exportClause = parseNamedImportsOrExports(245 /* 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() === 139 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { - parseExpected(139 /* FromKeyword */); + if (token() === 140 /* FromKeyword */ || (token() === 9 /* StringLiteral */ && !scanner.hasPrecedingLineBreak())) { + parseExpected(140 /* FromKeyword */); node.moduleSpecifier = parseModuleSpecifier(); } } @@ -19325,14 +19850,14 @@ var ts; return finishNode(node); } function parseExportAssignment(fullStart, decorators, modifiers) { - var node = createNode(242 /* ExportAssignment */, fullStart); + var node = createNode(243 /* ExportAssignment */, fullStart); node.decorators = decorators; node.modifiers = modifiers; - if (parseOptional(57 /* EqualsToken */)) { + if (parseOptional(58 /* EqualsToken */)) { node.isExportEquals = true; } else { - parseExpected(78 /* DefaultKeyword */); + parseExpected(79 /* DefaultKeyword */); } node.expression = parseAssignmentExpressionOrHigher(); parseSemicolon(); @@ -19344,6 +19869,7 @@ var ts; var typeReferenceDirectives = []; var amdDependencies = []; var amdModuleName; + var checkJsDirective = undefined; // Keep scanning all the leading trivia in the file until we get to something that // isn't trivia. Any single line comment will be analyzed to see if it is a // reference comment. @@ -19357,7 +19883,11 @@ var ts; break; } } - var range = { pos: triviaScanner.getTokenPos(), end: triviaScanner.getTextPos(), kind: triviaScanner.getToken() }; + var range = { + kind: triviaScanner.getToken(), + pos: triviaScanner.getTokenPos(), + end: triviaScanner.getTextPos(), + }; var comment = sourceText.substring(range.pos, range.end); var referencePathMatchResult = ts.getFileReferenceFromReferencePath(comment, range); if (referencePathMatchResult) { @@ -19397,20 +19927,30 @@ var ts; amdDependencies.push(amdDependency); } } + var checkJsDirectiveRegEx = /^\/\/\/?\s*(@ts-check|@ts-nocheck)\s*$/gim; + var checkJsDirectiveMatchResult = checkJsDirectiveRegEx.exec(comment); + if (checkJsDirectiveMatchResult) { + checkJsDirective = { + enabled: ts.compareStrings(checkJsDirectiveMatchResult[1], "@ts-check", /*ignoreCase*/ true) === 0 /* EqualTo */, + end: range.end, + pos: range.pos + }; + } } } sourceFile.referencedFiles = referencedFiles; sourceFile.typeReferenceDirectives = typeReferenceDirectives; sourceFile.amdDependencies = amdDependencies; sourceFile.moduleName = amdModuleName; + sourceFile.checkJsDirective = checkJsDirective; } function setExternalModuleIndicator(sourceFile) { sourceFile.externalModuleIndicator = ts.forEach(sourceFile.statements, function (node) { return ts.hasModifier(node, 1 /* Export */) - || node.kind === 236 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 247 /* ExternalModuleReference */ - || node.kind === 237 /* ImportDeclaration */ - || node.kind === 242 /* ExportAssignment */ - || node.kind === 243 /* ExportDeclaration */ + || node.kind === 237 /* ImportEqualsDeclaration */ && node.moduleReference.kind === 248 /* ExternalModuleReference */ + || node.kind === 238 /* ImportDeclaration */ + || node.kind === 243 /* ExportAssignment */ + || node.kind === 244 /* ExportDeclaration */ ? node : undefined; }); @@ -19456,16 +19996,16 @@ var ts; (function (JSDocParser) { function isJSDocType() { switch (token()) { - case 38 /* AsteriskToken */: - case 54 /* QuestionToken */: - case 18 /* OpenParenToken */: - case 20 /* OpenBracketToken */: - case 50 /* ExclamationToken */: - case 16 /* OpenBraceToken */: - case 88 /* FunctionKeyword */: - case 23 /* DotDotDotToken */: - case 93 /* NewKeyword */: - case 98 /* ThisKeyword */: + case 39 /* AsteriskToken */: + case 55 /* QuestionToken */: + case 19 /* OpenParenToken */: + case 21 /* OpenBracketToken */: + case 51 /* ExclamationToken */: + case 17 /* OpenBraceToken */: + case 89 /* FunctionKeyword */: + case 24 /* DotDotDotToken */: + case 94 /* NewKeyword */: + case 99 /* ThisKeyword */: return true; } return ts.tokenIsIdentifierOrKeyword(token()); @@ -19485,23 +20025,23 @@ var ts; // Parses out a JSDoc type expression. /* @internal */ function parseJSDocTypeExpression() { - var result = createNode(266 /* JSDocTypeExpression */, scanner.getTokenPos()); - parseExpected(16 /* OpenBraceToken */); + var result = createNode(267 /* JSDocTypeExpression */, scanner.getTokenPos()); + parseExpected(17 /* OpenBraceToken */); result.type = parseJSDocTopLevelType(); - parseExpected(17 /* CloseBraceToken */); + parseExpected(18 /* CloseBraceToken */); fixupParentReferences(result); return finishNode(result); } JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression; function parseJSDocTopLevelType() { var type = parseJSDocType(); - if (token() === 48 /* BarToken */) { - var unionType = createNode(270 /* JSDocUnionType */, type.pos); + if (token() === 49 /* BarToken */) { + var unionType = createNode(271 /* JSDocUnionType */, type.pos); unionType.types = parseJSDocTypeList(type); type = finishNode(unionType); } - if (token() === 57 /* EqualsToken */) { - var optionalType = createNode(277 /* JSDocOptionalType */, type.pos); + if (token() === 58 /* EqualsToken */) { + var optionalType = createNode(278 /* JSDocOptionalType */, type.pos); nextToken(); optionalType.type = type; type = finishNode(optionalType); @@ -19511,21 +20051,21 @@ var ts; function parseJSDocType() { var type = parseBasicTypeExpression(); while (true) { - if (token() === 20 /* OpenBracketToken */) { - var arrayType = createNode(269 /* JSDocArrayType */, type.pos); + if (token() === 21 /* OpenBracketToken */) { + var arrayType = createNode(270 /* JSDocArrayType */, type.pos); arrayType.elementType = type; nextToken(); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); type = finishNode(arrayType); } - else if (token() === 54 /* QuestionToken */) { - var nullableType = createNode(272 /* JSDocNullableType */, type.pos); + else if (token() === 55 /* QuestionToken */) { + var nullableType = createNode(273 /* JSDocNullableType */, type.pos); nullableType.type = type; nextToken(); type = finishNode(nullableType); } - else if (token() === 50 /* ExclamationToken */) { - var nonNullableType = createNode(273 /* JSDocNonNullableType */, type.pos); + else if (token() === 51 /* ExclamationToken */) { + var nonNullableType = createNode(274 /* JSDocNonNullableType */, type.pos); nonNullableType.type = type; nextToken(); type = finishNode(nonNullableType); @@ -19538,96 +20078,96 @@ var ts; } function parseBasicTypeExpression() { switch (token()) { - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: return parseJSDocAllType(); - case 54 /* QuestionToken */: + case 55 /* QuestionToken */: return parseJSDocUnknownOrNullableType(); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return parseJSDocUnionType(); - case 20 /* OpenBracketToken */: + case 21 /* OpenBracketToken */: return parseJSDocTupleType(); - case 50 /* ExclamationToken */: + case 51 /* ExclamationToken */: return parseJSDocNonNullableType(); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return parseJSDocRecordType(); - case 88 /* FunctionKeyword */: + case 89 /* FunctionKeyword */: return parseJSDocFunctionType(); - case 23 /* DotDotDotToken */: + case 24 /* DotDotDotToken */: return parseJSDocVariadicType(); - case 93 /* NewKeyword */: + case 94 /* NewKeyword */: return parseJSDocConstructorType(); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return parseJSDocThisType(); - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 94 /* NullKeyword */: - case 138 /* UndefinedKeyword */: - case 129 /* NeverKeyword */: - case 133 /* ObjectKeyword */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 95 /* NullKeyword */: + case 139 /* UndefinedKeyword */: + case 130 /* NeverKeyword */: + case 134 /* ObjectKeyword */: return parseTokenNode(); case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return parseJSDocLiteralType(); } return parseJSDocTypeReference(); } function parseJSDocThisType() { - var result = createNode(281 /* JSDocThisType */); + var result = createNode(282 /* JSDocThisType */); nextToken(); - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocConstructorType() { - var result = createNode(280 /* JSDocConstructorType */); + var result = createNode(281 /* JSDocConstructorType */); nextToken(); - parseExpected(55 /* ColonToken */); + parseExpected(56 /* ColonToken */); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocVariadicType() { - var result = createNode(279 /* JSDocVariadicType */); + var result = createNode(280 /* JSDocVariadicType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocFunctionType() { - var result = createNode(278 /* JSDocFunctionType */); + var result = createNode(279 /* JSDocFunctionType */); nextToken(); - parseExpected(18 /* OpenParenToken */); + parseExpected(19 /* OpenParenToken */); result.parameters = parseDelimitedList(23 /* JSDocFunctionParameters */, parseJSDocParameter); checkForTrailingComma(result.parameters); - parseExpected(19 /* CloseParenToken */); - if (token() === 55 /* ColonToken */) { + parseExpected(20 /* CloseParenToken */); + if (token() === 56 /* ColonToken */) { nextToken(); result.type = parseJSDocType(); } return finishNode(result); } function parseJSDocParameter() { - var parameter = createNode(145 /* Parameter */); + var parameter = createNode(146 /* Parameter */); parameter.type = parseJSDocType(); - if (parseOptional(57 /* EqualsToken */)) { + if (parseOptional(58 /* EqualsToken */)) { // TODO(rbuckton): Can this be changed to SyntaxKind.QuestionToken? - parameter.questionToken = createNode(57 /* EqualsToken */); + parameter.questionToken = createNode(58 /* EqualsToken */); } return finishNode(parameter); } function parseJSDocTypeReference() { - var result = createNode(276 /* JSDocTypeReference */); + var result = createNode(277 /* JSDocTypeReference */); result.name = parseSimplePropertyName(); - if (token() === 26 /* LessThanToken */) { + if (token() === 27 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); } else { - while (parseOptional(22 /* DotToken */)) { - if (token() === 26 /* LessThanToken */) { + while (parseOptional(23 /* DotToken */)) { + if (token() === 27 /* LessThanToken */) { result.typeArguments = parseTypeArguments(); break; } @@ -19644,7 +20184,7 @@ var ts; var typeArguments = parseDelimitedList(24 /* JSDocTypeArguments */, parseJSDocType); checkForTrailingComma(typeArguments); checkForEmptyTypeArgumentList(typeArguments); - parseExpected(28 /* GreaterThanToken */); + parseExpected(29 /* GreaterThanToken */); return typeArguments; } function checkForEmptyTypeArgumentList(typeArguments) { @@ -19655,28 +20195,28 @@ var ts; } } function parseQualifiedName(left) { - var result = createNode(142 /* QualifiedName */, left.pos); + var result = createNode(143 /* QualifiedName */, left.pos); result.left = left; result.right = parseIdentifierName(); return finishNode(result); } function parseJSDocRecordType() { - var result = createNode(274 /* JSDocRecordType */); + var result = createNode(275 /* JSDocRecordType */); result.literal = parseTypeLiteral(); return finishNode(result); } function parseJSDocNonNullableType() { - var result = createNode(273 /* JSDocNonNullableType */); + var result = createNode(274 /* JSDocNonNullableType */); nextToken(); result.type = parseJSDocType(); return finishNode(result); } function parseJSDocTupleType() { - var result = createNode(271 /* JSDocTupleType */); + var result = createNode(272 /* JSDocTupleType */); nextToken(); result.types = parseDelimitedList(26 /* JSDocTupleTypes */, parseJSDocType); checkForTrailingComma(result.types); - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); return finishNode(result); } function checkForTrailingComma(list) { @@ -19686,28 +20226,28 @@ var ts; } } function parseJSDocUnionType() { - var result = createNode(270 /* JSDocUnionType */); + var result = createNode(271 /* JSDocUnionType */); nextToken(); result.types = parseJSDocTypeList(parseJSDocType()); - parseExpected(19 /* CloseParenToken */); + parseExpected(20 /* CloseParenToken */); return finishNode(result); } function parseJSDocTypeList(firstType) { ts.Debug.assert(!!firstType); var types = createNodeArray([firstType], firstType.pos); - while (parseOptional(48 /* BarToken */)) { + while (parseOptional(49 /* BarToken */)) { types.push(parseJSDocType()); } types.end = scanner.getStartPos(); return types; } function parseJSDocAllType() { - var result = createNode(267 /* JSDocAllType */); + var result = createNode(268 /* JSDocAllType */); nextToken(); return finishNode(result); } function parseJSDocLiteralType() { - var result = createNode(292 /* JSDocLiteralType */); + var result = createNode(293 /* JSDocLiteralType */); result.literal = parseLiteralTypeNode(); return finishNode(result); } @@ -19724,17 +20264,17 @@ var ts; // Foo // Foo(?= // (?| - if (token() === 25 /* CommaToken */ || - token() === 17 /* CloseBraceToken */ || - token() === 19 /* CloseParenToken */ || - token() === 28 /* GreaterThanToken */ || - token() === 57 /* EqualsToken */ || - token() === 48 /* BarToken */) { - var result = createNode(268 /* JSDocUnknownType */, pos); + if (token() === 26 /* CommaToken */ || + token() === 18 /* CloseBraceToken */ || + token() === 20 /* CloseParenToken */ || + token() === 29 /* GreaterThanToken */ || + token() === 58 /* EqualsToken */ || + token() === 49 /* BarToken */) { + var result = createNode(269 /* JSDocUnknownType */, pos); return finishNode(result); } else { - var result = createNode(272 /* JSDocNullableType */, pos); + var result = createNode(273 /* JSDocNullableType */, pos); result.type = parseJSDocType(); return finishNode(result); } @@ -19810,7 +20350,7 @@ var ts; } while (token() !== 1 /* EndOfFileToken */) { switch (token()) { - case 56 /* AtToken */: + case 57 /* AtToken */: if (state === 0 /* BeginningOfLine */ || state === 1 /* SawAsterisk */) { removeTrailingNewlines(comments); parseTag(indent); @@ -19831,7 +20371,7 @@ var ts; state = 0 /* BeginningOfLine */; indent = 0; break; - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: var asterisk = scanner.getTokenText(); if (state === 1 /* SawAsterisk */ || state === 2 /* SavingComments */) { // If we've already seen an asterisk, then we can no longer parse a tag on this line @@ -19844,7 +20384,7 @@ var ts; indent += asterisk.length; } break; - case 70 /* Identifier */: + case 71 /* Identifier */: // Anything else is doc comment text. We just save it. Because it // wasn't a tag, we can no longer parse a tag on this line until we hit the next // line break. @@ -19899,7 +20439,7 @@ var ts; content.charCodeAt(start + 3) !== 42 /* asterisk */; } function createJSDocComment() { - var result = createNode(282 /* JSDocComment */, start); + var result = createNode(283 /* JSDocComment */, start); result.tags = tags; result.comment = comments.length ? comments.join("") : undefined; return finishNode(result, end); @@ -19910,8 +20450,8 @@ var ts; } } function parseTag(indent) { - ts.Debug.assert(token() === 56 /* AtToken */); - var atToken = createNode(56 /* AtToken */, scanner.getTokenPos()); + ts.Debug.assert(token() === 57 /* AtToken */); + var atToken = createNode(57 /* AtToken */, scanner.getTokenPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -19957,7 +20497,7 @@ var ts; } function parseTagComments(indent) { var comments = []; - var state = 1 /* SawAsterisk */; + var state = 0 /* BeginningOfLine */; var margin; function pushComment(text) { if (!margin) { @@ -19966,7 +20506,7 @@ var ts; comments.push(text); indent += text.length; } - while (token() !== 56 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { + while (token() !== 57 /* AtToken */ && token() !== 1 /* EndOfFileToken */) { switch (token()) { case 4 /* NewLineTrivia */: if (state >= 1 /* SawAsterisk */) { @@ -19975,7 +20515,7 @@ var ts; } indent = 0; break; - case 56 /* AtToken */: + case 57 /* AtToken */: // Done break; case 5 /* WhitespaceTrivia */: @@ -19991,20 +20531,21 @@ var ts; indent += whitespace.length; } break; - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: if (state === 0 /* BeginningOfLine */) { // leading asterisks start recording on the *next* (non-whitespace) token state = 1 /* SawAsterisk */; indent += scanner.getTokenText().length; break; } - // FALLTHROUGH otherwise to record the * as a comment + // record the * as a comment + // falls through default: state = 2 /* SavingComments */; // leading identifiers start recording as well pushComment(scanner.getTokenText()); break; } - if (token() === 56 /* AtToken */) { + if (token() === 57 /* AtToken */) { // Done break; } @@ -20015,7 +20556,7 @@ var ts; return comments; } function parseUnknownTag(atToken, tagName) { - var result = createNode(283 /* JSDocTag */, atToken.pos); + var result = createNode(284 /* JSDocTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; return finishNode(result); @@ -20033,7 +20574,7 @@ var ts; function tryParseTypeExpression() { return tryParse(function () { skipWhitespace(); - if (token() !== 16 /* OpenBraceToken */) { + if (token() !== 17 /* OpenBraceToken */) { return undefined; } return parseJSDocTypeExpression(); @@ -20045,15 +20586,15 @@ var ts; var name; var isBracketed; // Looking for something like '[foo]' or 'foo' - if (parseOptionalToken(20 /* OpenBracketToken */)) { + if (parseOptionalToken(21 /* OpenBracketToken */)) { name = parseJSDocIdentifierName(); skipWhitespace(); isBracketed = true; // May have an optional default, e.g. '[foo = 42]' - if (parseOptionalToken(57 /* EqualsToken */)) { + if (parseOptionalToken(58 /* EqualsToken */)) { parseExpression(); } - parseExpected(21 /* CloseBracketToken */); + parseExpected(22 /* CloseBracketToken */); } else if (ts.tokenIsIdentifierOrKeyword(token())) { name = parseJSDocIdentifierName(); @@ -20072,7 +20613,7 @@ var ts; if (!typeExpression) { typeExpression = tryParseTypeExpression(); } - var result = createNode(285 /* JSDocParameterTag */, atToken.pos); + var result = createNode(286 /* JSDocParameterTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.preParameterName = preName; @@ -20083,20 +20624,20 @@ var ts; return finishNode(result); } function parseReturnTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 286 /* JSDocReturnTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocReturnTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(286 /* JSDocReturnTag */, atToken.pos); + var result = createNode(287 /* JSDocReturnTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); return finishNode(result); } function parseTypeTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 287 /* JSDocTypeTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTypeTag */; })) { parseErrorAtPosition(tagName.pos, scanner.getTokenPos() - tagName.pos, ts.Diagnostics._0_tag_already_specified, tagName.text); } - var result = createNode(287 /* JSDocTypeTag */, atToken.pos); + var result = createNode(288 /* JSDocTypeTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = tryParseTypeExpression(); @@ -20111,7 +20652,7 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), /*length*/ 0, ts.Diagnostics.Identifier_expected); return undefined; } - var result = createNode(290 /* JSDocPropertyTag */, atToken.pos); + var result = createNode(291 /* JSDocPropertyTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.name = name; @@ -20120,7 +20661,7 @@ var ts; } function parseAugmentsTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); - var result = createNode(284 /* JSDocAugmentsTag */, atToken.pos); + var result = createNode(285 /* JSDocAugmentsTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeExpression = typeExpression; @@ -20129,17 +20670,17 @@ var ts; function parseTypedefTag(atToken, tagName) { var typeExpression = tryParseTypeExpression(); skipWhitespace(); - var typedefTag = createNode(289 /* JSDocTypedefTag */, atToken.pos); + var typedefTag = createNode(290 /* JSDocTypedefTag */, atToken.pos); typedefTag.atToken = atToken; typedefTag.tagName = tagName; typedefTag.fullName = parseJSDocTypeNameWithNamespace(/*flags*/ 0); if (typedefTag.fullName) { var rightNode = typedefTag.fullName; while (true) { - if (rightNode.kind === 70 /* Identifier */ || !rightNode.body) { + if (rightNode.kind === 71 /* Identifier */ || !rightNode.body) { // if node is identifier - use it as name // otherwise use name of the rightmost part that we were able to parse - typedefTag.name = rightNode.kind === 70 /* Identifier */ ? rightNode : rightNode.name; + typedefTag.name = rightNode.kind === 71 /* Identifier */ ? rightNode : rightNode.name; break; } rightNode = rightNode.body; @@ -20148,9 +20689,9 @@ var ts; typedefTag.typeExpression = typeExpression; skipWhitespace(); if (typeExpression) { - if (typeExpression.type.kind === 276 /* JSDocTypeReference */) { + if (typeExpression.type.kind === 277 /* JSDocTypeReference */) { var jsDocTypeReference = typeExpression.type; - if (jsDocTypeReference.name.kind === 70 /* Identifier */) { + if (jsDocTypeReference.name.kind === 71 /* Identifier */) { var name = jsDocTypeReference.name; if (name.text === "Object") { typedefTag.jsDocTypeLiteral = scanChildTags(); @@ -20166,7 +20707,7 @@ var ts; } return finishNode(typedefTag); function scanChildTags() { - var jsDocTypeLiteral = createNode(291 /* JSDocTypeLiteral */, scanner.getStartPos()); + var jsDocTypeLiteral = createNode(292 /* JSDocTypeLiteral */, scanner.getStartPos()); var resumePos = scanner.getStartPos(); var canParseTag = true; var seenAsterisk = false; @@ -20174,7 +20715,7 @@ var ts; while (token() !== 1 /* EndOfFileToken */ && !parentTagTerminated) { nextJSDocToken(); switch (token()) { - case 56 /* AtToken */: + case 57 /* AtToken */: if (canParseTag) { parentTagTerminated = !tryParseChildTag(jsDocTypeLiteral); if (!parentTagTerminated) { @@ -20188,14 +20729,15 @@ var ts; canParseTag = true; seenAsterisk = false; break; - case 38 /* AsteriskToken */: + case 39 /* AsteriskToken */: if (seenAsterisk) { canParseTag = false; } seenAsterisk = true; break; - case 70 /* Identifier */: + case 71 /* Identifier */: canParseTag = false; + break; case 1 /* EndOfFileToken */: break; } @@ -20206,8 +20748,8 @@ var ts; function parseJSDocTypeNameWithNamespace(flags) { var pos = scanner.getTokenPos(); var typeNameOrNamespaceName = parseJSDocIdentifierName(); - if (typeNameOrNamespaceName && parseOptional(22 /* DotToken */)) { - var jsDocNamespaceNode = createNode(232 /* ModuleDeclaration */, pos); + if (typeNameOrNamespaceName && parseOptional(23 /* DotToken */)) { + var jsDocNamespaceNode = createNode(233 /* ModuleDeclaration */, pos); jsDocNamespaceNode.flags |= flags; jsDocNamespaceNode.name = typeNameOrNamespaceName; jsDocNamespaceNode.body = parseJSDocTypeNameWithNamespace(4 /* NestedNamespace */); @@ -20220,8 +20762,8 @@ var ts; } } function tryParseChildTag(parentTag) { - ts.Debug.assert(token() === 56 /* AtToken */); - var atToken = createNode(56 /* AtToken */, scanner.getStartPos()); + ts.Debug.assert(token() === 57 /* AtToken */); + var atToken = createNode(57 /* AtToken */, scanner.getStartPos()); atToken.end = scanner.getTextPos(); nextJSDocToken(); var tagName = parseJSDocIdentifierName(); @@ -20253,7 +20795,7 @@ var ts; return false; } function parseTemplateTag(atToken, tagName) { - if (ts.forEach(tags, function (t) { return t.kind === 288 /* JSDocTemplateTag */; })) { + if (ts.forEach(tags, function (t) { return t.kind === 289 /* 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' @@ -20265,11 +20807,11 @@ var ts; parseErrorAtPosition(scanner.getStartPos(), 0, ts.Diagnostics.Identifier_expected); return undefined; } - var typeParameter = createNode(144 /* TypeParameter */, name.pos); + var typeParameter = createNode(145 /* TypeParameter */, name.pos); typeParameter.name = name; finishNode(typeParameter); typeParameters.push(typeParameter); - if (token() === 25 /* CommaToken */) { + if (token() === 26 /* CommaToken */) { nextJSDocToken(); skipWhitespace(); } @@ -20277,7 +20819,7 @@ var ts; break; } } - var result = createNode(288 /* JSDocTemplateTag */, atToken.pos); + var result = createNode(289 /* JSDocTemplateTag */, atToken.pos); result.atToken = atToken; result.tagName = tagName; result.typeParameters = typeParameters; @@ -20298,7 +20840,7 @@ var ts; } var pos = scanner.getTokenPos(); var end = scanner.getTextPos(); - var result = createNode(70 /* Identifier */, pos); + var result = createNode(71 /* Identifier */, pos); result.text = content.substring(pos, end); finishNode(result, end); nextJSDocToken(); @@ -20426,7 +20968,7 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 70 /* Identifier */: + case 71 /* Identifier */: return true; } return false; @@ -20797,16 +21339,16 @@ var ts; function getModuleInstanceState(node) { // A module is uninstantiated if it contains only // 1. interface declarations, type alias declarations - if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 230 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* InterfaceDeclaration */ || node.kind === 231 /* TypeAliasDeclaration */) { return 0 /* NonInstantiated */; } else if (ts.isConstEnumDeclaration(node)) { return 2 /* ConstEnumOnly */; } - else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { + else if ((node.kind === 238 /* ImportDeclaration */ || node.kind === 237 /* ImportEqualsDeclaration */) && !(ts.hasModifier(node, 1 /* Export */))) { return 0 /* NonInstantiated */; } - else if (node.kind === 233 /* ModuleBlock */) { + else if (node.kind === 234 /* ModuleBlock */) { var state_1 = 0 /* NonInstantiated */; ts.forEachChild(node, function (n) { switch (getModuleInstanceState(n)) { @@ -20825,11 +21367,11 @@ var ts; }); return state_1; } - else if (node.kind === 232 /* ModuleDeclaration */) { + else if (node.kind === 233 /* ModuleDeclaration */) { var body = node.body; return body ? getModuleInstanceState(body) : 1 /* Instantiated */; } - else if (node.kind === 70 /* Identifier */ && node.isInJSDocNamespace) { + else if (node.kind === 71 /* Identifier */ && node.isInJSDocNamespace) { return 0 /* NonInstantiated */; } else { @@ -20938,7 +21480,7 @@ var ts; } return bindSourceFile; function bindInStrictMode(file, opts) { - if (opts.alwaysStrict && !ts.isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !ts.isDeclarationFile(file)) { // bind in strict mode source files with alwaysStrict option return true; } @@ -20966,7 +21508,7 @@ var ts; if (symbolFlags & 107455 /* Value */) { var valueDeclaration = symbol.valueDeclaration; if (!valueDeclaration || - (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 232 /* ModuleDeclaration */)) { + (valueDeclaration.kind !== node.kind && valueDeclaration.kind === 233 /* ModuleDeclaration */)) { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } @@ -20979,7 +21521,7 @@ var ts; if (ts.isAmbientModule(node)) { return ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + node.name.text + "\""; } - if (node.name.kind === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* 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)) { @@ -20991,27 +21533,28 @@ var ts; return node.name.text; } switch (node.kind) { - case 151 /* Constructor */: + case 152 /* Constructor */: return "__constructor"; - case 159 /* FunctionType */: - case 154 /* CallSignature */: + case 160 /* FunctionType */: + case 155 /* CallSignature */: return "__call"; - case 160 /* ConstructorType */: - case 155 /* ConstructSignature */: + case 161 /* ConstructorType */: + case 156 /* ConstructSignature */: return "__new"; - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return "__index"; - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return "__export"; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return node.isExportEquals ? "export=" : "default"; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (ts.getSpecialPropertyAssignmentKind(node)) { case 2 /* ModuleExports */: // module.exports = ... return "export="; case 1 /* ExportsProperty */: case 4 /* ThisProperty */: + case 5 /* Property */: // exports.x = ... or this.y = ... return node.left.name.text; case 3 /* PrototypeProperty */: @@ -21020,25 +21563,25 @@ var ts; } ts.Debug.fail("Unknown binary declaration kind"); break; - case 227 /* FunctionDeclaration */: - case 228 /* ClassDeclaration */: + case 228 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: return ts.hasModifier(node, 512 /* Default */) ? "default" : undefined; - case 278 /* JSDocFunctionType */: + case 279 /* JSDocFunctionType */: return ts.isJSDocConstructSignature(node) ? "__new" : "__call"; - case 145 /* Parameter */: + case 146 /* 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 === 278 /* JSDocFunctionType */); + ts.Debug.assert(node.parent.kind === 279 /* JSDocFunctionType */); var functionType = node.parent; var index = ts.indexOf(functionType.parameters, node); return "arg" + index; - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: var parentNode = node.parent && node.parent.parent; var nameFromParentNode = void 0; - if (parentNode && parentNode.kind === 207 /* VariableStatement */) { + if (parentNode && parentNode.kind === 208 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70 /* Identifier */) { + if (nameIdentifier.kind === 71 /* Identifier */) { nameFromParentNode = nameIdentifier.text; } } @@ -21125,7 +21668,7 @@ var ts; // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === 242 /* ExportAssignment */ && !node.isExportEquals))) { + (isDefaultExport || (node.kind === 243 /* ExportAssignment */ && !node.isExportEquals))) { message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports; } } @@ -21145,11 +21688,11 @@ var ts; function declareModuleMember(node, symbolFlags, symbolExcludes) { var hasExportModifier = ts.getCombinedModifierFlags(node) & 1 /* Export */; if (symbolFlags & 8388608 /* Alias */) { - if (node.kind === 245 /* ExportSpecifier */ || (node.kind === 236 /* ImportEqualsDeclaration */ && hasExportModifier)) { + if (node.kind === 246 /* ExportSpecifier */ || (node.kind === 237 /* ImportEqualsDeclaration */ && hasExportModifier)) { return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); } else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } } else { @@ -21168,21 +21711,21 @@ 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. - var isJSDocTypedefInJSDocNamespace = node.kind === 289 /* JSDocTypedefTag */ && + var isJSDocTypedefInJSDocNamespace = node.kind === 290 /* JSDocTypedefTag */ && node.name && - node.name.kind === 70 /* Identifier */ && + node.name.kind === 71 /* Identifier */ && node.name.isInJSDocNamespace; if ((!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 32 /* ExportContext */)) || isJSDocTypedefInJSDocNamespace) { var exportKind = (symbolFlags & 107455 /* Value */ ? 1048576 /* ExportValue */ : 0) | (symbolFlags & 793064 /* Type */ ? 2097152 /* ExportType */ : 0) | (symbolFlags & 1920 /* Namespace */ ? 4194304 /* ExportNamespace */ : 0); - var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes); + var local = declareSymbol(container.locals, /*parent*/ undefined, node, exportKind, symbolExcludes); local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); node.localSymbol = local; return local; } else { - return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes); + return declareSymbol(container.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } } } @@ -21255,7 +21798,7 @@ var ts; if (hasExplicitReturn) node.flags |= 256 /* HasExplicitReturn */; } - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { node.flags |= emitFlags; } if (isIIFE) { @@ -21334,66 +21877,72 @@ var ts; return; } switch (node.kind) { - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: bindWhileStatement(node); break; - case 211 /* DoStatement */: + case 212 /* DoStatement */: bindDoStatement(node); break; - case 213 /* ForStatement */: + case 214 /* ForStatement */: bindForStatement(node); break; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: bindForInOrForOfStatement(node); break; - case 210 /* IfStatement */: + case 211 /* IfStatement */: bindIfStatement(node); break; - case 218 /* ReturnStatement */: - case 222 /* ThrowStatement */: + case 219 /* ReturnStatement */: + case 223 /* ThrowStatement */: bindReturnOrThrow(node); break; - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: bindBreakOrContinueStatement(node); break; - case 223 /* TryStatement */: + case 224 /* TryStatement */: bindTryStatement(node); break; - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: bindSwitchStatement(node); break; - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: bindCaseBlock(node); break; - case 256 /* CaseClause */: + case 257 /* CaseClause */: bindCaseClause(node); break; - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: bindLabeledStatement(node); break; - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: bindPrefixUnaryExpressionFlow(node); break; - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: bindPostfixUnaryExpressionFlow(node); break; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: bindBinaryExpressionFlow(node); break; - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: bindDeleteExpressionFlow(node); break; - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: bindConditionalExpressionFlow(node); break; - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: bindVariableDeclarationFlow(node); break; - case 180 /* CallExpression */: + case 181 /* CallExpression */: bindCallExpressionFlow(node); break; + case 283 /* JSDocComment */: + bindJSDocComment(node); + break; + case 290 /* JSDocTypedefTag */: + bindJSDocTypedefTag(node); + break; default: bindEachChild(node); break; @@ -21401,25 +21950,26 @@ var ts; } function isNarrowingExpression(expr) { switch (expr.kind) { - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 99 /* ThisKeyword */: + case 179 /* PropertyAccessExpression */: return isNarrowableReference(expr); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return hasNarrowableArgument(expr); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return isNarrowingExpression(expr.expression); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return isNarrowingBinaryExpression(expr); - case 191 /* PrefixUnaryExpression */: - return expr.operator === 50 /* ExclamationToken */ && isNarrowingExpression(expr.operand); + case 192 /* PrefixUnaryExpression */: + return expr.operator === 51 /* ExclamationToken */ && isNarrowingExpression(expr.operand); } return false; } function isNarrowableReference(expr) { - return expr.kind === 70 /* Identifier */ || - expr.kind === 98 /* ThisKeyword */ || - expr.kind === 178 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); + return expr.kind === 71 /* Identifier */ || + expr.kind === 99 /* ThisKeyword */ || + expr.kind === 97 /* SuperKeyword */ || + expr.kind === 179 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression); } function hasNarrowableArgument(expr) { if (expr.arguments) { @@ -21430,41 +21980,41 @@ var ts; } } } - if (expr.expression.kind === 178 /* PropertyAccessExpression */ && + if (expr.expression.kind === 179 /* PropertyAccessExpression */ && isNarrowableReference(expr.expression.expression)) { return true; } return false; } function isNarrowingTypeofOperands(expr1, expr2) { - return expr1.kind === 188 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; + return expr1.kind === 189 /* TypeOfExpression */ && isNarrowableOperand(expr1.expression) && expr2.kind === 9 /* StringLiteral */; } function isNarrowingBinaryExpression(expr) { switch (expr.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return isNarrowableReference(expr.left); - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) || isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right); - case 92 /* InstanceOfKeyword */: + case 93 /* InstanceOfKeyword */: return isNarrowableOperand(expr.left); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return isNarrowingExpression(expr.right); } return false; } function isNarrowableOperand(expr) { switch (expr.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return isNarrowableOperand(expr.expression); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (expr.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return isNarrowableOperand(expr.left); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return isNarrowableOperand(expr.right); } } @@ -21499,8 +22049,8 @@ var ts; if (!expression) { return flags & 32 /* TrueCondition */ ? antecedent : unreachableFlow; } - if (expression.kind === 100 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || - expression.kind === 85 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { + if (expression.kind === 101 /* TrueKeyword */ && flags & 64 /* FalseCondition */ || + expression.kind === 86 /* FalseKeyword */ && flags & 32 /* TrueCondition */) { return unreachableFlow; } if (!isNarrowingExpression(expression)) { @@ -21555,34 +22105,34 @@ var ts; function isStatementCondition(node) { var parent = node.parent; switch (parent.kind) { - case 210 /* IfStatement */: - case 212 /* WhileStatement */: - case 211 /* DoStatement */: + case 211 /* IfStatement */: + case 213 /* WhileStatement */: + case 212 /* DoStatement */: return parent.expression === node; - case 213 /* ForStatement */: - case 194 /* ConditionalExpression */: + case 214 /* ForStatement */: + case 195 /* ConditionalExpression */: return parent.condition === node; } return false; } function isLogicalExpression(node) { while (true) { - if (node.kind === 184 /* ParenthesizedExpression */) { + if (node.kind === 185 /* ParenthesizedExpression */) { node = node.expression; } - else if (node.kind === 191 /* PrefixUnaryExpression */ && node.operator === 50 /* ExclamationToken */) { + else if (node.kind === 192 /* PrefixUnaryExpression */ && node.operator === 51 /* ExclamationToken */) { node = node.operand; } else { - return node.kind === 193 /* BinaryExpression */ && (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */ || - node.operatorToken.kind === 53 /* BarBarToken */); + return node.kind === 194 /* BinaryExpression */ && (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */ || + node.operatorToken.kind === 54 /* BarBarToken */); } } } function isTopLevelLogicalExpression(node) { - while (node.parent.kind === 184 /* ParenthesizedExpression */ || - node.parent.kind === 191 /* PrefixUnaryExpression */ && - node.parent.operator === 50 /* ExclamationToken */) { + while (node.parent.kind === 185 /* ParenthesizedExpression */ || + node.parent.kind === 192 /* PrefixUnaryExpression */ && + node.parent.operator === 51 /* ExclamationToken */) { node = node.parent; } return !isStatementCondition(node) && !isLogicalExpression(node.parent); @@ -21623,7 +22173,7 @@ var ts; } function bindDoStatement(node) { var preDoLabel = createLoopLabel(); - var enclosingLabeledStatement = node.parent.kind === 221 /* LabeledStatement */ + var enclosingLabeledStatement = node.parent.kind === 222 /* LabeledStatement */ ? ts.lastOrUndefined(activeLabels) : undefined; // if do statement is wrapped in labeled statement then target labels for break/continue with or without @@ -21657,10 +22207,13 @@ var ts; var postLoopLabel = createBranchLabel(); addAntecedent(preLoopLabel, currentFlow); currentFlow = preLoopLabel; + if (node.kind === 216 /* ForOfStatement */) { + bind(node.awaitModifier); + } bind(node.expression); addAntecedent(postLoopLabel, currentFlow); bind(node.initializer); - if (node.initializer.kind !== 226 /* VariableDeclarationList */) { + if (node.initializer.kind !== 227 /* VariableDeclarationList */) { bindAssignmentTargetFlow(node.initializer); } bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel); @@ -21682,7 +22235,7 @@ var ts; } function bindReturnOrThrow(node) { bind(node.expression); - if (node.kind === 218 /* ReturnStatement */) { + if (node.kind === 219 /* ReturnStatement */) { hasExplicitReturn = true; if (currentReturnTarget) { addAntecedent(currentReturnTarget, currentFlow); @@ -21702,7 +22255,7 @@ var ts; return undefined; } function bindBreakOrContinueFlow(node, breakTarget, continueTarget) { - var flowLabel = node.kind === 217 /* BreakStatement */ ? breakTarget : continueTarget; + var flowLabel = node.kind === 218 /* BreakStatement */ ? breakTarget : continueTarget; if (flowLabel) { addAntecedent(flowLabel, currentFlow); currentFlow = unreachableFlow; @@ -21743,8 +22296,8 @@ var ts; // second -> edge that represents post-finally flow. // these edges are used in following scenario: // let a; (1) - // try { a = someOperation(); (2)} - // finally { (3) console.log(a) } (4) + // try { a = someOperation(); (2)} + // finally { (3) console.log(a) } (4) // (5) a // flow graph for this case looks roughly like this (arrows show ): // (1-pre-try-flow) <--.. <-- (2-post-try-flow) @@ -21755,11 +22308,11 @@ var ts; // In case when we walk the flow starting from inside the finally block we want to take edge '*****' into account // since it ensures that finally is always reachable. However when we start outside the finally block and go through label (5) // then edge '*****' should be discarded because label 4 is only reachable if post-finally label-4 is reachable - // Simply speaking code inside finally block is treated as reachable as pre-try-flow + // Simply speaking code inside finally block is treated as reachable as pre-try-flow // since we conservatively assume that any line in try block can throw or return in which case we'll enter finally. // However code after finally is reachable only if control flow was not abrupted in try/catch or finally blocks - it should be composed from // final flows of these blocks without taking pre-try flow into account. - // + // // extra edges that we inject allows to control this behavior // if when walking the flow we step on post-finally edge - we can mark matching pre-finally edge as locked so it will be skipped. var preFinallyFlow = { flags: 2048 /* PreFinally */, antecedent: preTryFlow, lock: {} }; @@ -21798,7 +22351,7 @@ var ts; preSwitchCaseFlow = currentFlow; bind(node.caseBlock); addAntecedent(postSwitchLabel, currentFlow); - var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 257 /* DefaultClause */; }); + var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 258 /* DefaultClause */; }); // We mark a switch statement as possibly exhaustive if it has no default clause and if all // case clauses have unreachable end points (e.g. they all return). node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents; @@ -21865,14 +22418,14 @@ var ts; if (!activeLabel.referenced && !options.allowUnusedLabels) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node.label, ts.Diagnostics.Unused_label)); } - if (!node.statement || node.statement.kind !== 211 /* DoStatement */) { + if (!node.statement || node.statement.kind !== 212 /* DoStatement */) { // do statement sets current flow inside bindDoStatement addAntecedent(postStatementLabel, currentFlow); currentFlow = finishFlowLabel(postStatementLabel); } } function bindDestructuringTargetFlow(node) { - if (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */) { + if (node.kind === 194 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */) { bindAssignmentTargetFlow(node.left); } else { @@ -21883,10 +22436,10 @@ var ts; if (isNarrowableReference(node)) { currentFlow = createFlowAssignment(currentFlow, node); } - else if (node.kind === 176 /* ArrayLiteralExpression */) { + else if (node.kind === 177 /* ArrayLiteralExpression */) { for (var _i = 0, _a = node.elements; _i < _a.length; _i++) { var e = _a[_i]; - if (e.kind === 197 /* SpreadElement */) { + if (e.kind === 198 /* SpreadElement */) { bindAssignmentTargetFlow(e.expression); } else { @@ -21894,16 +22447,16 @@ var ts; } } } - else if (node.kind === 177 /* ObjectLiteralExpression */) { + else if (node.kind === 178 /* ObjectLiteralExpression */) { for (var _b = 0, _c = node.properties; _b < _c.length; _b++) { var p = _c[_b]; - if (p.kind === 260 /* PropertyAssignment */) { + if (p.kind === 261 /* PropertyAssignment */) { bindDestructuringTargetFlow(p.initializer); } - else if (p.kind === 261 /* ShorthandPropertyAssignment */) { + else if (p.kind === 262 /* ShorthandPropertyAssignment */) { bindAssignmentTargetFlow(p.name); } - else if (p.kind === 262 /* SpreadAssignment */) { + else if (p.kind === 263 /* SpreadAssignment */) { bindAssignmentTargetFlow(p.expression); } } @@ -21911,7 +22464,7 @@ var ts; } function bindLogicalExpression(node, trueTarget, falseTarget) { var preRightLabel = createBranchLabel(); - if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { bindCondition(node.left, preRightLabel, falseTarget); } else { @@ -21922,7 +22475,7 @@ var ts; bindCondition(node.right, trueTarget, falseTarget); } function bindPrefixUnaryExpressionFlow(node) { - if (node.operator === 50 /* ExclamationToken */) { + if (node.operator === 51 /* ExclamationToken */) { var saveTrueTarget = currentTrueTarget; currentTrueTarget = currentFalseTarget; currentFalseTarget = saveTrueTarget; @@ -21932,20 +22485,20 @@ var ts; } else { bindEachChild(node); - if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { + if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } } function bindPostfixUnaryExpressionFlow(node) { bindEachChild(node); - if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { + if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { bindAssignmentTargetFlow(node.operand); } } function bindBinaryExpressionFlow(node) { var operator = node.operatorToken.kind; - if (operator === 52 /* AmpersandAmpersandToken */ || operator === 53 /* BarBarToken */) { + if (operator === 53 /* AmpersandAmpersandToken */ || operator === 54 /* BarBarToken */) { if (isTopLevelLogicalExpression(node)) { var postExpressionLabel = createBranchLabel(); bindLogicalExpression(node, postExpressionLabel, postExpressionLabel); @@ -21959,7 +22512,7 @@ var ts; bindEachChild(node); if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) { bindAssignmentTargetFlow(node.left); - if (operator === 57 /* EqualsToken */ && node.left.kind === 179 /* ElementAccessExpression */) { + if (operator === 58 /* EqualsToken */ && node.left.kind === 180 /* ElementAccessExpression */) { var elementAccess = node.left; if (isNarrowableOperand(elementAccess.expression)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -21970,7 +22523,7 @@ var ts; } function bindDeleteExpressionFlow(node) { bindEachChild(node); - if (node.expression.kind === 178 /* PropertyAccessExpression */) { + if (node.expression.kind === 179 /* PropertyAccessExpression */) { bindAssignmentTargetFlow(node.expression); } } @@ -22003,19 +22556,37 @@ var ts; } function bindVariableDeclarationFlow(node) { bindEachChild(node); - if (node.initializer || node.parent.parent.kind === 214 /* ForInStatement */ || node.parent.parent.kind === 215 /* ForOfStatement */) { + if (node.initializer || node.parent.parent.kind === 215 /* ForInStatement */ || node.parent.parent.kind === 216 /* ForOfStatement */) { bindInitializedVariableFlow(node); } } + function bindJSDocComment(node) { + ts.forEachChild(node, function (n) { + if (n.kind !== 290 /* JSDocTypedefTag */) { + bind(n); + } + }); + } + function bindJSDocTypedefTag(node) { + ts.forEachChild(node, function (n) { + // if the node has a fullName "A.B.C", that means symbol "C" was already bound + // when we visit "fullName"; so when we visit the name "C" as the next child of + // the jsDocTypedefTag, we should skip binding it. + if (node.fullName && n === node.name && node.fullName.kind !== 71 /* Identifier */) { + return; + } + bind(n); + }); + } function bindCallExpressionFlow(node) { // If the target of the call expression is a function expression or arrow function we have // an immediately invoked function expression (IIFE). Initialize the flowNode property to // the current control flow (which includes evaluation of the IIFE arguments). var expr = node.expression; - while (expr.kind === 184 /* ParenthesizedExpression */) { + while (expr.kind === 185 /* ParenthesizedExpression */) { expr = expr.expression; } - if (expr.kind === 185 /* FunctionExpression */ || expr.kind === 186 /* ArrowFunction */) { + if (expr.kind === 186 /* FunctionExpression */ || expr.kind === 187 /* ArrowFunction */) { bindEach(node.typeArguments); bindEach(node.arguments); bind(node.expression); @@ -22023,7 +22594,7 @@ var ts; else { bindEachChild(node); } - if (node.expression.kind === 178 /* PropertyAccessExpression */) { + if (node.expression.kind === 179 /* PropertyAccessExpression */) { var propertyAccess = node.expression; if (isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) { currentFlow = createFlowArrayMutation(currentFlow, node); @@ -22032,53 +22603,54 @@ var ts; } function getContainerFlags(node) { switch (node.kind) { - case 198 /* ClassExpression */: - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 177 /* ObjectLiteralExpression */: - case 162 /* TypeLiteral */: - case 291 /* JSDocTypeLiteral */: - case 274 /* JSDocRecordType */: - case 253 /* JsxAttributes */: + case 199 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 178 /* ObjectLiteralExpression */: + case 163 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 275 /* JSDocRecordType */: + case 254 /* JsxAttributes */: return 1 /* IsContainer */; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return 1 /* IsContainer */ | 64 /* IsInterface */; - case 278 /* JSDocFunctionType */: - case 232 /* ModuleDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 171 /* MappedType */: + case 279 /* JSDocFunctionType */: + case 233 /* ModuleDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 172 /* MappedType */: return 1 /* IsContainer */ | 32 /* HasLocals */; - case 264 /* SourceFile */: + case 265 /* SourceFile */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: if (ts.isObjectLiteralOrClassExpressionMethod(node)) { return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 128 /* IsObjectLiteralOrClassExpressionMethod */; } - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + // falls through + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */; - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return 1 /* IsContainer */ | 4 /* IsControlFlowContainer */ | 32 /* HasLocals */ | 8 /* IsFunctionLike */ | 16 /* IsFunctionExpression */; - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: return 4 /* IsControlFlowContainer */; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return node.initializer ? 4 /* IsControlFlowContainer */ : 0; - case 259 /* CatchClause */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 234 /* CaseBlock */: + case 260 /* CatchClause */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 235 /* CaseBlock */: return 2 /* IsBlockScopedContainer */; - case 206 /* Block */: + case 207 /* 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. Otherwise 'x' // would not appear to be a redeclaration of a block scoped local in the following @@ -22115,43 +22687,43 @@ 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 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return declareModuleMember(node, symbolFlags, symbolExcludes); - case 264 /* SourceFile */: + case 265 /* SourceFile */: return declareSourceFileMember(node, symbolFlags, symbolExcludes); - case 198 /* ClassExpression */: - case 228 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 229 /* ClassDeclaration */: return declareClassMember(node, symbolFlags, symbolExcludes); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes); - case 162 /* TypeLiteral */: - case 177 /* ObjectLiteralExpression */: - case 229 /* InterfaceDeclaration */: - case 274 /* JSDocRecordType */: - case 291 /* JSDocTypeLiteral */: - case 253 /* JsxAttributes */: + case 163 /* TypeLiteral */: + case 178 /* ObjectLiteralExpression */: + case 230 /* InterfaceDeclaration */: + case 275 /* JSDocRecordType */: + case 292 /* JSDocTypeLiteral */: + case 254 /* JsxAttributes */: // 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 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 278 /* JSDocFunctionType */: - case 230 /* TypeAliasDeclaration */: - case 171 /* MappedType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 279 /* JSDocFunctionType */: + case 231 /* TypeAliasDeclaration */: + case 172 /* MappedType */: // 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 @@ -22169,14 +22741,14 @@ var ts; function declareSourceFileMember(node, symbolFlags, symbolExcludes) { return ts.isExternalModule(file) ? declareModuleMember(node, symbolFlags, symbolExcludes) - : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes); + : declareSymbol(file.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } function hasExportDeclarations(node) { - var body = node.kind === 264 /* SourceFile */ ? node : node.body; - if (body && (body.kind === 264 /* SourceFile */ || body.kind === 233 /* ModuleBlock */)) { + var body = node.kind === 265 /* SourceFile */ ? node : node.body; + if (body && (body.kind === 265 /* SourceFile */ || body.kind === 234 /* ModuleBlock */)) { for (var _i = 0, _a = body.statements; _i < _a.length; _i++) { var stat = _a[_i]; - if (stat.kind === 243 /* ExportDeclaration */ || stat.kind === 242 /* ExportAssignment */) { + if (stat.kind === 244 /* ExportDeclaration */ || stat.kind === 243 /* ExportAssignment */) { return true; } } @@ -22271,7 +22843,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 /* SpreadAssignment */ || prop.name.kind !== 70 /* Identifier */) { + if (prop.kind === 263 /* SpreadAssignment */ || prop.name.kind !== 71 /* Identifier */) { continue; } var identifier = prop.name; @@ -22283,7 +22855,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 === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */ || prop.kind === 150 /* MethodDeclaration */ + var currentKind = prop.kind === 261 /* PropertyAssignment */ || prop.kind === 262 /* ShorthandPropertyAssignment */ || prop.kind === 151 /* MethodDeclaration */ ? 1 /* Property */ : 2 /* Accessor */; var existingKind = seen.get(identifier.text); @@ -22311,21 +22883,21 @@ var ts; } function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) { switch (blockScopeContainer.kind) { - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: declareModuleMember(node, symbolFlags, symbolExcludes); break; - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (ts.isExternalModule(container)) { declareModuleMember(node, symbolFlags, symbolExcludes); break; } - // fall through. + // falls through default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = ts.createMap(); addToContainerChain(blockScopeContainer); } - declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes); + declareSymbol(blockScopeContainer.locals, /*parent*/ undefined, node, symbolFlags, symbolExcludes); } } function bindBlockScopedVariableDeclaration(node) { @@ -22335,8 +22907,8 @@ var ts; // check for reserved words used as identifiers in strict mode code. function checkStrictModeIdentifier(node) { if (inStrictMode && - node.originalKeywordKind >= 107 /* FirstFutureReservedWord */ && - node.originalKeywordKind <= 115 /* LastFutureReservedWord */ && + node.originalKeywordKind >= 108 /* FirstFutureReservedWord */ && + node.originalKeywordKind <= 116 /* LastFutureReservedWord */ && !ts.isIdentifierName(node) && !ts.isInAmbientContext(node)) { // Report error only if there are no parse errors in file @@ -22372,7 +22944,7 @@ var ts; } function checkStrictModeDeleteExpression(node) { // Grammar checking - if (inStrictMode && node.expression.kind === 70 /* Identifier */) { + if (inStrictMode && node.expression.kind === 71 /* Identifier */) { // When a delete operator occurs within strict mode code, a SyntaxError is thrown if its // UnaryExpression is a direct reference to a variable, function argument, or function name var span_2 = ts.getErrorSpanForNode(file, node.expression); @@ -22380,11 +22952,11 @@ var ts; } } function isEvalOrArgumentsIdentifier(node) { - return node.kind === 70 /* Identifier */ && + return node.kind === 71 /* Identifier */ && (node.text === "eval" || node.text === "arguments"); } function checkStrictModeEvalOrArguments(contextNode, name) { - if (name && name.kind === 70 /* Identifier */) { + if (name && name.kind === 71 /* Identifier */) { var identifier = name; if (isEvalOrArgumentsIdentifier(identifier)) { // We check first if the name is inside class declaration or class expression; if so give explicit message @@ -22425,8 +22997,8 @@ var ts; function checkStrictModeFunctionDeclaration(node) { if (languageVersion < 2 /* ES2015 */) { // Report error if function is not top level function declaration - if (blockScopeContainer.kind !== 264 /* SourceFile */ && - blockScopeContainer.kind !== 232 /* ModuleDeclaration */ && + if (blockScopeContainer.kind !== 265 /* SourceFile */ && + blockScopeContainer.kind !== 233 /* ModuleDeclaration */ && !ts.isFunctionLike(blockScopeContainer)) { // We check first if the name is inside class declaration or class expression; if so give explicit message // otherwise report generic error message. @@ -22436,7 +23008,7 @@ var ts; } } function checkStrictModeNumericLiteral(node) { - if (inStrictMode && node.isOctalLiteral) { + if (inStrictMode && node.numericLiteralFlags & 4 /* Octal */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode)); } } @@ -22452,7 +23024,7 @@ var ts; function checkStrictModePrefixUnaryExpression(node) { // Grammar checking if (inStrictMode) { - if (node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) { + if (node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) { checkStrictModeEvalOrArguments(node, node.operand); } } @@ -22476,6 +23048,18 @@ var ts; } node.parent = parent; var saveInStrictMode = inStrictMode; + // Even though in the AST the jsdoc @typedef node belongs to the current node, + // its symbol might be in the same scope with the current node's symbol. Consider: + // + // /** @typedef {string | number} MyType */ + // function foo(); + // + // Here the current node is "foo", which is a container, but the scope of "MyType" should + // not be inside "foo". Therefore we always bind @typedef before bind the parent node, + // and skip binding this tag later when binding all the other jsdoc tags. + if (ts.isInJavaScriptFile(node)) { + bindJSDocTypedefTagIfAny(node); + } // First we bind declaration nodes to a symbol if possible. We'll both create a symbol // and then potentially add the symbol to an appropriate symbol table. Possible // destination symbol tables are: @@ -22492,7 +23076,7 @@ var ts; // the current 'container' node when it changes. This helps us know which symbol table // a local should go into for example. Since terminal nodes are known not to have // children, as an optimization we don't process those. - if (node.kind > 141 /* LastToken */) { + if (node.kind > 142 /* LastToken */) { var saveParent = parent; parent = node; var containerFlags = getContainerFlags(node); @@ -22509,6 +23093,26 @@ var ts; } inStrictMode = saveInStrictMode; } + function bindJSDocTypedefTagIfAny(node) { + if (!node.jsDoc) { + return; + } + for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) { + var jsDoc = _a[_i]; + if (!jsDoc.tags) { + continue; + } + for (var _b = 0, _c = jsDoc.tags; _b < _c.length; _b++) { + var tag = _c[_b]; + if (tag.kind === 290 /* JSDocTypedefTag */) { + var savedParent = parent; + parent = jsDoc; + bind(tag); + parent = savedParent; + } + } + } + } function updateStrictModeStatementList(statements) { if (!inStrictMode) { for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) { @@ -22533,95 +23137,97 @@ var ts; function bindWorker(node) { switch (node.kind) { /* Strict mode checks */ - case 70 /* Identifier */: + case 71 /* Identifier */: // for typedef type names with namespaces, bind the new jsdoc type symbol here // because it requires all containing namespaces to be in effect, namely the // current "blockScopeContainer" needs to be set to its immediate namespace parent. if (node.isInJSDocNamespace) { var parentNode = node.parent; - while (parentNode && parentNode.kind !== 289 /* JSDocTypedefTag */) { + while (parentNode && parentNode.kind !== 290 /* JSDocTypedefTag */) { parentNode = parentNode.parent; } bindBlockScopedDeclaration(parentNode, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); break; } - case 98 /* ThisKeyword */: - if (currentFlow && (ts.isExpression(node) || parent.kind === 261 /* ShorthandPropertyAssignment */)) { + // falls through + case 99 /* ThisKeyword */: + if (currentFlow && (ts.isExpression(node) || parent.kind === 262 /* ShorthandPropertyAssignment */)) { node.flowNode = currentFlow; } return checkStrictModeIdentifier(node); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: if (currentFlow && isNarrowableReference(node)) { node.flowNode = currentFlow; } break; - case 193 /* BinaryExpression */: - if (ts.isInJavaScriptFile(node)) { - var specialKind = ts.getSpecialPropertyAssignmentKind(node); - switch (specialKind) { - case 1 /* ExportsProperty */: - bindExportsPropertyAssignment(node); - break; - case 2 /* ModuleExports */: - bindModuleExportsAssignment(node); - break; - case 3 /* PrototypeProperty */: - bindPrototypePropertyAssignment(node); - break; - case 4 /* ThisProperty */: - bindThisPropertyAssignment(node); - break; - case 0 /* None */: - // Nothing to do - break; - default: - ts.Debug.fail("Unknown special property assignment kind"); - } + case 194 /* BinaryExpression */: + var specialKind = ts.getSpecialPropertyAssignmentKind(node); + switch (specialKind) { + case 1 /* ExportsProperty */: + bindExportsPropertyAssignment(node); + break; + case 2 /* ModuleExports */: + bindModuleExportsAssignment(node); + break; + case 3 /* PrototypeProperty */: + bindPrototypePropertyAssignment(node); + break; + case 4 /* ThisProperty */: + bindThisPropertyAssignment(node); + break; + case 5 /* Property */: + bindStaticPropertyAssignment(node); + break; + case 0 /* None */: + // Nothing to do + break; + default: + ts.Debug.fail("Unknown special property assignment kind"); } return checkStrictModeBinaryExpression(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return checkStrictModeCatchClause(node); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return checkStrictModeDeleteExpression(node); case 8 /* NumericLiteral */: return checkStrictModeNumericLiteral(node); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return checkStrictModePostfixUnaryExpression(node); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return checkStrictModePrefixUnaryExpression(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return checkStrictModeWithStatement(node); - case 168 /* ThisType */: + case 169 /* ThisType */: seenThisKeyword = true; return; - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return checkTypePredicate(node); - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return declareSymbolAndAddToSymbolTable(node, 262144 /* TypeParameter */, 530920 /* TypeParameterExcludes */); - case 145 /* Parameter */: + case 146 /* Parameter */: return bindParameter(node); - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: return bindVariableDeclarationOrBindingElement(node); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 275 /* JSDocRecordMember */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 276 /* JSDocRecordMember */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */ | (node.questionToken ? 67108864 /* Optional */ : 0 /* None */), 0 /* PropertyExcludes */); - case 290 /* JSDocPropertyTag */: + case 291 /* JSDocPropertyTag */: return bindJSDocProperty(node); - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* PropertyExcludes */); - case 263 /* EnumMember */: + case 264 /* EnumMember */: return bindPropertyOrMethodOrAccessor(node, 8 /* EnumMember */, 900095 /* EnumMemberExcludes */); - case 262 /* SpreadAssignment */: - case 254 /* JsxSpreadAttribute */: + case 263 /* SpreadAssignment */: + case 255 /* JsxSpreadAttribute */: var root = container; var hasRest = false; while (root.parent) { - if (root.kind === 177 /* ObjectLiteralExpression */ && - root.parent.kind === 193 /* BinaryExpression */ && - root.parent.operatorToken.kind === 57 /* EqualsToken */ && + if (root.kind === 178 /* ObjectLiteralExpression */ && + root.parent.kind === 194 /* BinaryExpression */ && + root.parent.operatorToken.kind === 58 /* EqualsToken */ && root.parent.left === root) { hasRest = true; break; @@ -22629,100 +23235,100 @@ var ts; root = root.parent; } return; - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: return declareSymbolAndAddToSymbolTable(node, 131072 /* Signature */, 0 /* None */); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* 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 ? 67108864 /* Optional */ : 0 /* None */), ts.isObjectLiteralMethod(node) ? 0 /* PropertyExcludes */ : 99263 /* MethodExcludes */); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return bindFunctionDeclaration(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return declareSymbolAndAddToSymbolTable(node, 16384 /* Constructor */, /*symbolExcludes:*/ 0 /* None */); - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: return bindPropertyOrMethodOrAccessor(node, 32768 /* GetAccessor */, 41919 /* GetAccessorExcludes */); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: return bindPropertyOrMethodOrAccessor(node, 65536 /* SetAccessor */, 74687 /* SetAccessorExcludes */); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 278 /* JSDocFunctionType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 279 /* JSDocFunctionType */: return bindFunctionOrConstructorType(node); - case 162 /* TypeLiteral */: - case 171 /* MappedType */: - case 291 /* JSDocTypeLiteral */: - case 274 /* JSDocRecordType */: + case 163 /* TypeLiteral */: + case 172 /* MappedType */: + case 292 /* JSDocTypeLiteral */: + case 275 /* JSDocRecordType */: return bindAnonymousDeclaration(node, 2048 /* TypeLiteral */, "__type"); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return bindObjectLiteralExpression(node); - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return bindFunctionExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: if (ts.isInJavaScriptFile(node)) { bindCallExpression(node); } break; // Members of classes, interfaces, and modules - case 198 /* ClassExpression */: - case 228 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 229 /* ClassDeclaration */: // All classes are automatically in strict mode in ES6. inStrictMode = true; return bindClassLikeDeclaration(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return bindBlockScopedDeclaration(node, 64 /* Interface */, 792968 /* InterfaceExcludes */); - case 289 /* JSDocTypedefTag */: - if (!node.fullName || node.fullName.kind === 70 /* Identifier */) { + case 290 /* JSDocTypedefTag */: + if (!node.fullName || node.fullName.kind === 71 /* Identifier */) { return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); } break; - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return bindBlockScopedDeclaration(node, 524288 /* TypeAlias */, 793064 /* TypeAliasExcludes */); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return bindEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return bindModuleDeclaration(node); // Jsx-attributes - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return bindJsxAttributes(node); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return bindJsxAttribute(node, 4 /* Property */, 0 /* PropertyExcludes */); // Imports and exports - case 236 /* ImportEqualsDeclaration */: - case 239 /* NamespaceImport */: - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 240 /* NamespaceImport */: + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: return declareSymbolAndAddToSymbolTable(node, 8388608 /* Alias */, 8388608 /* AliasExcludes */); - case 235 /* NamespaceExportDeclaration */: + case 236 /* NamespaceExportDeclaration */: return bindNamespaceExportDeclaration(node); - case 238 /* ImportClause */: + case 239 /* ImportClause */: return bindImportClause(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return bindExportDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return bindExportAssignment(node); - case 264 /* SourceFile */: + case 265 /* SourceFile */: updateStrictModeStatementList(node.statements); return bindSourceFileIfExternalModule(); - case 206 /* Block */: + case 207 /* Block */: if (!ts.isFunctionLike(node.parent)) { return; } - // Fall through - case 233 /* ModuleBlock */: + // falls through + case 234 /* ModuleBlock */: return updateStrictModeStatementList(node.statements); } } function checkTypePredicate(node) { var parameterName = node.parameterName, type = node.type; - if (parameterName && parameterName.kind === 70 /* Identifier */) { + if (parameterName && parameterName.kind === 71 /* Identifier */) { checkStrictModeIdentifier(parameterName); } - if (parameterName && parameterName.kind === 168 /* ThisType */) { + if (parameterName && parameterName.kind === 169 /* ThisType */) { seenThisKeyword = true; } bind(type); @@ -22745,7 +23351,7 @@ var ts; // An export default clause with an expression exports a value // We want to exclude both class and function here, this is necessary to issue an error when there are both // default export-assignment and default export function and class declaration. - var flags = node.kind === 242 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) + var flags = node.kind === 243 /* ExportAssignment */ && ts.exportAssignmentIsAlias(node) ? 8388608 /* Alias */ : 4 /* Property */; declareSymbol(container.symbol.exports, container.symbol, node, flags, 4 /* Property */ | 8388608 /* AliasExcludes */ | 32 /* Class */ | 16 /* Function */); @@ -22755,7 +23361,7 @@ var ts; if (node.modifiers && node.modifiers.length) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here)); } - if (node.parent.kind !== 264 /* SourceFile */) { + if (node.parent.kind !== 265 /* SourceFile */) { file.bindDiagnostics.push(ts.createDiagnosticForNode(node, ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level)); return; } @@ -22802,30 +23408,67 @@ var ts; setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node.left, 4 /* Property */ | 7340032 /* Export */, 0 /* None */); } + function isExportsOrModuleExportsOrAlias(node) { + return ts.isExportsIdentifier(node) || + ts.isModuleExportsPropertyAccessExpression(node) || + isNameOfExportsOrModuleExportsAliasDeclaration(node); + } + function isNameOfExportsOrModuleExportsAliasDeclaration(node) { + if (node.kind === 71 /* Identifier */) { + var symbol = lookupSymbolForName(node.text); + if (symbol && symbol.valueDeclaration && symbol.valueDeclaration.kind === 226 /* VariableDeclaration */) { + var declaration = symbol.valueDeclaration; + if (declaration.initializer) { + return isExportsOrModuleExportsOrAliasOrAssignemnt(declaration.initializer); + } + } + } + return false; + } + function isExportsOrModuleExportsOrAliasOrAssignemnt(node) { + return isExportsOrModuleExportsOrAlias(node) || + (ts.isAssignmentExpression(node, /*excludeCompoundAssignements*/ true) && (isExportsOrModuleExportsOrAliasOrAssignemnt(node.left) || isExportsOrModuleExportsOrAliasOrAssignemnt(node.right))); + } function bindModuleExportsAssignment(node) { + // A common practice in node modules is to set 'export = module.exports = {}', this ensures that 'exports' + // is still pointing to 'module.exports'. + // We do not want to consider this as 'export=' since a module can have only one of these. + // Similarlly we do not want to treat 'module.exports = exports' as an 'export='. + var assignedExpression = ts.getRightMostAssignedExpression(node.right); + if (ts.isEmptyObjectLiteral(assignedExpression) || isExportsOrModuleExportsOrAlias(assignedExpression)) { + // Mark it as a module in case there are no other exports in the file + setCommonJsModuleIndicator(node); + return; + } // 'module.exports = expr' assignment setCommonJsModuleIndicator(node); declareSymbol(file.symbol.exports, file.symbol, node, 4 /* Property */ | 7340032 /* Export */ | 512 /* ValueModule */, 0 /* None */); } function bindThisPropertyAssignment(node) { ts.Debug.assert(ts.isInJavaScriptFile(node)); - // Declare a 'member' if the container is an ES5 class or ES6 constructor - if (container.kind === 227 /* FunctionDeclaration */ || container.kind === 185 /* FunctionExpression */) { - container.symbol.members = container.symbol.members || ts.createMap(); - // It's acceptable for multiple 'this' assignments of the same identifier to occur - declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); - } - else if (container.kind === 151 /* Constructor */) { - // this.foo assignment in a JavaScript class - // Bind this property to the containing class - var saveContainer = container; - container = container.parent; - var symbol = bindPropertyOrMethodOrAccessor(node, 4 /* Property */, 0 /* None */); - if (symbol) { - // constructor-declared symbols can be overwritten by subsequent method declarations - symbol.isReplaceableByMethod = true; - } - container = saveContainer; + var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); + switch (container.kind) { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + // Declare a 'member' if the container is an ES5 class or ES6 constructor + container.symbol.members = container.symbol.members || ts.createMap(); + // It's acceptable for multiple 'this' assignments of the same identifier to occur + declareSymbol(container.symbol.members, container.symbol, node, 4 /* Property */, 0 /* PropertyExcludes */ & ~4 /* Property */); + break; + case 152 /* Constructor */: + case 149 /* PropertyDeclaration */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + // this.foo assignment in a JavaScript class + // Bind this property to the containing class + var containingClass = container.parent; + var symbol = declareSymbol(ts.hasModifier(container, 32 /* Static */) ? containingClass.symbol.exports : containingClass.symbol.members, containingClass.symbol, node, 4 /* Property */, 0 /* None */); + if (symbol) { + // symbols declared through 'this' property assignements can be overwritten by subsequent method declarations + symbol.isReplaceableByMethod = true; + } + break; } } function bindPrototypePropertyAssignment(node) { @@ -22839,16 +23482,44 @@ var ts; leftSideOfAssignment.parent = node; constructorFunction.parent = classPrototype; classPrototype.parent = leftSideOfAssignment; - var funcSymbol = container.locals.get(constructorFunction.text); - if (!funcSymbol || !(funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + bindPropertyAssignment(constructorFunction.text, leftSideOfAssignment, /*isPrototypeProperty*/ true); + } + function bindStaticPropertyAssignment(node) { + // We saw a node of the form 'x.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 leftSideOfAssignment = node.left; + var target = leftSideOfAssignment.expression; + // Fix up parent pointers since we're going to use these nodes before we bind into them + leftSideOfAssignment.parent = node; + target.parent = leftSideOfAssignment; + if (isNameOfExportsOrModuleExportsAliasDeclaration(target)) { + // This can be an alias for the 'exports' or 'module.exports' names, e.g. + // var util = module.exports; + // util.property = function ... + bindExportsPropertyAssignment(node); + } + else { + bindPropertyAssignment(target.text, leftSideOfAssignment, /*isPrototypeProperty*/ false); + } + } + function lookupSymbolForName(name) { + return (container.symbol && container.symbol.exports && container.symbol.exports.get(name)) || (container.locals && container.locals.get(name)); + } + function bindPropertyAssignment(functionName, propertyAccessExpression, isPrototypeProperty) { + var targetSymbol = lookupSymbolForName(functionName); + if (targetSymbol && ts.isDeclarationOfFunctionOrClassExpression(targetSymbol)) { + targetSymbol = targetSymbol.valueDeclaration.initializer.symbol; + } + if (!targetSymbol || !(targetSymbol.flags & (16 /* Function */ | 32 /* Class */))) { return; } // Set up the members collection if it doesn't exist already - if (!funcSymbol.members) { - funcSymbol.members = ts.createMap(); - } + var symbolTable = isPrototypeProperty ? + (targetSymbol.members || (targetSymbol.members = ts.createMap())) : + (targetSymbol.exports || (targetSymbol.exports = ts.createMap())); // Declare the method/property - declareSymbol(funcSymbol.members, funcSymbol, leftSideOfAssignment, 4 /* Property */, 0 /* PropertyExcludes */); + declareSymbol(symbolTable, targetSymbol, propertyAccessExpression, 4 /* Property */, 0 /* PropertyExcludes */); } function bindCallExpression(node) { // We're only inspecting call expressions to detect CommonJS modules, so we can skip @@ -22858,7 +23529,7 @@ var ts; } } function bindClassLikeDeclaration(node) { - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* ClassDeclaration */) { bindBlockScopedDeclaration(node, 32 /* Class */, 899519 /* ClassExcludes */); } else { @@ -22941,7 +23612,7 @@ var ts; } function bindFunctionDeclaration(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024 /* HasAsyncFunctions */; } } @@ -22956,7 +23627,7 @@ var ts; } function bindFunctionExpression(node) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024 /* HasAsyncFunctions */; } } @@ -22969,7 +23640,7 @@ var ts; } function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) { if (!ts.isDeclarationFile(file) && !ts.isInAmbientContext(node)) { - if (ts.isAsyncFunctionLike(node)) { + if (ts.isAsyncFunction(node)) { emitFlags |= 1024 /* HasAsyncFunctions */; } } @@ -22995,13 +23666,13 @@ var ts; if (currentFlow === unreachableFlow) { var reportError = // report error on all statements except empty ones - (ts.isStatementButNotDeclaration(node) && node.kind !== 208 /* EmptyStatement */) || + (ts.isStatementButNotDeclaration(node) && node.kind !== 209 /* EmptyStatement */) || // report error on class declarations - node.kind === 228 /* ClassDeclaration */ || + node.kind === 229 /* ClassDeclaration */ || // report error on instantiated modules or const-enums only modules if preserveConstEnums is set - (node.kind === 232 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || + (node.kind === 233 /* ModuleDeclaration */ && shouldReportErrorOnModuleDeclaration(node)) || // report error on regular enums and const enums if preserveConstEnums is set - (node.kind === 231 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); + (node.kind === 232 /* EnumDeclaration */ && (!ts.isConstEnumDeclaration(node) || options.preserveConstEnums)); if (reportError) { currentFlow = reportedUnreachableFlow; // unreachable code is reported if @@ -23015,7 +23686,7 @@ var ts; // On the other side we do want to report errors on non-initialized 'lets' because of TDZ var reportUnreachableCode = !options.allowUnreachableCode && !ts.isInAmbientContext(node) && - (node.kind !== 207 /* VariableStatement */ || + (node.kind !== 208 /* VariableStatement */ || ts.getCombinedNodeFlags(node.declarationList) & 3 /* BlockScoped */ || ts.forEach(node.declarationList.declarations, function (d) { return d.initializer; })); if (reportUnreachableCode) { @@ -23035,56 +23706,56 @@ var ts; function computeTransformFlagsForNode(node, subtreeFlags) { var kind = node.kind; switch (kind) { - case 180 /* CallExpression */: + case 181 /* CallExpression */: return computeCallExpression(node, subtreeFlags); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return computeNewExpression(node, subtreeFlags); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return computeModuleDeclaration(node, subtreeFlags); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return computeParenthesizedExpression(node, subtreeFlags); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return computeBinaryExpression(node, subtreeFlags); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return computeExpressionStatement(node, subtreeFlags); - case 145 /* Parameter */: + case 146 /* Parameter */: return computeParameter(node, subtreeFlags); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return computeArrowFunction(node, subtreeFlags); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return computeFunctionExpression(node, subtreeFlags); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return computeFunctionDeclaration(node, subtreeFlags); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return computeVariableDeclaration(node, subtreeFlags); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return computeVariableDeclarationList(node, subtreeFlags); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return computeVariableStatement(node, subtreeFlags); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return computeLabeledStatement(node, subtreeFlags); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return computeClassDeclaration(node, subtreeFlags); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return computeClassExpression(node, subtreeFlags); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: return computeHeritageClause(node, subtreeFlags); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return computeCatchClause(node, subtreeFlags); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return computeExpressionWithTypeArguments(node, subtreeFlags); - case 151 /* Constructor */: + case 152 /* Constructor */: return computeConstructor(node, subtreeFlags); - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return computePropertyDeclaration(node, subtreeFlags); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return computeMethod(node, subtreeFlags); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return computeAccessor(node, subtreeFlags); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return computeImportEquals(node, subtreeFlags); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return computePropertyAccess(node, subtreeFlags); default: return computeOther(node, kind, subtreeFlags); @@ -23109,13 +23780,13 @@ var ts; } function isSuperOrSuperProperty(node, kind) { switch (kind) { - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: return true; - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: var expression = node.expression; var expressionKind = expression.kind; - return expressionKind === 96 /* SuperKeyword */; + return expressionKind === 97 /* SuperKeyword */; } return false; } @@ -23136,17 +23807,17 @@ var ts; var transformFlags = subtreeFlags; var operatorTokenKind = node.operatorToken.kind; var leftKind = node.left.kind; - if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 177 /* ObjectLiteralExpression */) { + if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 178 /* ObjectLiteralExpression */) { // Destructuring object assignments with are ES2015 syntax // and possibly ESNext if they contain rest transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 57 /* EqualsToken */ && leftKind === 176 /* ArrayLiteralExpression */) { + else if (operatorTokenKind === 58 /* EqualsToken */ && leftKind === 177 /* ArrayLiteralExpression */) { // Destructuring assignments are ES2015 syntax. transformFlags |= 192 /* AssertES2015 */ | 3072 /* AssertDestructuringAssignment */; } - else if (operatorTokenKind === 39 /* AsteriskAsteriskToken */ - || operatorTokenKind === 61 /* AsteriskAsteriskEqualsToken */) { + else if (operatorTokenKind === 40 /* AsteriskAsteriskToken */ + || operatorTokenKind === 62 /* AsteriskAsteriskEqualsToken */) { // Exponentiation is ES2016 syntax. transformFlags |= 32 /* AssertES2016 */; } @@ -23191,8 +23862,8 @@ 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 (expressionKind === 201 /* AsExpression */ - || expressionKind === 183 /* TypeAssertionExpression */) { + if (expressionKind === 202 /* AsExpression */ + || expressionKind === 184 /* TypeAssertionExpression */) { transformFlags |= 3 /* AssertTypeScript */; } // If the expression of a ParenthesizedExpression is a destructuring assignment, @@ -23250,11 +23921,11 @@ var ts; function computeHeritageClause(node, subtreeFlags) { var transformFlags = subtreeFlags; switch (node.token) { - case 84 /* ExtendsKeyword */: + case 85 /* ExtendsKeyword */: // An `extends` HeritageClause is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 107 /* ImplementsKeyword */: + case 108 /* ImplementsKeyword */: // An `implements` HeritageClause is TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; @@ -23317,10 +23988,9 @@ var ts; } // An async method declaration is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 16 /* AssertES2017 */; + transformFlags |= node.asteriskToken ? 8 /* AssertESNext */ : 16 /* AssertES2017 */; } - // Currently, we only support generators that were originally async function bodies. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { transformFlags |= 768 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -23374,7 +24044,7 @@ var ts; } // An async function declaration is ES2017 syntax. if (modifierFlags & 256 /* Async */) { - transformFlags |= 16 /* AssertES2017 */; + transformFlags |= node.asteriskToken ? 8 /* AssertESNext */ : 16 /* AssertES2017 */; } // function declarations with object rest destructuring are ES Next syntax if (subtreeFlags & 1048576 /* ContainsObjectRest */) { @@ -23391,7 +24061,7 @@ var ts; // down-level generator. // Currently we do not support transforming any other generator fucntions // down level. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { transformFlags |= 768 /* AssertGenerator */; } } @@ -23409,7 +24079,7 @@ var ts; } // An async function expression is ES2017 syntax. if (ts.hasModifier(node, 256 /* Async */)) { - transformFlags |= 16 /* AssertES2017 */; + transformFlags |= node.asteriskToken ? 8 /* AssertESNext */ : 16 /* AssertES2017 */; } // function expressions with object rest destructuring are ES Next syntax if (subtreeFlags & 1048576 /* ContainsObjectRest */) { @@ -23424,9 +24094,7 @@ var ts; // If a FunctionExpression is generator function and is the body of a // transformed async function, then this node can be transformed to a // down-level generator. - // Currently we do not support transforming any other generator fucntions - // down level. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { transformFlags |= 768 /* AssertGenerator */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -23463,7 +24131,7 @@ var ts; var expressionKind = expression.kind; // If a PropertyAccessExpression starts with a super keyword, then it is // ES6 syntax, and requires a lexical `this` binding. - if (expressionKind === 96 /* SuperKeyword */) { + if (expressionKind === 97 /* SuperKeyword */) { transformFlags |= 16384 /* ContainsLexicalThis */; } node.transformFlags = transformFlags | 536870912 /* HasComputedFlags */; @@ -23556,95 +24224,109 @@ var ts; var transformFlags = subtreeFlags; var excludeFlags = 536872257 /* NodeExcludes */; switch (kind) { - case 119 /* AsyncKeyword */: - case 190 /* AwaitExpression */: - // async/await is ES2017 syntax - transformFlags |= 16 /* AssertES2017 */; + case 120 /* AsyncKeyword */: + case 191 /* AwaitExpression */: + // async/await is ES2017 syntax, but may be ESNext syntax (for async generators) + transformFlags |= 8 /* AssertESNext */ | 16 /* AssertES2017 */; break; - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 116 /* AbstractKeyword */: - case 123 /* DeclareKeyword */: - case 75 /* ConstKeyword */: - case 231 /* EnumDeclaration */: - case 263 /* EnumMember */: - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: - case 202 /* NonNullExpression */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 117 /* AbstractKeyword */: + case 124 /* DeclareKeyword */: + case 76 /* ConstKeyword */: + case 232 /* EnumDeclaration */: + case 264 /* EnumMember */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: + case 203 /* NonNullExpression */: + case 131 /* ReadonlyKeyword */: // These nodes are TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */; break; - case 248 /* JsxElement */: - case 249 /* JsxSelfClosingElement */: - case 250 /* JsxOpeningElement */: + case 249 /* JsxElement */: + case 250 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: case 10 /* JsxText */: - case 251 /* JsxClosingElement */: - case 252 /* JsxAttribute */: - case 253 /* JsxAttributes */: - case 254 /* JsxSpreadAttribute */: - case 255 /* JsxExpression */: + case 252 /* JsxClosingElement */: + case 253 /* JsxAttribute */: + case 254 /* JsxAttributes */: + case 255 /* JsxSpreadAttribute */: + case 256 /* JsxExpression */: // These nodes are Jsx syntax. transformFlags |= 4 /* AssertJsx */; break; - case 215 /* ForOfStatement */: - // for-of might be ESNext if it has a rest destructuring - transformFlags |= 8 /* AssertESNext */; - // FALLTHROUGH - case 12 /* NoSubstitutionTemplateLiteral */: - case 13 /* TemplateHead */: - case 14 /* TemplateMiddle */: - case 15 /* TemplateTail */: - case 195 /* TemplateExpression */: - case 182 /* TaggedTemplateExpression */: - case 261 /* ShorthandPropertyAssignment */: - case 114 /* StaticKeyword */: - case 203 /* MetaProperty */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* TemplateHead */: + case 15 /* TemplateMiddle */: + case 16 /* TemplateTail */: + case 196 /* TemplateExpression */: + case 183 /* TaggedTemplateExpression */: + case 262 /* ShorthandPropertyAssignment */: + case 115 /* StaticKeyword */: + case 204 /* MetaProperty */: // These nodes are ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 196 /* YieldExpression */: - // This node is ES6 syntax. - transformFlags |= 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; + case 9 /* StringLiteral */: + if (node.hasExtendedUnicodeEscape) { + transformFlags |= 192 /* AssertES2015 */; + } break; - case 118 /* AnyKeyword */: - case 132 /* NumberKeyword */: - case 129 /* NeverKeyword */: - case 133 /* ObjectKeyword */: - case 135 /* StringKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 144 /* TypeParameter */: - case 147 /* PropertySignature */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 157 /* TypePredicate */: - case 158 /* TypeReference */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 161 /* TypeQuery */: - case 162 /* TypeLiteral */: - case 163 /* ArrayType */: - case 164 /* TupleType */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: - case 167 /* ParenthesizedType */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 168 /* ThisType */: - case 169 /* TypeOperator */: - case 170 /* IndexedAccessType */: - case 171 /* MappedType */: - case 172 /* LiteralType */: + case 8 /* NumericLiteral */: + if (node.numericLiteralFlags & 48 /* BinaryOrOctalSpecifier */) { + transformFlags |= 192 /* AssertES2015 */; + } + break; + case 216 /* ForOfStatement */: + // This node is either ES2015 syntax or ES2017 syntax (if it is a for-await-of). + if (node.awaitModifier) { + transformFlags |= 8 /* AssertESNext */; + } + transformFlags |= 192 /* AssertES2015 */; + break; + case 197 /* YieldExpression */: + // This node is either ES2015 syntax (in a generator) or ES2017 syntax (in an async + // generator). + transformFlags |= 8 /* AssertESNext */ | 192 /* AssertES2015 */ | 16777216 /* ContainsYield */; + break; + case 119 /* AnyKeyword */: + case 133 /* NumberKeyword */: + case 130 /* NeverKeyword */: + case 134 /* ObjectKeyword */: + case 136 /* StringKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 145 /* TypeParameter */: + case 148 /* PropertySignature */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 158 /* TypePredicate */: + case 159 /* TypeReference */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 162 /* TypeQuery */: + case 163 /* TypeLiteral */: + case 164 /* ArrayType */: + case 165 /* TupleType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: + case 168 /* ParenthesizedType */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 169 /* ThisType */: + case 170 /* TypeOperator */: + case 171 /* IndexedAccessType */: + case 172 /* MappedType */: + case 173 /* LiteralType */: // Types and signatures are TypeScript syntax, and exclude all other facts. transformFlags = 3 /* AssertTypeScript */; excludeFlags = -3 /* TypeExcludes */; break; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: // Even though computed property names are ES6, we don't treat them as such. // This is so that they can flow through PropertyName transforms unaffected. // Instead, we mark the container as ES6, so that it can properly handle the transform. @@ -23661,42 +24343,42 @@ var ts; transformFlags |= 65536 /* ContainsLexicalThisInComputedPropertyName */; } break; - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: transformFlags |= 192 /* AssertES2015 */ | 524288 /* ContainsSpread */; break; - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectSpread */; break; - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: // This node is ES6 syntax. transformFlags |= 192 /* AssertES2015 */; break; - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: // Mark this node and its ancestors as containing a lexical `this` keyword. transformFlags |= 16384 /* ContainsLexicalThis */; break; - case 173 /* ObjectBindingPattern */: + case 174 /* ObjectBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; if (subtreeFlags & 524288 /* ContainsRest */) { transformFlags |= 8 /* AssertESNext */ | 1048576 /* ContainsObjectRest */; } excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 174 /* ArrayBindingPattern */: + case 175 /* ArrayBindingPattern */: transformFlags |= 192 /* AssertES2015 */ | 8388608 /* ContainsBindingPattern */; excludeFlags = 537396545 /* BindingPatternExcludes */; break; - case 175 /* BindingElement */: + case 176 /* BindingElement */: transformFlags |= 192 /* AssertES2015 */; if (node.dotDotDotToken) { transformFlags |= 524288 /* ContainsRest */; } break; - case 146 /* Decorator */: + case 147 /* Decorator */: // This node is TypeScript syntax, and marks its container as also being TypeScript syntax. transformFlags |= 3 /* AssertTypeScript */ | 4096 /* ContainsDecorators */; break; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: excludeFlags = 540087617 /* ObjectLiteralExcludes */; if (subtreeFlags & 2097152 /* ContainsComputedPropertyName */) { // If an ObjectLiteralExpression contains a ComputedPropertyName, then it @@ -23714,8 +24396,8 @@ var ts; transformFlags |= 8 /* AssertESNext */; } break; - case 176 /* ArrayLiteralExpression */: - case 181 /* NewExpression */: + case 177 /* ArrayLiteralExpression */: + case 182 /* NewExpression */: excludeFlags = 537396545 /* ArrayLiteralOrCallOrNewExcludes */; if (subtreeFlags & 524288 /* ContainsSpread */) { // If the this node contains a SpreadExpression, then it is an ES6 @@ -23723,23 +24405,23 @@ var ts; transformFlags |= 192 /* AssertES2015 */; } break; - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: // A loop containing a block scoped binding *may* need to be transformed from ES6. if (subtreeFlags & 4194304 /* ContainsBlockScopedBinding */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (subtreeFlags & 32768 /* ContainsCapturedLexicalThis */) { transformFlags |= 192 /* AssertES2015 */; } break; - case 218 /* ReturnStatement */: - case 216 /* ContinueStatement */: - case 217 /* BreakStatement */: + case 219 /* ReturnStatement */: + case 217 /* ContinueStatement */: + case 218 /* BreakStatement */: transformFlags |= 33554432 /* ContainsHoistedDeclarationOrCompletion */; break; } @@ -23755,57 +24437,57 @@ var ts; */ /* @internal */ function getTransformFlagsSubtreeExclusions(kind) { - if (kind >= 157 /* FirstTypeNode */ && kind <= 172 /* LastTypeNode */) { + if (kind >= 158 /* FirstTypeNode */ && kind <= 173 /* LastTypeNode */) { return -3 /* TypeExcludes */; } switch (kind) { - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 176 /* ArrayLiteralExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 177 /* ArrayLiteralExpression */: return 537396545 /* ArrayLiteralOrCallOrNewExcludes */; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return 574674241 /* ModuleExcludes */; - case 145 /* Parameter */: + case 146 /* Parameter */: return 536872257 /* ParameterExcludes */; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return 601249089 /* ArrowFunctionExcludes */; - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: return 601281857 /* FunctionExcludes */; - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return 546309441 /* VariableDeclarationListExcludes */; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return 539358529 /* ClassExcludes */; - case 151 /* Constructor */: + case 152 /* Constructor */: return 601015617 /* ConstructorExcludes */; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return 601015617 /* MethodOrAccessorExcludes */; - case 118 /* AnyKeyword */: - case 132 /* NumberKeyword */: - case 129 /* NeverKeyword */: - case 135 /* StringKeyword */: - case 133 /* ObjectKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 144 /* TypeParameter */: - case 147 /* PropertySignature */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 119 /* AnyKeyword */: + case 133 /* NumberKeyword */: + case 130 /* NeverKeyword */: + case 136 /* StringKeyword */: + case 134 /* ObjectKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 145 /* TypeParameter */: + case 148 /* PropertySignature */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: return -3 /* TypeExcludes */; - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return 540087617 /* ObjectLiteralExcludes */; - case 259 /* CatchClause */: + case 260 /* CatchClause */: return 537920833 /* CatchClauseExcludes */; - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: return 537396545 /* BindingPatternExcludes */; default: return 536872257 /* NodeExcludes */; @@ -23917,7 +24599,7 @@ var ts; // And if it doesn't exist, tough. } var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) { var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -24020,13 +24702,13 @@ var ts; } ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective; /** - * Given a set of options, returns the set of type directive names - * that should be included for this program automatically. - * This list could either come from the config file, - * or from enumerating the types root + initial secondary types lookup location. - * More type directives might appear in the program later as a result of loading actual source files; - * this list is only the set of defaults that are implicitly included. - */ + * Given a set of options, returns the set of type directive names + * that should be included for this program automatically. + * This list could either come from the config file, + * or from enumerating the types root + initial secondary types lookup location. + * More type directives might appear in the program later as a result of loading actual source files; + * this list is only the set of defaults that are implicitly included. + */ function getAutomaticTypeDirectiveNames(options, host) { // Use explicit type list from tsconfig.json if (options.types) { @@ -24120,7 +24802,7 @@ var ts; } directoryPathMap.set(parent, result); current = parent; - if (current == commonPrefix) { + if (current === commonPrefix) { break; } } @@ -24380,7 +25062,7 @@ var ts; } } function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache) { - return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /* jsOnly*/ false); + return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false); } ts.nodeModuleNameResolver = nodeModuleNameResolver; /* @internal */ @@ -24634,9 +25316,23 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } + /** For a scoped package, we must look in `@types/foo__bar` instead of `@types/@foo/bar`. */ + function mangleScopedPackage(moduleName, state) { + if (ts.startsWith(moduleName, "@")) { + var replaceSlash = moduleName.replace(ts.directorySeparator, "__"); + if (replaceSlash !== moduleName) { + var mangled = replaceSlash.slice(1); // Take off the "@" + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled); + } + return mangled; + } + } + return moduleName; + } function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { var result = cache && cache.get(containingDirectory); if (result) { @@ -24766,18 +25462,27 @@ var ts; var Signature = ts.objectAllocator.getSignatureConstructor(); var typeCount = 0; var symbolCount = 0; + var symbolInstantiationDepth = 0; var emptyArray = []; var emptySymbols = ts.createMap(); var compilerOptions = host.getCompilerOptions(); - var languageVersion = compilerOptions.target || 0 /* ES3 */; + var languageVersion = ts.getEmitScriptTarget(compilerOptions); var modulekind = ts.getEmitModuleKind(compilerOptions); var noUnusedIdentifiers = !!compilerOptions.noUnusedLocals || !!compilerOptions.noUnusedParameters; var allowSyntheticDefaultImports = typeof compilerOptions.allowSyntheticDefaultImports !== "undefined" ? compilerOptions.allowSyntheticDefaultImports : modulekind === ts.ModuleKind.System; - var strictNullChecks = compilerOptions.strictNullChecks; + var strictNullChecks = compilerOptions.strictNullChecks === undefined ? compilerOptions.strict : compilerOptions.strictNullChecks; + var noImplicitAny = compilerOptions.noImplicitAny === undefined ? compilerOptions.strict : compilerOptions.noImplicitAny; + var noImplicitThis = compilerOptions.noImplicitThis === undefined ? compilerOptions.strict : compilerOptions.noImplicitThis; var emitResolver = createResolver(); + var nodeBuilder = createNodeBuilder(); var undefinedSymbol = createSymbol(4 /* Property */, "undefined"); undefinedSymbol.declarations = []; var argumentsSymbol = createSymbol(4 /* Property */, "arguments"); + // for public members that accept a Node or one of its subtypes, we must guard against + // synthetic nodes created during transformations by calling `getParseTreeNode`. + // for most of these, we perform the guard only on `checker` to avoid any possible + // extra cost of calling `getParseTreeNode` when calling these functions from inside the + // checker. var checker = { getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); }, getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); }, @@ -24786,10 +25491,18 @@ var ts; isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; }, isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; }, isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; }, + getMergedSymbol: getMergedSymbol, getDiagnostics: getDiagnostics, getGlobalDiagnostics: getGlobalDiagnostics, - getTypeOfSymbolAtLocation: getTypeOfSymbolAtLocation, - getSymbolsOfParameterPropertyDeclaration: getSymbolsOfParameterPropertyDeclaration, + getTypeOfSymbolAtLocation: function (symbol, location) { + location = ts.getParseTreeNode(location); + return location ? getTypeOfSymbolAtLocation(symbol, location) : unknownType; + }, + getSymbolsOfParameterPropertyDeclaration: function (parameter, parameterName) { + parameter = ts.getParseTreeNode(parameter, ts.isParameter); + ts.Debug.assert(parameter !== undefined, "Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node."); + return getSymbolsOfParameterPropertyDeclaration(parameter, parameterName); + }, getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol, getPropertiesOfType: getPropertiesOfType, getPropertyOfType: getPropertyOfType, @@ -24797,37 +25510,103 @@ var ts; getSignaturesOfType: getSignaturesOfType, getIndexTypeOfType: getIndexTypeOfType, getBaseTypes: getBaseTypes, - getTypeFromTypeNode: getTypeFromTypeNode, + getBaseTypeOfLiteralType: getBaseTypeOfLiteralType, + getWidenedType: getWidenedType, + getTypeFromTypeNode: function (node) { + node = ts.getParseTreeNode(node, ts.isTypeNode); + return node ? getTypeFromTypeNode(node) : unknownType; + }, getParameterType: getTypeAtPosition, getReturnTypeOfSignature: getReturnTypeOfSignature, getNonNullableType: getNonNullableType, - getSymbolsInScope: getSymbolsInScope, - getSymbolAtLocation: getSymbolAtLocation, - getShorthandAssignmentValueSymbol: getShorthandAssignmentValueSymbol, - getExportSpecifierLocalTargetSymbol: getExportSpecifierLocalTargetSymbol, - getTypeAtLocation: getTypeOfNode, - getPropertySymbolOfDestructuringAssignment: getPropertySymbolOfDestructuringAssignment, - signatureToString: signatureToString, - typeToString: typeToString, + typeToTypeNode: nodeBuilder.typeToTypeNode, + indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration, + signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration, + getSymbolsInScope: function (location, meaning) { + location = ts.getParseTreeNode(location); + return location ? getSymbolsInScope(location, meaning) : []; + }, + getSymbolAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getSymbolAtLocation(node) : undefined; + }, + getShorthandAssignmentValueSymbol: function (node) { + node = ts.getParseTreeNode(node); + return node ? getShorthandAssignmentValueSymbol(node) : undefined; + }, + getExportSpecifierLocalTargetSymbol: function (node) { + node = ts.getParseTreeNode(node, ts.isExportSpecifier); + return node ? getExportSpecifierLocalTargetSymbol(node) : undefined; + }, + getTypeAtLocation: function (node) { + node = ts.getParseTreeNode(node); + return node ? getTypeOfNode(node) : unknownType; + }, + getPropertySymbolOfDestructuringAssignment: function (location) { + location = ts.getParseTreeNode(location, ts.isIdentifier); + return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined; + }, + signatureToString: function (signature, enclosingDeclaration, flags, kind) { + return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind); + }, + typeToString: function (type, enclosingDeclaration, flags) { + return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags); + }, getSymbolDisplayBuilder: getSymbolDisplayBuilder, - symbolToString: symbolToString, + symbolToString: function (symbol, enclosingDeclaration, meaning) { + return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning); + }, getAugmentedPropertiesOfType: getAugmentedPropertiesOfType, getRootSymbols: getRootSymbols, - getContextualType: getContextualType, + getContextualType: function (node) { + node = ts.getParseTreeNode(node, ts.isExpression); + return node ? getContextualType(node) : undefined; + }, getFullyQualifiedName: getFullyQualifiedName, - getResolvedSignature: getResolvedSignature, - getConstantValue: getConstantValue, - isValidPropertyAccess: isValidPropertyAccess, - getSignatureFromDeclaration: getSignatureFromDeclaration, - isImplementationOfOverload: isImplementationOfOverload, + getResolvedSignature: function (node, candidatesOutArray) { + node = ts.getParseTreeNode(node, ts.isCallLikeExpression); + return node ? getResolvedSignature(node, candidatesOutArray) : undefined; + }, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, + isValidPropertyAccess: function (node, propertyName) { + node = ts.getParseTreeNode(node, ts.isPropertyAccessOrQualifiedName); + return node ? isValidPropertyAccess(node, propertyName) : false; + }, + getSignatureFromDeclaration: function (declaration) { + declaration = ts.getParseTreeNode(declaration, ts.isFunctionLike); + return declaration ? getSignatureFromDeclaration(declaration) : undefined; + }, + isImplementationOfOverload: function (node) { + node = ts.getParseTreeNode(node, ts.isFunctionLike); + return node ? isImplementationOfOverload(node) : undefined; + }, + getImmediateAliasedSymbol: function (symbol) { + ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); + var links = getSymbolLinks(symbol); + if (!links.immediateTarget) { + var node = getDeclarationOfAliasSymbol(symbol); + ts.Debug.assert(!!node); + links.immediateTarget = getTargetOfAliasDeclaration(node, /*dontRecursivelyResolve*/ true); + } + return links.immediateTarget; + }, getAliasedSymbol: resolveAlias, getEmitResolver: getEmitResolver, getExportsOfModule: getExportsOfModuleAsArray, getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule, getAmbientModules: getAmbientModules, - getAllAttributesTypeFromJsxOpeningLikeElement: getAllAttributesTypeFromJsxOpeningLikeElement, + getAllAttributesTypeFromJsxOpeningLikeElement: function (node) { + node = ts.getParseTreeNode(node, ts.isJsxOpeningLikeElement); + return node ? getAllAttributesTypeFromJsxOpeningLikeElement(node) : undefined; + }, getJsxIntrinsicTagNames: getJsxIntrinsicTagNames, - isOptionalParameter: isOptionalParameter, + isOptionalParameter: function (node) { + node = ts.getParseTreeNode(node, ts.isParameter); + return node ? isOptionalParameter(node) : false; + }, tryGetMemberInModuleExports: tryGetMemberInModuleExports, tryFindAmbientModuleWithoutAugmentations: function (moduleName) { // we deliberately exclude augmentations @@ -24879,16 +25658,14 @@ var ts; var resolvingSignature = createSignature(undefined, undefined, undefined, emptyArray, anyType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var silentNeverSignature = createSignature(undefined, undefined, undefined, emptyArray, silentNeverType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false); var enumNumberIndexInfo = createIndexInfo(stringType, /*isReadonly*/ true); + var jsObjectLiteralIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); var globals = ts.createMap(); /** * List of every ambient module with a "*" wildcard. * Unlike other ambient modules, these can't be stored in `globals` because symbol tables only deal with exact matches. * This is only used if there is no exact match. - */ + */ var patternAmbientModules; - var getGlobalESSymbolConstructorSymbol; - var getGlobalPromiseConstructorSymbol; - var tryGetGlobalPromiseConstructorSymbol; var globalObjectType; var globalFunctionType; var globalArrayType; @@ -24897,29 +25674,29 @@ var ts; var globalNumberType; var globalBooleanType; var globalRegExpType; + var globalThisType; var anyArrayType; var autoArrayType; var anyReadonlyArrayType; // The library files are only loaded when the feature is used. // This allows users to just specify library files they want to used through --lib // and they will not get an error from not having unrelated library files - var getGlobalTemplateStringsArrayType; - var getGlobalESSymbolType; - var getGlobalIterableType; - var getGlobalIteratorType; - var getGlobalIterableIteratorType; - var getGlobalClassDecoratorType; - var getGlobalParameterDecoratorType; - var getGlobalPropertyDecoratorType; - var getGlobalMethodDecoratorType; - var getGlobalTypedPropertyDescriptorType; - var getGlobalPromiseType; - var tryGetGlobalPromiseType; - var getGlobalPromiseLikeType; - var getInstantiatedGlobalPromiseLikeType; - var getGlobalPromiseConstructorLikeType; - var getGlobalThenableType; - var jsxElementClassType; + var deferredGlobalESSymbolConstructorSymbol; + var deferredGlobalESSymbolType; + var deferredGlobalTypedPropertyDescriptorType; + var deferredGlobalPromiseType; + var deferredGlobalPromiseConstructorSymbol; + var deferredGlobalPromiseConstructorLikeType; + var deferredGlobalIterableType; + var deferredGlobalIteratorType; + var deferredGlobalIterableIteratorType; + var deferredGlobalAsyncIterableType; + var deferredGlobalAsyncIteratorType; + var deferredGlobalAsyncIterableIteratorType; + var deferredGlobalTemplateStringsArrayType; + var deferredJsxElementClassType; + var deferredJsxElementType; + var deferredJsxStatelessElementType; var deferredNodes; var deferredUnusedIdentifierNodes; var flowLoopStart = 0; @@ -25032,9 +25809,12 @@ var ts; "undefined": undefinedType }); var typeofType = createTypeofType(); - var jsxElementType; var _jsxNamespace; var _jsxFactoryEntity; + var _jsxElementPropertiesName; + var _hasComputedJsxElementPropertiesName = false; + var _jsxElementChildrenPropertyName; + var _hasComputedJsxElementChildrenPropertyName = false; /** Things we lazy load from the JSX namespace */ var jsxTypes = ts.createMap(); var JsxNames = { @@ -25042,6 +25822,7 @@ var ts; IntrinsicElements: "IntrinsicElements", ElementClass: "ElementClass", ElementAttributesPropertyNameContainer: "ElementAttributesProperty", + ElementChildrenAttributeNameContainer: "ElementChildrenAttribute", Element: "Element", IntrinsicAttributes: "IntrinsicAttributes", IntrinsicClassAttributes: "IntrinsicClassAttributes" @@ -25060,12 +25841,18 @@ var ts; TypeSystemPropertyName[TypeSystemPropertyName["DeclaredType"] = 2] = "DeclaredType"; TypeSystemPropertyName[TypeSystemPropertyName["ResolvedReturnType"] = 3] = "ResolvedReturnType"; })(TypeSystemPropertyName || (TypeSystemPropertyName = {})); + var CheckMode; + (function (CheckMode) { + CheckMode[CheckMode["Normal"] = 0] = "Normal"; + CheckMode[CheckMode["SkipContextSensitive"] = 1] = "SkipContextSensitive"; + CheckMode[CheckMode["Inferential"] = 2] = "Inferential"; + })(CheckMode || (CheckMode = {})); var builtinGlobals = ts.createMap(); builtinGlobals.set(undefinedSymbol.name, undefinedSymbol); initializeTypeChecker(); return checker; function getJsxNamespace() { - if (_jsxNamespace === undefined) { + if (!_jsxNamespace) { _jsxNamespace = "React"; if (compilerOptions.jsxFactory) { _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion); @@ -25097,6 +25884,9 @@ var ts; symbol.checkFlags = 0; return symbol; } + function isTransientSymbol(symbol) { + return (symbol.flags & 134217728 /* Transient */) !== 0; + } function getExcludedSymbolFlags(flags) { var result = 0; if (flags & 2 /* BlockScopedVariable */) @@ -25164,7 +25954,7 @@ var ts; target.flags |= source.flags; if (source.valueDeclaration && (!target.valueDeclaration || - (target.valueDeclaration.kind === 232 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 232 /* ModuleDeclaration */))) { + (target.valueDeclaration.kind === 233 /* ModuleDeclaration */ && source.valueDeclaration.kind !== 233 /* ModuleDeclaration */))) { // other kinds of value declarations take precedence over modules target.valueDeclaration = source.valueDeclaration; } @@ -25182,7 +25972,7 @@ var ts; recordMergedSymbol(target, source); } else if (target.flags & 1024 /* NamespaceModule */) { - error(source.valueDeclaration.name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(source.declarations[0].name, ts.Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { var message_2 = target.flags & 2 /* BlockScopedVariable */ || source.flags & 2 /* BlockScopedVariable */ @@ -25277,7 +26067,7 @@ var ts; return symbol.flags & 134217728 /* Transient */ ? symbol.checkFlags : 0; } function isGlobalSourceFile(node) { - return node.kind === 264 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); + return node.kind === 265 /* SourceFile */ && !ts.isExternalOrCommonJsModule(node); } function getSymbol(symbols, name, meaning) { if (meaning) { @@ -25320,12 +26110,12 @@ var ts; if (declarationFile !== useFile) { if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || (!compilerOptions.outFile && !compilerOptions.out)) { - // nodes are in different files and order cannot be determines + // nodes are in different files and order cannot be determined return true; } // declaration is after usage // can be legal if usage is deferred (i.e. inside function or in initializer of instance property) - if (isUsedInFunctionOrInstanceProperty(usage)) { + if (isUsedInFunctionOrInstanceProperty(usage, declaration)) { return true; } var sourceFiles = host.getSourceFiles(); @@ -25333,34 +26123,41 @@ var ts; } if (declaration.pos <= usage.pos) { // declaration is before usage - if (declaration.kind === 175 /* BindingElement */) { + if (declaration.kind === 176 /* BindingElement */) { // still might be illegal if declaration and usage are both binding elements (eg var [a = b, b = b] = [1, 2]) - var errorBindingElement = ts.getAncestor(usage, 175 /* BindingElement */); + var errorBindingElement = ts.getAncestor(usage, 176 /* BindingElement */); if (errorBindingElement) { - return getAncestorBindingPattern(errorBindingElement) !== getAncestorBindingPattern(declaration) || + return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) || declaration.pos < errorBindingElement.pos; } // or it might be illegal if usage happens before parent variable is declared (eg var [a] = a) - return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 225 /* VariableDeclaration */), usage); + return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 226 /* VariableDeclaration */), usage); } - else if (declaration.kind === 225 /* VariableDeclaration */) { + else if (declaration.kind === 226 /* VariableDeclaration */) { // still might be illegal if usage is in the initializer of the variable declaration (eg var a = a) return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage); } return true; } // declaration is after usage, but it can still be legal if usage is deferred: - // 1. inside a function - // 2. inside an instance property initializer, a reference to a non-instance property + // 1. inside an export specifier + // 2. inside a function + // 3. inside an instance property initializer, a reference to a non-instance property + // 4. inside a static property initializer, a reference to a static method in the same class + // or if usage is in a type context: + // 1. inside a type query (typeof in type position) + if (usage.parent.kind === 246 /* ExportSpecifier */) { + // export specifiers do not use the variable, they only make it available for use + return true; + } var container = ts.getEnclosingBlockScopeContainer(declaration); - var isInstanceProperty = declaration.kind === 148 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); - return isUsedInFunctionOrInstanceProperty(usage, isInstanceProperty, container); + return isInTypeQuery(usage) || isUsedInFunctionOrInstanceProperty(usage, declaration, container); function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) { var container = ts.getEnclosingBlockScopeContainer(declaration); switch (declaration.parent.parent.kind) { - case 207 /* VariableStatement */: - case 213 /* ForStatement */: - case 215 /* ForOfStatement */: + case 208 /* VariableStatement */: + case 214 /* ForStatement */: + case 216 /* ForOfStatement */: // variable statement/for/for-of statement case, // use site should not be inside variable declaration (initializer of declaration or binding element) if (isSameScopeDescendentOf(usage, declaration, container)) { @@ -25369,8 +26166,8 @@ var ts; break; } switch (declaration.parent.parent.kind) { - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: // ForIn/ForOf case - use site should not be used in expression part if (isSameScopeDescendentOf(usage, declaration.parent.parent.expression, container)) { return true; @@ -25378,34 +26175,31 @@ var ts; } return false; } - function isUsedInFunctionOrInstanceProperty(usage, isDeclarationInstanceProperty, container) { - var current = usage; - while (current) { + function isUsedInFunctionOrInstanceProperty(usage, declaration, container) { + return !!ts.findAncestor(usage, function (current) { if (current === container) { - return false; + return "quit"; } if (ts.isFunctionLike(current)) { return true; } - var initializerOfInstanceProperty = current.parent && - current.parent.kind === 148 /* PropertyDeclaration */ && - (ts.getModifierFlags(current.parent) & 32 /* Static */) === 0 && + var initializerOfProperty = current.parent && + current.parent.kind === 149 /* PropertyDeclaration */ && current.parent.initializer === current; - if (initializerOfInstanceProperty) { - return !isDeclarationInstanceProperty; + if (initializerOfProperty) { + if (ts.getModifierFlags(current.parent) & 32 /* Static */) { + if (declaration.kind === 151 /* MethodDeclaration */) { + return true; + } + } + else { + var isDeclarationInstanceProperty = declaration.kind === 149 /* PropertyDeclaration */ && !(ts.getModifierFlags(declaration) & 32 /* Static */); + if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) { + return true; + } + } } - current = current.parent; - } - return false; - } - function getAncestorBindingPattern(node) { - while (node) { - if (ts.isBindingPattern(node)) { - return node; - } - node = node.parent; - } - return undefined; + }); } } // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and @@ -25430,11 +26224,11 @@ var ts; // - parameters are only in the scope of function body // 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 & 793064 /* Type */ && lastLocation.kind !== 282 /* JSDocComment */) { + if (meaning & result.flags & 793064 /* Type */ && lastLocation.kind !== 283 /* JSDocComment */) { useResult = result.flags & 262144 /* TypeParameter */ ? lastLocation === location.type || - lastLocation.kind === 145 /* Parameter */ || - lastLocation.kind === 144 /* TypeParameter */ + lastLocation.kind === 146 /* Parameter */ || + lastLocation.kind === 145 /* TypeParameter */ : false; } if (meaning & 107455 /* Value */ && result.flags & 1 /* FunctionScopedVariable */) { @@ -25443,9 +26237,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 === 145 /* Parameter */ || + lastLocation.kind === 146 /* Parameter */ || (lastLocation === location.type && - result.valueDeclaration.kind === 145 /* Parameter */); + result.valueDeclaration.kind === 146 /* Parameter */); } } if (useResult) { @@ -25457,13 +26251,14 @@ var ts; } } switch (location.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) break; isInExternalModule = true; - case 232 /* ModuleDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: var moduleExports = getSymbolOfNode(location).exports; - if (location.kind === 264 /* SourceFile */ || ts.isAmbientModule(location)) { + if (location.kind === 265 /* 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.get("default")) { @@ -25487,7 +26282,7 @@ var ts; var moduleExport = moduleExports.get(name); if (moduleExport && moduleExport.flags === 8388608 /* Alias */ && - ts.getDeclarationOfKind(moduleExport, 245 /* ExportSpecifier */)) { + ts.getDeclarationOfKind(moduleExport, 246 /* ExportSpecifier */)) { break; } } @@ -25495,13 +26290,13 @@ var ts; break loop; } break; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & 8 /* EnumMember */)) { break loop; } break; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* 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 @@ -25518,9 +26313,9 @@ var ts; } } break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & 793064 /* Type */)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container @@ -25536,7 +26331,7 @@ var ts; } break loop; } - if (location.kind === 198 /* ClassExpression */ && meaning & 32 /* Class */) { + if (location.kind === 199 /* ClassExpression */ && meaning & 32 /* Class */) { var className = location.name; if (className && name === className.text) { result = location.symbol; @@ -25552,9 +26347,9 @@ var ts; // [foo()]() { } // <-- Reference to T from class's own computed property // } // - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: grandparent = location.parent.parent; - if (ts.isClassLike(grandparent) || grandparent.kind === 229 /* InterfaceDeclaration */) { + if (ts.isClassLike(grandparent) || grandparent.kind === 230 /* InterfaceDeclaration */) { // A reference to this grandparent's type parameters would be an error if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & 793064 /* Type */)) { error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); @@ -25562,19 +26357,19 @@ var ts; } } break; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; } break; - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: if (meaning & 3 /* Variable */ && name === "arguments") { result = argumentsSymbol; break loop; @@ -25587,7 +26382,7 @@ var ts; } } break; - case 146 /* Decorator */: + case 147 /* Decorator */: // Decorators are resolved at the class declaration. Resolving at the parameter // or member would result in looking up locals in the method. // @@ -25596,7 +26391,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 === 145 /* Parameter */) { + if (location.parent && location.parent.kind === 146 /* Parameter */) { location = location.parent; } // @@ -25625,7 +26420,8 @@ var ts; !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) && !checkAndReportErrorForExtendingInterface(errorLocation) && !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && - !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning)) { + !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && + !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : ts.declarationNameToString(nameArg)); } } @@ -25651,16 +26447,17 @@ var ts; // block-scoped variable and namespace module. However, only when we // try to resolve name in /*1*/ which is used in variable position, // we want to check for block-scoped - if (meaning & 2 /* BlockScopedVariable */) { + if (meaning & 2 /* BlockScopedVariable */ || + ((meaning & 32 /* Class */ || meaning & 384 /* Enum */) && (meaning & 107455 /* Value */) === 107455 /* Value */)) { var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result); - if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */) { + if (exportOrLocalSymbol.flags & 2 /* BlockScopedVariable */ || exportOrLocalSymbol.flags & 32 /* Class */ || exportOrLocalSymbol.flags & 384 /* Enum */) { checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation); } } // If we're in an external module, we can't reference value symbols created from UMD export declarations if (result && isInExternalModule && (meaning & 107455 /* Value */) === 107455 /* Value */) { var decls = result.declarations; - if (decls && decls.length === 1 && decls[0].kind === 235 /* NamespaceExportDeclaration */) { + if (decls && decls.length === 1 && decls[0].kind === 236 /* NamespaceExportDeclaration */) { error(errorLocation, ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead, name); } } @@ -25670,14 +26467,14 @@ var ts; function isTypeParameterSymbolDeclaredInContainer(symbol, container) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var decl = _a[_i]; - if (decl.kind === 144 /* TypeParameter */ && decl.parent === container) { + if (decl.kind === 145 /* TypeParameter */ && decl.parent === container) { return true; } } return false; } function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) { - if ((errorLocation.kind === 70 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { + if ((errorLocation.kind === 71 /* Identifier */ && (isTypeReferenceIdentifier(errorLocation)) || isInTypeQuery(errorLocation))) { return false; } var container = ts.getThisContainer(errorLocation, /*includeArrowFunctions*/ true); @@ -25722,10 +26519,10 @@ var ts; */ function getEntityNameForExtendingInterface(node) { switch (node.kind) { - case 70 /* Identifier */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: ts.Debug.assert(ts.isEntityNameExpression(node.expression)); return node.expression; default: @@ -25752,13 +26549,38 @@ var ts; } return false; } + function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) { + if (meaning & (107455 /* Value */ & ~1024 /* NamespaceModule */ & ~793064 /* Type */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~107455 /* Value */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, name); + return true; + } + } + else if (meaning & (793064 /* Type */ & ~1024 /* NamespaceModule */ & ~107455 /* Value */)) { + var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 /* NamespaceModule */ & ~793064 /* Type */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined)); + if (symbol) { + error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, name); + return true; + } + } + return false; + } function checkResolvedBlockScopedVariable(result, errorLocation) { - ts.Debug.assert((result.flags & 2 /* BlockScopedVariable */) !== 0); + ts.Debug.assert(!!(result.flags & 2 /* BlockScopedVariable */ || result.flags & 32 /* Class */ || result.flags & 384 /* Enum */)); // 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"); + var declaration = ts.forEach(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 232 /* EnumDeclaration */) ? d : undefined; }); + ts.Debug.assert(declaration !== undefined, "Declaration to checkResolvedBlockScopedVariable is undefined"); if (!ts.isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { - error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + if (result.flags & 2 /* BlockScopedVariable */) { + error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 32 /* Class */) { + error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } + else if (result.flags & 384 /* Enum */) { + error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, ts.declarationNameToString(declaration.name)); + } } } /* Starting from 'initial' node walk up the parent chain until 'stopAt' node is reached. @@ -25766,37 +26588,26 @@ var ts; * Return false if 'stopAt' node is reached or isFunctionLike(current) === true. */ function isSameScopeDescendentOf(initial, parent, stopAt) { - if (!parent) { - return false; - } - for (var current = initial; current && current !== stopAt && !ts.isFunctionLike(current); current = current.parent) { - if (current === parent) { - return true; - } - } - return false; + return parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; }); } function getAnyImportSyntax(node) { if (ts.isAliasSymbolDeclaration(node)) { - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { return node; } - while (node && node.kind !== 237 /* ImportDeclaration */) { - node = node.parent; - } - return node; + return ts.findAncestor(node, function (n) { return n.kind === 238 /* ImportDeclaration */; }); } } function getDeclarationOfAliasSymbol(symbol) { return ts.find(symbol.declarations, ts.isAliasSymbolDeclaration); } - function getTargetOfImportEqualsDeclaration(node) { - if (node.moduleReference.kind === 247 /* ExternalModuleReference */) { + function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) { + if (node.moduleReference.kind === 248 /* ExternalModuleReference */) { return resolveExternalModuleSymbol(resolveExternalModuleName(node, ts.getExternalModuleImportEqualsDeclarationExpression(node))); } - return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference); + return getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias); } - function getTargetOfImportClause(node) { + function getTargetOfImportClause(node, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier); if (moduleSymbol) { var exportDefaultSymbol = void 0; @@ -25807,20 +26618,20 @@ var ts; var exportValue = moduleSymbol.exports.get("export="); exportDefaultSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), "default") - : resolveSymbol(moduleSymbol.exports.get("default")); + : resolveSymbol(moduleSymbol.exports.get("default"), dontResolveAlias); } if (!exportDefaultSymbol && !allowSyntheticDefaultImports) { error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol)); } else if (!exportDefaultSymbol && allowSyntheticDefaultImports) { - return resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + return resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } return exportDefaultSymbol; } } - function getTargetOfNamespaceImport(node) { + function getTargetOfNamespaceImport(node, dontResolveAlias) { var moduleSpecifier = node.parent.parent.moduleSpecifier; - return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier); + return resolveESModuleSymbol(resolveExternalModuleName(node, moduleSpecifier), moduleSpecifier, dontResolveAlias); } // This function creates a synthetic symbol that combines the value side of one symbol with the // type/namespace side of another symbol. Consider this example: @@ -25855,12 +26666,9 @@ var ts; result.exports = valueSymbol.exports; return result; } - function getExportOfModule(symbol, name) { + function getExportOfModule(symbol, name, dontResolveAlias) { if (symbol.flags & 1536 /* Module */) { - var exportedSymbol = getExportsOfSymbol(symbol).get(name); - if (exportedSymbol) { - return resolveSymbol(exportedSymbol); - } + return resolveSymbol(getExportsOfSymbol(symbol).get(name), dontResolveAlias); } } function getPropertyOfVariable(symbol, name) { @@ -25871,9 +26679,9 @@ var ts; } } } - function getExternalModuleMember(node, specifier) { + function getExternalModuleMember(node, specifier, dontResolveAlias) { var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier); - var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier); + var targetSymbol = resolveESModuleSymbol(moduleSymbol, node.moduleSpecifier, dontResolveAlias); if (targetSymbol) { var name = specifier.propertyName || specifier.name; if (name.text) { @@ -25889,11 +26697,11 @@ var ts; symbolFromVariable = getPropertyOfVariable(targetSymbol, name.text); } // if symbolFromVariable is export - get its final target - symbolFromVariable = resolveSymbol(symbolFromVariable); - var symbolFromModule = getExportOfModule(targetSymbol, name.text); + symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias); + var symbolFromModule = getExportOfModule(targetSymbol, name.text, dontResolveAlias); // If the export member we're looking for is default, and there is no real default but allowSyntheticDefaultImports is on, return the entire module as the default if (!symbolFromModule && allowSyntheticDefaultImports && name.text === "default") { - symbolFromModule = resolveExternalModuleSymbol(moduleSymbol) || resolveSymbol(moduleSymbol); + symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias); } var symbol = symbolFromModule && symbolFromVariable ? combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) : @@ -25905,40 +26713,41 @@ var ts; } } } - function getTargetOfImportSpecifier(node) { - return getExternalModuleMember(node.parent.parent.parent, node); + function getTargetOfImportSpecifier(node, dontResolveAlias) { + return getExternalModuleMember(node.parent.parent.parent, node, dontResolveAlias); } - function getTargetOfNamespaceExportDeclaration(node) { - return resolveExternalModuleSymbol(node.parent.symbol); + function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) { + return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); } - function getTargetOfExportSpecifier(node) { + function getTargetOfExportSpecifier(node, dontResolveAlias) { return node.parent.parent.moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node) : - resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */); + getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : + resolveEntityName(node.propertyName || node.name, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } - function getTargetOfExportAssignment(node) { - return resolveEntityName(node.expression, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */); + function getTargetOfExportAssignment(node, dontResolveAlias) { + return resolveEntityName(node.expression, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } - function getTargetOfAliasDeclaration(node) { + function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) { switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: - return getTargetOfImportEqualsDeclaration(node); - case 238 /* ImportClause */: - return getTargetOfImportClause(node); - case 239 /* NamespaceImport */: - return getTargetOfNamespaceImport(node); - case 241 /* ImportSpecifier */: - return getTargetOfImportSpecifier(node); - case 245 /* ExportSpecifier */: - return getTargetOfExportSpecifier(node); - case 242 /* ExportAssignment */: - return getTargetOfExportAssignment(node); - case 235 /* NamespaceExportDeclaration */: - return getTargetOfNamespaceExportDeclaration(node); + case 237 /* ImportEqualsDeclaration */: + return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve); + case 239 /* ImportClause */: + return getTargetOfImportClause(node, dontRecursivelyResolve); + case 240 /* NamespaceImport */: + return getTargetOfNamespaceImport(node, dontRecursivelyResolve); + case 242 /* ImportSpecifier */: + return getTargetOfImportSpecifier(node, dontRecursivelyResolve); + case 246 /* ExportSpecifier */: + return getTargetOfExportSpecifier(node, dontRecursivelyResolve); + case 243 /* ExportAssignment */: + return getTargetOfExportAssignment(node, dontRecursivelyResolve); + case 236 /* NamespaceExportDeclaration */: + return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve); } } - function resolveSymbol(symbol) { - return symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */)) ? resolveAlias(symbol) : symbol; + function resolveSymbol(symbol, dontResolveAlias) { + var shouldResolve = !dontResolveAlias && symbol && symbol.flags & 8388608 /* Alias */ && !(symbol.flags & (107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */)); + return shouldResolve ? resolveAlias(symbol) : symbol; } function resolveAlias(symbol) { ts.Debug.assert((symbol.flags & 8388608 /* Alias */) !== 0, "Should only get Alias here."); @@ -25980,11 +26789,11 @@ var ts; links.referenced = true; var node = getDeclarationOfAliasSymbol(symbol); ts.Debug.assert(!!node); - if (node.kind === 242 /* ExportAssignment */) { + if (node.kind === 243 /* ExportAssignment */) { // export default checkExpressionCached(node.expression); } - else if (node.kind === 245 /* ExportSpecifier */) { + else if (node.kind === 246 /* ExportSpecifier */) { // export { } or export { as foo } checkExpressionCached(node.propertyName || node.name); } @@ -26002,17 +26811,17 @@ var ts; // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (entityName.kind === 70 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { + if (entityName.kind === 71 /* Identifier */ && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) { entityName = entityName.parent; } // Check for case 1 and 3 in the above example - if (entityName.kind === 70 /* Identifier */ || entityName.parent.kind === 142 /* QualifiedName */) { + if (entityName.kind === 71 /* Identifier */ || entityName.parent.kind === 143 /* QualifiedName */) { return resolveEntityName(entityName, 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } else { // Case 2 in above example // entityName.kind could be a QualifiedName or a Missing identifier - ts.Debug.assert(entityName.parent.kind === 236 /* ImportEqualsDeclaration */); + ts.Debug.assert(entityName.parent.kind === 237 /* ImportEqualsDeclaration */); return resolveEntityName(entityName, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */, /*ignoreErrors*/ false, dontResolveAlias); } } @@ -26027,16 +26836,30 @@ var ts; return undefined; } var symbol; - if (name.kind === 70 /* Identifier */) { + if (name.kind === 71 /* Identifier */) { var message = meaning === 1920 /* Namespace */ ? ts.Diagnostics.Cannot_find_namespace_0 : ts.Diagnostics.Cannot_find_name_0; symbol = resolveName(location || name, name.text, meaning, ignoreErrors ? undefined : message, name); if (!symbol) { return undefined; } } - else if (name.kind === 142 /* QualifiedName */ || name.kind === 178 /* PropertyAccessExpression */) { - var left = name.kind === 142 /* QualifiedName */ ? name.left : name.expression; - var right = name.kind === 142 /* QualifiedName */ ? name.right : name.name; + else if (name.kind === 143 /* QualifiedName */ || name.kind === 179 /* PropertyAccessExpression */) { + var left = void 0; + if (name.kind === 143 /* QualifiedName */) { + left = name.left; + } + else if (name.kind === 179 /* PropertyAccessExpression */ && + (name.expression.kind === 185 /* ParenthesizedExpression */ || ts.isEntityNameExpression(name.expression))) { + left = name.expression; + } + else { + // If the expression in property-access expression is not entity-name or parenthsizedExpression (e.g. it is a call expression), it won't be able to successfully resolve the name. + // This is the case when we are trying to do any language service operation in heritage clauses. By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression + // will attempt to checkPropertyAccessExpression to resolve symbol. + // i.e class C extends foo()./*do language service operation here*/B {} + return undefined; + } + var right = name.kind === 143 /* QualifiedName */ ? name.right : name.name; var namespace = resolveEntityName(left, 1920 /* Namespace */, ignoreErrors, /*dontResolveAlias*/ false, location); if (!namespace || ts.nodeIsMissing(right)) { return undefined; @@ -26052,6 +26875,15 @@ var ts; return undefined; } } + else if (name.kind === 185 /* ParenthesizedExpression */) { + // If the expression in parenthesizedExpression is not an entity-name (e.g. it is a call expression), it won't be able to successfully resolve the name. + // This is the case when we are trying to do any language service operation in heritage clauses. + // By return undefined, the getSymbolOfEntityNameOrPropertyAccessExpression will attempt to checkPropertyAccessExpression to resolve symbol. + // i.e class C extends foo()./*do language service operation here*/B {} + return ts.isEntityNameExpression(name.expression) ? + resolveEntityName(name.expression, meaning, ignoreErrors, dontResolveAlias, location) : + undefined; + } else { ts.Debug.fail("Unknown entity name kind."); } @@ -26063,7 +26895,7 @@ var ts; } function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) { if (isForAugmentation === void 0) { isForAugmentation = false; } - if (moduleReferenceExpression.kind !== 9 /* StringLiteral */) { + if (moduleReferenceExpression.kind !== 9 /* StringLiteral */ && moduleReferenceExpression.kind !== 13 /* NoSubstitutionTemplateLiteral */) { return; } var moduleReferenceLiteral = moduleReferenceExpression; @@ -26108,8 +26940,10 @@ var ts; var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented; error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName); } - else if (compilerOptions.noImplicitAny && moduleNotFoundError) { - error(errorNode, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + else if (noImplicitAny && moduleNotFoundError) { + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0, moduleReference); + errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Could_not_find_a_declaration_file_for_module_0_1_implicitly_has_an_any_type, moduleReference, resolvedModule.resolvedFileName); + diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo)); } // Failed imports and untyped modules are both treated in an untyped manner; only difference is whether we give a diagnostic first. return undefined; @@ -26134,15 +26968,15 @@ 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 && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="))) || moduleSymbol; + function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) { + return moduleSymbol && getMergedSymbol(resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias)) || 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 // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). - function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression) { - var symbol = resolveExternalModuleSymbol(moduleSymbol); - if (symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { + function resolveESModuleSymbol(moduleSymbol, moduleReferenceExpression, dontResolveAlias) { + var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); + if (!dontResolveAlias && symbol && !(symbol.flags & (1536 /* Module */ | 3 /* Variable */))) { error(moduleReferenceExpression, ts.Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); symbol = undefined; } @@ -26265,7 +27099,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 === 151 /* Constructor */ && ts.nodeIsPresent(member.body)) { + if (member.kind === 152 /* Constructor */ && ts.nodeIsPresent(member.body)) { return member; } } @@ -26343,11 +27177,12 @@ var ts; } } switch (location.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232 /* ModuleDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: if (result = callback(getSymbolOfNode(location).exports)) { return result; } @@ -26399,7 +27234,7 @@ var ts; return ts.forEachEntry(symbols, function (symbolFromSymbolTable) { if (symbolFromSymbolTable.flags & 8388608 /* Alias */ && symbolFromSymbolTable.name !== "export=" - && !ts.getDeclarationOfKind(symbolFromSymbolTable, 245 /* ExportSpecifier */)) { + && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) { if (!useOnlyExternalAliasing || // Is this external alias, then use it to name ts.forEach(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration)) { @@ -26439,7 +27274,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, 245 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; + symbolFromSymbolTable = (symbolFromSymbolTable.flags & 8388608 /* Alias */ && !ts.getDeclarationOfKind(symbolFromSymbolTable, 246 /* ExportSpecifier */)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable; if (symbolFromSymbolTable.flags & meaning) { qualify = true; return true; @@ -26454,10 +27289,10 @@ var ts; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; switch (declaration.kind) { - case 148 /* PropertyDeclaration */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 149 /* PropertyDeclaration */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: continue; default: return false; @@ -26530,15 +27365,12 @@ var ts; } return { accessibility: 0 /* Accessible */ }; function getExternalModuleContainer(declaration) { - for (; declaration; declaration = declaration.parent) { - if (hasExternalModuleSymbol(declaration)) { - return getSymbolOfNode(declaration); - } - } + var node = ts.findAncestor(declaration, hasExternalModuleSymbol); + return node && getSymbolOfNode(node); } } function hasExternalModuleSymbol(declaration) { - return ts.isAmbientModule(declaration) || (declaration.kind === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); + return ts.isAmbientModule(declaration) || (declaration.kind === 265 /* SourceFile */ && ts.isExternalOrCommonJsModule(declaration)); } function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) { var aliasesToMakeVisible; @@ -26579,12 +27411,12 @@ var ts; function isEntityNameVisible(entityName, enclosingDeclaration) { // get symbol of the first identifier of the entityName var meaning; - if (entityName.parent.kind === 161 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { + if (entityName.parent.kind === 162 /* TypeQuery */ || ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { // Typeof value meaning = 107455 /* Value */ | 1048576 /* ExportValue */; } - else if (entityName.kind === 142 /* QualifiedName */ || entityName.kind === 178 /* PropertyAccessExpression */ || - entityName.parent.kind === 236 /* ImportEqualsDeclaration */) { + else if (entityName.kind === 143 /* QualifiedName */ || entityName.kind === 179 /* PropertyAccessExpression */ || + entityName.parent.kind === 237 /* ImportEqualsDeclaration */) { // Left identifier from type reference or TypeAlias // Entity name of the import declaration meaning = 1920 /* Namespace */; @@ -26636,6 +27468,516 @@ var ts; } return result; } + function createNodeBuilder() { + var context; + return { + typeToTypeNode: function (type, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = typeToTypeNodeHelper(type); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + }, + signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags) { + context = createNodeBuilderContext(enclosingDeclaration, flags); + var resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + var result = context.encounteredError ? undefined : resultingNode; + return result; + } + }; + function createNodeBuilderContext(enclosingDeclaration, flags) { + return { + enclosingDeclaration: enclosingDeclaration, + flags: flags, + encounteredError: false, + inObjectTypeLiteral: false, + checkAlias: true, + symbolStack: undefined + }; + } + function typeToTypeNodeHelper(type) { + if (!type) { + context.encounteredError = true; + // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? + return undefined; + } + if (type.flags & 1 /* Any */) { + return ts.createKeywordTypeNode(119 /* AnyKeyword */); + } + if (type.flags & 2 /* String */) { + return ts.createKeywordTypeNode(136 /* StringKeyword */); + } + if (type.flags & 4 /* Number */) { + return ts.createKeywordTypeNode(133 /* NumberKeyword */); + } + if (type.flags & 8 /* Boolean */) { + return ts.createKeywordTypeNode(122 /* BooleanKeyword */); + } + if (type.flags & 16 /* Enum */) { + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & (32 /* StringLiteral */)) { + return ts.createLiteralTypeNode((ts.createLiteral(type.text))); + } + if (type.flags & (64 /* NumberLiteral */)) { + return ts.createLiteralTypeNode((ts.createNumericLiteral(type.text))); + } + if (type.flags & 128 /* BooleanLiteral */) { + return type.intrinsicName === "true" ? ts.createTrue() : ts.createFalse(); + } + if (type.flags & 256 /* EnumLiteral */) { + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & 1024 /* Void */) { + return ts.createKeywordTypeNode(105 /* VoidKeyword */); + } + if (type.flags & 2048 /* Undefined */) { + return ts.createKeywordTypeNode(139 /* UndefinedKeyword */); + } + if (type.flags & 4096 /* Null */) { + return ts.createKeywordTypeNode(95 /* NullKeyword */); + } + if (type.flags & 8192 /* Never */) { + return ts.createKeywordTypeNode(130 /* NeverKeyword */); + } + if (type.flags & 512 /* ESSymbol */) { + return ts.createKeywordTypeNode(137 /* SymbolKeyword */); + } + if (type.flags & 16777216 /* NonPrimitive */) { + return ts.createKeywordTypeNode(134 /* ObjectKeyword */); + } + if (type.flags & 16384 /* TypeParameter */ && type.isThisType) { + if (context.inObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowThisInObjectLiteral)) { + context.encounteredError = true; + } + } + return ts.createThis(); + } + var objectFlags = getObjectFlags(type); + if (objectFlags & 4 /* Reference */) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + return typeReferenceToTypeNode(type); + } + if (objectFlags & 3 /* ClassOrInterface */) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // TODO(aozgaa): handle type arguments. + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (type.flags & 16384 /* TypeParameter */) { + var name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. + return ts.createTypeReferenceNode(name, /*typeArguments*/ undefined); + } + if (context.checkAlias && type.aliasSymbol) { + var name = symbolToName(type.aliasSymbol, /*expectsIdentifier*/ false); + var typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + return ts.createTypeReferenceNode(name, typeArgumentNodes); + } + context.checkAlias = false; + if (type.flags & 65536 /* Union */) { + var formattedUnionTypes = formatUnionTypes(type.types); + var unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); + if (unionTypeNodes && unionTypeNodes.length > 0) { + return ts.createUnionOrIntersectionTypeNode(166 /* UnionType */, unionTypeNodes); + } + else { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + context.encounteredError = true; + } + return undefined; + } + } + if (type.flags & 131072 /* Intersection */) { + return ts.createUnionOrIntersectionTypeNode(167 /* IntersectionType */, mapToTypeNodeArray(type.types)); + } + if (objectFlags & (16 /* Anonymous */ | 32 /* Mapped */)) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + // The type is an object literal type. + return createAnonymousTypeNode(type); + } + if (type.flags & 262144 /* Index */) { + var indexedType = type.type; + var indexTypeNode = typeToTypeNodeHelper(indexedType); + return ts.createTypeOperatorNode(indexTypeNode); + } + if (type.flags & 524288 /* IndexedAccess */) { + var objectTypeNode = typeToTypeNodeHelper(type.objectType); + var indexTypeNode = typeToTypeNodeHelper(type.indexType); + return ts.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); + } + ts.Debug.fail("Should be unreachable."); + function mapToTypeNodeArray(types) { + var result = []; + for (var _i = 0, types_1 = types; _i < types_1.length; _i++) { + var type_1 = types_1[_i]; + var typeNode = typeToTypeNodeHelper(type_1); + if (typeNode) { + result.push(typeNode); + } + } + return result; + } + function createMappedTypeNodeFromType(type) { + ts.Debug.assert(!!(type.flags & 32768 /* Object */)); + var typeParameter = getTypeParameterFromMappedType(type); + var typeParameterNode = typeParameterToDeclaration(typeParameter); + var templateType = getTemplateTypeFromMappedType(type); + var templateTypeNode = typeToTypeNodeHelper(templateType); + var readonlyToken = type.declaration && type.declaration.readonlyToken ? ts.createToken(131 /* ReadonlyKeyword */) : undefined; + var questionToken = type.declaration && type.declaration.questionToken ? ts.createToken(55 /* QuestionToken */) : undefined; + return ts.createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + } + function createAnonymousTypeNode(type) { + var symbol = type.symbol; + if (symbol) { + // Always use 'typeof T' for type of class, enum, and module objects + if (symbol.flags & 32 /* Class */ && !getBaseTypeVariableOfClass(symbol) || + symbol.flags & (384 /* Enum */ | 512 /* ValueModule */) || + shouldWriteTypeOfFunctionSymbol()) { + return createTypeQueryNodeFromSymbol(symbol); + } + else if (ts.contains(context.symbolStack, symbol)) { + // If type is an anonymous type literal in a type alias declaration, use type alias name + var typeAlias = getTypeAliasForTypeLiteral(type); + if (typeAlias) { + // The specified symbol flags need to be reinterpreted as type flags + var entityName = symbolToName(typeAlias, /*expectsIdentifier*/ false); + return ts.createTypeReferenceNode(entityName, /*typeArguments*/ undefined); + } + else { + return ts.createKeywordTypeNode(119 /* AnyKeyword */); + } + } + else { + // Since instantiations of the same anonymous type have the same symbol, tracking symbols instead + // of types allows us to catch circular references to instantiations of the same anonymous type + if (!context.symbolStack) { + context.symbolStack = []; + } + context.symbolStack.push(symbol); + var result = createTypeNodeFromObjectType(type); + context.symbolStack.pop(); + return result; + } + } + else { + // Anonymous types without a symbol are never circular. + return createTypeNodeFromObjectType(type); + } + function shouldWriteTypeOfFunctionSymbol() { + var isStaticMethodSymbol = !!(symbol.flags & 8192 /* Method */ && + ts.forEach(symbol.declarations, function (declaration) { return ts.getModifierFlags(declaration) & 32 /* Static */; })); + var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && + (symbol.parent || + ts.forEach(symbol.declarations, function (declaration) { + return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; + })); + if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { + // typeof is allowed only for static/non local functions + return ts.contains(context.symbolStack, symbol); // it is type of the symbol uses itself recursively + } + } + } + function createTypeNodeFromObjectType(type) { + if (type.objectFlags & 32 /* Mapped */) { + if (getConstraintTypeFromMappedType(type).flags & (16384 /* TypeParameter */ | 262144 /* Index */)) { + return createMappedTypeNodeFromType(type); + } + } + var resolved = resolveStructuredTypeMembers(type); + if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { + if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { + return ts.createTypeLiteralNode(/*members*/ undefined); + } + if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { + var signature = resolved.callSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 160 /* FunctionType */); + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { + var signature = resolved.constructSignatures[0]; + return signatureToSignatureDeclarationHelper(signature, 161 /* ConstructorType */); + } + } + var saveInObjectTypeLiteral = context.inObjectTypeLiteral; + context.inObjectTypeLiteral = true; + var members = createTypeNodesFromResolvedType(resolved); + context.inObjectTypeLiteral = saveInObjectTypeLiteral; + return ts.createTypeLiteralNode(members); + } + function createTypeQueryNodeFromSymbol(symbol) { + var entityName = symbolToName(symbol, /*expectsIdentifier*/ false); + return ts.createTypeQueryNode(entityName); + } + function typeReferenceToTypeNode(type) { + var typeArguments = type.typeArguments || emptyArray; + if (type.target === globalArrayType) { + var elementType = typeToTypeNodeHelper(typeArguments[0]); + return ts.createArrayTypeNode(elementType); + } + else if (type.target.objectFlags & 8 /* Tuple */) { + if (typeArguments.length > 0) { + var tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { + return ts.createTupleTypeNode(tupleConstituentNodes); + } + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowEmptyTuple)) { + context.encounteredError = true; + } + return undefined; + } + else { + var outerTypeParameters = type.target.outerTypeParameters; + var i = 0; + var qualifiedName = undefined; + if (outerTypeParameters) { + var length_1 = outerTypeParameters.length; + while (i < length_1) { + // Find group of type arguments for type parameters with the same declaring container. + var start = i; + var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); + do { + i++; + } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + // 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)) { + var qualifiedNamePart = symbolToName(parent, /*expectsIdentifier*/ true); + if (!qualifiedName) { + qualifiedName = ts.createQualifiedName(qualifiedNamePart, /*right*/ undefined); + } + else { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = qualifiedNamePart; + qualifiedName = ts.createQualifiedName(qualifiedName, /*right*/ undefined); + } + } + } + } + var entityName = undefined; + var nameIdentifier = symbolToName(type.symbol, /*expectsIdentifier*/ true); + if (qualifiedName) { + ts.Debug.assert(!qualifiedName.right); + qualifiedName.right = nameIdentifier; + entityName = qualifiedName; + } + else { + entityName = nameIdentifier; + } + var typeParameterCount = (type.target.typeParameters || emptyArray).length; + var typeArgumentNodes = ts.some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + return ts.createTypeReferenceNode(entityName, typeArgumentNodes); + } + } + function createTypeNodesFromResolvedType(resolvedType) { + var typeElements = []; + for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) { + var signature = _a[_i]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 155 /* CallSignature */)); + } + for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) { + var signature = _c[_b]; + typeElements.push(signatureToSignatureDeclarationHelper(signature, 156 /* ConstructSignature */)); + } + if (resolvedType.stringIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0 /* String */)); + } + if (resolvedType.numberIndexInfo) { + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1 /* Number */)); + } + var properties = resolvedType.properties; + if (!properties) { + return typeElements; + } + for (var _d = 0, properties_2 = properties; _d < properties_2.length; _d++) { + var propertySymbol = properties_2[_d]; + var propertyType = getTypeOfSymbol(propertySymbol); + var oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0]; + if (!oldDeclaration) { + return; + } + var propertyName = oldDeclaration.name; + var optionalToken = propertySymbol.flags & 67108864 /* Optional */ ? ts.createToken(55 /* QuestionToken */) : undefined; + if (propertySymbol.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(propertyType).length) { + var signatures = getSignaturesOfType(propertyType, 0 /* Call */); + for (var _e = 0, signatures_1 = signatures; _e < signatures_1.length; _e++) { + var signature = signatures_1[_e]; + var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 150 /* MethodSignature */); + methodDeclaration.name = propertyName; + methodDeclaration.questionToken = optionalToken; + typeElements.push(methodDeclaration); + } + } + else { + // TODO(aozgaa): should we create a node with explicit or implict any? + var propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : ts.createKeywordTypeNode(119 /* AnyKeyword */); + typeElements.push(ts.createPropertySignature(propertyName, optionalToken, propertyTypeNode, + /*initializer*/ undefined)); + } + } + return typeElements.length ? typeElements : undefined; + } + } + function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind) { + var indexerTypeNode = ts.createKeywordTypeNode(kind === 0 /* String */ ? 136 /* StringKeyword */ : 133 /* NumberKeyword */); + var name = ts.getNameFromIndexInfo(indexInfo); + var indexingParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, name, + /*questionToken*/ undefined, indexerTypeNode, + /*initializer*/ undefined); + var typeNode = typeToTypeNodeHelper(indexInfo.type); + return ts.createIndexSignatureDeclaration( + /*decorators*/ undefined, indexInfo.isReadonly ? [ts.createToken(131 /* ReadonlyKeyword */)] : undefined, [indexingParameter], typeNode); + } + function signatureToSignatureDeclarationHelper(signature, kind) { + var typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter); }); + var parameters = signature.parameters.map(function (parameter) { return symbolToParameterDeclaration(parameter); }); + var returnTypeNode; + if (signature.typePredicate) { + var typePredicate = signature.typePredicate; + var parameterName = typePredicate.kind === 1 /* Identifier */ ? ts.createIdentifier(typePredicate.parameterName) : ts.createThisTypeNode(); + var typeNode = typeToTypeNodeHelper(typePredicate.type); + returnTypeNode = ts.createTypePredicateNode(parameterName, typeNode); + } + else { + var returnType = getReturnTypeOfSignature(signature); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + } + var returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== 119 /* AnyKeyword */ ? returnTypeNode : undefined; + return ts.createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + } + function typeParameterToDeclaration(type) { + var constraint = getConstraintFromTypeParameter(type); + var constraintNode = constraint && typeToTypeNodeHelper(constraint); + var defaultParameter = getDefaultFromTypeParameter(type); + var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); + var name = symbolToName(type.symbol, /*expectsIdentifier*/ true); + return ts.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); + } + function symbolToParameterDeclaration(parameterSymbol) { + var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 146 /* Parameter */); + var parameterType = getTypeOfSymbol(parameterSymbol); + var parameterTypeNode = typeToTypeNodeHelper(parameterType); + // TODO(aozgaa): In the future, check initializer accessibility. + var parameterNode = ts.createParameter(parameterDeclaration.decorators, parameterDeclaration.modifiers, parameterDeclaration.dotDotDotToken && ts.createToken(24 /* DotDotDotToken */), + // Clone name to remove trivia. + ts.getSynthesizedClone(parameterDeclaration.name), parameterDeclaration.questionToken && ts.createToken(55 /* QuestionToken */), parameterTypeNode, parameterDeclaration.initializer); + return parameterNode; + } + function symbolToName(symbol, expectsIdentifier) { + // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. + var chain; + var isTypeParameter = symbol.flags & 262144 /* TypeParameter */; + if (!isTypeParameter && context.enclosingDeclaration) { + chain = getSymbolChain(symbol, 0 /* None */, /*endOfChain*/ true); + ts.Debug.assert(chain && chain.length > 0); + } + else { + chain = [symbol]; + } + if (expectsIdentifier && chain.length !== 1 + && !context.encounteredError + && !(context.flags & ts.NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + context.encounteredError = true; + } + return createEntityNameFromSymbolChain(chain, chain.length - 1); + function createEntityNameFromSymbolChain(chain, index) { + ts.Debug.assert(chain && 0 <= index && index < chain.length); + // const parentIndex = index - 1; + var symbol = chain[index]; + var typeParameterString = ""; + if (index > 0) { + var parentSymbol = chain[index - 1]; + var typeParameters = void 0; + if (getCheckFlags(symbol) & 1 /* Instantiated */) { + typeParameters = getTypeParametersOfClassOrInterface(parentSymbol); + } + else { + var targetSymbol = getTargetSymbol(parentSymbol); + if (targetSymbol.flags & (32 /* Class */ | 64 /* Interface */ | 524288 /* TypeAlias */)) { + typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); + } + } + if (typeParameters && typeParameters.length > 0) { + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowTypeParameterInQualifiedName)) { + context.encounteredError = true; + } + var writer = ts.getSingleLineStringWriter(); + var displayBuilder = getSymbolDisplayBuilder(); + displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); + typeParameterString = writer.string(); + ts.releaseStringWriter(writer); + } + } + var symbolName = getNameOfSymbol(symbol); + var symbolNameWithTypeParameters = typeParameterString.length > 0 ? symbolName + "<" + typeParameterString + ">" : symbolName; + var identifier = ts.createIdentifier(symbolNameWithTypeParameters); + return index > 0 ? ts.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; + } + /** @param endOfChain Set to false for recursive calls; non-recursive calls should always output something. */ + function getSymbolChain(symbol, meaning, endOfChain) { + var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, /*useOnlyExternalAliasing*/ false); + var parentSymbol; + if (!accessibleSymbolChain || + needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) { + // Go up and add our parent. + var parent = getParentOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol); + if (parent) { + var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), /*endOfChain*/ false); + if (parentChain) { + parentSymbol = parent; + accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [symbol]); + } + } + } + if (accessibleSymbolChain) { + return accessibleSymbolChain; + } + if ( + // If this is the last part of outputting the symbol, always output. The cases apply only to parent symbols. + endOfChain || + // If a parent symbol is an external module, don't write it. (We prefer just `x` vs `"foo/bar".x`.) + !(!parentSymbol && ts.forEach(symbol.declarations, hasExternalModuleSymbol)) && + // If a parent symbol is an anonymous type, don't write it. + !(symbol.flags & (2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */))) { + return [symbol]; + } + } + function getNameOfSymbol(symbol) { + var declaration = ts.firstOrUndefined(symbol.declarations); + if (declaration) { + if (declaration.name) { + return ts.declarationNameToString(declaration.name); + } + if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { + return ts.declarationNameToString(declaration.parent.name); + } + if (!context.encounteredError && !(context.flags & ts.NodeBuilderFlags.allowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case 199 /* ClassExpression */: + return "(Anonymous class)"; + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return "(Anonymous function)"; + } + } + return symbol.name; + } + } + } function typePredicateToString(typePredicate, enclosingDeclaration, flags) { var writer = ts.getSingleLineStringWriter(); getSymbolDisplayBuilder().buildTypePredicateDisplay(typePredicate, writer, enclosingDeclaration, flags); @@ -26679,11 +28021,8 @@ var ts; } function getTypeAliasForTypeLiteral(type) { if (type.symbol && type.symbol.flags & 2048 /* TypeLiteral */) { - var node = type.symbol.declarations[0].parent; - while (node.kind === 167 /* ParenthesizedType */) { - node = node.parent; - } - if (node.kind === 230 /* TypeAliasDeclaration */) { + var node = ts.findAncestor(type.symbol.declarations[0].parent, function (n) { return n.kind !== 168 /* ParenthesizedType */; }); + if (node.kind === 231 /* TypeAliasDeclaration */) { return getSymbolOfNode(node); } } @@ -26691,7 +28030,7 @@ var ts; } function isTopLevelInExternalModuleAugmentation(node) { return node && node.parent && - node.parent.kind === 233 /* ModuleBlock */ && + node.parent.kind === 234 /* ModuleBlock */ && ts.isExternalModuleAugmentation(node.parent.parent); } function literalTypeToString(type) { @@ -26703,11 +28042,14 @@ var ts; if (declaration.name) { return ts.declarationNameToString(declaration.name); } + if (declaration.parent && declaration.parent.kind === 226 /* VariableDeclaration */) { + return ts.declarationNameToString(declaration.parent.name); + } switch (declaration.kind) { - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return "(Anonymous class)"; - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return "(Anonymous function)"; } } @@ -26731,17 +28073,17 @@ var ts; var firstChar = symbolName.charCodeAt(0); var needsElementAccess = !ts.isIdentifierStart(firstChar, languageVersion); if (needsElementAccess) { - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); if (ts.isSingleOrDoubleQuote(firstChar)) { writer.writeStringLiteral(symbolName); } else { writer.writeSymbol(symbolName, symbol); } - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else { - writePunctuation(writer, 22 /* DotToken */); + writePunctuation(writer, 23 /* DotToken */); writer.writeSymbol(symbolName, symbol); } } @@ -26840,7 +28182,7 @@ var ts; } else if (type.flags & 256 /* EnumLiteral */) { buildSymbolDisplay(getParentOfSymbol(type.symbol), writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, nextFlags); - writePunctuation(writer, 22 /* DotToken */); + writePunctuation(writer, 23 /* DotToken */); appendSymbolNameOnly(type.symbol, writer); } else if (getObjectFlags(type) & 3 /* ClassOrInterface */ || type.flags & (16 /* Enum */ | 16384 /* TypeParameter */)) { @@ -26868,30 +28210,30 @@ var ts; } else if (type.flags & 524288 /* IndexedAccess */) { writeType(type.objectType, 64 /* InElementType */); - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); writeType(type.indexType, 0 /* None */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else { // Should never get here // { ... } - writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); writeSpace(writer); - writePunctuation(writer, 23 /* DotDotDotToken */); + writePunctuation(writer, 24 /* DotDotDotToken */); writeSpace(writer); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); } } function writeTypeList(types, delimiter) { for (var i = 0; i < types.length; i++) { if (i > 0) { - if (delimiter !== 25 /* CommaToken */) { + if (delimiter !== 26 /* CommaToken */) { writeSpace(writer); } writePunctuation(writer, delimiter); writeSpace(writer); } - writeType(types[i], delimiter === 25 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); + writeType(types[i], delimiter === 26 /* CommaToken */ ? 0 /* None */ : 64 /* InElementType */); } } function writeSymbolTypeReference(symbol, typeArguments, pos, end, flags) { @@ -26900,29 +28242,29 @@ var ts; buildSymbolDisplay(symbol, writer, enclosingDeclaration, 793064 /* Type */, 0 /* None */, flags); } if (pos < end) { - writePunctuation(writer, 26 /* LessThanToken */); + writePunctuation(writer, 27 /* LessThanToken */); writeType(typeArguments[pos], 256 /* InFirstTypeArgument */); pos++; while (pos < end) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); writeType(typeArguments[pos], 0 /* None */); pos++; } - writePunctuation(writer, 28 /* GreaterThanToken */); + writePunctuation(writer, 29 /* GreaterThanToken */); } } function writeTypeReference(type, flags) { var typeArguments = type.typeArguments || emptyArray; if (type.target === globalArrayType && !(flags & 1 /* WriteArrayAsGenericType */)) { writeType(typeArguments[0], 64 /* InElementType */); - writePunctuation(writer, 20 /* OpenBracketToken */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else if (type.target.objectFlags & 8 /* Tuple */) { - writePunctuation(writer, 20 /* OpenBracketToken */); - writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 25 /* CommaToken */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); + writeTypeList(type.typeArguments.slice(0, getTypeReferenceArity(type)), 26 /* CommaToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } else { // Write the type reference in the format f
.g.C where A and B are type arguments @@ -26931,19 +28273,19 @@ var ts; var outerTypeParameters = type.target.outerTypeParameters; var i = 0; if (outerTypeParameters) { - var length_1 = outerTypeParameters.length; - while (i < length_1) { + var length_2 = outerTypeParameters.length; + while (i < length_2) { // Find group of type arguments for type parameters with the same declaring container. var start = i; var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]); do { i++; - } while (i < length_1 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); + } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent); // 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, typeArguments, start, i, flags); - writePunctuation(writer, 22 /* DotToken */); + writePunctuation(writer, 23 /* DotToken */); } } } @@ -26953,16 +28295,16 @@ var ts; } function writeUnionOrIntersectionType(type, flags) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); } if (type.flags & 65536 /* Union */) { - writeTypeList(formatUnionTypes(type.types), 48 /* BarToken */); + writeTypeList(formatUnionTypes(type.types), 49 /* BarToken */); } else { - writeTypeList(type.types, 47 /* AmpersandToken */); + writeTypeList(type.types, 48 /* AmpersandToken */); } if (flags & 64 /* InElementType */) { - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } } function writeAnonymousType(type, flags) { @@ -26985,7 +28327,7 @@ var ts; } else { // Recursive usage, use any - writeKeyword(writer, 118 /* AnyKeyword */); + writeKeyword(writer, 119 /* AnyKeyword */); } } else { @@ -27009,7 +28351,7 @@ var ts; var isNonLocalFunctionSymbol = !!(symbol.flags & 16 /* Function */) && (symbol.parent || ts.forEach(symbol.declarations, function (declaration) { - return declaration.parent.kind === 264 /* SourceFile */ || declaration.parent.kind === 233 /* ModuleBlock */; + return declaration.parent.kind === 265 /* SourceFile */ || declaration.parent.kind === 234 /* ModuleBlock */; })); if (isStaticMethodSymbol || isNonLocalFunctionSymbol) { // typeof is allowed only for static/non local functions @@ -27019,18 +28361,18 @@ var ts; } } function writeTypeOfSymbol(type, typeFormatFlags) { - writeKeyword(writer, 102 /* TypeOfKeyword */); + writeKeyword(writer, 103 /* TypeOfKeyword */); writeSpace(writer); buildSymbolDisplay(type.symbol, writer, enclosingDeclaration, 107455 /* Value */, 0 /* None */, typeFormatFlags); } function writePropertyWithModifiers(prop) { if (isReadonlySymbol(prop)) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeKeyword(writer, 131 /* ReadonlyKeyword */); writeSpace(writer); } buildSymbolDisplay(prop, writer); if (prop.flags & 67108864 /* Optional */) { - writePunctuation(writer, 54 /* QuestionToken */); + writePunctuation(writer, 55 /* QuestionToken */); } } function shouldAddParenthesisAroundFunctionType(callSignature, flags) { @@ -27055,55 +28397,55 @@ var ts; var resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - writePunctuation(writer, 16 /* OpenBraceToken */); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); return; } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { var parenthesizeSignature = shouldAddParenthesisAroundFunctionType(resolved.callSignatures[0], flags); if (parenthesizeSignature) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); } buildSignatureDisplay(resolved.callSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (parenthesizeSignature) { - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } return; } if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { if (flags & 64 /* InElementType */) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); } - writeKeyword(writer, 93 /* NewKeyword */); + writeKeyword(writer, 94 /* NewKeyword */); writeSpace(writer); buildSignatureDisplay(resolved.constructSignatures[0], writer, enclosingDeclaration, globalFlagsToPass | 8 /* WriteArrowStyleSignature */, /*kind*/ undefined, symbolStack); if (flags & 64 /* InElementType */) { - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } return; } } var saveInObjectTypeLiteral = inObjectTypeLiteral; inObjectTypeLiteral = true; - writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); writeObjectLiteralType(resolved); writer.decreaseIndent(); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); inObjectTypeLiteral = saveInObjectTypeLiteral; } function writeObjectLiteralType(resolved) { for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) { var signature = _a[_i]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) { var signature = _c[_b]; buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, 1 /* Construct */, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } buildIndexSignatureDisplay(resolved.stringIndexInfo, writer, 0 /* String */, enclosingDeclaration, globalFlags, symbolStack); @@ -27113,49 +28455,49 @@ var ts; var t = getTypeOfSymbol(p); if (p.flags & (16 /* Function */ | 8192 /* Method */) && !getPropertiesOfObjectType(t).length) { var signatures = getSignaturesOfType(t, 0 /* Call */); - for (var _f = 0, signatures_1 = signatures; _f < signatures_1.length; _f++) { - var signature = signatures_1[_f]; + for (var _f = 0, signatures_2 = signatures; _f < signatures_2.length; _f++) { + var signature = signatures_2[_f]; writePropertyWithModifiers(p); buildSignatureDisplay(signature, writer, enclosingDeclaration, globalFlagsToPass, /*kind*/ undefined, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } } else { writePropertyWithModifiers(p); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); writeType(t, 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } } } function writeMappedType(type) { - writePunctuation(writer, 16 /* OpenBraceToken */); + writePunctuation(writer, 17 /* OpenBraceToken */); writer.writeLine(); writer.increaseIndent(); if (type.declaration.readonlyToken) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeKeyword(writer, 131 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); appendSymbolNameOnly(getTypeParameterFromMappedType(type).symbol, writer); writeSpace(writer); - writeKeyword(writer, 91 /* InKeyword */); + writeKeyword(writer, 92 /* InKeyword */); writeSpace(writer); writeType(getConstraintTypeFromMappedType(type), 0 /* None */); - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); if (type.declaration.questionToken) { - writePunctuation(writer, 54 /* QuestionToken */); + writePunctuation(writer, 55 /* QuestionToken */); } - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); writeType(getTemplateTypeFromMappedType(type), 0 /* None */); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); writer.decreaseIndent(); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); } } function buildTypeParameterDisplayFromSymbol(symbol, writer, enclosingDeclaration, flags) { @@ -27169,65 +28511,65 @@ var ts; var constraint = getConstraintOfTypeParameter(tp); if (constraint) { writeSpace(writer); - writeKeyword(writer, 84 /* ExtendsKeyword */); + writeKeyword(writer, 85 /* ExtendsKeyword */); writeSpace(writer); buildTypeDisplay(constraint, writer, enclosingDeclaration, flags, symbolStack); } var defaultType = getDefaultFromTypeParameter(tp); if (defaultType) { writeSpace(writer); - writePunctuation(writer, 57 /* EqualsToken */); + writePunctuation(writer, 58 /* EqualsToken */); writeSpace(writer); buildTypeDisplay(defaultType, writer, enclosingDeclaration, flags, symbolStack); } } function buildParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack) { var parameterNode = p.valueDeclaration; - if (ts.isRestParameter(parameterNode)) { - writePunctuation(writer, 23 /* DotDotDotToken */); + if (parameterNode ? ts.isRestParameter(parameterNode) : isTransientSymbol(p) && p.isRestParameter) { + writePunctuation(writer, 24 /* DotDotDotToken */); } - if (ts.isBindingPattern(parameterNode.name)) { + if (parameterNode && ts.isBindingPattern(parameterNode.name)) { buildBindingPatternDisplay(parameterNode.name, writer, enclosingDeclaration, flags, symbolStack); } else { appendSymbolNameOnly(p, writer); } - if (isOptionalParameter(parameterNode)) { - writePunctuation(writer, 54 /* QuestionToken */); + if (parameterNode && isOptionalParameter(parameterNode)) { + writePunctuation(writer, 55 /* QuestionToken */); } - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); var type = getTypeOfSymbol(p); - if (isRequiredInitializedParameter(parameterNode)) { + if (parameterNode && isRequiredInitializedParameter(parameterNode)) { type = includeFalsyTypes(type, 2048 /* Undefined */); } buildTypeDisplay(type, writer, enclosingDeclaration, flags, symbolStack); } function buildBindingPatternDisplay(bindingPattern, writer, enclosingDeclaration, flags, symbolStack) { // We have to explicitly emit square bracket and bracket because these tokens are not stored inside the node. - if (bindingPattern.kind === 173 /* ObjectBindingPattern */) { - writePunctuation(writer, 16 /* OpenBraceToken */); + if (bindingPattern.kind === 174 /* ObjectBindingPattern */) { + writePunctuation(writer, 17 /* OpenBraceToken */); buildDisplayForCommaSeparatedList(bindingPattern.elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 17 /* CloseBraceToken */); + writePunctuation(writer, 18 /* CloseBraceToken */); } - else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { - writePunctuation(writer, 20 /* OpenBracketToken */); + else if (bindingPattern.kind === 175 /* ArrayBindingPattern */) { + writePunctuation(writer, 21 /* OpenBracketToken */); var elements = bindingPattern.elements; buildDisplayForCommaSeparatedList(elements, writer, function (e) { return buildBindingElementDisplay(e, writer, enclosingDeclaration, flags, symbolStack); }); if (elements && elements.hasTrailingComma) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); } - writePunctuation(writer, 21 /* CloseBracketToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); } } function buildBindingElementDisplay(bindingElement, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isOmittedExpression(bindingElement)) { return; } - ts.Debug.assert(bindingElement.kind === 175 /* BindingElement */); + ts.Debug.assert(bindingElement.kind === 176 /* BindingElement */); if (bindingElement.propertyName) { writer.writeProperty(ts.getTextOfNode(bindingElement.propertyName)); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); } if (ts.isBindingPattern(bindingElement.name)) { @@ -27235,22 +28577,22 @@ var ts; } else { if (bindingElement.dotDotDotToken) { - writePunctuation(writer, 23 /* DotDotDotToken */); + writePunctuation(writer, 24 /* DotDotDotToken */); } appendSymbolNameOnly(bindingElement.symbol, writer); } } function buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, enclosingDeclaration, flags, symbolStack) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26 /* LessThanToken */); + writePunctuation(writer, 27 /* LessThanToken */); buildDisplayForCommaSeparatedList(typeParameters, writer, function (p) { return buildTypeParameterDisplay(p, writer, enclosingDeclaration, flags, symbolStack); }); - writePunctuation(writer, 28 /* GreaterThanToken */); + writePunctuation(writer, 29 /* GreaterThanToken */); } } function buildDisplayForCommaSeparatedList(list, writer, action) { for (var i = 0; i < list.length; i++) { if (i > 0) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); } action(list[i]); @@ -27258,42 +28600,42 @@ var ts; } function buildDisplayForTypeArgumentsAndDelimiters(typeParameters, mapper, writer, enclosingDeclaration) { if (typeParameters && typeParameters.length) { - writePunctuation(writer, 26 /* LessThanToken */); + writePunctuation(writer, 27 /* LessThanToken */); var flags = 256 /* InFirstTypeArgument */; for (var i = 0; i < typeParameters.length; i++) { if (i > 0) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); flags = 0 /* None */; } buildTypeDisplay(mapper(typeParameters[i]), writer, enclosingDeclaration, flags); } - writePunctuation(writer, 28 /* GreaterThanToken */); + writePunctuation(writer, 29 /* GreaterThanToken */); } } function buildDisplayForParametersAndDelimiters(thisParameter, parameters, writer, enclosingDeclaration, flags, symbolStack) { - writePunctuation(writer, 18 /* OpenParenToken */); + writePunctuation(writer, 19 /* OpenParenToken */); if (thisParameter) { buildParameterDisplay(thisParameter, writer, enclosingDeclaration, flags, symbolStack); } for (var i = 0; i < parameters.length; i++) { if (i > 0 || thisParameter) { - writePunctuation(writer, 25 /* CommaToken */); + writePunctuation(writer, 26 /* CommaToken */); writeSpace(writer); } buildParameterDisplay(parameters[i], writer, enclosingDeclaration, flags, symbolStack); } - writePunctuation(writer, 19 /* CloseParenToken */); + writePunctuation(writer, 20 /* CloseParenToken */); } function buildTypePredicateDisplay(predicate, writer, enclosingDeclaration, flags, symbolStack) { if (ts.isIdentifierTypePredicate(predicate)) { writer.writeParameter(predicate.parameterName); } else { - writeKeyword(writer, 98 /* ThisKeyword */); + writeKeyword(writer, 99 /* ThisKeyword */); } writeSpace(writer); - writeKeyword(writer, 125 /* IsKeyword */); + writeKeyword(writer, 126 /* IsKeyword */); writeSpace(writer); buildTypeDisplay(predicate.type, writer, enclosingDeclaration, flags, symbolStack); } @@ -27304,10 +28646,10 @@ var ts; } if (flags & 8 /* WriteArrowStyleSignature */) { writeSpace(writer); - writePunctuation(writer, 35 /* EqualsGreaterThanToken */); + writePunctuation(writer, 36 /* EqualsGreaterThanToken */); } else { - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); } writeSpace(writer); if (signature.typePredicate) { @@ -27319,7 +28661,7 @@ var ts; } function buildSignatureDisplay(signature, writer, enclosingDeclaration, flags, kind, symbolStack) { if (kind === 1 /* Construct */) { - writeKeyword(writer, 93 /* NewKeyword */); + writeKeyword(writer, 94 /* NewKeyword */); writeSpace(writer); } if (signature.target && (flags & 32 /* WriteTypeArgumentsOfSignature */)) { @@ -27336,26 +28678,26 @@ var ts; function buildIndexSignatureDisplay(info, writer, kind, enclosingDeclaration, globalFlags, symbolStack) { if (info) { if (info.isReadonly) { - writeKeyword(writer, 130 /* ReadonlyKeyword */); + writeKeyword(writer, 131 /* ReadonlyKeyword */); writeSpace(writer); } - writePunctuation(writer, 20 /* OpenBracketToken */); + writePunctuation(writer, 21 /* OpenBracketToken */); writer.writeParameter(info.declaration ? ts.declarationNameToString(info.declaration.parameters[0].name) : "x"); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); switch (kind) { case 1 /* Number */: - writeKeyword(writer, 132 /* NumberKeyword */); + writeKeyword(writer, 133 /* NumberKeyword */); break; case 0 /* String */: - writeKeyword(writer, 135 /* StringKeyword */); + writeKeyword(writer, 136 /* StringKeyword */); break; } - writePunctuation(writer, 21 /* CloseBracketToken */); - writePunctuation(writer, 55 /* ColonToken */); + writePunctuation(writer, 22 /* CloseBracketToken */); + writePunctuation(writer, 56 /* ColonToken */); writeSpace(writer); buildTypeDisplay(info.type, writer, enclosingDeclaration, globalFlags, symbolStack); - writePunctuation(writer, 24 /* SemicolonToken */); + writePunctuation(writer, 25 /* SemicolonToken */); writer.writeLine(); } } @@ -27384,22 +28726,22 @@ var ts; return false; function determineIfDeclarationIsVisible() { switch (node.kind) { - case 175 /* BindingElement */: + case 176 /* BindingElement */: return isDeclarationVisible(node.parent.parent); - case 225 /* VariableDeclaration */: + case 226 /* 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 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 227 /* FunctionDeclaration */: - case 231 /* EnumDeclaration */: - case 236 /* ImportEqualsDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 228 /* FunctionDeclaration */: + case 232 /* EnumDeclaration */: + case 237 /* ImportEqualsDeclaration */: // external module augmentation is always visible if (ts.isExternalModuleAugmentation(node)) { return true; @@ -27407,52 +28749,53 @@ var ts; var parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) if (!(ts.getCombinedModifierFlags(node) & 1 /* Export */) && - !(node.kind !== 236 /* ImportEqualsDeclaration */ && parent.kind !== 264 /* SourceFile */ && ts.isInAmbientContext(parent))) { + !(node.kind !== 237 /* ImportEqualsDeclaration */ && parent.kind !== 265 /* SourceFile */ && ts.isInAmbientContext(parent))) { return isGlobalSourceFile(parent); } // Exported members/ambient module elements (exception import declaration) are visible if parent is visible return isDeclarationVisible(parent); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.getModifierFlags(node) & (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 151 /* Constructor */: - case 155 /* ConstructSignature */: - case 154 /* CallSignature */: - case 156 /* IndexSignature */: - case 145 /* Parameter */: - case 233 /* ModuleBlock */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 162 /* TypeLiteral */: - case 158 /* TypeReference */: - case 163 /* ArrayType */: - case 164 /* TupleType */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: - case 167 /* ParenthesizedType */: + // Public properties/methods are visible if its parents are visible, so: + // falls through + case 152 /* Constructor */: + case 156 /* ConstructSignature */: + case 155 /* CallSignature */: + case 157 /* IndexSignature */: + case 146 /* Parameter */: + case 234 /* ModuleBlock */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 163 /* TypeLiteral */: + case 159 /* TypeReference */: + case 164 /* ArrayType */: + case 165 /* TupleType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: + case 168 /* 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 238 /* ImportClause */: - case 239 /* NamespaceImport */: - case 241 /* ImportSpecifier */: + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + case 242 /* ImportSpecifier */: return false; // Type parameters are always visible - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: // Source file and namespace export are always visible - case 264 /* SourceFile */: - case 235 /* NamespaceExportDeclaration */: + case 265 /* SourceFile */: + case 236 /* NamespaceExportDeclaration */: return true; // Export assignments do not create name bindings outside the module - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return false; default: return false; @@ -27461,10 +28804,10 @@ var ts; } function collectLinkedAliases(node) { var exportSymbol; - if (node.parent && node.parent.kind === 242 /* ExportAssignment */) { + if (node.parent && node.parent.kind === 243 /* ExportAssignment */) { exportSymbol = resolveName(node.parent, node.text, 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */, ts.Diagnostics.Cannot_find_name_0, node); } - else if (node.parent.kind === 245 /* ExportSpecifier */) { + else if (node.parent.kind === 246 /* ExportSpecifier */) { var exportSpecifier = node.parent; exportSymbol = exportSpecifier.parent.parent.moduleSpecifier ? getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : @@ -27509,8 +28852,8 @@ var ts; var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName); if (resolutionCycleStartIndex >= 0) { // A cycle was found - var length_2 = resolutionTargets.length; - for (var i = resolutionCycleStartIndex; i < length_2; i++) { + var length_3 = resolutionTargets.length; + for (var i = resolutionCycleStartIndex; i < length_3; i++) { resolutionResults[i] = false; } return false; @@ -27554,21 +28897,20 @@ var ts; return resolutionResults.pop(); } function getDeclarationContainer(node) { - node = ts.getRootDeclaration(node); - while (node) { + node = ts.findAncestor(ts.getRootDeclaration(node), function (node) { switch (node.kind) { - case 225 /* VariableDeclaration */: - case 226 /* VariableDeclarationList */: - case 241 /* ImportSpecifier */: - case 240 /* NamedImports */: - case 239 /* NamespaceImport */: - case 238 /* ImportClause */: - node = node.parent; - break; + case 226 /* VariableDeclaration */: + case 227 /* VariableDeclarationList */: + case 242 /* ImportSpecifier */: + case 241 /* NamedImports */: + case 240 /* NamespaceImport */: + case 239 /* ImportClause */: + return false; default: - return node.parent; + return true; } - } + }); + return node && node.parent; } function getTypeOfPrototypeProperty(prototype) { // TypeScript 1.0 spec (April 2014): 8.4 @@ -27593,7 +28935,7 @@ var ts; return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, /*includeOptionality*/ false); } function isComputedNonLiteralName(name) { - return name.kind === 143 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); + return name.kind === 144 /* ComputedPropertyName */ && !ts.isStringOrNumericLiteral(name.expression); } function getRestType(source, properties, symbol) { source = filterType(source, function (t) { return !(t.flags & 6144 /* Nullable */); }); @@ -27605,8 +28947,8 @@ var ts; } var members = ts.createMap(); var names = ts.createMap(); - for (var _i = 0, properties_2 = properties; _i < properties_2.length; _i++) { - var name = properties_2[_i]; + for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { + var name = properties_3[_i]; names.set(ts.getTextOfPropertyName(name), true); } for (var _a = 0, _b = getPropertiesOfType(source); _a < _b.length; _a++) { @@ -27640,7 +28982,7 @@ var ts; return parentType; } var type; - if (pattern.kind === 173 /* ObjectBindingPattern */) { + if (pattern.kind === 174 /* ObjectBindingPattern */) { if (declaration.dotDotDotToken) { if (!isValidSpreadType(parentType)) { error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types); @@ -27681,7 +29023,7 @@ var ts; // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false); + var elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); if (declaration.dotDotDotToken) { // Rest element has an array type with the same element type as the parent type type = createArrayType(elementType); @@ -27721,24 +29063,15 @@ var ts; } function isNullOrUndefined(node) { var expr = ts.skipParentheses(node); - return expr.kind === 94 /* NullKeyword */ || expr.kind === 70 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; + return expr.kind === 95 /* NullKeyword */ || expr.kind === 71 /* Identifier */ && getResolvedSymbol(expr) === undefinedSymbol; } function isEmptyArrayLiteral(node) { var expr = ts.skipParentheses(node); - return expr.kind === 176 /* ArrayLiteralExpression */ && expr.elements.length === 0; + return expr.kind === 177 /* ArrayLiteralExpression */ && expr.elements.length === 0; } function addOptionality(type, optional) { return strictNullChecks && optional ? includeFalsyTypes(type, 2048 /* Undefined */) : type; } - /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ - function removeOptionalityFromAnnotation(annotatedType, declaration) { - var annotationIncludesUndefined = strictNullChecks && - declaration.kind === 145 /* Parameter */ && - declaration.initializer && - getFalsyFlags(annotatedType) & 2048 /* Undefined */ && - !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); - return annotationIncludesUndefined ? getNonNullableType(annotatedType) : annotatedType; - } // Return the inferred type for a variable, parameter, or property declaration function getTypeForVariableLikeDeclaration(declaration, includeOptionality) { if (declaration.flags & 65536 /* JavaScriptFile */) { @@ -27752,27 +29085,28 @@ var ts; } // A variable declared in a for..in statement is of type string, or of type keyof T when the // right hand expression is of a type parameter type. - if (declaration.parent.parent.kind === 214 /* ForInStatement */) { + if (declaration.parent.parent.kind === 215 /* ForInStatement */) { var indexType = getIndexType(checkNonNullExpression(declaration.parent.parent.expression)); return indexType.flags & (16384 /* TypeParameter */ | 262144 /* Index */) ? indexType : stringType; } - if (declaration.parent.parent.kind === 215 /* ForOfStatement */) { + if (declaration.parent.parent.kind === 216 /* 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, // or it may have led to an error inside getElementTypeOfIterable. - return checkRightHandSideOfForOf(declaration.parent.parent.expression) || anyType; + var forOfStatement = declaration.parent.parent; + return checkRightHandSideOfForOf(forOfStatement.expression, forOfStatement.awaitModifier) || anyType; } if (ts.isBindingPattern(declaration.parent)) { return getTypeForBindingElement(declaration); } // Use type from type annotation if one is present if (declaration.type) { - var declaredType = removeOptionalityFromAnnotation(getTypeFromTypeNode(declaration.type), declaration); + var declaredType = getTypeFromTypeNode(declaration.type); return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } - if ((compilerOptions.noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && - declaration.kind === 225 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && + if ((noImplicitAny || declaration.flags & 65536 /* JavaScriptFile */) && + declaration.kind === 226 /* VariableDeclaration */ && !ts.isBindingPattern(declaration.name) && !(ts.getCombinedModifierFlags(declaration) & 1 /* Export */) && !ts.isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no @@ -27786,11 +29120,11 @@ var ts; return autoArrayType; } } - if (declaration.kind === 145 /* Parameter */) { + if (declaration.kind === 146 /* 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 === 153 /* SetAccessor */ && !ts.hasDynamicName(func)) { - var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 152 /* GetAccessor */); + if (func.kind === 154 /* SetAccessor */ && !ts.hasDynamicName(func)) { + var getter = ts.getDeclarationOfKind(declaration.parent.symbol, 153 /* GetAccessor */); if (getter) { var getterSignature = getSignatureFromDeclaration(getter); var thisParameter = getAccessorThisParameter(func); @@ -27825,7 +29159,7 @@ var ts; return trueType; } // If it is a short-hand property assignment, use the type of the identifier - if (declaration.kind === 261 /* ShorthandPropertyAssignment */) { + if (declaration.kind === 262 /* ShorthandPropertyAssignment */) { return checkIdentifier(declaration.name); } // If the declaration specifies a binding pattern, use the type implied by the binding pattern @@ -27835,22 +29169,37 @@ var ts; // No type specified and nothing can be inferred return undefined; } - // Return the inferred type for a variable, parameter, or property declaration - function getTypeForJSSpecialPropertyDeclaration(declaration) { - var expression = declaration.kind === 193 /* BinaryExpression */ ? declaration : - declaration.kind === 178 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 193 /* BinaryExpression */) : - undefined; - if (!expression) { - return unknownType; - } - if (expression.flags & 65536 /* JavaScriptFile */) { - // If there is a JSDoc type, use it - var type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - return getWidenedType(type); + function getWidenedTypeFromJSSpecialPropertyDeclarations(symbol) { + var types = []; + var definedInConstructor = false; + var definedInMethod = false; + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + var expression = declaration.kind === 194 /* BinaryExpression */ ? declaration : + declaration.kind === 179 /* PropertyAccessExpression */ ? ts.getAncestor(declaration, 194 /* BinaryExpression */) : + undefined; + if (!expression) { + return unknownType; } + if (ts.isPropertyAccessExpression(expression.left) && expression.left.expression.kind === 99 /* ThisKeyword */) { + if (ts.getThisContainer(expression, /*includeArrowFunctions*/ false).kind === 152 /* Constructor */) { + definedInConstructor = true; + } + else { + definedInMethod = true; + } + } + if (expression.flags & 65536 /* JavaScriptFile */) { + // If there is a JSDoc type, use it + var type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type && type !== unknownType) { + types.push(getWidenedType(type)); + continue; + } + } + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); } - return getWidenedLiteralType(checkExpressionCached(expression.right)); + return getWidenedType(addOptionality(getUnionType(types, /*subtypeReduction*/ true), definedInMethod && !definedInConstructor)); } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if // one is present. Otherwise, if the element is itself a binding pattern, it is the type implied by the binding @@ -27862,7 +29211,7 @@ var ts; if (ts.isBindingPattern(element.name)) { return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors); } - if (reportErrors && compilerOptions.noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { + if (reportErrors && noImplicitAny && !declarationBelongsToPrivateAmbientMember(element)) { reportImplicitAnyError(element, anyType); } return anyType; @@ -27923,7 +29272,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, reportErrors) { - return pattern.kind === 173 /* ObjectBindingPattern */ + return pattern.kind === 174 /* ObjectBindingPattern */ ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors); } @@ -27945,7 +29294,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 === 260 /* PropertyAssignment */) { + if (declaration.kind === 261 /* PropertyAssignment */) { return type; } return getWidenedType(type); @@ -27953,7 +29302,7 @@ var ts; // Rest parameters default to type any[], other parameters default to type any type = declaration.dotDotDotToken ? anyArrayType : anyType; // Report implicit any errors unless this is a private property within an ambient declaration - if (reportErrors && compilerOptions.noImplicitAny) { + if (reportErrors && noImplicitAny) { if (!declarationBelongsToPrivateAmbientMember(declaration)) { reportImplicitAnyError(declaration, type); } @@ -27962,7 +29311,7 @@ var ts; } function declarationBelongsToPrivateAmbientMember(declaration) { var root = ts.getRootDeclaration(declaration); - var memberDeclaration = root.kind === 145 /* Parameter */ ? root.parent : root; + var memberDeclaration = root.kind === 146 /* Parameter */ ? root.parent : root; return isPrivateWithinAmbient(memberDeclaration); } function getTypeOfVariableOrParameterOrProperty(symbol) { @@ -27978,10 +29327,10 @@ var ts; return links.type = anyType; } // Handle export default expressions - if (declaration.kind === 242 /* ExportAssignment */) { + if (declaration.kind === 243 /* ExportAssignment */) { return links.type = checkExpression(declaration.expression); } - if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 290 /* JSDocPropertyTag */ && declaration.typeExpression) { + if (declaration.flags & 65536 /* JavaScriptFile */ && declaration.kind === 291 /* JSDocPropertyTag */ && declaration.typeExpression) { return links.type = getTypeFromTypeNode(declaration.typeExpression.type); } // Handle variable, parameter or property @@ -27994,9 +29343,9 @@ var ts; // * exports.p = expr // * this.p = expr // * className.prototype.method = expr - if (declaration.kind === 193 /* BinaryExpression */ || - declaration.kind === 178 /* PropertyAccessExpression */ && declaration.parent.kind === 193 /* BinaryExpression */) { - type = getWidenedType(getUnionType(ts.map(symbol.declarations, getTypeForJSSpecialPropertyDeclaration), /*subtypeReduction*/ true)); + if (declaration.kind === 194 /* BinaryExpression */ || + declaration.kind === 179 /* PropertyAccessExpression */ && declaration.parent.kind === 194 /* BinaryExpression */) { + type = getWidenedTypeFromJSSpecialPropertyDeclarations(symbol); } else { type = getWidenedTypeForVariableLikeDeclaration(declaration, /*reportErrors*/ true); @@ -28010,7 +29359,7 @@ var ts; } function getAnnotatedAccessorType(accessor) { if (accessor) { - if (accessor.kind === 152 /* GetAccessor */) { + if (accessor.kind === 153 /* GetAccessor */) { return accessor.type && getTypeFromTypeNode(accessor.type); } else { @@ -28030,8 +29379,8 @@ var ts; function getTypeOfAccessors(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - var getter = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); - var setter = ts.getDeclarationOfKind(symbol, 153 /* SetAccessor */); + var getter = ts.getDeclarationOfKind(symbol, 153 /* GetAccessor */); + var setter = ts.getDeclarationOfKind(symbol, 154 /* SetAccessor */); if (getter && getter.flags & 65536 /* JavaScriptFile */) { var jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { @@ -28059,7 +29408,7 @@ var ts; type = getReturnTypeFromBody(getter); } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { if (setter) { error(setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol)); } @@ -28074,8 +29423,8 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { - var getter_1 = ts.getDeclarationOfKind(symbol, 152 /* GetAccessor */); + if (noImplicitAny) { + var getter_1 = ts.getDeclarationOfKind(symbol, 153 /* 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)); } } @@ -28131,14 +29480,22 @@ var ts; function getTypeOfInstantiatedSymbol(symbol) { var links = getSymbolLinks(symbol); if (!links.type) { - if (!pushTypeResolution(symbol, 0 /* Type */)) { - return unknownType; + if (symbolInstantiationDepth === 100) { + error(symbol.valueDeclaration, ts.Diagnostics.Generic_type_instantiation_is_excessively_deep_and_possibly_infinite); + links.type = unknownType; } - var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); - if (!popTypeResolution()) { - type = reportCircularityError(symbol); + else { + if (!pushTypeResolution(symbol, 0 /* Type */)) { + return unknownType; + } + symbolInstantiationDepth++; + var type = instantiateType(getTypeOfSymbol(links.target), links.mapper); + symbolInstantiationDepth--; + if (!popTypeResolution()) { + type = reportCircularityError(symbol); + } + links.type = type; } - links.type = type; } return links.type; } @@ -28149,7 +29506,7 @@ var ts; return unknownType; } // Otherwise variable has initializer that circularly references the variable itself - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(symbol.valueDeclaration, ts.Diagnostics._0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer, symbolToString(symbol)); } return anyType; @@ -28175,6 +29532,12 @@ var ts; } return unknownType; } + function isReferenceToType(type, target) { + return type !== undefined + && target !== undefined + && (getObjectFlags(type) & 4 /* Reference */) !== 0 + && type.target === target; + } function getTargetType(type) { return getObjectFlags(type) & 4 /* Reference */ ? type.target : type; } @@ -28215,9 +29578,9 @@ var ts; if (!node) { return typeParameters; } - if (node.kind === 228 /* ClassDeclaration */ || node.kind === 198 /* ClassExpression */ || - node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */ || - node.kind === 150 /* MethodDeclaration */ || node.kind === 186 /* ArrowFunction */) { + if (node.kind === 229 /* ClassDeclaration */ || node.kind === 199 /* ClassExpression */ || + node.kind === 228 /* FunctionDeclaration */ || node.kind === 186 /* FunctionExpression */ || + node.kind === 151 /* MethodDeclaration */ || node.kind === 187 /* ArrowFunction */) { var declarations = node.typeParameters; if (declarations) { return appendTypeParameters(appendOuterTypeParameters(typeParameters, node), declarations); @@ -28227,8 +29590,8 @@ 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, 229 /* InterfaceDeclaration */); - return appendOuterTypeParameters(undefined, declaration); + var declaration = symbol.flags & 32 /* Class */ ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 230 /* InterfaceDeclaration */); + return appendOuterTypeParameters(/*typeParameters*/ undefined, declaration); } // The local type parameters are the combined set of type parameters from all declarations of the class, // interface, or type alias. @@ -28236,8 +29599,8 @@ var ts; var result; for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var node = _a[_i]; - if (node.kind === 229 /* InterfaceDeclaration */ || node.kind === 228 /* ClassDeclaration */ || - node.kind === 198 /* ClassExpression */ || node.kind === 230 /* TypeAliasDeclaration */) { + if (node.kind === 230 /* InterfaceDeclaration */ || node.kind === 229 /* ClassDeclaration */ || + node.kind === 199 /* ClassExpression */ || node.kind === 231 /* TypeAliasDeclaration */) { var declaration = node; if (declaration.typeParameters) { result = appendTypeParameters(result, declaration.typeParameters); @@ -28267,19 +29630,20 @@ var ts; } if (type.flags & 540672 /* TypeVariable */) { var constraint = getBaseConstraintOfType(type); - return isValidBaseType(constraint) && isMixinConstructorType(constraint); + return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint); } return false; } function getBaseTypeNodeOfClass(type) { return ts.getClassExtendsHeritageClauseElement(type.symbol.valueDeclaration); } - function getConstructorsForTypeArguments(type, typeArgumentNodes) { + function getConstructorsForTypeArguments(type, typeArgumentNodes, location) { var typeArgCount = ts.length(typeArgumentNodes); - return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return typeArgCount >= getMinTypeArgumentCount(sig.typeParameters) && typeArgCount <= ts.length(sig.typeParameters); }); + var isJavaScript = ts.isInJavaScriptFile(location); + return ts.filter(getSignaturesOfType(type, 1 /* Construct */), function (sig) { return (isJavaScript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); }); } - function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes) { - var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes); + function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) { + var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location); if (typeArgumentNodes) { var typeArguments_1 = ts.map(typeArgumentNodes, getTypeFromTypeNode); signatures = ts.map(signatures, function (sig) { return getSignatureInstantiation(sig, typeArguments_1); }); @@ -28290,7 +29654,8 @@ var ts; * The base constructor of a class can resolve to * * undefinedType if the class has no extends clause, * * unknownType if an error occurred during resolution of the extends expression, - * * nullType if the extends expression is the null value, or + * * nullType if the extends expression is the null value, + * * anyType if the extends expression has type any, or * * an object type with at least one construct signature. */ function getBaseConstructorTypeOfClass(type) { @@ -28312,7 +29677,7 @@ var ts; error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol)); return type.resolvedBaseConstructorType = unknownType; } - if (baseConstructorType !== unknownType && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { + if (!(baseConstructorType.flags & 1 /* Any */) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) { error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType)); return type.resolvedBaseConstructorType = unknownType; } @@ -28342,7 +29707,7 @@ var ts; function resolveBaseTypesOfClass(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type)); - if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */))) { + if (!(baseConstructorType.flags & (32768 /* Object */ | 131072 /* Intersection */ | 1 /* Any */))) { return; } var baseTypeNode = getBaseTypeNodeOfClass(type); @@ -28355,11 +29720,14 @@ var ts; // type arguments in the same manner as a type reference to get the same error reporting experience. baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); } + else if (baseConstructorType.flags & 1 /* Any */) { + baseType = baseConstructorType; + } else { // The class derives from a "class-like" constructor function, check that we have at least one construct signature // with a matching number of type parameters and use the return type of the first instantiated signature. Elsewhere // we check that all instantiated signatures return the same type. - var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments); + var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode); if (!constructors.length) { error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments); return; @@ -28403,17 +29771,17 @@ var ts; } return true; } - // A valid base type is any non-generic object type or intersection of non-generic + // A valid base type is `any`, any non-generic object type or intersection of non-generic // object types. function isValidBaseType(type) { - return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */) && !isGenericMappedType(type) || + return type.flags & (32768 /* Object */ | 16777216 /* NonPrimitive */ | 1 /* Any */) && !isGenericMappedType(type) || type.flags & 131072 /* Intersection */ && !ts.forEach(type.types, function (t) { return !isValidBaseType(t); }); } function resolveBaseTypesOfInterface(type) { type.resolvedBaseTypes = type.resolvedBaseTypes || emptyArray; for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { + if (declaration.kind === 230 /* InterfaceDeclaration */ && ts.getInterfaceBaseTypeNodes(declaration)) { for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) { var node = _c[_b]; var baseType = getTypeFromTypeNode(node); @@ -28445,7 +29813,7 @@ var ts; function isIndependentInterface(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 229 /* InterfaceDeclaration */) { + if (declaration.kind === 230 /* InterfaceDeclaration */) { if (declaration.flags & 64 /* ContainsThis */) { return false; } @@ -28502,7 +29870,7 @@ var ts; if (!pushTypeResolution(symbol, 2 /* DeclaredType */)) { return unknownType; } - var declaration = ts.getDeclarationOfKind(symbol, 289 /* JSDocTypedefTag */); + var declaration = ts.getDeclarationOfKind(symbol, 290 /* JSDocTypedefTag */); var type = void 0; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -28513,7 +29881,7 @@ var ts; } } else { - declaration = ts.getDeclarationOfKind(symbol, 230 /* TypeAliasDeclaration */); + declaration = ts.getDeclarationOfKind(symbol, 231 /* TypeAliasDeclaration */); type = getTypeFromTypeNode(declaration.type); } if (popTypeResolution()) { @@ -28540,14 +29908,14 @@ var ts; return !ts.isInAmbientContext(member); } return expr.kind === 8 /* NumericLiteral */ || - expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 192 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */ || - expr.kind === 70 /* Identifier */ && !!symbol.exports.get(expr.text); + expr.kind === 71 /* Identifier */ && !!symbol.exports.get(expr.text); } function enumHasLiteralMembers(symbol) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231 /* EnumDeclaration */) { + if (declaration.kind === 232 /* EnumDeclaration */) { for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; if (!isLiteralEnumMember(symbol, member)) { @@ -28575,7 +29943,7 @@ var ts; var memberTypes = []; for (var _i = 0, _a = enumType.symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (declaration.kind === 231 /* EnumDeclaration */) { + if (declaration.kind === 232 /* EnumDeclaration */) { computeEnumMemberValues(declaration); for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) { var member = _c[_b]; @@ -28662,21 +30030,21 @@ var ts; // considered independent. function isIndependentType(node) { switch (node.kind) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 136 /* SymbolKeyword */: - case 133 /* ObjectKeyword */: - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 129 /* NeverKeyword */: - case 172 /* LiteralType */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 137 /* SymbolKeyword */: + case 134 /* ObjectKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 130 /* NeverKeyword */: + case 173 /* LiteralType */: return true; - case 163 /* ArrayType */: + case 164 /* ArrayType */: return isIndependentType(node.elementType); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return isIndependentTypeReference(node); } return false; @@ -28689,7 +30057,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 !== 151 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { + if (node.kind !== 152 /* Constructor */ && (!node.type || !isIndependentType(node.type))) { return false; } for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { @@ -28710,12 +30078,12 @@ var ts; var declaration = symbol.declarations[0]; if (declaration) { switch (declaration.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return isIndependentVariableLikeDeclaration(declaration); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: return isIndependentFunctionLikeDeclaration(declaration); } } @@ -28807,7 +30175,11 @@ var ts; addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType)); callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0 /* Call */)); constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1 /* Construct */)); - stringIndexInfo = stringIndexInfo || getIndexInfoOfType(instantiatedBaseType, 0 /* String */); + if (!stringIndexInfo) { + stringIndexInfo = instantiatedBaseType === anyType ? + createIndexInfo(anyType, /*isReadonly*/ false) : + getIndexInfoOfType(instantiatedBaseType, 0 /* String */); + } numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1 /* Number */); } } @@ -28846,6 +30218,7 @@ var ts; return [createSignature(undefined, classType.localTypeParameters, undefined, emptyArray, classType, /*typePredicate*/ undefined, 0, /*hasRestParameter*/ false, /*hasLiteralTypes*/ false)]; } var baseTypeNode = getBaseTypeNodeOfClass(classType); + var isJavaScript = ts.isInJavaScriptFile(baseTypeNode); var typeArguments = ts.map(baseTypeNode.typeArguments, getTypeFromTypeNode); var typeArgCount = ts.length(typeArguments); var result = []; @@ -28853,8 +30226,8 @@ var ts; var baseSig = baseSignatures_1[_i]; var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters); var typeParamCount = ts.length(baseSig.typeParameters); - if (typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) { - var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount)) : cloneSignature(baseSig); + if ((isJavaScript || typeArgCount >= minTypeArgumentCount) && typeArgCount <= typeParamCount) { + var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, baseTypeNode)) : cloneSignature(baseSig); sig.typeParameters = classType.localTypeParameters; sig.resolvedReturnType = classType; result.push(sig); @@ -28933,8 +30306,8 @@ var ts; 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]; + for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { + var type = types_2[_i]; var indexInfo = getIndexInfoOfType(type, kind); if (!indexInfo) { return undefined; @@ -29035,7 +30408,8 @@ var ts; // Combinations of function, class, enum and module var members = emptySymbols; var constructSignatures = emptyArray; - if (symbol.flags & 1952 /* HasExports */) { + var stringIndexInfo = undefined; + if (symbol.exports) { members = getExportsOfSymbol(symbol); } if (symbol.flags & 32 /* Class */) { @@ -29049,9 +30423,12 @@ var ts; members = createSymbolTable(getNamedMembers(members)); addInheritedMembers(members, getPropertiesOfType(baseConstructorType)); } + else if (baseConstructorType === anyType) { + stringIndexInfo = createIndexInfo(anyType, /*isReadonly*/ false); + } } var numberIndexInfo = symbol.flags & 384 /* Enum */ ? enumNumberIndexInfo : undefined; - setStructuredTypeMembers(type, members, emptyArray, constructSignatures, undefined, numberIndexInfo); + setStructuredTypeMembers(type, members, emptyArray, constructSignatures, stringIndexInfo, 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 @@ -29075,7 +30452,7 @@ var ts; var modifiersType = getApparentType(getModifiersTypeFromMappedType(type)); // The 'T' in 'keyof T' var templateReadonly = !!type.declaration.readonlyToken; var templateOptional = !!type.declaration.questionToken; - if (type.declaration.typeParameter.constraint.kind === 169 /* TypeOperator */) { + if (type.declaration.typeParameter.constraint.kind === 170 /* TypeOperator */) { // We have a { [P in keyof T]: X } for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) { var propertySymbol = _a[_i]; @@ -29108,10 +30485,10 @@ var ts; var modifiersProp = getPropertyOfType(modifiersType, propName); var isOptional = templateOptional || !!(modifiersProp && modifiersProp.flags & 67108864 /* Optional */); var prop = createSymbol(4 /* Property */ | (isOptional ? 67108864 /* Optional */ : 0), propName); - prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 4 /* Readonly */ : 0; + prop.checkFlags = templateReadonly || modifiersProp && isReadonlySymbol(modifiersProp) ? 8 /* Readonly */ : 0; prop.type = propType; if (propertySymbol) { - prop.mappedTypeOrigin = propertySymbol; + prop.syntheticOrigin = propertySymbol; } members.set(propName, prop); } @@ -29137,7 +30514,7 @@ var ts; function getModifiersTypeFromMappedType(type) { if (!type.modifiersType) { var constraintDeclaration = type.declaration.typeParameter.constraint; - if (constraintDeclaration.kind === 169 /* TypeOperator */) { + if (constraintDeclaration.kind === 170 /* TypeOperator */) { // If the constraint declaration is a 'keyof T' node, the modifiers type is T. We check // AST nodes here because, when T is a non-generic type, the logic below eagerly resolves // 'keyof T' to a literal union type and we can't recover T from that type. @@ -29195,7 +30572,8 @@ var ts; return emptyArray; } /** If the given type is an object type and that type has a property by the given name, - * return the symbol for that property. Otherwise return undefined. */ + * return the symbol for that property. Otherwise return undefined. + */ function getPropertyOfObjectType(type, name) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); @@ -29236,14 +30614,29 @@ var ts; getPropertiesOfObjectType(type); } function getConstraintOfType(type) { - return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type); + return type.flags & 16384 /* TypeParameter */ ? getConstraintOfTypeParameter(type) : + type.flags & 524288 /* IndexedAccess */ ? getConstraintOfIndexedAccess(type) : + getBaseConstraintOfType(type); } function getConstraintOfTypeParameter(typeParameter) { return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined; } + function getConstraintOfIndexedAccess(type) { + var baseObjectType = getBaseConstraintOfType(type.objectType); + var baseIndexType = getBaseConstraintOfType(type.indexType); + return baseObjectType || baseIndexType ? getIndexedAccessType(baseObjectType || type.objectType, baseIndexType || type.indexType) : undefined; + } function getBaseConstraintOfType(type) { - var constraint = getResolvedBaseConstraint(type); - return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined; + if (type.flags & (540672 /* TypeVariable */ | 196608 /* UnionOrIntersection */)) { + var constraint = getResolvedBaseConstraint(type); + if (constraint !== noConstraintType && constraint !== circularConstraintType) { + return constraint; + } + } + else if (type.flags & 262144 /* Index */) { + return stringType; + } + return undefined; } function hasNonCircularBaseConstraint(type) { return getResolvedBaseConstraint(type) !== circularConstraintType; @@ -29281,9 +30674,9 @@ var ts; if (t.flags & 196608 /* UnionOrIntersection */) { var types = t.types; var baseTypes = []; - for (var _i = 0, types_2 = types; _i < types_2.length; _i++) { - var type_1 = types_2[_i]; - var baseType = getBaseConstraint(type_1); + for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { + var type_2 = types_3[_i]; + var baseType = getBaseConstraint(type_2); if (baseType) { baseTypes.push(baseType); } @@ -29340,7 +30733,7 @@ var ts; t.flags & 262178 /* StringLike */ ? globalStringType : t.flags & 340 /* NumberLike */ ? globalNumberType : t.flags & 136 /* BooleanLike */ ? globalBooleanType : - t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType() : + t.flags & 512 /* ESSymbol */ ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= 2 /* ES2015 */) : t.flags & 16777216 /* NonPrimitive */ ? emptyObjectType : t; } @@ -29351,9 +30744,10 @@ var ts; var excludeModifiers = isUnion ? 24 /* NonPublicAccessibilityModifier */ : 0; // Flags we want to propagate to the result if they exist in all source symbols var commonFlags = isUnion ? 0 /* None */ : 67108864 /* Optional */; - var checkFlags = 2 /* SyntheticProperty */; - for (var _i = 0, types_3 = types; _i < types_3.length; _i++) { - var current = types_3[_i]; + var syntheticFlag = 4 /* SyntheticMethod */; + var checkFlags = 0; + for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { + var current = types_4[_i]; var type = getApparentType(current); if (type !== unknownType) { var prop = getPropertyOfType(type, name); @@ -29366,21 +30760,24 @@ var ts; else if (!ts.contains(props, prop)) { props.push(prop); } - checkFlags |= (isReadonlySymbol(prop) ? 4 /* Readonly */ : 0) | - (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 32 /* ContainsPublic */ : 0) | - (modifiers & 16 /* Protected */ ? 64 /* ContainsProtected */ : 0) | - (modifiers & 8 /* Private */ ? 128 /* ContainsPrivate */ : 0) | - (modifiers & 32 /* Static */ ? 256 /* ContainsStatic */ : 0); + checkFlags |= (isReadonlySymbol(prop) ? 8 /* Readonly */ : 0) | + (!(modifiers & 24 /* NonPublicAccessibilityModifier */) ? 64 /* ContainsPublic */ : 0) | + (modifiers & 16 /* Protected */ ? 128 /* ContainsProtected */ : 0) | + (modifiers & 8 /* Private */ ? 256 /* ContainsPrivate */ : 0) | + (modifiers & 32 /* Static */ ? 512 /* ContainsStatic */ : 0); + if (!isMethodLike(prop)) { + syntheticFlag = 2 /* SyntheticProperty */; + } } else if (isUnion) { - checkFlags |= 8 /* Partial */; + checkFlags |= 16 /* Partial */; } } } if (!props) { return undefined; } - if (props.length === 1 && !(checkFlags & 8 /* Partial */)) { + if (props.length === 1 && !(checkFlags & 16 /* Partial */)) { return props[0]; } var propTypes = []; @@ -29396,12 +30793,12 @@ var ts; commonType = type; } else if (type !== commonType) { - checkFlags |= 16 /* HasNonUniformType */; + checkFlags |= 32 /* HasNonUniformType */; } propTypes.push(type); } var result = createSymbol(4 /* Property */ | commonFlags, name); - result.checkFlags = checkFlags; + result.checkFlags = syntheticFlag | checkFlags; result.containingType = containingType; result.declarations = declarations; result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes); @@ -29426,7 +30823,7 @@ var ts; function getPropertyOfUnionOrIntersectionType(type, name) { var property = getUnionOrIntersectionProperty(type, name); // We need to filter out partial properties in union types - return property && !(getCheckFlags(property) & 8 /* Partial */) ? property : undefined; + return property && !(getCheckFlags(property) & 16 /* Partial */) ? property : undefined; } /** * Return the symbol for the property with the given name in the given type. Creates synthetic union properties when @@ -29538,7 +30935,7 @@ var ts; } function isJSDocOptionalParameter(node) { if (node.flags & 65536 /* JavaScriptFile */) { - if (node.type && node.type.kind === 277 /* JSDocOptionalType */) { + if (node.type && node.type.kind === 278 /* JSDocOptionalType */) { return true; } var paramTags = ts.getJSDocParameterTags(node); @@ -29549,7 +30946,7 @@ var ts; return true; } if (paramTag.typeExpression) { - return paramTag.typeExpression.type.kind === 277 /* JSDocOptionalType */; + return paramTag.typeExpression.type.kind === 278 /* JSDocOptionalType */; } } } @@ -29583,7 +30980,7 @@ var ts; return false; } function createTypePredicateFromTypePredicateNode(node) { - if (node.parameterName.kind === 70 /* Identifier */) { + if (node.parameterName.kind === 71 /* Identifier */) { var parameterName = node.parameterName; return { kind: 1 /* Identifier */, @@ -29622,11 +31019,12 @@ var ts; * @param typeParameters The requested type parameters. * @param minTypeArgumentCount The minimum number of required type arguments. */ - function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount) { + function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, location) { var numTypeParameters = ts.length(typeParameters); if (numTypeParameters) { var numTypeArguments = ts.length(typeArguments); - if (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters) { + var isJavaScript = ts.isInJavaScriptFile(location); + if ((isJavaScript || numTypeArguments >= minTypeArgumentCount) && numTypeArguments <= numTypeParameters) { if (!typeArguments) { typeArguments = []; } @@ -29634,12 +31032,12 @@ var ts; // If a type parameter does not have a default type, or if the default type // is a forward reference, the empty object type is used. for (var i = numTypeArguments; i < numTypeParameters; i++) { - typeArguments[i] = emptyObjectType; + typeArguments[i] = isJavaScript ? anyType : emptyObjectType; } for (var i = numTypeArguments; i < numTypeParameters; i++) { var mapper = createTypeMapper(typeParameters, typeArguments); var defaultType = getDefaultFromTypeParameter(typeParameters[i]); - typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : emptyObjectType; + typeArguments[i] = defaultType ? instantiateType(defaultType, mapper) : isJavaScript ? anyType : emptyObjectType; } } } @@ -29674,7 +31072,7 @@ var ts; else { parameters.push(paramSymbol); } - if (param.type && param.type.kind === 172 /* LiteralType */) { + if (param.type && param.type.kind === 173 /* LiteralType */) { hasLiteralTypes = true; } // Record a new minimum argument count if this is not an optional parameter @@ -29687,23 +31085,23 @@ var ts; } } // If only one accessor includes a this-type annotation, the other behaves as if it had the same type annotation - if ((declaration.kind === 152 /* GetAccessor */ || declaration.kind === 153 /* SetAccessor */) && + if ((declaration.kind === 153 /* GetAccessor */ || declaration.kind === 154 /* SetAccessor */) && !ts.hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { - var otherKind = declaration.kind === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; + var otherKind = declaration.kind === 153 /* GetAccessor */ ? 154 /* SetAccessor */ : 153 /* GetAccessor */; var other = ts.getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } } - var classType = declaration.kind === 151 /* Constructor */ ? + var classType = declaration.kind === 152 /* Constructor */ ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol)) : undefined; var typeParameters = classType ? classType.localTypeParameters : declaration.typeParameters ? getTypeParametersFromDeclaration(declaration.typeParameters) : getTypeParametersFromJSDocTemplate(declaration); var returnType = getSignatureReturnTypeFromDeclaration(declaration, isJSConstructSignature, classType); - var typePredicate = declaration.type && declaration.type.kind === 157 /* TypePredicate */ ? + var typePredicate = declaration.type && declaration.type.kind === 158 /* TypePredicate */ ? createTypePredicateFromTypePredicateNode(declaration.type) : undefined; links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, returnType, typePredicate, minArgumentCount, ts.hasRestParameter(declaration), hasLiteralTypes); @@ -29728,14 +31126,42 @@ var ts; } // 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 === 152 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { - var setter = ts.getDeclarationOfKind(declaration.symbol, 153 /* SetAccessor */); + if (declaration.kind === 153 /* GetAccessor */ && !ts.hasDynamicName(declaration)) { + var setter = ts.getDeclarationOfKind(declaration.symbol, 154 /* SetAccessor */); return getAnnotatedAccessorType(setter); } if (ts.nodeIsMissing(declaration.body)) { return anyType; } } + function containsArgumentsReference(declaration) { + var links = getNodeLinks(declaration); + if (links.containsArgumentsReference === undefined) { + if (links.flags & 8192 /* CaptureArguments */) { + links.containsArgumentsReference = true; + } + else { + links.containsArgumentsReference = traverse(declaration.body); + } + } + return links.containsArgumentsReference; + function traverse(node) { + if (!node) + return false; + switch (node.kind) { + case 71 /* Identifier */: + return node.text === "arguments" && ts.isPartOfExpression(node); + case 149 /* PropertyDeclaration */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + return node.name.kind === 144 /* ComputedPropertyName */ + && traverse(node.name); + default: + return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && ts.forEachChild(node, traverse); + } + } + } function getSignaturesOfSymbol(symbol) { if (!symbol) return emptyArray; @@ -29743,20 +31169,20 @@ var ts; for (var i = 0; i < symbol.declarations.length; i++) { var node = symbol.declarations[i]; switch (node.kind) { - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 278 /* JSDocFunctionType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 279 /* 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). @@ -29803,7 +31229,7 @@ var ts; } if (!popTypeResolution()) { type = anyType; - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { var declaration = signature.declaration; if (declaration.name) { error(declaration.name, ts.Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, ts.declarationNameToString(declaration.name)); @@ -29853,7 +31279,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 === 151 /* Constructor */ || signature.declaration.kind === 155 /* ConstructSignature */; + var isConstructor = signature.declaration.kind === 152 /* Constructor */ || signature.declaration.kind === 156 /* ConstructSignature */; var type = createObjectType(16 /* Anonymous */); type.members = emptySymbols; type.properties = emptyArray; @@ -29867,7 +31293,7 @@ var ts; return symbol.members.get("__index"); } function getIndexDeclarationOfSymbol(symbol, kind) { - var syntaxKind = kind === 1 /* Number */ ? 132 /* NumberKeyword */ : 135 /* StringKeyword */; + var syntaxKind = kind === 1 /* Number */ ? 133 /* NumberKeyword */ : 136 /* StringKeyword */; var indexSymbol = getIndexSymbol(symbol); if (indexSymbol) { for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) { @@ -29894,7 +31320,7 @@ var ts; return undefined; } function getConstraintDeclaration(type) { - return ts.getDeclarationOfKind(type.symbol, 144 /* TypeParameter */).constraint; + return ts.getDeclarationOfKind(type.symbol, 145 /* TypeParameter */).constraint; } function getConstraintFromTypeParameter(typeParameter) { if (!typeParameter.constraint) { @@ -29910,17 +31336,17 @@ var ts; return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint; } function getParentSymbolOfTypeParameter(typeParameter) { - return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 144 /* TypeParameter */).parent); + return getSymbolOfNode(ts.getDeclarationOfKind(typeParameter.symbol, 145 /* TypeParameter */).parent); } function getTypeListId(types) { var result = ""; if (types) { - var length_3 = types.length; + var length_4 = types.length; var i = 0; - while (i < length_3) { + while (i < length_4) { var startId = types[i].id; var count = 1; - while (i + count < length_3 && types[i + count].id === startId + count) { + while (i + count < length_4 && types[i + count].id === startId + count) { count++; } if (result.length) { @@ -29941,8 +31367,8 @@ var ts; // that care about the presence of such types at arbitrary depth in a containing type. function getPropagatingFlagsOfTypes(types, excludeKinds) { var result = 0; - for (var _i = 0, types_4 = types; _i < types_4.length; _i++) { - var type = types_4[_i]; + for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { + var type = types_5[_i]; if (!(type.flags & excludeKinds)) { result |= type.flags; } @@ -29979,7 +31405,7 @@ var ts; if (typeParameters) { var numTypeArguments = ts.length(node.typeArguments); var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters); - if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) { + if (!ts.isInJavaScriptFile(node) && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) { error(node, minTypeArgumentCount === typeParameters.length ? ts.Diagnostics.Generic_type_0_requires_1_type_argument_s : ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, typeToString(type, /*enclosingDeclaration*/ undefined, 1 /* WriteArrayAsGenericType */), minTypeArgumentCount, typeParameters.length); @@ -29988,7 +31414,7 @@ var ts; // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount)); + var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -30042,11 +31468,11 @@ var ts; } function getTypeReferenceName(node) { switch (node.kind) { - case 158 /* TypeReference */: + case 159 /* TypeReference */: return node.typeName; - case 276 /* JSDocTypeReference */: + case 277 /* JSDocTypeReference */: return node.name; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: // We only support expressions that are simple qualified names. For other // expressions this produces undefined. var expr = node.expression; @@ -30072,7 +31498,7 @@ var ts; if (symbol.flags & 524288 /* TypeAlias */) { return getTypeFromTypeAliasReference(node, symbol); } - if (symbol.flags & 107455 /* Value */ && node.kind === 276 /* JSDocTypeReference */) { + if (symbol.flags & 107455 /* Value */ && node.kind === 277 /* 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. @@ -30080,19 +31506,54 @@ var ts; } return getTypeFromNonGenericTypeReference(node, symbol); } + function getPrimitiveTypeFromJSDocTypeReference(node) { + if (ts.isIdentifier(node.name)) { + switch (node.name.text) { + case "String": + return stringType; + case "Number": + return numberType; + case "Boolean": + return booleanType; + case "Void": + return voidType; + case "Undefined": + return undefinedType; + case "Null": + return nullType; + case "Object": + return anyType; + case "Function": + return anyFunctionType; + case "Array": + case "array": + return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined; + case "Promise": + case "promise": + return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined; + } + } + } + function getTypeFromJSDocNullableTypeNode(node) { + var type = getTypeFromTypeNode(node.type); + return strictNullChecks ? getUnionType([type, nullType]) : type; + } function getTypeFromTypeReference(node) { var links = getNodeLinks(node); if (!links.resolvedType) { var symbol = void 0; var type = void 0; - if (node.kind === 276 /* JSDocTypeReference */) { - var typeReferenceName = getTypeReferenceName(node); - symbol = resolveTypeReferenceName(typeReferenceName); - type = getTypeReferenceType(node, symbol); + if (node.kind === 277 /* JSDocTypeReference */) { + type = getPrimitiveTypeFromJSDocTypeReference(node); + if (!type) { + var typeReferenceName = getTypeReferenceName(node); + symbol = resolveTypeReferenceName(typeReferenceName); + type = getTypeReferenceType(node, symbol); + } } else { // We only support expressions that are simple qualified names. For other expressions this produces undefined. - var typeNameOrExpression = node.kind === 158 /* TypeReference */ + var typeNameOrExpression = node.kind === 159 /* TypeReference */ ? node.typeName : ts.isEntityNameExpression(node.expression) ? node.expression @@ -30127,9 +31588,9 @@ var ts; for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) { var declaration = declarations_4[_i]; switch (declaration.kind) { - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: return declaration; } } @@ -30148,18 +31609,62 @@ var ts; } return type; } - function getGlobalValueSymbol(name) { - return getGlobalSymbol(name, 107455 /* Value */, ts.Diagnostics.Cannot_find_global_value_0); + function getGlobalValueSymbol(name, reportErrors) { + return getGlobalSymbol(name, 107455 /* Value */, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined); } - function getGlobalTypeSymbol(name) { - return getGlobalSymbol(name, 793064 /* Type */, ts.Diagnostics.Cannot_find_global_type_0); + function getGlobalTypeSymbol(name, reportErrors) { + return getGlobalSymbol(name, 793064 /* Type */, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined); } function getGlobalSymbol(name, meaning, diagnostic) { return resolveName(undefined, name, meaning, diagnostic, name); } - function getGlobalType(name, arity) { + function getGlobalType(name, arity, reportErrors) { + var symbol = getGlobalTypeSymbol(name, reportErrors); + return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined; + } + function getGlobalTypedPropertyDescriptorType() { + return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", /*arity*/ 1, /*reportErrors*/ true)) || emptyGenericType; + } + function getGlobalTemplateStringsArrayType() { + return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", /*arity*/ 0, /*reportErrors*/ true)) || emptyObjectType; + } + function getGlobalESSymbolConstructorSymbol(reportErrors) { + return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors)); + } + function getGlobalESSymbolType(reportErrors) { + return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", /*arity*/ 0, reportErrors)) || emptyObjectType; + } + function getGlobalPromiseType(reportErrors) { + return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalPromiseConstructorSymbol(reportErrors) { + return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors)); + } + function getGlobalPromiseConstructorLikeType(reportErrors) { + return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", /*arity*/ 0, reportErrors)) || emptyObjectType; + } + function getGlobalAsyncIterableType(reportErrors) { + return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIteratorType(reportErrors) { + return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalAsyncIterableIteratorType(reportErrors) { + return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableType(reportErrors) { + return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalIteratorType(reportErrors) { + return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalIterableIteratorType(reportErrors) { + return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", /*arity*/ 1, reportErrors)) || emptyGenericType; + } + function getGlobalTypeOrUndefined(name, arity) { if (arity === void 0) { arity = 0; } - return getTypeOfGlobalSymbol(getGlobalTypeSymbol(name), arity); + var symbol = getGlobalSymbol(name, 793064 /* Type */, /*diagnostic*/ undefined); + return symbol && getTypeOfGlobalSymbol(symbol, arity); } /** * Returns a type that is inside a namespace at the global scope, e.g. @@ -30170,26 +31675,26 @@ var ts; var typeSymbol = namespaceSymbol && getSymbol(namespaceSymbol.exports, name, 793064 /* Type */); return typeSymbol && getDeclaredTypeOfSymbol(typeSymbol); } - /** - * Creates a TypeReference for a generic `TypedPropertyDescriptor`. - */ - function createTypedPropertyDescriptorType(propertyType) { - var globalTypedPropertyDescriptorType = getGlobalTypedPropertyDescriptorType(); - return globalTypedPropertyDescriptorType !== emptyGenericType - ? createTypeReference(globalTypedPropertyDescriptorType, [propertyType]) - : emptyObjectType; - } /** * Instantiates a global type that is generic with some element type, and returns that instantiation. */ function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) { return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType; } - function createIterableType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableType(), [elementType]); + function createTypedPropertyDescriptorType(propertyType) { + return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]); } - function createIterableIteratorType(elementType) { - return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(), [elementType]); + function createAsyncIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableType(/*reportErrors*/ true), [iteratedType]); + } + function createAsyncIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalAsyncIterableIteratorType(/*reportErrors*/ true), [iteratedType]); + } + function createIterableType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableType(/*reportErrors*/ true), [iteratedType]); + } + function createIterableIteratorType(iteratedType) { + return createTypeFromGenericGlobalType(getGlobalIterableIteratorType(/*reportErrors*/ true), [iteratedType]); } function createArrayType(elementType) { return createTypeFromGenericGlobalType(globalArrayType, [elementType]); @@ -30307,14 +31812,14 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToUnion(typeSet, types) { - for (var _i = 0, types_5 = types; _i < types_5.length; _i++) { - var type = types_5[_i]; + for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { + var type = types_6[_i]; addTypeToUnion(typeSet, type); } } function containsIdenticalType(types, type) { - for (var _i = 0, types_6 = types; _i < types_6.length; _i++) { - var t = types_6[_i]; + for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { + var t = types_7[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -30322,8 +31827,8 @@ var ts; return false; } function isSubtypeOfAny(candidate, types) { - for (var _i = 0, types_7 = types; _i < types_7.length; _i++) { - var type = types_7[_i]; + for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { + var type = types_8[_i]; if (candidate !== type && isTypeSubtypeOf(candidate, type)) { return true; } @@ -30435,7 +31940,13 @@ var ts; else if (type.flags & 1 /* Any */) { typeSet.containsAny = true; } + else if (getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type)) { + typeSet.containsEmptyObject = true; + } else if (!(type.flags & 8192 /* Never */) && (strictNullChecks || !(type.flags & 6144 /* Nullable */)) && !ts.contains(typeSet, type)) { + if (type.flags & 32768 /* Object */) { + typeSet.containsObjectType = true; + } if (type.flags & 65536 /* Union */ && typeSet.unionIndex === undefined) { typeSet.unionIndex = typeSet.length; } @@ -30448,8 +31959,8 @@ var ts; // Add the given types to the given type set. Order is preserved, duplicates are removed, // and nested types of the given kind are flattened into the set. function addTypesToIntersection(typeSet, types) { - for (var _i = 0, types_8 = types; _i < types_8.length; _i++) { - var type = types_8[_i]; + for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { + var type = types_9[_i]; addTypeToIntersection(typeSet, type); } } @@ -30472,6 +31983,9 @@ var ts; if (typeSet.containsAny) { return anyType; } + if (typeSet.containsEmptyObject && !typeSet.containsObjectType) { + typeSet.push(emptyObjectType); + } if (typeSet.length === 1) { return typeSet[0]; } @@ -30541,7 +32055,7 @@ var ts; return type; } function getPropertyTypeForIndexType(objectType, indexType, accessNode, cacheSymbol) { - var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode : undefined; var propName = indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */ | 256 /* EnumLiteral */) ? indexType.text : accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? @@ -30577,7 +32091,7 @@ var ts; return indexInfo.type; } if (accessExpression && !isConstEnumObjectType(objectType)) { - if (compilerOptions.noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { + if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors) { if (getIndexTypeOfType(objectType, 1 /* Number */)) { error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number); } @@ -30589,7 +32103,7 @@ var ts; } } if (accessNode) { - var indexNode = accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; + var indexNode = accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode.argumentExpression : accessNode.indexType; if (indexType.flags & (32 /* StringLiteral */ | 64 /* NumberLiteral */)) { error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.text, typeToString(objectType)); } @@ -30599,11 +32113,12 @@ var ts; else { error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType)); } + return unknownType; } - return unknownType; + return anyType; } function getIndexedAccessForMappedType(type, indexType, accessNode) { - var accessExpression = accessNode && accessNode.kind === 179 /* ElementAccessExpression */ ? accessNode : undefined; + var accessExpression = accessNode && accessNode.kind === 180 /* ElementAccessExpression */ ? accessNode : undefined; if (accessExpression && ts.isAssignmentTarget(accessExpression) && type.declaration.readonlyToken) { error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(type)); return unknownType; @@ -30620,7 +32135,7 @@ var ts; // preserve backwards compatibility. For example, an element access 'this["foo"]' has always been resolved // eagerly using the constraint type of 'this' at the given location. if (maybeTypeOfKind(indexType, 540672 /* TypeVariable */ | 262144 /* Index */) || - maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 179 /* ElementAccessExpression */) || + maybeTypeOfKind(objectType, 540672 /* TypeVariable */) && !(accessNode && accessNode.kind === 180 /* ElementAccessExpression */) || isGenericMappedType(objectType)) { if (objectType.flags & 1 /* Any */) { return objectType; @@ -30694,7 +32209,7 @@ var ts; return links.resolvedType; } function getAliasSymbolForTypeNode(node) { - return node.parent.kind === 230 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; + return node.parent.kind === 231 /* TypeAliasDeclaration */ ? getSymbolOfNode(node.parent) : undefined; } function getAliasTypeArgumentsForTypeNode(node) { var symbol = getAliasSymbolForTypeNode(node); @@ -30747,7 +32262,7 @@ var ts; skippedPrivateMembers.set(rightProp.name, true); } else if (!isClassMethod(rightProp) && !isSetterWithoutGetter) { - members.set(rightProp.name, rightProp); + members.set(rightProp.name, getNonReadonlySymbol(rightProp)); } } for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) { @@ -30764,7 +32279,6 @@ var ts; var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations); var flags = 4 /* Property */ | (leftProp.flags & 67108864 /* Optional */); var result = createSymbol(flags, leftProp.name); - result.checkFlags = isReadonlySymbol(leftProp) || isReadonlySymbol(rightProp) ? 4 /* Readonly */ : 0; result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 131072 /* NEUndefined */)]); result.leftSpread = leftProp; result.rightSpread = rightProp; @@ -30773,11 +32287,22 @@ var ts; } } else { - members.set(leftProp.name, leftProp); + members.set(leftProp.name, getNonReadonlySymbol(leftProp)); } } return createAnonymousType(undefined, members, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); } + function getNonReadonlySymbol(prop) { + if (!isReadonlySymbol(prop)) { + return prop; + } + var flags = 4 /* Property */ | (prop.flags & 67108864 /* Optional */); + var result = createSymbol(flags, prop.name); + result.type = getTypeOfSymbol(prop); + result.declarations = prop.declarations; + result.syntheticOrigin = prop; + return result; + } function isClassMethod(prop) { return prop.flags & 8192 /* Method */ && ts.find(prop.declarations, function (decl) { return ts.isClassLike(decl.parent); }); } @@ -30834,9 +32359,9 @@ var ts; function getThisType(node) { var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); var parent = container && container.parent; - if (parent && (ts.isClassLike(parent) || parent.kind === 229 /* InterfaceDeclaration */)) { + if (parent && (ts.isClassLike(parent) || parent.kind === 230 /* InterfaceDeclaration */)) { if (!(ts.getModifierFlags(container) & 32 /* Static */) && - (container.kind !== 151 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { + (container.kind !== 152 /* Constructor */ || ts.isNodeDescendantOf(node, container.body))) { return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType; } } @@ -30852,90 +32377,85 @@ var ts; } function getTypeFromTypeNode(node) { switch (node.kind) { - case 118 /* AnyKeyword */: - case 267 /* JSDocAllType */: - case 268 /* JSDocUnknownType */: + case 119 /* AnyKeyword */: + case 268 /* JSDocAllType */: + case 269 /* JSDocUnknownType */: return anyType; - case 135 /* StringKeyword */: + case 136 /* StringKeyword */: return stringType; - case 132 /* NumberKeyword */: + case 133 /* NumberKeyword */: return numberType; - case 121 /* BooleanKeyword */: + case 122 /* BooleanKeyword */: return booleanType; - case 136 /* SymbolKeyword */: + case 137 /* SymbolKeyword */: return esSymbolType; - case 104 /* VoidKeyword */: + case 105 /* VoidKeyword */: return voidType; - case 138 /* UndefinedKeyword */: + case 139 /* UndefinedKeyword */: return undefinedType; - case 94 /* NullKeyword */: + case 95 /* NullKeyword */: return nullType; - case 129 /* NeverKeyword */: + case 130 /* NeverKeyword */: return neverType; - case 133 /* ObjectKeyword */: + case 134 /* ObjectKeyword */: return nonPrimitiveType; - case 293 /* JSDocNullKeyword */: - return nullType; - case 294 /* JSDocUndefinedKeyword */: - return undefinedType; - case 295 /* JSDocNeverKeyword */: - return neverType; - case 168 /* ThisType */: - case 98 /* ThisKeyword */: + case 169 /* ThisType */: + case 99 /* ThisKeyword */: return getTypeFromThisTypeNode(node); - case 172 /* LiteralType */: + case 173 /* LiteralType */: return getTypeFromLiteralTypeNode(node); - case 292 /* JSDocLiteralType */: + case 293 /* JSDocLiteralType */: return getTypeFromLiteralTypeNode(node.literal); - case 158 /* TypeReference */: - case 276 /* JSDocTypeReference */: + case 159 /* TypeReference */: + case 277 /* JSDocTypeReference */: return getTypeFromTypeReference(node); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return booleanType; - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return getTypeFromTypeReference(node); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return getTypeFromTypeQueryNode(node); - case 163 /* ArrayType */: - case 269 /* JSDocArrayType */: + case 164 /* ArrayType */: + case 270 /* JSDocArrayType */: return getTypeFromArrayTypeNode(node); - case 164 /* TupleType */: + case 165 /* TupleType */: return getTypeFromTupleTypeNode(node); - case 165 /* UnionType */: - case 270 /* JSDocUnionType */: + case 166 /* UnionType */: + case 271 /* JSDocUnionType */: return getTypeFromUnionTypeNode(node); - case 166 /* IntersectionType */: + case 167 /* IntersectionType */: return getTypeFromIntersectionTypeNode(node); - case 167 /* ParenthesizedType */: - case 272 /* JSDocNullableType */: - case 273 /* JSDocNonNullableType */: - case 280 /* JSDocConstructorType */: - case 281 /* JSDocThisType */: - case 277 /* JSDocOptionalType */: + case 273 /* JSDocNullableType */: + return getTypeFromJSDocNullableTypeNode(node); + case 168 /* ParenthesizedType */: + case 274 /* JSDocNonNullableType */: + case 281 /* JSDocConstructorType */: + case 282 /* JSDocThisType */: + case 278 /* JSDocOptionalType */: return getTypeFromTypeNode(node.type); - case 274 /* JSDocRecordType */: + case 275 /* JSDocRecordType */: return getTypeFromTypeNode(node.literal); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 162 /* TypeLiteral */: - case 291 /* JSDocTypeLiteral */: - case 278 /* JSDocFunctionType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 163 /* TypeLiteral */: + case 292 /* JSDocTypeLiteral */: + case 279 /* JSDocFunctionType */: return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node); - case 169 /* TypeOperator */: + case 170 /* TypeOperator */: return getTypeFromTypeOperatorNode(node); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return getTypeFromIndexedAccessTypeNode(node); - case 171 /* MappedType */: + case 172 /* MappedType */: return getTypeFromMappedTypeNode(node); // This function assumes that an identifier or qualified name is a type expression // Callers should first ensure this by calling isTypeNode - case 70 /* Identifier */: - case 142 /* QualifiedName */: + case 71 /* Identifier */: + case 143 /* QualifiedName */: var symbol = getSymbolAtLocation(node); return symbol && getDeclaredTypeOfSymbol(symbol); - case 271 /* JSDocTupleType */: + case 272 /* JSDocTupleType */: return getTypeFromJSDocTupleType(node); - case 279 /* JSDocVariadicType */: + case 280 /* JSDocVariadicType */: return getTypeFromJSDocVariadicType(node); default: return unknownType; @@ -30986,7 +32506,7 @@ var ts; return mapper; } function createTypeEraser(sources) { - return createTypeMapper(sources, undefined); + return createTypeMapper(sources, /*targets*/ undefined); } /** * Maps forward-references to later types parameters to the empty object type. @@ -31144,26 +32664,28 @@ var ts; // Starting with the parent of the symbol's declaration, check if the mapper maps any of // the type parameters introduced by enclosing declarations. We just pick the first // declaration since multiple declarations will all have the same parent anyway. - var node = symbol.declarations[0]; - while (node) { + return !!ts.findAncestor(symbol.declarations[0], function (node) { + if (node.kind === 233 /* ModuleDeclaration */ || node.kind === 265 /* SourceFile */) { + return "quit"; + } switch (node.kind) { - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: var declaration = node; if (declaration.typeParameters) { for (var _i = 0, _a = declaration.typeParameters; _i < _a.length; _i++) { @@ -31173,19 +32695,19 @@ var ts; } } } - if (ts.isClassLike(node) || node.kind === 229 /* InterfaceDeclaration */) { + if (ts.isClassLike(node) || node.kind === 230 /* InterfaceDeclaration */) { var thisType = getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType; if (thisType && ts.contains(mappedTypes, thisType)) { return true; } } break; - case 171 /* MappedType */: + case 172 /* MappedType */: if (ts.contains(mappedTypes, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)))) { return true; } break; - case 278 /* JSDocFunctionType */: + case 279 /* JSDocFunctionType */: var func = node; for (var _b = 0, _c = func.parameters; _b < _c.length; _b++) { var p = _c[_b]; @@ -31194,18 +32716,13 @@ var ts; } } break; - case 232 /* ModuleDeclaration */: - case 264 /* SourceFile */: - return false; } - node = node.parent; - } - return false; + }); } function isTopLevelTypeAlias(symbol) { if (symbol.declarations && symbol.declarations.length) { var parentKind = symbol.declarations[0].parent.kind; - return parentKind === 264 /* SourceFile */ || parentKind === 233 /* ModuleBlock */; + return parentKind === 265 /* SourceFile */ || parentKind === 234 /* ModuleBlock */; } return false; } @@ -31282,34 +32799,34 @@ var ts; // Returns true if the given expression contains (at any level of nesting) a function or arrow expression // that is subject to contextual typing. function isContextSensitive(node) { - ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); switch (node.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return isContextSensitiveFunctionLikeDeclaration(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return ts.forEach(node.properties, isContextSensitive); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return ts.forEach(node.elements, isContextSensitive); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return isContextSensitive(node.whenTrue) || isContextSensitive(node.whenFalse); - case 193 /* BinaryExpression */: - return node.operatorToken.kind === 53 /* BarBarToken */ && + case 194 /* BinaryExpression */: + return node.operatorToken.kind === 54 /* BarBarToken */ && (isContextSensitive(node.left) || isContextSensitive(node.right)); - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return isContextSensitive(node.initializer); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return isContextSensitiveFunctionLikeDeclaration(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return isContextSensitive(node.expression); - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return ts.forEach(node.properties, isContextSensitive); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: // If there is no initializer, JSX attribute has a boolean value of true which is not context sensitive. return node.initializer && isContextSensitive(node.initializer); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: // It is possible to that node.expression is undefined (e.g
) return node.expression && isContextSensitive(node.expression); } @@ -31325,7 +32842,7 @@ var ts; return true; } // For arrow functions we now know we're not context sensitive. - if (node.kind === 186 /* ArrowFunction */) { + if (node.kind === 187 /* ArrowFunction */) { return false; } // If the first parameter is not an explicit 'this' parameter, then the function has @@ -31401,12 +32918,13 @@ var ts; return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain); } function isSignatureAssignableTo(source, target, ignoreReturnTypes) { - return compareSignaturesRelated(source, target, ignoreReturnTypes, /*reportErrors*/ false, /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; + return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, ignoreReturnTypes, /*reportErrors*/ false, + /*errorReporter*/ undefined, compareTypesAssignable) !== 0 /* False */; } /** * See signatureRelatedTo, compareSignaturesIdentical */ - function compareSignaturesRelated(source, target, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { + function compareSignaturesRelated(source, target, checkAsCallback, ignoreReturnTypes, reportErrors, errorReporter, compareTypes) { // TODO (drosen): De-duplicate code between related functions. if (source === target) { return -1 /* True */; @@ -31441,9 +32959,23 @@ var ts; var sourceParams = source.parameters; var targetParams = target.parameters; for (var i = 0; i < checkCount; i++) { - var s = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); - var t = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); - var related = compareTypes(s, t, /*reportErrors*/ false) || compareTypes(t, s, reportErrors); + var sourceType = i < sourceMax ? getTypeOfParameter(sourceParams[i]) : getRestTypeOfSignature(source); + var targetType = i < targetMax ? getTypeOfParameter(targetParams[i]) : getRestTypeOfSignature(target); + var sourceSig = getSingleCallSignature(getNonNullableType(sourceType)); + var targetSig = getSingleCallSignature(getNonNullableType(targetType)); + // In order to ensure that any generic type Foo is at least co-variant with respect to T no matter + // how Foo uses T, we need to relate parameters bi-variantly (given that parameters are input positions, + // they naturally relate only contra-variantly). However, if the source and target parameters both have + // function types with a single call signature, we known we are relating two callback parameters. In + // that case it is sufficient to only relate the parameters of the signatures co-variantly because, + // similar to return values, callback parameters are output positions. This means that a Promise, + // where T is used only in callback parameter positions, will be co-variant (as opposed to bi-variant) + // with respect to T. + var callbacks = sourceSig && targetSig && !sourceSig.typePredicate && !targetSig.typePredicate && + (getFalsyFlags(sourceType) & 6144 /* Nullable */) === (getFalsyFlags(targetType) & 6144 /* Nullable */); + var related = callbacks ? + compareSignaturesRelated(targetSig, sourceSig, /*checkAsCallback*/ true, /*ignoreReturnTypes*/ false, reportErrors, errorReporter, compareTypes) : + !checkAsCallback && compareTypes(sourceType, targetType, /*reportErrors*/ false) || compareTypes(targetType, sourceType, reportErrors); if (!related) { if (reportErrors) { errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, sourceParams[i < sourceMax ? i : sourceMax].name, targetParams[i < targetMax ? i : targetMax].name); @@ -31471,7 +33003,11 @@ var ts; } } else { - result &= compareTypes(sourceReturnType, targetReturnType, reportErrors); + // When relating callback signatures, we still need to relate return types bi-variantly as otherwise + // the containing type wouldn't be co-variant. For example, interface Foo { add(cb: () => T): void } + // wouldn't be co-variant for T without this rule. + result &= checkAsCallback && compareTypes(targetReturnType, sourceReturnType, /*reportErrors*/ false) || + compareTypes(sourceReturnType, targetReturnType, reportErrors); } } return result; @@ -31538,6 +33074,19 @@ var ts; sourceNonRestParamCount; } } + function isEmptyResolvedType(t) { + return t.properties.length === 0 && + t.callSignatures.length === 0 && + t.constructSignatures.length === 0 && + !t.stringIndexInfo && + !t.numberIndexInfo; + } + function isEmptyObjectType(type) { + return type.flags & 32768 /* Object */ ? isEmptyResolvedType(resolveStructuredTypeMembers(type)) : + type.flags & 65536 /* Union */ ? ts.forEach(type.types, isEmptyObjectType) : + type.flags & 131072 /* Intersection */ ? !ts.forEach(type.types, function (t) { return !isEmptyObjectType(t); }) : + false; + } function isEnumTypeRelatedTo(source, target, errorReporter) { if (source === target) { return true; @@ -31628,7 +33177,7 @@ var ts; } } if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { - return checkTypeRelatedTo(source, target, relation, undefined, undefined, undefined); + return checkTypeRelatedTo(source, target, relation, /*errorNode*/ undefined); } return false; } @@ -31692,7 +33241,7 @@ var ts; if ((globalStringType === source && stringType === target) || (globalNumberType === source && numberType === target) || (globalBooleanType === source && booleanType === target) || - (getGlobalESSymbolType() === source && esSymbolType === target)) { + (getGlobalESSymbolType(/*reportErrors*/ false) === source && esSymbolType === target)) { reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType); } } @@ -31767,136 +33316,37 @@ var ts; return result; } } - else if (target.flags & 65536 /* Union */) { - if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { - return result; - } - } - else if (target.flags & 131072 /* Intersection */) { - if (result = typeRelatedToEachType(source, target, reportErrors)) { - return result; - } - } - else if (source.flags & 131072 /* Intersection */) { - // Check to see if any constituents of the intersection are immediately related to the target. - // - // Don't report errors though. Checking whether a constituent is related to the source is not actually - // useful and leads to some confusing error messages. Instead it is better to let the below checks - // take care of this, or to not elaborate at all. For instance, - // - // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. - // - // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection - // than to report that 'D' is not assignable to 'A' or 'B'. - // - // - For a primitive type or type parameter (such as 'number = A & B') there is no point in - // breaking the intersection apart. - if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { - return result; - } - } - else if (target.flags & 16384 /* TypeParameter */) { - // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. - if (getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { - if (!source.declaration.questionToken) { - var templateType = getTemplateTypeFromMappedType(source); - var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); - if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { - return result; - } - } - } - } - else if (target.flags & 262144 /* Index */) { - // A keyof S is related to a keyof T if T is related to S. - if (source.flags & 262144 /* Index */) { - if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { - return result; - } - } - // A type S is assignable to keyof T if S is assignable to keyof C, where C is the - // constraint of T. - var constraint = getConstraintOfType(target.type); - if (constraint) { - if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { - return result; - } - } - } - else if (target.flags & 524288 /* IndexedAccess */) { - // if we have indexed access types with identical index types, see if relationship holds for - // the two object types. - if (source.flags & 524288 /* IndexedAccess */ && source.indexType === target.indexType) { - if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { - return result; - } - } - // A type S is related to a type T[K] if S is related to A[K], where K is string-like and - // A is the apparent type of S. - var constraint = getBaseConstraintOfType(target); - if (constraint) { - if (result = isRelatedTo(source, constraint, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - if (source.flags & 16384 /* TypeParameter */) { - // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. - if (getObjectFlags(target) & 32 /* Mapped */ && getConstraintTypeFromMappedType(target) === getIndexType(source)) { - var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); - var templateType = getTemplateTypeFromMappedType(target); - if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - else { - var constraint = getConstraintOfTypeParameter(source); - // A type parameter with no constraint is not related to the non-primitive object type. - if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { - if (!constraint || constraint.flags & 1 /* Any */) { - constraint = emptyObjectType; - } - // The constraint may need to be further instantiated with its 'this' type. - constraint = getTypeWithThisArgument(constraint, source); - // Report constraint errors only if the constraint is not the empty object type - var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; - if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } - } - else if (source.flags & 524288 /* IndexedAccess */) { - // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and - // A is the apparent type of S. - var constraint = getBaseConstraintOfType(source); - if (constraint) { - if (result = isRelatedTo(constraint, target, reportErrors)) { - errorInfo = saveErrorInfo; - return result; - } - } - } else { - if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if relationship holds for all type arguments - if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + if (target.flags & 65536 /* Union */) { + if (result = typeRelatedToSomeType(source, target, reportErrors && !(source.flags & 8190 /* Primitive */) && !(target.flags & 8190 /* Primitive */))) { return result; } } - // Even if relationship doesn't hold for unions, intersections, or generic type references, - // it may hold in a structural comparison. - var apparentSource = getApparentType(source); - // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates - // to X. Failing both of those we want to check if the aggregation of A and B's members structurally - // relates to X. Thus, we include intersection types on the source side here. - if (apparentSource.flags & (32768 /* Object */ | 131072 /* Intersection */) && target.flags & 32768 /* Object */) { - // Report structural errors only if we haven't reported any errors yet - var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !(source.flags & 8190 /* Primitive */); - if (result = objectTypeRelatedTo(apparentSource, source, target, reportStructuralErrors)) { + else if (target.flags & 131072 /* Intersection */) { + if (result = typeRelatedToEachType(source, target, reportErrors)) { + return result; + } + } + else if (source.flags & 131072 /* Intersection */) { + // Check to see if any constituents of the intersection are immediately related to the target. + // + // Don't report errors though. Checking whether a constituent is related to the source is not actually + // useful and leads to some confusing error messages. Instead it is better to let the below checks + // take care of this, or to not elaborate at all. For instance, + // + // - For an object type (such as 'C = A & B'), users are usually more interested in structural errors. + // + // - For a union type (such as '(A | B) = (C & D)'), it's better to hold onto the whole intersection + // than to report that 'D' is not assignable to 'A' or 'B'. + // + // - For a primitive type or type parameter (such as 'number = A & B') there is no point in + // breaking the intersection apart. + if (result = someTypeRelatedToType(source, target, /*reportErrors*/ false)) { + return result; + } + } + if (source.flags & 1032192 /* StructuredOrTypeVariable */ || target.flags & 1032192 /* StructuredOrTypeVariable */) { + if (result = recursiveTypeRelatedTo(source, target, reportErrors)) { errorInfo = saveErrorInfo; return result; } @@ -31916,13 +33366,7 @@ var ts; function isIdenticalTo(source, target) { var result; if (source.flags & 32768 /* Object */ && target.flags & 32768 /* Object */) { - if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { - // We have type references to same target type, see if all type arguments are identical - if (result = typeArgumentsRelatedTo(source, target, /*reportErrors*/ false)) { - return result; - } - } - return objectTypeRelatedTo(source, source, target, /*reportErrors*/ false); + return recursiveTypeRelatedTo(source, target, /*reportErrors*/ false); } if (source.flags & 65536 /* Union */ && target.flags & 65536 /* Union */ || source.flags & 131072 /* Intersection */ && target.flags & 131072 /* Intersection */) { @@ -31941,14 +33385,8 @@ var ts; function isKnownProperty(type, name, isComparingJsxAttributes) { if (type.flags & 32768 /* Object */) { var resolved = resolveStructuredTypeMembers(type); - if ((relation === assignableRelation || relation === comparableRelation) && - (type === globalObjectType || (!isComparingJsxAttributes && isEmptyObjectType(resolved)))) { - return true; - } - else if (resolved.stringIndexInfo || (resolved.numberIndexInfo && isNumericLiteralName(name))) { - return true; - } - else if (getPropertyOfType(type, name) || (isComparingJsxAttributes && !isUnhyphenatedJsxName(name))) { + if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. return true; } @@ -31963,19 +33401,13 @@ var ts; } return false; } - function isEmptyResolvedType(t) { - return t.properties.length === 0 && - t.callSignatures.length === 0 && - t.constructSignatures.length === 0 && - !t.stringIndexInfo && - !t.numberIndexInfo; - } - function isEmptyObjectType(type) { - return type.flags & 32768 /* Object */ && isEmptyResolvedType(resolveStructuredTypeMembers(type)); - } function hasExcessProperties(source, target, reportErrors) { if (maybeTypeOfKind(target, 32768 /* Object */) && !(getObjectFlags(target) & 512 /* ObjectLiteralPatternWithComputedProperties */)) { var isComparingJsxAttributes = !!(source.flags & 33554432 /* JsxAttributes */); + if ((relation === assignableRelation || relation === comparableRelation) && + (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) { + return false; + } for (var _i = 0, _a = getPropertiesOfObjectType(source); _i < _a.length; _i++) { var prop = _a[_i]; if (!isKnownProperty(target, prop.name, isComparingJsxAttributes)) { @@ -31984,7 +33416,7 @@ var ts; // Use this property as the error node as this will be more helpful in // reasoning about what went wrong. ts.Debug.assert(!!errorNode); - if (ts.isJsxAttributes(errorNode)) { + if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode)) { // JsxAttributes has an object-literal flag and undergo same type-assignablity check as normal object-literal. // However, using an object-literal error message will be very confusing to the users so we give different a message. reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(prop), typeToString(target)); @@ -32106,12 +33538,12 @@ var ts; } return result; } - // Determine if two object types are related by structure. First, check if the result is already available in the global cache. + // Determine if possibly recursive types are related. First, check if the result is already available in the global cache. // Second, check if we have already started a comparison of the given two types in which case we assume the result to be true. // Third, check if both types are part of deeply nested chains of generic type instantiations and if so assume the types are // equal and infinitely expanding. Fourth, if we have reached a depth of 100 nested comparisons, assume we have runaway recursion // and issue an error. Otherwise, actually compare the structure of the two types. - function objectTypeRelatedTo(source, originalSource, target, reportErrors) { + function recursiveTypeRelatedTo(source, target, reportErrors) { if (overflow) { return 0 /* False */; } @@ -32151,32 +33583,11 @@ var ts; maybeStack[depth].set(id, 1 /* Succeeded */); depth++; var saveExpandingFlags = expandingFlags; - if (!(expandingFlags & 1) && isDeeplyNestedGeneric(source, sourceStack, depth)) + if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth)) expandingFlags |= 1; - if (!(expandingFlags & 2) && isDeeplyNestedGeneric(target, targetStack, depth)) + if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth)) expandingFlags |= 2; - var result; - if (expandingFlags === 3) { - result = 1 /* Maybe */; - } - else if (isGenericMappedType(source) || isGenericMappedType(target)) { - result = mappedTypeRelatedTo(source, target, reportErrors); - } - else { - result = propertiesRelatedTo(source, target, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 0 /* Call */, reportErrors); - if (result) { - result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 0 /* String */, reportErrors); - if (result) { - result &= indexTypesRelatedTo(source, originalSource, target, 1 /* Number */, reportErrors); - } - } - } - } - } + var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors) : 1 /* Maybe */; expandingFlags = saveExpandingFlags; depth--; if (result) { @@ -32192,6 +33603,139 @@ var ts; } return result; } + function structuredTypeRelatedTo(source, target, reportErrors) { + var result; + var saveErrorInfo = errorInfo; + if (target.flags & 16384 /* TypeParameter */) { + // A source type { [P in keyof T]: X } is related to a target type T if X is related to T[P]. + if (getObjectFlags(source) & 32 /* Mapped */ && getConstraintTypeFromMappedType(source) === getIndexType(target)) { + if (!source.declaration.questionToken) { + var templateType = getTemplateTypeFromMappedType(source); + var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source)); + if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) { + return result; + } + } + } + } + else if (target.flags & 262144 /* Index */) { + // A keyof S is related to a keyof T if T is related to S. + if (source.flags & 262144 /* Index */) { + if (result = isRelatedTo(target.type, source.type, /*reportErrors*/ false)) { + return result; + } + } + // A type S is assignable to keyof T if S is assignable to keyof C, where C is the + // constraint of T. + var constraint = getConstraintOfType(target.type); + if (constraint) { + if (result = isRelatedTo(source, getIndexType(constraint), reportErrors)) { + return result; + } + } + } + else if (target.flags & 524288 /* IndexedAccess */) { + // A type S is related to a type T[K] if S is related to A[K], where K is string-like and + // A is the apparent type of S. + var constraint = getConstraintOfType(target); + if (constraint) { + if (result = isRelatedTo(source, constraint, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + if (source.flags & 16384 /* TypeParameter */) { + // A source type T is related to a target type { [P in keyof T]: X } if T[P] is related to X. + if (getObjectFlags(target) & 32 /* Mapped */ && getConstraintTypeFromMappedType(target) === getIndexType(source)) { + var indexedAccessType = getIndexedAccessType(source, getTypeParameterFromMappedType(target)); + var templateType = getTemplateTypeFromMappedType(target); + if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else { + var constraint = getConstraintOfTypeParameter(source); + // A type parameter with no constraint is not related to the non-primitive object type. + if (constraint || !(target.flags & 16777216 /* NonPrimitive */)) { + if (!constraint || constraint.flags & 1 /* Any */) { + constraint = emptyObjectType; + } + // The constraint may need to be further instantiated with its 'this' type. + constraint = getTypeWithThisArgument(constraint, source); + // Report constraint errors only if the constraint is not the empty object type + var reportConstraintErrors = reportErrors && constraint !== emptyObjectType; + if (result = isRelatedTo(constraint, target, reportConstraintErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + } + } + else if (source.flags & 524288 /* IndexedAccess */) { + // A type S[K] is related to a type T if A[K] is related to T, where K is string-like and + // A is the apparent type of S. + var constraint = getConstraintOfType(source); + if (constraint) { + if (result = isRelatedTo(constraint, target, reportErrors)) { + errorInfo = saveErrorInfo; + return result; + } + } + else if (target.flags & 524288 /* IndexedAccess */ && source.indexType === target.indexType) { + // if we have indexed access types with identical index types, see if relationship holds for + // the two object types. + if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) { + return result; + } + } + } + else { + if (getObjectFlags(source) & 4 /* Reference */ && getObjectFlags(target) & 4 /* Reference */ && source.target === target.target) { + // We have type references to same target type, see if relationship holds for all type arguments + if (result = typeArgumentsRelatedTo(source, target, reportErrors)) { + return result; + } + } + // Even if relationship doesn't hold for unions, intersections, or generic type references, + // it may hold in a structural comparison. + var sourceIsPrimitive = !!(source.flags & 8190 /* Primitive */); + if (relation !== identityRelation) { + source = getApparentType(source); + } + // In a check of the form X = A & B, we will have previously checked if A relates to X or B relates + // to X. Failing both of those we want to check if the aggregation of A and B's members structurally + // relates to X. Thus, we include intersection types on the source side here. + if (source.flags & (32768 /* Object */ | 131072 /* Intersection */) && target.flags & 32768 /* Object */) { + // Report structural errors only if we haven't reported any errors yet + var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo && !sourceIsPrimitive; + if (isGenericMappedType(source) || isGenericMappedType(target)) { + result = mappedTypeRelatedTo(source, target, reportStructuralErrors); + } + else { + result = propertiesRelatedTo(source, target, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 0 /* Call */, reportStructuralErrors); + if (result) { + result &= signaturesRelatedTo(source, target, 1 /* Construct */, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 0 /* String */, sourceIsPrimitive, reportStructuralErrors); + if (result) { + result &= indexTypesRelatedTo(source, target, 1 /* Number */, sourceIsPrimitive, reportStructuralErrors); + } + } + } + } + } + if (result) { + errorInfo = saveErrorInfo; + return result; + } + } + } + return 0 /* False */; + } // A type [P in S]: X is related to a type [Q in T]: Y if T is related to S and X' is // related to Y, where X' is an instantiation of X in which P is replaced with Q. Notice // that S and T are contra-variant whereas X and Y are co-variant. @@ -32232,8 +33776,8 @@ var ts; var result = -1 /* True */; var properties = getPropertiesOfObjectType(target); var requireOptionalProperties = relation === subtypeRelation && !(getObjectFlags(source) & 128 /* ObjectLiteral */); - for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) { - var targetProp = properties_3[_i]; + for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { + var targetProp = properties_4[_i]; var sourceProp = getPropertyOfType(source, targetProp.name); if (sourceProp !== targetProp) { if (!sourceProp) { @@ -32248,7 +33792,7 @@ var ts; var sourcePropFlags = getDeclarationModifierFlagsFromSymbol(sourceProp); var targetPropFlags = getDeclarationModifierFlagsFromSymbol(targetProp); if (sourcePropFlags & 8 /* Private */ || targetPropFlags & 8 /* Private */) { - if (getCheckFlags(sourceProp) & 128 /* ContainsPrivate */) { + if (getCheckFlags(sourceProp) & 256 /* ContainsPrivate */) { if (reportErrors) { reportError(ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(sourceProp), typeToString(source)); } @@ -32382,7 +33926,7 @@ var ts; * See signatureAssignableTo, compareSignaturesIdentical */ function signatureRelatedTo(source, target, reportErrors) { - return compareSignaturesRelated(source, target, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); + return compareSignaturesRelated(source, target, /*checkAsCallback*/ false, /*ignoreReturnTypes*/ false, reportErrors, reportError, isRelatedTo); } function signaturesIdenticalTo(source, target, kind) { var sourceSignatures = getSignaturesOfType(source, kind); @@ -32424,12 +33968,12 @@ var ts; } return related; } - function indexTypesRelatedTo(source, originalSource, target, kind, reportErrors) { + function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors) { if (relation === identityRelation) { return indexTypesIdenticalTo(source, target, kind); } var targetInfo = getIndexInfoOfType(target, kind); - if (!targetInfo || ((targetInfo.type.flags & 1 /* Any */) && !(originalSource.flags & 8190 /* Primitive */))) { + if (!targetInfo || targetInfo.type.flags & 1 /* Any */ && !sourceIsPrimitive) { // Index signature of type any permits assignment from everything but primitives return -1 /* True */; } @@ -32494,7 +34038,7 @@ var ts; // Invoke the callback for each underlying property symbol of the given symbol and return the first // value that isn't undefined. function forEachProperty(prop, callback) { - if (getCheckFlags(prop) & 2 /* SyntheticProperty */) { + if (getCheckFlags(prop) & 6 /* Synthetic */) { for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) { var t = _a[_i]; var p = getPropertyOfType(t, prop.name); @@ -32543,22 +34087,24 @@ var ts; } return false; } - // Return true if the given type is part of a deeply nested chain of generic instantiations. We consider this to be the case - // when structural type comparisons have been started for 10 or more instantiations of the same generic type. It is possible, - // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely expanding. - // Effectively, we will generate a false positive when two types are structurally equal to at least 10 levels, but unequal at - // some level beyond that. - function isDeeplyNestedGeneric(type, stack, depth) { - // We track type references (created by createTypeReference) and instantiated types (created by instantiateType) - if (getObjectFlags(type) & (4 /* Reference */ | 64 /* Instantiated */) && depth >= 5) { + // Return true if the given type is deeply nested. We consider this to be the case when structural type comparisons + // for 5 or more occurrences or instantiations of the type have been recorded on the given stack. It is possible, + // though highly unlikely, for this test to be true in a situation where a chain of instantiations is not infinitely + // expanding. Effectively, we will generate a false positive when two types are structurally equal to at least 5 + // levels, but unequal at some level beyond that. + function isDeeplyNestedType(type, stack, depth) { + // We track all object types that have an associated symbol (representing the origin of the type) + if (depth >= 5 && type.flags & 32768 /* Object */) { var symbol = type.symbol; - var count = 0; - for (var i = 0; i < depth; i++) { - var t = stack[i]; - if (getObjectFlags(t) & (4 /* Reference */ | 64 /* Instantiated */) && t.symbol === symbol) { - count++; - if (count >= 5) - return true; + if (symbol) { + var count = 0; + for (var i = 0; i < depth; i++) { + var t = stack[i]; + if (t.flags & 32768 /* Object */ && t.symbol === symbol) { + count++; + if (count >= 5) + return true; + } } } } @@ -32669,8 +34215,8 @@ var ts; return signature.hasRestParameter && parameterIndex >= signature.parameters.length - 1; } function isSupertypeOfEach(candidate, types) { - for (var _i = 0, types_9 = types; _i < types_9.length; _i++) { - var t = types_9[_i]; + for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { + var t = types_10[_i]; if (candidate !== t && !isTypeSubtypeOf(t, candidate)) return false; } @@ -32678,8 +34224,8 @@ var ts; } function literalTypesWithSameBaseType(types) { var commonBaseType; - for (var _i = 0, types_10 = types; _i < types_10.length; _i++) { - var t = types_10[_i]; + for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { + var t = types_11[_i]; var baseType = getBaseTypeOfLiteralType(t); if (!commonBaseType) { commonBaseType = baseType; @@ -32785,8 +34331,8 @@ var ts; } function getFalsyFlagsOfTypes(types) { var result = 0; - for (var _i = 0, types_11 = types; _i < types_11.length; _i++) { - var t = types_11[_i]; + for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { + var t = types_12[_i]; result |= getFalsyFlags(t); } return result; @@ -32856,7 +34402,6 @@ var ts; var updated = f(original); members.set(property.name, updated === original ? property : createSymbolWithType(property, updated)); } - ; return members; } /** @@ -32880,11 +34425,19 @@ var ts; type.regularType = regularNew; return regularNew; } + function getWidenedProperty(prop) { + var original = getTypeOfSymbol(prop); + var widened = getWidenedType(original); + return widened === original ? prop : createSymbolWithType(prop, widened); + } function getWidenedTypeOfObjectLiteral(type) { - var members = transformTypeOfMembers(type, function (prop) { - var widened = getWidenedType(prop); - return prop === widened ? prop : widened; - }); + var members = ts.createMap(); + for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) { + var prop = _a[_i]; + // Since get accessors already widen their return value there is no need to + // widen accessor based properties here. + members.set(prop.name, prop.flags & 4 /* Property */ ? getWidenedProperty(prop) : prop); + } 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)); @@ -32956,25 +34509,25 @@ var ts; var typeAsString = typeToString(getWidenedType(type)); var diagnostic; switch (declaration.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: diagnostic = ts.Diagnostics.Member_0_implicitly_has_an_1_type; break; - case 145 /* Parameter */: + case 146 /* 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 175 /* BindingElement */: + case 176 /* BindingElement */: diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type; break; - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: if (!declaration.name) { error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; @@ -32987,7 +34540,7 @@ var ts; error(declaration, diagnostic, ts.declarationNameToString(declaration.name), typeAsString); } function reportErrorsFromWidening(declaration, type) { - if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & 2097152 /* ContainsWideningType */) { + if (produceDiagnostics && noImplicitAny && type.flags & 2097152 /* ContainsWideningType */) { // Report implicit any error within type if possible, otherwise report error on declaration if (!reportWideningErrorsInType(type)) { reportImplicitAnyError(declaration, type); @@ -33014,13 +34567,14 @@ var ts; callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i)); } } - function createInferenceContext(signature, inferUnionTypes) { + function createInferenceContext(signature, inferUnionTypes, useAnyForNoInferences) { var inferences = ts.map(signature.typeParameters, createTypeInferencesObject); return { signature: signature, inferUnionTypes: inferUnionTypes, inferences: inferences, inferredTypes: new Array(signature.typeParameters.length), + useAnyForNoInferences: useAnyForNoInferences }; } function createTypeInferencesObject() { @@ -33069,14 +34623,14 @@ var ts; var readonlyMask = target.declaration.readonlyToken ? false : true; var optionalMask = target.declaration.questionToken ? 0 : 67108864 /* Optional */; var members = createSymbolTable(properties); - for (var _i = 0, properties_4 = properties; _i < properties_4.length; _i++) { - var prop = properties_4[_i]; + for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { + var prop = properties_5[_i]; var inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (!inferredPropType) { return undefined; } var inferredProp = createSymbol(4 /* Property */ | prop.flags & optionalMask, prop.name); - inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 4 /* Readonly */ : 0; + inferredProp.checkFlags = readonlyMask && isReadonlySymbol(prop) ? 8 /* Readonly */ : 0; inferredProp.declarations = prop.declarations; inferredProp.type = inferredPropType; members.set(prop.name, inferredProp); @@ -33249,7 +34803,7 @@ var ts; if (isInProcess(source, target)) { return; } - if (isDeeplyNestedGeneric(source, sourceStack, depth) && isDeeplyNestedGeneric(target, targetStack, depth)) { + if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { return; } var key = source.id + "," + target.id; @@ -33303,8 +34857,8 @@ var ts; } function inferFromProperties(source, target) { var properties = getPropertiesOfObjectType(target); - for (var _i = 0, properties_5 = properties; _i < properties_5.length; _i++) { - var targetProp = properties_5[_i]; + for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { + var targetProp = properties_6[_i]; var sourceProp = getPropertyOfObjectType(source, targetProp.name); if (sourceProp) { inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp)); @@ -33354,8 +34908,8 @@ var ts; } } function typeIdenticalToSomeType(type, types) { - for (var _i = 0, types_12 = types; _i < types_12.length; _i++) { - var t = types_12[_i]; + for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { + var t = types_13[_i]; if (isTypeIdenticalTo(t, type)) { return true; } @@ -33417,7 +34971,7 @@ var ts; inferredType = instantiateType(defaultType, combineTypeMappers(createBackreferenceMapper(context.signature.typeParameters, index), getInferenceMapper(context))); } else { - inferredType = emptyObjectType; + inferredType = context.useAnyForNoInferences ? anyType : emptyObjectType; } inferenceSucceeded = true; } @@ -33459,33 +35013,21 @@ var ts; // TypeScript 1.0 spec (April 2014): 3.6.3 // A type query consists of the keyword typeof followed by an expression. // The expression is restricted to a single identifier or a sequence of identifiers separated by periods - while (node) { - switch (node.kind) { - case 161 /* TypeQuery */: - return true; - case 70 /* Identifier */: - case 142 /* QualifiedName */: - node = node.parent; - continue; - default: - return false; - } - } - ts.Debug.fail("should not get here"); + return !!ts.findAncestor(node, function (n) { return n.kind === 162 /* TypeQuery */ ? true : n.kind === 71 /* Identifier */ || n.kind === 143 /* QualifiedName */ ? false : "quit"; }); } // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the // leftmost identifier followed by zero or more property names separated by dots. // The result is undefined if the reference isn't a dotted name. function getFlowCacheKey(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { var symbol = getResolvedSymbol(node); return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; } - if (node.kind === 98 /* ThisKeyword */) { + if (node.kind === 99 /* ThisKeyword */) { return "0"; } - if (node.kind === 178 /* PropertyAccessExpression */) { + if (node.kind === 179 /* PropertyAccessExpression */) { var key = getFlowCacheKey(node.expression); return key && key + "." + node.name.text; } @@ -33493,31 +35035,33 @@ var ts; } function getLeftmostIdentifierOrThis(node) { switch (node.kind) { - case 70 /* Identifier */: - case 98 /* ThisKeyword */: + case 71 /* Identifier */: + case 99 /* ThisKeyword */: return node; - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return getLeftmostIdentifierOrThis(node.expression); } return undefined; } function isMatchingReference(source, target) { switch (source.kind) { - case 70 /* Identifier */: - return target.kind === 70 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || - (target.kind === 225 /* VariableDeclaration */ || target.kind === 175 /* BindingElement */) && + case 71 /* Identifier */: + return target.kind === 71 /* Identifier */ && getResolvedSymbol(source) === getResolvedSymbol(target) || + (target.kind === 226 /* VariableDeclaration */ || target.kind === 176 /* BindingElement */) && getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target); - case 98 /* ThisKeyword */: - return target.kind === 98 /* ThisKeyword */; - case 178 /* PropertyAccessExpression */: - return target.kind === 178 /* PropertyAccessExpression */ && + case 99 /* ThisKeyword */: + return target.kind === 99 /* ThisKeyword */; + case 97 /* SuperKeyword */: + return target.kind === 97 /* SuperKeyword */; + case 179 /* PropertyAccessExpression */: + return target.kind === 179 /* PropertyAccessExpression */ && source.name.text === target.name.text && isMatchingReference(source.expression, target.expression); } return false; } function containsMatchingReference(source, target) { - while (source.kind === 178 /* PropertyAccessExpression */) { + while (source.kind === 179 /* PropertyAccessExpression */) { source = source.expression; if (isMatchingReference(source, target)) { return true; @@ -33530,15 +35074,15 @@ var ts; // a possible discriminant if its type differs in the constituents of containing union type, and if every // choice is a unit type or a union of unit types. function containsMatchingReferenceDiscriminant(source, target) { - return target.kind === 178 /* PropertyAccessExpression */ && + return target.kind === 179 /* PropertyAccessExpression */ && containsMatchingReference(source, target.expression) && isDiscriminantProperty(getDeclaredTypeOfReference(target.expression), target.name.text); } function getDeclaredTypeOfReference(expr) { - if (expr.kind === 70 /* Identifier */) { + if (expr.kind === 71 /* Identifier */) { return getTypeOfSymbol(getResolvedSymbol(expr)); } - if (expr.kind === 178 /* PropertyAccessExpression */) { + if (expr.kind === 179 /* PropertyAccessExpression */) { var type = getDeclaredTypeOfReference(expr.expression); return type && getTypeOfPropertyOfType(type, expr.name.text); } @@ -33549,7 +35093,7 @@ var ts; var prop = getUnionOrIntersectionProperty(type, name); if (prop && getCheckFlags(prop) & 2 /* SyntheticProperty */) { if (prop.isDiscriminantProperty === undefined) { - prop.isDiscriminantProperty = prop.checkFlags & 16 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); + prop.isDiscriminantProperty = prop.checkFlags & 32 /* HasNonUniformType */ && isLiteralType(getTypeOfSymbol(prop)); } return prop.isDiscriminantProperty; } @@ -33568,7 +35112,7 @@ var ts; } } } - if (callExpression.expression.kind === 178 /* PropertyAccessExpression */ && + if (callExpression.expression.kind === 179 /* PropertyAccessExpression */ && isOrContainsMatchingReference(reference, callExpression.expression.expression)) { return true; } @@ -33610,8 +35154,8 @@ var ts; } function getTypeFactsOfTypes(types) { var result = 0 /* None */; - for (var _i = 0, types_13 = types; _i < types_13.length; _i++) { - var t = types_13[_i]; + for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { + var t = types_14[_i]; result |= getTypeFacts(t); } return result; @@ -33667,9 +35211,8 @@ var ts; if (flags & 16777216 /* NonPrimitive */) { return strictNullChecks ? 6166480 /* ObjectStrictFacts */ : 8378320 /* ObjectFacts */; } - if (flags & 16384 /* TypeParameter */) { - var constraint = getConstraintOfTypeParameter(type); - return getTypeFacts(constraint || emptyObjectType); + if (flags & 540672 /* TypeVariable */) { + return getTypeFacts(getBaseConstraintOfType(type) || emptyObjectType); } if (flags & 196608 /* UnionOrIntersection */) { return getTypeFactsOfTypes(type.types); @@ -33695,22 +35238,22 @@ var ts; } function getTypeOfDestructuredArrayElement(type, index) { return isTupleLikeType(type) && getTypeOfPropertyOfType(type, "" + index) || - checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || + checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; } function getTypeOfDestructuredSpreadExpression(type) { - return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false) || unknownType); + return createArrayType(checkIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType); } function getAssignedTypeOfBinaryExpression(node) { - var isDestructuringDefaultAssignment = node.parent.kind === 176 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || - node.parent.kind === 260 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); + var isDestructuringDefaultAssignment = node.parent.kind === 177 /* ArrayLiteralExpression */ && isDestructuringAssignmentTarget(node.parent) || + node.parent.kind === 261 /* PropertyAssignment */ && isDestructuringAssignmentTarget(node.parent.parent); return isDestructuringDefaultAssignment ? getTypeWithDefault(getAssignedType(node), node.right) : getTypeOfExpression(node.right); } function isDestructuringAssignmentTarget(parent) { - return parent.parent.kind === 193 /* BinaryExpression */ && parent.parent.left === parent || - parent.parent.kind === 215 /* ForOfStatement */ && parent.parent.initializer === parent; + return parent.parent.kind === 194 /* BinaryExpression */ && parent.parent.left === parent || + parent.parent.kind === 216 /* ForOfStatement */ && parent.parent.initializer === parent; } function getAssignedTypeOfArrayLiteralElement(node, element) { return getTypeOfDestructuredArrayElement(getAssignedType(node), ts.indexOf(node.elements, element)); @@ -33727,21 +35270,21 @@ var ts; function getAssignedType(node) { var parent = node.parent; switch (parent.kind) { - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return stringType; - case 215 /* ForOfStatement */: - return checkRightHandSideOfForOf(parent.expression) || unknownType; - case 193 /* BinaryExpression */: + case 216 /* ForOfStatement */: + return checkRightHandSideOfForOf(parent.expression, parent.awaitModifier) || unknownType; + case 194 /* BinaryExpression */: return getAssignedTypeOfBinaryExpression(parent); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return undefinedType; - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return getAssignedTypeOfArrayLiteralElement(parent, node); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return getAssignedTypeOfSpreadExpression(parent); - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return getAssignedTypeOfPropertyAssignment(parent); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return getAssignedTypeOfShorthandPropertyAssignment(parent); } return unknownType; @@ -33749,7 +35292,7 @@ var ts; function getInitialTypeOfBindingElement(node) { var pattern = node.parent; var parentType = getInitialType(pattern.parent); - var type = pattern.kind === 173 /* ObjectBindingPattern */ ? + var type = pattern.kind === 174 /* ObjectBindingPattern */ ? getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) : !node.dotDotDotToken ? getTypeOfDestructuredArrayElement(parentType, ts.indexOf(pattern.elements, node)) : @@ -33767,39 +35310,39 @@ var ts; if (node.initializer) { return getTypeOfInitializer(node.initializer); } - if (node.parent.parent.kind === 214 /* ForInStatement */) { + if (node.parent.parent.kind === 215 /* ForInStatement */) { return stringType; } - if (node.parent.parent.kind === 215 /* ForOfStatement */) { - return checkRightHandSideOfForOf(node.parent.parent.expression) || unknownType; + if (node.parent.parent.kind === 216 /* ForOfStatement */) { + return checkRightHandSideOfForOf(node.parent.parent.expression, node.parent.parent.awaitModifier) || unknownType; } return unknownType; } function getInitialType(node) { - return node.kind === 225 /* VariableDeclaration */ ? + return node.kind === 226 /* VariableDeclaration */ ? getInitialTypeOfVariableDeclaration(node) : getInitialTypeOfBindingElement(node); } function getInitialOrAssignedType(node) { - return node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */ ? + return node.kind === 226 /* VariableDeclaration */ || node.kind === 176 /* BindingElement */ ? getInitialType(node) : getAssignedType(node); } function isEmptyArrayAssignment(node) { - return node.kind === 225 /* VariableDeclaration */ && node.initializer && + return node.kind === 226 /* VariableDeclaration */ && node.initializer && isEmptyArrayLiteral(node.initializer) || - node.kind !== 175 /* BindingElement */ && node.parent.kind === 193 /* BinaryExpression */ && + node.kind !== 176 /* BindingElement */ && node.parent.kind === 194 /* BinaryExpression */ && isEmptyArrayLiteral(node.parent.right); } function getReferenceCandidate(node) { switch (node.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return getReferenceCandidate(node.expression); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: switch (node.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return getReferenceCandidate(node.left); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return getReferenceCandidate(node.right); } } @@ -33807,13 +35350,13 @@ var ts; } function getReferenceRoot(node) { var parent = node.parent; - return parent.kind === 184 /* ParenthesizedExpression */ || - parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 57 /* EqualsToken */ && parent.left === node || - parent.kind === 193 /* BinaryExpression */ && parent.operatorToken.kind === 25 /* CommaToken */ && parent.right === node ? + return parent.kind === 185 /* ParenthesizedExpression */ || + parent.kind === 194 /* BinaryExpression */ && parent.operatorToken.kind === 58 /* EqualsToken */ && parent.left === node || + parent.kind === 194 /* BinaryExpression */ && parent.operatorToken.kind === 26 /* CommaToken */ && parent.right === node ? getReferenceRoot(parent) : node; } function getTypeOfSwitchClause(clause) { - if (clause.kind === 256 /* CaseClause */) { + if (clause.kind === 257 /* CaseClause */) { var caseType = getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression)); return isUnitType(caseType) ? caseType : undefined; } @@ -33861,8 +35404,32 @@ var ts; } return f(type) ? type : neverType; } - function mapType(type, f) { - return type.flags & 65536 /* Union */ ? getUnionType(ts.map(type.types, f)) : f(type); + // Apply a mapping function to a type and return the resulting type. If the source type + // is a union type, the mapping function is applied to each constituent type and a union + // of the resulting types is returned. + function mapType(type, mapper) { + if (!(type.flags & 65536 /* Union */)) { + return mapper(type); + } + var types = type.types; + var mappedType; + var mappedTypes; + for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { + var current = types_15[_i]; + var t = mapper(current); + if (t) { + if (!mappedType) { + mappedType = t; + } + else if (!mappedTypes) { + mappedTypes = [mappedType, t]; + } + else { + mappedTypes.push(t); + } + } + } + return mappedTypes ? getUnionType(mappedTypes) : mappedType; } function extractTypesOfKind(type, kind) { return filterType(type, function (t) { return (t.flags & kind) !== 0; }); @@ -33906,7 +35473,7 @@ var ts; // we defer subtype reduction until the evolving array type is finalized into a manifest // array type. function addEvolvingArrayElementType(evolvingArrayType, node) { - var elementType = getBaseTypeOfLiteralType(getTypeOfExpression(node)); + var elementType = getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)); return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType])); } function createFinalArrayType(elementType) { @@ -33928,8 +35495,8 @@ var ts; } function isEvolvingArrayTypeList(types) { var hasEvolvingArrayType = false; - for (var _i = 0, types_14 = types; _i < types_14.length; _i++) { - var t = types_14[_i]; + for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { + var t = types_16[_i]; if (!(t.flags & 8192 /* Never */)) { if (!(getObjectFlags(t) & 256 /* EvolvingArray */)) { return false; @@ -33952,12 +35519,12 @@ var ts; function isEvolvingArrayOperationTarget(node) { var root = getReferenceRoot(node); var parent = root.parent; - var isLengthPushOrUnshift = parent.kind === 178 /* PropertyAccessExpression */ && (parent.name.text === "length" || - parent.parent.kind === 180 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); - var isElementAssignment = parent.kind === 179 /* ElementAccessExpression */ && + var isLengthPushOrUnshift = parent.kind === 179 /* PropertyAccessExpression */ && (parent.name.text === "length" || + parent.parent.kind === 181 /* CallExpression */ && ts.isPushOrUnshiftIdentifier(parent.name)); + var isElementAssignment = parent.kind === 180 /* ElementAccessExpression */ && parent.expression === root && - parent.parent.kind === 193 /* BinaryExpression */ && - parent.parent.operatorToken.kind === 57 /* EqualsToken */ && + parent.parent.kind === 194 /* BinaryExpression */ && + parent.parent.operatorToken.kind === 58 /* EqualsToken */ && parent.parent.left === parent && !ts.isAssignmentTarget(parent.parent) && isTypeAnyOrAllConstituentTypesHaveKind(getTypeOfExpression(parent.argumentExpression), 340 /* NumberLike */ | 2048 /* Undefined */); @@ -33971,7 +35538,7 @@ var ts; return links.maybeTypePredicate; } function getMaybeTypePredicate(node) { - if (node.expression.kind !== 96 /* SuperKeyword */) { + if (node.expression.kind !== 97 /* SuperKeyword */) { var funcType = checkNonNullExpression(node.expression); if (funcType !== silentNeverType) { var apparentType = getApparentType(funcType); @@ -33983,14 +35550,12 @@ var ts; } return false; } - function getFlowTypeOfReference(reference, declaredType, assumeInitialized, flowContainer) { + function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) { + if (initialType === void 0) { initialType = declaredType; } var key; - if (!reference.flowNode || assumeInitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { + if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 17810431 /* Narrowable */)) { return declaredType; } - var initialType = assumeInitialized ? declaredType : - declaredType === autoType || declaredType === autoArrayType ? undefinedType : - includeFalsyTypes(declaredType, 2048 /* Undefined */); var visitedFlowStart = visitedFlowCount; var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode)); visitedFlowCount = visitedFlowStart; @@ -33999,7 +35564,7 @@ var ts; // on empty arrays are possible without implicit any errors and new element types can be inferred without // type mismatch errors. var resultType = getObjectFlags(evolvedType) & 256 /* EvolvingArray */ && isEvolvingArrayOperationTarget(reference) ? anyArrayType : finalizeEvolvingArrayType(evolvedType); - if (reference.parent.kind === 202 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { + if (reference.parent.kind === 203 /* NonNullExpression */ && getTypeWithFacts(resultType, 524288 /* NEUndefinedOrNull */).flags & 8192 /* Never */) { return declaredType; } return resultType; @@ -34017,7 +35582,7 @@ var ts; } var type = void 0; if (flow.flags & 4096 /* AfterFinally */) { - // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement + // block flow edge: finally -> pre-try (for larger explanation check comment in binder.ts - bindTryStatement flow.locked = true; type = getTypeAtFlowNode(flow.antecedent); flow.locked = false; @@ -34060,7 +35625,7 @@ var ts; else if (flow.flags & 2 /* Start */) { // Check if we should continue with the control flow of the containing function. var container = flow.container; - if (container && container !== flowContainer && reference.kind !== 178 /* PropertyAccessExpression */) { + if (container && container !== flowContainer && reference.kind !== 179 /* PropertyAccessExpression */ && reference.kind !== 99 /* ThisKeyword */) { flow = container.flowNode; continue; } @@ -34114,7 +35679,7 @@ var ts; } function getTypeAtFlowArrayMutation(flow) { var node = flow.node; - var expr = node.kind === 180 /* CallExpression */ ? + var expr = node.kind === 181 /* CallExpression */ ? node.expression.expression : node.left.expression; if (isMatchingReference(reference, getReferenceCandidate(expr))) { @@ -34122,7 +35687,7 @@ var ts; var type = getTypeFromFlowType(flowType); if (getObjectFlags(type) & 256 /* EvolvingArray */) { var evolvedType_1 = type; - if (node.kind === 180 /* CallExpression */) { + if (node.kind === 181 /* CallExpression */) { for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) { var arg = _a[_i]; evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg); @@ -34182,7 +35747,7 @@ var ts; for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) { var antecedent = _a[_i]; if (antecedent.flags & 2048 /* PreFinally */ && antecedent.lock.locked) { - // if flow correspond to branch from pre-try to finally and this branch is locked - this means that + // if flow correspond to branch from pre-try to finally and this branch is locked - this means that // we initially have started following the flow outside the finally block. // in this case we should ignore this branch. continue; @@ -34286,7 +35851,7 @@ var ts; return result; } function isMatchingReferenceDiscriminant(expr) { - return expr.kind === 178 /* PropertyAccessExpression */ && + return expr.kind === 179 /* PropertyAccessExpression */ && declaredType.flags & 65536 /* Union */ && isMatchingReference(reference, expr.expression) && isDiscriminantProperty(declaredType, expr.name.text); @@ -34311,19 +35876,19 @@ var ts; } function narrowTypeByBinaryExpression(type, expr, assumeTrue) { switch (expr.operatorToken.kind) { - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: return narrowTypeByTruthiness(type, expr.left, assumeTrue); - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: var operator_1 = expr.operatorToken.kind; var left_1 = getReferenceCandidate(expr.left); var right_1 = getReferenceCandidate(expr.right); - if (left_1.kind === 188 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { + if (left_1.kind === 189 /* TypeOfExpression */ && right_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue); } - if (right_1.kind === 188 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { + if (right_1.kind === 189 /* TypeOfExpression */ && left_1.kind === 9 /* StringLiteral */) { return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue); } if (isMatchingReference(reference, left_1)) { @@ -34342,9 +35907,9 @@ var ts; return declaredType; } break; - case 92 /* InstanceOfKeyword */: + case 93 /* InstanceOfKeyword */: return narrowTypeByInstanceof(type, expr, assumeTrue); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return narrowType(type, expr.right, assumeTrue); } return type; @@ -34353,7 +35918,7 @@ var ts; if (type.flags & 1 /* Any */) { return type; } - if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { + if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } var valueType = getTypeOfExpression(value); @@ -34361,10 +35926,10 @@ var ts; if (!strictNullChecks) { return type; } - var doubleEquals = operator === 31 /* EqualsEqualsToken */ || operator === 32 /* ExclamationEqualsToken */; + var doubleEquals = operator === 32 /* EqualsEqualsToken */ || operator === 33 /* ExclamationEqualsToken */; var facts = doubleEquals ? assumeTrue ? 65536 /* EQUndefinedOrNull */ : 524288 /* NEUndefinedOrNull */ : - value.kind === 94 /* NullKeyword */ ? + value.kind === 95 /* NullKeyword */ ? assumeTrue ? 32768 /* EQNull */ : 262144 /* NENull */ : assumeTrue ? 16384 /* EQUndefined */ : 131072 /* NEUndefined */; return getTypeWithFacts(type, facts); @@ -34393,7 +35958,7 @@ var ts; } return type; } - if (operator === 32 /* ExclamationEqualsToken */ || operator === 34 /* ExclamationEqualsEqualsToken */) { + if (operator === 33 /* ExclamationEqualsToken */ || operator === 35 /* ExclamationEqualsEqualsToken */) { assumeTrue = !assumeTrue; } if (assumeTrue && !(type.flags & 65536 /* Union */)) { @@ -34401,8 +35966,16 @@ var ts; // is a supertype of that primitive type. For example, type 'any' can be narrowed // to one of the primitive types. var targetType = typeofTypesByName.get(literal.text); - if (targetType && isTypeSubtypeOf(targetType, type)) { - return targetType; + if (targetType) { + if (isTypeSubtypeOf(targetType, type)) { + return targetType; + } + if (type.flags & 540672 /* TypeVariable */) { + var constraint = getBaseConstraintOfType(type) || anyType; + if (isTypeSubtypeOf(targetType, constraint)) { + return getIntersectionType([type, targetType]); + } + } } } var facts = assumeTrue ? @@ -34490,10 +36063,9 @@ var ts; // Otherwise, if the candidate type is assignable to the target type, narrow to the candidate // type. Otherwise, the types are completely unrelated, so narrow to an intersection of the // two types. - var targetType = type.flags & 16384 /* TypeParameter */ ? getApparentType(type) : type; return isTypeSubtypeOf(candidate, type) ? candidate : isTypeAssignableTo(type, candidate) ? type : - isTypeAssignableTo(candidate, targetType) ? candidate : + isTypeAssignableTo(candidate, type) ? candidate : getIntersectionType([type, candidate]); } function narrowTypeByTypePredicate(type, callExpression, assumeTrue) { @@ -34510,7 +36082,7 @@ var ts; return type; } if (ts.isIdentifierTypePredicate(predicate)) { - var predicateArgument = callExpression.arguments[predicate.parameterIndex]; + var predicateArgument = callExpression.arguments[predicate.parameterIndex - (signature.thisParameter ? 1 : 0)]; if (predicateArgument) { if (isMatchingReference(reference, predicateArgument)) { return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf); @@ -34522,7 +36094,7 @@ var ts; } else { var invokedExpression = ts.skipParentheses(callExpression.expression); - if (invokedExpression.kind === 179 /* ElementAccessExpression */ || invokedExpression.kind === 178 /* PropertyAccessExpression */) { + if (invokedExpression.kind === 180 /* ElementAccessExpression */ || invokedExpression.kind === 179 /* PropertyAccessExpression */) { var accessExpression = invokedExpression; var possibleReference = ts.skipParentheses(accessExpression.expression); if (isMatchingReference(reference, possibleReference)) { @@ -34539,18 +36111,19 @@ var ts; // will be a subtype or the same type as the argument. function narrowType(type, expr, assumeTrue) { switch (expr.kind) { - case 70 /* Identifier */: - case 98 /* ThisKeyword */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 99 /* ThisKeyword */: + case 97 /* SuperKeyword */: + case 179 /* PropertyAccessExpression */: return narrowTypeByTruthiness(type, expr, assumeTrue); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return narrowTypeByTypePredicate(type, expr, assumeTrue); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return narrowType(type, expr.expression, assumeTrue); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return narrowTypeByBinaryExpression(type, expr, assumeTrue); - case 191 /* PrefixUnaryExpression */: - if (expr.operator === 50 /* ExclamationToken */) { + case 192 /* PrefixUnaryExpression */: + if (expr.operator === 51 /* ExclamationToken */) { return narrowType(type, expr.operand, !assumeTrue); } break; @@ -34563,7 +36136,7 @@ var ts; // an dotted name expression, and if the location is not an assignment target, obtain the type // of the expression (which will reflect control flow analysis). If the expression indeed // resolved to the given symbol, return the narrowed type. - if (location.kind === 70 /* Identifier */) { + if (location.kind === 71 /* Identifier */) { if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) { location = location.parent; } @@ -34582,15 +36155,12 @@ var ts; return getTypeOfSymbol(symbol); } function getControlFlowContainer(node) { - while (true) { - node = node.parent; - if (ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || - node.kind === 233 /* ModuleBlock */ || - node.kind === 264 /* SourceFile */ || - node.kind === 148 /* PropertyDeclaration */) { - return node; - } - } + return ts.findAncestor(node.parent, function (node) { + return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) || + node.kind === 234 /* ModuleBlock */ || + node.kind === 265 /* SourceFile */ || + node.kind === 149 /* PropertyDeclaration */; + }); } // Check if a parameter is assigned anywhere within its declaring function. function isParameterAssigned(symbol) { @@ -34605,21 +36175,13 @@ var ts; return symbol.isAssigned || false; } function hasParentWithAssignmentsMarked(node) { - while (true) { - node = node.parent; - if (!node) { - return false; - } - if (ts.isFunctionLike(node) && getNodeLinks(node).flags & 4194304 /* AssignmentsMarked */) { - return true; - } - } + return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 4194304 /* AssignmentsMarked */); }); } function markParameterAssignments(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { if (ts.isAssignmentTarget(node)) { var symbol = getResolvedSymbol(node); - if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 145 /* Parameter */) { + if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 146 /* Parameter */) { symbol.isAssigned = true; } } @@ -34631,6 +36193,15 @@ var ts; function isConstVariable(symbol) { return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType; } + /** remove undefined from the annotated type of a parameter when there is an initializer (that doesn't include undefined) */ + function removeOptionalityFromDeclaredType(declaredType, declaration) { + var annotationIncludesUndefined = strictNullChecks && + declaration.kind === 146 /* Parameter */ && + declaration.initializer && + getFalsyFlags(declaredType) & 2048 /* Undefined */ && + !(getFalsyFlags(checkExpression(declaration.initializer)) & 2048 /* Undefined */); + return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 131072 /* NEUndefined */) : declaredType; + } function checkIdentifier(node) { var symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -34645,16 +36216,14 @@ var ts; if (symbol === argumentsSymbol) { var container = ts.getContainingFunction(node); if (languageVersion < 2 /* ES2015 */) { - if (container.kind === 186 /* ArrowFunction */) { + if (container.kind === 187 /* ArrowFunction */) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression); } else if (ts.hasModifier(container, 256 /* Async */)) { error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method); } } - if (node.flags & 16384 /* AwaitContext */) { - getNodeLinks(container).flags |= 8192 /* CaptureArguments */; - } + getNodeLinks(container).flags |= 8192 /* CaptureArguments */; return getTypeOfSymbol(symbol); } if (symbol.flags & 8388608 /* Alias */ && !isInTypeQuery(node) && !isConstEnumOrConstEnumOnlyModule(resolveAlias(symbol))) { @@ -34666,7 +36235,7 @@ var ts; // 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 (declaration_1.kind === 228 /* ClassDeclaration */ + if (declaration_1.kind === 229 /* ClassDeclaration */ && ts.nodeIsDecorated(declaration_1)) { var container = ts.getContainingClass(node); while (container !== undefined) { @@ -34678,14 +36247,14 @@ var ts; container = ts.getContainingClass(container); } } - else if (declaration_1.kind === 198 /* ClassExpression */) { + else if (declaration_1.kind === 199 /* ClassExpression */) { // When we emit a class expression with static members that contain a reference // to the constructor in the initializer, we will need to substitute that // binding with an alias as the class name is not in scope. var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); while (container !== undefined) { if (container.parent === declaration_1) { - if (container.kind === 148 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { + if (container.kind === 149 /* PropertyDeclaration */ && ts.hasModifier(container, 32 /* Static */)) { getNodeLinks(declaration_1).flags |= 8388608 /* ClassWithConstructorReference */; getNodeLinks(node).flags |= 16777216 /* ConstructorReferenceInClass */; } @@ -34720,15 +36289,15 @@ var ts; // The declaration container is the innermost function that encloses the declaration of the variable // or parameter. The flow container is the innermost function starting with which we analyze the control // flow graph to determine the control flow based type. - var isParameter = ts.getRootDeclaration(declaration).kind === 145 /* Parameter */; + var isParameter = ts.getRootDeclaration(declaration).kind === 146 /* Parameter */; var declarationContainer = getControlFlowContainer(declaration); var flowContainer = getControlFlowContainer(node); var isOuterVariable = flowContainer !== declarationContainer; // When the control flow originates in a function expression or arrow function and we are referencing // a const variable or parameter from an outer function, we extend the origin of the control flow // analysis to include the immediately enclosing function. - while (flowContainer !== declarationContainer && (flowContainer.kind === 185 /* FunctionExpression */ || - flowContainer.kind === 186 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && + while (flowContainer !== declarationContainer && (flowContainer.kind === 186 /* FunctionExpression */ || + flowContainer.kind === 187 /* ArrowFunction */ || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) && (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } @@ -34736,15 +36305,18 @@ var ts; // the entire control flow graph from the variable's declaration (i.e. when the flow container and // declaration container are the same). var assumeInitialized = isParameter || isOuterVariable || - type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node)) || + type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & 1 /* Any */) !== 0 || isInTypeQuery(node) || node.parent.kind === 246 /* ExportSpecifier */) || ts.isInAmbientContext(declaration); - var flowType = getFlowTypeOfReference(node, type, assumeInitialized, flowContainer); + var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, ts.getRootDeclaration(declaration)) : type) : + type === autoType || type === autoArrayType ? undefinedType : + includeFalsyTypes(type, 2048 /* Undefined */); + var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized); // A variable is considered uninitialized when it is possible to analyze the entire control flow graph // from declaration to use, and when the variable's declared type doesn't include undefined but the // control flow based type does include undefined. if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(declaration.name, ts.Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } @@ -34759,19 +36331,12 @@ var ts; return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isInsideFunction(node, threshold) { - var current = node; - while (current && current !== threshold) { - if (ts.isFunctionLike(current)) { - return true; - } - current = current.parent; - } - return false; + return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); }); } function checkNestedBlockScopedBinding(node, symbol) { if (languageVersion >= 2 /* ES2015 */ || (symbol.flags & (2 /* BlockScopedVariable */ | 32 /* Class */)) === 0 || - symbol.valueDeclaration.parent.kind === 259 /* CatchClause */) { + symbol.valueDeclaration.parent.kind === 260 /* CatchClause */) { return; } // 1. walk from the use site up to the declaration and check @@ -34796,8 +36361,8 @@ var ts; } // 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 === 213 /* ForStatement */ && - ts.getAncestor(symbol.valueDeclaration, 226 /* VariableDeclarationList */).parent === container && + if (container.kind === 214 /* ForStatement */ && + ts.getAncestor(symbol.valueDeclaration, 227 /* VariableDeclarationList */).parent === container && isAssignedInBodyOfForStatement(node, container)) { getNodeLinks(symbol.valueDeclaration).flags |= 2097152 /* NeedsLoopOutParameter */; } @@ -34809,9 +36374,9 @@ var ts; } } function isAssignedInBodyOfForStatement(node, container) { - var current = node; // skip parenthesized nodes - while (current.parent.kind === 184 /* ParenthesizedExpression */) { + var current = node; + while (current.parent.kind === 185 /* ParenthesizedExpression */) { current = current.parent; } // check if node is used as LHS in some assignment expression @@ -34819,28 +36384,20 @@ var ts; if (ts.isAssignmentTarget(current)) { isAssigned = true; } - else if ((current.parent.kind === 191 /* PrefixUnaryExpression */ || current.parent.kind === 192 /* PostfixUnaryExpression */)) { + else if ((current.parent.kind === 192 /* PrefixUnaryExpression */ || current.parent.kind === 193 /* PostfixUnaryExpression */)) { var expr = current.parent; - isAssigned = expr.operator === 42 /* PlusPlusToken */ || expr.operator === 43 /* MinusMinusToken */; + isAssigned = expr.operator === 43 /* PlusPlusToken */ || expr.operator === 44 /* 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; + return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; }); } function captureLexicalThis(node, container) { getNodeLinks(node).flags |= 2 /* LexicalThis */; - if (container.kind === 148 /* PropertyDeclaration */ || container.kind === 151 /* Constructor */) { + if (container.kind === 149 /* PropertyDeclaration */ || container.kind === 152 /* Constructor */) { var classNode = container.parent; getNodeLinks(classNode).flags |= 4 /* CaptureThis */; } @@ -34908,38 +36465,38 @@ var ts; // tell whether 'this' needs to be captured. var container = ts.getThisContainer(node, /* includeArrowFunctions */ true); var needToCaptureLexicalThis = false; - if (container.kind === 151 /* Constructor */) { + if (container.kind === 152 /* Constructor */) { checkThisBeforeSuper(node, container, 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 === 186 /* ArrowFunction */) { + if (container.kind === 187 /* 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 /* ES2015 */); } switch (container.kind) { - case 232 /* ModuleDeclaration */: + case 233 /* 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 231 /* EnumDeclaration */: + case 232 /* 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 151 /* Constructor */: + case 152 /* Constructor */: if (isInConstructorArgumentInitializer(node, container)) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: if (ts.getModifierFlags(container) & 32 /* Static */) { error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer); // do not return here so in case if lexical this is captured - it will be reflected in flags on NodeLinks } break; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name); break; } @@ -34951,8 +36508,8 @@ var ts; // Note: a parameter initializer should refer to class-this unless function-this is explicitly annotated. // 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 === 185 /* FunctionExpression */ && - ts.isInJavaScriptFile(container.parent) && + if (container.kind === 186 /* FunctionExpression */ && + container.parent.kind === 194 /* BinaryExpression */ && 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 @@ -34972,7 +36529,7 @@ var ts; if (ts.isClassLike(container.parent)) { var symbol = getSymbolOfNode(container.parent); var type = ts.hasModifier(container, 32 /* Static */) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType; - return getFlowTypeOfReference(node, type, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + return getFlowTypeOfReference(node, type); } if (ts.isInJavaScriptFile(node)) { var type = getTypeForThisExpressionFromJSDoc(container); @@ -34980,7 +36537,7 @@ var ts; return type; } } - if (compilerOptions.noImplicitThis) { + if (noImplicitThis) { // With noImplicitThis, functions may not reference 'this' if it has type 'any' error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation); } @@ -34988,28 +36545,23 @@ var ts; } function getTypeForThisExpressionFromJSDoc(node) { var jsdocType = ts.getJSDocType(node); - if (jsdocType && jsdocType.kind === 278 /* JSDocFunctionType */) { + if (jsdocType && jsdocType.kind === 279 /* JSDocFunctionType */) { var jsDocFunctionType = jsdocType; - if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 281 /* JSDocThisType */) { + if (jsDocFunctionType.parameters.length > 0 && jsDocFunctionType.parameters[0].type.kind === 282 /* JSDocThisType */) { return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type); } } } function isInConstructorArgumentInitializer(node, constructorDecl) { - for (var n = node; n && n !== constructorDecl; n = n.parent) { - if (n.kind === 145 /* Parameter */) { - return true; - } - } - return false; + return !!ts.findAncestor(node, function (n) { return n === constructorDecl ? "quit" : n.kind === 146 /* Parameter */; }); } function checkSuperExpression(node) { - var isCallExpression = node.parent.kind === 180 /* CallExpression */ && node.parent.expression === node; + var isCallExpression = node.parent.kind === 181 /* CallExpression */ && node.parent.expression === node; var container = ts.getSuperContainer(node, /*stopOnFunctions*/ true); var needToCaptureLexicalThis = false; // adjust the container reference in case if super is used inside arrow functions with arbitrarily deep nesting if (!isCallExpression) { - while (container && container.kind === 186 /* ArrowFunction */) { + while (container && container.kind === 187 /* ArrowFunction */) { container = ts.getSuperContainer(container, /*stopOnFunctions*/ true); needToCaptureLexicalThis = languageVersion < 2 /* ES2015 */; } @@ -35022,17 +36574,14 @@ var ts; // class B { // [super.foo()]() {} // } - var current = node; - while (current && current !== container && current.kind !== 143 /* ComputedPropertyName */) { - current = current.parent; - } - if (current && current.kind === 143 /* ComputedPropertyName */) { + var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 144 /* ComputedPropertyName */; }); + if (current && current.kind === 144 /* 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 === 177 /* ObjectLiteralExpression */)) { + else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 178 /* ObjectLiteralExpression */)) { error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions); } else { @@ -35040,7 +36589,7 @@ var ts; } return unknownType; } - if (!isCallExpression && container.kind === 151 /* Constructor */) { + if (!isCallExpression && container.kind === 152 /* Constructor */) { checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class); } if ((ts.getModifierFlags(container) & 32 /* Static */) || isCallExpression) { @@ -35106,7 +36655,7 @@ var ts; // 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 === 150 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { + if (container.kind === 151 /* MethodDeclaration */ && ts.getModifierFlags(container) & 256 /* Async */) { if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) { getNodeLinks(container).flags |= 4096 /* AsyncMethodWithSuperBinding */; } @@ -35120,7 +36669,7 @@ var ts; // in this case they should also use correct lexical this captureLexicalThis(node.parent, container); } - if (container.parent.kind === 177 /* ObjectLiteralExpression */) { + if (container.parent.kind === 178 /* ObjectLiteralExpression */) { if (languageVersion < 2 /* ES2015 */) { error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher); return unknownType; @@ -35140,7 +36689,7 @@ var ts; } return unknownType; } - if (container.kind === 151 /* Constructor */ && isInConstructorArgumentInitializer(node, container)) { + if (container.kind === 152 /* 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; @@ -35155,7 +36704,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 === 151 /* Constructor */; + return container.kind === 152 /* Constructor */; } else { // TS 1.0 SPEC (April 2014) @@ -35163,29 +36712,47 @@ 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 === 177 /* ObjectLiteralExpression */) { + if (ts.isClassLike(container.parent) || container.parent.kind === 178 /* ObjectLiteralExpression */) { if (ts.getModifierFlags(container) & 32 /* Static */) { - return container.kind === 150 /* MethodDeclaration */ || - container.kind === 149 /* MethodSignature */ || - container.kind === 152 /* GetAccessor */ || - container.kind === 153 /* SetAccessor */; + return container.kind === 151 /* MethodDeclaration */ || + container.kind === 150 /* MethodSignature */ || + container.kind === 153 /* GetAccessor */ || + container.kind === 154 /* SetAccessor */; } else { - return container.kind === 150 /* MethodDeclaration */ || - container.kind === 149 /* MethodSignature */ || - container.kind === 152 /* GetAccessor */ || - container.kind === 153 /* SetAccessor */ || - container.kind === 148 /* PropertyDeclaration */ || - container.kind === 147 /* PropertySignature */ || - container.kind === 151 /* Constructor */; + return container.kind === 151 /* MethodDeclaration */ || + container.kind === 150 /* MethodSignature */ || + container.kind === 153 /* GetAccessor */ || + container.kind === 154 /* SetAccessor */ || + container.kind === 149 /* PropertyDeclaration */ || + container.kind === 148 /* PropertySignature */ || + container.kind === 152 /* Constructor */; } } } return false; } } + function getContainingObjectLiteral(func) { + return (func.kind === 151 /* MethodDeclaration */ || + func.kind === 153 /* GetAccessor */ || + func.kind === 154 /* SetAccessor */) && func.parent.kind === 178 /* ObjectLiteralExpression */ ? func.parent : + func.kind === 186 /* FunctionExpression */ && func.parent.kind === 261 /* PropertyAssignment */ ? func.parent.parent : + undefined; + } + function getThisTypeArgument(type) { + return getObjectFlags(type) & 4 /* Reference */ && type.target === globalThisType ? type.typeArguments[0] : undefined; + } + function getThisTypeFromContextualType(type) { + return mapType(type, function (t) { + return t.flags & 131072 /* Intersection */ ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t); + }); + } function getContextualThisParameterType(func) { - if (isContextSensitiveFunctionOrObjectLiteralMethod(func) && func.kind !== 186 /* ArrowFunction */) { + if (func.kind === 187 /* ArrowFunction */) { + return undefined; + } + if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) { var contextualSignature = getContextualSignature(func); if (contextualSignature) { var thisParameter = contextualSignature.thisParameter; @@ -35194,6 +36761,40 @@ var ts; } } } + if (noImplicitThis) { + var containingLiteral = getContainingObjectLiteral(func); + if (containingLiteral) { + // We have an object literal method. Check if the containing object literal has a contextual type + // that includes a ThisType. If so, T is the contextual type for 'this'. We continue looking in + // any directly enclosing object literals. + var contextualType = getApparentTypeOfContextualType(containingLiteral); + var literal = containingLiteral; + var type = contextualType; + while (type) { + var thisType = getThisTypeFromContextualType(type); + if (thisType) { + return instantiateType(thisType, getContextualMapper(containingLiteral)); + } + if (literal.parent.kind !== 261 /* PropertyAssignment */) { + break; + } + literal = literal.parent.parent; + type = getApparentTypeOfContextualType(literal); + } + // There was no contextual ThisType for the containing object literal, so the contextual type + // for 'this' is the non-null form of the contextual type for the containing object literal or + // the type of the object literal itself. + return contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral); + } + // In an assignment of the form 'obj.xxx = function(...)' or 'obj[xxx] = function(...)', the + // contextual type for 'this' is 'obj'. + if (func.parent.kind === 194 /* BinaryExpression */ && func.parent.operatorToken.kind === 58 /* EqualsToken */) { + var target = func.parent.left; + if (target.kind === 179 /* PropertyAccessExpression */ || target.kind === 180 /* ElementAccessExpression */) { + return checkExpressionCached(target.expression); + } + } + } return undefined; } // Return contextual type of parameter or undefined if no contextual type is available @@ -35251,7 +36852,7 @@ var ts; if (declaration.type) { return getTypeFromTypeNode(declaration.type); } - if (declaration.kind === 145 /* Parameter */) { + if (declaration.kind === 146 /* Parameter */) { var type = getContextuallyTypedParameterType(declaration); if (type) { return type; @@ -35263,7 +36864,7 @@ var ts; if (ts.isBindingPattern(declaration.parent)) { var parentDeclaration = declaration.parent.parent; var name = declaration.propertyName || declaration.name; - if (ts.isVariableLike(parentDeclaration) && + if (parentDeclaration.kind !== 176 /* BindingElement */ && parentDeclaration.type && !ts.isBindingPattern(name)) { var text = ts.getTextOfPropertyName(name); @@ -35277,33 +36878,34 @@ var ts; } function getContextualTypeForReturnExpression(node) { var func = ts.getContainingFunction(node); - if (ts.isAsyncFunctionLike(func)) { - var contextualReturnType = getContextualReturnType(func); - if (contextualReturnType) { - return getPromisedType(contextualReturnType); + if (func) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1 /* Generator */) { + return undefined; } - return undefined; - } - if (func && !func.asteriskToken) { - return getContextualReturnType(func); + var contextualReturnType = getContextualReturnType(func); + return functionFlags & 2 /* Async */ + ? contextualReturnType && getAwaitedTypeOfPromise(contextualReturnType) // Async function + : contextualReturnType; // Regular function } return undefined; } function getContextualTypeForYieldOperand(node) { var func = ts.getContainingFunction(node); if (func) { + var functionFlags = ts.getFunctionFlags(func); var contextualReturnType = getContextualReturnType(func); if (contextualReturnType) { return node.asteriskToken ? contextualReturnType - : getElementTypeOfIterableIterator(contextualReturnType); + : getIteratedTypeOfGenerator(contextualReturnType, (functionFlags & 2 /* Async */) !== 0); } } return undefined; } function isInParameterInitializerBeforeContainingFunction(node) { while (node.parent && !ts.isFunctionLike(node.parent)) { - if (node.parent.kind === 145 /* Parameter */ && node.parent.initializer === node) { + if (node.parent.kind === 146 /* Parameter */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -35314,8 +36916,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 === 151 /* Constructor */ || - functionDecl.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 153 /* SetAccessor */))) { + functionDecl.kind === 152 /* Constructor */ || + functionDecl.kind === 153 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(functionDecl.symbol, 154 /* SetAccessor */))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } // Otherwise, if the containing function is contextually typed by a function type with exactly one call signature @@ -35337,7 +36939,7 @@ var ts; return undefined; } function getContextualTypeForSubstitutionExpression(template, substitutionExpression) { - if (template.parent.kind === 182 /* TaggedTemplateExpression */) { + if (template.parent.kind === 183 /* TaggedTemplateExpression */) { return getContextualTypeForArgument(template.parent, substitutionExpression); } return undefined; @@ -35345,7 +36947,7 @@ var ts; function getContextualTypeForBinaryOperand(node) { var binaryExpression = node.parent; var operator = binaryExpression.operatorToken.kind; - if (operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { + if (operator >= 58 /* FirstAssignment */ && operator <= 70 /* LastAssignment */) { // Don't do this for special property assignments to avoid circularity if (ts.getSpecialPropertyAssignmentKind(binaryExpression) !== 0 /* None */) { return undefined; @@ -35355,7 +36957,7 @@ var ts; return getTypeOfExpression(binaryExpression.left); } } - else if (operator === 53 /* BarBarToken */) { + else if (operator === 54 /* BarBarToken */) { // When an || expression has a contextual type, the operands are contextually typed by that type. When an || // expression has no contextual type, the right operand is contextually typed by the type of the left operand. var type = getContextualType(binaryExpression); @@ -35364,48 +36966,21 @@ var ts; } return type; } - else if (operator === 52 /* AmpersandAmpersandToken */ || operator === 25 /* CommaToken */) { + else if (operator === 53 /* AmpersandAmpersandToken */ || operator === 26 /* CommaToken */) { if (node === binaryExpression.right) { return getContextualType(binaryExpression); } } return undefined; } - // Apply a mapping function to a contextual type and return the resulting type. If the contextual type - // is a union type, the mapping function is applied to each constituent type and a union of the resulting - // types is returned. - function applyToContextualType(type, mapper) { - if (!(type.flags & 65536 /* Union */)) { - return mapper(type); - } - var types = type.types; - var mappedType; - var mappedTypes; - for (var _i = 0, types_15 = types; _i < types_15.length; _i++) { - var current = types_15[_i]; - var t = mapper(current); - if (t) { - if (!mappedType) { - mappedType = t; - } - else if (!mappedTypes) { - mappedTypes = [mappedType, t]; - } - else { - mappedTypes.push(t); - } - } - } - return mappedTypes ? getUnionType(mappedTypes) : mappedType; - } function getTypeOfPropertyOfContextualType(type, name) { - return applyToContextualType(type, function (t) { + return mapType(type, function (t) { var prop = t.flags & 229376 /* StructuredType */ ? getPropertyOfType(t, name) : undefined; return prop ? getTypeOfSymbol(prop) : undefined; }); } function getIndexTypeOfContextualType(type, kind) { - return applyToContextualType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); + return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }); } // Return true if the given contextual type is a tuple-like type function contextualTypeIsTupleLikeType(type) { @@ -35452,7 +37027,7 @@ var ts; var index = ts.indexOf(arrayLiteral.elements, node); return getTypeOfPropertyOfContextualType(type, "" + index) || getIndexTypeOfContextualType(type, 1 /* Number */) - || (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(type, /*errorNode*/ undefined) : undefined); + || getIteratedTypeOrElementType(type, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); } return undefined; } @@ -35461,6 +37036,32 @@ var ts; var conditional = node.parent; return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional) : undefined; } + function getContextualTypeForJsxExpression(node) { + // JSX expression can appear in two position : JSX Element's children or JSX attribute + var jsxAttributes = ts.isJsxAttributeLike(node.parent) ? + node.parent.parent : + node.parent.openingElement.attributes; // node.parent is JsxElement + // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type + // which is a type of the parameter of the signature we are trying out. + // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName + var attributesType = getContextualType(jsxAttributes); + if (!attributesType || isTypeAny(attributesType)) { + return undefined; + } + if (ts.isJsxAttribute(node.parent)) { + // JSX expression is in JSX attribute + return getTypeOfPropertyOfType(attributesType, node.parent.name.text); + } + else if (node.parent.kind === 249 /* JsxElement */) { + // JSX expression is in children of JSX Element, we will look for an "children" atttribute (we get the name from JSX.ElementAttributesProperty) + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + return jsxChildrenPropertyName && jsxChildrenPropertyName !== "" ? getTypeOfPropertyOfType(attributesType, jsxChildrenPropertyName) : anyType; + } + else { + // JSX expression is in JSX spread attribute + return attributesType; + } + } function getContextualTypeForJsxAttribute(attribute) { // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type // which is a type of the parameter of the signature we are trying out. @@ -35509,48 +37110,54 @@ var ts; } var parent = node.parent; switch (parent.kind) { - case 225 /* VariableDeclaration */: - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 175 /* BindingElement */: + case 226 /* VariableDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 176 /* BindingElement */: return getContextualTypeForInitializerExpression(node); - case 186 /* ArrowFunction */: - case 218 /* ReturnStatement */: + case 187 /* ArrowFunction */: + case 219 /* ReturnStatement */: return getContextualTypeForReturnExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return getContextualTypeForYieldOperand(parent); - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return getContextualTypeForArgument(parent, node); - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: return getTypeFromTypeNode(parent.type); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return getContextualTypeForBinaryOperand(node); - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return getContextualTypeForObjectLiteralElement(parent); - case 176 /* ArrayLiteralExpression */: + case 263 /* SpreadAssignment */: + return getApparentTypeOfContextualType(parent.parent); + case 177 /* ArrayLiteralExpression */: return getContextualTypeForElementExpression(node); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return getContextualTypeForConditionalOperand(node); - case 204 /* TemplateSpan */: - ts.Debug.assert(parent.parent.kind === 195 /* TemplateExpression */); + case 205 /* TemplateSpan */: + ts.Debug.assert(parent.parent.kind === 196 /* TemplateExpression */); return getContextualTypeForSubstitutionExpression(parent.parent, node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return getContextualType(parent); - case 255 /* JsxExpression */: - return getContextualType(parent); - case 252 /* JsxAttribute */: - case 254 /* JsxSpreadAttribute */: + case 256 /* JsxExpression */: + return getContextualTypeForJsxExpression(parent); + case 253 /* JsxAttribute */: + case 255 /* JsxSpreadAttribute */: return getContextualTypeForJsxAttribute(parent); - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: return getAttributesTypeFromJsxOpeningLikeElement(parent); } return undefined; } + function getContextualMapper(node) { + node = ts.findAncestor(node, function (n) { return !!n.contextualMapper; }); + return node ? node.contextualMapper : identityMapper; + } // If the given type is an object or union type, if that type has a single signature, and if // that signature is non-generic, return the signature. Otherwise return undefined. function getNonGenericSignature(type, node) { @@ -35578,7 +37185,7 @@ var ts; return sourceLength < targetParameterCount; } function isFunctionExpressionOrArrowFunction(node) { - return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */; + return node.kind === 186 /* FunctionExpression */ || node.kind === 187 /* ArrowFunction */; } function getContextualSignatureForFunctionLikeDeclaration(node) { // Only function expressions, arrow functions, and object literal methods are contextually typed. @@ -35597,7 +37204,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 !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); var type = getContextualTypeForFunctionLikeDeclaration(node); if (!type) { return undefined; @@ -35607,8 +37214,8 @@ var ts; } var signatureList; var types = type.types; - for (var _i = 0, types_16 = types; _i < types_16.length; _i++) { - var current = types_16[_i]; + for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { + var current = types_17[_i]; var signature = getNonGenericSignature(current, node); if (signature) { if (!signatureList) { @@ -35635,40 +37242,25 @@ var ts; } return result; } - /** - * Detect if the mapper implies an inference context. Specifically, there are 4 possible values - * for a mapper. Let's go through each one of them: - * - * 1. undefined - this means we are not doing inferential typing, but we may do contextual typing, - * which could cause us to assign a parameter a type - * 2. identityMapper - means we want to avoid assigning a parameter a type, whether or not we are in - * inferential typing (context is undefined for the identityMapper) - * 3. a mapper created by createInferenceMapper - we are doing inferential typing, we want to assign - * types to parameters and fix type parameters (context is defined) - * 4. an instantiation mapper created by createTypeMapper or createTypeEraser - this should never be - * passed as the contextual mapper when checking an expression (context is undefined for these) - * - * isInferentialContext is detecting if we are in case 3 - */ - function isInferentialContext(mapper) { - return mapper && mapper.context; - } - function checkSpreadExpression(node, contextualMapper) { - var arrayOrIterableType = checkExpression(node.expression, contextualMapper); - return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false); + function checkSpreadExpression(node, checkMode) { + if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 1536 /* SpreadIncludes */); + } + var arrayOrIterableType = checkExpression(node.expression, checkMode); + return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false, /*allowAsyncIterable*/ false); } function hasDefaultValue(node) { - return (node.kind === 175 /* BindingElement */ && !!node.initializer) || - (node.kind === 193 /* BinaryExpression */ && node.operatorToken.kind === 57 /* EqualsToken */); + return (node.kind === 176 /* BindingElement */ && !!node.initializer) || + (node.kind === 194 /* BinaryExpression */ && node.operatorToken.kind === 58 /* EqualsToken */); } - function checkArrayLiteral(node, contextualMapper) { + function checkArrayLiteral(node, checkMode) { var elements = node.elements; var hasSpreadElement = false; var elementTypes = []; var inDestructuringPattern = ts.isAssignmentTarget(node); for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) { var e = elements_1[_i]; - if (inDestructuringPattern && e.kind === 197 /* SpreadElement */) { + if (inDestructuringPattern && e.kind === 198 /* SpreadElement */) { // Given the following situation: // var c: {}; // [...c] = ["", 0]; @@ -35681,18 +37273,18 @@ var ts; // get the contextual element type from it. So we do something similar to // getContextualTypeForElementExpression, which will crucially not error // if there is no index type / iterated type. - var restArrayType = checkExpression(e.expression, contextualMapper); + var restArrayType = checkExpression(e.expression, checkMode); var restElementType = getIndexTypeOfType(restArrayType, 1 /* Number */) || - (languageVersion >= 2 /* ES2015 */ ? getElementTypeOfIterable(restArrayType, /*errorNode*/ undefined) : undefined); + getIteratedTypeOrElementType(restArrayType, /*errorNode*/ undefined, /*allowStringInput*/ false, /*allowAsyncIterable*/ false, /*checkAssignability*/ false); if (restElementType) { elementTypes.push(restElementType); } } else { - var type = checkExpressionForMutableLocation(e, contextualMapper); + var type = checkExpressionForMutableLocation(e, checkMode); elementTypes.push(type); } - hasSpreadElement = hasSpreadElement || e.kind === 197 /* SpreadElement */; + hasSpreadElement = hasSpreadElement || e.kind === 198 /* SpreadElement */; } if (!hasSpreadElement) { // If array literal is actually a destructuring pattern, mark it as an implied type. We do this such @@ -35707,7 +37299,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 === 174 /* ArrayBindingPattern */ || pattern.kind === 176 /* ArrayLiteralExpression */)) { + if (pattern && (pattern.kind === 175 /* ArrayBindingPattern */ || pattern.kind === 177 /* ArrayLiteralExpression */)) { var patternElements = pattern.elements; for (var i = elementTypes.length; i < patternElements.length; i++) { var patternElement = patternElements[i]; @@ -35715,7 +37307,7 @@ var ts; elementTypes.push(contextualType.typeArguments[i]); } else { - if (patternElement.kind !== 199 /* OmittedExpression */) { + if (patternElement.kind !== 200 /* OmittedExpression */) { error(patternElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value); } elementTypes.push(unknownType); @@ -35732,7 +37324,7 @@ var ts; strictNullChecks ? neverType : undefinedWideningType); } function isNumericName(name) { - return name.kind === 143 /* ComputedPropertyName */ ? isNumericComputedName(name) : isNumericLiteralName(name.text); + return name.kind === 144 /* 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, @@ -35794,7 +37386,7 @@ var ts; var unionType = propTypes.length ? getUnionType(propTypes, /*subtypeReduction*/ true) : undefinedType; return createIndexInfo(unionType, /*isReadonly*/ false); } - function checkObjectLiteral(node, contextualMapper) { + function checkObjectLiteral(node, checkMode) { var inDestructuringPattern = ts.isAssignmentTarget(node); // Grammar checking checkGrammarObjectLiteralExpression(node, inDestructuringPattern); @@ -35804,7 +37396,8 @@ var ts; var propagatedFlags = 0; var contextualType = getApparentTypeOfContextualType(node); var contextualTypeHasPattern = contextualType && contextualType.pattern && - (contextualType.pattern.kind === 173 /* ObjectBindingPattern */ || contextualType.pattern.kind === 177 /* ObjectLiteralExpression */); + (contextualType.pattern.kind === 174 /* ObjectBindingPattern */ || contextualType.pattern.kind === 178 /* ObjectLiteralExpression */); + var isJSObjectLiteral = !contextualType && ts.isInJavaScriptFile(node); var typeFlags = 0; var patternWithComputedProperties = false; var hasComputedStringProperty = false; @@ -35813,27 +37406,27 @@ var ts; for (var i = 0; i < node.properties.length; i++) { var memberDecl = node.properties[i]; var member = memberDecl.symbol; - if (memberDecl.kind === 260 /* PropertyAssignment */ || - memberDecl.kind === 261 /* ShorthandPropertyAssignment */ || + if (memberDecl.kind === 261 /* PropertyAssignment */ || + memberDecl.kind === 262 /* ShorthandPropertyAssignment */ || ts.isObjectLiteralMethod(memberDecl)) { var type = void 0; - if (memberDecl.kind === 260 /* PropertyAssignment */) { - type = checkPropertyAssignment(memberDecl, contextualMapper); + if (memberDecl.kind === 261 /* PropertyAssignment */) { + type = checkPropertyAssignment(memberDecl, checkMode); } - else if (memberDecl.kind === 150 /* MethodDeclaration */) { - type = checkObjectLiteralMethod(memberDecl, contextualMapper); + else if (memberDecl.kind === 151 /* MethodDeclaration */) { + type = checkObjectLiteralMethod(memberDecl, checkMode); } else { - ts.Debug.assert(memberDecl.kind === 261 /* ShorthandPropertyAssignment */); - type = checkExpressionForMutableLocation(memberDecl.name, contextualMapper); + ts.Debug.assert(memberDecl.kind === 262 /* ShorthandPropertyAssignment */); + type = checkExpressionForMutableLocation(memberDecl.name, checkMode); } typeFlags |= type.flags; var prop = createSymbol(4 /* Property */ | member.flags, member.name); 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 === 260 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || - (memberDecl.kind === 261 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); + var isOptional = (memberDecl.kind === 261 /* PropertyAssignment */ && hasDefaultValue(memberDecl.initializer)) || + (memberDecl.kind === 262 /* ShorthandPropertyAssignment */ && memberDecl.objectAssignmentInitializer); if (isOptional) { prop.flags |= 67108864 /* Optional */; } @@ -35861,7 +37454,7 @@ var ts; prop.target = member; member = prop; } - else if (memberDecl.kind === 262 /* SpreadAssignment */) { + else if (memberDecl.kind === 263 /* SpreadAssignment */) { if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(memberDecl, 2 /* Assign */); } @@ -35888,8 +37481,8 @@ 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 === 152 /* GetAccessor */ || memberDecl.kind === 153 /* SetAccessor */); - checkAccessorDeclaration(memberDecl); + ts.Debug.assert(memberDecl.kind === 153 /* GetAccessor */ || memberDecl.kind === 154 /* SetAccessor */); + checkNodeDeferred(memberDecl); } if (ts.hasDynamicName(memberDecl)) { if (isNumericName(memberDecl.name)) { @@ -35931,8 +37524,8 @@ var ts; } return createObjectLiteralType(); function createObjectLiteralType() { - var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; - var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; + var stringIndexInfo = isJSObjectLiteral ? jsObjectLiteralIndexInfo : hasComputedStringProperty ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 0 /* String */) : undefined; + var numberIndexInfo = hasComputedNumberProperty && !isJSObjectLiteral ? getObjectLiteralIndexInfo(node.properties, offset, propertiesArray, 1 /* Number */) : undefined; var result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, stringIndexInfo, numberIndexInfo); var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 1048576 /* FreshLiteral */; result.flags |= 4194304 /* ContainsObjectLiteral */ | freshObjectLiteralFlag | (typeFlags & 14680064 /* PropagatingFlags */); @@ -35956,7 +37549,7 @@ var ts; } function checkJsxSelfClosingElement(node) { checkJsxOpeningLikeElement(node); - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } function checkJsxElement(node) { // Check attributes @@ -35968,22 +37561,7 @@ var ts; else { checkExpression(node.closingElement.tagName); } - // Check children - for (var _i = 0, _a = node.children; _i < _a.length; _i++) { - var child = _a[_i]; - switch (child.kind) { - case 255 /* JsxExpression */: - checkJsxExpression(child); - break; - case 248 /* JsxElement */: - checkJsxElement(child); - break; - case 249 /* JsxSelfClosingElement */: - checkJsxSelfClosingElement(child); - break; - } - } - return jsxElementType || anyType; + return getJsxGlobalElementType() || anyType; } /** * Returns true iff the JSX element name would be a valid JS identifier, ignoring restrictions about keywords not being identifiers @@ -35997,7 +37575,7 @@ var ts; */ function isJsxIntrinsicIdentifier(tagName) { // TODO (yuisu): comment - if (tagName.kind === 178 /* PropertyAccessExpression */ || tagName.kind === 98 /* ThisKeyword */) { + if (tagName.kind === 179 /* PropertyAccessExpression */ || tagName.kind === 99 /* ThisKeyword */) { return false; } else { @@ -36010,8 +37588,10 @@ var ts; * @param openingLikeElement a JSX opening-like element * @param filter a function to remove attributes that will not participate in checking whether attributes are assignable * @return an anonymous type (similar to the one returned by checkObjectLiteral) in which its properties are attributes property. + * @remarks Because this function calls getSpreadType, it needs to use the same checks as checkObjectLiteral, + * which also calls getSpreadType. */ - function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, contextualMapper) { + function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, filter, checkMode) { var attributes = openingLikeElement.attributes; var attributesTable = ts.createMap(); var spread = emptyObjectType; @@ -36021,8 +37601,8 @@ var ts; var member = attributeDecl.symbol; if (ts.isJsxAttribute(attributeDecl)) { var exprType = attributeDecl.initializer ? - checkExpression(attributeDecl.initializer, contextualMapper) : - trueType; // is sugar for + checkExpression(attributeDecl.initializer, checkMode) : + trueType; // is sugar for var attributeSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */ | member.flags, member.name); attributeSymbol.declarations = member.declarations; attributeSymbol.parent = member.parent; @@ -36035,14 +37615,14 @@ var ts; attributesArray.push(attributeSymbol); } else { - ts.Debug.assert(attributeDecl.kind === 254 /* JsxSpreadAttribute */); + ts.Debug.assert(attributeDecl.kind === 255 /* JsxSpreadAttribute */); if (attributesArray.length > 0) { spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); attributesArray = []; attributesTable = ts.createMap(); } var exprType = checkExpression(attributeDecl.expression); - if (!(exprType.flags & (32768 /* Object */ | 1 /* Any */))) { + if (!isValidSpreadType(exprType)) { error(attributeDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types); return anyType; } @@ -36068,6 +37648,39 @@ var ts; } }); } + // Handle children attribute + var parent = openingLikeElement.parent.kind === 249 /* JsxElement */ ? openingLikeElement.parent : undefined; + // We have to check that openingElement of the parent is the one we are visiting as this may not be true for selfClosingElement + if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) { + var childrenTypes = []; + for (var _b = 0, _c = parent.children; _b < _c.length; _b++) { + var child = _c[_b]; + // In React, JSX text that contains only whitespaces will be ignored so we don't want to type-check that + // because then type of children property will have constituent of string type. + if (child.kind === 10 /* JsxText */) { + if (!child.containsOnlyWhiteSpaces) { + childrenTypes.push(stringType); + } + } + else { + childrenTypes.push(checkExpression(child, checkMode)); + } + } + // Error if there is a attribute named "children" and children element. + // This is because children element will overwrite the value from attributes + var jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { + if (attributesTable.has(jsxChildrenPropertyName)) { + error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); + } + // If there are children in the body of JSX element, create dummy attribute "children" with anyType so that it will pass the attribute checking process + var childrenPropSymbol = createSymbol(4 /* Property */ | 134217728 /* Transient */, jsxChildrenPropertyName); + childrenPropSymbol.type = childrenTypes.length === 1 ? + childrenTypes[0] : + createArrayType(getUnionType(childrenTypes, /*subtypeReduction*/ false)); + attributesTable.set(jsxChildrenPropertyName, childrenPropSymbol); + } + } return createJsxAttributesType(attributes.symbol, attributesTable); /** * Create anonymous type from given attributes symbol table. @@ -36087,8 +37700,8 @@ var ts; * (See "checkApplicableSignatureForJsxOpeningLikeElement" for how the function is used) * @param node a JSXAttributes to be resolved of its type */ - function checkJsxAttributes(node, contextualMapper) { - return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, contextualMapper); + function checkJsxAttributes(node, checkMode) { + return createJsxAttributesTypeFromAttributesProperty(node.parent, /*filter*/ undefined, checkMode); } function getJsxType(name) { var jsxType = jsxTypes.get(name); @@ -36098,11 +37711,11 @@ var ts; return jsxType; } /** - * 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. - */ + * 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) { @@ -36125,7 +37738,7 @@ var ts; return links.resolvedSymbol = unknownSymbol; } else { - if (compilerOptions.noImplicitAny) { + if (noImplicitAny) { error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, JsxNames.IntrinsicElements); } return links.resolvedSymbol = unknownSymbol; @@ -36157,37 +37770,55 @@ var ts; } return getUnionType(ts.map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } + /** + * Look into JSX namespace and then look for container with matching name as nameOfAttribPropContainer. + * Get a single property from that container if existed. Report an error if there are more than one property. + * + * @param nameOfAttribPropContainer a string of value JsxNames.ElementAttributesPropertyNameContainer or JsxNames.ElementChildrenAttributeNameContainer + * if other string is given or the container doesn't exist, return undefined. + */ + function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer) { + // JSX + var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); + // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [symbol] + var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 793064 /* Type */); + // JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute [type] + var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym); + // The properties of JSX.ElementAttributesProperty | JSX.ElementChildrenAttribute + var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType); + if (propertiesOfJsxElementAttribPropInterface) { + // Element Attributes has zero properties, so the element attributes type will be the class instance type + if (propertiesOfJsxElementAttribPropInterface.length === 0) { + return ""; + } + else if (propertiesOfJsxElementAttribPropInterface.length === 1) { + return propertiesOfJsxElementAttribPropInterface[0].name; + } + else if (propertiesOfJsxElementAttribPropInterface.length > 1) { + // More than one property on ElementAttributesProperty is an error + error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, nameOfAttribPropContainer); + } + } + return undefined; + } /// e.g. "props" for React.d.ts, /// 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-intrinsic elements' attributes type is the element instance type) function getJsxElementPropertiesName() { - // JSX - var jsxNamespace = getGlobalSymbol(JsxNames.JSX, 1920 /* Namespace */, /*diagnosticMessage*/ undefined); - // JSX.ElementAttributesProperty [symbol] - var attribsPropTypeSym = jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.ElementAttributesPropertyNameContainer, 793064 /* Type */); - // JSX.ElementAttributesProperty [type] - var attribPropType = attribsPropTypeSym && getDeclaredTypeOfSymbol(attribsPropTypeSym); - // 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 - if (attribProperties.length === 0) { - return ""; - } - else if (attribProperties.length === 1) { - return attribProperties[0].name; - } - else { - error(attribsPropTypeSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, JsxNames.ElementAttributesPropertyNameContainer); - return undefined; - } + if (!_hasComputedJsxElementPropertiesName) { + _hasComputedJsxElementPropertiesName = true; + _jsxElementPropertiesName = getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer); } - else { - // No interface exists, so the element attributes type will be an implicit any - return undefined; + return _jsxElementPropertiesName; + } + function getJsxElementChildrenPropertyname() { + if (!_hasComputedJsxElementChildrenPropertyName) { + _hasComputedJsxElementChildrenPropertyName = true; + _jsxElementChildrenPropertyName = getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer); } + return _jsxElementChildrenPropertyName; } /** * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. @@ -36202,13 +37833,14 @@ var ts; function defaultTryGetJsxStatelessFunctionAttributesType(openingLikeElement, elementType, elemInstanceType, elementClassType) { ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature here because we have already resolve the type of JSX Element. var callSignature = getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, /*candidatesOutArray*/ undefined); if (callSignature !== unknownSignature) { var callReturnType = callSignature && getReturnTypeOfSignature(callSignature); var paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); if (intrinsicAttributes !== unknownType) { @@ -36235,7 +37867,8 @@ var ts; ts.Debug.assert(!(elementType.flags & 65536 /* Union */)); if (!elementClassType || !isTypeAssignableTo(elemInstanceType, elementClassType)) { // Is this is a stateless function component? See if its single signature's return type is assignable to the JSX Element Type - if (jsxElementType) { + var jsxStatelessElementType = getJsxGlobalStatelessElementType(); + if (jsxStatelessElementType) { // We don't call getResolvedSignature because here we have already resolve the type of JSX Element. var candidatesOutArray = []; getResolvedJsxStatelessFunctionSignature(openingLikeElement, elementType, candidatesOutArray); @@ -36245,7 +37878,7 @@ var ts; var candidate = candidatesOutArray_1[_i]; var callReturnType = getReturnTypeOfSignature(candidate); var paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); - if (callReturnType && isTypeAssignableTo(callReturnType, jsxElementType)) { + if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { var shouldBeCandidate = true; for (var _a = 0, _b = openingLikeElement.attributes.properties; _a < _b.length; _a++) { var attribute = _b[_a]; @@ -36292,7 +37925,7 @@ var ts; * @return attributes type if able to resolve the type of node * anyType if there is no type ElementAttributesProperty or there is an error * emptyObjectType if there is no "prop" in the element instance type - **/ + */ function resolveCustomJsxElementAttributesType(openingLikeElement, shouldIncludeAllStatelessAttributesType, elementType, elementClassType) { if (!elementType) { elementType = checkExpression(openingLikeElement.tagName); @@ -36311,7 +37944,7 @@ var ts; // If the elemType is a stringLiteral type, we can then provide a check to make sure that the string literal type is one of the Jsx intrinsic element type // For example: // var CustomTag: "h1" = "h1"; - // Hello World + // Hello World var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements); if (intrinsicElementsType !== unknownType) { var stringLiteralTypeName = elementType.text; @@ -36364,11 +37997,6 @@ var ts; // Props is of type 'any' or unknown return attributesType; } - else if (attributesType.flags & 65536 /* Union */) { - // Props cannot be a union type - error(openingLikeElement.tagName, ts.Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType)); - return anyType; - } else { // Normal case -- add in IntrinsicClassElements and IntrinsicElements var apparentAttributesType = attributesType; @@ -36424,7 +38052,7 @@ var ts; var links = getNodeLinks(node); if (!links.resolvedJsxElementAttributesType) { var elemClassType = getJsxGlobalElementClassType(); - return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, undefined, elemClassType); + return links.resolvedJsxElementAttributesType = resolveCustomJsxElementAttributesType(node, shouldIncludeAllStatelessAttributesType, /*elementType*/ undefined, elemClassType); } return links.resolvedJsxElementAttributesType; } @@ -36467,10 +38095,25 @@ var ts; return prop || unknownSymbol; } function getJsxGlobalElementClassType() { - if (!jsxElementClassType) { - jsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); + if (!deferredJsxElementClassType) { + deferredJsxElementClassType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.ElementClass); } - return jsxElementClassType; + return deferredJsxElementClassType; + } + function getJsxGlobalElementType() { + if (!deferredJsxElementType) { + deferredJsxElementType = getExportedTypeFromNamespace(JsxNames.JSX, JsxNames.Element); + } + return deferredJsxElementType; + } + function getJsxGlobalStatelessElementType() { + if (!deferredJsxStatelessElementType) { + var jsxElementType = getJsxGlobalElementType(); + if (jsxElementType) { + deferredJsxStatelessElementType = getUnionType([jsxElementType, nullType]); + } + } + return deferredJsxStatelessElementType; } /** * Returns all the properties of the Jsx.IntrinsicElements interface @@ -36484,8 +38127,8 @@ var ts; if ((compilerOptions.jsx || 0 /* None */) === 0 /* None */) { error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided); } - if (jsxElementType === undefined) { - if (compilerOptions.noImplicitAny) { + if (getJsxGlobalElementType() === undefined) { + if (noImplicitAny) { error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist); } } @@ -36510,11 +38153,11 @@ var ts; checkJsxAttributesAssignableToTagNameAttributes(node); } /** - * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. - * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" - * Check assignablity between given attributes property, "source attributes", and the "target attributes" - * @param openingLikeElement an opening-like JSX element to check its JSXAttributes - */ + * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. + * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" + * Check assignablity between given attributes property, "source attributes", and the "target attributes" + * @param openingLikeElement an opening-like JSX element to check its JSXAttributes + */ function checkJsxAttributesAssignableToTagNameAttributes(openingLikeElement) { // The function involves following steps: // 1. Figure out expected attributes type by resolving tagName of the JSX opening-like element, targetAttributesType. @@ -36540,9 +38183,9 @@ var ts; checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); } } - function checkJsxExpression(node, contextualMapper) { + function checkJsxExpression(node, checkMode) { if (node.expression) { - var type = checkExpression(node.expression, contextualMapper); + var type = checkExpression(node.expression, checkMode); if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) { error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type, node.toString(), typeToString(type)); } @@ -36555,19 +38198,19 @@ 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 : 148 /* PropertyDeclaration */; + return s.valueDeclaration ? s.valueDeclaration.kind : 149 /* PropertyDeclaration */; } function getDeclarationModifierFlagsFromSymbol(s) { if (s.valueDeclaration) { var flags = ts.getCombinedModifierFlags(s.valueDeclaration); return s.parent && s.parent.flags & 32 /* Class */ ? flags : flags & ~28 /* AccessibilityModifier */; } - if (getCheckFlags(s) & 2 /* SyntheticProperty */) { + if (getCheckFlags(s) & 6 /* Synthetic */) { var checkFlags = s.checkFlags; - var accessModifier = checkFlags & 128 /* ContainsPrivate */ ? 8 /* Private */ : - checkFlags & 32 /* ContainsPublic */ ? 4 /* Public */ : + var accessModifier = checkFlags & 256 /* ContainsPrivate */ ? 8 /* Private */ : + checkFlags & 64 /* ContainsPublic */ ? 4 /* Public */ : 16 /* Protected */; - var staticModifier = checkFlags & 256 /* ContainsStatic */ ? 32 /* Static */ : 0; + var staticModifier = checkFlags & 512 /* ContainsStatic */ ? 32 /* Static */ : 0; return accessModifier | staticModifier; } if (s.flags & 16777216 /* Prototype */) { @@ -36578,6 +38221,9 @@ var ts; function getDeclarationNodeFlagsFromSymbol(s) { return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0; } + function isMethodLike(symbol) { + return !!(symbol.flags & 8192 /* Method */ || getCheckFlags(symbol) & 4 /* SyntheticMethod */); + } /** * Check whether the requested property access is valid. * Returns true if node is a valid property access, and false otherwise. @@ -36588,15 +38234,15 @@ var ts; */ function checkPropertyAccessibility(node, left, type, prop) { var flags = getDeclarationModifierFlagsFromSymbol(prop); - var errorNode = node.kind === 178 /* PropertyAccessExpression */ || node.kind === 225 /* VariableDeclaration */ ? + var errorNode = node.kind === 179 /* PropertyAccessExpression */ || node.kind === 226 /* VariableDeclaration */ ? node.name : node.right; - if (getCheckFlags(prop) & 128 /* ContainsPrivate */) { + if (getCheckFlags(prop) & 256 /* ContainsPrivate */) { // Synthetic property with private constituent property error(errorNode, ts.Diagnostics.Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1, symbolToString(prop), typeToString(type)); return false; } - if (left.kind === 96 /* SuperKeyword */) { + if (left.kind === 97 /* SuperKeyword */) { // TS 1.0 spec (April 2014): 4.8.2 // - In a constructor, instance member function, instance member accessor, or // instance member variable initializer where this references a derived class instance, @@ -36605,10 +38251,11 @@ var ts; // 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 /* ES2015 */) { - var propKind = getDeclarationKindFromSymbol(prop); - if (propKind !== 150 /* MethodDeclaration */ && propKind !== 149 /* MethodSignature */) { - // `prop` refers to a *property* declared in the super class - // rather than a *method*, so it does not satisfy the above criteria. + var hasNonMethodDeclaration = forEachProperty(prop, function (p) { + var propKind = getDeclarationKindFromSymbol(p); + return propKind !== 151 /* MethodDeclaration */ && propKind !== 150 /* MethodSignature */; + }); + if (hasNonMethodDeclaration) { error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword); return false; } @@ -36638,7 +38285,7 @@ var ts; } // Property is known to be protected at this point // All protected properties of a supertype are accessible in a super access - if (left.kind === 96 /* SuperKeyword */) { + if (left.kind === 97 /* SuperKeyword */) { return true; } // Find the first enclosing class that has the declaring classes of the protected constituents @@ -36717,7 +38364,7 @@ var ts; } function isInPropertyInitializer(node) { while (node) { - if (node.parent && node.parent.kind === 148 /* PropertyDeclaration */ && node.parent.initializer === node) { + if (node.parent && node.parent.kind === 149 /* PropertyDeclaration */ && node.parent.initializer === node) { return true; } node = node.parent; @@ -36745,10 +38392,17 @@ var ts; } return unknownType; } - if (prop.valueDeclaration && - isInPropertyInitializer(node) && - !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { - error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + if (prop.valueDeclaration) { + if (isInPropertyInitializer(node) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, right.text); + } + if (prop.valueDeclaration.kind === 229 /* ClassDeclaration */ && + node.parent && node.parent.kind !== 159 /* TypeReference */ && + !ts.isInAmbientContext(prop.valueDeclaration) && + !isBlockScopedNameDeclaredBeforeUse(prop.valueDeclaration, right)) { + error(right, ts.Diagnostics.Class_0_used_before_its_declaration, right.text); + } } markPropertyAsReferenced(prop); getNodeLinks(node).resolvedSymbol = prop; @@ -36764,16 +38418,16 @@ var ts; // Only compute control flow type if this is a property access expression that isn't an // assignment target, and the referenced property was declared as a variable, property, // accessor, or optional method. - if (node.kind !== 178 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || + if (node.kind !== 179 /* PropertyAccessExpression */ || assignmentKind === 1 /* Definite */ || !(prop.flags & (3 /* Variable */ | 4 /* Property */ | 98304 /* Accessor */)) && !(prop.flags & 8192 /* Method */ && propType.flags & 65536 /* Union */)) { return propType; } - var flowType = getFlowTypeOfReference(node, propType, /*assumeInitialized*/ true, /*flowContainer*/ undefined); + var flowType = getFlowTypeOfReference(node, propType); return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } function isValidPropertyAccess(node, propertyName) { - var left = node.kind === 178 /* PropertyAccessExpression */ + var left = node.kind === 179 /* PropertyAccessExpression */ ? node.expression : node.left; var type = checkExpression(left); @@ -36790,13 +38444,13 @@ var ts; */ function getForInVariableSymbol(node) { var initializer = node.initializer; - if (initializer.kind === 226 /* VariableDeclarationList */) { + if (initializer.kind === 227 /* VariableDeclarationList */) { var variable = initializer.declarations[0]; if (variable && !ts.isBindingPattern(variable.name)) { return getSymbolOfNode(variable); } } - else if (initializer.kind === 70 /* Identifier */) { + else if (initializer.kind === 71 /* Identifier */) { return getResolvedSymbol(initializer); } return undefined; @@ -36813,13 +38467,13 @@ var ts; */ function isForInVariableForNumericPropertyNames(expr) { var e = ts.skipParentheses(expr); - if (e.kind === 70 /* Identifier */) { + if (e.kind === 71 /* Identifier */) { var symbol = getResolvedSymbol(e); if (symbol.flags & 3 /* Variable */) { var child = expr; var node = expr.parent; while (node) { - if (node.kind === 214 /* ForInStatement */ && + if (node.kind === 215 /* ForInStatement */ && child === node.statement && getForInVariableSymbol(node) === symbol && hasNumericPropertyNames(getTypeOfExpression(node.expression))) { @@ -36837,7 +38491,7 @@ var ts; var indexExpression = node.argumentExpression; if (!indexExpression) { var sourceFile = ts.getSourceFileOfNode(node); - if (node.parent.kind === 181 /* NewExpression */ && node.parent.expression === node) { + if (node.parent.kind === 182 /* 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); @@ -36881,7 +38535,7 @@ var ts; if (!leftHandSideSymbol) { return false; } - var globalESSymbol = getGlobalESSymbolConstructorSymbol(); + var globalESSymbol = getGlobalESSymbolConstructorSymbol(/*reportErrors*/ true); if (!globalESSymbol) { // Already errored when we tried to look up the symbol return false; @@ -36895,10 +38549,10 @@ var ts; return true; } function resolveUntypedCall(node) { - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* TaggedTemplateExpression */) { checkExpression(node.template); } - else if (node.kind !== 146 /* Decorator */) { + else if (node.kind !== 147 /* Decorator */) { ts.forEach(node.arguments, function (argument) { checkExpression(argument); }); @@ -36925,8 +38579,8 @@ var ts; var specializedIndex = -1; var spliceIndex; ts.Debug.assert(!result.length); - for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) { - var signature = signatures_2[_i]; + for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) { + var signature = signatures_3[_i]; var symbol = signature.declaration && getSymbolOfNode(signature.declaration); var parent = signature.declaration && signature.declaration.parent; if (!lastSymbol || symbol === lastSymbol) { @@ -36964,7 +38618,7 @@ var ts; function getSpreadArgumentIndex(args) { for (var i = 0; i < args.length; i++) { var arg = args[i]; - if (arg && arg.kind === 197 /* SpreadElement */) { + if (arg && arg.kind === 198 /* SpreadElement */) { return i; } } @@ -36981,13 +38635,13 @@ var ts; // The arity check will be done in "checkApplicableSignatureForJsxOpeningLikeElement". return true; } - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* 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 argCount = args.length; typeArguments = undefined; - if (tagExpression.template.kind === 195 /* TemplateExpression */) { + if (tagExpression.template.kind === 196 /* 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; @@ -37000,11 +38654,11 @@ var ts; // then this might actually turn out to be a TemplateHead in the future; // so we consider the call to be incomplete. var templateLiteral = tagExpression.template; - ts.Debug.assert(templateLiteral.kind === 12 /* NoSubstitutionTemplateLiteral */); + ts.Debug.assert(templateLiteral.kind === 13 /* NoSubstitutionTemplateLiteral */); callIsIncomplete = !!templateLiteral.isUnterminated; } } - else if (node.kind === 146 /* Decorator */) { + else if (node.kind === 147 /* Decorator */) { isDecorator = true; typeArguments = undefined; argCount = getEffectiveArgumentCount(node, /*args*/ undefined, signature); @@ -37013,7 +38667,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 === 181 /* NewExpression */); + ts.Debug.assert(callExpression.kind === 182 /* NewExpression */); return signature.minArgumentCount === 0; } argCount = signatureHelpTrailingComma ? args.length + 1 : args.length; @@ -37057,7 +38711,7 @@ var ts; } // Instantiate a generic signature in the context of a non-generic signature (section 3.8.5 in TypeScript spec) function instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper) { - var context = createInferenceContext(signature, /*inferUnionTypes*/ true); + var context = createInferenceContext(signature, /*inferUnionTypes*/ true, /*useAnyForNoInferences*/ false); forEachMatchingParameterType(contextualSignature, signature, function (source, target) { // Type parameters from outer context referenced by source type are fixed by instantiation of the source type inferTypesWithContext(context, instantiateType(source, contextualMapper), target); @@ -37099,7 +38753,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 !== 199 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 200 /* OmittedExpression */) { var paramType = getTypeAtPosition(signature, i); var argType = getEffectiveArgumentType(node, i); // If the effective argument type is 'undefined', there is no synthetic type @@ -37163,7 +38817,7 @@ var ts; */ function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation) { // JSX opening-like element has correct arity for stateless-function component if the one of the following condition is true: - // 1. callIsIncomplete + // 1. callIsIncomplete // 2. attributes property has same number of properties as the parameter object type. // We can figure that out by resolving attributes property and check number of properties in the resolved type // If the call has correct arity, we will then check if the argument type and parameter type is assignable @@ -37191,7 +38845,7 @@ var ts; return checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation); } var thisType = getThisTypeOfSignature(signature); - if (thisType && thisType !== voidType && node.kind !== 181 /* NewExpression */) { + if (thisType && thisType !== voidType && node.kind !== 182 /* NewExpression */) { // If the called expression is not of the form `x.f` or `x["f"]`, then sourceType = voidType // If the signature's 'this' type is voidType, then the check is skipped -- anything is compatible. // If the expression is a new expression, then the check is skipped. @@ -37208,7 +38862,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 !== 199 /* OmittedExpression */) { + if (arg === undefined || arg.kind !== 200 /* 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); @@ -37230,12 +38884,12 @@ var ts; * Returns the this argument in calls like x.f(...) and x[f](...). Undefined otherwise. */ function getThisArgumentOfCall(node) { - if (node.kind === 180 /* CallExpression */) { + if (node.kind === 181 /* CallExpression */) { var callee = node.expression; - if (callee.kind === 178 /* PropertyAccessExpression */) { + if (callee.kind === 179 /* PropertyAccessExpression */) { return callee.expression; } - else if (callee.kind === 179 /* ElementAccessExpression */) { + else if (callee.kind === 180 /* ElementAccessExpression */) { return callee.expression; } } @@ -37251,16 +38905,16 @@ var ts; */ function getEffectiveCallArguments(node) { var args; - if (node.kind === 182 /* TaggedTemplateExpression */) { + if (node.kind === 183 /* TaggedTemplateExpression */) { var template = node.template; args = [undefined]; - if (template.kind === 195 /* TemplateExpression */) { + if (template.kind === 196 /* TemplateExpression */) { ts.forEach(template.templateSpans, function (span) { args.push(span.expression); }); } } - else if (node.kind === 146 /* Decorator */) { + else if (node.kind === 147 /* 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. @@ -37275,32 +38929,32 @@ var ts; return args; } /** - * Returns the effective argument count for a node that works like a function invocation. - * If 'node' is a Decorator, the number of arguments is derived from the decoration - * target and the signature: - * If 'node.target' is a class declaration or class expression, the effective argument - * count is 1. - * If 'node.target' is a parameter declaration, the effective argument count is 3. - * If 'node.target' is a property declaration, the effective argument count is 2. - * If 'node.target' is a method or accessor declaration, the effective argument count - * is 3, although it can be 2 if the signature only accepts two arguments, allowing - * us to match a property decorator. - * Otherwise, the argument count is the length of the 'args' array. - */ + * Returns the effective argument count for a node that works like a function invocation. + * If 'node' is a Decorator, the number of arguments is derived from the decoration + * target and the signature: + * If 'node.target' is a class declaration or class expression, the effective argument + * count is 1. + * If 'node.target' is a parameter declaration, the effective argument count is 3. + * If 'node.target' is a property declaration, the effective argument count is 2. + * If 'node.target' is a method or accessor declaration, the effective argument count + * is 3, although it can be 2 if the signature only accepts two arguments, allowing + * us to match a property decorator. + * Otherwise, the argument count is the length of the 'args' array. + */ function getEffectiveArgumentCount(node, args, signature) { - if (node.kind === 146 /* Decorator */) { + if (node.kind === 147 /* Decorator */) { switch (node.parent.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: // A class decorator will have one argument (see `ClassDecorator` in core.d.ts) return 1; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // A property declaration decorator will have two arguments (see // `PropertyDecorator` in core.d.ts) return 2; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* 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. @@ -37310,7 +38964,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 145 /* Parameter */: + case 146 /* Parameter */: // A parameter declaration decorator will have three arguments (see // `ParameterDecorator` in core.d.ts) return 3; @@ -37321,38 +38975,38 @@ var ts; } } /** - * Returns the effective type of the first argument to a decorator. - * If 'node' is a class declaration or class expression, the effective argument type - * is the type of the static side of the class. - * If 'node' is a parameter declaration, the effective argument type is either the type - * of the static or instance side of the class for the parameter's parent method, - * depending on whether the method is declared static. - * For a constructor, the type is always the type of the static side of the class. - * If 'node' is a property, method, or accessor declaration, the effective argument - * type is the type of the static or instance side of the parent class for class - * element, depending on whether the element is declared static. - */ + * Returns the effective type of the first argument to a decorator. + * If 'node' is a class declaration or class expression, the effective argument type + * is the type of the static side of the class. + * If 'node' is a parameter declaration, the effective argument type is either the type + * of the static or instance side of the class for the parameter's parent method, + * depending on whether the method is declared static. + * For a constructor, the type is always the type of the static side of the class. + * If 'node' is a property, method, or accessor declaration, the effective argument + * type is the type of the static or instance side of the parent class for class + * element, depending on whether the element is declared static. + */ function getEffectiveDecoratorFirstArgumentType(node) { // The first argument to a decorator is its `target`. - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* 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 === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { // For a parameter decorator, the `target` is the parent type of the // parameter's containing method. node = node.parent; - if (node.kind === 151 /* Constructor */) { + if (node.kind === 152 /* Constructor */) { var classSymbol = getSymbolOfNode(node); return getTypeOfSymbol(classSymbol); } } - if (node.kind === 148 /* PropertyDeclaration */ || - node.kind === 150 /* MethodDeclaration */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 149 /* PropertyDeclaration */ || + node.kind === 151 /* MethodDeclaration */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* 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 @@ -37363,50 +39017,50 @@ var ts; return unknownType; } /** - * Returns the effective type for the second argument to a decorator. - * If 'node' is a parameter, its effective argument type is one of the following: - * If 'node.parent' is a constructor, the effective argument type is 'any', as we - * will emit `undefined`. - * If 'node.parent' is a member with an identifier, numeric, or string literal name, - * the effective argument type will be a string literal type for the member name. - * If 'node.parent' is a computed property name, the effective argument type will - * either be a symbol type or the string type. - * If 'node' is a member with an identifier, numeric, or string literal name, the - * effective argument type will be a string literal type for the member name. - * If 'node' is a computed property name, the effective argument type will either - * be a symbol type or the string type. - * A class decorator does not have a second argument type. - */ + * Returns the effective type for the second argument to a decorator. + * If 'node' is a parameter, its effective argument type is one of the following: + * If 'node.parent' is a constructor, the effective argument type is 'any', as we + * will emit `undefined`. + * If 'node.parent' is a member with an identifier, numeric, or string literal name, + * the effective argument type will be a string literal type for the member name. + * If 'node.parent' is a computed property name, the effective argument type will + * either be a symbol type or the string type. + * If 'node' is a member with an identifier, numeric, or string literal name, the + * effective argument type will be a string literal type for the member name. + * If 'node' is a computed property name, the effective argument type will either + * be a symbol type or the string type. + * A class decorator does not have a second argument type. + */ function getEffectiveDecoratorSecondArgumentType(node) { // The second argument to a decorator is its `propertyKey` - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a second synthetic argument."); return unknownType; } - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { node = node.parent; - if (node.kind === 151 /* Constructor */) { + if (node.kind === 152 /* Constructor */) { // For a constructor parameter decorator, the `propertyKey` will be `undefined`. return anyType; } // For a non-constructor parameter decorator, the `propertyKey` will be either // a string or a symbol, based on the name of the parameter's containing method. } - if (node.kind === 148 /* PropertyDeclaration */ || - node.kind === 150 /* MethodDeclaration */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 149 /* PropertyDeclaration */ || + node.kind === 151 /* MethodDeclaration */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* SetAccessor */) { // The `propertyKey` for a property or method decorator will be a // string literal type if the member name is an identifier, number, or string; // otherwise, if the member name is a computed property name it will // be either string or symbol. var element = node; switch (element.name.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: case 8 /* NumericLiteral */: case 9 /* StringLiteral */: return getLiteralTypeForText(32 /* StringLiteral */, element.name.text); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: var nameType = checkComputedPropertyName(element.name); if (isTypeOfKind(nameType, 512 /* ESSymbol */)) { return nameType; @@ -37423,30 +39077,30 @@ var ts; return unknownType; } /** - * Returns the effective argument type for the third argument to a decorator. - * If 'node' is a parameter, the effective argument type is the number type. - * If 'node' is a method or accessor, the effective argument type is a - * `TypedPropertyDescriptor` instantiated with the type of the member. - * Class and property decorators do not have a third effective argument. - */ + * Returns the effective argument type for the third argument to a decorator. + * If 'node' is a parameter, the effective argument type is the number type. + * If 'node' is a method or accessor, the effective argument type is a + * `TypedPropertyDescriptor` instantiated with the type of the member. + * Class and property decorators do not have a third effective argument. + */ function getEffectiveDecoratorThirdArgumentType(node) { // The third argument to a decorator is either its `descriptor` for a method decorator // or its `parameterIndex` for a parameter decorator - if (node.kind === 228 /* ClassDeclaration */) { + if (node.kind === 229 /* ClassDeclaration */) { ts.Debug.fail("Class decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { // The `parameterIndex` for a parameter decorator is always a number return numberType; } - if (node.kind === 148 /* PropertyDeclaration */) { + if (node.kind === 149 /* PropertyDeclaration */) { ts.Debug.fail("Property decorators should not have a third synthetic argument."); return unknownType; } - if (node.kind === 150 /* MethodDeclaration */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 151 /* MethodDeclaration */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* SetAccessor */) { // The `descriptor` for a method decorator will be a `TypedPropertyDescriptor` // for the type of the member. var propertyType = getTypeOfNode(node); @@ -37456,8 +39110,8 @@ var ts; return unknownType; } /** - * Returns the effective argument type for the provided argument to a decorator. - */ + * Returns the effective argument type for the provided argument to a decorator. + */ function getEffectiveDecoratorArgumentType(node, argIndex) { if (argIndex === 0) { return getEffectiveDecoratorFirstArgumentType(node.parent); @@ -37472,16 +39126,16 @@ var ts; return unknownType; } /** - * Gets the effective argument type for an argument in a call expression. - */ + * Gets the effective argument type for an argument in a call expression. + */ function getEffectiveArgumentType(node, argIndex) { // 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 === 146 /* Decorator */) { + if (node.kind === 147 /* Decorator */) { return getEffectiveDecoratorArgumentType(node, argIndex); } - else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 183 /* TaggedTemplateExpression */) { return getGlobalTemplateStringsArrayType(); } // This is not a synthetic argument, so we return 'undefined' @@ -37489,25 +39143,25 @@ var ts; return undefined; } /** - * Gets the effective argument expression for an argument in a call expression. - */ + * Gets the effective argument expression for an argument in a call expression. + */ function getEffectiveArgument(node, args, argIndex) { // For a decorator or the first argument of a tagged template expression we return undefined. - if (node.kind === 146 /* Decorator */ || - (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */)) { + if (node.kind === 147 /* Decorator */ || + (argIndex === 0 && node.kind === 183 /* TaggedTemplateExpression */)) { return undefined; } return args[argIndex]; } /** - * Gets the error node to use when reporting errors for an effective argument. - */ + * Gets the error node to use when reporting errors for an effective argument. + */ function getEffectiveArgumentErrorNode(node, argIndex, arg) { - if (node.kind === 146 /* Decorator */) { + if (node.kind === 147 /* Decorator */) { // For a decorator, we use the expression of the decorator for error reporting. return node.expression; } - else if (argIndex === 0 && node.kind === 182 /* TaggedTemplateExpression */) { + else if (argIndex === 0 && node.kind === 183 /* TaggedTemplateExpression */) { // For a the first argument of a tagged template expression, we use the template of the tag for error reporting. return node.template; } @@ -37516,17 +39170,31 @@ var ts; } } function resolveCall(node, signatures, candidatesOutArray, headMessage) { - var isTaggedTemplate = node.kind === 182 /* TaggedTemplateExpression */; - var isDecorator = node.kind === 146 /* Decorator */; + var isTaggedTemplate = node.kind === 183 /* TaggedTemplateExpression */; + var isDecorator = node.kind === 147 /* Decorator */; var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node); var typeArguments; if (!isTaggedTemplate && !isDecorator && !isJsxOpeningOrSelfClosingElement) { typeArguments = node.typeArguments; // We already perform checking on the type arguments on the class declaration itself. - if (node.expression.kind !== 96 /* SuperKeyword */) { + if (node.expression.kind !== 97 /* SuperKeyword */) { ts.forEach(typeArguments, checkSourceElement); } } + if (signatures.length === 1) { + var declaration = signatures[0].declaration; + if (declaration && ts.isInJavaScriptFile(declaration) && !ts.hasJSDocParameterTags(declaration)) { + if (containsArgumentsReference(declaration)) { + var signatureWithRest = cloneSignature(signatures[0]); + var syntheticArgsSymbol = createSymbol(3 /* Variable */, "args"); + syntheticArgsSymbol.type = anyArrayType; + syntheticArgsSymbol.isRestParameter = true; + signatureWithRest.parameters = ts.concatenate(signatureWithRest.parameters, [syntheticArgsSymbol]); + signatureWithRest.hasRestParameter = true; + signatures = [signatureWithRest]; + } + } + } var candidates = candidatesOutArray || []; // reorderCandidates fills up the candidates array directly reorderCandidates(signatures, candidates); @@ -37589,7 +39257,7 @@ var ts; var result; // If we are in signature help, a trailing comma indicates that we intend to provide another argument, // so we will only accept overloads with arity at least 1 higher than the current number of provided arguments. - var signatureHelpTrailingComma = candidatesOutArray && node.kind === 180 /* CallExpression */ && node.arguments.hasTrailingComma; + var signatureHelpTrailingComma = candidatesOutArray && node.kind === 181 /* CallExpression */ && node.arguments.hasTrailingComma; // Section 4.12.1: // if the candidate list contains one or more signatures for which the type of each argument // expression is a subtype of each corresponding parameter type, the return type of the first @@ -37684,7 +39352,7 @@ var ts; var candidate = void 0; var typeArgumentsAreValid = void 0; var inferenceContext = originalCandidate.typeParameters - ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false) + ? createInferenceContext(originalCandidate, /*inferUnionTypes*/ false, /*useAnyForNoInferences*/ ts.isInJavaScriptFile(node)) : undefined; while (true) { candidate = originalCandidate; @@ -37707,7 +39375,7 @@ var ts; if (!checkApplicableSignature(node, args, candidate, relation, excludeArgument, /*reportErrors*/ false)) { break; } - var index = excludeArgument ? ts.indexOf(excludeArgument, true) : -1; + var index = excludeArgument ? ts.indexOf(excludeArgument, /*value*/ true) : -1; if (index < 0) { return candidate; } @@ -37739,14 +39407,14 @@ var ts; } } function resolveCallExpression(node, candidatesOutArray) { - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { var superType = checkSuperExpression(node.expression); if (superType !== unknownType) { // In super call, the candidate signatures are the matching arity signatures of the base constructor function instantiated // with the type arguments specified in the extends clause. var baseTypeNode = ts.getClassExtendsHeritageClauseElement(ts.getContainingClass(node)); if (baseTypeNode) { - var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments); + var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode); return resolveCall(node, baseConstructors, candidatesOutArray); } } @@ -37938,26 +39606,26 @@ var ts; return resolveCall(node, callSignatures, candidatesOutArray); } /** - * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. - */ + * Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression. + */ function getDiagnosticHeadMessageForDecoratorResolution(node) { switch (node.parent.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression; - case 145 /* Parameter */: + case 146 /* Parameter */: return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression; } } /** - * Resolves a decorator as if it were a call expression. - */ + * Resolves a decorator as if it were a call expression. + */ function resolveDecorator(node, candidatesOutArray) { var funcType = checkExpression(node.expression); var apparentType = getApparentType(funcType); @@ -38008,8 +39676,8 @@ var ts; if (elementType.flags & 65536 /* Union */) { var types = elementType.types; var result = void 0; - for (var _i = 0, types_17 = types; _i < types_17.length; _i++) { - var type = types_17[_i]; + for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { + var type = types_18[_i]; result = result || resolveStatelessJsxOpeningLikeElement(openingLikeElement, type, candidatesOutArray); } return result; @@ -38024,16 +39692,16 @@ var ts; } function resolveSignature(node, candidatesOutArray) { switch (node.kind) { - case 180 /* CallExpression */: + case 181 /* CallExpression */: return resolveCallExpression(node, candidatesOutArray); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return resolveNewExpression(node, candidatesOutArray); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return resolveTaggedTemplateExpression(node, candidatesOutArray); - case 146 /* Decorator */: + case 147 /* Decorator */: return resolveDecorator(node, candidatesOutArray); - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: // This code-path is called by language service return resolveStatelessJsxOpeningLikeElement(node, checkExpression(node.tagName), candidatesOutArray); } @@ -38085,28 +39753,31 @@ var ts; // Grammar checking; stop grammar-checking if checkGrammarTypeArguments return true checkGrammarTypeArguments(node, node.typeArguments) || checkGrammarArguments(node, node.arguments); var signature = getResolvedSignature(node); - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { return voidType; } - if (node.kind === 181 /* NewExpression */) { + if (node.kind === 182 /* NewExpression */) { var declaration = signature.declaration; if (declaration && - declaration.kind !== 151 /* Constructor */ && - declaration.kind !== 155 /* ConstructSignature */ && - declaration.kind !== 160 /* ConstructorType */ && + declaration.kind !== 152 /* Constructor */ && + declaration.kind !== 156 /* ConstructSignature */ && + declaration.kind !== 161 /* 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 // Note:JS inferred classes might come from a variable declaration instead of a function declaration. // In this case, using getResolvedSymbol directly is required to avoid losing the members from the declaration. - var funcSymbol = node.expression.kind === 70 /* Identifier */ ? + var funcSymbol = node.expression.kind === 71 /* Identifier */ ? getResolvedSymbol(node.expression) : checkExpression(node.expression).symbol; - if (funcSymbol && funcSymbol.members && (funcSymbol.flags & 16 /* Function */ || ts.isDeclarationOfFunctionExpression(funcSymbol))) { + if (funcSymbol && ts.isDeclarationOfFunctionOrClassExpression(funcSymbol)) { + funcSymbol = getSymbolOfNode(funcSymbol.valueDeclaration.initializer); + } + if (funcSymbol && funcSymbol.members && funcSymbol.flags & 16 /* Function */) { return getInferredClassType(funcSymbol); } - else if (compilerOptions.noImplicitAny) { + else if (noImplicitAny) { error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type); } return anyType; @@ -38133,9 +39804,9 @@ var ts; return false; } var targetDeclarationKind = resolvedRequire.flags & 16 /* Function */ - ? 227 /* FunctionDeclaration */ + ? 228 /* FunctionDeclaration */ : resolvedRequire.flags & 3 /* Variable */ - ? 225 /* VariableDeclaration */ + ? 226 /* VariableDeclaration */ : 0 /* Unknown */; if (targetDeclarationKind !== 0 /* Unknown */) { var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind); @@ -38164,13 +39835,12 @@ var ts; } function checkMetaProperty(node) { checkGrammarMetaProperty(node); - ts.Debug.assert(node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target", "Unrecognized meta-property."); var container = ts.getNewTargetContainer(node); if (!container) { error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target"); return unknownType; } - else if (container.kind === 151 /* Constructor */) { + else if (container.kind === 152 /* Constructor */) { var symbol = getSymbolOfNode(container.parent); return getTypeOfSymbol(symbol); } @@ -38194,9 +39864,12 @@ var ts; pos < signature.parameters.length - 1 ? getTypeOfParameter(signature.parameters[pos]) : getRestTypeOfSignature(signature) : pos < signature.parameters.length ? getTypeOfParameter(signature.parameters[pos]) : anyType; } - function assignContextualParameterTypes(signature, context, mapper) { + function getTypeOfFirstParameterOfSignature(signature) { + return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + } + function assignContextualParameterTypes(signature, context, mapper, checkMode) { var len = signature.parameters.length - (signature.hasRestParameter ? 1 : 0); - if (isInferentialContext(mapper)) { + if (checkMode === 2 /* Inferential */) { for (var i = 0; i < len; i++) { var declaration = signature.parameters[i].valueDeclaration; if (declaration.type) { @@ -38208,23 +39881,23 @@ var ts; var parameter = signature.thisParameter; if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) { if (!parameter) { - signature.thisParameter = createSymbolWithType(context.thisParameter, undefined); + signature.thisParameter = createSymbolWithType(context.thisParameter, /*type*/ undefined); } - assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper); + assignTypeToParameterAndFixTypeParameters(signature.thisParameter, getTypeOfSymbol(context.thisParameter), mapper, checkMode); } } for (var i = 0; i < len; i++) { var parameter = signature.parameters[i]; if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeAtPosition(context, i); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } if (signature.hasRestParameter && isRestParameterIndex(context, signature.parameters.length - 1)) { var parameter = ts.lastOrUndefined(signature.parameters); if (!parameter.valueDeclaration.type) { var contextualParameterType = getTypeOfSymbol(ts.lastOrUndefined(context.parameters)); - assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper); + assignTypeToParameterAndFixTypeParameters(parameter, contextualParameterType, mapper, checkMode); } } } @@ -38235,7 +39908,7 @@ var ts; for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) { var element = _a[_i]; if (!ts.isOmittedExpression(element)) { - if (element.name.kind === 70 /* Identifier */) { + if (element.name.kind === 71 /* Identifier */) { getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element); } assignBindingElementTypes(element); @@ -38243,19 +39916,19 @@ var ts; } } } - function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper) { + function assignTypeToParameterAndFixTypeParameters(parameter, contextualType, mapper, checkMode) { var links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === 173 /* ObjectBindingPattern */ || - parameter.valueDeclaration.name.kind === 174 /* ArrayBindingPattern */)) { + (parameter.valueDeclaration.name.kind === 174 /* ObjectBindingPattern */ || + parameter.valueDeclaration.name.kind === 175 /* ArrayBindingPattern */)) { links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); } assignBindingElementTypes(parameter.valueDeclaration); } - else if (isInferentialContext(mapper)) { + else if (checkMode === 2 /* Inferential */) { // Even if the parameter already has a type, it might be because it was given a type while // processing the function as an argument to a prior signature during overload resolution. // If this was the case, it may have caused some type parameters to be fixed. So here, @@ -38297,10 +39970,10 @@ var ts; } function createPromiseType(promisedType) { // creates a `Promise` type where `T` is the promisedType argument - var globalPromiseType = getGlobalPromiseType(); + var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); if (globalPromiseType !== emptyGenericType) { // if the promised type is itself a promise, get the underlying type; otherwise, fallback to the promised type - promisedType = getAwaitedType(promisedType); + promisedType = getAwaitedType(promisedType) || emptyObjectType; return createTypeReference(globalPromiseType, [promisedType]); } return emptyObjectType; @@ -38311,56 +39984,63 @@ var ts; error(func, ts.Diagnostics.An_async_function_or_method_must_return_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option); return unknownType; } - else if (!getGlobalPromiseConstructorSymbol()) { + else if (!getGlobalPromiseConstructorSymbol(/*reportErrors*/ true)) { error(func, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } return promiseType; } - function getReturnTypeFromBody(func, contextualMapper) { + function getReturnTypeFromBody(func, checkMode) { var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func); if (!func.body) { return unknownType; } - var isAsync = ts.isAsyncFunctionLike(func); + var functionFlags = ts.getFunctionFlags(func); var type; - if (func.body.kind !== 206 /* Block */) { - type = checkExpressionCached(func.body, contextualMapper); - if (isAsync) { + if (func.body.kind !== 207 /* Block */) { + type = checkExpressionCached(func.body, checkMode); + if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which we will wrap in // the native Promise type later in this function. - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, /*errorNode*/ func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } } else { var types = void 0; - var funcIsGenerator = !!func.asteriskToken; - if (funcIsGenerator) { - types = checkAndAggregateYieldOperandTypes(func, contextualMapper); - if (types.length === 0) { - var iterableIteratorAny = createIterableIteratorType(anyType); - if (compilerOptions.noImplicitAny) { + if (functionFlags & 1 /* Generator */) { + types = ts.concatenate(checkAndAggregateYieldOperandTypes(func, checkMode), checkAndAggregateReturnExpressionTypes(func, checkMode)); + if (!types || types.length === 0) { + var iterableIteratorAny = functionFlags & 2 /* Async */ + ? createAsyncIterableIteratorType(anyType) // AsyncGenerator function + : createIterableIteratorType(anyType); // Generator function + if (noImplicitAny) { error(func.asteriskToken, ts.Diagnostics.Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type, typeToString(iterableIteratorAny)); } return iterableIteratorAny; } } else { - types = checkAndAggregateReturnExpressionTypes(func, contextualMapper); + types = checkAndAggregateReturnExpressionTypes(func, checkMode); if (!types) { // For an async function, the return type will not be never, but rather a Promise for never. - return isAsync ? createPromiseReturnType(func, neverType) : neverType; + return functionFlags & 2 /* Async */ + ? createPromiseReturnType(func, neverType) // Async function + : neverType; // Normal function } if (types.length === 0) { // For an async function, the return type will not be void, but rather a Promise for void. - return isAsync ? createPromiseReturnType(func, voidType) : voidType; + return functionFlags & 2 /* Async */ + ? createPromiseReturnType(func, voidType) // Async function + : voidType; // Normal function } } // Return a union of the return expression types. type = getUnionType(types, /*subtypeReduction*/ true); - if (funcIsGenerator) { - type = createIterableIteratorType(type); + if (functionFlags & 1 /* Generator */) { + type = functionFlags & 2 /* Async */ + ? createAsyncIterableIteratorType(type) // AsyncGenerator function + : createIterableIteratorType(type); // Generator function } } if (!contextualSignature) { @@ -38375,17 +40055,25 @@ var ts; // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body is awaited type of the body, wrapped in a native Promise type. - return isAsync ? createPromiseReturnType(func, widenedType) : widenedType; + return (functionFlags & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */ + ? createPromiseReturnType(func, widenedType) // Async function + : widenedType; // Generator function, AsyncGenerator function, or normal function } - function checkAndAggregateYieldOperandTypes(func, contextualMapper) { + function checkAndAggregateYieldOperandTypes(func, checkMode) { var aggregatedTypes = []; + var functionFlags = ts.getFunctionFlags(func); ts.forEachYieldExpression(func.body, function (yieldExpression) { var expr = yieldExpression.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); + var type = checkExpressionCached(expr, checkMode); if (yieldExpression.asteriskToken) { // A yield* expression effectively yields everything that its operand yields - type = checkElementTypeOfIterable(type, yieldExpression.expression); + type = checkIteratedTypeOrElementType(type, yieldExpression.expression, /*allowStringInput*/ false, (functionFlags & 2 /* Async */) !== 0); + } + if (functionFlags & 2 /* Async */) { + type = checkAwaitedType(type, expr, yieldExpression.asteriskToken + ? ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member + : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (!ts.contains(aggregatedTypes, type)) { aggregatedTypes.push(type); @@ -38413,26 +40101,26 @@ var ts; return false; } var lastStatement = ts.lastOrUndefined(func.body.statements); - if (lastStatement && lastStatement.kind === 220 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { + if (lastStatement && lastStatement.kind === 221 /* SwitchStatement */ && isExhaustiveSwitchStatement(lastStatement)) { return false; } return true; } - function checkAndAggregateReturnExpressionTypes(func, contextualMapper) { - var isAsync = ts.isAsyncFunctionLike(func); + function checkAndAggregateReturnExpressionTypes(func, checkMode) { + var functionFlags = ts.getFunctionFlags(func); var aggregatedTypes = []; var hasReturnWithNoExpression = functionHasImplicitReturn(func); var hasReturnOfTypeNever = false; ts.forEachReturnStatement(func.body, function (returnStatement) { var expr = returnStatement.expression; if (expr) { - var type = checkExpressionCached(expr, contextualMapper); - if (isAsync) { + var type = checkExpressionCached(expr, checkMode); + if (functionFlags & 2 /* Async */) { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body should be unwrapped to its awaited type, which should be wrapped in // the native Promise type by the caller. - type = checkAwaitedType(type, func, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + type = checkAwaitedType(type, func, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } if (type.flags & 8192 /* Never */) { hasReturnOfTypeNever = true; @@ -38446,7 +40134,7 @@ var ts; } }); if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || - func.kind === 185 /* FunctionExpression */ || func.kind === 186 /* ArrowFunction */)) { + func.kind === 186 /* FunctionExpression */ || func.kind === 187 /* ArrowFunction */)) { return undefined; } if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression) { @@ -38475,7 +40163,7 @@ var ts; } // If all we have is a function signature, or an arrow function with an expression body, then there is nothing to check. // also if HasImplicitReturn flag is not set this means that all codepaths in function body end with return or throw - if (ts.nodeIsMissing(func.body) || func.body.kind !== 206 /* Block */ || !functionHasImplicitReturn(func)) { + if (ts.nodeIsMissing(func.body) || func.body.kind !== 207 /* Block */ || !functionHasImplicitReturn(func)) { return; } var hasExplicitReturn = func.flags & 256 /* HasExplicitReturn */; @@ -38507,22 +40195,22 @@ var ts; error(func.type || func, ts.Diagnostics.Not_all_code_paths_return_a_value); } } - function checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper) { - ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) { + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); // Grammar checking var hasGrammarError = checkGrammarFunctionLikeDeclaration(node); - if (!hasGrammarError && node.kind === 185 /* FunctionExpression */) { + if (!hasGrammarError && node.kind === 186 /* FunctionExpression */) { checkGrammarForGenerator(node); } // The identityMapper object is used to indicate that function expressions are wildcards - if (contextualMapper === identityMapper && isContextSensitive(node)) { + if (checkMode === 1 /* SkipContextSensitive */ && isContextSensitive(node)) { checkNodeDeferred(node); return anyFunctionType; } var links = getNodeLinks(node); var type = getTypeOfSymbol(node.symbol); var contextSensitive = isContextSensitive(node); - var mightFixTypeParameters = contextSensitive && isInferentialContext(contextualMapper); + var mightFixTypeParameters = contextSensitive && checkMode === 2 /* Inferential */; // Check if function expression is contextually typed and assign parameter types if so. // See the comment in assignTypeToParameterAndFixTypeParameters to understand why we need to // check mightFixTypeParameters. @@ -38537,10 +40225,10 @@ var ts; if (contextualSignature) { var signature = getSignaturesOfType(type, 0 /* Call */)[0]; if (contextSensitive) { - assignContextualParameterTypes(signature, contextualSignature, contextualMapper || identityMapper); + assignContextualParameterTypes(signature, contextualSignature, getContextualMapper(node), checkMode); } if (mightFixTypeParameters || !node.type && !signature.resolvedReturnType) { - var returnType = getReturnTypeFromBody(node, contextualMapper); + var returnType = getReturnTypeFromBody(node, checkMode); if (!signature.resolvedReturnType) { signature.resolvedReturnType = returnType; } @@ -38552,7 +40240,7 @@ var ts; } } } - if (produceDiagnostics && node.kind !== 150 /* MethodDeclaration */) { + if (produceDiagnostics && node.kind !== 151 /* MethodDeclaration */) { checkCollisionWithCapturedSuperVariable(node, node.name); checkCollisionWithCapturedThisVariable(node, node.name); checkCollisionWithCapturedNewTargetVariable(node, node.name); @@ -38560,10 +40248,13 @@ var ts; return type; } function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) { - ts.Debug.assert(node.kind !== 150 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); - var isAsync = ts.isAsyncFunctionLike(node); - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); - if (!node.asteriskToken) { + ts.Debug.assert(node.kind !== 151 /* MethodDeclaration */ || ts.isObjectLiteralMethod(node)); + var functionFlags = ts.getFunctionFlags(node); + var returnOrPromisedType = node.type && + ((functionFlags & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */ ? + checkAsyncFunctionReturnType(node) : + getTypeFromTypeNode(node.type)); // AsyncGenerator function, Generator function, or normal function + if ((functionFlags & 1 /* Generator */) === 0) { // return is not necessary in the body of generators checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } @@ -38576,7 +40267,7 @@ var ts; // checkFunctionExpressionBodies). So it must be done now. getReturnTypeOfSignature(getSignatureFromDeclaration(node)); } - if (node.body.kind === 206 /* Block */) { + if (node.body.kind === 207 /* Block */) { checkSourceElement(node.body); } else { @@ -38587,8 +40278,8 @@ var ts; // its return type annotation. var exprType = checkExpression(node.body); if (returnOrPromisedType) { - if (isAsync) { - var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member); + if ((functionFlags & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */) { + var awaitedType = checkAwaitedType(exprType, node.body, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } else { @@ -38613,7 +40304,7 @@ var ts; // Get accessors without matching set accessors // Enum members // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) - return !!(getCheckFlags(symbol) & 4 /* Readonly */ || + return !!(getCheckFlags(symbol) & 8 /* Readonly */ || symbol.flags & 4 /* Property */ && getDeclarationModifierFlagsFromSymbol(symbol) & 64 /* Readonly */ || symbol.flags & 3 /* Variable */ && getDeclarationNodeFlagsFromSymbol(symbol) & 2 /* Const */ || symbol.flags & 98304 /* Accessor */ && !(symbol.flags & 65536 /* SetAccessor */) || @@ -38623,11 +40314,11 @@ var ts; if (isReadonlySymbol(symbol)) { // Allow assignments to readonly properties within constructors of the same class declaration. if (symbol.flags & 4 /* Property */ && - (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) && - expr.expression.kind === 98 /* ThisKeyword */) { + (expr.kind === 179 /* PropertyAccessExpression */ || expr.kind === 180 /* ElementAccessExpression */) && + expr.expression.kind === 99 /* ThisKeyword */) { // Look for if this is the constructor for the class that `symbol` is a property of. var func = ts.getContainingFunction(expr); - if (!(func && func.kind === 151 /* Constructor */)) + if (!(func && func.kind === 152 /* Constructor */)) return true; // If func.parent is a class and symbol is a (readonly) property of that class, or // if func is a constructor and symbol is a (readonly) parameter property declared in it, @@ -38639,13 +40330,13 @@ var ts; return false; } function isReferenceThroughNamespaceImport(expr) { - if (expr.kind === 178 /* PropertyAccessExpression */ || expr.kind === 179 /* ElementAccessExpression */) { + if (expr.kind === 179 /* PropertyAccessExpression */ || expr.kind === 180 /* ElementAccessExpression */) { var node = ts.skipParentheses(expr.expression); - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { var symbol = getNodeLinks(node).resolvedSymbol; if (symbol.flags & 8388608 /* Alias */) { var declaration = getDeclarationOfAliasSymbol(symbol); - return declaration && declaration.kind === 239 /* NamespaceImport */; + return declaration && declaration.kind === 240 /* NamespaceImport */; } } } @@ -38654,7 +40345,7 @@ var ts; function checkReferenceExpression(expr, invalidReferenceMessage) { // References are combinations of identifiers, parentheses, and property accesses. var node = ts.skipParentheses(expr); - if (node.kind !== 70 /* Identifier */ && node.kind !== 178 /* PropertyAccessExpression */ && node.kind !== 179 /* ElementAccessExpression */) { + if (node.kind !== 71 /* Identifier */ && node.kind !== 179 /* PropertyAccessExpression */ && node.kind !== 180 /* ElementAccessExpression */) { error(expr, invalidReferenceMessage); return false; } @@ -38663,7 +40354,7 @@ var ts; function checkDeleteExpression(node) { checkExpression(node.expression); var expr = ts.skipParentheses(node.expression); - if (expr.kind !== 178 /* PropertyAccessExpression */ && expr.kind !== 179 /* ElementAccessExpression */) { + if (expr.kind !== 179 /* PropertyAccessExpression */ && expr.kind !== 180 /* ElementAccessExpression */) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } @@ -38693,32 +40384,32 @@ var ts; } } var operandType = checkExpression(node.expression); - return checkAwaitedType(operandType, node); + return checkAwaitedType(operandType, node, ts.Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } function checkPrefixUnaryExpression(node) { var operandType = checkExpression(node.operand); if (operandType === silentNeverType) { return silentNeverType; } - if (node.operator === 37 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { + if (node.operator === 38 /* MinusToken */ && node.operand.kind === 8 /* NumericLiteral */) { return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, "" + -node.operand.text)); } switch (node.operator) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: checkNonNullType(operandType, node.operand); if (maybeTypeOfKind(operandType, 512 /* ESSymbol */)) { error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator)); } return numberType; - case 50 /* ExclamationToken */: + case 51 /* ExclamationToken */: var facts = getTypeFacts(operandType) & (1048576 /* Truthy */ | 2097152 /* Falsy */); return facts === 1048576 /* Truthy */ ? falseType : facts === 2097152 /* Falsy */ ? trueType : booleanType; - case 42 /* PlusPlusToken */: - case 43 /* MinusMinusToken */: + case 43 /* PlusPlusToken */: + case 44 /* MinusMinusToken */: var ok = checkArithmeticOperandType(node.operand, checkNonNullType(operandType, node.operand), 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 @@ -38748,8 +40439,8 @@ var ts; } if (type.flags & 196608 /* UnionOrIntersection */) { var types = type.types; - for (var _i = 0, types_18 = types; _i < types_18.length; _i++) { - var t = types_18[_i]; + for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { + var t = types_19[_i]; if (maybeTypeOfKind(t, kind)) { return true; } @@ -38766,8 +40457,8 @@ var ts; } if (type.flags & 65536 /* Union */) { var types = type.types; - for (var _i = 0, types_19 = types; _i < types_19.length; _i++) { - var t = types_19[_i]; + for (var _i = 0, types_20 = types; _i < types_20.length; _i++) { + var t = types_20[_i]; if (!isTypeOfKind(t, kind)) { return false; } @@ -38776,8 +40467,8 @@ var ts; } if (type.flags & 131072 /* Intersection */) { var types = type.types; - for (var _a = 0, types_20 = types; _a < types_20.length; _a++) { - var t = types_20[_a]; + for (var _a = 0, types_21 = types; _a < types_21.length; _a++) { + var t = types_21[_a]; if (isTypeOfKind(t, kind)) { return true; } @@ -38825,24 +40516,24 @@ var ts; if (!(isTypeComparableTo(leftType, stringType) || isTypeOfKind(leftType, 340 /* NumberLike */ | 512 /* ESSymbol */))) { error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol); } - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter); } return booleanType; } function checkObjectLiteralAssignment(node, sourceType) { var properties = node.properties; - for (var _i = 0, properties_6 = properties; _i < properties_6.length; _i++) { - var p = properties_6[_i]; + for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) { + var p = properties_7[_i]; checkObjectLiteralDestructuringPropertyAssignment(sourceType, p, properties); } return sourceType; } /** Note: If property cannot be a SpreadAssignment, then allProperties does not need to be provided */ function checkObjectLiteralDestructuringPropertyAssignment(objectLiteralType, property, allProperties) { - if (property.kind === 260 /* PropertyAssignment */ || property.kind === 261 /* ShorthandPropertyAssignment */) { + if (property.kind === 261 /* PropertyAssignment */ || property.kind === 262 /* ShorthandPropertyAssignment */) { var name = property.name; - if (name.kind === 143 /* ComputedPropertyName */) { + if (name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(name); } if (isComputedNonLiteralName(name)) { @@ -38855,7 +40546,7 @@ var ts; isNumericLiteralName(text) && getIndexTypeOfType(objectLiteralType, 1 /* Number */) || getIndexTypeOfType(objectLiteralType, 0 /* String */); if (type) { - if (property.kind === 261 /* ShorthandPropertyAssignment */) { + if (property.kind === 262 /* ShorthandPropertyAssignment */) { return checkDestructuringAssignment(property, type); } else { @@ -38867,7 +40558,7 @@ var ts; error(name, ts.Diagnostics.Type_0_has_no_property_1_and_no_string_index_signature, typeToString(objectLiteralType), ts.declarationNameToString(name)); } } - else if (property.kind === 262 /* SpreadAssignment */) { + else if (property.kind === 263 /* SpreadAssignment */) { if (languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(property, 4 /* Rest */); } @@ -38884,22 +40575,25 @@ var ts; error(property, ts.Diagnostics.Property_assignment_expected); } } - function checkArrayLiteralAssignment(node, sourceType, contextualMapper) { + function checkArrayLiteralAssignment(node, sourceType, checkMode) { + if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* Read */); + } // This elementType will be used if the specific property corresponding to this index is not // present (aka the tuple element property). This call also checks that the parentType is in // fact an iterable or array (depending on target language). - var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; var elements = node.elements; for (var i = 0; i < elements.length; i++) { - checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, contextualMapper); + checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, elementType, checkMode); } return sourceType; } - function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, contextualMapper) { + function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) { var elements = node.elements; var element = elements[elementIndex]; - if (element.kind !== 199 /* OmittedExpression */) { - if (element.kind !== 197 /* SpreadElement */) { + if (element.kind !== 200 /* OmittedExpression */) { + if (element.kind !== 198 /* SpreadElement */) { var propName = "" + elementIndex; var type = isTypeAny(sourceType) ? sourceType @@ -38907,7 +40601,7 @@ var ts; ? getTypeOfPropertyOfType(sourceType, propName) : elementType; if (type) { - return checkDestructuringAssignment(element, type, contextualMapper); + return checkDestructuringAssignment(element, type, checkMode); } else { // We still need to check element expression here because we may need to set appropriate flag on the expression @@ -38927,20 +40621,20 @@ var ts; } else { var restExpression = element.expression; - if (restExpression.kind === 193 /* BinaryExpression */ && restExpression.operatorToken.kind === 57 /* EqualsToken */) { + if (restExpression.kind === 194 /* BinaryExpression */ && restExpression.operatorToken.kind === 58 /* EqualsToken */) { error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer); } else { - return checkDestructuringAssignment(restExpression, createArrayType(elementType), contextualMapper); + return checkDestructuringAssignment(restExpression, createArrayType(elementType), checkMode); } } } } return undefined; } - function checkDestructuringAssignment(exprOrAssignment, sourceType, contextualMapper) { + function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode) { var target; - if (exprOrAssignment.kind === 261 /* ShorthandPropertyAssignment */) { + if (exprOrAssignment.kind === 262 /* ShorthandPropertyAssignment */) { var prop = exprOrAssignment; if (prop.objectAssignmentInitializer) { // In strict null checking mode, if a default value of a non-undefined type is specified, remove @@ -38949,28 +40643,28 @@ var ts; !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 2048 /* Undefined */)) { sourceType = getTypeWithFacts(sourceType, 131072 /* NEUndefined */); } - checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, contextualMapper); + checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode); } target = exprOrAssignment.name; } else { target = exprOrAssignment; } - if (target.kind === 193 /* BinaryExpression */ && target.operatorToken.kind === 57 /* EqualsToken */) { - checkBinaryExpression(target, contextualMapper); + if (target.kind === 194 /* BinaryExpression */ && target.operatorToken.kind === 58 /* EqualsToken */) { + checkBinaryExpression(target, checkMode); target = target.left; } - if (target.kind === 177 /* ObjectLiteralExpression */) { + if (target.kind === 178 /* ObjectLiteralExpression */) { return checkObjectLiteralAssignment(target, sourceType); } - if (target.kind === 176 /* ArrayLiteralExpression */) { - return checkArrayLiteralAssignment(target, sourceType, contextualMapper); + if (target.kind === 177 /* ArrayLiteralExpression */) { + return checkArrayLiteralAssignment(target, sourceType, checkMode); } - return checkReferenceAssignment(target, sourceType, contextualMapper); + return checkReferenceAssignment(target, sourceType, checkMode); } - function checkReferenceAssignment(target, sourceType, contextualMapper) { - var targetType = checkExpression(target, contextualMapper); - var error = target.parent.kind === 262 /* SpreadAssignment */ ? + function checkReferenceAssignment(target, sourceType, checkMode) { + var targetType = checkExpression(target, checkMode); + var error = target.parent.kind === 263 /* SpreadAssignment */ ? ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access : ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access; if (checkReferenceExpression(target, error)) { @@ -38989,52 +40683,52 @@ var ts; function isSideEffectFree(node) { node = ts.skipParentheses(node); switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: case 9 /* StringLiteral */: - case 11 /* RegularExpressionLiteral */: - case 182 /* TaggedTemplateExpression */: - case 195 /* TemplateExpression */: - case 12 /* NoSubstitutionTemplateLiteral */: + case 12 /* RegularExpressionLiteral */: + case 183 /* TaggedTemplateExpression */: + case 196 /* TemplateExpression */: + case 13 /* NoSubstitutionTemplateLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: - case 94 /* NullKeyword */: - case 138 /* UndefinedKeyword */: - case 185 /* FunctionExpression */: - case 198 /* ClassExpression */: - case 186 /* ArrowFunction */: - case 176 /* ArrayLiteralExpression */: - case 177 /* ObjectLiteralExpression */: - case 188 /* TypeOfExpression */: - case 202 /* NonNullExpression */: - case 249 /* JsxSelfClosingElement */: - case 248 /* JsxElement */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 139 /* UndefinedKeyword */: + case 186 /* FunctionExpression */: + case 199 /* ClassExpression */: + case 187 /* ArrowFunction */: + case 177 /* ArrayLiteralExpression */: + case 178 /* ObjectLiteralExpression */: + case 189 /* TypeOfExpression */: + case 203 /* NonNullExpression */: + case 250 /* JsxSelfClosingElement */: + case 249 /* JsxElement */: return true; - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return isSideEffectFree(node.whenTrue) && isSideEffectFree(node.whenFalse); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: if (ts.isAssignmentOperator(node.operatorToken.kind)) { return false; } return isSideEffectFree(node.left) && isSideEffectFree(node.right); - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: // Unary operators ~, !, +, and - have no side effects. // The rest do. switch (node.operator) { - case 50 /* ExclamationToken */: - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: + case 51 /* ExclamationToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: return true; } return false; // Some forms listed here for clarity - case 189 /* VoidExpression */: // Explicit opt-out - case 183 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings - case 201 /* AsExpression */: // Not SEF, but can produce useful type warnings + case 190 /* VoidExpression */: // Explicit opt-out + case 184 /* TypeAssertionExpression */: // Not SEF, but can produce useful type warnings + case 202 /* AsExpression */: // Not SEF, but can produce useful type warnings default: return false; } @@ -39049,39 +40743,39 @@ var ts; firstAssignableToSecond && !secondAssignableToFirst ? type2 : getUnionType([type1, type2], /*subtypeReduction*/ true); } - function checkBinaryExpression(node, contextualMapper) { - return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, contextualMapper, node); + function checkBinaryExpression(node, checkMode) { + return checkBinaryLikeExpression(node.left, node.operatorToken, node.right, checkMode, node); } - function checkBinaryLikeExpression(left, operatorToken, right, contextualMapper, errorNode) { + function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) { var operator = operatorToken.kind; - if (operator === 57 /* EqualsToken */ && (left.kind === 177 /* ObjectLiteralExpression */ || left.kind === 176 /* ArrayLiteralExpression */)) { - return checkDestructuringAssignment(left, checkExpression(right, contextualMapper), contextualMapper); + if (operator === 58 /* EqualsToken */ && (left.kind === 178 /* ObjectLiteralExpression */ || left.kind === 177 /* ArrayLiteralExpression */)) { + return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode); } - var leftType = checkExpression(left, contextualMapper); - var rightType = checkExpression(right, contextualMapper); + var leftType = checkExpression(left, checkMode); + var rightType = checkExpression(right, checkMode); switch (operator) { - case 38 /* AsteriskToken */: - case 39 /* AsteriskAsteriskToken */: - case 60 /* AsteriskEqualsToken */: - case 61 /* AsteriskAsteriskEqualsToken */: - case 40 /* SlashToken */: - case 62 /* SlashEqualsToken */: - case 41 /* PercentToken */: - case 63 /* PercentEqualsToken */: - case 37 /* MinusToken */: - case 59 /* MinusEqualsToken */: - case 44 /* LessThanLessThanToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 48 /* BarToken */: - case 68 /* BarEqualsToken */: - case 49 /* CaretToken */: - case 69 /* CaretEqualsToken */: - case 47 /* AmpersandToken */: - case 67 /* AmpersandEqualsToken */: + case 39 /* AsteriskToken */: + case 40 /* AsteriskAsteriskToken */: + case 61 /* AsteriskEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: + case 41 /* SlashToken */: + case 63 /* SlashEqualsToken */: + case 42 /* PercentToken */: + case 64 /* PercentEqualsToken */: + case 38 /* MinusToken */: + case 60 /* MinusEqualsToken */: + case 45 /* LessThanLessThanToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 49 /* BarToken */: + case 69 /* BarEqualsToken */: + case 50 /* CaretToken */: + case 70 /* CaretEqualsToken */: + case 48 /* AmpersandToken */: + case 68 /* AmpersandEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -39104,8 +40798,8 @@ var ts; } } return numberType; - case 36 /* PlusToken */: - case 58 /* PlusEqualsToken */: + case 37 /* PlusToken */: + case 59 /* PlusEqualsToken */: if (leftType === silentNeverType || rightType === silentNeverType) { return silentNeverType; } @@ -39138,14 +40832,14 @@ var ts; reportOperatorError(); return anyType; } - if (operator === 58 /* PlusEqualsToken */) { + if (operator === 59 /* PlusEqualsToken */) { checkAssignmentOperator(resultType); } return resultType; - case 26 /* LessThanToken */: - case 28 /* GreaterThanToken */: - case 29 /* LessThanEqualsToken */: - case 30 /* GreaterThanEqualsToken */: + case 27 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 30 /* LessThanEqualsToken */: + case 31 /* GreaterThanEqualsToken */: if (checkForDisallowedESSymbolOperand(operator)) { leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left)); rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right)); @@ -39154,10 +40848,10 @@ var ts; } } return booleanType; - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: var leftIsLiteral = isLiteralType(leftType); var rightIsLiteral = isLiteralType(rightType); if (!leftIsLiteral || !rightIsLiteral) { @@ -39168,27 +40862,30 @@ var ts; reportOperatorError(); } return booleanType; - case 92 /* InstanceOfKeyword */: + case 93 /* InstanceOfKeyword */: return checkInstanceOfExpression(left, right, leftType, rightType); - case 91 /* InKeyword */: + case 92 /* InKeyword */: return checkInExpression(left, right, leftType, rightType); - case 52 /* AmpersandAmpersandToken */: + case 53 /* AmpersandAmpersandToken */: return getTypeFacts(leftType) & 1048576 /* Truthy */ ? includeFalsyTypes(rightType, getFalsyFlags(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType))) : leftType; - case 53 /* BarBarToken */: + case 54 /* BarBarToken */: return getTypeFacts(leftType) & 2097152 /* Falsy */ ? getBestChoiceType(removeDefinitelyFalsyTypes(leftType), rightType) : leftType; - case 57 /* EqualsToken */: + case 58 /* EqualsToken */: checkAssignmentOperator(rightType); return getRegularTypeOfObjectLiteral(rightType); - case 25 /* CommaToken */: - if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) { + case 26 /* CommaToken */: + if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) { error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects); } return rightType; } + function isEvalNode(node) { + return node.kind === 71 /* Identifier */ && node.text === "eval"; + } // Return true if there was no error, false if there was an error. function checkForDisallowedESSymbolOperand(operator) { var offendingSymbolOperand = maybeTypeOfKind(leftType, 512 /* ESSymbol */) ? left : @@ -39202,21 +40899,21 @@ var ts; } function getSuggestedBooleanOperator(operator) { switch (operator) { - case 48 /* BarToken */: - case 68 /* BarEqualsToken */: - return 53 /* BarBarToken */; - case 49 /* CaretToken */: - case 69 /* CaretEqualsToken */: - return 34 /* ExclamationEqualsEqualsToken */; - case 47 /* AmpersandToken */: - case 67 /* AmpersandEqualsToken */: - return 52 /* AmpersandAmpersandToken */; + case 49 /* BarToken */: + case 69 /* BarEqualsToken */: + return 54 /* BarBarToken */; + case 50 /* CaretToken */: + case 70 /* CaretEqualsToken */: + return 35 /* ExclamationEqualsEqualsToken */; + case 48 /* AmpersandToken */: + case 68 /* AmpersandEqualsToken */: + return 53 /* AmpersandAmpersandToken */; default: return undefined; } } function checkAssignmentOperator(valueType) { - if (produceDiagnostics && operator >= 57 /* FirstAssignment */ && operator <= 69 /* LastAssignment */) { + if (produceDiagnostics && operator >= 58 /* FirstAssignment */ && operator <= 70 /* LastAssignment */) { // TypeScript 1.0 spec (April 2014): 4.17 // An assignment of the form // VarExpr = ValueExpr @@ -39262,23 +40959,40 @@ var ts; var func = ts.getContainingFunction(node); // If the user's code is syntactically correct, the func should always have a star. After all, // we are in a yield context. - if (func && func.asteriskToken) { + var functionFlags = func && ts.getFunctionFlags(func); + if (node.asteriskToken) { + if (functionFlags & 2 /* Async */) { + if (languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 4096 /* AsyncDelegator */); + } + } + else if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* Values */); + } + } + if (functionFlags & 1 /* Generator */) { var expressionType = checkExpressionCached(node.expression, /*contextualMapper*/ undefined); var expressionElementType = void 0; var nodeIsYieldStar = !!node.asteriskToken; if (nodeIsYieldStar) { - expressionElementType = checkElementTypeOfIterable(expressionType, node.expression); + expressionElementType = checkIteratedTypeOrElementType(expressionType, node.expression, /*allowStringInput*/ false, (functionFlags & 2 /* Async */) !== 0); } // There is no point in doing an assignability check if the function // has no explicit return type because the return type is directly computed // from the yield expressions. if (func.type) { - var signatureElementType = getElementTypeOfIterableIterator(getTypeFromTypeNode(func.type)) || anyType; + var signatureElementType = getIteratedTypeOfGenerator(getTypeFromTypeNode(func.type), (functionFlags & 2 /* Async */) !== 0) || anyType; if (nodeIsYieldStar) { - checkTypeAssignableTo(expressionElementType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(functionFlags & 2 /* Async */ + ? getAwaitedType(expressionElementType, node.expression, ts.Diagnostics.Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionElementType, signatureElementType, node.expression, + /*headMessage*/ undefined); } else { - checkTypeAssignableTo(expressionType, signatureElementType, node.expression, /*headMessage*/ undefined); + checkTypeAssignableTo(functionFlags & 2 /* Async */ + ? getAwaitedType(expressionType, node.expression, ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member) + : expressionType, signatureElementType, node.expression, + /*headMessage*/ undefined); } } } @@ -39286,10 +41000,10 @@ var ts; // Both yield and yield* expressions have type 'any' return anyType; } - function checkConditionalExpression(node, contextualMapper) { + function checkConditionalExpression(node, checkMode) { checkExpression(node.condition); - var type1 = checkExpression(node.whenTrue, contextualMapper); - var type2 = checkExpression(node.whenFalse, contextualMapper); + var type1 = checkExpression(node.whenTrue, checkMode); + var type2 = checkExpression(node.whenFalse, checkMode); return getBestChoiceType(type1, type2); } function checkLiteralExpression(node) { @@ -39301,9 +41015,9 @@ var ts; return getFreshTypeOfLiteralType(getLiteralTypeForText(32 /* StringLiteral */, node.text)); case 8 /* NumericLiteral */: return getFreshTypeOfLiteralType(getLiteralTypeForText(64 /* NumberLiteral */, node.text)); - case 100 /* TrueKeyword */: + case 101 /* TrueKeyword */: return trueType; - case 85 /* FalseKeyword */: + case 86 /* FalseKeyword */: return falseType; } } @@ -39320,12 +41034,17 @@ var ts; } function checkExpressionWithContextualType(node, contextualType, contextualMapper) { var saveContextualType = node.contextualType; + var saveContextualMapper = node.contextualMapper; node.contextualType = contextualType; - var result = checkExpression(node, contextualMapper); + node.contextualMapper = contextualMapper; + var checkMode = contextualMapper === identityMapper ? 1 /* SkipContextSensitive */ : + contextualMapper ? 2 /* Inferential */ : 0 /* Normal */; + var result = checkExpression(node, checkMode); node.contextualType = saveContextualType; + node.contextualMapper = saveContextualMapper; return result; } - function checkExpressionCached(node, contextualMapper) { + function checkExpressionCached(node, checkMode) { var links = getNodeLinks(node); if (!links.resolvedType) { // When computing a type that we're going to cache, we need to ignore any ongoing control flow @@ -39333,17 +41052,17 @@ var ts; // to the top of the stack ensures all transient types are computed from a known point. var saveFlowLoopStart = flowLoopStart; flowLoopStart = flowLoopCount; - links.resolvedType = checkExpression(node, contextualMapper); + links.resolvedType = checkExpression(node, checkMode); flowLoopStart = saveFlowLoopStart; } return links.resolvedType; } function isTypeAssertion(node) { node = ts.skipParentheses(node); - return node.kind === 183 /* TypeAssertionExpression */ || node.kind === 201 /* AsExpression */; + return node.kind === 184 /* TypeAssertionExpression */ || node.kind === 202 /* AsExpression */; } function checkDeclarationInitializer(declaration) { - var type = checkExpressionCached(declaration.initializer); + var type = getTypeOfExpression(declaration.initializer, /*cache*/ true); return ts.getCombinedNodeFlags(declaration) & 2 /* Const */ || ts.getCombinedModifierFlags(declaration) & 64 /* Readonly */ && !ts.isParameterPropertyDeclaration(declaration) || isTypeAssertion(declaration.initializer) ? type : getWidenedLiteralType(type); @@ -39364,52 +41083,56 @@ var ts; } return false; } - function checkExpressionForMutableLocation(node, contextualMapper) { - var type = checkExpression(node, contextualMapper); + function checkExpressionForMutableLocation(node, checkMode) { + var type = checkExpression(node, checkMode); return isTypeAssertion(node) || isLiteralContextualType(getContextualType(node)) ? type : getWidenedLiteralType(type); } - function checkPropertyAssignment(node, contextualMapper) { + function checkPropertyAssignment(node, checkMode) { // 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 === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - return checkExpressionForMutableLocation(node.initializer, contextualMapper); + return checkExpressionForMutableLocation(node.initializer, checkMode); } - function checkObjectLiteralMethod(node, contextualMapper) { + function checkObjectLiteralMethod(node, checkMode) { // Grammar checking checkGrammarMethod(node); // 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 === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); } - var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } - function instantiateTypeWithSingleGenericCallSignature(node, type, contextualMapper) { - if (isInferentialContext(contextualMapper)) { + function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) { + if (checkMode === 2 /* Inferential */) { var signature = getSingleCallSignature(type); if (signature && signature.typeParameters) { var contextualType = getApparentTypeOfContextualType(node); if (contextualType) { var contextualSignature = getSingleCallSignature(contextualType); if (contextualSignature && !contextualSignature.typeParameters) { - return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, contextualMapper)); + return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, getContextualMapper(node))); } } } } return type; } - // Returns the type of an expression. Unlike checkExpression, this function is simply concerned - // with computing the type and may not fully check all contained sub-expressions for errors. - function getTypeOfExpression(node) { + /** + * Returns the type of an expression. Unlike checkExpression, this function is simply concerned + * with computing the type and may not fully check all contained sub-expressions for errors. + * A cache argument of true indicates that if the function performs a full type check, it is ok + * to cache the result. + */ + function getTypeOfExpression(node, cache) { // Optimize for the common case of a call to a function with a single non-generic call // signature where we can just fetch the return type without checking the arguments. - if (node.kind === 180 /* CallExpression */ && node.expression.kind !== 96 /* SuperKeyword */) { + if (node.kind === 181 /* CallExpression */ && node.expression.kind !== 97 /* SuperKeyword */ && !ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { var funcType = checkNonNullExpression(node.expression); var signature = getSingleCallSignature(funcType); if (signature && !signature.typeParameters) { @@ -39419,7 +41142,21 @@ var ts; // Otherwise simply call checkExpression. Ideally, the entire family of checkXXX functions // should have a parameter that indicates whether full error checking is required such that // we can perform the optimizations locally. - return checkExpression(node); + return cache ? checkExpressionCached(node) : checkExpression(node); + } + /** + * Returns the type of an expression. Unlike checkExpression, this function is simply concerned + * with computing the type and may not fully check all contained sub-expressions for errors. + * It is intended for uses where you know there is no contextual type, + * and requesting the contextual type might cause a circularity or other bad behaviour. + * It sets the contextual type of the node to any before calling getTypeOfExpression. + */ + function getContextFreeTypeOfExpression(node) { + var saveContextualType = node.contextualType; + node.contextualType = anyType; + var type = getTypeOfExpression(node); + node.contextualType = saveContextualType; + return type; } // Checks an expression and returns its type. The contextualMapper parameter serves two purposes: When // contextualMapper is not undefined and not equal to the identityMapper function object it indicates that the @@ -39428,108 +41165,108 @@ var ts; // object, it serves as an indicator that all contained function and arrow expressions should be considered to // have the wildcard function type; this form of type check is used during overload resolution to exclude // contextually typed function and arrow expressions in the initial phase. - function checkExpression(node, contextualMapper) { + function checkExpression(node, checkMode) { var type; - if (node.kind === 142 /* QualifiedName */) { + if (node.kind === 143 /* QualifiedName */) { type = checkQualifiedName(node); } else { - var uninstantiatedType = checkExpressionWorker(node, contextualMapper); - type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, contextualMapper); + var uninstantiatedType = checkExpressionWorker(node, checkMode); + type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode); } if (isConstEnumObjectType(type)) { // enum object type for const enums are only permitted in: // - 'left' in property access // - 'object' in indexed access // - target in rhs of import statement - var ok = (node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.expression === node) || - (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.expression === node) || - ((node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */) && isInRightSideOfImportOrExportAssignment(node)); + var ok = (node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.expression === node) || + (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.expression === node) || + ((node.kind === 71 /* Identifier */ || node.kind === 143 /* 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); } } return type; } - function checkExpressionWorker(node, contextualMapper) { + function checkExpressionWorker(node, checkMode) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return checkIdentifier(node); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return checkThisExpression(node); - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: return checkSuperExpression(node); - case 94 /* NullKeyword */: + case 95 /* NullKeyword */: return nullWideningType; case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return checkLiteralExpression(node); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return checkTemplateExpression(node); - case 12 /* NoSubstitutionTemplateLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return stringType; - case 11 /* RegularExpressionLiteral */: + case 12 /* RegularExpressionLiteral */: return globalRegExpType; - case 176 /* ArrayLiteralExpression */: - return checkArrayLiteral(node, contextualMapper); - case 177 /* ObjectLiteralExpression */: - return checkObjectLiteral(node, contextualMapper); - case 178 /* PropertyAccessExpression */: + case 177 /* ArrayLiteralExpression */: + return checkArrayLiteral(node, checkMode); + case 178 /* ObjectLiteralExpression */: + return checkObjectLiteral(node, checkMode); + case 179 /* PropertyAccessExpression */: return checkPropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return checkIndexedAccess(node); - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: return checkCallExpression(node); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return checkTaggedTemplateExpression(node); - case 184 /* ParenthesizedExpression */: - return checkExpression(node.expression, contextualMapper); - case 198 /* ClassExpression */: + case 185 /* ParenthesizedExpression */: + return checkExpression(node.expression, checkMode); + case 199 /* ClassExpression */: return checkClassExpression(node); - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - return checkFunctionExpressionOrObjectLiteralMethod(node, contextualMapper); - case 188 /* TypeOfExpression */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode); + case 189 /* TypeOfExpression */: return checkTypeOfExpression(node); - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: return checkAssertion(node); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return checkNonNullAssertion(node); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return checkMetaProperty(node); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return checkDeleteExpression(node); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return checkVoidExpression(node); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return checkAwaitExpression(node); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return checkPrefixUnaryExpression(node); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return checkPostfixUnaryExpression(node); - case 193 /* BinaryExpression */: - return checkBinaryExpression(node, contextualMapper); - case 194 /* ConditionalExpression */: - return checkConditionalExpression(node, contextualMapper); - case 197 /* SpreadElement */: - return checkSpreadExpression(node, contextualMapper); - case 199 /* OmittedExpression */: + case 194 /* BinaryExpression */: + return checkBinaryExpression(node, checkMode); + case 195 /* ConditionalExpression */: + return checkConditionalExpression(node, checkMode); + case 198 /* SpreadElement */: + return checkSpreadExpression(node, checkMode); + case 200 /* OmittedExpression */: return undefinedWideningType; - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return checkYieldExpression(node); - case 255 /* JsxExpression */: - return checkJsxExpression(node, contextualMapper); - case 248 /* JsxElement */: + case 256 /* JsxExpression */: + return checkJsxExpression(node, checkMode); + case 249 /* JsxElement */: return checkJsxElement(node); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return checkJsxSelfClosingElement(node); - case 253 /* JsxAttributes */: - return checkJsxAttributes(node, contextualMapper); - case 250 /* JsxOpeningElement */: + case 254 /* JsxAttributes */: + return checkJsxAttributes(node, checkMode); + case 251 /* JsxOpeningElement */: ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement"); } return unknownType; @@ -39566,7 +41303,7 @@ var ts; var func = ts.getContainingFunction(node); if (ts.getModifierFlags(node) & 92 /* ParameterPropertyModifier */) { func = ts.getContainingFunction(node); - if (!(func.kind === 151 /* Constructor */ && ts.nodeIsPresent(func.body))) { + if (!(func.kind === 152 /* Constructor */ && ts.nodeIsPresent(func.body))) { error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation); } } @@ -39577,7 +41314,7 @@ var ts; if (ts.indexOf(func.parameters, node) !== 0) { error(node, ts.Diagnostics.A_this_parameter_must_be_the_first_parameter); } - if (func.kind === 151 /* Constructor */ || func.kind === 155 /* ConstructSignature */ || func.kind === 160 /* ConstructorType */) { + if (func.kind === 152 /* Constructor */ || func.kind === 156 /* ConstructSignature */ || func.kind === 161 /* ConstructorType */) { error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter); } } @@ -39587,19 +41324,11 @@ var ts; error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type); } } - function isSyntacticallyValidGenerator(node) { - if (!node.asteriskToken || !node.body) { - return false; - } - return node.kind === 150 /* MethodDeclaration */ || - node.kind === 227 /* FunctionDeclaration */ || - node.kind === 185 /* FunctionExpression */; - } function getTypePredicateParameterIndex(parameterList, parameter) { if (parameterList) { for (var i = 0; i < parameterList.length; i++) { var param = parameterList[i]; - if (param.name.kind === 70 /* Identifier */ && + if (param.name.kind === 71 /* Identifier */ && param.name.text === parameter.text) { return i; } @@ -39628,7 +41357,7 @@ var ts; error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter); } else { - var leadingError = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); + var leadingError = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); checkTypeAssignableTo(typePredicate.type, getTypeOfNode(parent.parameters[typePredicate.parameterIndex]), node.type, /*headMessage*/ undefined, leadingError); } @@ -39651,13 +41380,13 @@ var ts; } function getTypePredicateParent(node) { switch (node.parent.kind) { - case 186 /* ArrowFunction */: - case 154 /* CallSignature */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 159 /* FunctionType */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 187 /* ArrowFunction */: + case 155 /* CallSignature */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 160 /* FunctionType */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: var parent = node.parent; if (node === parent.type) { return parent; @@ -39671,13 +41400,13 @@ var ts; continue; } var name = element.name; - if (name.kind === 70 /* Identifier */ && + if (name.kind === 71 /* Identifier */ && name.text === predicateVariableName) { error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName); return true; } - else if (name.kind === 174 /* ArrayBindingPattern */ || - name.kind === 173 /* ObjectBindingPattern */) { + else if (name.kind === 175 /* ArrayBindingPattern */ || + name.kind === 174 /* ObjectBindingPattern */) { if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) { return true; } @@ -39686,20 +41415,29 @@ var ts; } function checkSignatureDeclaration(node) { // Grammar checking - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { checkGrammarIndexSignature(node); } - else if (node.kind === 159 /* FunctionType */ || node.kind === 227 /* FunctionDeclaration */ || node.kind === 160 /* ConstructorType */ || - node.kind === 154 /* CallSignature */ || node.kind === 151 /* Constructor */ || - node.kind === 155 /* ConstructSignature */) { + else if (node.kind === 160 /* FunctionType */ || node.kind === 228 /* FunctionDeclaration */ || node.kind === 161 /* ConstructorType */ || + node.kind === 155 /* CallSignature */ || node.kind === 152 /* Constructor */ || + node.kind === 156 /* ConstructSignature */) { checkGrammarFunctionLikeDeclaration(node); } - if (ts.isAsyncFunctionLike(node) && languageVersion < 4 /* ES2017 */) { + var functionFlags = ts.getFunctionFlags(node); + if ((functionFlags & 7 /* InvalidAsyncOrAsyncGenerator */) === 2 /* Async */ && languageVersion < 4 /* ES2017 */) { checkExternalEmitHelpers(node, 64 /* Awaiter */); if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(node, 128 /* Generator */); } } + if ((functionFlags & 5 /* InvalidGenerator */) === 1 /* Generator */) { + if (functionFlags & 2 /* Async */ && languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 2048 /* AsyncGenerator */); + } + else if (languageVersion < 2 /* ES2015 */) { + checkExternalEmitHelpers(node, 128 /* Generator */); + } + } checkTypeParameters(node.typeParameters); ts.forEach(node.parameters, checkParameter); if (node.type) { @@ -39707,25 +41445,28 @@ var ts; } if (produceDiagnostics) { checkCollisionWithArgumentsInGeneratedCode(node); - if (compilerOptions.noImplicitAny && !node.type) { + if (noImplicitAny && !node.type) { switch (node.kind) { - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; - case 154 /* CallSignature */: + case 155 /* CallSignature */: error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type); break; } } if (node.type) { - if (languageVersion >= 2 /* ES2015 */ && isSyntacticallyValidGenerator(node)) { + var functionFlags_1 = ts.getFunctionFlags(node); + if ((functionFlags_1 & 5 /* InvalidGenerator */) === 1 /* Generator */) { var returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation); } else { - var generatorElementType = getElementTypeOfIterableIterator(returnType) || anyType; - var iterableIteratorInstantiation = createIterableIteratorType(generatorElementType); + var generatorElementType = getIteratedTypeOfGenerator(returnType, (functionFlags_1 & 2 /* Async */) !== 0) || anyType; + var iterableIteratorInstantiation = functionFlags_1 & 2 /* Async */ + ? createAsyncIterableIteratorType(generatorElementType) // AsyncGenerator function + : createIterableIteratorType(generatorElementType); // Generator function // Naively, one could check that IterableIterator is assignable to the return type annotation. // However, that would not catch the error in the following case. // @@ -39735,7 +41476,7 @@ var ts; checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if (ts.isAsyncFunctionLike(node)) { + else if ((functionFlags_1 & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */) { checkAsyncFunctionReturnType(node); } } @@ -39756,7 +41497,7 @@ var ts; var staticNames = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* Constructor */) { + if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var param = _c[_b]; if (ts.isParameterPropertyDeclaration(param)) { @@ -39770,16 +41511,16 @@ var ts; var memberName = member.name && ts.getPropertyNameForPropertyNameNode(member.name); if (memberName) { switch (member.kind) { - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: addName(names, member.name, memberName, 1 /* Getter */); break; - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: addName(names, member.name, memberName, 2 /* Setter */); break; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: addName(names, member.name, memberName, 3 /* Property */); break; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: addName(names, member.name, memberName, 4 /* Method */); break; } @@ -39842,12 +41583,12 @@ var ts; var names = ts.createMap(); for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind == 147 /* PropertySignature */) { + if (member.kind === 148 /* PropertySignature */) { var memberName = void 0; switch (member.name.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - case 70 /* Identifier */: + case 71 /* Identifier */: memberName = member.name.text; break; default: @@ -39864,7 +41605,7 @@ var ts; } } function checkTypeForDuplicateIndexSignatures(node) { - if (node.kind === 229 /* InterfaceDeclaration */) { + if (node.kind === 230 /* 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 @@ -39884,7 +41625,7 @@ var ts; var declaration = decl; if (declaration.parameters.length === 1 && declaration.parameters[0].type) { switch (declaration.parameters[0].type.kind) { - case 135 /* StringKeyword */: + case 136 /* StringKeyword */: if (!seenStringIndexer) { seenStringIndexer = true; } @@ -39892,7 +41633,7 @@ var ts; error(declaration, ts.Diagnostics.Duplicate_string_index_signature); } break; - case 132 /* NumberKeyword */: + case 133 /* NumberKeyword */: if (!seenNumericIndexer) { seenNumericIndexer = true; } @@ -39957,15 +41698,15 @@ var ts; return ts.forEachChild(n, containsSuperCall); } function markThisReferencesAsErrors(n) { - if (n.kind === 98 /* ThisKeyword */) { + if (n.kind === 99 /* ThisKeyword */) { error(n, ts.Diagnostics.this_cannot_be_referenced_in_current_location); } - else if (n.kind !== 185 /* FunctionExpression */ && n.kind !== 227 /* FunctionDeclaration */) { + else if (n.kind !== 186 /* FunctionExpression */ && n.kind !== 228 /* FunctionDeclaration */) { ts.forEachChild(n, markThisReferencesAsErrors); } } function isInstancePropertyWithInitializer(n) { - return n.kind === 148 /* PropertyDeclaration */ && + return n.kind === 149 /* PropertyDeclaration */ && !(ts.getModifierFlags(n) & 32 /* Static */) && !!n.initializer; } @@ -39995,7 +41736,7 @@ var ts; var superCallStatement = void 0; for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) { var statement = statements_3[_i]; - if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { superCallStatement = statement; break; } @@ -40019,7 +41760,7 @@ var ts; checkGrammarFunctionLikeDeclaration(node) || checkGrammarAccessor(node) || checkGrammarComputedPropertyName(node.name); checkDecorators(node); checkSignatureDeclaration(node); - if (node.kind === 152 /* GetAccessor */) { + if (node.kind === 153 /* GetAccessor */) { if (!ts.isInAmbientContext(node) && ts.nodeIsPresent(node.body) && (node.flags & 128 /* HasImplicitReturn */)) { if (!(node.flags & 256 /* HasExplicitReturn */)) { error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value); @@ -40029,13 +41770,13 @@ var ts; // Do not use hasDynamicName here, because that returns false for well known symbols. // We want to perform checkComputedPropertyName for all computed properties, including // well known symbols. - if (node.name.kind === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* 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 === 152 /* GetAccessor */ ? 153 /* SetAccessor */ : 152 /* GetAccessor */; + var otherKind = node.kind === 153 /* GetAccessor */ ? 154 /* SetAccessor */ : 153 /* GetAccessor */; var otherAccessor = ts.getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((ts.getModifierFlags(node) & 28 /* AccessibilityModifier */) !== (ts.getModifierFlags(otherAccessor) & 28 /* AccessibilityModifier */)) { @@ -40051,17 +41792,12 @@ var ts; } } var returnType = getTypeOfAccessors(getSymbolOfNode(node)); - if (node.kind === 152 /* GetAccessor */) { + if (node.kind === 153 /* GetAccessor */) { checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType); } } - if (node.parent.kind !== 177 /* ObjectLiteralExpression */) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } - else { - checkNodeDeferred(node); - } + checkSourceElement(node.body); + registerForUnusedIdentifiersCheck(node); } function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) { var firstType = getAnnotatedType(first); @@ -40070,10 +41806,6 @@ var ts; error(first, message); } } - function checkAccessorDeferred(node) { - checkSourceElement(node.body); - registerForUnusedIdentifiersCheck(node); - } function checkMissingDeclaration(node) { checkDecorators(node); } @@ -40177,9 +41909,9 @@ var ts; var flags = ts.getCombinedModifierFlags(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 !== 229 /* InterfaceDeclaration */ && - n.parent.kind !== 228 /* ClassDeclaration */ && - n.parent.kind !== 198 /* ClassExpression */ && + if (n.parent.kind !== 230 /* InterfaceDeclaration */ && + n.parent.kind !== 229 /* ClassDeclaration */ && + n.parent.kind !== 199 /* ClassExpression */ && ts.isInAmbientContext(n)) { if (!(flags & 2 /* Ambient */)) { // It is nested in an ambient context, which means it is automatically exported @@ -40267,7 +41999,7 @@ var ts; var errorNode_1 = subsequentNode.name || subsequentNode; // TODO(jfreeman): These are methods, so handle computed name case if (node.name && subsequentNode.name && node.name.text === subsequentNode.name.text) { - var reportError = (node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */) && + var reportError = (node.kind === 151 /* MethodDeclaration */ || node.kind === 150 /* MethodSignature */) && (ts.getModifierFlags(node) & 32 /* Static */) !== (ts.getModifierFlags(subsequentNode) & 32 /* Static */); // we can get here in two cases // 1. mixed static and instance class members @@ -40306,7 +42038,7 @@ var ts; var current = declarations_5[_i]; var node = current; var inAmbientContext = ts.isInAmbientContext(node); - var inAmbientContextOrInterface = node.parent.kind === 229 /* InterfaceDeclaration */ || node.parent.kind === 162 /* TypeLiteral */ || inAmbientContext; + var inAmbientContextOrInterface = node.parent.kind === 230 /* InterfaceDeclaration */ || node.parent.kind === 163 /* TypeLiteral */ || inAmbientContext; if (inAmbientContextOrInterface) { // check if declarations are consecutive only if they are non-ambient // 1. ambient declarations can be interleaved @@ -40317,7 +42049,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 === 227 /* FunctionDeclaration */ || node.kind === 150 /* MethodDeclaration */ || node.kind === 149 /* MethodSignature */ || node.kind === 151 /* Constructor */) { + if (node.kind === 228 /* FunctionDeclaration */ || node.kind === 151 /* MethodDeclaration */ || node.kind === 150 /* MethodSignature */ || node.kind === 152 /* Constructor */) { var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck); someNodeFlags |= currentNodeFlags; allNodeFlags &= currentNodeFlags; @@ -40369,8 +42101,8 @@ var ts; if (bodyDeclaration) { var signatures = getSignaturesOfSymbol(symbol); var bodySignature = getSignatureFromDeclaration(bodyDeclaration); - for (var _a = 0, signatures_3 = signatures; _a < signatures_3.length; _a++) { - var signature = signatures_3[_a]; + for (var _a = 0, signatures_4 = signatures; _a < signatures_4.length; _a++) { + var signature = signatures_4[_a]; if (!isImplementationCompatibleWithOverload(bodySignature, signature)) { error(signature.declaration, ts.Diagnostics.Overload_signature_is_not_compatible_with_function_implementation); break; @@ -40439,16 +42171,16 @@ var ts; } function getDeclarationSpaces(d) { switch (d.kind) { - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return 2097152 /* ExportType */; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0 /* NonInstantiated */ ? 4194304 /* ExportNamespace */ | 1048576 /* ExportValue */ : 4194304 /* ExportNamespace */; - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: return 2097152 /* ExportType */ | 1048576 /* ExportValue */; - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: var result_3 = 0; var target = resolveAlias(getSymbolOfNode(d)); ts.forEach(target.declarations, function (d) { result_3 |= getDeclarationSpaces(d); }); @@ -40458,26 +42190,16 @@ var ts; } } } - function checkNonThenableType(type, location, message) { - type = getWidenedType(type); - var apparentType = getApparentType(type); - if ((apparentType.flags & (1 /* Any */ | 8192 /* Never */)) === 0 && isTypeAssignableTo(type, getGlobalThenableType())) { - if (location) { - if (!message) { - message = ts.Diagnostics.Operand_for_await_does_not_have_a_valid_callable_then_member; - } - error(location, message); - } - return unknownType; - } - return type; + function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage) { + var promisedType = getPromisedTypeOfPromise(type, errorNode); + return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage); } /** - * Gets the "promised type" of a promise. - * @param type The type of the promise. - * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. - */ - function getPromisedType(promise) { + * Gets the "promised type" of a promise. + * @param type The type of the promise. + * @remarks The "promised type" of a type is the type of the "value" parameter of the "onfulfilled" callback. + */ + function getPromisedTypeOfPromise(promise, errorNode) { // // { // promise // then( // thenFunction @@ -40490,22 +42212,22 @@ var ts; if (isTypeAny(promise)) { return undefined; } - if (getObjectFlags(promise) & 4 /* Reference */) { - if (promise.target === tryGetGlobalPromiseType() - || promise.target === getGlobalPromiseLikeType()) { - return promise.typeArguments[0]; - } + var typeAsPromise = promise; + if (typeAsPromise.promisedTypeOfPromise) { + return typeAsPromise.promisedTypeOfPromise; } - var globalPromiseLikeType = getInstantiatedGlobalPromiseLikeType(); - if (globalPromiseLikeType === emptyObjectType || !isTypeAssignableTo(promise, globalPromiseLikeType)) { - return undefined; + if (isReferenceToType(promise, getGlobalPromiseType(/*reportErrors*/ false))) { + return typeAsPromise.promisedTypeOfPromise = promise.typeArguments[0]; } var thenFunction = getTypeOfPropertyOfType(promise, "then"); - if (!thenFunction || isTypeAny(thenFunction)) { + if (isTypeAny(thenFunction)) { return undefined; } - var thenSignatures = getSignaturesOfType(thenFunction, 0 /* Call */); + var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0 /* Call */) : emptyArray; if (thenSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method); + } return undefined; } var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 524288 /* NEUndefinedOrNull */); @@ -40514,103 +42236,116 @@ var ts; } var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0 /* Call */); if (onfulfilledParameterSignatures.length === 0) { + if (errorNode) { + error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback); + } return undefined; } - return getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true); - } - function getTypeOfFirstParameterOfSignature(signature) { - return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : neverType; + return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), /*subtypeReduction*/ true); } /** - * Gets the "awaited type" of a type. - * @param type The type to await. - * @remarks The "awaited type" of an expression is its "promised type" if the expression is a - * Promise-like type; otherwise, it is the type of the expression. This is used to reflect - * The runtime behavior of the `await` keyword. - */ - function getAwaitedType(type) { - return checkAwaitedType(type, /*location*/ undefined, /*message*/ undefined); + * Gets the "awaited type" of a type. + * @param type The type to await. + * @remarks The "awaited type" of an expression is its "promised type" if the expression is a + * Promise-like type; otherwise, it is the type of the expression. This is used to reflect + * The runtime behavior of the `await` keyword. + */ + function checkAwaitedType(type, errorNode, diagnosticMessage) { + return getAwaitedType(type, errorNode, diagnosticMessage) || unknownType; } - function checkAwaitedType(type, location, message) { - return checkAwaitedTypeWorker(type); - function checkAwaitedTypeWorker(type) { - if (type.flags & 65536 /* Union */) { - var types = []; - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var constituentType = _a[_i]; - types.push(checkAwaitedTypeWorker(constituentType)); - } - return getUnionType(types, /*subtypeReduction*/ true); - } - else { - var promisedType = getPromisedType(type); - if (promisedType === undefined) { - // The type was not a PromiseLike, so it could not be unwrapped any further. - // As long as the type does not have a callable "then" property, it is - // safe to return the type; otherwise, an error will have been reported in - // the call to checkNonThenableType and we will return unknownType. - // - // An example of a non-promise "thenable" might be: - // - // await { then(): void {} } - // - // The "thenable" does not match the minimal definition for a PromiseLike. When - // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise - // will never settle. We treat this as an error to help flag an early indicator - // of a runtime problem. If the user wants to return this value from an async - // function, they would need to wrap it in some other value. If they want it to - // be treated as a promise, they can cast to . - return checkNonThenableType(type, location, message); - } - else { - if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { - // We have a bad actor in the form of a promise whose promised type is - // the same promise type, or a mutually recursive promise. Return the - // unknown type as we cannot guess the shape. If this were the actual - // case in the JavaScript, this Promise would never resolve. - // - // An example of a bad actor with a singly-recursive promise type might - // be: - // - // interface BadPromise { - // then( - // onfulfilled: (value: BadPromise) => any, - // onrejected: (error: any) => any): BadPromise; - // } - // - // The above interface will pass the PromiseLike check, and return a - // promised type of `BadPromise`. Since this is a self reference, we - // don't want to keep recursing ad infinitum. - // - // An example of a bad actor in the form of a mutually-recursive - // promise type might be: - // - // interface BadPromiseA { - // then( - // onfulfilled: (value: BadPromiseB) => any, - // onrejected: (error: any) => any): BadPromiseB; - // } - // - // interface BadPromiseB { - // then( - // onfulfilled: (value: BadPromiseA) => any, - // onrejected: (error: any) => any): BadPromiseA; - // } - // - if (location) { - error(location, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method, symbolToString(type.symbol)); - } - return unknownType; - } - // Keep track of the type we're about to unwrap to avoid bad recursive promise types. - // See the comments above for more information. - awaitedTypeStack.push(type.id); - var awaitedType = checkAwaitedTypeWorker(promisedType); - awaitedTypeStack.pop(); - return awaitedType; - } - } + function getAwaitedType(type, errorNode, diagnosticMessage) { + var typeAsAwaitable = type; + if (typeAsAwaitable.awaitedTypeOfType) { + return typeAsAwaitable.awaitedTypeOfType; } + if (isTypeAny(type)) { + return typeAsAwaitable.awaitedTypeOfType = type; + } + if (type.flags & 65536 /* Union */) { + var types = void 0; + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var constituentType = _a[_i]; + types = ts.append(types, getAwaitedType(constituentType, errorNode, diagnosticMessage)); + } + if (!types) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = getUnionType(types, /*subtypeReduction*/ true); + } + var promisedType = getPromisedTypeOfPromise(type); + if (promisedType) { + if (type.id === promisedType.id || ts.indexOf(awaitedTypeStack, promisedType.id) >= 0) { + // Verify that we don't have a bad actor in the form of a promise whose + // promised type is the same as the promise type, or a mutually recursive + // promise. If so, we return undefined as we cannot guess the shape. If this + // were the actual case in the JavaScript, this Promise would never resolve. + // + // An example of a bad actor with a singly-recursive promise type might + // be: + // + // interface BadPromise { + // then( + // onfulfilled: (value: BadPromise) => any, + // onrejected: (error: any) => any): BadPromise; + // } + // The above interface will pass the PromiseLike check, and return a + // promised type of `BadPromise`. Since this is a self reference, we + // don't want to keep recursing ad infinitum. + // + // An example of a bad actor in the form of a mutually-recursive + // promise type might be: + // + // interface BadPromiseA { + // then( + // onfulfilled: (value: BadPromiseB) => any, + // onrejected: (error: any) => any): BadPromiseB; + // } + // + // interface BadPromiseB { + // then( + // onfulfilled: (value: BadPromiseA) => any, + // onrejected: (error: any) => any): BadPromiseA; + // } + // + if (errorNode) { + error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method); + } + return undefined; + } + // Keep track of the type we're about to unwrap to avoid bad recursive promise types. + // See the comments above for more information. + awaitedTypeStack.push(type.id); + var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage); + awaitedTypeStack.pop(); + if (!awaitedType) { + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = awaitedType; + } + // The type was not a promise, so it could not be unwrapped any further. + // As long as the type does not have a callable "then" property, it is + // safe to return the type; otherwise, an error will be reported in + // the call to getNonThenableType and we will return undefined. + // + // An example of a non-promise "thenable" might be: + // + // await { then(): void {} } + // + // The "thenable" does not match the minimal definition for a promise. When + // a Promise/A+-compatible or ES6 promise tries to adopt this value, the promise + // will never settle. We treat this as an error to help flag an early indicator + // of a runtime problem. If the user wants to return this value from an async + // function, they would need to wrap it in some other value. If they want it to + // be treated as a promise, they can cast to . + var thenFunction = getTypeOfPropertyOfType(type, "then"); + if (thenFunction && getSignaturesOfType(thenFunction, 0 /* Call */).length > 0) { + if (errorNode) { + ts.Debug.assert(!!diagnosticMessage); + error(errorNode, diagnosticMessage); + } + return undefined; + } + return typeAsAwaitable.awaitedTypeOfType = type; } /** * Checks the return type of an async function to ensure it is a compatible @@ -40655,8 +42390,8 @@ var ts; if (returnType === unknownType) { return unknownType; } - var globalPromiseType = getGlobalPromiseType(); - if (globalPromiseType !== emptyGenericType && globalPromiseType !== getTargetType(returnType)) { + var globalPromiseType = getGlobalPromiseType(/*reportErrors*/ true); + if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) { // 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(node.type, ts.Diagnostics.The_return_type_of_an_async_function_or_method_must_be_the_global_Promise_T_type); @@ -40677,7 +42412,7 @@ var ts; var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 107455 /* Value */, /*ignoreErrors*/ true); var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : unknownType; if (promiseConstructorType === unknownType) { - if (promiseConstructorName.kind === 70 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === tryGetGlobalPromiseType()) { + if (promiseConstructorName.kind === 71 /* Identifier */ && promiseConstructorName.text === "Promise" && getTargetType(returnType) === getGlobalPromiseType(/*reportErrors*/ false)) { error(node.type, ts.Diagnostics.An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option); } else { @@ -40685,7 +42420,7 @@ var ts; } return unknownType; } - var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(); + var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(/*reportErrors*/ true); if (globalPromiseConstructorLikeType === emptyObjectType) { // If we couldn't resolve the global PromiseConstructorLike type we cannot verify // compatibility with __awaiter. @@ -40704,7 +42439,7 @@ var ts; } } // Get and return the awaited type of the return type. - return checkAwaitedType(returnType, node, ts.Diagnostics.An_async_function_or_method_must_have_a_valid_awaitable_return_type); + return checkAwaitedType(returnType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); } /** Check a decorator */ function checkDecorator(node) { @@ -40717,22 +42452,22 @@ var ts; var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node); var errorInfo; switch (node.parent.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: var classSymbol = getSymbolOfNode(node.parent); var classConstructorType = getTypeOfSymbol(classSymbol); expectedReturnType = getUnionType([classConstructorType, voidType]); break; - case 145 /* Parameter */: + case 146 /* 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 148 /* PropertyDeclaration */: + case 149 /* 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 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: var methodType = getTypeOfNode(node.parent); var descriptorType = createTypedPropertyDescriptorType(methodType); expectedReturnType = getUnionType([descriptorType, voidType]); @@ -40747,7 +42482,7 @@ var ts; function markTypeNodeAsReferenced(node) { var typeName = node && ts.getEntityNameFromTypeNode(node); var rootName = typeName && getFirstIdentifier(typeName); - var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 70 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); + var rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === 71 /* Identifier */ ? 793064 /* Type */ : 1920 /* Namespace */) | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (rootSymbol && rootSymbol.flags & 8388608 /* Alias */ && symbolIsValue(rootSymbol) @@ -40773,14 +42508,14 @@ var ts; } var firstDecorator = node.decorators[0]; checkExternalEmitHelpers(firstDecorator, 8 /* Decorate */); - if (node.kind === 145 /* Parameter */) { + if (node.kind === 146 /* Parameter */) { checkExternalEmitHelpers(firstDecorator, 32 /* Param */); } if (compilerOptions.emitDecoratorMetadata) { checkExternalEmitHelpers(firstDecorator, 16 /* Metadata */); // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: var constructor = ts.getFirstConstructorWithBody(node); if (constructor) { for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) { @@ -40789,19 +42524,19 @@ var ts; } } break; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } markTypeNodeAsReferenced(node.type); break; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; - case 145 /* Parameter */: + case 146 /* Parameter */: markTypeNodeAsReferenced(node.type); break; } @@ -40821,11 +42556,11 @@ var ts; function checkFunctionOrMethodDeclaration(node) { checkDecorators(node); checkSignatureDeclaration(node); - var isAsync = ts.isAsyncFunctionLike(node); + var functionFlags = ts.getFunctionFlags(node); // 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 === 143 /* ComputedPropertyName */) { + if (node.name && node.name.kind === 144 /* ComputedPropertyName */) { // This check will account for methods in class/interface declarations, // as well as accessors in classes/object literals checkComputedPropertyName(node.name); @@ -40856,17 +42591,19 @@ var ts; } } checkSourceElement(node.body); - if (!node.asteriskToken) { - var returnOrPromisedType = node.type && (isAsync ? checkAsyncFunctionReturnType(node) : getTypeFromTypeNode(node.type)); + if ((functionFlags & 1 /* Generator */) === 0) { + var returnOrPromisedType = node.type && (functionFlags & 2 /* Async */ + ? checkAsyncFunctionReturnType(node) // Async function + : getTypeFromTypeNode(node.type)); // normal function checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnOrPromisedType); } if (produceDiagnostics && !node.type) { // Report an implicit any error if there is no body, no explicit return type, and node is not a private method // in an ambient context - if (compilerOptions.noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { + if (noImplicitAny && ts.nodeIsMissing(node.body) && !isPrivateWithinAmbient(node)) { reportImplicitAnyError(node, anyType); } - if (node.asteriskToken && ts.nodeIsPresent(node.body)) { + if (functionFlags & 1 /* Generator */ && ts.nodeIsPresent(node.body)) { // A generator with a body and no type annotation can still cause errors. It can error if the // yielded values have no common supertype, or it can give an implicit any error if it has no // yielded values. The only way to trigger these errors is to try checking its return type. @@ -40885,55 +42622,54 @@ var ts; for (var _i = 0, deferredUnusedIdentifierNodes_1 = deferredUnusedIdentifierNodes; _i < deferredUnusedIdentifierNodes_1.length; _i++) { var node = deferredUnusedIdentifierNodes_1[_i]; switch (node.kind) { - case 264 /* SourceFile */: - case 232 /* ModuleDeclaration */: + case 265 /* SourceFile */: + case 233 /* ModuleDeclaration */: checkUnusedModuleMembers(node); break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: checkUnusedClassMembers(node); checkUnusedTypeParameters(node); break; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: checkUnusedTypeParameters(node); break; - case 206 /* Block */: - case 234 /* CaseBlock */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 207 /* Block */: + case 235 /* CaseBlock */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: checkUnusedLocalsAndParameters(node); break; - case 151 /* Constructor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 152 /* Constructor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: if (node.body) { checkUnusedLocalsAndParameters(node); } checkUnusedTypeParameters(node); break; - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 157 /* IndexSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: checkUnusedTypeParameters(node); break; } - ; } } } function checkUnusedLocalsAndParameters(node) { - if (node.parent.kind !== 229 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { + if (node.parent.kind !== 230 /* InterfaceDeclaration */ && noUnusedIdentifiers && !ts.isInAmbientContext(node)) { node.locals.forEach(function (local) { if (!local.isReferenced) { - if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 145 /* Parameter */) { + if (local.valueDeclaration && ts.getRootDeclaration(local.valueDeclaration).kind === 146 /* Parameter */) { var parameter = ts.getRootDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !ts.isParameterPropertyDeclaration(parameter) && @@ -40959,13 +42695,13 @@ var ts; function errorUnusedLocal(node, name) { if (isIdentifierThatStartsWithUnderScore(node)) { var declaration = ts.getRootDeclaration(node.parent); - if (declaration.kind === 225 /* VariableDeclaration */ && - (declaration.parent.parent.kind === 214 /* ForInStatement */ || - declaration.parent.parent.kind === 215 /* ForOfStatement */)) { + if (declaration.kind === 226 /* VariableDeclaration */ && + (declaration.parent.parent.kind === 215 /* ForInStatement */ || + declaration.parent.parent.kind === 216 /* ForOfStatement */)) { return; } } - if (!isRemovedPropertyFromObjectSpread(node.kind === 70 /* Identifier */ ? node.parent : node)) { + if (!isRemovedPropertyFromObjectSpread(node.kind === 71 /* Identifier */ ? node.parent : node)) { error(node, ts.Diagnostics._0_is_declared_but_never_used, name); } } @@ -40973,19 +42709,19 @@ var ts; return parameterName && isIdentifierThatStartsWithUnderScore(parameterName); } function isIdentifierThatStartsWithUnderScore(node) { - return node.kind === 70 /* Identifier */ && node.text.charCodeAt(0) === 95 /* _ */; + return node.kind === 71 /* Identifier */ && node.text.charCodeAt(0) === 95 /* _ */; } function checkUnusedClassMembers(node) { if (compilerOptions.noUnusedLocals && !ts.isInAmbientContext(node)) { if (node.members) { for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 150 /* MethodDeclaration */ || member.kind === 148 /* PropertyDeclaration */) { + if (member.kind === 151 /* MethodDeclaration */ || member.kind === 149 /* PropertyDeclaration */) { if (!member.symbol.isReferenced && ts.getModifierFlags(member) & 8 /* Private */) { error(member.name, ts.Diagnostics._0_is_declared_but_never_used, member.symbol.name); } } - else if (member.kind === 151 /* Constructor */) { + else if (member.kind === 152 /* Constructor */) { for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) { var parameter = _c[_b]; if (!parameter.symbol.isReferenced && ts.getModifierFlags(parameter) & 8 /* Private */) { @@ -41032,7 +42768,7 @@ var ts; } function checkBlock(node) { // Grammar checking for SyntaxKind.Block - if (node.kind === 206 /* Block */) { + if (node.kind === 207 /* Block */) { checkGrammarStatementInAmbientContext(node); } ts.forEach(node.statements, checkSourceElement); @@ -41055,12 +42791,12 @@ var ts; if (!(identifier && identifier.text === name)) { return false; } - if (node.kind === 148 /* PropertyDeclaration */ || - node.kind === 147 /* PropertySignature */ || - node.kind === 150 /* MethodDeclaration */ || - node.kind === 149 /* MethodSignature */ || - node.kind === 152 /* GetAccessor */ || - node.kind === 153 /* SetAccessor */) { + if (node.kind === 149 /* PropertyDeclaration */ || + node.kind === 148 /* PropertySignature */ || + node.kind === 151 /* MethodDeclaration */ || + node.kind === 150 /* MethodSignature */ || + node.kind === 153 /* GetAccessor */ || + node.kind === 154 /* SetAccessor */) { // it is ok to have member named '_super' or '_this' - member access is always qualified return false; } @@ -41069,7 +42805,7 @@ var ts; return false; } var root = ts.getRootDeclaration(node); - if (root.kind === 145 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { + if (root.kind === 146 /* Parameter */ && ts.nodeIsMissing(root.parent.body)) { // just an overload - no codegen impact return false; } @@ -41087,36 +42823,32 @@ var ts; } // this function will run after checking the source file so 'CaptureThis' is correct for all nodes function checkIfThisIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 4 /* CaptureThis */) { - var isDeclaration_1 = node.kind !== 70 /* Identifier */; + var isDeclaration_1 = node.kind !== 71 /* Identifier */; if (isDeclaration_1) { error(node.name, ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkIfNewTargetIsCapturedInEnclosingScope(node) { - var current = node; - while (current) { + ts.findAncestor(node, function (current) { if (getNodeCheckFlags(current) & 8 /* CaptureNewTarget */) { - var isDeclaration_2 = node.kind !== 70 /* Identifier */; + var isDeclaration_2 = node.kind !== 71 /* Identifier */; if (isDeclaration_2) { error(node.name, ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } else { error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); } - return; + return true; } - current = current.parent; - } + }); } function checkCollisionWithCapturedSuperVariable(node, name) { if (!needCollisionCheckForIdentifier(node, name, "_super")) { @@ -41129,7 +42861,7 @@ var ts; return; } if (ts.getClassExtendsHeritageClauseElement(enclosingClass)) { - var isDeclaration_3 = node.kind !== 70 /* Identifier */; + var isDeclaration_3 = node.kind !== 71 /* Identifier */; if (isDeclaration_3) { error(node, ts.Diagnostics.Duplicate_identifier_super_Compiler_uses_super_to_capture_base_class_reference); } @@ -41147,12 +42879,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 233 /* 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 === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent)) { + if (parent.kind === 265 /* 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)); } @@ -41162,12 +42894,12 @@ var ts; return; } // Uninstantiated modules shouldnt do this check - if (node.kind === 232 /* ModuleDeclaration */ && ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { + if (node.kind === 233 /* 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 === 264 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* HasAsyncFunctions */) { + if (parent.kind === 265 /* SourceFile */ && ts.isExternalOrCommonJsModule(parent) && parent.flags & 1024 /* 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)); } @@ -41202,7 +42934,7 @@ var ts; // skip variable declarations that don't have initializers // NOTE: in ES6 spec initializer is required in variable declarations where name is binding pattern // so we'll always treat binding elements as initialized - if (node.kind === 225 /* VariableDeclaration */ && !node.initializer) { + if (node.kind === 226 /* VariableDeclaration */ && !node.initializer) { return; } var symbol = getSymbolOfNode(node); @@ -41212,17 +42944,17 @@ var ts; localDeclarationSymbol !== symbol && localDeclarationSymbol.flags & 2 /* BlockScopedVariable */) { if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3 /* BlockScoped */) { - var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 226 /* VariableDeclarationList */); - var container = varDeclList.parent.kind === 207 /* VariableStatement */ && varDeclList.parent.parent + var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 227 /* VariableDeclarationList */); + var container = varDeclList.parent.kind === 208 /* 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 === 206 /* Block */ && ts.isFunctionLike(container.parent) || - container.kind === 233 /* ModuleBlock */ || - container.kind === 232 /* ModuleDeclaration */ || - container.kind === 264 /* SourceFile */); + (container.kind === 207 /* Block */ && ts.isFunctionLike(container.parent) || + container.kind === 234 /* ModuleBlock */ || + container.kind === 233 /* ModuleDeclaration */ || + container.kind === 265 /* 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 @@ -41237,7 +42969,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 !== 145 /* Parameter */) { + if (ts.getRootDeclaration(node).kind !== 146 /* Parameter */) { return; } var func = ts.getContainingFunction(node); @@ -41248,11 +42980,11 @@ var ts; // skip declaration names (i.e. in object literal expressions) return; } - if (n.kind === 178 /* PropertyAccessExpression */) { + if (n.kind === 179 /* PropertyAccessExpression */) { // skip property names in property access expression return visit(n.expression); } - else if (n.kind === 70 /* Identifier */) { + else if (n.kind === 71 /* Identifier */) { // check FunctionLikeDeclaration.locals (stores parameters\function local variable) // if it contains entry with a specified name var symbol = resolveName(n, n.text, 107455 /* Value */ | 8388608 /* Alias */, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); @@ -41267,27 +42999,26 @@ var ts; // so we need to do a bit of extra work to check if reference is legal var enclosingContainer = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration); if (enclosingContainer === func) { - if (symbol.valueDeclaration.kind === 145 /* Parameter */ || - symbol.valueDeclaration.kind === 175 /* BindingElement */) { + if (symbol.valueDeclaration.kind === 146 /* Parameter */ || + symbol.valueDeclaration.kind === 176 /* BindingElement */) { // it is ok to reference parameter in initializer if either // - parameter is located strictly on the left of current parameter declaration if (symbol.valueDeclaration.pos < node.pos) { return; } // - parameter is wrapped in function-like entity - var current = n; - while (current !== node.initializer) { - if (ts.isFunctionLike(current.parent)) { - return; + if (ts.findAncestor(n, function (current) { + if (current === node.initializer) { + return "quit"; } - // computed property names/initializers in instance property declaration of class like entities - // are executed in constructor and thus deferred - if (current.parent.kind === 148 /* PropertyDeclaration */ && - !(ts.hasModifier(current.parent, 32 /* Static */)) && - ts.isClassLike(current.parent.parent)) { - return; - } - current = current.parent; + return ts.isFunctionLike(current.parent) || + // computed property names/initializers in instance property declaration of class like entities + // are executed in constructor and thus deferred + (current.parent.kind === 149 /* PropertyDeclaration */ && + !(ts.hasModifier(current.parent, 32 /* Static */)) && + ts.isClassLike(current.parent.parent)); + })) { + return; } // fall through to report error } @@ -41310,18 +43041,18 @@ 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 === 143 /* ComputedPropertyName */) { + if (node.name.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.name); if (node.initializer) { checkExpressionCached(node.initializer); } } - if (node.kind === 175 /* BindingElement */) { - if (node.parent.kind === 173 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */ && !ts.isInAmbientContext(node)) { + if (node.kind === 176 /* BindingElement */) { + if (node.parent.kind === 174 /* ObjectBindingPattern */ && languageVersion < 5 /* ESNext */) { checkExternalEmitHelpers(node, 4 /* Rest */); } // check computed properties inside property names of binding elements - if (node.propertyName && node.propertyName.kind === 143 /* ComputedPropertyName */) { + if (node.propertyName && node.propertyName.kind === 144 /* ComputedPropertyName */) { checkComputedPropertyName(node.propertyName); } // check private/protected variable access @@ -41336,17 +43067,20 @@ var ts; } // For a binding pattern, check contained binding elements if (ts.isBindingPattern(node.name)) { + if (node.name.kind === 175 /* ArrayBindingPattern */ && languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 512 /* Read */); + } 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 === 145 /* Parameter */ && ts.nodeIsMissing(ts.getContainingFunction(node).body)) { + if (node.initializer && ts.getRootDeclaration(node).kind === 146 /* 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 !== 214 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 215 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), getWidenedTypeForVariableLikeDeclaration(node), node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -41357,7 +43091,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 !== 214 /* ForInStatement */) { + if (node.initializer && node.parent.parent.kind !== 215 /* ForInStatement */) { checkTypeAssignableTo(checkExpressionCached(node.initializer), type, node, /*headMessage*/ undefined); checkParameterInitializer(node); } @@ -41377,10 +43111,10 @@ var ts; error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name)); } } - if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */) { + if (node.kind !== 149 /* PropertyDeclaration */ && node.kind !== 148 /* PropertySignature */) { // We know we don't have a binding pattern or computed name here checkExportsOnMergedDeclarations(node); - if (node.kind === 225 /* VariableDeclaration */ || node.kind === 175 /* BindingElement */) { + if (node.kind === 226 /* VariableDeclaration */ || node.kind === 176 /* BindingElement */) { checkVarDeclaredNamesNotShadowed(node); } checkCollisionWithCapturedSuperVariable(node, node.name); @@ -41391,8 +43125,8 @@ var ts; } } function areDeclarationFlagsIdentical(left, right) { - if ((left.kind === 145 /* Parameter */ && right.kind === 225 /* VariableDeclaration */) || - (left.kind === 225 /* VariableDeclaration */ && right.kind === 145 /* Parameter */)) { + if ((left.kind === 146 /* Parameter */ && right.kind === 226 /* VariableDeclaration */) || + (left.kind === 226 /* VariableDeclaration */ && right.kind === 146 /* Parameter */)) { // Differences in optionality between parameters and variables are allowed. return true; } @@ -41422,8 +43156,8 @@ 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 === 177 /* ObjectLiteralExpression */) { - if (ts.isAsyncFunctionLike(node)) { + if (node.modifiers && node.parent.kind === 178 /* ObjectLiteralExpression */) { + if (ts.getFunctionFlags(node) & 2 /* Async */) { if (node.modifiers.length > 1) { return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here); } @@ -41443,7 +43177,7 @@ var ts; checkGrammarStatementInAmbientContext(node); checkExpression(node.expression); checkSourceElement(node.thenStatement); - if (node.thenStatement.kind === 208 /* EmptyStatement */) { + if (node.thenStatement.kind === 209 /* EmptyStatement */) { error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement); } checkSourceElement(node.elseStatement); @@ -41463,12 +43197,12 @@ var ts; function checkForStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind === 226 /* VariableDeclarationList */) { + if (node.initializer && node.initializer.kind === 227 /* VariableDeclarationList */) { checkGrammarVariableDeclarationList(node.initializer); } } if (node.initializer) { - if (node.initializer.kind === 226 /* VariableDeclarationList */) { + if (node.initializer.kind === 227 /* VariableDeclarationList */) { ts.forEach(node.initializer.declarations, checkVariableDeclaration); } else { @@ -41486,19 +43220,29 @@ var ts; } function checkForOfStatement(node) { checkGrammarForInOrForOfStatement(node); + if (node.kind === 216 /* ForOfStatement */) { + if (node.awaitModifier) { + if (languageVersion < 4 /* ES2017 */) { + checkExternalEmitHelpers(node, 8192 /* ForAwaitOfIncludes */); + } + } + else if (languageVersion < 2 /* ES2015 */ && compilerOptions.downlevelIteration) { + checkExternalEmitHelpers(node, 256 /* ForOfIncludes */); + } + } // Check the LHS and RHS // If the LHS is a declaration, just check it as a variable declaration, which will in turn check the RHS // 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 === 226 /* VariableDeclarationList */) { + if (node.initializer.kind === 227 /* VariableDeclarationList */) { checkForInOrForOfVariableDeclaration(node); } else { var varExpr = node.initializer; - var iteratedType = checkRightHandSideOfForOf(node.expression); + var iteratedType = checkRightHandSideOfForOf(node.expression, node.awaitModifier); // There may be a destructuring assignment on the left side - if (varExpr.kind === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { + if (varExpr.kind === 177 /* ArrayLiteralExpression */ || varExpr.kind === 178 /* 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. @@ -41530,7 +43274,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 === 226 /* VariableDeclarationList */) { + if (node.initializer.kind === 227 /* 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); @@ -41544,7 +43288,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 === 176 /* ArrayLiteralExpression */ || varExpr.kind === 177 /* ObjectLiteralExpression */) { + if (varExpr.kind === 177 /* ArrayLiteralExpression */ || varExpr.kind === 178 /* ObjectLiteralExpression */) { error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) { @@ -41557,7 +43301,7 @@ var ts; } // unknownType is returned i.e. if node.expression is identifier whose name cannot be resolved // in this case error about missing name is already reported - do not report extra one - if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */)) { + if (!isTypeAnyOrAllConstituentTypesHaveKind(rightType, 32768 /* Object */ | 540672 /* TypeVariable */ | 16777216 /* NonPrimitive */)) { error(node.expression, ts.Diagnostics.The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter); } checkSourceElement(node.statement); @@ -41573,52 +43317,113 @@ var ts; checkVariableDeclaration(decl); } } - function checkRightHandSideOfForOf(rhsExpression) { + function checkRightHandSideOfForOf(rhsExpression, awaitModifier) { var expressionType = checkNonNullExpression(rhsExpression); - return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true); + return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true, awaitModifier !== undefined); } - function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput) { + function checkIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable) { if (isTypeAny(inputType)) { return inputType; } - if (languageVersion >= 2 /* ES2015 */) { - return checkElementTypeOfIterable(inputType, errorNode); - } - if (allowStringInput) { - return checkElementTypeOfArrayOrString(inputType, errorNode); - } - if (isArrayLikeType(inputType)) { - var indexType = getIndexTypeOfType(inputType, 1 /* Number */); - if (indexType) { - return indexType; - } - } - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType)); - } - return unknownType; + return getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, /*checkAssignability*/ true) || anyType; } /** - * When errorNode is undefined, it means we should not report any errors. + * When consuming an iterable type in a for..of, spread, or iterator destructuring assignment + * we want to get the iterated type of an iterable for ES2015 or later, or the iterated type + * of a iterable (if defined globally) or element type of an array like for ES2015 or earlier. */ - function checkElementTypeOfIterable(iterable, errorNode) { - var elementType = getElementTypeOfIterable(iterable, errorNode); - // Now even though we have extracted the iteratedType, we will have to validate that the type - // passed in is actually an Iterable. - if (errorNode && elementType) { - checkTypeAssignableTo(iterable, createIterableType(elementType), errorNode); + function getIteratedTypeOrElementType(inputType, errorNode, allowStringInput, allowAsyncIterable, checkAssignability) { + var uplevelIteration = languageVersion >= 2 /* ES2015 */; + var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration; + // Get the iterated type of an `Iterable` or `IterableIterator` only in ES2015 + // or higher, when inside of an async generator or for-await-if, or when + // downlevelIteration is requested. + if (uplevelIteration || downlevelIteration || allowAsyncIterable) { + // We only report errors for an invalid iterable type in ES2015 or higher. + var iteratedType = getIteratedTypeOfIterable(inputType, uplevelIteration ? errorNode : undefined, allowAsyncIterable, allowAsyncIterable, checkAssignability); + if (iteratedType || uplevelIteration) { + return iteratedType; + } } - return elementType || anyType; + var arrayType = inputType; + var reportedError = false; + var hasStringConstituent = false; + // If strings are permitted, remove any string-like constituents from the array type. + // This allows us to find other non-string element types from an array unioned with + // a string. + if (allowStringInput) { + if (arrayType.flags & 65536 /* Union */) { + // After we remove all types that are StringLike, we will know if there was a string constituent + // based on whether the result of filter is a new array. + var arrayTypes = inputType.types; + var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178 /* StringLike */); }); + if (filteredTypes !== arrayTypes) { + arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); + } + } + else if (arrayType.flags & 262178 /* StringLike */) { + arrayType = neverType; + } + hasStringConstituent = arrayType !== inputType; + if (hasStringConstituent) { + if (languageVersion < 1 /* ES5 */) { + if (errorNode) { + error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); + reportedError = true; + } + } + // Now that we've removed all the StringLike types, if no constituents remain, then the entire + // arrayOrStringType was a string. + if (arrayType.flags & 8192 /* Never */) { + return stringType; + } + } + } + if (!isArrayLikeType(arrayType)) { + if (errorNode && !reportedError) { + // Which error we report depends on whether we allow strings or if there was a + // string constituent. For example, if the input type is number | string, we + // want to say that number is not an array type. But if the input was just + // number and string input is allowed, we want to say that number is not an + // array type or a string type. + var diagnostic = !allowStringInput || hasStringConstituent + ? downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type + : downlevelIteration + ? ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator + : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; + error(errorNode, diagnostic, typeToString(arrayType)); + } + return hasStringConstituent ? stringType : undefined; + } + var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */); + if (hasStringConstituent && arrayElementType) { + // This is just an optimization for the case where arrayOrStringType is string | string[] + if (arrayElementType.flags & 262178 /* StringLike */) { + return stringType; + } + return getUnionType([arrayElementType, stringType], /*subtypeReduction*/ true); + } + return arrayElementType; } /** * We want to treat type as an iterable, and get the type it is an iterable of. The iterable * must have the following structure (annotated with the names of the variables below): * - * { // iterable - * [Symbol.iterator]: { // iteratorFunction - * (): Iterator + * { // iterable + * [Symbol.iterator]: { // iteratorMethod + * (): Iterator + * } + * } + * + * For an async iterable, we expect the following structure: + * + * { // iterable + * [Symbol.asyncIterator]: { // iteratorMethod + * (): AsyncIterator + * } * } - * } * * T is the type we are after. At every level that involves analyzing return types * of signatures, we union the return types of all the signatures. @@ -41630,166 +43435,170 @@ var ts; * caller requested it. Then the caller can decide what to do in the case where there is no iterated * type. This is different from returning anyType, because that would signify that we have matched the * whole pattern and that T (above) is 'any'. + * + * For a **for-of** statement, `yield*` (in a normal generator), spread, array + * destructuring, or normal generator we will only ever look for a `[Symbol.iterator]()` + * method. + * + * For an async generator we will only ever look at the `[Symbol.asyncIterator]()` method. + * + * For a **for-await-of** statement or a `yield*` in an async generator we will look for + * the `[Symbol.asyncIterator]()` method first, and then the `[Symbol.iterator]()` method. */ - function getElementTypeOfIterable(type, errorNode) { + function getIteratedTypeOfIterable(type, errorNode, isAsyncIterable, allowNonAsyncIterables, checkAssignability) { if (isTypeAny(type)) { return undefined; } var typeAsIterable = type; - if (!typeAsIterable.iterableElementType) { - // As an optimization, if the type is instantiated directly using the globalIterableType (Iterable), - // then just grab its type argument. - if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableType()) { - typeAsIterable.iterableElementType = type.typeArguments[0]; - } - else { - var iteratorFunction = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); - if (isTypeAny(iteratorFunction)) { - return undefined; - } - var iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, 0 /* Call */) : emptyArray; - if (iteratorFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); - } - return undefined; - } - typeAsIterable.iterableElementType = getElementTypeOfIterator(getUnionType(ts.map(iteratorFunctionSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true), errorNode); + if (isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable) { + return isAsyncIterable ? typeAsIterable.iteratedTypeOfAsyncIterable : typeAsIterable.iteratedTypeOfIterable; + } + if (isAsyncIterable) { + // As an optimization, if the type is an instantiation of the global `AsyncIterable` + // or the global `AsyncIterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalAsyncIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalAsyncIterableIteratorType(/*reportErrors*/ false))) { + return typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0]; } } - return typeAsIterable.iterableElementType; + if (!isAsyncIterable || allowNonAsyncIterables) { + // As an optimization, if the type is an instantiation of the global `Iterable` or + // `IterableIterator` then just grab its type argument. + if (isReferenceToType(type, getGlobalIterableType(/*reportErrors*/ false)) || + isReferenceToType(type, getGlobalIterableIteratorType(/*reportErrors*/ false))) { + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = type.typeArguments[0] + : typeAsIterable.iteratedTypeOfIterable = type.typeArguments[0]; + } + } + var iteratorMethodSignatures; + var isNonAsyncIterable = false; + if (isAsyncIterable) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("asyncIterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0 /* Call */); + } + if (!isAsyncIterable || (allowNonAsyncIterables && !ts.some(iteratorMethodSignatures))) { + var iteratorMethod = getTypeOfPropertyOfType(type, ts.getPropertyNameForKnownSymbolName("iterator")); + if (isTypeAny(iteratorMethod)) { + return undefined; + } + iteratorMethodSignatures = iteratorMethod && getSignaturesOfType(iteratorMethod, 0 /* Call */); + isNonAsyncIterable = true; + } + if (ts.some(iteratorMethodSignatures)) { + var iteratorMethodReturnType = getUnionType(ts.map(iteratorMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + var iteratedType = getIteratedTypeOfIterator(iteratorMethodReturnType, errorNode, /*isAsyncIterator*/ !isNonAsyncIterable); + if (checkAssignability && errorNode && iteratedType) { + // If `checkAssignability` was specified, we were called from + // `checkIteratedTypeOrElementType`. As such, we need to validate that + // the type passed in is actually an Iterable. + checkTypeAssignableTo(type, isNonAsyncIterable + ? createIterableType(iteratedType) + : createAsyncIterableType(iteratedType), errorNode); + } + return isAsyncIterable + ? typeAsIterable.iteratedTypeOfAsyncIterable = iteratedType + : typeAsIterable.iteratedTypeOfIterable = iteratedType; + } + if (errorNode) { + error(errorNode, isAsyncIterable + ? ts.Diagnostics.Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator + : ts.Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator); + } + return undefined; } /** - * This function has very similar logic as getElementTypeOfIterable, except that it operates on + * This function has very similar logic as getIteratedTypeOfIterable, except that it operates on * Iterators instead of Iterables. Here is the structure: * * { // iterator - * next: { // iteratorNextFunction - * (): { // iteratorNextResult - * value: T // iteratorNextValue + * next: { // nextMethod + * (): { // nextResult + * value: T // nextValue * } * } * } * + * For an async iterator, we expect the following structure: + * + * { // iterator + * next: { // nextMethod + * (): PromiseLike<{ // nextResult + * value: T // nextValue + * }> + * } + * } */ - function getElementTypeOfIterator(type, errorNode) { + function getIteratedTypeOfIterator(type, errorNode, isAsyncIterator) { if (isTypeAny(type)) { return undefined; } var typeAsIterator = type; - if (!typeAsIterator.iteratorElementType) { - // As an optimization, if the type is instantiated directly using the globalIteratorType (Iterator), - // then just grab its type argument. - if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIteratorType()) { - typeAsIterator.iteratorElementType = type.typeArguments[0]; - } - else { - var iteratorNextFunction = getTypeOfPropertyOfType(type, "next"); - if (isTypeAny(iteratorNextFunction)) { - return undefined; - } - var iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, 0 /* Call */) : emptyArray; - if (iteratorNextFunctionSignatures.length === 0) { - if (errorNode) { - error(errorNode, ts.Diagnostics.An_iterator_must_have_a_next_method); - } - return undefined; - } - var iteratorNextResult = getUnionType(ts.map(iteratorNextFunctionSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); - if (isTypeAny(iteratorNextResult)) { - return undefined; - } - var iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value"); - if (!iteratorNextValue) { - if (errorNode) { - error(errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); - } - return undefined; - } - typeAsIterator.iteratorElementType = iteratorNextValue; - } + if (isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator) { + return isAsyncIterator ? typeAsIterator.iteratedTypeOfAsyncIterator : typeAsIterator.iteratedTypeOfIterator; } - return typeAsIterator.iteratorElementType; - } - function getElementTypeOfIterableIterator(type) { - if (isTypeAny(type)) { + // As an optimization, if the type is an instantiation of the global `Iterator` (for + // a non-async iterator) or the global `AsyncIterator` (for an async-iterator) then + // just grab its type argument. + var getIteratorType = isAsyncIterator ? getGlobalAsyncIteratorType : getGlobalIteratorType; + if (isReferenceToType(type, getIteratorType(/*reportErrors*/ false))) { + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = type.typeArguments[0] + : typeAsIterator.iteratedTypeOfIterator = type.typeArguments[0]; + } + // Both async and non-async iterators must have a `next` method. + var nextMethod = getTypeOfPropertyOfType(type, "next"); + if (isTypeAny(nextMethod)) { return undefined; } - // As an optimization, if the type is instantiated directly using the globalIterableIteratorType (IterableIterator), - // then just grab its type argument. - if ((getObjectFlags(type) & 4 /* Reference */) && type.target === getGlobalIterableIteratorType()) { - return type.typeArguments[0]; + var nextMethodSignatures = nextMethod ? getSignaturesOfType(nextMethod, 0 /* Call */) : emptyArray; + if (nextMethodSignatures.length === 0) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.An_async_iterator_must_have_a_next_method + : ts.Diagnostics.An_iterator_must_have_a_next_method); + } + return undefined; } - return getElementTypeOfIterable(type, /*errorNode*/ undefined) || - getElementTypeOfIterator(type, /*errorNode*/ undefined); + var nextResult = getUnionType(ts.map(nextMethodSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + if (isTypeAny(nextResult)) { + return undefined; + } + // For an async iterator, we must get the awaited type of the return type. + if (isAsyncIterator) { + nextResult = getAwaitedTypeOfPromise(nextResult, errorNode, ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property); + if (isTypeAny(nextResult)) { + return undefined; + } + } + var nextValue = nextResult && getTypeOfPropertyOfType(nextResult, "value"); + if (!nextValue) { + if (errorNode) { + error(errorNode, isAsyncIterator + ? ts.Diagnostics.The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property + : ts.Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property); + } + return undefined; + } + return isAsyncIterator + ? typeAsIterator.iteratedTypeOfAsyncIterator = nextValue + : typeAsIterator.iteratedTypeOfIterator = nextValue; } /** - * 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 constituent. - * - * For example: - * string -> string - * number[] -> number - * string[] | number[] -> string | number - * string | number[] -> string | number - * string | string[] | number[] -> string | number - * - * It also errors if: - * 1. Some constituent is neither a string nor an array. - * 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable). + * A generator may have a return type of `Iterator`, `Iterable`, or + * `IterableIterator`. An async generator may have a return type of `AsyncIterator`, + * `AsyncIterable`, or `AsyncIterableIterator`. This function can be used to extract + * the iterated type from this return type for contextual typing and verifying signatures. */ - function checkElementTypeOfArrayOrString(arrayOrStringType, errorNode) { - ts.Debug.assert(languageVersion < 2 /* ES2015 */); - var arrayType = arrayOrStringType; - if (arrayOrStringType.flags & 65536 /* Union */) { - // After we remove all types that are StringLike, we will know if there was a string constituent - // based on whether the result of filter is a new array. - var arrayTypes = arrayOrStringType.types; - var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 262178 /* StringLike */); }); - if (filteredTypes !== arrayTypes) { - arrayType = getUnionType(filteredTypes, /*subtypeReduction*/ true); - } + function getIteratedTypeOfGenerator(returnType, isAsyncGenerator) { + if (isTypeAny(returnType)) { + return undefined; } - else if (arrayOrStringType.flags & 262178 /* StringLike */) { - arrayType = neverType; - } - var hasStringConstituent = arrayOrStringType !== arrayType; - var reportedError = false; - if (hasStringConstituent) { - if (languageVersion < 1 /* ES5 */) { - error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher); - reportedError = true; - } - // Now that we've removed all the StringLike types, if no constituents remain, then the entire - // arrayOrStringType was a string. - if (arrayType.flags & 8192 /* Never */) { - return stringType; - } - } - if (!isArrayLikeType(arrayType)) { - if (!reportedError) { - // Which error we report depends on whether there was a string constituent. For example, - // if the input type is number | string, we want to say that number is not an array type. - // But if the input was just number, we want to say that number is not an array type - // or a string type. - var diagnostic = hasStringConstituent - ? ts.Diagnostics.Type_0_is_not_an_array_type - : ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type; - error(errorNode, diagnostic, typeToString(arrayType)); - } - return hasStringConstituent ? stringType : unknownType; - } - var arrayElementType = getIndexTypeOfType(arrayType, 1 /* Number */) || unknownType; - if (hasStringConstituent) { - // This is just an optimization for the case where arrayOrStringType is string | string[] - if (arrayElementType.flags & 262178 /* StringLike */) { - return stringType; - } - return getUnionType([arrayElementType, stringType], /*subtypeReduction*/ true); - } - return arrayElementType; + return getIteratedTypeOfIterable(returnType, /*errorNode*/ undefined, isAsyncGenerator, /*allowNonAsyncIterables*/ false, /*checkAssignability*/ false) + || getIteratedTypeOfIterator(returnType, /*errorNode*/ undefined, isAsyncGenerator); } function checkBreakOrContinueStatement(node) { // Grammar checking @@ -41797,10 +43606,12 @@ var ts; // TODO: Check that target label is valid } function isGetAccessorWithAnnotatedSetAccessor(node) { - return !!(node.kind === 152 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 153 /* SetAccessor */))); + return !!(node.kind === 153 /* GetAccessor */ && ts.getSetAccessorTypeAnnotationNode(ts.getDeclarationOfKind(node.symbol, 154 /* SetAccessor */))); } function isUnwrappedReturnTypeVoidOrAny(func, returnType) { - var unwrappedReturnType = ts.isAsyncFunctionLike(func) ? getPromisedType(returnType) : returnType; + var unwrappedReturnType = (ts.getFunctionFlags(func) & 3 /* AsyncOrAsyncGenerator */) === 2 /* Async */ + ? getPromisedTypeOfPromise(returnType) // Async function + : returnType; // AsyncGenerator function, Generator function, or normal function return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 1024 /* Void */ | 1 /* Any */); } function checkReturnStatement(node) { @@ -41817,27 +43628,28 @@ var ts; var returnType = getReturnTypeOfSignature(signature); if (strictNullChecks || node.expression || returnType.flags & 8192 /* Never */) { var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType; - if (func.asteriskToken) { + var functionFlags = ts.getFunctionFlags(func); + if (functionFlags & 1 /* Generator */) { // A generator does not need its return expressions checked against its return type. // Instead, the yield expressions are checked against the element type. // TODO: Check return expressions of generators when return type tracking is added // for generators. return; } - if (func.kind === 153 /* SetAccessor */) { + if (func.kind === 154 /* SetAccessor */) { if (node.expression) { error(node, ts.Diagnostics.Setters_cannot_return_a_value); } } - else if (func.kind === 151 /* Constructor */) { + else if (func.kind === 152 /* Constructor */) { if (node.expression && !checkTypeAssignableTo(exprType, returnType, node)) { error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class); } } else if (func.type || isGetAccessorWithAnnotatedSetAccessor(func)) { - if (ts.isAsyncFunctionLike(func)) { - var promisedType = getPromisedType(returnType); - var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.Return_expression_in_async_function_does_not_have_a_valid_callable_then_member); + if (functionFlags & 2 /* Async */) { + var promisedType = getPromisedTypeOfPromise(returnType); + var awaitedType = checkAwaitedType(exprType, node, ts.Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); if (promisedType) { // If the function has a return type, but promisedType is // undefined, an error will be reported in checkAsyncFunctionReturnType @@ -41850,7 +43662,7 @@ var ts; } } } - else if (func.kind !== 151 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { + else if (func.kind !== 152 /* Constructor */ && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) { // The function has a return type, but the return statement doesn't have an expression. error(node, ts.Diagnostics.Not_all_code_paths_return_a_value); } @@ -41880,7 +43692,7 @@ var ts; var expressionIsLiteral = isLiteralType(expressionType); ts.forEach(node.caseBlock.clauses, function (clause) { // Grammar check for duplicate default clauses, skip if we already report duplicate default clause - if (clause.kind === 257 /* DefaultClause */ && !hasDuplicateDefaultClause) { + if (clause.kind === 258 /* DefaultClause */ && !hasDuplicateDefaultClause) { if (firstDefaultClause === undefined) { firstDefaultClause = clause; } @@ -41892,7 +43704,7 @@ var ts; hasDuplicateDefaultClause = true; } } - if (produceDiagnostics && clause.kind === 256 /* CaseClause */) { + if (produceDiagnostics && clause.kind === 257 /* 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 comparable @@ -41918,18 +43730,16 @@ var ts; function checkLabeledStatement(node) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - var current = node.parent; - while (current) { + ts.findAncestor(node.parent, function (current) { if (ts.isFunctionLike(current)) { - break; + return "quit"; } - if (current.kind === 221 /* LabeledStatement */ && current.label.text === node.label.text) { + if (current.kind === 222 /* 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; + return true; } - current = current.parent; - } + }); } // ensure that label is unique checkSourceElement(node.statement); @@ -42027,7 +43837,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 (propDeclaration && (propDeclaration.name.kind === 143 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { + if (propDeclaration && (propDeclaration.name.kind === 144 /* ComputedPropertyName */ || prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { @@ -42165,7 +43975,7 @@ var ts; registerForUnusedIdentifiersCheck(node); } function checkClassLikeDeclaration(node) { - checkGrammarClassDeclarationHeritageClauses(node); + checkGrammarClassLikeDeclaration(node); checkDecorators(node); if (node.name) { checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0); @@ -42188,7 +43998,7 @@ var ts; } var baseTypeNode = ts.getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - if (languageVersion < 2 /* ES2015 */ && !ts.isInAmbientContext(node)) { + if (languageVersion < 2 /* ES2015 */) { checkExternalEmitHelpers(baseTypeNode.parent, 1 /* Extends */); } var baseTypes = getBaseTypes(type); @@ -42200,7 +44010,7 @@ var ts; checkSourceElement(baseTypeNode.expression); if (baseTypeNode.typeArguments) { ts.forEach(baseTypeNode.typeArguments, checkSourceElement); - for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments); _i < _a.length; _i++) { + for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) { var constructor = _a[_i]; if (!checkTypeArgumentConstraints(constructor.typeParameters, baseTypeNode.typeArguments)) { break; @@ -42212,19 +44022,12 @@ var ts; if (baseConstructorType.flags & 540672 /* TypeVariable */ && !isMixinConstructorType(staticType)) { error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any); } - if (baseType_1.symbol && baseType_1.symbol.valueDeclaration && - !ts.isInAmbientContext(baseType_1.symbol.valueDeclaration) && - baseType_1.symbol.valueDeclaration.kind === 228 /* ClassDeclaration */) { - if (!isBlockScopedNameDeclaredBeforeUse(baseType_1.symbol.valueDeclaration, node)) { - error(baseTypeNode, ts.Diagnostics.A_class_must_be_declared_after_its_base_class); - } - } if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32 /* Class */) && !(baseConstructorType.flags & 540672 /* TypeVariable */)) { // When the static base type is a "class-like" constructor function (but not actually a class), we verify // that all instantiated base constructor signatures return the same type. We can simply compare the type // 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); + var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); 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); } @@ -42280,7 +44083,7 @@ var ts; } function getClassOrInterfaceDeclarationsOfSymbol(symbol) { return ts.filter(symbol.declarations, function (d) { - return d.kind === 228 /* ClassDeclaration */ || d.kind === 229 /* InterfaceDeclaration */; + return d.kind === 229 /* ClassDeclaration */ || d.kind === 230 /* InterfaceDeclaration */; }); } function checkKindsOfPropertyMemberOverrides(type, baseType) { @@ -42319,7 +44122,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 || !(ts.getModifierFlags(derivedClassDecl) & 128 /* Abstract */))) { - if (derivedClassDecl.kind === 198 /* ClassExpression */) { + if (derivedClassDecl.kind === 199 /* ClassExpression */) { error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType)); } else { @@ -42330,7 +44133,7 @@ var ts; else { // derived overrides base. var derivedDeclarationFlags = getDeclarationModifierFlagsFromSymbol(derived); - if ((baseDeclarationFlags & 8 /* Private */) || (derivedDeclarationFlags & 8 /* Private */)) { + if (baseDeclarationFlags & 8 /* Private */ || derivedDeclarationFlags & 8 /* Private */) { // either base or derived property is private - not override, skip it continue; } @@ -42338,36 +44141,32 @@ var ts; // value of 'static' is not the same for properties - not override, skip it continue; } - if ((base.flags & derived.flags & 8192 /* Method */) || ((base.flags & 98308 /* PropertyOrAccessor */) && (derived.flags & 98308 /* PropertyOrAccessor */))) { + if (isMethodLike(base) && isMethodLike(derived) || base.flags & 98308 /* PropertyOrAccessor */ && derived.flags & 98308 /* PropertyOrAccessor */) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; } var errorMessage = void 0; - if (base.flags & 8192 /* Method */) { + if (isMethodLike(base)) { if (derived.flags & 98304 /* Accessor */) { errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor; } else { - ts.Debug.assert((derived.flags & 4 /* Property */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property; } } else if (base.flags & 4 /* Property */) { - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function; } else { - ts.Debug.assert((base.flags & 98304 /* Accessor */) !== 0); - ts.Debug.assert((derived.flags & 8192 /* Method */) !== 0); errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - error(derived.valueDeclaration.name, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } } function isAccessor(kind) { - return kind === 152 /* GetAccessor */ || kind === 153 /* SetAccessor */; + return kind === 153 /* GetAccessor */ || kind === 154 /* SetAccessor */; } function checkInheritedPropertiesAreIdentical(type, typeNode) { var baseTypes = getBaseTypes(type); @@ -42380,8 +44179,8 @@ var ts; for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) { var base = baseTypes_2[_i]; var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType)); - for (var _a = 0, properties_7 = properties; _a < properties_7.length; _a++) { - var prop = properties_7[_a]; + for (var _a = 0, properties_8 = properties; _a < properties_8.length; _a++) { + var prop = properties_8[_a]; var existing = seen.get(prop.name); if (!existing) { seen.set(prop.name, { prop: prop, containingType: base }); @@ -42392,7 +44191,7 @@ var ts; ok = false; var typeName1 = typeToString(existing.containingType); var typeName2 = typeToString(base); - var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); + var errorInfo = ts.chainDiagnosticMessages(/*details*/ undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2); errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2); diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo)); } @@ -42411,7 +44210,7 @@ var ts; var symbol = getSymbolOfNode(node); checkTypeParameterListsIdentical(symbol); // Only check this symbol once - var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 229 /* InterfaceDeclaration */); + var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 230 /* InterfaceDeclaration */); if (node === firstInterfaceDecl) { var type = getDeclaredTypeOfSymbol(symbol); var typeWithThis = getTypeWithThisArgument(type); @@ -42518,18 +44317,18 @@ var ts; return value; function evalConstant(e) { switch (e.kind) { - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: var value_1 = evalConstant(e.operand); if (value_1 === undefined) { return undefined; } switch (e.operator) { - case 36 /* PlusToken */: return value_1; - case 37 /* MinusToken */: return -value_1; - case 51 /* TildeToken */: return ~value_1; + case 37 /* PlusToken */: return value_1; + case 38 /* MinusToken */: return -value_1; + case 52 /* TildeToken */: return ~value_1; } return undefined; - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: var left = evalConstant(e.left); if (left === undefined) { return undefined; @@ -42539,32 +44338,32 @@ var ts; return undefined; } switch (e.operatorToken.kind) { - case 48 /* BarToken */: return left | right; - case 47 /* AmpersandToken */: return left & right; - case 45 /* GreaterThanGreaterThanToken */: return left >> right; - case 46 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; - case 44 /* LessThanLessThanToken */: return left << right; - case 49 /* CaretToken */: return left ^ right; - case 38 /* AsteriskToken */: return left * right; - case 40 /* SlashToken */: return left / right; - case 36 /* PlusToken */: return left + right; - case 37 /* MinusToken */: return left - right; - case 41 /* PercentToken */: return left % right; + case 49 /* BarToken */: return left | right; + case 48 /* AmpersandToken */: return left & right; + case 46 /* GreaterThanGreaterThanToken */: return left >> right; + case 47 /* GreaterThanGreaterThanGreaterThanToken */: return left >>> right; + case 45 /* LessThanLessThanToken */: return left << right; + case 50 /* CaretToken */: return left ^ right; + case 39 /* AsteriskToken */: return left * right; + case 41 /* SlashToken */: return left / right; + case 37 /* PlusToken */: return left + right; + case 38 /* MinusToken */: return left - right; + case 42 /* PercentToken */: return left % right; } return undefined; case 8 /* NumericLiteral */: checkGrammarNumericLiteral(e); return +e.text; - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return evalConstant(e.expression); - case 70 /* Identifier */: - case 179 /* ElementAccessExpression */: - case 178 /* PropertyAccessExpression */: + case 71 /* Identifier */: + case 180 /* ElementAccessExpression */: + case 179 /* PropertyAccessExpression */: var member = initializer.parent; var currentType = getTypeOfSymbol(getSymbolOfNode(member.parent)); var enumType_1; var propertyName = void 0; - if (e.kind === 70 /* Identifier */) { + if (e.kind === 71 /* Identifier */) { // unqualified names can refer to member that reside in different declaration of the enum so just doing name resolution won't work. // instead pick current enum type and later try to fetch member from the type enumType_1 = currentType; @@ -42572,7 +44371,7 @@ var ts; } else { var expression = void 0; - if (e.kind === 179 /* ElementAccessExpression */) { + if (e.kind === 180 /* ElementAccessExpression */) { if (e.argumentExpression === undefined || e.argumentExpression.kind !== 9 /* StringLiteral */) { return undefined; @@ -42587,10 +44386,10 @@ var ts; // expression part in ElementAccess\PropertyAccess should be either identifier or dottedName var current = expression; while (current) { - if (current.kind === 70 /* Identifier */) { + if (current.kind === 71 /* Identifier */) { break; } - else if (current.kind === 178 /* PropertyAccessExpression */) { + else if (current.kind === 179 /* PropertyAccessExpression */) { current = current.expression; } else { @@ -42663,7 +44462,7 @@ var ts; 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 !== 231 /* EnumDeclaration */) { + if (declaration.kind !== 232 /* EnumDeclaration */) { return false; } var enumDeclaration = declaration; @@ -42686,8 +44485,8 @@ var ts; var declarations = symbol.declarations; for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) { var declaration = declarations_8[_i]; - if ((declaration.kind === 228 /* ClassDeclaration */ || - (declaration.kind === 227 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && + if ((declaration.kind === 229 /* ClassDeclaration */ || + (declaration.kind === 228 /* FunctionDeclaration */ && ts.nodeIsPresent(declaration.body))) && !ts.isInAmbientContext(declaration)) { return declaration; } @@ -42751,7 +44550,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, 228 /* ClassDeclaration */); + var mergedClass = ts.getDeclarationOfKind(symbol, 229 /* ClassDeclaration */); if (mergedClass && inSameLexicalScope(node, mergedClass)) { getNodeLinks(node).flags |= 32768 /* LexicalModuleMergesWithClass */; @@ -42802,23 +44601,23 @@ var ts; } function checkModuleAugmentationElement(node, isGlobalAugmentation) { switch (node.kind) { - case 207 /* VariableStatement */: + case 208 /* 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 242 /* ExportAssignment */: - case 243 /* ExportDeclaration */: + case 243 /* ExportAssignment */: + case 244 /* ExportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations); break; - case 236 /* ImportEqualsDeclaration */: - case 237 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 238 /* ImportDeclaration */: grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module); break; - case 175 /* BindingElement */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 226 /* VariableDeclaration */: var name = node.name; if (ts.isBindingPattern(name)) { for (var _b = 0, _c = name.elements; _b < _c.length; _b++) { @@ -42828,13 +44627,13 @@ var ts; } break; } - // fallthrough - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 227 /* FunctionDeclaration */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 230 /* TypeAliasDeclaration */: + // falls through + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 228 /* FunctionDeclaration */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 231 /* TypeAliasDeclaration */: if (isGlobalAugmentation) { return; } @@ -42855,17 +44654,17 @@ var ts; } function getFirstIdentifier(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return node; - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: do { node = node.left; - } while (node.kind !== 70 /* Identifier */); + } while (node.kind !== 71 /* Identifier */); return node; - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: do { node = node.expression; - } while (node.kind !== 70 /* Identifier */); + } while (node.kind !== 71 /* Identifier */); return node; } } @@ -42875,9 +44674,9 @@ var ts; error(moduleName, ts.Diagnostics.String_literal_expected); return false; } - var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule) { - error(moduleName, node.kind === 243 /* ExportDeclaration */ ? + var inAmbientExternalModule = node.parent.kind === 234 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + if (node.parent.kind !== 265 /* SourceFile */ && !inAmbientExternalModule) { + error(moduleName, node.kind === 244 /* ExportDeclaration */ ? ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace : ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module); return false; @@ -42910,7 +44709,7 @@ var ts; (symbol.flags & 793064 /* Type */ ? 793064 /* Type */ : 0) | (symbol.flags & 1920 /* Namespace */ ? 1920 /* Namespace */ : 0); if (target.flags & excludedMeanings) { - var message = node.kind === 245 /* ExportSpecifier */ ? + var message = node.kind === 246 /* 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)); @@ -42938,7 +44737,7 @@ var ts; checkImportBinding(importClause); } if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 240 /* NamespaceImport */) { checkImportBinding(importClause.namedBindings); } else { @@ -42995,10 +44794,10 @@ var ts; // export { x, y } // export { x, y } from "foo" ts.forEach(node.exportClause.elements, checkExportSpecifier); - var inAmbientExternalModule = node.parent.kind === 233 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); - var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 233 /* ModuleBlock */ && + var inAmbientExternalModule = node.parent.kind === 234 /* ModuleBlock */ && ts.isAmbientModule(node.parent.parent); + var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 234 /* ModuleBlock */ && !node.moduleSpecifier && ts.isInAmbientContext(node); - if (node.parent.kind !== 264 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { + if (node.parent.kind !== 265 /* SourceFile */ && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) { error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace); } } @@ -43012,7 +44811,7 @@ var ts; } } function checkGrammarModuleElementContext(node, errorMessage) { - var isInAppropriateContext = node.parent.kind === 264 /* SourceFile */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 232 /* ModuleDeclaration */; + var isInAppropriateContext = node.parent.kind === 265 /* SourceFile */ || node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 233 /* ModuleDeclaration */; if (!isInAppropriateContext) { grammarErrorOnFirstToken(node, errorMessage); } @@ -43038,8 +44837,8 @@ var ts; // If we hit an export assignment in an illegal context, just bail out to avoid cascading errors. return; } - var container = node.parent.kind === 264 /* SourceFile */ ? node.parent : node.parent.parent; - if (container.kind === 232 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { + var container = node.parent.kind === 265 /* SourceFile */ ? node.parent : node.parent.parent; + if (container.kind === 233 /* ModuleDeclaration */ && !ts.isAmbientModule(container)) { if (node.isExportEquals) { error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace); } @@ -43052,7 +44851,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && ts.getModifierFlags(node) !== 0) { grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers); } - if (node.expression.kind === 70 /* Identifier */) { + if (node.expression.kind === 71 /* Identifier */) { markExportAsReferenced(node); } else { @@ -43114,7 +44913,7 @@ var ts; links.exportsChecked = true; } function isNotOverload(declaration) { - return (declaration.kind !== 227 /* FunctionDeclaration */ && declaration.kind !== 150 /* MethodDeclaration */) || + return (declaration.kind !== 228 /* FunctionDeclaration */ && declaration.kind !== 151 /* MethodDeclaration */) || !!declaration.body; } } @@ -43127,123 +44926,123 @@ var ts; // 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 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 227 /* FunctionDeclaration */: + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 228 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } switch (kind) { - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return checkTypeParameter(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return checkParameter(node); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return checkPropertyDeclaration(node); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: return checkSignatureDeclaration(node); - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return checkSignatureDeclaration(node); - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return checkMethodDeclaration(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return checkConstructorDeclaration(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return checkAccessorDeclaration(node); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return checkTypeReferenceNode(node); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return checkTypePredicate(node); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return checkTypeQuery(node); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return checkTypeLiteral(node); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return checkArrayType(node); - case 164 /* TupleType */: + case 165 /* TupleType */: return checkTupleType(node); - case 165 /* UnionType */: - case 166 /* IntersectionType */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: return checkUnionOrIntersectionType(node); - case 167 /* ParenthesizedType */: - case 169 /* TypeOperator */: + case 168 /* ParenthesizedType */: + case 170 /* TypeOperator */: return checkSourceElement(node.type); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return checkIndexedAccessType(node); - case 171 /* MappedType */: + case 172 /* MappedType */: return checkMappedType(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return checkFunctionDeclaration(node); - case 206 /* Block */: - case 233 /* ModuleBlock */: + case 207 /* Block */: + case 234 /* ModuleBlock */: return checkBlock(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return checkVariableStatement(node); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return checkExpressionStatement(node); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return checkIfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return checkDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return checkWhileStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return checkForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return checkForInStatement(node); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return checkForOfStatement(node); - case 216 /* ContinueStatement */: - case 217 /* BreakStatement */: + case 217 /* ContinueStatement */: + case 218 /* BreakStatement */: return checkBreakOrContinueStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return checkReturnStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return checkWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return checkSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return checkLabeledStatement(node); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return checkThrowStatement(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return checkTryStatement(node); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return checkVariableDeclaration(node); - case 175 /* BindingElement */: + case 176 /* BindingElement */: return checkBindingElement(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return checkClassDeclaration(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return checkInterfaceDeclaration(node); - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return checkTypeAliasDeclaration(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return checkEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return checkModuleDeclaration(node); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return checkImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return checkImportEqualsDeclaration(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return checkExportDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return checkExportAssignment(node); - case 208 /* EmptyStatement */: + case 209 /* EmptyStatement */: checkGrammarStatementInAmbientContext(node); return; - case 224 /* DebuggerStatement */: + case 225 /* DebuggerStatement */: checkGrammarStatementInAmbientContext(node); return; - case 246 /* MissingDeclaration */: + case 247 /* MissingDeclaration */: return checkMissingDeclaration(node); } } @@ -43265,17 +45064,17 @@ var ts; for (var _i = 0, deferredNodes_1 = deferredNodes; _i < deferredNodes_1.length; _i++) { var node = deferredNodes_1[_i]; switch (node.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: checkFunctionExpressionOrObjectLiteralMethodDeferred(node); break; - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - checkAccessorDeferred(node); + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + checkAccessorDeclaration(node); break; - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: checkClassExpressionDeferred(node); break; } @@ -43381,7 +45180,7 @@ var ts; function isInsideWithStatementBody(node) { if (node) { while (node.parent) { - if (node.parent.kind === 219 /* WithStatement */ && node.parent.statement === node) { + if (node.parent.kind === 220 /* WithStatement */ && node.parent.statement === node) { return true; } node = node.parent; @@ -43390,12 +45189,12 @@ var ts; return false; } function getSymbolsInScope(location, meaning) { - var symbols = ts.createMap(); - var memberFlags = 0 /* None */; if (isInsideWithStatementBody(location)) { // We cannot answer semantic questions within a with block, do not proceed any further return []; } + var symbols = ts.createMap(); + var memberFlags = 0 /* None */; populateSymbols(); return symbolsToArray(symbols); function populateSymbols() { @@ -43404,25 +45203,27 @@ var ts; copySymbols(location.locals, meaning); } switch (location.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: if (!ts.isExternalOrCommonJsModule(location)) { break; } - case 232 /* ModuleDeclaration */: + // falls through + case 233 /* ModuleDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8914931 /* ModuleMember */); break; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: copySymbols(getSymbolOfNode(location).exports, meaning & 8 /* EnumMember */); break; - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: var className = location.name; if (className) { copySymbol(location.symbol, meaning); } - // fall through; this fall-through is necessary because we would like to handle + // falls 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 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* 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. @@ -43431,7 +45232,7 @@ var ts; copySymbols(getSymbolOfNode(location).members, meaning & 793064 /* Type */); } break; - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: var funcName = location.name; if (funcName) { copySymbol(location.symbol, meaning); @@ -43473,34 +45274,34 @@ var ts; } } function isTypeDeclarationName(name) { - return name.kind === 70 /* Identifier */ && + return name.kind === 71 /* Identifier */ && isTypeDeclaration(name.parent) && name.parent.name === name; } function isTypeDeclaration(node) { switch (node.kind) { - case 144 /* TypeParameter */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 231 /* EnumDeclaration */: + case 145 /* TypeParameter */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 232 /* 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 === 142 /* QualifiedName */) { + while (node.parent && node.parent.kind === 143 /* QualifiedName */) { node = node.parent; } - return node.parent && (node.parent.kind === 158 /* TypeReference */ || node.parent.kind === 276 /* JSDocTypeReference */); + return node.parent && (node.parent.kind === 159 /* TypeReference */ || node.parent.kind === 277 /* JSDocTypeReference */); } function isHeritageClauseElementIdentifier(entityName) { var node = entityName; - while (node.parent && node.parent.kind === 178 /* PropertyAccessExpression */) { + while (node.parent && node.parent.kind === 179 /* PropertyAccessExpression */) { node = node.parent; } - return node.parent && node.parent.kind === 200 /* ExpressionWithTypeArguments */; + return node.parent && node.parent.kind === 201 /* ExpressionWithTypeArguments */; } function forEachEnclosingClass(node, callback) { var result; @@ -43517,13 +45318,13 @@ var ts; return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; }); } function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) { - while (nodeOnRightSide.parent.kind === 142 /* QualifiedName */) { + while (nodeOnRightSide.parent.kind === 143 /* QualifiedName */) { nodeOnRightSide = nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 236 /* ImportEqualsDeclaration */) { + if (nodeOnRightSide.parent.kind === 237 /* ImportEqualsDeclaration */) { return nodeOnRightSide.parent.moduleReference === nodeOnRightSide && nodeOnRightSide.parent; } - if (nodeOnRightSide.parent.kind === 242 /* ExportAssignment */) { + if (nodeOnRightSide.parent.kind === 243 /* ExportAssignment */) { return nodeOnRightSide.parent.expression === nodeOnRightSide && nodeOnRightSide.parent; } return undefined; @@ -43531,29 +45332,38 @@ var ts; function isInRightSideOfImportOrExportAssignment(node) { return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined; } + function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) { + 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 */: + case 5 /* Property */: + return getSymbolOfNode(entityName.parent.parent); + } + } function getSymbolOfEntityNameOrPropertyAccessExpression(entityName) { if (ts.isDeclarationName(entityName)) { return getSymbolOfNode(entityName.parent); } - if (ts.isInJavaScriptFile(entityName) && entityName.parent.kind === 178 /* 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 (ts.isInJavaScriptFile(entityName) && + entityName.parent.kind === 179 /* PropertyAccessExpression */ && + entityName.parent === entityName.parent.parent.left) { + // Check if this is a special property assignment + var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName); + if (specialPropertyAssignmentSymbol) { + return specialPropertyAssignmentSymbol; } } - if (entityName.parent.kind === 242 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { + if (entityName.parent.kind === 243 /* ExportAssignment */ && ts.isEntityNameExpression(entityName)) { return resolveEntityName(entityName, /*all meanings*/ 107455 /* Value */ | 793064 /* Type */ | 1920 /* Namespace */ | 8388608 /* Alias */); } - if (entityName.kind !== 178 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { + if (entityName.kind !== 179 /* PropertyAccessExpression */ && isInRightSideOfImportOrExportAssignment(entityName)) { // Since we already checked for ExportAssignment, this really could only be an Import - var importEqualsDeclaration = ts.getAncestor(entityName, 236 /* ImportEqualsDeclaration */); + var importEqualsDeclaration = ts.getAncestor(entityName, 237 /* ImportEqualsDeclaration */); ts.Debug.assert(importEqualsDeclaration !== undefined); return getSymbolOfPartOfRightHandSideOfImportEquals(entityName, /*dontResolveAlias*/ true); } @@ -43563,7 +45373,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 === 200 /* ExpressionWithTypeArguments */) { + if (entityName.parent.kind === 201 /* ExpressionWithTypeArguments */) { meaning = 793064 /* Type */; // In a class 'extends' clause we are also looking for a value. if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent)) { @@ -43574,27 +45384,30 @@ var ts; meaning = 1920 /* Namespace */; } meaning |= 8388608 /* Alias */; - return resolveEntityName(entityName, meaning); + var entityNameSymbol = resolveEntityName(entityName, meaning); + if (entityNameSymbol) { + return entityNameSymbol; + } } - else if (ts.isPartOfExpression(entityName)) { + if (ts.isPartOfExpression(entityName)) { if (ts.nodeIsMissing(entityName)) { // Missing entity name. return undefined; } - if (entityName.kind === 70 /* Identifier */) { + if (entityName.kind === 71 /* Identifier */) { if (ts.isJSXTagName(entityName) && isJsxIntrinsicIdentifier(entityName)) { return getIntrinsicTagSymbol(entityName.parent); } return resolveEntityName(entityName, 107455 /* Value */, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.kind === 178 /* PropertyAccessExpression */) { + else if (entityName.kind === 179 /* PropertyAccessExpression */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkPropertyAccessExpression(entityName); } return getNodeLinks(entityName).resolvedSymbol; } - else if (entityName.kind === 142 /* QualifiedName */) { + else if (entityName.kind === 143 /* QualifiedName */) { var symbol = getNodeLinks(entityName).resolvedSymbol; if (!symbol) { checkQualifiedName(entityName); @@ -43603,20 +45416,20 @@ var ts; } } else if (isTypeReferenceIdentifier(entityName)) { - var meaning = (entityName.parent.kind === 158 /* TypeReference */ || entityName.parent.kind === 276 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; + var meaning = (entityName.parent.kind === 159 /* TypeReference */ || entityName.parent.kind === 277 /* JSDocTypeReference */) ? 793064 /* Type */ : 1920 /* Namespace */; return resolveEntityName(entityName, meaning, /*ignoreErrors*/ false, /*dontResolveAlias*/ true); } - else if (entityName.parent.kind === 252 /* JsxAttribute */) { + else if (entityName.parent.kind === 253 /* JsxAttribute */) { return getJsxAttributePropertySymbol(entityName.parent); } - if (entityName.parent.kind === 157 /* TypePredicate */) { + if (entityName.parent.kind === 158 /* TypePredicate */) { return resolveEntityName(entityName, /*meaning*/ 1 /* FunctionScopedVariable */); } // Do we want to return undefined here? return undefined; } function getSymbolAtLocation(node) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined; } if (isInsideWithStatementBody(node)) { @@ -43630,12 +45443,12 @@ var ts; else if (ts.isLiteralComputedPropertyDeclarationName(node)) { return getSymbolOfNode(node.parent.parent); } - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { if (isInRightSideOfImportOrExportAssignment(node)) { return getSymbolOfEntityNameOrPropertyAccessExpression(node); } - else if (node.parent.kind === 175 /* BindingElement */ && - node.parent.parent.kind === 173 /* ObjectBindingPattern */ && + else if (node.parent.kind === 176 /* BindingElement */ && + node.parent.parent.kind === 174 /* ObjectBindingPattern */ && node === node.parent.propertyName) { var typeOfPattern = getTypeOfNode(node.parent.parent); var propertyDeclaration = typeOfPattern && getPropertyOfType(typeOfPattern, node.text); @@ -43645,11 +45458,11 @@ var ts; } } switch (node.kind) { - case 70 /* Identifier */: - case 178 /* PropertyAccessExpression */: - case 142 /* QualifiedName */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: + case 143 /* QualifiedName */: return getSymbolOfEntityNameOrPropertyAccessExpression(node); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false); if (ts.isFunctionLike(container)) { var sig = getSignatureFromDeclaration(container); @@ -43657,16 +45470,16 @@ var ts; return sig.thisParameter; } } - // fallthrough - case 96 /* SuperKeyword */: + // falls through + case 97 /* SuperKeyword */: var type = ts.isPartOfExpression(node) ? getTypeOfExpression(node) : getTypeFromTypeNode(node); return type.symbol; - case 168 /* ThisType */: + case 169 /* ThisType */: return getTypeFromTypeNode(node).symbol; - case 122 /* ConstructorKeyword */: + case 123 /* ConstructorKeyword */: // constructor keyword for an overload, should take us to the definition if it exist var constructorDeclaration = node.parent; - if (constructorDeclaration && constructorDeclaration.kind === 151 /* Constructor */) { + if (constructorDeclaration && constructorDeclaration.kind === 152 /* Constructor */) { return constructorDeclaration.parent.symbol; } return undefined; @@ -43674,17 +45487,17 @@ var ts; // External module name in an import declaration if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) || - ((node.parent.kind === 237 /* ImportDeclaration */ || node.parent.kind === 243 /* ExportDeclaration */) && + ((node.parent.kind === 238 /* ImportDeclaration */ || node.parent.kind === 244 /* ExportDeclaration */) && node.parent.moduleSpecifier === node)) { return resolveExternalModuleName(node, node); } if (ts.isInJavaScriptFile(node) && ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) { return resolveExternalModuleName(node, node); } - // Fall through + // falls through case 8 /* NumericLiteral */: // index access - if (node.parent.kind === 179 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { + if (node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node) { var objectType = getTypeOfExpression(node.parent.expression); if (objectType === unknownType) return undefined; @@ -43701,7 +45514,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 === 261 /* ShorthandPropertyAssignment */) { + if (location && location.kind === 262 /* ShorthandPropertyAssignment */) { return resolveEntityName(location.name, 107455 /* Value */ | 8388608 /* Alias */); } return undefined; @@ -43718,7 +45531,13 @@ var ts; return unknownType; } if (ts.isPartOfTypeNode(node)) { - return getTypeFromTypeNode(node); + var typeFromTypeNode = getTypeFromTypeNode(node); + if (typeFromTypeNode && ts.isExpressionWithTypeArgumentsInClassImplementsClause(node)) { + var containingClass = ts.getContainingClass(node); + var classType = getTypeOfNode(containingClass); + typeFromTypeNode = getTypeWithThisArgument(typeFromTypeNode, classType.thisType); + } + return typeFromTypeNode; } if (ts.isPartOfExpression(node)) { return getRegularTypeOfExpression(node); @@ -43726,7 +45545,10 @@ var ts; if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(node)) { // A SyntaxKind.ExpressionWithTypeArguments is considered a type node, except when it occurs in the // extends clause of a class. We handle that case here. - return getBaseTypes(getDeclaredTypeOfSymbol(getSymbolOfNode(node.parent.parent)))[0]; + var classNode = ts.getContainingClass(node); + var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classNode)); + var baseType = getBaseTypes(classType)[0]; + return baseType && getTypeWithThisArgument(baseType, classType.thisType); } if (isTypeDeclaration(node)) { // In this case, we call getSymbolOfNode instead of getSymbolAtLocation because it is a declaration @@ -43763,31 +45585,31 @@ var ts; // [ a ] from // [a] = [ some array ...] function getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr) { - ts.Debug.assert(expr.kind === 177 /* ObjectLiteralExpression */ || expr.kind === 176 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.kind === 178 /* ObjectLiteralExpression */ || expr.kind === 177 /* ArrayLiteralExpression */); // If this is from "for of" // for ( { a } of elems) { // } - if (expr.parent.kind === 215 /* ForOfStatement */) { - var iteratedType = checkRightHandSideOfForOf(expr.parent.expression); + if (expr.parent.kind === 216 /* ForOfStatement */) { + var iteratedType = checkRightHandSideOfForOf(expr.parent.expression, expr.parent.awaitModifier); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from "for" initializer // for ({a } = elems[0];.....) { } - if (expr.parent.kind === 193 /* BinaryExpression */) { + if (expr.parent.kind === 194 /* BinaryExpression */) { var iteratedType = getTypeOfExpression(expr.parent.right); return checkDestructuringAssignment(expr, iteratedType || unknownType); } // If this is from nested object binding pattern // for ({ skills: { primary, secondary } } = multiRobot, i = 0; i < 1; i++) { - if (expr.parent.kind === 260 /* PropertyAssignment */) { + if (expr.parent.kind === 261 /* PropertyAssignment */) { var typeOfParentObjectLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent.parent); return checkObjectLiteralDestructuringPropertyAssignment(typeOfParentObjectLiteral || unknownType, expr.parent); } // Array literal assignment - array destructuring pattern - ts.Debug.assert(expr.parent.kind === 176 /* ArrayLiteralExpression */); + ts.Debug.assert(expr.parent.kind === 177 /* ArrayLiteralExpression */); // [{ property1: p1, property2 }] = elems; var typeOfArrayLiteral = getTypeOfArrayLiteralOrObjectLiteralDestructuringAssignment(expr.parent); - var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false) || unknownType; + var elementType = checkIteratedTypeOrElementType(typeOfArrayLiteral || unknownType, expr.parent, /*allowStringInput*/ false, /*allowAsyncIterable*/ false) || unknownType; return checkArrayLiteralDestructuringElementAssignment(expr.parent, typeOfArrayLiteral, ts.indexOf(expr.parent.elements, expr), elementType || unknownType); } // Gets the property symbol corresponding to the property in destructuring assignment @@ -43808,9 +45630,9 @@ var ts; return getRegularTypeOfLiteralType(getTypeOfExpression(expr)); } /** - * Gets either the static or instance type of a class element, based on - * whether the element is declared as "static". - */ + * Gets either the static or instance type of a class element, based on + * whether the element is declared as "static". + */ function getParentTypeOfClassElement(node) { var classSymbol = getSymbolOfNode(node.parent); return ts.getModifierFlags(node) & 32 /* Static */ @@ -43832,7 +45654,7 @@ var ts; return getNamedMembers(propsByName); } function getRootSymbols(symbol) { - if (getCheckFlags(symbol) & 2 /* SyntheticProperty */) { + if (getCheckFlags(symbol) & 6 /* Synthetic */) { var symbols_3 = []; var name_2 = symbol.name; ts.forEach(getSymbolLinks(symbol).containingType.types, function (t) { @@ -43846,10 +45668,10 @@ var ts; else if (symbol.flags & 134217728 /* Transient */) { if (symbol.leftSpread) { var links = symbol; - return [links.leftSpread, links.rightSpread]; + return getRootSymbols(links.leftSpread).concat(getRootSymbols(links.rightSpread)); } - if (symbol.mappedTypeOrigin) { - return getRootSymbols(symbol.mappedTypeOrigin); + if (symbol.syntheticOrigin) { + return getRootSymbols(symbol.syntheticOrigin); } var target = void 0; var next = symbol; @@ -43867,7 +45689,7 @@ var ts; if (!ts.isGeneratedIdentifier(node)) { node = ts.getParseTreeNode(node, ts.isIdentifier); if (node) { - var isPropertyName_1 = node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + var isPropertyName_1 = node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.name === node; return !isPropertyName_1 && getReferencedValueSymbol(node) === argumentsSymbol; } } @@ -43922,20 +45744,16 @@ var ts; } symbol = exportSymbol; } - var parentSymbol = getParentOfSymbol(symbol); - if (parentSymbol) { - if (parentSymbol.flags & 512 /* ValueModule */ && parentSymbol.valueDeclaration.kind === 264 /* SourceFile */) { - var symbolFile = parentSymbol.valueDeclaration; + var parentSymbol_1 = getParentOfSymbol(symbol); + if (parentSymbol_1) { + if (parentSymbol_1.flags & 512 /* ValueModule */ && parentSymbol_1.valueDeclaration.kind === 265 /* SourceFile */) { + var symbolFile = parentSymbol_1.valueDeclaration; var referenceFile = ts.getSourceFileOfNode(node); // If `node` accesses an export and that export isn't in the same file, then symbol is a namespace export, so return undefined. var symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - for (var n = node.parent; n; n = n.parent) { - if (ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) { - return n; - } - } + return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; }); } } } @@ -43981,7 +45799,7 @@ var ts; // they will not collide with anything var isDeclaredInLoop = nodeLinks_1.flags & 262144 /* BlockScopedBindingInLoop */; var inLoopInitializer = ts.isIterationStatement(container, /*lookInLabeledStatements*/ false); - var inLoopBodyBlock = container.kind === 206 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); + var inLoopBodyBlock = container.kind === 207 /* Block */ && ts.isIterationStatement(container.parent, /*lookInLabeledStatements*/ false); links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock)); } else { @@ -44021,24 +45839,19 @@ var ts; return false; } function isValueAliasDeclaration(node) { - node = ts.getParseTreeNode(node); - if (node === undefined) { - // A synthesized node comes from an emit transformation and is always a value. - return true; - } switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: - case 238 /* ImportClause */: - case 239 /* NamespaceImport */: - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: var exportClause = node.exportClause; return exportClause && ts.forEach(exportClause.elements, isValueAliasDeclaration); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return node.expression - && node.expression.kind === 70 /* Identifier */ + && node.expression.kind === 71 /* Identifier */ ? isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) : true; } @@ -44046,7 +45859,7 @@ var ts; } function isTopLevelValueImportEqualsWithEntityName(node) { node = ts.getParseTreeNode(node, ts.isImportEqualsDeclaration); - if (node === undefined || node.parent.kind !== 264 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { + if (node === undefined || node.parent.kind !== 265 /* SourceFile */ || !ts.isInternalModuleImportEqualsDeclaration(node)) { // parent is not source file or it is not reference to internal module return false; } @@ -44067,11 +45880,6 @@ var ts; return isConstEnumSymbol(s) || s.constEnumOnlyModule; } function isReferencedAliasDeclaration(node, checkChildren) { - node = ts.getParseTreeNode(node); - // Purely synthesized nodes are always emitted. - if (node === undefined) { - return true; - } if (ts.isAliasSymbolDeclaration(node)) { var symbol = getSymbolOfNode(node); if (symbol && getSymbolLinks(symbol).referenced) { @@ -44110,15 +45918,23 @@ var ts; !(ts.getModifierFlags(parameter) & 92 /* ParameterPropertyModifier */); } function getNodeCheckFlags(node) { - node = ts.getParseTreeNode(node); - return node ? getNodeLinks(node).flags : undefined; + return getNodeLinks(node).flags; } function getEnumMemberValue(node) { computeEnumMemberValues(node.parent); return getNodeLinks(node).enumMemberValue; } + function canHaveConstantValue(node) { + switch (node.kind) { + case 264 /* EnumMember */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: + return true; + } + return false; + } function getConstantValue(node) { - if (node.kind === 263 /* EnumMember */) { + if (node.kind === 264 /* EnumMember */) { return getEnumMemberValue(node); } var symbol = getNodeLinks(node).resolvedSymbol; @@ -44139,7 +45955,7 @@ var ts; // Resolve the symbol as a type so that we can provide a more useful hint for the type serializer. var typeSymbol = resolveEntityName(typeName, 793064 /* Type */, /*ignoreErrors*/ true, /*dontResolveAlias*/ false, location); if (valueSymbol && valueSymbol === typeSymbol) { - var globalPromiseSymbol = tryGetGlobalPromiseConstructorSymbol(); + var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(/*reportErrors*/ false); if (globalPromiseSymbol && valueSymbol === globalPromiseSymbol) { return ts.TypeReferenceSerializationKind.Promise; } @@ -44278,10 +46094,21 @@ var ts; getReferencedImportDeclaration: getReferencedImportDeclaration, getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName, isDeclarationWithCollidingName: isDeclarationWithCollidingName, - isValueAliasDeclaration: isValueAliasDeclaration, + isValueAliasDeclaration: function (node) { + node = ts.getParseTreeNode(node); + // Synthesized nodes are always treated like values. + return node ? isValueAliasDeclaration(node) : true; + }, hasGlobalName: hasGlobalName, - isReferencedAliasDeclaration: isReferencedAliasDeclaration, - getNodeCheckFlags: getNodeCheckFlags, + isReferencedAliasDeclaration: function (node, checkChildren) { + node = ts.getParseTreeNode(node); + // Synthesized nodes are always treated as referenced. + return node ? isReferencedAliasDeclaration(node, checkChildren) : true; + }, + getNodeCheckFlags: function (node) { + node = ts.getParseTreeNode(node); + return node ? getNodeCheckFlags(node) : undefined; + }, isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName, isDeclarationVisible: isDeclarationVisible, isImplementationOfOverload: isImplementationOfOverload, @@ -44292,7 +46119,10 @@ var ts; writeBaseConstructorTypeOfClass: writeBaseConstructorTypeOfClass, isSymbolAccessible: isSymbolAccessible, isEntityNameVisible: isEntityNameVisible, - getConstantValue: getConstantValue, + getConstantValue: function (node) { + node = ts.getParseTreeNode(node, canHaveConstantValue); + return node ? getConstantValue(node) : undefined; + }, collectLinkedAliases: collectLinkedAliases, getReferencedValueDeclaration: getReferencedValueDeclaration, getTypeReferenceSerializationKind: getTypeReferenceSerializationKind, @@ -44315,7 +46145,7 @@ var ts; // property access can only be used as values // qualified names can only be used as types\namespaces // identifiers are treated as values only if they appear in type queries - var meaning = (node.kind === 178 /* PropertyAccessExpression */) || (node.kind === 70 /* Identifier */ && isInTypeQuery(node)) + var meaning = (node.kind === 179 /* PropertyAccessExpression */) || (node.kind === 71 /* Identifier */ && isInTypeQuery(node)) ? 107455 /* Value */ | 1048576 /* ExportValue */ : 793064 /* Type */ | 1920 /* Namespace */; var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true); @@ -44366,7 +46196,7 @@ var ts; break; } } - if (current.valueDeclaration && current.valueDeclaration.kind === 264 /* SourceFile */ && current.flags & 512 /* ValueModule */) { + if (current.valueDeclaration && current.valueDeclaration.kind === 265 /* SourceFile */ && current.flags & 512 /* ValueModule */) { return false; } // check that at least one declaration of top level symbol originates from type declaration file @@ -44386,7 +46216,7 @@ var ts; if (!moduleSymbol) { return undefined; } - return ts.getDeclarationOfKind(moduleSymbol, 264 /* SourceFile */); + return ts.getDeclarationOfKind(moduleSymbol, 265 /* SourceFile */); } function initializeTypeChecker() { // Bind all source files and propagate errors @@ -44431,58 +46261,30 @@ var ts; // Setup global builtins addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0); getSymbolLinks(undefinedSymbol).type = undefinedWideningType; - getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments"); + getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", /*arity*/ 0, /*reportErrors*/ true); getSymbolLinks(unknownSymbol).type = unknownType; // Initialize special types - globalArrayType = getGlobalType("Array", /*arity*/ 1); - globalObjectType = getGlobalType("Object"); - globalFunctionType = getGlobalType("Function"); - globalStringType = getGlobalType("String"); - globalNumberType = getGlobalType("Number"); - globalBooleanType = getGlobalType("Boolean"); - globalRegExpType = getGlobalType("RegExp"); - jsxElementType = getExportedTypeFromNamespace("JSX", JsxNames.Element); - getGlobalClassDecoratorType = ts.memoize(function () { return getGlobalType("ClassDecorator"); }); - getGlobalPropertyDecoratorType = ts.memoize(function () { return getGlobalType("PropertyDecorator"); }); - getGlobalMethodDecoratorType = ts.memoize(function () { return getGlobalType("MethodDecorator"); }); - getGlobalParameterDecoratorType = ts.memoize(function () { return getGlobalType("ParameterDecorator"); }); - getGlobalTypedPropertyDescriptorType = ts.memoize(function () { return getGlobalType("TypedPropertyDescriptor", /*arity*/ 1); }); - getGlobalESSymbolConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Symbol"); }); - getGlobalPromiseType = ts.memoize(function () { return getGlobalType("Promise", /*arity*/ 1); }); - tryGetGlobalPromiseType = ts.memoize(function () { return getGlobalSymbol("Promise", 793064 /* Type */, /*diagnostic*/ undefined) && getGlobalPromiseType(); }); - getGlobalPromiseLikeType = ts.memoize(function () { return getGlobalType("PromiseLike", /*arity*/ 1); }); - getInstantiatedGlobalPromiseLikeType = ts.memoize(createInstantiatedPromiseLikeType); - getGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalValueSymbol("Promise"); }); - tryGetGlobalPromiseConstructorSymbol = ts.memoize(function () { return getGlobalSymbol("Promise", 107455 /* Value */, /*diagnostic*/ undefined) && getGlobalPromiseConstructorSymbol(); }); - getGlobalPromiseConstructorLikeType = ts.memoize(function () { return getGlobalType("PromiseConstructorLike"); }); - getGlobalThenableType = ts.memoize(createThenableType); - getGlobalTemplateStringsArrayType = ts.memoize(function () { return getGlobalType("TemplateStringsArray"); }); - if (languageVersion >= 2 /* ES2015 */) { - getGlobalESSymbolType = ts.memoize(function () { return getGlobalType("Symbol"); }); - getGlobalIterableType = ts.memoize(function () { return getGlobalType("Iterable", /*arity*/ 1); }); - getGlobalIteratorType = ts.memoize(function () { return getGlobalType("Iterator", /*arity*/ 1); }); - getGlobalIterableIteratorType = ts.memoize(function () { return getGlobalType("IterableIterator", /*arity*/ 1); }); - } - else { - getGlobalESSymbolType = ts.memoize(function () { return emptyObjectType; }); - getGlobalIterableType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIteratorType = ts.memoize(function () { return emptyGenericType; }); - getGlobalIterableIteratorType = ts.memoize(function () { return emptyGenericType; }); - } + globalArrayType = getGlobalType("Array", /*arity*/ 1, /*reportErrors*/ true); + globalObjectType = getGlobalType("Object", /*arity*/ 0, /*reportErrors*/ true); + globalFunctionType = getGlobalType("Function", /*arity*/ 0, /*reportErrors*/ true); + globalStringType = getGlobalType("String", /*arity*/ 0, /*reportErrors*/ true); + globalNumberType = getGlobalType("Number", /*arity*/ 0, /*reportErrors*/ true); + globalBooleanType = getGlobalType("Boolean", /*arity*/ 0, /*reportErrors*/ true); + globalRegExpType = getGlobalType("RegExp", /*arity*/ 0, /*reportErrors*/ true); anyArrayType = createArrayType(anyType); autoArrayType = createArrayType(autoType); - var symbol = getGlobalSymbol("ReadonlyArray", 793064 /* Type */, /*diagnostic*/ undefined); - globalReadonlyArrayType = symbol && getTypeOfGlobalSymbol(symbol, /*arity*/ 1); + globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", /*arity*/ 1); anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType; + globalThisType = getGlobalTypeOrUndefined("ThisType", /*arity*/ 1); } function checkExternalEmitHelpers(location, helpers) { if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) { var sourceFile = ts.getSourceFileOfNode(location); - if (ts.isEffectiveExternalModule(sourceFile, compilerOptions)) { + if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !ts.isInAmbientContext(location)) { var helpersModule = resolveHelpersModule(sourceFile, location); if (helpersModule !== unknownSymbol) { var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers; - for (var helper = 1 /* FirstEmitHelper */; helper <= 128 /* LastEmitHelper */; helper <<= 1) { + for (var helper = 1 /* FirstEmitHelper */; helper <= 8192 /* LastEmitHelper */; helper <<= 1) { if (uncheckedHelpers & helper) { var name = getHelperName(helper); var symbol = getSymbol(helpersModule.exports, ts.escapeIdentifier(name), 107455 /* Value */); @@ -44506,6 +46308,13 @@ var ts; case 32 /* Param */: return "__param"; case 64 /* Awaiter */: return "__awaiter"; case 128 /* Generator */: return "__generator"; + case 256 /* Values */: return "__values"; + case 512 /* Read */: return "__read"; + case 1024 /* Spread */: return "__spread"; + case 2048 /* AsyncGenerator */: return "__asyncGenerator"; + case 4096 /* AsyncDelegator */: return "__asyncDelegator"; + case 8192 /* AsyncValues */: return "__asyncValues"; + default: ts.Debug.fail("Unrecognized helper."); } } function resolveHelpersModule(node, errorNode) { @@ -44514,38 +46323,20 @@ var ts; } return externalHelpersModule; } - function createInstantiatedPromiseLikeType() { - var promiseLikeType = getGlobalPromiseLikeType(); - if (promiseLikeType !== emptyGenericType) { - return createTypeReference(promiseLikeType, [anyType]); - } - return emptyObjectType; - } - function createThenableType() { - // build the thenable type that is used to verify against a non-promise "thenable" operand to `await`. - var thenPropertySymbol = createSymbol(4 /* Property */, "then"); - getSymbolLinks(thenPropertySymbol).type = globalFunctionType; - var thenableType = createObjectType(16 /* Anonymous */); - thenableType.properties = [thenPropertySymbol]; - thenableType.members = createSymbolTable(thenableType.properties); - thenableType.callSignatures = []; - thenableType.constructSignatures = []; - return thenableType; - } // GRAMMAR CHECKING function checkGrammarDecorators(node) { if (!node.decorators) { return false; } if (!ts.nodeCanBeDecorated(node)) { - if (node.kind === 150 /* MethodDeclaration */ && !ts.nodeIsPresent(node.body)) { + if (node.kind === 151 /* 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 === 152 /* GetAccessor */ || node.kind === 153 /* SetAccessor */) { + else if (node.kind === 153 /* GetAccessor */ || node.kind === 154 /* 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); @@ -44562,28 +46353,28 @@ var ts; var flags = 0 /* None */; for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 130 /* ReadonlyKeyword */) { - if (node.kind === 147 /* PropertySignature */ || node.kind === 149 /* MethodSignature */) { + if (modifier.kind !== 131 /* ReadonlyKeyword */) { + if (node.kind === 148 /* PropertySignature */ || node.kind === 150 /* MethodSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind)); } - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind)); } } switch (modifier.kind) { - case 75 /* ConstKeyword */: - if (node.kind !== 231 /* EnumDeclaration */ && node.parent.kind === 228 /* ClassDeclaration */) { - return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(75 /* ConstKeyword */)); + case 76 /* ConstKeyword */: + if (node.kind !== 232 /* EnumDeclaration */ && node.parent.kind === 229 /* ClassDeclaration */) { + return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(76 /* ConstKeyword */)); } break; - case 113 /* PublicKeyword */: - case 112 /* ProtectedKeyword */: - case 111 /* PrivateKeyword */: + case 114 /* PublicKeyword */: + case 113 /* ProtectedKeyword */: + case 112 /* PrivateKeyword */: var text = visibilityToString(ts.modifierToFlag(modifier.kind)); - if (modifier.kind === 112 /* ProtectedKeyword */) { + if (modifier.kind === 113 /* ProtectedKeyword */) { lastProtected = modifier; } - else if (modifier.kind === 111 /* PrivateKeyword */) { + else if (modifier.kind === 112 /* PrivateKeyword */) { lastPrivate = modifier; } if (flags & 28 /* AccessibilityModifier */) { @@ -44598,11 +46389,11 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async"); } - else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + else if (node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* 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 === 111 /* PrivateKeyword */) { + if (modifier.kind === 112 /* PrivateKeyword */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract"); } else { @@ -44611,7 +46402,7 @@ var ts; } flags |= ts.modifierToFlag(modifier.kind); break; - case 114 /* StaticKeyword */: + case 115 /* StaticKeyword */: if (flags & 32 /* Static */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static"); } @@ -44621,10 +46412,10 @@ var ts; else if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async"); } - else if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + else if (node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* SourceFile */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static"); } else if (flags & 128 /* Abstract */) { @@ -44633,18 +46424,18 @@ var ts; flags |= 32 /* Static */; lastStatic = modifier; break; - case 130 /* ReadonlyKeyword */: + case 131 /* ReadonlyKeyword */: if (flags & 64 /* Readonly */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly"); } - else if (node.kind !== 148 /* PropertyDeclaration */ && node.kind !== 147 /* PropertySignature */ && node.kind !== 156 /* IndexSignature */ && node.kind !== 145 /* Parameter */) { + else if (node.kind !== 149 /* PropertyDeclaration */ && node.kind !== 148 /* PropertySignature */ && node.kind !== 157 /* IndexSignature */ && node.kind !== 146 /* Parameter */) { // If node.kind === SyntaxKind.Parameter, checkParameter report an error if it's not a parameter property. return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature); } flags |= 64 /* Readonly */; lastReadonly = modifier; break; - case 83 /* ExportKeyword */: + case 84 /* ExportKeyword */: if (flags & 1 /* Export */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export"); } @@ -44657,45 +46448,45 @@ 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 === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "export"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } flags |= 1 /* Export */; break; - case 123 /* DeclareKeyword */: + case 124 /* DeclareKeyword */: 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 === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* ClassDeclaration */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_class_element, "declare"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } - else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 233 /* ModuleBlock */) { + else if (ts.isInAmbientContext(node.parent) && node.parent.kind === 234 /* ModuleBlock */) { return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } flags |= 2 /* Ambient */; lastDeclare = modifier; break; - case 116 /* AbstractKeyword */: + case 117 /* AbstractKeyword */: if (flags & 128 /* Abstract */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract"); } - if (node.kind !== 228 /* ClassDeclaration */) { - if (node.kind !== 150 /* MethodDeclaration */ && - node.kind !== 148 /* PropertyDeclaration */ && - node.kind !== 152 /* GetAccessor */ && - node.kind !== 153 /* SetAccessor */) { + if (node.kind !== 229 /* ClassDeclaration */) { + if (node.kind !== 151 /* MethodDeclaration */ && + node.kind !== 149 /* PropertyDeclaration */ && + node.kind !== 153 /* GetAccessor */ && + node.kind !== 154 /* SetAccessor */) { return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration); } - if (!(node.parent.kind === 228 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { + if (!(node.parent.kind === 229 /* ClassDeclaration */ && ts.getModifierFlags(node.parent) & 128 /* Abstract */)) { return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class); } if (flags & 32 /* Static */) { @@ -44707,14 +46498,14 @@ var ts; } flags |= 128 /* Abstract */; break; - case 119 /* AsyncKeyword */: + case 120 /* AsyncKeyword */: if (flags & 256 /* Async */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async"); } else if (flags & 2 /* Ambient */ || ts.isInAmbientContext(node.parent)) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async"); } - else if (node.kind === 145 /* Parameter */) { + else if (node.kind === 146 /* Parameter */) { return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async"); } flags |= 256 /* Async */; @@ -44722,7 +46513,7 @@ var ts; break; } } - if (node.kind === 151 /* Constructor */) { + if (node.kind === 152 /* Constructor */) { if (flags & 32 /* Static */) { return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static"); } @@ -44737,13 +46528,13 @@ var ts; } return; } - else if ((node.kind === 237 /* ImportDeclaration */ || node.kind === 236 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { + else if ((node.kind === 238 /* ImportDeclaration */ || node.kind === 237 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) { return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { + else if (node.kind === 146 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && ts.isBindingPattern(node.name)) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === 145 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { + else if (node.kind === 146 /* Parameter */ && (flags & 92 /* ParameterPropertyModifier */) && node.dotDotDotToken) { return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & 256 /* Async */) { @@ -44763,38 +46554,38 @@ var ts; } function shouldReportBadModifier(node) { switch (node.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 151 /* Constructor */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 156 /* IndexSignature */: - case 232 /* ModuleDeclaration */: - case 237 /* ImportDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 243 /* ExportDeclaration */: - case 242 /* ExportAssignment */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 145 /* Parameter */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 152 /* Constructor */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 157 /* IndexSignature */: + case 233 /* ModuleDeclaration */: + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 244 /* ExportDeclaration */: + case 243 /* ExportAssignment */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 146 /* Parameter */: return false; default: - if (node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + if (node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* SourceFile */) { return false; } switch (node.kind) { - case 227 /* FunctionDeclaration */: - return nodeHasAnyModifiersExcept(node, 119 /* AsyncKeyword */); - case 228 /* ClassDeclaration */: - return nodeHasAnyModifiersExcept(node, 116 /* AbstractKeyword */); - case 229 /* InterfaceDeclaration */: - case 207 /* VariableStatement */: - case 230 /* TypeAliasDeclaration */: + case 228 /* FunctionDeclaration */: + return nodeHasAnyModifiersExcept(node, 120 /* AsyncKeyword */); + case 229 /* ClassDeclaration */: + return nodeHasAnyModifiersExcept(node, 117 /* AbstractKeyword */); + case 230 /* InterfaceDeclaration */: + case 208 /* VariableStatement */: + case 231 /* TypeAliasDeclaration */: return true; - case 231 /* EnumDeclaration */: - return nodeHasAnyModifiersExcept(node, 75 /* ConstKeyword */); + case 232 /* EnumDeclaration */: + return nodeHasAnyModifiersExcept(node, 76 /* ConstKeyword */); default: ts.Debug.fail(); return false; @@ -44806,14 +46597,11 @@ var ts; } function checkGrammarAsyncModifier(node, asyncModifier) { switch (node.kind) { - case 150 /* MethodDeclaration */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - if (!node.asteriskToken) { - return false; - } - break; + case 151 /* MethodDeclaration */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + return false; } return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async"); } @@ -44871,8 +46659,12 @@ var ts; return checkGrammarDecorators(node) || checkGrammarModifiers(node) || checkGrammarTypeParameterList(node.typeParameters, file) || checkGrammarParameterList(node.parameters) || checkGrammarArrowFunction(node, file); } + function checkGrammarClassLikeDeclaration(node) { + var file = ts.getSourceFileOfNode(node); + return checkGrammarClassDeclarationHeritageClauses(node) || checkGrammarTypeParameterList(node.typeParameters, file); + } function checkGrammarArrowFunction(node, file) { - if (node.kind === 186 /* ArrowFunction */) { + if (node.kind === 187 /* ArrowFunction */) { var arrowFunction = node; var startLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.pos).line; var endLine = ts.getLineAndCharacterOfPosition(file, arrowFunction.equalsGreaterThanToken.end).line; @@ -44907,7 +46699,7 @@ var ts; if (!parameter.type) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation); } - if (parameter.type.kind !== 135 /* StringKeyword */ && parameter.type.kind !== 132 /* NumberKeyword */) { + if (parameter.type.kind !== 136 /* StringKeyword */ && parameter.type.kind !== 133 /* NumberKeyword */) { return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_string_or_number); } if (!node.type) { @@ -44935,7 +46727,7 @@ var ts; var sourceFile = ts.getSourceFileOfNode(node); for (var _i = 0, args_4 = args; _i < args_4.length; _i++) { var arg = args_4[_i]; - if (arg.kind === 199 /* OmittedExpression */) { + if (arg.kind === 200 /* OmittedExpression */) { return grammarErrorAtPos(sourceFile, arg.pos, 0, ts.Diagnostics.Argument_expression_expected); } } @@ -44961,7 +46753,7 @@ var ts; if (!checkGrammarDecorators(node) && !checkGrammarModifiers(node) && node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84 /* ExtendsKeyword */) { + if (heritageClause.token === 85 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } @@ -44974,7 +46766,7 @@ var ts; seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); if (seenImplementsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen); } @@ -44990,14 +46782,14 @@ var ts; if (node.heritageClauses) { for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) { var heritageClause = _a[_i]; - if (heritageClause.token === 84 /* ExtendsKeyword */) { + if (heritageClause.token === 85 /* ExtendsKeyword */) { if (seenExtendsClause) { return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen); } seenExtendsClause = true; } else { - ts.Debug.assert(heritageClause.token === 107 /* ImplementsKeyword */); + ts.Debug.assert(heritageClause.token === 108 /* ImplementsKeyword */); return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause); } // Grammar checking heritageClause inside class declaration @@ -45008,28 +46800,25 @@ var ts; } function checkGrammarComputedPropertyName(node) { // If node is not a computedPropertyName, just skip the grammar checking - if (node.kind !== 143 /* ComputedPropertyName */) { + if (node.kind !== 144 /* ComputedPropertyName */) { return false; } var computedPropertyName = node; - if (computedPropertyName.expression.kind === 193 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 25 /* CommaToken */) { + if (computedPropertyName.expression.kind === 194 /* BinaryExpression */ && computedPropertyName.expression.operatorToken.kind === 26 /* 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 === 227 /* FunctionDeclaration */ || - node.kind === 185 /* FunctionExpression */ || - node.kind === 150 /* MethodDeclaration */); + ts.Debug.assert(node.kind === 228 /* FunctionDeclaration */ || + node.kind === 186 /* FunctionExpression */ || + node.kind === 151 /* MethodDeclaration */); if (ts.isInAmbientContext(node)) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context); } if (!node.body) { return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator); } - if (languageVersion < 2 /* ES2015 */) { - return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_only_available_when_targeting_ECMAScript_2015_or_higher); - } } } function checkGrammarForInvalidQuestionMark(questionToken, message) { @@ -45045,15 +46834,15 @@ var ts; var GetOrSetAccessor = GetAccessor | SetAccessor; for (var _i = 0, _a = node.properties; _i < _a.length; _i++) { var prop = _a[_i]; - if (prop.kind === 262 /* SpreadAssignment */) { + if (prop.kind === 263 /* SpreadAssignment */) { continue; } var name = prop.name; - if (name.kind === 143 /* ComputedPropertyName */) { + if (name.kind === 144 /* ComputedPropertyName */) { // If the name is not a ComputedPropertyName, the grammar checking will skip it checkGrammarComputedPropertyName(name); } - if (prop.kind === 261 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { + if (prop.kind === 262 /* ShorthandPropertyAssignment */ && !inDestructuring && prop.objectAssignmentInitializer) { // having objectAssignmentInitializer is only valid in ObjectAssignmentPattern // outside of destructuring it is a syntax error return grammarErrorOnNode(prop.equalsToken, ts.Diagnostics.can_only_be_used_in_an_object_literal_property_inside_a_destructuring_assignment); @@ -45062,7 +46851,7 @@ var ts; if (prop.modifiers) { for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) { var mod = _c[_b]; - if (mod.kind !== 119 /* AsyncKeyword */ || prop.kind !== 150 /* MethodDeclaration */) { + if (mod.kind !== 120 /* AsyncKeyword */ || prop.kind !== 151 /* MethodDeclaration */) { grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod)); } } @@ -45076,7 +46865,7 @@ var ts; // d.IsAccessorDescriptor(previous) is true and IsAccessorDescriptor(propId.descriptor) is true // and either both previous and propId.descriptor have[[Get]] fields or both previous and propId.descriptor have[[Set]] fields var currentKind = void 0; - if (prop.kind === 260 /* PropertyAssignment */ || prop.kind === 261 /* ShorthandPropertyAssignment */) { + if (prop.kind === 261 /* PropertyAssignment */ || prop.kind === 262 /* ShorthandPropertyAssignment */) { // Grammar checking for computedPropertyName and shorthandPropertyAssignment checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === 8 /* NumericLiteral */) { @@ -45084,13 +46873,13 @@ var ts; } currentKind = Property; } - else if (prop.kind === 150 /* MethodDeclaration */) { + else if (prop.kind === 151 /* MethodDeclaration */) { currentKind = Property; } - else if (prop.kind === 152 /* GetAccessor */) { + else if (prop.kind === 153 /* GetAccessor */) { currentKind = GetAccessor; } - else if (prop.kind === 153 /* SetAccessor */) { + else if (prop.kind === 154 /* SetAccessor */) { currentKind = SetAccessor; } else { @@ -45126,7 +46915,7 @@ var ts; var seen = ts.createMap(); for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) { var attr = _a[_i]; - if (attr.kind === 254 /* JsxSpreadAttribute */) { + if (attr.kind === 255 /* JsxSpreadAttribute */) { continue; } var jsxAttr = attr; @@ -45138,7 +46927,7 @@ var ts; return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name); } var initializer = jsxAttr.initializer; - if (initializer && initializer.kind === 255 /* JsxExpression */ && !initializer.expression) { + if (initializer && initializer.kind === 256 /* JsxExpression */ && !initializer.expression) { return grammarErrorOnNode(jsxAttr.initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression); } } @@ -45147,7 +46936,12 @@ var ts; if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) { return true; } - if (forInOrOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { + if (forInOrOfStatement.kind === 216 /* ForOfStatement */ && forInOrOfStatement.awaitModifier) { + if ((forInOrOfStatement.flags & 16384 /* AwaitContext */) === 0 /* None */) { + return grammarErrorOnNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator); + } + } + if (forInOrOfStatement.initializer.kind === 227 /* VariableDeclarationList */) { var variableList = forInOrOfStatement.initializer; if (!checkGrammarVariableDeclarationList(variableList)) { var declarations = variableList.declarations; @@ -45162,20 +46956,20 @@ var ts; return false; } if (declarations.length > 1) { - var diagnostic = forInOrOfStatement.kind === 214 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 215 /* 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 === 214 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 215 /* 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 === 214 /* ForInStatement */ + var diagnostic = forInOrOfStatement.kind === 215 /* 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); @@ -45202,11 +46996,11 @@ var ts; return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters); } else if (!doesAccessorHaveCorrectParameterCount(accessor)) { - return grammarErrorOnNode(accessor.name, kind === 152 /* GetAccessor */ ? + return grammarErrorOnNode(accessor.name, kind === 153 /* GetAccessor */ ? ts.Diagnostics.A_get_accessor_cannot_have_parameters : ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } - else if (kind === 153 /* SetAccessor */) { + else if (kind === 154 /* SetAccessor */) { if (accessor.type) { return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } @@ -45225,14 +47019,14 @@ var ts; } } /** Does the accessor have the right number of parameters? - - A get accessor has no parameters or a single `this` parameter. - A set accessor has one parameter or a `this` parameter and one more parameter */ + * A get accessor has no parameters or a single `this` parameter. + * A set accessor has one parameter or a `this` parameter and one more parameter. + */ function doesAccessorHaveCorrectParameterCount(accessor) { - return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 0 : 1); + return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 153 /* GetAccessor */ ? 0 : 1); } function getAccessorThisParameter(accessor) { - if (accessor.parameters.length === (accessor.kind === 152 /* GetAccessor */ ? 1 : 2)) { + if (accessor.parameters.length === (accessor.kind === 153 /* GetAccessor */ ? 1 : 2)) { return ts.getThisParameter(accessor); } } @@ -45247,7 +47041,7 @@ var ts; checkGrammarForGenerator(node)) { return true; } - if (node.parent.kind === 177 /* ObjectLiteralExpression */) { + if (node.parent.kind === 178 /* ObjectLiteralExpression */) { if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } @@ -45268,10 +47062,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 === 229 /* InterfaceDeclaration */) { + else if (node.parent.kind === 230 /* 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 === 162 /* TypeLiteral */) { + else if (node.parent.kind === 163 /* TypeLiteral */) { return checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_a_type_literal_must_directly_refer_to_a_built_in_symbol); } } @@ -45282,11 +47076,11 @@ var ts; return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary); } switch (current.kind) { - case 221 /* LabeledStatement */: + case 222 /* 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 === 216 /* ContinueStatement */ + var isMisplacedContinueLabel = node.kind === 217 /* 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); @@ -45294,8 +47088,8 @@ var ts; return false; } break; - case 220 /* SwitchStatement */: - if (node.kind === 217 /* BreakStatement */ && !node.label) { + case 221 /* SwitchStatement */: + if (node.kind === 218 /* BreakStatement */ && !node.label) { // unlabeled break within switch statement - ok return false; } @@ -45310,13 +47104,13 @@ var ts; current = current.parent; } if (node.label) { - var message = node.kind === 217 /* BreakStatement */ + var message = node.kind === 218 /* 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 === 217 /* BreakStatement */ + var message = node.kind === 218 /* 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); @@ -45328,7 +47122,7 @@ var ts; if (node !== ts.lastOrUndefined(elements)) { return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern); } - if (node.name.kind === 174 /* ArrayBindingPattern */ || node.name.kind === 173 /* ObjectBindingPattern */) { + if (node.name.kind === 175 /* ArrayBindingPattern */ || node.name.kind === 174 /* ObjectBindingPattern */) { return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern); } if (node.initializer) { @@ -45339,11 +47133,11 @@ var ts; } function isStringOrNumberLiteralExpression(expr) { return expr.kind === 9 /* StringLiteral */ || expr.kind === 8 /* NumericLiteral */ || - expr.kind === 191 /* PrefixUnaryExpression */ && expr.operator === 37 /* MinusToken */ && + expr.kind === 192 /* PrefixUnaryExpression */ && expr.operator === 38 /* MinusToken */ && expr.operand.kind === 8 /* NumericLiteral */; } function checkGrammarVariableDeclaration(node) { - if (node.parent.parent.kind !== 214 /* ForInStatement */ && node.parent.parent.kind !== 215 /* ForOfStatement */) { + if (node.parent.parent.kind !== 215 /* ForInStatement */ && node.parent.parent.kind !== 216 /* ForOfStatement */) { if (ts.isInAmbientContext(node)) { if (node.initializer) { if (ts.isConst(node) && !node.type) { @@ -45386,7 +47180,7 @@ var ts; return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name) { - if (name.kind === 70 /* Identifier */) { + if (name.kind === 71 /* Identifier */) { if (ts.unescapeIdentifier(name.text) === "__esModule") { return grammarErrorOnNode(name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules); } @@ -45402,8 +47196,8 @@ var ts; } } function checkGrammarNameInLetOrConstDeclarations(name) { - if (name.kind === 70 /* Identifier */) { - if (name.originalKeywordKind === 109 /* LetKeyword */) { + if (name.kind === 71 /* Identifier */) { + if (name.originalKeywordKind === 110 /* LetKeyword */) { return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations); } } @@ -45428,15 +47222,15 @@ var ts; } function allowLetAndConstDeclarations(parent) { switch (parent.kind) { - case 210 /* IfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 219 /* WithStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 211 /* IfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 220 /* WithStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: return false; - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return allowLetAndConstDeclarations(parent.parent); } return true; @@ -45452,9 +47246,9 @@ var ts; } } function checkGrammarMetaProperty(node) { - if (node.keywordToken === 93 /* NewKeyword */) { + if (node.keywordToken === 94 /* NewKeyword */) { if (node.name.text !== "target") { - return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0, node.name.text, ts.tokenToString(node.keywordToken), "target"); + return grammarErrorOnNode(node.name, ts.Diagnostics._0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2, node.name.text, ts.tokenToString(node.keywordToken), "target"); } } } @@ -45498,7 +47292,7 @@ var ts; return true; } } - else if (node.parent.kind === 229 /* InterfaceDeclaration */) { + else if (node.parent.kind === 230 /* InterfaceDeclaration */) { if (checkGrammarForNonSymbolComputedProperty(node.name, ts.Diagnostics.A_computed_property_name_in_an_interface_must_directly_refer_to_a_built_in_symbol)) { return true; } @@ -45506,7 +47300,7 @@ var ts; return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer); } } - else if (node.parent.kind === 162 /* TypeLiteral */) { + else if (node.parent.kind === 163 /* 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; } @@ -45531,13 +47325,13 @@ var ts; // export_opt AmbientDeclaration // // TODO: The spec needs to be amended to reflect this grammar. - if (node.kind === 229 /* InterfaceDeclaration */ || - node.kind === 230 /* TypeAliasDeclaration */ || - node.kind === 237 /* ImportDeclaration */ || - node.kind === 236 /* ImportEqualsDeclaration */ || - node.kind === 243 /* ExportDeclaration */ || - node.kind === 242 /* ExportAssignment */ || - node.kind === 235 /* NamespaceExportDeclaration */ || + if (node.kind === 230 /* InterfaceDeclaration */ || + node.kind === 231 /* TypeAliasDeclaration */ || + node.kind === 238 /* ImportDeclaration */ || + node.kind === 237 /* ImportEqualsDeclaration */ || + node.kind === 244 /* ExportDeclaration */ || + node.kind === 243 /* ExportAssignment */ || + node.kind === 236 /* NamespaceExportDeclaration */ || ts.getModifierFlags(node) & (2 /* Ambient */ | 1 /* Export */ | 512 /* Default */)) { return false; } @@ -45546,7 +47340,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 === 207 /* VariableStatement */) { + if (ts.isDeclaration(decl) || decl.kind === 208 /* VariableStatement */) { if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) { return true; } @@ -45572,7 +47366,7 @@ var ts; // 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 === 206 /* Block */ || node.parent.kind === 233 /* ModuleBlock */ || node.parent.kind === 264 /* SourceFile */) { + if (node.parent.kind === 207 /* Block */ || node.parent.kind === 234 /* ModuleBlock */ || node.parent.kind === 265 /* SourceFile */) { var links_1 = getNodeLinks(node.parent); // Check if the containing block ever report this error if (!links_1.hasReportedStatementInAmbientContext) { @@ -45588,19 +47382,19 @@ var ts; } function checkGrammarNumericLiteral(node) { // Grammar checking - if (node.isOctalLiteral) { + if (node.numericLiteralFlags & 4 /* Octal */) { var diagnosticMessage = void 0; if (languageVersion >= 1 /* ES5 */) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 172 /* LiteralType */)) { + else if (ts.isChildOfNodeWithKind(node, 173 /* LiteralType */)) { diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0; } - else if (ts.isChildOfNodeWithKind(node, 263 /* EnumMember */)) { + else if (ts.isChildOfNodeWithKind(node, 264 /* EnumMember */)) { diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0; } if (diagnosticMessage) { - var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 37 /* MinusToken */; + var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 38 /* MinusToken */; var literal = (withMinus ? "-" : "") + "0o" + node.text; return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal); } @@ -45629,446 +47423,19 @@ var ts; /// /// /// -/* @internal */ var ts; (function (ts) { - function reduceNode(node, f, initial) { - return node ? f(initial, node) : initial; - } - function reduceNodeArray(nodes, f, initial) { - return nodes ? f(initial, nodes) : initial; - } - /** - * Similar to `reduceLeft`, performs a reduction against each child of a node. - * NOTE: Unlike `forEachChild`, this does *not* visit every node. - * - * @param node The node containing the children to reduce. - * @param initial The initial value to supply to the reduction. - * @param f The callback function - */ - function reduceEachChild(node, initial, cbNode, cbNodeArray) { - if (node === undefined) { - return initial; - } - var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; - var cbNodes = cbNodeArray || cbNode; - var kind = node.kind; - // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { - return initial; - } - // We do not yet support types. - if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { - return initial; - } - var result = initial; - switch (node.kind) { - // Leaf nodes - case 205 /* SemicolonClassElement */: - case 208 /* EmptyStatement */: - case 199 /* OmittedExpression */: - case 224 /* DebuggerStatement */: - case 297 /* NotEmittedStatement */: - // No need to visit nodes with no children. - break; - // Names - case 142 /* QualifiedName */: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 143 /* ComputedPropertyName */: - result = reduceNode(node.expression, cbNode, result); - break; - // Signature elements - case 145 /* Parameter */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 146 /* Decorator */: - result = reduceNode(node.expression, cbNode, result); - break; - // Type member - case 148 /* PropertyDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 150 /* MethodDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 151 /* Constructor */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - case 152 /* GetAccessor */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 153 /* SetAccessor */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.body, cbNode, result); - break; - // Binding patterns - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 175 /* BindingElement */: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - // Expression - case 176 /* ArrayLiteralExpression */: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 177 /* ObjectLiteralExpression */: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 178 /* PropertyAccessExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 179 /* ElementAccessExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.argumentExpression, cbNode, result); - break; - case 180 /* CallExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 181 /* NewExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - result = reduceNodes(node.arguments, cbNodes, result); - break; - case 182 /* TaggedTemplateExpression */: - result = reduceNode(node.tag, cbNode, result); - result = reduceNode(node.template, cbNode, result); - break; - case 183 /* TypeAssertionExpression */: - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 185 /* FunctionExpression */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 186 /* ArrowFunction */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 184 /* ParenthesizedExpression */: - case 187 /* DeleteExpression */: - case 188 /* TypeOfExpression */: - case 189 /* VoidExpression */: - case 190 /* AwaitExpression */: - case 196 /* YieldExpression */: - case 197 /* SpreadElement */: - case 202 /* NonNullExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: - result = reduceNode(node.operand, cbNode, result); - break; - case 193 /* BinaryExpression */: - result = reduceNode(node.left, cbNode, result); - result = reduceNode(node.right, cbNode, result); - break; - case 194 /* ConditionalExpression */: - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.whenTrue, cbNode, result); - result = reduceNode(node.whenFalse, cbNode, result); - break; - case 195 /* TemplateExpression */: - result = reduceNode(node.head, cbNode, result); - result = reduceNodes(node.templateSpans, cbNodes, result); - break; - case 198 /* ClassExpression */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 200 /* ExpressionWithTypeArguments */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNodes(node.typeArguments, cbNodes, result); - break; - case 201 /* AsExpression */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.type, cbNode, result); - break; - case 202 /* NonNullExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - // Misc - case 204 /* TemplateSpan */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.literal, cbNode, result); - break; - // Element - case 206 /* Block */: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 207 /* VariableStatement */: - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.declarationList, cbNode, result); - break; - case 209 /* ExpressionStatement */: - result = reduceNode(node.expression, cbNode, result); - break; - case 210 /* IfStatement */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.thenStatement, cbNode, result); - result = reduceNode(node.elseStatement, cbNode, result); - break; - case 211 /* DoStatement */: - result = reduceNode(node.statement, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 212 /* WhileStatement */: - case 219 /* WithStatement */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 213 /* ForStatement */: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.condition, cbNode, result); - result = reduceNode(node.incrementor, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - result = reduceNode(node.initializer, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 218 /* ReturnStatement */: - case 222 /* ThrowStatement */: - result = reduceNode(node.expression, cbNode, result); - break; - case 220 /* SwitchStatement */: - result = reduceNode(node.expression, cbNode, result); - result = reduceNode(node.caseBlock, cbNode, result); - break; - case 221 /* LabeledStatement */: - result = reduceNode(node.label, cbNode, result); - result = reduceNode(node.statement, cbNode, result); - break; - case 223 /* TryStatement */: - result = reduceNode(node.tryBlock, cbNode, result); - result = reduceNode(node.catchClause, cbNode, result); - result = reduceNode(node.finallyBlock, cbNode, result); - break; - case 225 /* VariableDeclaration */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 226 /* VariableDeclarationList */: - result = reduceNodes(node.declarations, cbNodes, result); - break; - case 227 /* FunctionDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.parameters, cbNodes, result); - result = reduceNode(node.type, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 228 /* ClassDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.typeParameters, cbNodes, result); - result = reduceNodes(node.heritageClauses, cbNodes, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 231 /* EnumDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNodes(node.members, cbNodes, result); - break; - case 232 /* ModuleDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.body, cbNode, result); - break; - case 233 /* ModuleBlock */: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 234 /* CaseBlock */: - result = reduceNodes(node.clauses, cbNodes, result); - break; - case 236 /* ImportEqualsDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.moduleReference, cbNode, result); - break; - case 237 /* ImportDeclaration */: - result = reduceNodes(node.decorators, cbNodes, result); - result = reduceNodes(node.modifiers, cbNodes, result); - result = reduceNode(node.importClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - case 238 /* ImportClause */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.namedBindings, cbNode, result); - break; - case 239 /* NamespaceImport */: - result = reduceNode(node.name, cbNode, result); - break; - case 240 /* NamedImports */: - case 244 /* NamedExports */: - result = reduceNodes(node.elements, cbNodes, result); - break; - case 241 /* ImportSpecifier */: - case 245 /* ExportSpecifier */: - result = reduceNode(node.propertyName, cbNode, result); - result = reduceNode(node.name, cbNode, result); - break; - case 242 /* ExportAssignment */: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.expression, cbNode, result); - break; - case 243 /* ExportDeclaration */: - result = ts.reduceLeft(node.decorators, cbNode, result); - result = ts.reduceLeft(node.modifiers, cbNode, result); - result = reduceNode(node.exportClause, cbNode, result); - result = reduceNode(node.moduleSpecifier, cbNode, result); - break; - // Module references - case 247 /* ExternalModuleReference */: - result = reduceNode(node.expression, cbNode, result); - break; - // JSX - case 248 /* JsxElement */: - result = reduceNode(node.openingElement, cbNode, result); - result = ts.reduceLeft(node.children, cbNode, result); - result = reduceNode(node.closingElement, cbNode, result); - break; - case 249 /* JsxSelfClosingElement */: - case 250 /* JsxOpeningElement */: - result = reduceNode(node.tagName, cbNode, result); - result = reduceNode(node.attributes, cbNode, result); - break; - case 251 /* JsxClosingElement */: - result = reduceNode(node.tagName, cbNode, result); - break; - case 253 /* JsxAttributes */: - result = reduceNodes(node.properties, cbNodes, result); - break; - case 252 /* JsxAttribute */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 254 /* JsxSpreadAttribute */: - result = reduceNode(node.expression, cbNode, result); - break; - case 255 /* JsxExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - // Clauses - case 256 /* CaseClause */: - result = reduceNode(node.expression, cbNode, result); - // fall-through - case 257 /* DefaultClause */: - result = reduceNodes(node.statements, cbNodes, result); - break; - case 258 /* HeritageClause */: - result = reduceNodes(node.types, cbNodes, result); - break; - case 259 /* CatchClause */: - result = reduceNode(node.variableDeclaration, cbNode, result); - result = reduceNode(node.block, cbNode, result); - break; - // Property assignments - case 260 /* PropertyAssignment */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - break; - case 261 /* ShorthandPropertyAssignment */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.objectAssignmentInitializer, cbNode, result); - break; - case 262 /* SpreadAssignment */: - result = reduceNode(node.expression, cbNode, result); - break; - // Enum - case 263 /* EnumMember */: - result = reduceNode(node.name, cbNode, result); - result = reduceNode(node.initializer, cbNode, result); - // Top-level nodes - case 264 /* SourceFile */: - result = reduceNodes(node.statements, cbNodes, result); - break; - // Transformation nodes - case 298 /* PartiallyEmittedExpression */: - result = reduceNode(node.expression, cbNode, result); - break; - default: - break; - } - return result; - } - ts.reduceEachChild = reduceEachChild; - /** - * Visits a Node using the supplied visitor, possibly returning a new Node in its place. - * - * @param node The Node to visit. - * @param visitor The callback used to visit the Node. - * @param test A callback to execute to verify the Node is valid. - * @param optional An optional value indicating whether the Node is itself optional. - * @param lift An optional callback to execute to lift a NodeArray into a valid Node. - */ - function visitNode(node, visitor, test, optional, lift) { + function visitNode(node, visitor, test, lift) { if (node === undefined || visitor === undefined) { return node; } - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = visitor(node); if (visited === node) { return node; } var visitedNode; if (visited === undefined) { - if (!optional) { - Debug.failNotOptional(); - } return undefined; } else if (ts.isArray(visited)) { @@ -46077,8 +47444,8 @@ var ts; else { visitedNode = visited; } - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); return visitedNode; } ts.visitNode = visitNode; @@ -46092,8 +47459,8 @@ var ts; * @param count An optional value indicating the maximum number of nodes to visit. */ function visitNodes(nodes, visitor, test, start, count) { - if (nodes === undefined) { - return undefined; + if (nodes === undefined || visitor === undefined) { + return nodes; } var updated; // Ensure start and count have valid values @@ -46113,7 +47480,7 @@ var ts; // Visit each original node. for (var i = 0; i < count; i++) { var node = nodes[i + start]; - aggregateTransformFlags(node); + ts.aggregateTransformFlags(node); var visited = node !== undefined ? visitor(node) : undefined; if (updated !== undefined || visited === undefined || visited !== node) { if (updated === undefined) { @@ -46125,14 +47492,14 @@ var ts; if (ts.isArray(visited)) { for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) { var visitedNode = visited_1[_i]; - Debug.assertNode(visitedNode, test); - aggregateTransformFlags(visitedNode); + ts.Debug.assertNode(visitedNode, test); + ts.aggregateTransformFlags(visitedNode); updated.push(visitedNode); } } else { - Debug.assertNode(visited, test); - aggregateTransformFlags(visited); + ts.Debug.assertNode(visited, test); + ts.aggregateTransformFlags(visited); updated.push(visited); } } @@ -46159,9 +47526,10 @@ var ts; * Starts a new lexical environment and visits a parameter list, suspending the lexical * environment upon completion. */ - function visitParameterList(nodes, visitor, context) { + function visitParameterList(nodes, visitor, context, nodesVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } context.startLexicalEnvironment(); - var updated = visitNodes(nodes, visitor, ts.isParameterDeclaration); + var updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration); context.suspendLexicalEnvironment(); return updated; } @@ -46172,237 +47540,706 @@ var ts; var declarations = context.endLexicalEnvironment(); if (ts.some(declarations)) { var block = ts.convertToFunctionBody(updated); - var statements = mergeLexicalEnvironment(block.statements, declarations); + var statements = ts.mergeLexicalEnvironment(block.statements, declarations); return ts.updateBlock(block, statements); } return updated; } ts.visitFunctionBody = visitFunctionBody; - function visitEachChild(node, visitor, context) { + function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor) { + if (nodesVisitor === void 0) { nodesVisitor = visitNodes; } if (node === undefined) { return undefined; } var kind = node.kind; // No need to visit nodes with no children. - if ((kind > 0 /* FirstToken */ && kind <= 141 /* LastToken */)) { - return node; - } - // We do not yet support types. - if ((kind >= 157 /* TypePredicate */ && kind <= 172 /* LiteralType */)) { + if ((kind > 0 /* FirstToken */ && kind <= 142 /* LastToken */) || kind === 169 /* ThisType */) { return node; } switch (node.kind) { - case 205 /* SemicolonClassElement */: - case 208 /* EmptyStatement */: - case 199 /* OmittedExpression */: - case 224 /* DebuggerStatement */: + case 206 /* SemicolonClassElement */: + case 209 /* EmptyStatement */: + case 200 /* OmittedExpression */: + case 225 /* DebuggerStatement */: + case 298 /* EndOfDeclarationMarker */: + case 247 /* MissingDeclaration */: // No need to visit nodes with no children. return node; // Names - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return ts.updateQualifiedName(node, visitNode(node.left, visitor, ts.isEntityName), visitNode(node.right, visitor, ts.isIdentifier)); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return ts.updateComputedPropertyName(node, visitNode(node.expression, visitor, ts.isExpression)); - // Signature elements - case 145 /* Parameter */: - return ts.updateParameter(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), node.dotDotDotToken, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 146 /* Decorator */: + // Signatures and Signature Elements + case 160 /* FunctionType */: + return ts.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 161 /* ConstructorType */: + return ts.updateConstructorTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 155 /* CallSignature */: + return ts.updateCallSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 156 /* ConstructSignature */: + return ts.updateConstructSignatureDeclaration(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 150 /* MethodSignature */: + return ts.updateMethodSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken)); + case 157 /* IndexSignature */: + return ts.updateIndexSignatureDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), visitNode(node.type, visitor, ts.isTypeNode)); + case 146 /* Parameter */: + return ts.updateParameter(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 147 /* Decorator */: return ts.updateDecorator(node, visitNode(node.expression, visitor, ts.isExpression)); - // Type member - case 148 /* PropertyDeclaration */: - return ts.updateProperty(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 150 /* MethodDeclaration */: - return ts.updateMethod(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 151 /* Constructor */: - return ts.updateConstructor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); - case 152 /* GetAccessor */: - return ts.updateGetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 153 /* SetAccessor */: - return ts.updateSetAccessor(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context)); + // Types + case 159 /* TypeReference */: + return ts.updateTypeReferenceNode(node, visitNode(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode)); + case 158 /* TypePredicate */: + return ts.updateTypePredicateNode(node, visitNode(node.parameterName, visitor), visitNode(node.type, visitor, ts.isTypeNode)); + case 162 /* TypeQuery */: + return ts.updateTypeQueryNode(node, visitNode(node.exprName, visitor, ts.isEntityName)); + case 163 /* TypeLiteral */: + return ts.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor)); + case 164 /* ArrayType */: + return ts.updateArrayTypeNode(node, visitNode(node.elementType, visitor, ts.isTypeNode)); + case 165 /* TupleType */: + return ts.updateTypleTypeNode(node, nodesVisitor(node.elementTypes, visitor, ts.isTypeNode)); + case 166 /* UnionType */: + case 167 /* IntersectionType */: + return ts.updateUnionOrIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode)); + case 168 /* ParenthesizedType */: + return ts.updateParenthesizedType(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 170 /* TypeOperator */: + return ts.updateTypeOperatorNode(node, visitNode(node.type, visitor, ts.isTypeNode)); + case 171 /* IndexedAccessType */: + return ts.updateIndexedAccessTypeNode(node, visitNode(node.objectType, visitor, ts.isTypeNode), visitNode(node.indexType, visitor, ts.isTypeNode)); + case 172 /* MappedType */: + return ts.updateMappedTypeNode(node, visitNode(node.readonlyToken, tokenVisitor, ts.isToken), visitNode(node.typeParameter, visitor, ts.isTypeParameter), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode)); + case 173 /* LiteralType */: + return ts.updateLiteralTypeNode(node, visitNode(node.literal, visitor, ts.isExpression)); + // Type Declarations + case 145 /* TypeParameter */: + return ts.updateTypeParameterDeclaration(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.constraint, visitor, ts.isTypeNode), visitNode(node.default, visitor, ts.isTypeNode)); + // Type members + case 148 /* PropertySignature */: + return ts.updatePropertySignature(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 149 /* PropertyDeclaration */: + return ts.updateProperty(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 151 /* MethodDeclaration */: + return ts.updateMethod(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.questionToken, tokenVisitor, ts.isToken), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 152 /* Constructor */: + return ts.updateConstructor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); + case 153 /* GetAccessor */: + return ts.updateGetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 154 /* SetAccessor */: + return ts.updateSetAccessor(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body, visitor, context)); // Binding patterns - case 173 /* ObjectBindingPattern */: - return ts.updateObjectBindingPattern(node, visitNodes(node.elements, visitor, ts.isBindingElement)); - case 174 /* ArrayBindingPattern */: - return ts.updateArrayBindingPattern(node, visitNodes(node.elements, visitor, ts.isArrayBindingElement)); - case 175 /* BindingElement */: - return ts.updateBindingElement(node, node.dotDotDotToken, visitNode(node.propertyName, visitor, ts.isPropertyName, /*optional*/ true), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 174 /* ObjectBindingPattern */: + return ts.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement)); + case 175 /* ArrayBindingPattern */: + return ts.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement)); + case 176 /* BindingElement */: + return ts.updateBindingElement(node, visitNode(node.dotDotDotToken, tokenVisitor, ts.isToken), visitNode(node.propertyName, visitor, ts.isPropertyName), visitNode(node.name, visitor, ts.isBindingName), visitNode(node.initializer, visitor, ts.isExpression)); // Expression - case 176 /* ArrayLiteralExpression */: - return ts.updateArrayLiteral(node, visitNodes(node.elements, visitor, ts.isExpression)); - case 177 /* ObjectLiteralExpression */: - return ts.updateObjectLiteral(node, visitNodes(node.properties, visitor, ts.isObjectLiteralElementLike)); - case 178 /* PropertyAccessExpression */: + case 177 /* ArrayLiteralExpression */: + return ts.updateArrayLiteral(node, nodesVisitor(node.elements, visitor, ts.isExpression)); + case 178 /* ObjectLiteralExpression */: + return ts.updateObjectLiteral(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike)); + case 179 /* PropertyAccessExpression */: return ts.updatePropertyAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.name, visitor, ts.isIdentifier)); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return ts.updateElementAccess(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.argumentExpression, visitor, ts.isExpression)); - case 180 /* CallExpression */: - return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 181 /* NewExpression */: - return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNodes(node.arguments, visitor, ts.isExpression)); - case 182 /* TaggedTemplateExpression */: + case 181 /* CallExpression */: + return ts.updateCall(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 182 /* NewExpression */: + return ts.updateNew(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression)); + case 183 /* TaggedTemplateExpression */: return ts.updateTaggedTemplate(node, visitNode(node.tag, visitor, ts.isExpression), visitNode(node.template, visitor, ts.isTemplateLiteral)); - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return ts.updateTypeAssertion(node, visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return ts.updateParen(node, visitNode(node.expression, visitor, ts.isExpression)); - case 185 /* FunctionExpression */: - return ts.updateFunctionExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 186 /* ArrowFunction */: - return ts.updateArrowFunction(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 187 /* DeleteExpression */: + case 186 /* FunctionExpression */: + return ts.updateFunctionExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 187 /* ArrowFunction */: + return ts.updateArrowFunction(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 188 /* DeleteExpression */: return ts.updateDelete(node, visitNode(node.expression, visitor, ts.isExpression)); - case 188 /* TypeOfExpression */: + case 189 /* TypeOfExpression */: return ts.updateTypeOf(node, visitNode(node.expression, visitor, ts.isExpression)); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return ts.updateVoid(node, visitNode(node.expression, visitor, ts.isExpression)); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return ts.updateAwait(node, visitNode(node.expression, visitor, ts.isExpression)); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return ts.updateBinary(node, visitNode(node.left, visitor, ts.isExpression), visitNode(node.right, visitor, ts.isExpression)); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return ts.updatePrefix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return ts.updatePostfix(node, visitNode(node.operand, visitor, ts.isExpression)); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return ts.updateConditional(node, visitNode(node.condition, visitor, ts.isExpression), visitNode(node.whenTrue, visitor, ts.isExpression), visitNode(node.whenFalse, visitor, ts.isExpression)); - case 195 /* TemplateExpression */: - return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), visitNodes(node.templateSpans, visitor, ts.isTemplateSpan)); - case 196 /* YieldExpression */: - return ts.updateYield(node, visitNode(node.expression, visitor, ts.isExpression)); - case 197 /* SpreadElement */: + case 196 /* TemplateExpression */: + return ts.updateTemplateExpression(node, visitNode(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan)); + case 197 /* YieldExpression */: + return ts.updateYield(node, visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.expression, visitor, ts.isExpression)); + case 198 /* SpreadElement */: return ts.updateSpread(node, visitNode(node.expression, visitor, ts.isExpression)); - case 198 /* ClassExpression */: - return ts.updateClassExpression(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 200 /* ExpressionWithTypeArguments */: - return ts.updateExpressionWithTypeArguments(node, visitNodes(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); - case 201 /* AsExpression */: + case 199 /* ClassExpression */: + return ts.updateClassExpression(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 201 /* ExpressionWithTypeArguments */: + return ts.updateExpressionWithTypeArguments(node, nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), visitNode(node.expression, visitor, ts.isExpression)); + case 202 /* AsExpression */: return ts.updateAsExpression(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.type, visitor, ts.isTypeNode)); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return ts.updateNonNullExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Misc - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return ts.updateTemplateSpan(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail)); // Element - case 206 /* Block */: - return ts.updateBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 207 /* VariableStatement */: - return ts.updateVariableStatement(node, visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); - case 209 /* ExpressionStatement */: + case 207 /* Block */: + return ts.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 208 /* VariableStatement */: + return ts.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.declarationList, visitor, ts.isVariableDeclarationList)); + case 210 /* ExpressionStatement */: return ts.updateStatement(node, visitNode(node.expression, visitor, ts.isExpression)); - case 210 /* IfStatement */: - return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, /*optional*/ true, liftToBlock)); - case 211 /* DoStatement */: - return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); - case 212 /* WhileStatement */: - return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 213 /* ForStatement */: - return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 214 /* ForInStatement */: - return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 215 /* ForOfStatement */: - return ts.updateForOf(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 216 /* ContinueStatement */: - return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 217 /* BreakStatement */: - return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier, /*optional*/ true)); - case 218 /* ReturnStatement */: - return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true)); - case 219 /* WithStatement */: - return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 220 /* SwitchStatement */: + case 211 /* IfStatement */: + return ts.updateIf(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.thenStatement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.elseStatement, visitor, ts.isStatement, ts.liftToBlock)); + case 212 /* DoStatement */: + return ts.updateDo(node, visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock), visitNode(node.expression, visitor, ts.isExpression)); + case 213 /* WhileStatement */: + return ts.updateWhile(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 214 /* ForStatement */: + return ts.updateFor(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.condition, visitor, ts.isExpression), visitNode(node.incrementor, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 215 /* ForInStatement */: + return ts.updateForIn(node, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 216 /* ForOfStatement */: + return ts.updateForOf(node, node.awaitModifier, visitNode(node.initializer, visitor, ts.isForInitializer), visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 217 /* ContinueStatement */: + return ts.updateContinue(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 218 /* BreakStatement */: + return ts.updateBreak(node, visitNode(node.label, visitor, ts.isIdentifier)); + case 219 /* ReturnStatement */: + return ts.updateReturn(node, visitNode(node.expression, visitor, ts.isExpression)); + case 220 /* WithStatement */: + return ts.updateWith(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 221 /* SwitchStatement */: return ts.updateSwitch(node, visitNode(node.expression, visitor, ts.isExpression), visitNode(node.caseBlock, visitor, ts.isCaseBlock)); - case 221 /* LabeledStatement */: - return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, liftToBlock)); - case 222 /* ThrowStatement */: + case 222 /* LabeledStatement */: + return ts.updateLabel(node, visitNode(node.label, visitor, ts.isIdentifier), visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); + case 223 /* ThrowStatement */: return ts.updateThrow(node, visitNode(node.expression, visitor, ts.isExpression)); - case 223 /* TryStatement */: - return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause, /*optional*/ true), visitNode(node.finallyBlock, visitor, ts.isBlock, /*optional*/ true)); - case 225 /* VariableDeclaration */: - return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); - case 226 /* VariableDeclarationList */: - return ts.updateVariableDeclarationList(node, visitNodes(node.declarations, visitor, ts.isVariableDeclaration)); - case 227 /* FunctionDeclaration */: - return ts.updateFunctionDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isPropertyName), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context), visitNode(node.type, visitor, ts.isTypeNode, /*optional*/ true), visitFunctionBody(node.body, visitor, context)); - case 228 /* ClassDeclaration */: - return ts.updateClassDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNodes(node.typeParameters, visitor, ts.isTypeParameter), visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), visitNodes(node.members, visitor, ts.isClassElement)); - case 231 /* EnumDeclaration */: - return ts.updateEnumDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNodes(node.members, visitor, ts.isEnumMember)); - case 232 /* ModuleDeclaration */: - return ts.updateModuleDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); - case 233 /* ModuleBlock */: - return ts.updateModuleBlock(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 234 /* CaseBlock */: - return ts.updateCaseBlock(node, visitNodes(node.clauses, visitor, ts.isCaseOrDefaultClause)); - case 236 /* ImportEqualsDeclaration */: - return ts.updateImportEqualsDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); - case 237 /* ImportDeclaration */: - return ts.updateImportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); - case 238 /* ImportClause */: - return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings, /*optional*/ true)); - case 239 /* NamespaceImport */: + case 224 /* TryStatement */: + return ts.updateTry(node, visitNode(node.tryBlock, visitor, ts.isBlock), visitNode(node.catchClause, visitor, ts.isCatchClause), visitNode(node.finallyBlock, visitor, ts.isBlock)); + case 226 /* VariableDeclaration */: + return ts.updateVariableDeclaration(node, visitNode(node.name, visitor, ts.isBindingName), visitNode(node.type, visitor, ts.isTypeNode), visitNode(node.initializer, visitor, ts.isExpression)); + case 227 /* VariableDeclarationList */: + return ts.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration)); + case 228 /* FunctionDeclaration */: + return ts.updateFunctionDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.asteriskToken, tokenVisitor, ts.isToken), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitNode(node.type, visitor, ts.isTypeNode), visitFunctionBody(node.body, visitor, context)); + case 229 /* ClassDeclaration */: + return ts.updateClassDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameter), nodesVisitor(node.heritageClauses, visitor, ts.isHeritageClause), nodesVisitor(node.members, visitor, ts.isClassElement)); + case 232 /* EnumDeclaration */: + return ts.updateEnumDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), nodesVisitor(node.members, visitor, ts.isEnumMember)); + case 233 /* ModuleDeclaration */: + return ts.updateModuleDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.body, visitor, ts.isModuleBody)); + case 234 /* ModuleBlock */: + return ts.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 235 /* CaseBlock */: + return ts.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause)); + case 237 /* ImportEqualsDeclaration */: + return ts.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.moduleReference, visitor, ts.isModuleReference)); + case 238 /* ImportDeclaration */: + return ts.updateImportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.importClause, visitor, ts.isImportClause), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 239 /* ImportClause */: + return ts.updateImportClause(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.namedBindings, visitor, ts.isNamedImportBindings)); + case 240 /* NamespaceImport */: return ts.updateNamespaceImport(node, visitNode(node.name, visitor, ts.isIdentifier)); - case 240 /* NamedImports */: - return ts.updateNamedImports(node, visitNodes(node.elements, visitor, ts.isImportSpecifier)); - case 241 /* ImportSpecifier */: - return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); - case 242 /* ExportAssignment */: - return ts.updateExportAssignment(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); - case 243 /* ExportDeclaration */: - return ts.updateExportDeclaration(node, visitNodes(node.decorators, visitor, ts.isDecorator), visitNodes(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports, /*optional*/ true), visitNode(node.moduleSpecifier, visitor, ts.isExpression, /*optional*/ true)); - case 244 /* NamedExports */: - return ts.updateNamedExports(node, visitNodes(node.elements, visitor, ts.isExportSpecifier)); - case 245 /* ExportSpecifier */: - return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier, /*optional*/ true), visitNode(node.name, visitor, ts.isIdentifier)); + case 241 /* NamedImports */: + return ts.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier)); + case 242 /* ImportSpecifier */: + return ts.updateImportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); + case 243 /* ExportAssignment */: + return ts.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.expression, visitor, ts.isExpression)); + case 244 /* ExportDeclaration */: + return ts.updateExportDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), visitNode(node.exportClause, visitor, ts.isNamedExports), visitNode(node.moduleSpecifier, visitor, ts.isExpression)); + case 245 /* NamedExports */: + return ts.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier)); + case 246 /* ExportSpecifier */: + return ts.updateExportSpecifier(node, visitNode(node.propertyName, visitor, ts.isIdentifier), visitNode(node.name, visitor, ts.isIdentifier)); // Module references - case 247 /* ExternalModuleReference */: + case 248 /* ExternalModuleReference */: return ts.updateExternalModuleReference(node, visitNode(node.expression, visitor, ts.isExpression)); // JSX - case 248 /* JsxElement */: - return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), visitNodes(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); - case 253 /* JsxAttributes */: - return ts.updateJsxAttributes(node, visitNodes(node.properties, visitor, ts.isJsxAttributeLike)); - case 249 /* JsxSelfClosingElement */: + case 249 /* JsxElement */: + return ts.updateJsxElement(node, visitNode(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), visitNode(node.closingElement, visitor, ts.isJsxClosingElement)); + case 254 /* JsxAttributes */: + return ts.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike)); + case 250 /* JsxSelfClosingElement */: return ts.updateJsxSelfClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 250 /* JsxOpeningElement */: + case 251 /* JsxOpeningElement */: return ts.updateJsxOpeningElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), visitNode(node.attributes, visitor, ts.isJsxAttributes)); - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: return ts.updateJsxClosingElement(node, visitNode(node.tagName, visitor, ts.isJsxTagNameExpression)); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return ts.updateJsxAttribute(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.initializer, visitor, ts.isStringLiteralOrJsxExpression)); - case 254 /* JsxSpreadAttribute */: + case 255 /* JsxSpreadAttribute */: return ts.updateJsxSpreadAttribute(node, visitNode(node.expression, visitor, ts.isExpression)); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return ts.updateJsxExpression(node, visitNode(node.expression, visitor, ts.isExpression)); // Clauses - case 256 /* CaseClause */: - return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), visitNodes(node.statements, visitor, ts.isStatement)); - case 257 /* DefaultClause */: - return ts.updateDefaultClause(node, visitNodes(node.statements, visitor, ts.isStatement)); - case 258 /* HeritageClause */: - return ts.updateHeritageClause(node, visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments)); - case 259 /* CatchClause */: + case 257 /* CaseClause */: + return ts.updateCaseClause(node, visitNode(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement)); + case 258 /* DefaultClause */: + return ts.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement)); + case 259 /* HeritageClause */: + return ts.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments)); + case 260 /* CatchClause */: return ts.updateCatchClause(node, visitNode(node.variableDeclaration, visitor, ts.isVariableDeclaration), visitNode(node.block, visitor, ts.isBlock)); // Property assignments - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return ts.updatePropertyAssignment(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return ts.updateShorthandPropertyAssignment(node, visitNode(node.name, visitor, ts.isIdentifier), visitNode(node.objectAssignmentInitializer, visitor, ts.isExpression)); - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: return ts.updateSpreadAssignment(node, visitNode(node.expression, visitor, ts.isExpression)); // Enum - case 263 /* EnumMember */: - return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression, /*optional*/ true)); + case 264 /* EnumMember */: + return ts.updateEnumMember(node, visitNode(node.name, visitor, ts.isPropertyName), visitNode(node.initializer, visitor, ts.isExpression)); // Top-level nodes - case 264 /* SourceFile */: + case 265 /* SourceFile */: return ts.updateSourceFileNode(node, visitLexicalEnvironment(node.statements, visitor, context)); // Transformation nodes - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: return ts.updatePartiallyEmittedExpression(node, visitNode(node.expression, visitor, ts.isExpression)); default: return node; } } ts.visitEachChild = visitEachChild; + /** + * Extracts the single node from a NodeArray. + * + * @param nodes The NodeArray. + */ + function extractSingleNode(nodes) { + ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output."); + return ts.singleOrUndefined(nodes); + } +})(ts || (ts = {})); +/* @internal */ +(function (ts) { + function reduceNode(node, f, initial) { + return node ? f(initial, node) : initial; + } + function reduceNodeArray(nodes, f, initial) { + return nodes ? f(initial, nodes) : initial; + } + /** + * Similar to `reduceLeft`, performs a reduction against each child of a node. + * NOTE: Unlike `forEachChild`, this does *not* visit every node. + * + * @param node The node containing the children to reduce. + * @param initial The initial value to supply to the reduction. + * @param f The callback function + */ + function reduceEachChild(node, initial, cbNode, cbNodeArray) { + if (node === undefined) { + return initial; + } + var reduceNodes = cbNodeArray ? reduceNodeArray : ts.reduceLeft; + var cbNodes = cbNodeArray || cbNode; + var kind = node.kind; + // No need to visit nodes with no children. + if ((kind > 0 /* FirstToken */ && kind <= 142 /* LastToken */)) { + return initial; + } + // We do not yet support types. + if ((kind >= 158 /* TypePredicate */ && kind <= 173 /* LiteralType */)) { + return initial; + } + var result = initial; + switch (node.kind) { + // Leaf nodes + case 206 /* SemicolonClassElement */: + case 209 /* EmptyStatement */: + case 200 /* OmittedExpression */: + case 225 /* DebuggerStatement */: + case 295 /* NotEmittedStatement */: + // No need to visit nodes with no children. + break; + // Names + case 143 /* QualifiedName */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 144 /* ComputedPropertyName */: + result = reduceNode(node.expression, cbNode, result); + break; + // Signature elements + case 146 /* Parameter */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 147 /* Decorator */: + result = reduceNode(node.expression, cbNode, result); + break; + // Type member + case 149 /* PropertyDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 151 /* MethodDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 152 /* Constructor */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + case 153 /* GetAccessor */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 154 /* SetAccessor */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.body, cbNode, result); + break; + // Binding patterns + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 176 /* BindingElement */: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + // Expression + case 177 /* ArrayLiteralExpression */: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 178 /* ObjectLiteralExpression */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 179 /* PropertyAccessExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 180 /* ElementAccessExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.argumentExpression, cbNode, result); + break; + case 181 /* CallExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 182 /* NewExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + result = reduceNodes(node.arguments, cbNodes, result); + break; + case 183 /* TaggedTemplateExpression */: + result = reduceNode(node.tag, cbNode, result); + result = reduceNode(node.template, cbNode, result); + break; + case 184 /* TypeAssertionExpression */: + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 186 /* FunctionExpression */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 187 /* ArrowFunction */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 185 /* ParenthesizedExpression */: + case 188 /* DeleteExpression */: + case 189 /* TypeOfExpression */: + case 190 /* VoidExpression */: + case 191 /* AwaitExpression */: + case 197 /* YieldExpression */: + case 198 /* SpreadElement */: + case 203 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + result = reduceNode(node.operand, cbNode, result); + break; + case 194 /* BinaryExpression */: + result = reduceNode(node.left, cbNode, result); + result = reduceNode(node.right, cbNode, result); + break; + case 195 /* ConditionalExpression */: + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.whenTrue, cbNode, result); + result = reduceNode(node.whenFalse, cbNode, result); + break; + case 196 /* TemplateExpression */: + result = reduceNode(node.head, cbNode, result); + result = reduceNodes(node.templateSpans, cbNodes, result); + break; + case 199 /* ClassExpression */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 201 /* ExpressionWithTypeArguments */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNodes(node.typeArguments, cbNodes, result); + break; + case 202 /* AsExpression */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.type, cbNode, result); + break; + case 203 /* NonNullExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + // Misc + case 205 /* TemplateSpan */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.literal, cbNode, result); + break; + // Element + case 207 /* Block */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 208 /* VariableStatement */: + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.declarationList, cbNode, result); + break; + case 210 /* ExpressionStatement */: + result = reduceNode(node.expression, cbNode, result); + break; + case 211 /* IfStatement */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.thenStatement, cbNode, result); + result = reduceNode(node.elseStatement, cbNode, result); + break; + case 212 /* DoStatement */: + result = reduceNode(node.statement, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 213 /* WhileStatement */: + case 220 /* WithStatement */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 214 /* ForStatement */: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.condition, cbNode, result); + result = reduceNode(node.incrementor, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + result = reduceNode(node.initializer, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 219 /* ReturnStatement */: + case 223 /* ThrowStatement */: + result = reduceNode(node.expression, cbNode, result); + break; + case 221 /* SwitchStatement */: + result = reduceNode(node.expression, cbNode, result); + result = reduceNode(node.caseBlock, cbNode, result); + break; + case 222 /* LabeledStatement */: + result = reduceNode(node.label, cbNode, result); + result = reduceNode(node.statement, cbNode, result); + break; + case 224 /* TryStatement */: + result = reduceNode(node.tryBlock, cbNode, result); + result = reduceNode(node.catchClause, cbNode, result); + result = reduceNode(node.finallyBlock, cbNode, result); + break; + case 226 /* VariableDeclaration */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 227 /* VariableDeclarationList */: + result = reduceNodes(node.declarations, cbNodes, result); + break; + case 228 /* FunctionDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.parameters, cbNodes, result); + result = reduceNode(node.type, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 229 /* ClassDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.typeParameters, cbNodes, result); + result = reduceNodes(node.heritageClauses, cbNodes, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 232 /* EnumDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNodes(node.members, cbNodes, result); + break; + case 233 /* ModuleDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.body, cbNode, result); + break; + case 234 /* ModuleBlock */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 235 /* CaseBlock */: + result = reduceNodes(node.clauses, cbNodes, result); + break; + case 237 /* ImportEqualsDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.moduleReference, cbNode, result); + break; + case 238 /* ImportDeclaration */: + result = reduceNodes(node.decorators, cbNodes, result); + result = reduceNodes(node.modifiers, cbNodes, result); + result = reduceNode(node.importClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + case 239 /* ImportClause */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.namedBindings, cbNode, result); + break; + case 240 /* NamespaceImport */: + result = reduceNode(node.name, cbNode, result); + break; + case 241 /* NamedImports */: + case 245 /* NamedExports */: + result = reduceNodes(node.elements, cbNodes, result); + break; + case 242 /* ImportSpecifier */: + case 246 /* ExportSpecifier */: + result = reduceNode(node.propertyName, cbNode, result); + result = reduceNode(node.name, cbNode, result); + break; + case 243 /* ExportAssignment */: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.expression, cbNode, result); + break; + case 244 /* ExportDeclaration */: + result = ts.reduceLeft(node.decorators, cbNode, result); + result = ts.reduceLeft(node.modifiers, cbNode, result); + result = reduceNode(node.exportClause, cbNode, result); + result = reduceNode(node.moduleSpecifier, cbNode, result); + break; + // Module references + case 248 /* ExternalModuleReference */: + result = reduceNode(node.expression, cbNode, result); + break; + // JSX + case 249 /* JsxElement */: + result = reduceNode(node.openingElement, cbNode, result); + result = ts.reduceLeft(node.children, cbNode, result); + result = reduceNode(node.closingElement, cbNode, result); + break; + case 250 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + result = reduceNode(node.tagName, cbNode, result); + result = reduceNode(node.attributes, cbNode, result); + break; + case 254 /* JsxAttributes */: + result = reduceNodes(node.properties, cbNodes, result); + break; + case 252 /* JsxClosingElement */: + result = reduceNode(node.tagName, cbNode, result); + break; + case 253 /* JsxAttribute */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 255 /* JsxSpreadAttribute */: + result = reduceNode(node.expression, cbNode, result); + break; + case 256 /* JsxExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + // Clauses + case 257 /* CaseClause */: + result = reduceNode(node.expression, cbNode, result); + // falls through + case 258 /* DefaultClause */: + result = reduceNodes(node.statements, cbNodes, result); + break; + case 259 /* HeritageClause */: + result = reduceNodes(node.types, cbNodes, result); + break; + case 260 /* CatchClause */: + result = reduceNode(node.variableDeclaration, cbNode, result); + result = reduceNode(node.block, cbNode, result); + break; + // Property assignments + case 261 /* PropertyAssignment */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + case 262 /* ShorthandPropertyAssignment */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.objectAssignmentInitializer, cbNode, result); + break; + case 263 /* SpreadAssignment */: + result = reduceNode(node.expression, cbNode, result); + break; + // Enum + case 264 /* EnumMember */: + result = reduceNode(node.name, cbNode, result); + result = reduceNode(node.initializer, cbNode, result); + break; + // Top-level nodes + case 265 /* SourceFile */: + result = reduceNodes(node.statements, cbNodes, result); + break; + // Transformation nodes + case 296 /* PartiallyEmittedExpression */: + result = reduceNode(node.expression, cbNode, result); + break; + default: + break; + } + return result; + } + ts.reduceEachChild = reduceEachChild; function mergeLexicalEnvironment(statements, declarations) { if (!ts.some(declarations)) { return statements; @@ -46412,20 +48249,6 @@ var ts; : ts.addRange(statements, declarations); } ts.mergeLexicalEnvironment = mergeLexicalEnvironment; - function mergeFunctionBodyLexicalEnvironment(body, declarations) { - if (body && declarations !== undefined && declarations.length > 0) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.setTextRange(ts.createNodeArray(ts.concatenate(body.statements, declarations)), body.statements)); - } - else { - return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray([ts.setTextRange(ts.createReturn(body), body)].concat(declarations)), body), - /*multiLine*/ true), - /*location*/ body); - } - } - return body; - } - ts.mergeFunctionBodyLexicalEnvironment = mergeFunctionBodyLexicalEnvironment; /** * Lifts a NodeArray containing only Statement nodes to a block. * @@ -46436,15 +48259,6 @@ var ts; return ts.singleOrUndefined(nodes) || ts.createBlock(nodes); } ts.liftToBlock = liftToBlock; - /** - * Extracts the single node from a NodeArray. - * - * @param nodes The NodeArray. - */ - function extractSingleNode(nodes) { - Debug.assert(nodes.length <= 1, "Too many nodes written to output."); - return ts.singleOrUndefined(nodes); - } /** * Aggregates the TransformFlags for a Node and its subtree. */ @@ -46490,7 +48304,7 @@ var ts; function aggregateTransformFlagsForSubtree(node) { // We do not transform ambient declarations or types, so there is no need to // recursively aggregate transform flags. - if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 200 /* ExpressionWithTypeArguments */)) { + if (ts.hasModifier(node, 2 /* Ambient */) || (ts.isTypeNode(node) && node.kind !== 201 /* ExpressionWithTypeArguments */)) { return 0 /* None */; } // Aggregate the transform flags of each child. @@ -46508,9 +48322,6 @@ var ts; } var Debug; (function (Debug) { - Debug.failNotOptional = Debug.shouldAssert(1 /* Normal */) - ? function (message) { return Debug.assert(false, message || "Node not optional."); } - : ts.noop; Debug.failBadSyntaxKind = Debug.shouldAssert(1 /* Normal */) ? function (node, message) { return Debug.assert(false, message || "Unexpected node.", function () { return "Node " + ts.formatSyntaxKind(node.kind) + " was unexpected."; }); } : ts.noop; @@ -46570,7 +48381,7 @@ var ts; var value; if (ts.isDestructuringAssignment(node)) { value = node.right; - while (ts.isEmptyObjectLiteralOrArrayLiteral(node.left)) { + while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) { if (ts.isDestructuringAssignment(value)) { location = node = value; value = node.right; @@ -46584,6 +48395,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: true, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -46656,6 +48468,7 @@ var ts; var flattenContext = { context: context, level: level, + downlevelIteration: context.getCompilerOptions().downlevelIteration, hoistTempVariables: hoistTempVariables, emitExpression: emitExpression, emitBindingOrAssignment: emitBindingOrAssignment, @@ -46808,7 +48621,14 @@ var ts; function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) { var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern); var numElements = elements.length; - if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)) { + if (flattenContext.level < 1 /* ObjectRest */ && flattenContext.downlevelIteration) { + // Read the elements of the iterable into an array + value = ensureIdentifier(flattenContext, ts.createReadHelper(flattenContext.context, value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1]) + ? undefined + : numElements, location), + /*reuseIdentifierExpressions*/ false, location); + } + else if (numElements !== 1 && (flattenContext.level < 1 /* ObjectRest */ || numElements === 0)) { // For anything other than a single-element destructuring we need to generate a temporary // to ensure value is evaluated exactly once. Additionally, if we have zero elements // we need to emit *something* to ensure that in case a 'var' keyword was already emitted, @@ -46936,7 +48756,7 @@ var ts; return ts.createObjectLiteral(ts.map(elements, ts.convertToObjectAssignmentElement)); } function makeBindingElement(name) { - return ts.createBindingElement(/*propertyName*/ undefined, /*dotDotDotToken*/ undefined, name); + return ts.createBindingElement(/*dotDotDotToken*/ undefined, /*propertyName*/ undefined, name); } function makeAssignmentElement(name) { return name; @@ -46947,7 +48767,8 @@ var ts; text: "\n var __rest = (this && this.__rest) || function (s, e) {\n var t = {};\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\n t[p] = s[p];\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\n t[p[i]] = s[p[i]];\n return t;\n };" }; /** Given value: o, propName: p, pattern: { a, b, ...p } from the original statement - * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);`*/ + * `{ a, b, ...p } = o`, create `p = __rest(o, ["a", "b"]);` + */ function createRestCall(context, value, elements, computedTempVariables, location) { context.requestEmitHelper(restHelper); var propertyNames = []; @@ -46966,7 +48787,8 @@ var ts; } } } - return ts.createCall(ts.getHelperName("__rest"), undefined, [ + return ts.createCall(ts.getHelperName("__rest"), + /*typeArguments*/ undefined, [ value, ts.setTextRange(ts.createArrayLiteral(propertyNames), location) ]); @@ -47004,8 +48826,8 @@ var ts; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; // Enable substitution for property/element access to emit const enum values. - context.enableSubstitution(178 /* PropertyAccessExpression */); - context.enableSubstitution(179 /* ElementAccessExpression */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(180 /* ElementAccessExpression */); // These variables contain state that changes as we descend into the tree. var currentSourceFile; var currentNamespace; @@ -47069,15 +48891,15 @@ var ts; */ function onBeforeVisitNode(node) { switch (node.kind) { - case 264 /* SourceFile */: - case 234 /* CaseBlock */: - case 233 /* ModuleBlock */: - case 206 /* Block */: + case 265 /* SourceFile */: + case 235 /* CaseBlock */: + case 234 /* ModuleBlock */: + case 207 /* Block */: currentScope = node; currentScopeFirstDeclarationsOfName = undefined; break; - case 228 /* ClassDeclaration */: - case 227 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + case 228 /* FunctionDeclaration */: if (ts.hasModifier(node, 2 /* Ambient */)) { break; } @@ -47124,13 +48946,13 @@ var ts; */ function sourceElementVisitorWorker(node) { switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return visitExportDeclaration(node); default: return visitorWorker(node); @@ -47150,11 +48972,11 @@ var ts; * @param node The node to visit. */ function namespaceElementVisitorWorker(node) { - if (node.kind === 243 /* ExportDeclaration */ || - node.kind === 237 /* ImportDeclaration */ || - node.kind === 238 /* ImportClause */ || - (node.kind === 236 /* ImportEqualsDeclaration */ && - node.moduleReference.kind === 247 /* ExternalModuleReference */)) { + if (node.kind === 244 /* ExportDeclaration */ || + node.kind === 238 /* ImportDeclaration */ || + node.kind === 239 /* ImportClause */ || + (node.kind === 237 /* ImportEqualsDeclaration */ && + node.moduleReference.kind === 248 /* ExternalModuleReference */)) { // do not emit ES6 imports and exports since they are illegal inside a namespace return undefined; } @@ -47184,19 +49006,19 @@ var ts; */ function classElementVisitorWorker(node) { switch (node.kind) { - case 151 /* Constructor */: + case 152 /* Constructor */: // TypeScript constructors are transformed in `visitClassDeclaration`. // We elide them here as `visitorWorker` checks transform flags, which could // erronously include an ES6 constructor without TypeScript syntax. return undefined; - case 148 /* PropertyDeclaration */: - case 156 /* IndexSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 150 /* MethodDeclaration */: + case 149 /* PropertyDeclaration */: + case 157 /* IndexSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 151 /* MethodDeclaration */: // Fallback to the default visit behavior. return visitorWorker(node); - case 205 /* SemicolonClassElement */: + case 206 /* SemicolonClassElement */: return node; default: ts.Debug.failBadSyntaxKind(node); @@ -47207,7 +49029,7 @@ var ts; if (ts.modifierToFlag(node.kind) & 2270 /* TypeScriptModifier */) { return undefined; } - else if (currentNamespace && node.kind === 83 /* ExportKeyword */) { + else if (currentNamespace && node.kind === 84 /* ExportKeyword */) { return undefined; } return node; @@ -47224,59 +49046,59 @@ var ts; return ts.createNotEmittedStatement(node); } switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: // ES6 export and default modifiers are elided when inside a namespace. return currentNamespace ? undefined : node; - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 116 /* AbstractKeyword */: - case 75 /* ConstKeyword */: - case 123 /* DeclareKeyword */: - case 130 /* ReadonlyKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 117 /* AbstractKeyword */: + case 76 /* ConstKeyword */: + case 124 /* DeclareKeyword */: + case 131 /* ReadonlyKeyword */: // TypeScript accessibility and readonly modifiers are elided. - case 163 /* ArrayType */: - case 164 /* TupleType */: - case 162 /* TypeLiteral */: - case 157 /* TypePredicate */: - case 144 /* TypeParameter */: - case 118 /* AnyKeyword */: - case 121 /* BooleanKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 129 /* NeverKeyword */: - case 104 /* VoidKeyword */: - case 136 /* SymbolKeyword */: - case 160 /* ConstructorType */: - case 159 /* FunctionType */: - case 161 /* TypeQuery */: - case 158 /* TypeReference */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: - case 167 /* ParenthesizedType */: - case 168 /* ThisType */: - case 169 /* TypeOperator */: - case 170 /* IndexedAccessType */: - case 171 /* MappedType */: - case 172 /* LiteralType */: + case 164 /* ArrayType */: + case 165 /* TupleType */: + case 163 /* TypeLiteral */: + case 158 /* TypePredicate */: + case 145 /* TypeParameter */: + case 119 /* AnyKeyword */: + case 122 /* BooleanKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 130 /* NeverKeyword */: + case 105 /* VoidKeyword */: + case 137 /* SymbolKeyword */: + case 161 /* ConstructorType */: + case 160 /* FunctionType */: + case 162 /* TypeQuery */: + case 159 /* TypeReference */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: + case 168 /* ParenthesizedType */: + case 169 /* ThisType */: + case 170 /* TypeOperator */: + case 171 /* IndexedAccessType */: + case 172 /* MappedType */: + case 173 /* LiteralType */: // TypeScript type nodes are elided. - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: // TypeScript index signatures are elided. - case 146 /* Decorator */: + case 147 /* Decorator */: // TypeScript decorators are elided. They will be emitted as part of visitClassDeclaration. - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: // TypeScript type-only declarations are elided. - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // TypeScript property declarations are elided. return undefined; - case 151 /* Constructor */: + case 152 /* Constructor */: return visitConstructor(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: // TypeScript interfaces are elided, but some comments may be preserved. // See the implementation of `getLeadingComments` in comments.ts for more details. return ts.createNotEmittedStatement(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: // This is a class declaration with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -47287,7 +49109,7 @@ var ts; // - index signatures // - method overload signatures return visitClassDeclaration(node); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: // This is a class expression with TypeScript syntax extensions. // // TypeScript class syntax extensions include: @@ -47298,35 +49120,35 @@ var ts; // - index signatures // - method overload signatures return visitClassExpression(node); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: // This is a heritage clause with TypeScript syntax extensions. // // TypeScript heritage clause extensions include: // - `implements` clause return visitHeritageClause(node); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: // TypeScript supports type arguments on an expression in an `extends` heritage clause. return visitExpressionWithTypeArguments(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: // TypeScript method declarations may have decorators, modifiers // or type annotations. return visitMethodDeclaration(node); - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: // Get Accessors can have TypeScript modifiers, decorators, and type annotations. return visitGetAccessor(node); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: // Set Accessors can have TypeScript modifiers and type annotations. return visitSetAccessor(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: // Typescript function declarations can have modifiers, decorators, and type annotations. return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: // TypeScript function expressions can have modifiers and type annotations. return visitFunctionExpression(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: // TypeScript arrow functions can have modifiers and type annotations. return visitArrowFunction(node); - case 145 /* Parameter */: + case 146 /* Parameter */: // This is a parameter declaration with TypeScript syntax extensions. // // TypeScript parameter declaration syntax extensions include: @@ -47336,33 +49158,33 @@ var ts; // - type annotations // - this parameters return visitParameter(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: // ParenthesizedExpressions are TypeScript if their expression is a // TypeAssertion or AsExpression return visitParenthesizedExpression(node); - case 183 /* TypeAssertionExpression */: - case 201 /* AsExpression */: + case 184 /* TypeAssertionExpression */: + case 202 /* AsExpression */: // TypeScript type assertions are removed, but their subtrees are preserved. return visitAssertionExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return visitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return visitNewExpression(node); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: // TypeScript non-null expressions are removed, but their subtrees are preserved. return visitNonNullExpression(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: // TypeScript enum declarations do not exist in ES6 and must be rewritten. return visitEnumDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: // TypeScript namespace exports for variable statements must be transformed. return visitVariableStatement(node); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: // TypeScript namespace declarations must be transformed. return visitModuleDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // TypeScript namespace or external module import. return visitImportEqualsDeclaration(node); default: @@ -47371,7 +49193,8 @@ var ts; } } function visitSourceFile(node) { - var alwaysStrict = compilerOptions.alwaysStrict && !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); + var alwaysStrict = (compilerOptions.alwaysStrict === undefined ? compilerOptions.strict : compilerOptions.alwaysStrict) && + !(ts.isExternalModule(node) && moduleKind === ts.ModuleKind.ES2015); return ts.updateSourceFileNode(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, /*start*/ 0, alwaysStrict)); } /** @@ -47411,9 +49234,10 @@ var ts; // emit name if // - node has a name // - node has static initializers + // - node has a member that is decorated // var name = node.name; - if (!name && staticProperties.length > 0) { + if (!name && (staticProperties.length > 0 || ts.childIsDecorated(node))) { name = ts.getGeneratedNameForNode(node); } var classStatement = isDecoratedClass @@ -47449,7 +49273,7 @@ var ts; if (statements.length > 1) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304 /* HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -47609,7 +49433,7 @@ var ts; function visitClassExpression(node) { var staticProperties = getInitializedProperties(node, /*isStatic*/ true); var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause); - var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 84 /* ExtendsKeyword */; })); + var members = transformClassMembers(node, ts.some(heritageClauses, function (c) { return c.token === 85 /* ExtendsKeyword */; })); var classExpression = ts.createClassExpression( /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); @@ -47625,7 +49449,7 @@ var ts; } // To preserve the behavior of the old emitter, we explicitly indent // the body of a class with static initializers. - ts.setEmitFlags(classExpression, 32768 /* Indented */ | ts.getEmitFlags(classExpression)); + ts.setEmitFlags(classExpression, 65536 /* Indented */ | ts.getEmitFlags(classExpression)); expressions.push(ts.startOnNewLine(ts.createAssignment(temp, classExpression))); ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp)); expressions.push(ts.startOnNewLine(temp)); @@ -47755,7 +49579,7 @@ var ts; ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement)); } // End the lexical environment. - ts.addRange(statements, endLexicalEnvironment()); + statements = ts.mergeLexicalEnvironment(statements, endLexicalEnvironment()); return ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ constructor ? constructor.body.statements : node.members), /*multiLine*/ true), @@ -47771,13 +49595,13 @@ var ts; if (ctor.body) { var statements = ctor.body.statements; // add prologue directives to the list (if any) - var index = ts.addPrologueDirectives(result, statements, /*ensureUseStrict*/ false, visitor); + var index = ts.addPrologue(result, statements, /*ensureUseStrict*/ false, visitor); if (index === statements.length) { // list contains nothing but prologue directives (or empty) - exit return index; } var statement = statements[index]; - if (statement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { + if (statement.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(statement.expression)) { result.push(ts.visitNode(statement, visitor, ts.isStatement)); return index + 1; } @@ -47848,7 +49672,7 @@ var ts; * @param isStatic A value indicating whether the member should be a static or instance member. */ function isInitializedProperty(member, isStatic) { - return member.kind === 148 /* PropertyDeclaration */ + return member.kind === 149 /* PropertyDeclaration */ && isStatic === ts.hasModifier(member, 32 /* Static */) && member.initializer !== undefined; } @@ -47859,8 +49683,8 @@ var ts; * @param receiver The receiver on which each property should be assigned. */ function addInitializedPropertyStatements(statements, properties, receiver) { - for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) { - var property = properties_8[_i]; + for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { + var property = properties_9[_i]; var statement = ts.createStatement(transformInitializedProperty(property, receiver)); ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property)); ts.setCommentRange(statement, property); @@ -47875,8 +49699,8 @@ var ts; */ function generateInitializedPropertyExpressions(properties, receiver) { var expressions = []; - for (var _i = 0, properties_9 = properties; _i < properties_9.length; _i++) { - var property = properties_9[_i]; + for (var _i = 0, properties_10 = properties; _i < properties_10.length; _i++) { + var property = properties_10[_i]; var expression = transformInitializedProperty(property, receiver); expression.startsOnNewLine = true; ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property)); @@ -47983,12 +49807,12 @@ var ts; */ function getAllDecoratorsOfClassElement(node, member) { switch (member.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return getAllDecoratorsOfAccessors(node, member); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return getAllDecoratorsOfMethod(member); - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return getAllDecoratorsOfProperty(member); default: return undefined; @@ -48141,7 +49965,7 @@ var ts; var prefix = getClassMemberPrefix(node, member); var memberName = getExpressionForPropertyName(member, /*generateNameForComputedPropertyName*/ true); var descriptor = languageVersion > 0 /* ES3 */ - ? member.kind === 148 /* PropertyDeclaration */ + ? member.kind === 149 /* PropertyDeclaration */ ? ts.createVoidZero() : ts.createNull() : undefined; @@ -48238,13 +50062,13 @@ var ts; if (compilerOptions.emitDecoratorMetadata) { var properties = void 0; if (shouldAddTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("type", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeTypeOfNode(node)))); } if (shouldAddParamTypesMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("paramTypes", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeParameterTypesOfNode(node, container)))); } if (shouldAddReturnTypeMetadata(node)) { - (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(35 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); + (properties || (properties = [])).push(ts.createPropertyAssignment("returnType", ts.createArrowFunction(/*modifiers*/ undefined, /*typeParameters*/ undefined, [], /*type*/ undefined, ts.createToken(36 /* EqualsGreaterThanToken */), serializeReturnTypeOfNode(node)))); } if (properties) { decoratorExpressions.push(createMetadataHelper(context, "design:typeinfo", ts.createObjectLiteral(properties, /*multiLine*/ true))); @@ -48260,10 +50084,10 @@ var ts; */ function shouldAddTypeMetadata(node) { var kind = node.kind; - return kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */ - || kind === 148 /* PropertyDeclaration */; + return kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */ + || kind === 149 /* PropertyDeclaration */; } /** * Determines whether to emit the "design:returntype" metadata based on the node's kind. @@ -48273,7 +50097,7 @@ var ts; * @param node The node to test. */ function shouldAddReturnTypeMetadata(node) { - return node.kind === 150 /* MethodDeclaration */; + return node.kind === 151 /* MethodDeclaration */; } /** * Determines whether to emit the "design:paramtypes" metadata based on the node's kind. @@ -48284,12 +50108,12 @@ var ts; */ function shouldAddParamTypesMetadata(node) { switch (node.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return ts.getFirstConstructorWithBody(node) !== undefined; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return true; } return false; @@ -48301,15 +50125,15 @@ var ts; */ function serializeTypeOfNode(node) { switch (node.kind) { - case 148 /* PropertyDeclaration */: - case 145 /* Parameter */: - case 152 /* GetAccessor */: + case 149 /* PropertyDeclaration */: + case 146 /* Parameter */: + case 153 /* GetAccessor */: return serializeTypeNode(node.type); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: return serializeTypeNode(ts.getSetAccessorTypeAnnotationNode(node)); - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 150 /* MethodDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 151 /* MethodDeclaration */: return ts.createIdentifier("Function"); default: return ts.createVoidZero(); @@ -48346,7 +50170,7 @@ var ts; return ts.createArrayLiteral(expressions); } function getParametersOfDecoratedDeclaration(node, container) { - if (container && node.kind === 152 /* GetAccessor */) { + if (container && node.kind === 153 /* GetAccessor */) { var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor; if (setAccessor) { return setAccessor.parameters; @@ -48363,7 +50187,7 @@ var ts; if (ts.isFunctionLike(node) && node.type) { return serializeTypeNode(node.type); } - else if (ts.isAsyncFunctionLike(node)) { + else if (ts.isAsyncFunction(node)) { return ts.createIdentifier("Promise"); } return ts.createVoidZero(); @@ -48391,56 +50215,58 @@ var ts; return ts.createIdentifier("Object"); } switch (node.kind) { - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 129 /* NeverKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 130 /* NeverKeyword */: return ts.createVoidZero(); - case 167 /* ParenthesizedType */: + case 168 /* ParenthesizedType */: return serializeTypeNode(node.type); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return ts.createIdentifier("Function"); - case 163 /* ArrayType */: - case 164 /* TupleType */: + case 164 /* ArrayType */: + case 165 /* TupleType */: return ts.createIdentifier("Array"); - case 157 /* TypePredicate */: - case 121 /* BooleanKeyword */: + case 158 /* TypePredicate */: + case 122 /* BooleanKeyword */: return ts.createIdentifier("Boolean"); - case 135 /* StringKeyword */: + case 136 /* StringKeyword */: return ts.createIdentifier("String"); - case 172 /* LiteralType */: + case 134 /* ObjectKeyword */: + return ts.createIdentifier("Object"); + case 173 /* LiteralType */: switch (node.literal.kind) { case 9 /* StringLiteral */: return ts.createIdentifier("String"); case 8 /* NumericLiteral */: return ts.createIdentifier("Number"); - case 100 /* TrueKeyword */: - case 85 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 86 /* FalseKeyword */: return ts.createIdentifier("Boolean"); default: ts.Debug.failBadSyntaxKind(node.literal); break; } break; - case 132 /* NumberKeyword */: + case 133 /* NumberKeyword */: return ts.createIdentifier("Number"); - case 136 /* SymbolKeyword */: + case 137 /* SymbolKeyword */: return languageVersion < 2 /* ES2015 */ ? getGlobalSymbolNameWithFallback() : ts.createIdentifier("Symbol"); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return serializeTypeReferenceNode(node); - case 166 /* IntersectionType */: - case 165 /* UnionType */: + case 167 /* IntersectionType */: + case 166 /* UnionType */: return serializeUnionOrIntersectionType(node); - case 161 /* TypeQuery */: - case 169 /* TypeOperator */: - case 170 /* IndexedAccessType */: - case 171 /* MappedType */: - case 162 /* TypeLiteral */: - case 118 /* AnyKeyword */: - case 168 /* ThisType */: + case 162 /* TypeQuery */: + case 170 /* TypeOperator */: + case 171 /* IndexedAccessType */: + case 172 /* MappedType */: + case 163 /* TypeLiteral */: + case 119 /* AnyKeyword */: + case 169 /* ThisType */: break; default: ts.Debug.failBadSyntaxKind(node); @@ -48525,7 +50351,7 @@ var ts; */ function serializeEntityNameAsExpression(node, useFallback) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: // Create a clone of the name with a new parent, and treat it as if it were // a source tree node for the purposes of the checker. var name = ts.getMutableClone(node); @@ -48536,7 +50362,7 @@ var ts; return ts.createLogicalAnd(ts.createStrictInequality(ts.createTypeOf(name), ts.createLiteral("undefined")), name); } return name; - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return serializeQualifiedNameAsExpression(node, useFallback); } } @@ -48549,7 +50375,7 @@ var ts; */ function serializeQualifiedNameAsExpression(node, useFallback) { var left; - if (node.left.kind === 70 /* Identifier */) { + if (node.left.kind === 71 /* Identifier */) { left = serializeEntityNameAsExpression(node.left, useFallback); } else if (useFallback) { @@ -48620,9 +50446,9 @@ var ts; * @param node The HeritageClause to transform. */ function visitHeritageClause(node) { - if (node.token === 84 /* ExtendsKeyword */) { + if (node.token === 85 /* ExtendsKeyword */) { var types = ts.visitNodes(node.types, visitor, ts.isExpressionWithTypeArguments, 0, 1); - return ts.setTextRange(ts.createHeritageClause(84 /* ExtendsKeyword */, types), node); + return ts.setTextRange(ts.createHeritageClause(85 /* ExtendsKeyword */, types), node); } return undefined; } @@ -48651,7 +50477,7 @@ var ts; if (!shouldEmitFunctionLikeDeclaration(node)) { return undefined; } - return ts.visitEachChild(node, visitor, context); + return ts.updateConstructor(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), ts.visitNodes(node.modifiers, visitor, ts.isModifier), ts.visitParameterList(node.parameters, visitor, context), ts.visitFunctionBody(node.body, visitor, context)); } /** * Visits a method declaration of a class. @@ -48668,7 +50494,8 @@ var ts; return undefined; } var updated = ts.updateMethod(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), visitPropertyNameOfClassElement(node), + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, visitPropertyNameOfClassElement(node), + /*questionToken*/ undefined, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context)); if (updated !== node) { @@ -48750,7 +50577,7 @@ var ts; return ts.createNotEmittedStatement(node); } var updated = ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); if (isNamespaceExport(node)) { @@ -48769,12 +50596,12 @@ var ts; * @param node The function expression node. */ function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { + if (!shouldEmitFunctionLikeDeclaration(node)) { return ts.createOmittedExpression(); } - var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.name, + var updated = ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context)); + /*type*/ undefined, ts.visitFunctionBody(node.body, visitor, context) || ts.createBlock([])); return updated; } /** @@ -48868,13 +50695,13 @@ var ts; // code if the casted expression has a lower precedence than the rest of the // expression. // + // To preserve comments, we return a "PartiallyEmittedExpression" here which will + // preserve the position information of the original expression. + // // Due to the auto-parenthesization rules used by the visitor and factory functions // we can safely elide the parentheses here, as a new synthetic // ParenthesizedExpression will be inserted if we remove parentheses too // aggressively. - // - // To preserve comments, we return a "PartiallyEmittedExpression" here which will - // preserve the position information of the original expression. return ts.createPartiallyEmittedExpression(expression, node); } return ts.visitEachChild(node, visitor, context); @@ -49075,7 +50902,7 @@ var ts; recordEmittedDeclarationInScope(node); if (isFirstEmittedDeclarationInScope(node)) { // Adjust the source map emit to match the old emitter. - if (node.kind === 231 /* EnumDeclaration */) { + if (node.kind === 232 /* EnumDeclaration */) { ts.setSourceMapRange(statement.declarationList, node); } else { @@ -49100,7 +50927,7 @@ var ts; // })(m1 || (m1 = {})); // trailing comment module // ts.setCommentRange(statement, node); - ts.setEmitFlags(statement, 1024 /* NoTrailingComments */ | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, 1024 /* NoTrailingComments */ | 4194304 /* HasEndOfDeclarationMarker */); statements.push(statement); return true; } @@ -49110,7 +50937,7 @@ var ts; // begin/end semantics of the declararation and to properly handle exports // we wrap the leading variable declaration in a `MergeDeclarationMarker`. var mergeMarker = ts.createMergeDeclarationMarker(statement); - ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(mergeMarker, 1536 /* NoComments */ | 4194304 /* HasEndOfDeclarationMarker */); statements.push(mergeMarker); return false; } @@ -49194,7 +51021,7 @@ var ts; var statementsLocation; var blockLocation; var body = node.body; - if (body.kind === 233 /* ModuleBlock */) { + if (body.kind === 234 /* ModuleBlock */) { saveStateAndInvoke(body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); }); statementsLocation = body.statements; blockLocation = body; @@ -49240,13 +51067,13 @@ var ts; // })(hi = hello.hi || (hello.hi = {})); // })(hello || (hello = {})); // We only want to emit comment on the namespace which contains block body itself, not the containing namespaces. - if (body.kind !== 233 /* ModuleBlock */) { + if (body.kind !== 234 /* ModuleBlock */) { ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536 /* NoComments */); } return block; } function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) { - if (moduleDeclaration.body.kind === 232 /* ModuleDeclaration */) { + if (moduleDeclaration.body.kind === 233 /* ModuleDeclaration */) { var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body); return recursiveInnerModule || moduleDeclaration.body; } @@ -49263,7 +51090,7 @@ var ts; return node; } // Elide the declaration if the import clause was elided. - var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause, /*optional*/ true); + var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause); return importClause ? ts.updateImportDeclaration(node, /*decorators*/ undefined, @@ -49278,7 +51105,7 @@ var ts; function visitImportClause(node) { // Elide the import clause if we elide both its name and its named bindings. var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined; - var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings, /*optional*/ true); + var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings); return (name || namedBindings) ? ts.updateImportClause(node, name, namedBindings) : undefined; } /** @@ -49287,7 +51114,7 @@ var ts; * @param node The named import bindings node. */ function visitNamedImportBindings(node) { - if (node.kind === 239 /* NamespaceImport */) { + if (node.kind === 240 /* NamespaceImport */) { // Elide a namespace import if it is not referenced. return resolver.isReferencedAliasDeclaration(node) ? node : undefined; } @@ -49334,7 +51161,7 @@ var ts; return undefined; } // Elide the export declaration if all of its named exports are elided. - var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports, /*optional*/ true); + var exportClause = ts.visitNode(node.exportClause, visitNamedExports, ts.isNamedExports); return exportClause ? ts.updateExportDeclaration(node, /*decorators*/ undefined, @@ -49500,7 +51327,7 @@ var ts; function enableSubstitutionForNonQualifiedEnumMembers() { if ((enabledSubstitutions & 8 /* NonQualifiedEnumMembers */) === 0) { enabledSubstitutions |= 8 /* NonQualifiedEnumMembers */; - context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(71 /* Identifier */); } } function enableSubstitutionForClassAliases() { @@ -49508,7 +51335,7 @@ var ts; enabledSubstitutions |= 1 /* ClassAliases */; // We need to enable substitutions for identifiers. This allows us to // substitute class names inside of a class declaration. - context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(71 /* Identifier */); // Keep track of class aliases. classAliases = []; } @@ -49518,17 +51345,17 @@ var ts; enabledSubstitutions |= 2 /* NamespaceExports */; // We need to enable substitutions for identifiers and shorthand property assignments. This allows us to // substitute the names of exported members of a namespace. - context.enableSubstitution(70 /* Identifier */); - context.enableSubstitution(261 /* ShorthandPropertyAssignment */); + context.enableSubstitution(71 /* Identifier */); + context.enableSubstitution(262 /* ShorthandPropertyAssignment */); // We need to be notified when entering and exiting namespaces. - context.enableEmitNotification(232 /* ModuleDeclaration */); + context.enableEmitNotification(233 /* ModuleDeclaration */); } } function isTransformedModuleDeclaration(node) { - return ts.getOriginalNode(node).kind === 232 /* ModuleDeclaration */; + return ts.getOriginalNode(node).kind === 233 /* ModuleDeclaration */; } function isTransformedEnumDeclaration(node) { - return ts.getOriginalNode(node).kind === 231 /* EnumDeclaration */; + return ts.getOriginalNode(node).kind === 232 /* EnumDeclaration */; } /** * Hook for node emit. @@ -49539,6 +51366,10 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { var savedApplicableSubstitutions = applicableSubstitutions; + var savedCurrentSourceFile = currentSourceFile; + if (ts.isSourceFile(node)) { + currentSourceFile = node; + } if (enabledSubstitutions & 2 /* NamespaceExports */ && isTransformedModuleDeclaration(node)) { applicableSubstitutions |= 2 /* NamespaceExports */; } @@ -49547,6 +51378,7 @@ var ts; } previousOnEmitNode(hint, node, emitCallback); applicableSubstitutions = savedApplicableSubstitutions; + currentSourceFile = savedCurrentSourceFile; } /** * Hooks node substitutions. @@ -49582,11 +51414,11 @@ var ts; } function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return substitutePropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return substituteElementAccessExpression(node); } return node; @@ -49624,9 +51456,9 @@ var ts; // If we are nested within a namespace declaration, we may need to qualifiy // an identifier that is exported from a merged namespace. var container = resolver.getReferencedExportContainer(node, /*prefixLocals*/ false); - if (container && container.kind !== 264 /* SourceFile */) { - var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 232 /* ModuleDeclaration */) || - (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 231 /* EnumDeclaration */); + if (container && container.kind !== 265 /* SourceFile */) { + var substitute = (applicableSubstitutions & 2 /* NamespaceExports */ && container.kind === 233 /* ModuleDeclaration */) || + (applicableSubstitutions & 8 /* NonQualifiedEnumMembers */ && container.kind === 232 /* EnumDeclaration */); if (substitute) { return ts.setTextRange(ts.createPropertyAccess(ts.getGeneratedNameForNode(container), node), /*location*/ node); @@ -49644,16 +51476,15 @@ var ts; function substituteConstantValue(node) { var constantValue = tryGetConstEnumValue(node); if (constantValue !== undefined) { + // track the constant value on the node for the printer in needsDotDotForPropertyAccess + ts.setConstantValue(node, constantValue); var substitute = ts.createLiteral(constantValue); - ts.setSourceMapRange(substitute, node); - ts.setCommentRange(substitute, node); if (!compilerOptions.removeComments) { var propertyName = ts.isPropertyAccessExpression(node) ? ts.declarationNameToString(node.name) : ts.getTextOfNode(node.argumentExpression); - substitute.trailingComment = " " + propertyName + " "; + ts.addSyntheticTrailingComment(substitute, 3 /* MultiLineCommentTrivia */, " " + propertyName + " "); } - ts.setConstantValue(node, constantValue); return substitute; } return node; @@ -49668,42 +51499,7 @@ var ts; } } ts.transformTypeScript = transformTypeScript; - var paramHelper = { - name: "typescript:param", - scoped: false, - priority: 4, - text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" - }; - function createParamHelper(context, expression, parameterOffset, location) { - context.requestEmitHelper(paramHelper); - return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), - /*typeArguments*/ undefined, [ - ts.createLiteral(parameterOffset), - expression - ]), location); - } - var metadataHelper = { - name: "typescript:metadata", - scoped: false, - priority: 3, - text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" - }; - function createMetadataHelper(context, metadataKey, metadataValue) { - context.requestEmitHelper(metadataHelper); - return ts.createCall(ts.getHelperName("__metadata"), - /*typeArguments*/ undefined, [ - ts.createLiteral(metadataKey), - metadataValue - ]); - } - var decorateHelper = { - name: "typescript:decorate", - scoped: false, - priority: 2, - text: "\n var __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 };" - }; function createDecorateHelper(context, decoratorExpressions, target, memberName, descriptor, location) { - context.requestEmitHelper(decorateHelper); var argumentsArray = []; argumentsArray.push(ts.createArrayLiteral(decoratorExpressions, /*multiLine*/ true)); argumentsArray.push(target); @@ -49713,17 +51509,415 @@ var ts; argumentsArray.push(descriptor); } } + context.requestEmitHelper(decorateHelper); return ts.setTextRange(ts.createCall(ts.getHelperName("__decorate"), /*typeArguments*/ undefined, argumentsArray), location); } + var decorateHelper = { + name: "typescript:decorate", + scoped: false, + priority: 2, + text: "\n var __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 };" + }; + function createMetadataHelper(context, metadataKey, metadataValue) { + context.requestEmitHelper(metadataHelper); + return ts.createCall(ts.getHelperName("__metadata"), + /*typeArguments*/ undefined, [ + ts.createLiteral(metadataKey), + metadataValue + ]); + } + var metadataHelper = { + name: "typescript:metadata", + scoped: false, + priority: 3, + text: "\n var __metadata = (this && this.__metadata) || function (k, v) {\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(k, v);\n };" + }; + function createParamHelper(context, expression, parameterOffset, location) { + context.requestEmitHelper(paramHelper); + return ts.setTextRange(ts.createCall(ts.getHelperName("__param"), + /*typeArguments*/ undefined, [ + ts.createLiteral(parameterOffset), + expression + ]), location); + } + var paramHelper = { + name: "typescript:param", + scoped: false, + priority: 4, + text: "\n var __param = (this && this.__param) || function (paramIndex, decorator) {\n return function (target, key) { decorator(target, key, paramIndex); }\n };" + }; })(ts || (ts = {})); /// /// /*@internal*/ var ts; (function (ts) { + var ES2017SubstitutionFlags; + (function (ES2017SubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); + function transformES2017(context) { + var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + // These variables contain state that changes as we descend into the tree. + var currentSourceFile; + /** + * Keeps track of whether expression substitution has been enabled for specific edge cases. + * They are persisted between each SourceFile transformation and should not be reset. + */ + var enabledSubstitutions; + /** + * This keeps track of containers where `super` is valid, for use with + * just-in-time substitution for `super` expressions inside of async methods. + */ + var enclosingSuperContainerFlags = 0; + // Save the previous transformation hooks. + var previousOnEmitNode = context.onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + // Set new transformation hooks. + context.onEmitNode = onEmitNode; + context.onSubstituteNode = onSubstituteNode; + return transformSourceFile; + function transformSourceFile(node) { + if (ts.isDeclarationFile(node)) { + return node; + } + currentSourceFile = node; + var visited = ts.visitEachChild(node, visitor, context); + ts.addEmitHelpers(visited, context.readEmitHelpers()); + currentSourceFile = undefined; + return visited; + } + function visitor(node) { + if ((node.transformFlags & 16 /* ContainsES2017 */) === 0) { + return node; + } + switch (node.kind) { + case 120 /* AsyncKeyword */: + // ES2017 async modifier should be elided for targets < ES2017 + return undefined; + case 191 /* AwaitExpression */: + return visitAwaitExpression(node); + case 151 /* MethodDeclaration */: + return visitMethodDeclaration(node); + case 228 /* FunctionDeclaration */: + return visitFunctionDeclaration(node); + case 186 /* FunctionExpression */: + return visitFunctionExpression(node); + case 187 /* ArrowFunction */: + return visitArrowFunction(node); + default: + return ts.visitEachChild(node, visitor, context); + } + } + /** + * Visits an AwaitExpression node. + * + * This function will be called any time a ES2017 await expression is encountered. + * + * @param node The node to visit. + */ + function visitAwaitExpression(node) { + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); + } + /** + * Visits a MethodDeclaration node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked as async + * + * @param node The node to visit. + */ + function visitMethodDeclaration(node) { + return ts.updateMethod(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*questionToken*/ undefined, + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + /** + * Visits a FunctionDeclaration node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The node to visit. + */ + function visitFunctionDeclaration(node) { + return ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + /** + * Visits a FunctionExpression node. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The node to visit. + */ + function visitFunctionExpression(node) { + return ts.updateFunctionExpression(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, node.name, + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + /** + * Visits an ArrowFunction. + * + * This function will be called when one of the following conditions are met: + * - The node is marked async + * + * @param node The node to visit. + */ + function visitArrowFunction(node) { + return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), + /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), + /*type*/ undefined, ts.getFunctionFlags(node) & 2 /* Async */ + ? transformAsyncFunctionBody(node) + : ts.visitFunctionBody(node.body, visitor, context)); + } + function transformAsyncFunctionBody(node) { + resumeLexicalEnvironment(); + var original = ts.getOriginalNode(node, ts.isFunctionLike); + var nodeType = original.type; + var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; + var isArrowFunction = node.kind === 187 /* 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 + // passed to `__awaiter` is executed inside of the callback to the + // promise constructor. + if (!isArrowFunction) { + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.createBlock(statements, /*multiLine*/ true); + ts.setTextRange(block, node.body); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; + } + else { + var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); + var declarations = endLexicalEnvironment(); + if (ts.some(declarations)) { + var block = ts.convertToFunctionBody(expression); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); + } + return expression; + } + } + function transformFunctionBodyWorker(body, start) { + if (ts.isBlock(body)) { + return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); + } + else { + startLexicalEnvironment(); + var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); + var declarations = endLexicalEnvironment(); + return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); + } + } + function getPromiseConstructor(type) { + var typeName = type && ts.getEntityNameFromTypeNode(type); + if (typeName && ts.isEntityName(typeName)) { + var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); + if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue + || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { + return typeName; + } + } + return undefined; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(181 /* CallExpression */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(180 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(229 /* ClassDeclaration */); + context.enableEmitNotification(151 /* MethodDeclaration */); + context.enableEmitNotification(153 /* GetAccessor */); + context.enableEmitNotification(154 /* SetAccessor */); + context.enableEmitNotification(152 /* Constructor */); + } + } + /** + * Hook for node emit. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to emit. + * @param emit A callback used to emit the node in the printer. + */ + function onEmitNode(hint, node, emitCallback) { + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 180 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 181 /* CallExpression */: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 /* ClassDeclaration */ + || kind === 152 /* Constructor */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); + } + } + } + ts.transformES2017 = transformES2017; + var awaiterHelper = { + name: "typescript:awaiter", + scoped: false, + priority: 5, + text: "\n var __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 };" + }; + function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { + context.requestEmitHelper(awaiterHelper); + var generatorFunc = ts.createFunctionExpression( + /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), + /*name*/ undefined, + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, body); + // Mark this node as originally an async function + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; + return ts.createCall(ts.getHelperName("__awaiter"), + /*typeArguments*/ undefined, [ + ts.createThis(), + hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), + promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), + generatorFunc + ]); + } + ts.asyncSuperHelper = { + name: "typescript:async-super", + scoped: true, + text: "\n const _super = name => super[name];\n " + }; + ts.advancedAsyncSuperHelper = { + name: "typescript:advanced-async-super", + scoped: true, + text: "\n const _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);\n " + }; +})(ts || (ts = {})); +/// +/// +/// +/*@internal*/ +var ts; +(function (ts) { + var ESNextSubstitutionFlags; + (function (ESNextSubstitutionFlags) { + /** Enables substitutions for async methods with `super` calls. */ + ESNextSubstitutionFlags[ESNextSubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; + })(ESNextSubstitutionFlags || (ESNextSubstitutionFlags = {})); function transformESNext(context) { - var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; + var resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var resolver = context.getEmitResolver(); + var compilerOptions = context.getCompilerOptions(); + var languageVersion = ts.getEmitScriptTarget(compilerOptions); + var previousOnEmitNode = context.onEmitNode; + context.onEmitNode = onEmitNode; + var previousOnSubstituteNode = context.onSubstituteNode; + context.onSubstituteNode = onSubstituteNode; + var enabledSubstitutions; + var enclosingFunctionFlags; + var enclosingSuperContainerFlags = 0; return transformSourceFile; function transformSourceFile(node) { if (ts.isDeclarationFile(node)) { @@ -49739,53 +51933,95 @@ var ts; function visitorNoDestructuringValue(node) { return visitorWorker(node, /*noDestructuringValue*/ true); } + function visitorNoAsyncModifier(node) { + if (node.kind === 120 /* AsyncKeyword */) { + return undefined; + } + return node; + } function visitorWorker(node, noDestructuringValue) { if ((node.transformFlags & 8 /* ContainsESNext */) === 0) { return node; } switch (node.kind) { - case 177 /* ObjectLiteralExpression */: + case 191 /* AwaitExpression */: + return visitAwaitExpression(node); + case 197 /* YieldExpression */: + return visitYieldExpression(node); + case 222 /* LabeledStatement */: + return visitLabeledStatement(node); + case 178 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node, noDestructuringValue); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 215 /* ForOfStatement */: - return visitForOfStatement(node); - case 213 /* ForStatement */: + case 216 /* ForOfStatement */: + return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); + case 214 /* ForStatement */: return visitForStatement(node); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return visitVoidExpression(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return visitConstructorDeclaration(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 152 /* GetAccessor */: + case 153 /* GetAccessor */: return visitGetAccessorDeclaration(node); - case 153 /* SetAccessor */: + case 154 /* SetAccessor */: return visitSetAccessorDeclaration(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return visitArrowFunction(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return visitParameter(node); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return visitExpressionStatement(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, noDestructuringValue); default: return ts.visitEachChild(node, visitor, context); } } + function visitAwaitExpression(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.setOriginalNode(ts.setTextRange(ts.createYield( + /*asteriskToken*/ undefined, ts.createArrayLiteral([ts.createLiteral("await"), expression])), + /*location*/ node), node); + } + return ts.visitEachChild(node, visitor, context); + } + function visitYieldExpression(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + return ts.updateYield(node, node.asteriskToken, node.asteriskToken + ? createAsyncDelegatorHelper(context, expression, expression) + : ts.createArrayLiteral(expression + ? [ts.createLiteral("yield"), expression] + : [ts.createLiteral("yield")])); + } + return ts.visitEachChild(node, visitor, context); + } + function visitLabeledStatement(node) { + if (enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */) { + var statement = ts.unwrapInnermostStatementOfLabel(node); + if (statement.kind === 216 /* ForOfStatement */ && statement.awaitModifier) { + return visitForOfStatement(statement, node); + } + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), node); + } + return ts.visitEachChild(node, visitor, context); + } function chunkObjectLiteralElements(elements) { var chunkObject; var objects = []; for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) { var e = elements_4[_i]; - if (e.kind === 262 /* SpreadAssignment */) { + if (e.kind === 263 /* SpreadAssignment */) { if (chunkObject) { objects.push(ts.createObjectLiteral(chunkObject)); chunkObject = undefined; @@ -49797,7 +52033,7 @@ var ts; if (!chunkObject) { chunkObject = []; } - if (e.kind === 260 /* PropertyAssignment */) { + if (e.kind === 261 /* PropertyAssignment */) { var p = e; chunkObject.push(ts.createPropertyAssignment(p.name, ts.visitNode(p.initializer, visitor, ts.isExpression))); } @@ -49819,7 +52055,7 @@ var ts; // If the first element is a spread element, then the first argument to __assign is {}: // { ...o, a, b, ...o2 } => __assign({}, o, {a, b}, o2) var objects = chunkObjectLiteralElements(node.properties); - if (objects.length && objects[0].kind !== 177 /* ObjectLiteralExpression */) { + if (objects.length && objects[0].kind !== 178 /* ObjectLiteralExpression */) { objects.unshift(ts.createObjectLiteral()); } return createAssignHelper(context, objects); @@ -49841,7 +52077,7 @@ var ts; if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 1048576 /* ContainsObjectRest */) { return ts.flattenDestructuringAssignment(node, visitor, context, 1 /* ObjectRest */, !noDestructuringValue); } - else if (node.operatorToken.kind === 25 /* CommaToken */) { + else if (node.operatorToken.kind === 26 /* CommaToken */) { return ts.updateBinary(node, ts.visitNode(node.left, visitorNoDestructuringValue, ts.isExpression), ts.visitNode(node.right, noDestructuringValue ? visitorNoDestructuringValue : visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); @@ -49869,41 +52105,101 @@ var ts; * * @param node A ForOfStatement. */ - function visitForOfStatement(node) { - var leadingStatements; - var temp; - var initializer = ts.skipParentheses(node.initializer); - if (initializer.transformFlags & 1048576 /* ContainsObjectRest */) { - if (ts.isVariableDeclarationList(initializer)) { - temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var firstDeclaration = ts.firstOrUndefined(initializer.declarations); - var declarations = ts.flattenDestructuringBinding(firstDeclaration, visitor, context, 1 /* ObjectRest */, temp, - /*doNotRecordTempVariablesInLine*/ false, - /*skipInitializer*/ true); - if (ts.some(declarations)) { - var statement = ts.createVariableStatement( - /*modifiers*/ undefined, ts.updateVariableDeclarationList(initializer, declarations)); - ts.setTextRange(statement, initializer); - leadingStatements = ts.append(leadingStatements, statement); - } - } - else if (ts.isAssignmentPattern(initializer)) { - temp = ts.createTempVariable(/*recordTempVariable*/ undefined); - var expression = ts.flattenDestructuringAssignment(ts.aggregateTransformFlags(ts.setTextRange(ts.createAssignment(initializer, temp), node.initializer)), visitor, context, 1 /* ObjectRest */); - leadingStatements = ts.append(leadingStatements, ts.setTextRange(ts.createStatement(expression), node.initializer)); - } + function visitForOfStatement(node, outermostLabeledStatement) { + if (node.initializer.transformFlags & 1048576 /* ContainsObjectRest */) { + node = transformForOfStatementWithObjectRest(node); } - if (temp) { - var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var statement = ts.visitNode(node.statement, visitor, ts.isStatement); - var block = ts.isBlock(statement) - ? ts.updateBlock(statement, ts.setTextRange(ts.createNodeArray(ts.concatenate(leadingStatements, statement.statements)), statement.statements)) - : ts.setTextRange(ts.createBlock(ts.append(leadingStatements, statement), /*multiLine*/ true), statement); - return ts.updateForOf(node, ts.setTextRange(ts.createVariableDeclarationList([ + if (node.awaitModifier) { + return transformForAwaitOfStatement(node, outermostLabeledStatement); + } + else { + return ts.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement); + } + } + function transformForOfStatementWithObjectRest(node) { + var initializerWithoutParens = ts.skipParentheses(node.initializer); + if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) { + var bodyLocation = void 0; + var statementsLocation = void 0; + var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); + var statements = [ts.createForOfBindingStatement(initializerWithoutParens, temp)]; + if (ts.isBlock(node.statement)) { + ts.addRange(statements, node.statement.statements); + bodyLocation = node.statement; + statementsLocation = node.statement.statements; + } + return ts.updateForOf(node, node.awaitModifier, ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(temp), node.initializer) - ], 1 /* Let */), node.initializer), expression, block); + ], 1 /* Let */), node.initializer), node.expression, ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), + /*multiLine*/ true), bodyLocation)); } - return ts.visitEachChild(node, visitor, context); + return node; + } + function convertForOfStatementHead(node, boundValue) { + var binding = ts.createForOfBindingStatement(node.initializer, boundValue); + var bodyLocation; + var statementsLocation; + var statements = [ts.visitNode(binding, visitor, ts.isStatement)]; + var statement = ts.visitNode(node.statement, visitor, ts.isStatement); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), + /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + } + function transformForAwaitOfStatement(node, outermostLabeledStatement) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(/*recordTempVariable*/ undefined); + var values = createAsyncValuesHelper(context, expression, /*location*/ node.expression); + var next = ts.createYield( + /*asteriskToken*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []) + ]) + : ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, [])); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor( + /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), + ts.createVariableDeclaration(result, /*type*/ undefined, next) + ]), node.expression), 2097152 /* NoHoisting */), + /*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")), + /*incrementor*/ ts.createAssignment(result, next), + /*statement*/ convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"))), + /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1 /* SingleLine */)), ts.createBlock([ + ts.createTry( + /*tryBlock*/ ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createYield( + /*asteriskToken*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.createArrayLiteral([ + ts.createLiteral("await"), + ts.createFunctionCall(returnMethod, iterator, []) + ]) + : ts.createFunctionCall(returnMethod, iterator, [])))), 1 /* SingleLine */) + ]), + /*catchClause*/ undefined, + /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1 /* SingleLine */) + ]), 1 /* SingleLine */)) + ])); } function visitParameter(node) { if (node.transformFlags & 1048576 /* ContainsObjectRest */) { @@ -49912,48 +52208,137 @@ var ts; return ts.updateParameter(node, /*decorators*/ undefined, /*modifiers*/ undefined, node.dotDotDotToken, ts.getGeneratedNameForNode(node), + /*questionToken*/ undefined, /*type*/ undefined, ts.visitNode(node.initializer, visitor, ts.isExpression)); } return ts.visitEachChild(node, visitor, context); } function visitConstructorDeclaration(node) { - return ts.updateConstructor(node, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0 /* Normal */; + var updated = ts.updateConstructor(node, /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitGetAccessorDeclaration(node) { - return ts.updateGetAccessor(node, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0 /* Normal */; + var updated = ts.updateGetAccessor(node, /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitSetAccessorDeclaration(node) { - return ts.updateSetAccessor(node, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = 0 /* Normal */; + var updated = ts.updateSetAccessor(node, /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitMethodDeclaration(node) { - return ts.updateMethod(node, - /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateMethod(node, + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + ? undefined + : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken), /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, node.modifiers, node.name, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionDeclaration(node, + /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */ + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + ? undefined + : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitArrowFunction(node) { - return ts.updateArrowFunction(node, node.modifiers, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateArrowFunction(node, node.modifiers, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), /*type*/ undefined, transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; } function visitFunctionExpression(node) { - return ts.updateFunctionExpression(node, node.modifiers, node.name, + var savedEnclosingFunctionFlags = enclosingFunctionFlags; + enclosingFunctionFlags = ts.getFunctionFlags(node); + var updated = ts.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */ + ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier) + : node.modifiers, enclosingFunctionFlags & 2 /* Async */ + ? undefined + : node.asteriskToken, node.name, /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, transformFunctionBody(node)); + /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */ + ? transformAsyncGeneratorFunctionBody(node) + : transformFunctionBody(node)); + enclosingFunctionFlags = savedEnclosingFunctionFlags; + return updated; + } + function transformAsyncGeneratorFunctionBody(node) { + resumeLexicalEnvironment(); + var statements = []; + var statementOffset = ts.addPrologue(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); + appendObjectRestAssignmentsIfNeeded(statements, node); + statements.push(ts.createReturn(createAsyncGeneratorHelper(context, ts.createFunctionExpression( + /*modifiers*/ undefined, ts.createToken(39 /* AsteriskToken */), node.name && ts.getGeneratedNameForNode(node.name), + /*typeParameters*/ undefined, + /*parameters*/ [], + /*type*/ undefined, ts.updateBlock(node.body, ts.visitLexicalEnvironment(node.body.statements, visitor, context, statementOffset)))))); + ts.addRange(statements, endLexicalEnvironment()); + var block = ts.updateBlock(node.body, statements); + // Minor optimization, emit `_super` helper to capture `super` access in an arrow. + // This step isn't needed if we eventually transform this to ES5. + if (languageVersion >= 2 /* ES2015 */) { + if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.advancedAsyncSuperHelper); + } + else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { + enableSubstitutionForAsyncMethodsWithSuper(); + ts.addEmitHelper(block, ts.asyncSuperHelper); + } + } + return block; } function transformFunctionBody(node) { resumeLexicalEnvironment(); - var leadingStatements; + var statementOffset = 0; + var statements = []; + var body = ts.visitNode(node.body, visitor, ts.isConciseBody); + if (ts.isBlock(body)) { + statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); + } + ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(/*statements*/ undefined, node)); + var trailingStatements = endLexicalEnvironment(); + if (statementOffset > 0 || ts.some(statements) || ts.some(trailingStatements)) { + var block = ts.convertToFunctionBody(body, /*multiLine*/ true); + ts.addRange(statements, block.statements.slice(statementOffset)); + ts.addRange(statements, trailingStatements); + return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(statements), block.statements)); + } + return body; + } + function appendObjectRestAssignmentsIfNeeded(statements, node) { for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) { var parameter = _a[_i]; if (parameter.transformFlags & 1048576 /* ContainsObjectRest */) { @@ -49964,18 +52349,117 @@ var ts; if (ts.some(declarations)) { var statement = ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(declarations)); - ts.setEmitFlags(statement, 524288 /* CustomPrologue */); - leadingStatements = ts.append(leadingStatements, statement); + ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); + statements = ts.append(statements, statement); } } } - var body = ts.visitNode(node.body, visitor, ts.isConciseBody); - var trailingStatements = endLexicalEnvironment(); - if (ts.some(leadingStatements) || ts.some(trailingStatements)) { - var block = ts.convertToFunctionBody(body, /*multiLine*/ true); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(ts.concatenate(leadingStatements, block.statements), trailingStatements)), block.statements)); + return statements; + } + function enableSubstitutionForAsyncMethodsWithSuper() { + if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { + enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; + // We need to enable substitutions for call, property access, and element access + // if we need to rewrite super calls. + context.enableSubstitution(181 /* CallExpression */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(180 /* ElementAccessExpression */); + // We need to be notified when entering and exiting declarations that bind super. + context.enableEmitNotification(229 /* ClassDeclaration */); + context.enableEmitNotification(151 /* MethodDeclaration */); + context.enableEmitNotification(153 /* GetAccessor */); + context.enableEmitNotification(154 /* SetAccessor */); + context.enableEmitNotification(152 /* Constructor */); + } + } + /** + * Called by the printer just before a node is printed. + * + * @param hint A hint as to the intended usage of the node. + * @param node The node to be printed. + * @param emitCallback The callback used to emit the node. + */ + function onEmitNode(hint, node, emitCallback) { + // If we need to support substitutions for `super` in an async method, + // we should track it here. + if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { + var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); + if (superContainerFlags !== enclosingSuperContainerFlags) { + var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags; + enclosingSuperContainerFlags = superContainerFlags; + previousOnEmitNode(hint, node, emitCallback); + enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags; + return; + } + } + previousOnEmitNode(hint, node, emitCallback); + } + /** + * Hooks node substitutions. + * + * @param hint The context for the emitter. + * @param node The node to substitute. + */ + function onSubstituteNode(hint, node) { + node = previousOnSubstituteNode(hint, node); + if (hint === 1 /* Expression */ && enclosingSuperContainerFlags) { + return substituteExpression(node); + } + return node; + } + function substituteExpression(node) { + switch (node.kind) { + case 179 /* PropertyAccessExpression */: + return substitutePropertyAccessExpression(node); + case 180 /* ElementAccessExpression */: + return substituteElementAccessExpression(node); + case 181 /* CallExpression */: + return substituteCallExpression(node); + } + return node; + } + function substitutePropertyAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), node); + } + return node; + } + function substituteElementAccessExpression(node) { + if (node.expression.kind === 97 /* SuperKeyword */) { + return createSuperAccessInAsyncMethod(node.argumentExpression, node); + } + return node; + } + function substituteCallExpression(node) { + var expression = node.expression; + if (ts.isSuperProperty(expression)) { + var argumentExpression = ts.isPropertyAccessExpression(expression) + ? substitutePropertyAccessExpression(expression) + : substituteElementAccessExpression(expression); + return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), + /*typeArguments*/ undefined, [ + ts.createThis() + ].concat(node.arguments)); + } + return node; + } + function isSuperContainer(node) { + var kind = node.kind; + return kind === 229 /* ClassDeclaration */ + || kind === 152 /* Constructor */ + || kind === 151 /* MethodDeclaration */ + || kind === 153 /* GetAccessor */ + || kind === 154 /* SetAccessor */; + } + function createSuperAccessInAsyncMethod(argumentExpression, location) { + if (enclosingSuperContainerFlags & 4096 /* AsyncMethodWithSuperBinding */) { + return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), "value"), location); + } + else { + return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), + /*typeArguments*/ undefined, [argumentExpression]), location); } - return body; } } ts.transformESNext = transformESNext; @@ -49995,6 +52479,43 @@ var ts; /*typeArguments*/ undefined, attributesSegments); } ts.createAssignHelper = createAssignHelper; + var asyncGeneratorHelper = { + name: "typescript:asyncGenerator", + scoped: false, + text: "\n var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), q = [], c, i;\n return i = { next: verb(\"next\"), \"throw\": verb(\"throw\"), \"return\": verb(\"return\") }, i[Symbol.asyncIterator] = function () { return this; }, i;\n function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; }\n function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } }\n function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === \"yield\" ? send : fulfill, reject); }\n function send(value) { settle(c[2], { value: value, done: false }); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { c = void 0, f(v), next(); }\n };\n " + }; + function createAsyncGeneratorHelper(context, generatorFunc) { + context.requestEmitHelper(asyncGeneratorHelper); + // Mark this node as originally an async function + (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 /* AsyncFunctionBody */; + return ts.createCall(ts.getHelperName("__asyncGenerator"), + /*typeArguments*/ undefined, [ + ts.createThis(), + ts.createIdentifier("arguments"), + generatorFunc + ]); + } + var asyncDelegator = { + name: "typescript:asyncDelegator", + scoped: false, + text: "\n var __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i = { next: verb(\"next\"), \"throw\": verb(\"throw\", function (e) { throw e; }), \"return\": verb(\"return\", function (v) { return { value: v, done: true }; }) }, p;\n return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { return function (v) { return v = p && n === \"throw\" ? f(v) : p && v.done ? v : { value: p ? [\"yield\", v.value] : [\"await\", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; }\n };\n " + }; + function createAsyncDelegatorHelper(context, expression, location) { + context.requestEmitHelper(asyncDelegator); + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncDelegator"), + /*typeArguments*/ undefined, [expression]), location); + } + var asyncValues = { + name: "typescript:asyncValues", + scoped: false, + text: "\n var __asyncValues = (this && this.__asyncIterator) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator];\n return m ? m.call(o) : typeof __values === \"function\" ? __values(o) : o[Symbol.iterator]();\n };\n " + }; + function createAsyncValuesHelper(context, expression, location) { + context.requestEmitHelper(asyncValues); + return ts.setTextRange(ts.createCall(ts.getHelperName("__asyncValues"), + /*typeArguments*/ undefined, [expression]), location); + } })(ts || (ts = {})); /// /// @@ -50004,7 +52525,6 @@ var ts; (function (ts) { function transformJsx(context) { var compilerOptions = context.getCompilerOptions(); - var currentSourceFile; return transformSourceFile; /** * Transform JSX-specific syntax in a SourceFile. @@ -50015,10 +52535,8 @@ var ts; if (ts.isDeclarationFile(node)) { return node; } - currentSourceFile = node; var visited = ts.visitEachChild(node, visitor, context); ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; return visited; } function visitor(node) { @@ -50031,11 +52549,11 @@ var ts; } function visitorWorker(node) { switch (node.kind) { - case 248 /* JsxElement */: + case 249 /* JsxElement */: return visitJsxElement(node, /*isChild*/ false); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ false); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return visitJsxExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -50045,11 +52563,11 @@ var ts; switch (node.kind) { case 10 /* JsxText */: return visitJsxText(node); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return visitJsxExpression(node); - case 248 /* JsxElement */: + case 249 /* JsxElement */: return visitJsxElement(node, /*isChild*/ true); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return visitJsxSelfClosingElement(node, /*isChild*/ true); default: ts.Debug.failBadSyntaxKind(node); @@ -50110,7 +52628,7 @@ var ts; var decoded = tryDecodeEntities(node.text); return decoded ? ts.setTextRange(ts.createLiteral(decoded), node) : node; } - else if (node.kind === 255 /* JsxExpression */) { + else if (node.kind === 256 /* JsxExpression */) { if (node.expression === undefined) { return ts.createTrue(); } @@ -50202,7 +52720,7 @@ var ts; return decoded === text ? undefined : decoded; } function getTagName(node) { - if (node.kind === 248 /* JsxElement */) { + if (node.kind === 249 /* JsxElement */) { return getTagName(node.openingElement); } else { @@ -50494,375 +53012,6 @@ var ts; /// /*@internal*/ var ts; -(function (ts) { - var ES2017SubstitutionFlags; - (function (ES2017SubstitutionFlags) { - /** Enables substitutions for async methods with `super` calls. */ - ES2017SubstitutionFlags[ES2017SubstitutionFlags["AsyncMethodsWithSuper"] = 1] = "AsyncMethodsWithSuper"; - })(ES2017SubstitutionFlags || (ES2017SubstitutionFlags = {})); - function transformES2017(context) { - var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment; - var resolver = context.getEmitResolver(); - var compilerOptions = context.getCompilerOptions(); - var languageVersion = ts.getEmitScriptTarget(compilerOptions); - // These variables contain state that changes as we descend into the tree. - var currentSourceFile; - /** - * Keeps track of whether expression substitution has been enabled for specific edge cases. - * They are persisted between each SourceFile transformation and should not be reset. - */ - var enabledSubstitutions; - /** - * This keeps track of containers where `super` is valid, for use with - * just-in-time substitution for `super` expressions inside of async methods. - */ - var currentSuperContainer; - // Save the previous transformation hooks. - var previousOnEmitNode = context.onEmitNode; - var previousOnSubstituteNode = context.onSubstituteNode; - // Set new transformation hooks. - context.onEmitNode = onEmitNode; - context.onSubstituteNode = onSubstituteNode; - return transformSourceFile; - function transformSourceFile(node) { - if (ts.isDeclarationFile(node)) { - return node; - } - currentSourceFile = node; - var visited = ts.visitEachChild(node, visitor, context); - ts.addEmitHelpers(visited, context.readEmitHelpers()); - currentSourceFile = undefined; - return visited; - } - function visitor(node) { - if ((node.transformFlags & 16 /* ContainsES2017 */) === 0) { - return node; - } - switch (node.kind) { - case 119 /* AsyncKeyword */: - // ES2017 async modifier should be elided for targets < ES2017 - return undefined; - case 190 /* AwaitExpression */: - // ES2017 'await' expressions must be transformed for targets < ES2017. - return visitAwaitExpression(node); - case 150 /* MethodDeclaration */: - // ES2017 method declarations may be 'async' - return visitMethodDeclaration(node); - case 227 /* FunctionDeclaration */: - // ES2017 function declarations may be 'async' - return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: - // ES2017 function expressions may be 'async' - return visitFunctionExpression(node); - case 186 /* ArrowFunction */: - // ES2017 arrow functions may be 'async' - return visitArrowFunction(node); - default: - return ts.visitEachChild(node, visitor, context); - } - } - /** - * Visits an AwaitExpression node. - * - * This function will be called any time a ES2017 await expression is encountered. - * - * @param node The node to visit. - */ - function visitAwaitExpression(node) { - return ts.setOriginalNode(ts.setTextRange(ts.createYield( - /*asteriskToken*/ undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node); - } - /** - * Visits a MethodDeclaration node. - * - * This function will be called when one of the following conditions are met: - * - The node is marked as async - * - * @param node The node to visit. - */ - function visitMethodDeclaration(node) { - return ts.updateMethod(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - /** - * Visits a FunctionDeclaration node. - * - * This function will be called when one of the following conditions are met: - * - The node is marked async - * - * @param node The node to visit. - */ - function visitFunctionDeclaration(node) { - return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - /** - * Visits a FunctionExpression node. - * - * This function will be called when one of the following conditions are met: - * - The node is marked async - * - * @param node The node to visit. - */ - function visitFunctionExpression(node) { - if (ts.nodeIsMissing(node.body)) { - return ts.createOmittedExpression(); - } - return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, node.name, - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - /** - * Visits an ArrowFunction. - * - * This function will be called when one of the following conditions are met: - * - The node is marked async - * - * @param node The node to visit. - */ - function visitArrowFunction(node) { - return ts.updateArrowFunction(node, ts.visitNodes(node.modifiers, visitor, ts.isModifier), - /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context), - /*type*/ undefined, ts.isAsyncFunctionLike(node) - ? transformAsyncFunctionBody(node) - : ts.visitFunctionBody(node.body, visitor, context)); - } - function transformAsyncFunctionBody(node) { - resumeLexicalEnvironment(); - var original = ts.getOriginalNode(node, ts.isFunctionLike); - var nodeType = original.type; - var promiseConstructor = languageVersion < 2 /* ES2015 */ ? getPromiseConstructor(nodeType) : undefined; - var isArrowFunction = node.kind === 186 /* 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 - // passed to `__awaiter` is executed inside of the callback to the - // promise constructor. - if (!isArrowFunction) { - var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.body.statements, /*ensureUseStrict*/ false, visitor); - statements.push(ts.createReturn(createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body, statementOffset)))); - ts.addRange(statements, endLexicalEnvironment()); - var block = ts.createBlock(statements, /*multiLine*/ true); - ts.setTextRange(block, node.body); - // Minor optimization, emit `_super` helper to capture `super` access in an arrow. - // This step isn't needed if we eventually transform this to ES5. - if (languageVersion >= 2 /* ES2015 */) { - if (resolver.getNodeCheckFlags(node) & 4096 /* AsyncMethodWithSuperBinding */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, advancedAsyncSuperHelper); - } - else if (resolver.getNodeCheckFlags(node) & 2048 /* AsyncMethodWithSuper */) { - enableSubstitutionForAsyncMethodsWithSuper(); - ts.addEmitHelper(block, asyncSuperHelper); - } - } - return block; - } - else { - var expression = createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, transformFunctionBodyWorker(node.body)); - var declarations = endLexicalEnvironment(); - if (ts.some(declarations)) { - var block = ts.convertToFunctionBody(expression); - return ts.updateBlock(block, ts.setTextRange(ts.createNodeArray(ts.concatenate(block.statements, declarations)), block.statements)); - } - return expression; - } - } - function transformFunctionBodyWorker(body, start) { - if (ts.isBlock(body)) { - return ts.updateBlock(body, ts.visitLexicalEnvironment(body.statements, visitor, context, start)); - } - else { - startLexicalEnvironment(); - var visited = ts.convertToFunctionBody(ts.visitNode(body, visitor, ts.isConciseBody)); - var declarations = endLexicalEnvironment(); - return ts.updateBlock(visited, ts.setTextRange(ts.createNodeArray(ts.concatenate(visited.statements, declarations)), visited.statements)); - } - } - function getPromiseConstructor(type) { - var typeName = type && ts.getEntityNameFromTypeNode(type); - if (typeName && ts.isEntityName(typeName)) { - var serializationKind = resolver.getTypeReferenceSerializationKind(typeName); - if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue - || serializationKind === ts.TypeReferenceSerializationKind.Unknown) { - return typeName; - } - } - return undefined; - } - function enableSubstitutionForAsyncMethodsWithSuper() { - if ((enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) === 0) { - enabledSubstitutions |= 1 /* AsyncMethodsWithSuper */; - // We need to enable substitutions for call, property access, and element access - // if we need to rewrite super calls. - context.enableSubstitution(180 /* CallExpression */); - context.enableSubstitution(178 /* PropertyAccessExpression */); - context.enableSubstitution(179 /* ElementAccessExpression */); - // We need to be notified when entering and exiting declarations that bind super. - context.enableEmitNotification(228 /* ClassDeclaration */); - context.enableEmitNotification(150 /* MethodDeclaration */); - context.enableEmitNotification(152 /* GetAccessor */); - context.enableEmitNotification(153 /* SetAccessor */); - context.enableEmitNotification(151 /* Constructor */); - } - } - function substituteExpression(node) { - switch (node.kind) { - case 178 /* PropertyAccessExpression */: - return substitutePropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: - return substituteElementAccessExpression(node); - case 180 /* CallExpression */: - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */) { - return substituteCallExpression(node); - } - break; - } - return node; - } - function substitutePropertyAccessExpression(node) { - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(ts.createLiteral(node.name.text), flags, node); - } - } - return node; - } - function substituteElementAccessExpression(node) { - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && node.expression.kind === 96 /* SuperKeyword */) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - return createSuperAccessInAsyncMethod(node.argumentExpression, flags, node); - } - } - return node; - } - function substituteCallExpression(node) { - var expression = node.expression; - if (ts.isSuperProperty(expression)) { - var flags = getSuperContainerAsyncMethodFlags(); - if (flags) { - var argumentExpression = ts.isPropertyAccessExpression(expression) - ? substitutePropertyAccessExpression(expression) - : substituteElementAccessExpression(expression); - return ts.createCall(ts.createPropertyAccess(argumentExpression, "call"), - /*typeArguments*/ undefined, [ - ts.createThis() - ].concat(node.arguments)); - } - } - return node; - } - function isSuperContainer(node) { - var kind = node.kind; - return kind === 228 /* ClassDeclaration */ - || kind === 151 /* Constructor */ - || kind === 150 /* MethodDeclaration */ - || kind === 152 /* GetAccessor */ - || kind === 153 /* SetAccessor */; - } - /** - * Hook for node emit. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to emit. - * @param emit A callback used to emit the node in the printer. - */ - function onEmitNode(hint, node, emitCallback) { - // If we need to support substitutions for `super` in an async method, - // we should track it here. - if (enabledSubstitutions & 1 /* AsyncMethodsWithSuper */ && isSuperContainer(node)) { - var savedCurrentSuperContainer = currentSuperContainer; - currentSuperContainer = node; - previousOnEmitNode(hint, node, emitCallback); - currentSuperContainer = savedCurrentSuperContainer; - } - else { - previousOnEmitNode(hint, node, emitCallback); - } - } - /** - * Hooks node substitutions. - * - * @param hint A hint as to the intended usage of the node. - * @param node The node to substitute. - */ - function onSubstituteNode(hint, node) { - node = previousOnSubstituteNode(hint, node); - if (hint === 1 /* Expression */) { - return substituteExpression(node); - } - return node; - } - function createSuperAccessInAsyncMethod(argumentExpression, flags, location) { - if (flags & 4096 /* AsyncMethodWithSuperBinding */) { - return ts.setTextRange(ts.createPropertyAccess(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), "value"), location); - } - else { - return ts.setTextRange(ts.createCall(ts.createIdentifier("_super"), - /*typeArguments*/ undefined, [argumentExpression]), location); - } - } - function getSuperContainerAsyncMethodFlags() { - return currentSuperContainer !== undefined - && resolver.getNodeCheckFlags(currentSuperContainer) & (2048 /* AsyncMethodWithSuper */ | 4096 /* AsyncMethodWithSuperBinding */); - } - } - ts.transformES2017 = transformES2017; - function createAwaiterHelper(context, hasLexicalArguments, promiseConstructor, body) { - context.requestEmitHelper(awaiterHelper); - var generatorFunc = ts.createFunctionExpression( - /*modifiers*/ undefined, ts.createToken(38 /* AsteriskToken */), - /*name*/ undefined, - /*typeParameters*/ undefined, - /*parameters*/ [], - /*type*/ undefined, body); - // Mark this node as originally an async function - (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 131072 /* AsyncFunctionBody */; - return ts.createCall(ts.getHelperName("__awaiter"), - /*typeArguments*/ undefined, [ - ts.createThis(), - hasLexicalArguments ? ts.createIdentifier("arguments") : ts.createVoidZero(), - promiseConstructor ? ts.createExpressionFromEntityName(promiseConstructor) : ts.createVoidZero(), - generatorFunc - ]); - } - var awaiterHelper = { - name: "typescript:awaiter", - scoped: false, - priority: 5, - text: "\n var __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 asyncSuperHelper = { - name: "typescript:async-super", - scoped: true, - text: "\n const _super = name => super[name];" - }; - var advancedAsyncSuperHelper = { - name: "typescript:advanced-async-super", - scoped: true, - text: "\n const _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);" - }; -})(ts || (ts = {})); -/// -/// -/*@internal*/ -var ts; (function (ts) { function transformES2016(context) { var hoistVariableDeclaration = context.hoistVariableDeclaration; @@ -50878,7 +53027,7 @@ var ts; return node; } switch (node.kind) { - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -50886,9 +53035,9 @@ var ts; } function visitBinaryExpression(node) { switch (node.operatorToken.kind) { - case 61 /* AsteriskAsteriskEqualsToken */: + case 62 /* AsteriskAsteriskEqualsToken */: return visitExponentiationAssignmentExpression(node); - case 39 /* AsteriskAsteriskToken */: + case 40 /* AsteriskAsteriskToken */: return visitExponentiationExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -50930,6 +53079,7 @@ var ts; })(ts || (ts = {})); /// /// +/// /*@internal*/ var ts; (function (ts) { @@ -51053,6 +53203,7 @@ var ts; })(HierarchyFacts || (HierarchyFacts = {})); function transformES2015(context) { var startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration; + var compilerOptions = context.getCompilerOptions(); var resolver = context.getEmitResolver(); var previousOnSubstituteNode = context.onSubstituteNode; var previousOnEmitNode = context.onEmitNode; @@ -51089,7 +53240,7 @@ var ts; * Sets the `HierarchyFacts` for this node prior to visiting this node's subtree, returning the facts set prior to modification. * @param excludeFacts The existing `HierarchyFacts` to reset before visiting the subtree. * @param includeFacts The new `HierarchyFacts` to set before visiting the subtree. - **/ + */ function enterSubtree(excludeFacts, includeFacts) { var ancestorFacts = hierarchyFacts; hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383 /* AncestorFactsMask */; @@ -51101,13 +53252,13 @@ var ts; * @param ancestorFacts The `HierarchyFacts` of the ancestor to restore after visiting the subtree. * @param excludeFacts The existing `HierarchyFacts` of the subtree that should not be propagated. * @param includeFacts The new `HierarchyFacts` of the subtree that should be propagated. - **/ + */ function exitSubtree(ancestorFacts, excludeFacts, includeFacts) { hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 /* SubtreeFactsMask */ | ancestorFacts; } function isReturnVoidStatementInConstructorWithCapturedSuper(node) { return hierarchyFacts & 4096 /* ConstructorWithCapturedSuper */ - && node.kind === 218 /* ReturnStatement */ + && node.kind === 219 /* ReturnStatement */ && !node.expression; } function shouldVisitNode(node) { @@ -51131,100 +53282,104 @@ var ts; return node; } function callExpressionVisitor(node) { - if (node.kind === 96 /* SuperKeyword */) { + if (node.kind === 97 /* SuperKeyword */) { return visitSuperKeyword(/*isExpressionOfCall*/ true); } return visitor(node); } function visitJavaScript(node) { switch (node.kind) { - case 114 /* StaticKeyword */: + case 115 /* StaticKeyword */: return undefined; // elide static keyword - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return visitClassDeclaration(node); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return visitClassExpression(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return visitParameter(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return visitArrowFunction(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return visitVariableDeclaration(node); - case 70 /* Identifier */: + case 71 /* Identifier */: return visitIdentifier(node); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return visitVariableDeclarationList(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return visitCaseBlock(node); - case 206 /* Block */: + case 207 /* Block */: return visitBlock(node, /*isFunctionBody*/ false); - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: return visitBreakOrContinueStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitLabeledStatement(node); - case 211 /* DoStatement */: - case 212 /* WhileStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: return visitDoOrWhileStatement(node, /*outermostLabeledStatement*/ undefined); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitForStatement(node, /*outermostLabeledStatement*/ undefined); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitForInStatement(node, /*outermostLabeledStatement*/ undefined); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return visitForOfStatement(node, /*outermostLabeledStatement*/ undefined); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return visitExpressionStatement(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return visitCatchClause(node); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return visitShorthandPropertyAssignment(node); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return visitComputedPropertyName(node); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return visitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return visitNewExpression(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return visitParenthesizedExpression(node, /*needsDestructuringValue*/ true); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node, /*needsDestructuringValue*/ true); - case 12 /* NoSubstitutionTemplateLiteral */: - case 13 /* TemplateHead */: - case 14 /* TemplateMiddle */: - case 15 /* TemplateTail */: + case 13 /* NoSubstitutionTemplateLiteral */: + case 14 /* TemplateHead */: + case 15 /* TemplateMiddle */: + case 16 /* TemplateTail */: return visitTemplateLiteral(node); - case 182 /* TaggedTemplateExpression */: + case 9 /* StringLiteral */: + return visitStringLiteral(node); + case 8 /* NumericLiteral */: + return visitNumericLiteral(node); + case 183 /* TaggedTemplateExpression */: return visitTaggedTemplateExpression(node); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return visitTemplateExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return visitYieldExpression(node); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return visitSpreadElement(node); - case 96 /* SuperKeyword */: + case 97 /* SuperKeyword */: return visitSuperKeyword(/*isExpressionOfCall*/ false); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return visitThisKeyword(node); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return visitMetaProperty(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return visitMethodDeclaration(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return visitAccessorDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitReturnStatement(node); default: return ts.visitEachChild(node, visitor, context); @@ -51234,8 +53389,9 @@ var ts; var ancestorFacts = enterSubtree(3968 /* SourceFileExcludes */, 64 /* SourceFileIncludes */); var statements = []; startLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ false, visitor); + var statementOffset = ts.addStandardPrologue(statements, node.statements, /*ensureUseStrict*/ false); addCaptureThisForNodeIfNeeded(statements, node); + statementOffset = ts.addCustomPrologue(statements, node.statements, statementOffset, visitor); ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset)); ts.addRange(statements, endLexicalEnvironment()); exitSubtree(ancestorFacts, 0 /* None */, 0 /* None */); @@ -51307,13 +53463,13 @@ var ts; // it is possible if either // - break/continue is 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 === 217 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; + var jump = node.kind === 218 /* BreakStatement */ ? 2 /* Break */ : 4 /* Continue */; var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(node.label.text)) || (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump)); if (!canUseBreakOrContinue) { var labelMarker = void 0; if (!node.label) { - if (node.kind === 217 /* BreakStatement */) { + if (node.kind === 218 /* BreakStatement */) { convertedLoopState.nonLocalJumps |= 2 /* Break */; labelMarker = "break"; } @@ -51324,7 +53480,7 @@ var ts; } } else { - if (node.kind === 217 /* BreakStatement */) { + if (node.kind === 218 /* BreakStatement */) { labelMarker = "break-" + node.label.text; setLabeledJump(convertedLoopState, /*isBreak*/ true, node.label.text, labelMarker); } @@ -51343,10 +53499,10 @@ var ts; expr = copyExpr; } else { - expr = ts.createBinary(expr, 25 /* CommaToken */, copyExpr); + expr = ts.createBinary(expr, 26 /* CommaToken */, copyExpr); } } - returnExpression = ts.createBinary(expr, 25 /* CommaToken */, returnExpression); + returnExpression = ts.createBinary(expr, 26 /* CommaToken */, returnExpression); } return ts.createReturn(returnExpression); } @@ -51386,10 +53542,10 @@ var ts; statements.push(exportStatement); } var emitFlags = ts.getEmitFlags(node); - if ((emitFlags & 2097152 /* HasEndOfDeclarationMarker */) === 0) { + if ((emitFlags & 4194304 /* HasEndOfDeclarationMarker */) === 0) { // Add a DeclarationMarker as a marker for the end of the declaration statements.push(ts.createEndOfDeclarationMarker(node)); - ts.setEmitFlags(statement, emitFlags | 2097152 /* HasEndOfDeclarationMarker */); + ts.setEmitFlags(statement, emitFlags | 4194304 /* HasEndOfDeclarationMarker */); } return ts.singleOrMany(statements); } @@ -51451,8 +53607,8 @@ var ts; // To preserve the behavior of the old emitter, we explicitly indent // the body of the function here if it was requested in an earlier // transformation. - if (ts.getEmitFlags(node) & 32768 /* Indented */) { - ts.setEmitFlags(classFunction, 32768 /* Indented */); + if (ts.getEmitFlags(node) & 65536 /* Indented */) { + ts.setEmitFlags(classFunction, 65536 /* Indented */); } // "inner" and "outer" below are added purely to preserve source map locations from // the old emitter @@ -51480,8 +53636,8 @@ var ts; addConstructor(statements, node, extendsClauseElement); addClassMembers(statements, node); // Create a synthetic text range for the return statement. - var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 17 /* CloseBraceToken */); - var localName = ts.getLocalName(node); + var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 18 /* CloseBraceToken */); + var localName = ts.getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. var outer = ts.createPartiallyEmittedExpression(localName); @@ -51525,7 +53681,7 @@ var ts; var constructorFunction = ts.createFunctionDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, - /*asteriskToken*/ undefined, ts.getDeclarationName(node), + /*asteriskToken*/ undefined, ts.getInternalName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper)); ts.setTextRange(constructorFunction, constructor || node); @@ -51572,17 +53728,20 @@ var ts; statementOffset = 0; } else if (constructor) { - // Otherwise, try to emit all potential prologue directives first. - statementOffset = ts.addPrologueDirectives(statements, constructor.body.statements, /*ensureUseStrict*/ false, visitor); + statementOffset = ts.addStandardPrologue(statements, constructor.body.statements, /*ensureUseStrict*/ false); } if (constructor) { addDefaultValueAssignmentsIfNeeded(statements, constructor); addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper); + if (!hasSynthesizedSuper) { + // If no super call has been synthesized, emit custom prologue directives. + statementOffset = ts.addCustomPrologue(statements, constructor.body.statements, statementOffset, visitor); + } ts.Debug.assert(statementOffset >= 0, "statementOffset not initialized correctly!"); } // determine whether the class is known syntactically to be a derived class (e.g. a // class that extends a value that is not syntactically known to be `null`). - var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 94 /* NullKeyword */; + var isDerivedClass = extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 95 /* NullKeyword */; var superCaptureStatus = declareOrCaptureOrReturnThisForConstructorIfNeeded(statements, constructor, isDerivedClass, hasSynthesizedSuper, statementOffset); // The last statement expression was replaced. Skip it. if (superCaptureStatus === 1 /* ReplaceSuperCapture */ || superCaptureStatus === 2 /* ReplaceWithReturn */) { @@ -51621,17 +53780,17 @@ var ts; */ function isSufficientlyCoveredByReturnStatements(statement) { // A return statement is considered covered. - if (statement.kind === 218 /* ReturnStatement */) { + if (statement.kind === 219 /* ReturnStatement */) { return true; } - else if (statement.kind === 210 /* IfStatement */) { + else if (statement.kind === 211 /* IfStatement */) { var ifStatement = statement; if (ifStatement.elseStatement) { return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) && isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement); } } - else if (statement.kind === 206 /* Block */) { + else if (statement.kind === 207 /* Block */) { var lastStatement = ts.lastOrUndefined(statement.statements); if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) { return true; @@ -51689,7 +53848,7 @@ var ts; var ctorStatements = ctor.body.statements; if (statementOffset < ctorStatements.length) { firstStatement = ctorStatements[statementOffset]; - if (firstStatement.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { + if (firstStatement.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(firstStatement.expression)) { superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression); } } @@ -51699,8 +53858,8 @@ var ts; && statementOffset === ctorStatements.length - 1 && !(ctor.transformFlags & (16384 /* ContainsLexicalThis */ | 32768 /* ContainsCapturedLexicalThis */))) { var returnStatement = ts.createReturn(superCallExpression); - if (superCallExpression.kind !== 193 /* BinaryExpression */ - || superCallExpression.left.kind !== 180 /* CallExpression */) { + if (superCallExpression.kind !== 194 /* BinaryExpression */ + || superCallExpression.left.kind !== 181 /* CallExpression */) { ts.Debug.fail("Assumed generated super call would have form 'super.call(...) || this'."); } // Shift comments from the original super call to the return statement. @@ -51812,10 +53971,10 @@ var ts; // of an initializer, we must emit that expression to preserve side effects. if (name.elements.length > 0) { statements.push(ts.setEmitFlags(ts.createVariableStatement( - /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 524288 /* CustomPrologue */)); + /*modifiers*/ undefined, ts.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, temp))), 1048576 /* CustomPrologue */)); } else if (initializer) { - statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 524288 /* CustomPrologue */)); + statements.push(ts.setEmitFlags(ts.createStatement(ts.createAssignment(temp, ts.visitNode(initializer, visitor, ts.isExpression))), 1048576 /* CustomPrologue */)); } } /** @@ -51833,7 +53992,7 @@ var ts; ]), parameter), 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */)); statement.startsOnNewLine = true; ts.setTextRange(statement, parameter); - ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 524288 /* CustomPrologue */); + ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */); statements.push(statement); } /** @@ -51845,7 +54004,7 @@ var ts; * synthesized call to `super` */ function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) { - return node && node.dotDotDotToken && node.name.kind === 70 /* Identifier */ && !inConstructorWithSynthesizedSuper; + return node && node.dotDotDotToken && node.name.kind === 71 /* Identifier */ && !inConstructorWithSynthesizedSuper; } /** * Adds statements to the body of a function-like node if it contains a rest parameter. @@ -51874,7 +54033,7 @@ var ts; ts.createVariableDeclaration(declarationName, /*type*/ undefined, ts.createArrayLiteral([])) ])), - /*location*/ parameter), 524288 /* CustomPrologue */)); + /*location*/ parameter), 1048576 /* CustomPrologue */)); // for (var _i = restIndex; _i < arguments.length; _i++) { // param[_i - restIndex] = arguments[_i]; // } @@ -51886,7 +54045,7 @@ var ts; : ts.createSubtract(temp, ts.createLiteral(restIndex))), ts.createElementAccess(ts.createIdentifier("arguments"), temp))), /*location*/ parameter)) ])); - ts.setEmitFlags(forStatement, 524288 /* CustomPrologue */); + ts.setEmitFlags(forStatement, 1048576 /* CustomPrologue */); ts.startOnNewLine(forStatement); statements.push(forStatement); } @@ -51897,7 +54056,7 @@ var ts; * @param node A node. */ function addCaptureThisForNodeIfNeeded(statements, node) { - if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 186 /* ArrowFunction */) { + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */ && node.kind !== 187 /* ArrowFunction */) { captureThisForNode(statements, node, ts.createThis()); } } @@ -51908,7 +54067,7 @@ var ts; ts.createVariableDeclaration("_this", /*type*/ undefined, initializer) ])); - ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 524288 /* CustomPrologue */); + ts.setEmitFlags(captureThisStatement, 1536 /* NoComments */ | 1048576 /* CustomPrologue */); ts.setTextRange(captureThisStatement, originalStatement); ts.setSourceMapRange(captureThisStatement, node); statements.push(captureThisStatement); @@ -51917,25 +54076,25 @@ var ts; if (hierarchyFacts & 16384 /* NewTarget */) { var newTarget = void 0; switch (node.kind) { - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return statements; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: // Methods and accessors cannot be constructors, so 'new.target' will // always return 'undefined'. newTarget = ts.createVoidZero(); break; - case 151 /* Constructor */: + case 152 /* Constructor */: // Class constructors can only be called with `new`, so `this.constructor` // should be relatively safe to use. newTarget = ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"); break; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: // Functions can be called or constructed, and may have a `this` due to // being a member or when calling an imported function via `other_1.f()`. - newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 92 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); + newTarget = ts.createConditional(ts.createLogicalAnd(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), ts.createBinary(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), 93 /* InstanceOfKeyword */, ts.getLocalName(node))), ts.createPropertyAccess(ts.setEmitFlags(ts.createThis(), 4 /* NoSubstitution */), "constructor"), ts.createVoidZero()); break; default: ts.Debug.failBadSyntaxKind(node); @@ -51964,20 +54123,20 @@ var ts; for (var _i = 0, _a = node.members; _i < _a.length; _i++) { var member = _a[_i]; switch (member.kind) { - case 205 /* SemicolonClassElement */: + case 206 /* SemicolonClassElement */: statements.push(transformSemicolonClassElementToStatement(member)); break; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node)); break; - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.members, member); if (member === accessors.firstAccessor) { statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node)); } break; - case 151 /* Constructor */: + case 152 /* Constructor */: // Constructors are handled in visitClassExpression/visitClassDeclaration break; default: @@ -52112,7 +54271,7 @@ var ts; * @param node a FunctionExpression node. */ function visitFunctionExpression(node) { - var ancestorFacts = ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */ + var ancestorFacts = ts.getEmitFlags(node) & 262144 /* AsyncFunctionBody */ ? enterSubtree(16278 /* AsyncFunctionBodyExcludes */, 69 /* AsyncFunctionBodyIncludes */) : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var savedConvertedLoopState = convertedLoopState; @@ -52127,7 +54286,7 @@ var ts; exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return ts.updateFunctionExpression(node, - /*modifiers*/ undefined, name, + /*modifiers*/ undefined, node.asteriskToken, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -52150,7 +54309,7 @@ var ts; exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return ts.updateFunctionDeclaration(node, - /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), name, + /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, /*typeParameters*/ undefined, parameters, /*type*/ undefined, body); } @@ -52169,7 +54328,7 @@ var ts; : enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); var parameters = ts.visitParameterList(node.parameters, visitor, context); var body = transformFunctionBody(node); - if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 227 /* FunctionDeclaration */ || node.kind === 185 /* FunctionExpression */)) { + if (hierarchyFacts & 16384 /* NewTarget */ && !name && (node.kind === 228 /* FunctionDeclaration */ || node.kind === 186 /* FunctionExpression */)) { name = ts.getGeneratedNameForNode(node); } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); @@ -52196,8 +54355,8 @@ var ts; resumeLexicalEnvironment(); if (ts.isBlock(body)) { // ensureUseStrict is false because no new prologue-directive should be added. - // addPrologueDirectives will simply put already-existing directives at the beginning of the target statement-array - statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + // addStandardPrologue will put already-existing directives at the beginning of the target statement-array + statementOffset = ts.addStandardPrologue(statements, body.statements, /*ensureUseStrict*/ false); } addCaptureThisForNodeIfNeeded(statements, node); addDefaultValueAssignmentsIfNeeded(statements, node); @@ -52207,6 +54366,8 @@ var ts; multiLine = true; } if (ts.isBlock(body)) { + // addCustomPrologue puts already-existing directives at the beginning of the target statement-array + statementOffset = ts.addCustomPrologue(statements, body.statements, statementOffset, visitor); statementsLocation = body.statements; ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset)); // If the original body was a multi-line block, this must be a multi-line block. @@ -52215,7 +54376,7 @@ var ts; } } else { - ts.Debug.assert(node.kind === 186 /* ArrowFunction */); + ts.Debug.assert(node.kind === 187 /* ArrowFunction */); // To align with the old emitter, we use a synthetic end position on the location // for the statement list we synthesize when we down-level an arrow function with // an expression function body. This prevents both comments and source maps from @@ -52252,7 +54413,7 @@ var ts; ts.setEmitFlags(block, 1 /* SingleLine */); } if (closeBraceLocation) { - ts.setTokenSourceMapRange(block, 17 /* CloseBraceToken */, closeBraceLocation); + ts.setTokenSourceMapRange(block, 18 /* CloseBraceToken */, closeBraceLocation); } ts.setOriginalNode(block, node.body); return block; @@ -52282,9 +54443,9 @@ var ts; function visitExpressionStatement(node) { // If we are here it is most likely because our expression is a destructuring assignment. switch (node.expression.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return ts.updateStatement(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return ts.updateStatement(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } return ts.visitEachChild(node, visitor, context); @@ -52299,10 +54460,13 @@ var ts; function visitParenthesizedExpression(node, needsDestructuringValue) { // If we are here it is most likely because our expression is a destructuring assignment. if (!needsDestructuringValue) { + // By default we always emit the RHS at the end of a flattened destructuring + // expression. If we are in a state where we do not need the destructuring value, + // we pass that information along to the children that care about it. switch (node.expression.kind) { - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return ts.updateParen(node, visitParenthesizedExpression(node.expression, /*needsDestructuringValue*/ false)); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return ts.updateParen(node, visitBinaryExpression(node.expression, /*needsDestructuringValue*/ false)); } } @@ -52337,13 +54501,13 @@ var ts; assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0 /* All */); } else { - assignment = ts.createBinary(decl.name, 57 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); + assignment = ts.createBinary(decl.name, 58 /* EqualsToken */, ts.visitNode(decl.initializer, visitor, ts.isExpression)); } - (assignments || (assignments = [])).push(assignment); + assignments = ts.append(assignments, assignment); } } if (assignments) { - updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 25 /* CommaToken */, acc); })), node); + updated = ts.setTextRange(ts.createStatement(ts.reduceLeft(assignments, function (acc, v) { return ts.createBinary(v, 26 /* CommaToken */, acc); })), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -52495,11 +54659,24 @@ var ts; if (convertedLoopState && !convertedLoopState.labels) { convertedLoopState.labels = ts.createMap(); } - var statement = ts.unwrapInnermostStatmentOfLabel(node, convertedLoopState && recordLabel); - return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) && shouldConvertIterationStatementBody(statement) + var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel); + return ts.isIterationStatement(statement, /*lookInLabeledStatements*/ false) ? visitIterationStatement(statement, /*outermostLabeledStatement*/ node) : ts.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement), node, convertedLoopState && resetLabel); } + function visitIterationStatement(node, outermostLabeledStatement) { + switch (node.kind) { + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + return visitDoOrWhileStatement(node, outermostLabeledStatement); + case 214 /* ForStatement */: + return visitForStatement(node, outermostLabeledStatement); + case 215 /* ForInStatement */: + return visitForInStatement(node, outermostLabeledStatement); + case 216 /* ForOfStatement */: + return visitForOfStatement(node, outermostLabeledStatement); + } + } function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) { var ancestorFacts = enterSubtree(excludeFacts, includeFacts); var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, convert); @@ -52516,9 +54693,74 @@ var ts; return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement); } function visitForOfStatement(node, outermostLabeledStatement) { - return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, convertForOfToFor); + return visitIterationStatementWithFacts(1984 /* ForInOrForOfStatementExcludes */, 2304 /* ForInOrForOfStatementIncludes */, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray); } - function convertForOfToFor(node, outermostLabeledStatement, convertedLoopBodyStatements) { + function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) { + var statements = []; + if (ts.isVariableDeclarationList(node.initializer)) { + if (node.initializer.flags & 3 /* BlockScoped */) { + enableSubstitutionsForBlockScopedBindings(); + } + var firstOriginalDeclaration = ts.firstOrUndefined(node.initializer.declarations); + if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { + // This works whether the declaration is a var, let, or const. + // It will use rhsIterationValue _a[_i] as the initializer. + var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, boundValue); + var declarationList = ts.setTextRange(ts.createVariableDeclarationList(declarations), node.initializer); + ts.setOriginalNode(declarationList, node.initializer); + // Adjust the source map range for the first declaration to align with the old + // emitter. + var firstDeclaration = declarations[0]; + var lastDeclaration = ts.lastOrUndefined(declarations); + ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); + statements.push(ts.createVariableStatement( + /*modifiers*/ undefined, declarationList)); + } + else { + // The following call does not include the initializer, so we have + // to emit it separately. + statements.push(ts.setTextRange(ts.createVariableStatement( + /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ + ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), + /*type*/ undefined, boundValue) + ]), ts.moveRangePos(node.initializer, -1)), node.initializer)), ts.moveRangeEnd(node.initializer, -1))); + } + } + else { + // Initializer is an expression. Emit the expression in the body, so that it's + // evaluated on every iteration. + var assignment = ts.createAssignment(node.initializer, boundValue); + if (ts.isDestructuringAssignment(assignment)) { + ts.aggregateTransformFlags(assignment); + statements.push(ts.createStatement(visitBinaryExpression(assignment, /*needsDestructuringValue*/ false))); + } + else { + assignment.end = node.initializer.end; + statements.push(ts.setTextRange(ts.createStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(node.initializer, -1))); + } + } + var bodyLocation; + var statementsLocation; + if (convertedLoopBodyStatements) { + ts.addRange(statements, convertedLoopBodyStatements); + } + else { + var statement = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); + if (ts.isBlock(statement)) { + ts.addRange(statements, statement.statements); + bodyLocation = statement; + statementsLocation = statement.statements; + } + else { + statements.push(statement); + } + } + // The old emitter does not emit source maps for the block. + // We add the location to preserve comments. + return ts.setEmitFlags(ts.setTextRange(ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), statementsLocation), + /*multiLine*/ true), bodyLocation), 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); + } + function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) { // The following ES6 code: // // for (let v of expr) { } @@ -52540,109 +54782,65 @@ var ts; // Note also that because an extra statement is needed to assign to the LHS, // for-of bodies are always emitted as blocks. var expression = ts.visitNode(node.expression, visitor, ts.isExpression); - var initializer = node.initializer; - var statements = []; // In the case where the user wrote an identifier as the RHS, like this: // // for (let v of arr) { } // // we don't want to emit a temporary variable for the RHS, just use it directly. var counter = ts.createLoopVariable(); - var rhsReference = expression.kind === 70 /* Identifier */ - ? ts.createUniqueName(ts.unescapeIdentifier(expression.text)) - : ts.createTempVariable(/*recordTempVariable*/ undefined); - var elementAccess = ts.createElementAccess(rhsReference, counter); - // Initialize LHS - // var v = _a[_i]; - if (ts.isVariableDeclarationList(initializer)) { - if (initializer.flags & 3 /* BlockScoped */) { - enableSubstitutionsForBlockScopedBindings(); - } - var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations); - if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) { - // This works whether the declaration is a var, let, or const. - // It will use rhsIterationValue _a[_i] as the initializer. - var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0 /* All */, elementAccess); - var declarationList = ts.createVariableDeclarationList(declarations); - ts.setOriginalNode(declarationList, initializer); - ts.setTextRange(declarationList, initializer); - // Adjust the source map range for the first declaration to align with the old - // emitter. - var firstDeclaration = declarations[0]; - var lastDeclaration = ts.lastOrUndefined(declarations); - ts.setSourceMapRange(declarationList, ts.createRange(firstDeclaration.pos, lastDeclaration.end)); - statements.push(ts.createVariableStatement( - /*modifiers*/ undefined, declarationList)); - } - else { - // The following call does not include the initializer, so we have - // to emit it separately. - statements.push(ts.setTextRange(ts.createVariableStatement( - /*modifiers*/ undefined, ts.setOriginalNode(ts.setTextRange(ts.createVariableDeclarationList([ - ts.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : ts.createTempVariable(/*recordTempVariable*/ undefined), - /*type*/ undefined, ts.createElementAccess(rhsReference, counter)) - ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1))); - } - } - else { - // Initializer is an expression. Emit the expression in the body, so that it's - // evaluated on every iteration. - var assignment = ts.createAssignment(initializer, elementAccess); - if (ts.isDestructuringAssignment(assignment)) { - // This is a destructuring pattern, so we flatten the destructuring instead. - statements.push(ts.createStatement(ts.flattenDestructuringAssignment(assignment, visitor, context, 0 /* All */))); - } - else { - // Currently there is not way to check that assignment is binary expression of destructing assignment - // so we have to cast never type to binaryExpression - assignment.end = initializer.end; - statements.push(ts.setTextRange(ts.createStatement(assignment), ts.moveRangeEnd(initializer, -1))); - } - } - var bodyLocation; - var statementsLocation; - if (convertedLoopBodyStatements) { - ts.addRange(statements, convertedLoopBodyStatements); - } - else { - var statement = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); - if (ts.isBlock(statement)) { - ts.addRange(statements, statement.statements); - bodyLocation = statement; - statementsLocation = statement.statements; - } - else { - statements.push(statement); - } - } + var rhsReference = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); // The old emitter does not emit source maps for the expression ts.setEmitFlags(expression, 48 /* NoSourceMap */ | ts.getEmitFlags(expression)); - // The old emitter does not emit source maps for the block. - // We add the location to preserve comments. - var body = ts.createBlock(ts.setTextRange(ts.createNodeArray(statements), /*location*/ statementsLocation)); - ts.setTextRange(body, bodyLocation); - ts.setEmitFlags(body, 48 /* NoSourceMap */ | 384 /* NoTokenSourceMaps */); - var forStatement = ts.createFor(ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + var forStatement = ts.setTextRange(ts.createFor( + /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ ts.setTextRange(ts.createVariableDeclaration(counter, /*type*/ undefined, ts.createLiteral(0)), ts.moveRangePos(node.expression, -1)), ts.setTextRange(ts.createVariableDeclaration(rhsReference, /*type*/ undefined, expression), node.expression) - ]), node.expression), 1048576 /* NoHoisting */), ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), body); + ]), node.expression), 2097152 /* NoHoisting */), + /*condition*/ ts.setTextRange(ts.createLessThan(counter, ts.createPropertyAccess(rhsReference, "length")), node.expression), + /*incrementor*/ ts.setTextRange(ts.createPostfixIncrement(counter), node.expression), + /*statement*/ convertForOfStatementHead(node, ts.createElementAccess(rhsReference, counter), convertedLoopBodyStatements)), + /*location*/ node); // Disable trailing source maps for the OpenParenToken to align source map emit with the old emitter. ts.setEmitFlags(forStatement, 256 /* NoTokenTrailingSourceMaps */); ts.setTextRange(forStatement, node); return ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel); } - function visitIterationStatement(node, outermostLabeledStatement) { - switch (node.kind) { - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - return visitDoOrWhileStatement(node, outermostLabeledStatement); - case 213 /* ForStatement */: - return visitForStatement(node, outermostLabeledStatement); - case 214 /* ForInStatement */: - return visitForInStatement(node, outermostLabeledStatement); - case 215 /* ForOfStatement */: - return visitForOfStatement(node, outermostLabeledStatement); - } + function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements) { + var expression = ts.visitNode(node.expression, visitor, ts.isExpression); + var iterator = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(expression) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var result = ts.isIdentifier(expression) ? ts.getGeneratedNameForNode(iterator) : ts.createTempVariable(/*recordTempVariable*/ undefined); + var errorRecord = ts.createUniqueName("e"); + var catchVariable = ts.getGeneratedNameForNode(errorRecord); + var returnMethod = ts.createTempVariable(/*recordTempVariable*/ undefined); + var values = ts.createValuesHelper(context, expression, node.expression); + var next = ts.createCall(ts.createPropertyAccess(iterator, "next"), /*typeArguments*/ undefined, []); + hoistVariableDeclaration(errorRecord); + hoistVariableDeclaration(returnMethod); + var forStatement = ts.setEmitFlags(ts.setTextRange(ts.createFor( + /*initializer*/ ts.setEmitFlags(ts.setTextRange(ts.createVariableDeclarationList([ + ts.setTextRange(ts.createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), + ts.createVariableDeclaration(result, /*type*/ undefined, next) + ]), node.expression), 2097152 /* NoHoisting */), + /*condition*/ ts.createLogicalNot(ts.createPropertyAccess(result, "done")), + /*incrementor*/ ts.createAssignment(result, next), + /*statement*/ convertForOfStatementHead(node, ts.createPropertyAccess(result, "value"), convertedLoopBodyStatements)), + /*location*/ node), 256 /* NoTokenTrailingSourceMaps */); + return ts.createTry(ts.createBlock([ + ts.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel) + ]), ts.createCatchClause(ts.createVariableDeclaration(catchVariable), ts.setEmitFlags(ts.createBlock([ + ts.createStatement(ts.createAssignment(errorRecord, ts.createObjectLiteral([ + ts.createPropertyAssignment("error", catchVariable) + ]))) + ]), 1 /* SingleLine */)), ts.createBlock([ + ts.createTry( + /*tryBlock*/ ts.createBlock([ + ts.setEmitFlags(ts.createIf(ts.createLogicalAnd(ts.createLogicalAnd(result, ts.createLogicalNot(ts.createPropertyAccess(result, "done"))), ts.createAssignment(returnMethod, ts.createPropertyAccess(iterator, "return"))), ts.createStatement(ts.createFunctionCall(returnMethod, iterator, []))), 1 /* SingleLine */), + ]), + /*catchClause*/ undefined, + /*finallyBlock*/ ts.setEmitFlags(ts.createBlock([ + ts.setEmitFlags(ts.createIf(errorRecord, ts.createThrow(ts.createPropertyAccess(errorRecord, "error"))), 1 /* SingleLine */) + ]), 1 /* SingleLine */)) + ])); } /** * Visits an ObjectLiteralExpression with computed propety names. @@ -52663,7 +54861,7 @@ var ts; && i < numInitialPropertiesWithoutYield) { numInitialPropertiesWithoutYield = i; } - if (property.name.kind === 143 /* ComputedPropertyName */) { + if (property.name.kind === 144 /* ComputedPropertyName */) { numInitialProperties = i; break; } @@ -52677,7 +54875,7 @@ var ts; var temp = ts.createTempVariable(hoistVariableDeclaration); // Write out the first non-computed properties, then emit the rest through indexing on the temp variable. var expressions = []; - var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 32768 /* Indented */)); + var assignment = ts.createAssignment(temp, ts.setEmitFlags(ts.createObjectLiteral(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), 65536 /* Indented */)); if (node.multiLine) { assignment.startsOnNewLine = true; } @@ -52702,7 +54900,7 @@ var ts; } visit(node.name); function visit(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { state.hoistedLocalVariables.push(node); } else { @@ -52735,11 +54933,11 @@ var ts; var functionName = ts.createUniqueName("_loop"); var loopInitializer; switch (node.kind) { - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: var initializer = node.initializer; - if (initializer && initializer.kind === 226 /* VariableDeclarationList */) { + if (initializer && initializer.kind === 227 /* VariableDeclarationList */) { loopInitializer = initializer; } break; @@ -52776,7 +54974,7 @@ var ts; } } startLexicalEnvironment(); - var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock); + var loopBody = ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock); var lexicalEnvironment = endLexicalEnvironment(); var currentState = convertedLoopState; convertedLoopState = outerConvertedLoopState; @@ -52794,24 +54992,24 @@ var ts; else { loopBody = ts.createBlock([loopBody], /*multiline*/ true); } - var isAsyncBlockContainingAwait = hierarchyFacts & 4 /* AsyncFunctionBody */ - && (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var containsYield = (node.statement.transformFlags & 16777216 /* ContainsYield */) !== 0; + var isAsyncBlockContainingAwait = containsYield && (hierarchyFacts & 4 /* AsyncFunctionBody */) !== 0; var loopBodyFlags = 0; if (currentState.containsLexicalThis) { loopBodyFlags |= 8 /* CapturesThis */; } if (isAsyncBlockContainingAwait) { - loopBodyFlags |= 131072 /* AsyncFunctionBody */; + loopBodyFlags |= 262144 /* AsyncFunctionBody */; } var convertedLoopVariable = ts.createVariableStatement( /*modifiers*/ undefined, ts.setEmitFlags(ts.createVariableDeclarationList([ ts.createVariableDeclaration(functionName, /*type*/ undefined, ts.setEmitFlags(ts.createFunctionExpression( - /*modifiers*/ undefined, isAsyncBlockContainingAwait ? ts.createToken(38 /* AsteriskToken */) : undefined, + /*modifiers*/ undefined, containsYield ? ts.createToken(39 /* AsteriskToken */) : undefined, /*name*/ undefined, /*typeParameters*/ undefined, loopParameters, /*type*/ undefined, loopBody), loopBodyFlags)) - ]), 1048576 /* NoHoisting */)); + ]), 2097152 /* NoHoisting */)); var statements = [convertedLoopVariable]; var extraVariableDeclarations; // propagate state from the inner loop to the outer loop if necessary @@ -52874,7 +55072,7 @@ var ts; statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList(extraVariableDeclarations))); } - var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, isAsyncBlockContainingAwait); + var convertedLoopBodyStatements = generateCallToConvertedLoop(functionName, loopParameters, currentState, containsYield); var loop; if (convert) { loop = convert(node, outermostLabeledStatement, convertedLoopBodyStatements); @@ -52898,7 +55096,7 @@ var ts; function copyOutParameter(outParam, copyDirection) { var source = copyDirection === 0 /* ToOriginal */ ? outParam.outParamName : outParam.originalName; var target = copyDirection === 0 /* ToOriginal */ ? outParam.originalName : outParam.outParamName; - return ts.createBinary(target, 57 /* EqualsToken */, source); + return ts.createBinary(target, 58 /* EqualsToken */, source); } function copyOutParameters(outParams, copyDirection, statements) { for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) { @@ -52916,7 +55114,9 @@ var ts; !state.labeledNonLocalBreaks && !state.labeledNonLocalContinues; var call = ts.createCall(loopFunctionExpressionName, /*typeArguments*/ undefined, ts.map(parameters, function (p) { return p.name; })); - var callResult = isAsyncBlockContainingAwait ? ts.createYield(ts.createToken(38 /* AsteriskToken */), call) : call; + var callResult = isAsyncBlockContainingAwait + ? ts.createYield(ts.createToken(39 /* AsteriskToken */), ts.setEmitFlags(call, 8388608 /* Iterator */)) + : call; if (isSimpleLoop) { statements.push(ts.createStatement(callResult)); copyOutParameters(state.loopOutParameters, 0 /* ToOriginal */, statements); @@ -52936,10 +55136,10 @@ var ts; else { returnStatement = ts.createReturn(ts.createPropertyAccess(loopResultName, "value")); } - statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); + statements.push(ts.createIf(ts.createBinary(ts.createTypeOf(loopResultName), 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("object")), returnStatement)); } if (state.nonLocalJumps & 2 /* Break */) { - statements.push(ts.createIf(ts.createBinary(loopResultName, 33 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); + statements.push(ts.createIf(ts.createBinary(loopResultName, 34 /* EqualsEqualsEqualsToken */, ts.createLiteral("break")), ts.createBreak())); } if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) { var caseClauses = []; @@ -53017,20 +55217,20 @@ var ts; for (var i = start; i < numProperties; i++) { var property = properties[i]; switch (property.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: var accessors = ts.getAllAccessorDeclarations(node.properties, property); if (property === accessors.firstAccessor) { expressions.push(transformAccessorsToExpression(receiver, accessors, node, node.multiLine)); } break; - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine)); break; - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine)); break; default: @@ -53090,7 +55290,7 @@ var ts; var ancestorFacts = enterSubtree(4032 /* BlockScopeExcludes */, 0 /* BlockScopeIncludes */); var updated; if (ts.isBindingPattern(node.variableDeclaration.name)) { - var temp = ts.createTempVariable(undefined); + var temp = ts.createTempVariable(/*recordTempVariable*/ undefined); var newVariableDeclaration = ts.createVariableDeclaration(temp); ts.setTextRange(newVariableDeclaration, node.variableDeclaration); var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0 /* All */, temp); @@ -53135,7 +55335,20 @@ var ts; var savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; var ancestorFacts = enterSubtree(16286 /* FunctionExcludes */, 65 /* FunctionIncludes */); - var updated = ts.visitEachChild(node, visitor, context); + var updated; + if (node.transformFlags & 32768 /* ContainsCapturedLexicalThis */) { + var parameters = ts.visitParameterList(node.parameters, visitor, context); + var body = transformFunctionBody(node); + if (node.kind === 153 /* GetAccessor */) { + updated = ts.updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + } + else { + updated = ts.updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body); + } + } + else { + updated = ts.visitEachChild(node, visitor, context); + } exitSubtree(ancestorFacts, 49152 /* PropagateNewTargetMask */, 0 /* None */); convertedLoopState = savedConvertedLoopState; return updated; @@ -53195,7 +55408,7 @@ var ts; // We are here either because SuperKeyword was used somewhere in the expression, or // because we contain a SpreadElementExpression. var _a = ts.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg; - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { ts.setEmitFlags(thisArg, 4 /* NoSubstitution */); } var resultingCall; @@ -53228,7 +55441,7 @@ var ts; resultingCall = ts.createFunctionCall(ts.visitNode(target, callExpressionVisitor, ts.isExpression), ts.visitNode(thisArg, visitor, ts.isExpression), ts.visitNodes(node.arguments, visitor, ts.isExpression), /*location*/ node); } - if (node.expression.kind === 96 /* SuperKeyword */) { + if (node.expression.kind === 97 /* SuperKeyword */) { var actualThis = ts.createThis(); ts.setEmitFlags(actualThis, 4 /* NoSubstitution */); var initializer = ts.createLogicalOr(resultingCall, actualThis); @@ -53276,14 +55489,28 @@ var ts; var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) { return visitPartition(partition, multiLine, hasTrailingComma && end === numElements); })); - if (segments.length === 1) { - var firstElement = elements[0]; - return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 176 /* ArrayLiteralExpression */ - ? ts.createArraySlice(segments[0]) - : segments[0]; + if (compilerOptions.downlevelIteration) { + if (segments.length === 1) { + var firstSegment = segments[0]; + if (ts.isCallExpression(firstSegment) + && ts.isIdentifier(firstSegment.expression) + && (ts.getEmitFlags(firstSegment.expression) & 4096 /* HelperName */) + && firstSegment.expression.text === "___spread") { + return segments[0]; + } + } + return ts.createSpreadHelper(context, segments); + } + else { + if (segments.length === 1) { + var firstElement = elements[0]; + return needsUniqueCopy && ts.isSpreadExpression(firstElement) && firstElement.expression.kind !== 177 /* ArrayLiteralExpression */ + ? ts.createArraySlice(segments[0]) + : segments[0]; + } + // Rewrite using the pattern .concat(, , ...) + return ts.createArrayConcat(segments.shift(), segments); } - // Rewrite using the pattern .concat(, , ...) - return ts.createArrayConcat(segments.shift(), segments); } function partitionSpread(node) { return ts.isSpreadExpression(node) @@ -53315,6 +55542,28 @@ var ts; function visitTemplateLiteral(node) { return ts.setTextRange(ts.createLiteral(node.text), node); } + /** + * Visits a string literal with an extended unicode escape. + * + * @param node A string literal. + */ + function visitStringLiteral(node) { + if (node.hasExtendedUnicodeEscape) { + return ts.setTextRange(ts.createLiteral(node.text), node); + } + return node; + } + /** + * Visits a binary or octal (ES6) numeric literal. + * + * @param node A string literal. + */ + function visitNumericLiteral(node) { + if (node.numericLiteralFlags & 48 /* BinaryOrOctalSpecifier */) { + return ts.setTextRange(ts.createNumericLiteral(node.text), node); + } + return node; + } /** * Visits a TaggedTemplateExpression node. * @@ -53367,7 +55616,7 @@ var ts; // thus we need to remove those characters. // First template piece starts with "`", others with "}" // Last template piece ends with "`", others with "${" - var isLast = node.kind === 12 /* NoSubstitutionTemplateLiteral */ || node.kind === 15 /* TemplateTail */; + var isLast = node.kind === 13 /* NoSubstitutionTemplateLiteral */ || node.kind === 16 /* TemplateTail */; text = text.substring(1, text.length - (isLast ? 1 : 2)); // Newline normalization: // ES6 Spec 11.8.6.1 - Static Semantics of TV's and TRV's @@ -53465,7 +55714,7 @@ var ts; : ts.createIdentifier("_super"); } function visitMetaProperty(node) { - if (node.keywordToken === 93 /* NewKeyword */ && node.name.text === "target") { + if (node.keywordToken === 94 /* NewKeyword */ && node.name.text === "target") { if (hierarchyFacts & 8192 /* ComputedPropertyName */) { hierarchyFacts |= 32768 /* NewTargetInComputedPropertyName */; } @@ -53502,7 +55751,7 @@ var ts; function enableSubstitutionsForBlockScopedBindings() { if ((enabledSubstitutions & 2 /* BlockScopedBindings */) === 0) { enabledSubstitutions |= 2 /* BlockScopedBindings */; - context.enableSubstitution(70 /* Identifier */); + context.enableSubstitution(71 /* Identifier */); } } /** @@ -53512,14 +55761,14 @@ var ts; function enableSubstitutionsForCapturedThis() { if ((enabledSubstitutions & 1 /* CapturedThis */) === 0) { enabledSubstitutions |= 1 /* CapturedThis */; - context.enableSubstitution(98 /* ThisKeyword */); - context.enableEmitNotification(151 /* Constructor */); - context.enableEmitNotification(150 /* MethodDeclaration */); - context.enableEmitNotification(152 /* GetAccessor */); - context.enableEmitNotification(153 /* SetAccessor */); - context.enableEmitNotification(186 /* ArrowFunction */); - context.enableEmitNotification(185 /* FunctionExpression */); - context.enableEmitNotification(227 /* FunctionDeclaration */); + context.enableSubstitution(99 /* ThisKeyword */); + context.enableEmitNotification(152 /* Constructor */); + context.enableEmitNotification(151 /* MethodDeclaration */); + context.enableEmitNotification(153 /* GetAccessor */); + context.enableEmitNotification(154 /* SetAccessor */); + context.enableEmitNotification(187 /* ArrowFunction */); + context.enableEmitNotification(186 /* FunctionExpression */); + context.enableEmitNotification(228 /* FunctionDeclaration */); } } /** @@ -53544,10 +55793,10 @@ var ts; function substituteIdentifier(node) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { var original = ts.getParseTreeNode(node, ts.isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { - return ts.getGeneratedNameForNode(original); + return ts.setTextRange(ts.getGeneratedNameForNode(original), node); } } return node; @@ -53561,10 +55810,10 @@ var ts; function isNameOfDeclarationWithCollidingName(node) { var parent = node.parent; switch (parent.kind) { - case 175 /* BindingElement */: - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 226 /* VariableDeclaration */: return parent.name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -53577,9 +55826,9 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: return substituteThisKeyword(node); } return node; @@ -53590,14 +55839,39 @@ var ts; * @param node An Identifier node. */ function substituteExpressionIdentifier(node) { - if (enabledSubstitutions & 2 /* BlockScopedBindings */) { + if (enabledSubstitutions & 2 /* BlockScopedBindings */ && !ts.isInternalName(node)) { var declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return ts.getGeneratedNameForNode(declaration.name); + if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) { + return ts.setTextRange(ts.getGeneratedNameForNode(declaration.name), node); } } return node; } + function isPartOfClassBody(declaration, node) { + var currentNode = ts.getParseTreeNode(node); + if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) { + // if the node has no correlation to a parse tree node, its definitely not + // part of the body. + // if the node is outside of the document range of the declaration, its + // definitely not part of the body. + return false; + } + var blockScope = ts.getEnclosingBlockScopeContainer(declaration); + while (currentNode) { + if (currentNode === blockScope || currentNode === declaration) { + // if we are in the enclosing block scope of the declaration, we are definitely + // not inside the class body. + return false; + } + if (ts.isClassElement(currentNode) && currentNode.parent === declaration) { + // we are in the class body, but we treat static fields as outside of the class body + return currentNode.kind !== 149 /* PropertyDeclaration */ + || (ts.getModifierFlags(currentNode) & 32 /* Static */) === 0; + } + currentNode = currentNode.parent; + } + return false; + } /** * Substitutes `this` when contained within an arrow function. * @@ -53611,8 +55885,9 @@ var ts; return node; } function getClassMemberPrefix(node, member) { - var expression = ts.getLocalName(node); - return ts.hasModifier(member, 32 /* Static */) ? expression : ts.createPropertyAccess(expression, "prototype"); + return ts.hasModifier(member, 32 /* Static */) + ? ts.getInternalName(node) + : ts.createPropertyAccess(ts.getInternalName(node), "prototype"); } function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) { if (!constructor || !hasExtendsClause) { @@ -53622,19 +55897,19 @@ var ts; return false; } var statement = ts.firstOrUndefined(constructor.body.statements); - if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 209 /* ExpressionStatement */) { + if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 210 /* ExpressionStatement */) { return false; } var statementExpression = statement.expression; - if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 180 /* CallExpression */) { + if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 181 /* CallExpression */) { return false; } var callTarget = statementExpression.expression; - if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 96 /* SuperKeyword */) { + if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 97 /* SuperKeyword */) { return false; } var callArgument = ts.singleOrUndefined(statementExpression.arguments); - if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 197 /* SpreadElement */) { + if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 198 /* SpreadElement */) { return false; } var expression = callArgument.expression; @@ -53675,15 +55950,15 @@ var ts; if (compilerOptions.jsx === 1 /* Preserve */ || compilerOptions.jsx === 3 /* ReactNative */) { previousOnEmitNode = context.onEmitNode; context.onEmitNode = onEmitNode; - context.enableEmitNotification(250 /* JsxOpeningElement */); - context.enableEmitNotification(251 /* JsxClosingElement */); - context.enableEmitNotification(249 /* JsxSelfClosingElement */); + context.enableEmitNotification(251 /* JsxOpeningElement */); + context.enableEmitNotification(252 /* JsxClosingElement */); + context.enableEmitNotification(250 /* JsxSelfClosingElement */); noSubstitution = []; } var previousOnSubstituteNode = context.onSubstituteNode; context.onSubstituteNode = onSubstituteNode; - context.enableSubstitution(178 /* PropertyAccessExpression */); - context.enableSubstitution(260 /* PropertyAssignment */); + context.enableSubstitution(179 /* PropertyAccessExpression */); + context.enableSubstitution(261 /* PropertyAssignment */); return transformSourceFile; /** * Transforms an ES5 source file to ES3. @@ -53702,9 +55977,9 @@ var ts; */ function onEmitNode(hint, node, emitCallback) { switch (node.kind) { - case 250 /* JsxOpeningElement */: - case 251 /* JsxClosingElement */: - case 249 /* JsxSelfClosingElement */: + case 251 /* JsxOpeningElement */: + case 252 /* JsxClosingElement */: + case 250 /* JsxSelfClosingElement */: var tagName = node.tagName; noSubstitution[ts.getOriginalNodeId(tagName)] = true; break; @@ -53761,7 +56036,7 @@ var ts; */ function trySubstituteReservedName(name) { var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(name.text) : undefined); - if (token >= 71 /* FirstReservedWord */ && token <= 106 /* LastReservedWord */) { + if (token >= 72 /* FirstReservedWord */ && token <= 107 /* LastReservedWord */) { return ts.setTextRange(ts.createLiteral(name), name); } return undefined; @@ -54041,13 +56316,13 @@ var ts; */ function visitJavaScriptInStatementContainingYield(node) { switch (node.kind) { - case 211 /* DoStatement */: + case 212 /* DoStatement */: return visitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return visitWhileStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitLabeledStatement(node); default: return visitJavaScriptInGeneratorFunctionBody(node); @@ -54060,24 +56335,24 @@ var ts; */ function visitJavaScriptInGeneratorFunctionBody(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return visitAccessorDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitForInStatement(node); - case 217 /* BreakStatement */: + case 218 /* BreakStatement */: return visitBreakStatement(node); - case 216 /* ContinueStatement */: + case 217 /* ContinueStatement */: return visitContinueStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return visitReturnStatement(node); default: if (node.transformFlags & 16777216 /* ContainsYield */) { @@ -54098,21 +56373,21 @@ var ts; */ function visitJavaScriptContainingYield(node) { switch (node.kind) { - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return visitBinaryExpression(node); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return visitConditionalExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return visitYieldExpression(node); - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return visitArrayLiteralExpression(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return visitObjectLiteralExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return visitElementAccessExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return visitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return visitNewExpression(node); default: return ts.visitEachChild(node, visitor, context); @@ -54125,9 +56400,9 @@ var ts; */ function visitGenerator(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return visitFunctionExpression(node); default: ts.Debug.failBadSyntaxKind(node); @@ -54145,7 +56420,7 @@ var ts; */ function visitFunctionDeclaration(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionDeclaration( /*decorators*/ undefined, node.modifiers, /*asteriskToken*/ undefined, node.name, @@ -54183,7 +56458,7 @@ var ts; */ function visitFunctionExpression(node) { // Currently, we only support generators that were originally async functions. - if (node.asteriskToken && ts.getEmitFlags(node) & 131072 /* AsyncFunctionBody */) { + if (node.asteriskToken) { node = ts.setOriginalNode(ts.setTextRange(ts.createFunctionExpression( /*modifiers*/ undefined, /*asteriskToken*/ undefined, node.name, @@ -54257,7 +56532,7 @@ var ts; state = ts.createTempVariable(/*recordTempVariable*/ undefined); // Build the generator resumeLexicalEnvironment(); - var statementOffset = ts.addPrologueDirectives(statements, body.statements, /*ensureUseStrict*/ false, visitor); + var statementOffset = ts.addPrologue(statements, body.statements, /*ensureUseStrict*/ false, visitor); transformAndEmitStatements(body.statements, statementOffset); var buildResult = build(); ts.addRange(statements, endLexicalEnvironment()); @@ -54293,7 +56568,7 @@ var ts; } else { // Do not hoist custom prologues. - if (ts.getEmitFlags(node) & 524288 /* CustomPrologue */) { + if (ts.getEmitFlags(node) & 1048576 /* CustomPrologue */) { return node; } for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) { @@ -54326,23 +56601,23 @@ var ts; } } function isCompoundAssignment(kind) { - return kind >= 58 /* FirstCompoundAssignment */ - && kind <= 69 /* LastCompoundAssignment */; + return kind >= 59 /* FirstCompoundAssignment */ + && kind <= 70 /* LastCompoundAssignment */; } function getOperatorForCompoundAssignment(kind) { switch (kind) { - case 58 /* PlusEqualsToken */: return 36 /* PlusToken */; - case 59 /* MinusEqualsToken */: return 37 /* MinusToken */; - case 60 /* AsteriskEqualsToken */: return 38 /* AsteriskToken */; - case 61 /* AsteriskAsteriskEqualsToken */: return 39 /* AsteriskAsteriskToken */; - case 62 /* SlashEqualsToken */: return 40 /* SlashToken */; - case 63 /* PercentEqualsToken */: return 41 /* PercentToken */; - case 64 /* LessThanLessThanEqualsToken */: return 44 /* LessThanLessThanToken */; - case 65 /* GreaterThanGreaterThanEqualsToken */: return 45 /* GreaterThanGreaterThanToken */; - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanGreaterThanToken */; - case 67 /* AmpersandEqualsToken */: return 47 /* AmpersandToken */; - case 68 /* BarEqualsToken */: return 48 /* BarToken */; - case 69 /* CaretEqualsToken */: return 49 /* CaretToken */; + case 59 /* PlusEqualsToken */: return 37 /* PlusToken */; + case 60 /* MinusEqualsToken */: return 38 /* MinusToken */; + case 61 /* AsteriskEqualsToken */: return 39 /* AsteriskToken */; + case 62 /* AsteriskAsteriskEqualsToken */: return 40 /* AsteriskAsteriskToken */; + case 63 /* SlashEqualsToken */: return 41 /* SlashToken */; + case 64 /* PercentEqualsToken */: return 42 /* PercentToken */; + case 65 /* LessThanLessThanEqualsToken */: return 45 /* LessThanLessThanToken */; + case 66 /* GreaterThanGreaterThanEqualsToken */: return 46 /* GreaterThanGreaterThanToken */; + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: return 47 /* GreaterThanGreaterThanGreaterThanToken */; + case 68 /* AmpersandEqualsToken */: return 48 /* AmpersandToken */; + case 69 /* BarEqualsToken */: return 49 /* BarToken */; + case 70 /* CaretEqualsToken */: return 50 /* CaretToken */; } } /** @@ -54355,7 +56630,7 @@ var ts; if (containsYield(right)) { var target = void 0; switch (left.kind) { - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: // [source] // a.b = yield; // @@ -54367,7 +56642,7 @@ var ts; // _a.b = %sent%; target = ts.updatePropertyAccess(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name); break; - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: // [source] // a[b] = yield; // @@ -54399,7 +56674,7 @@ var ts; if (ts.isLogicalOperator(node.operatorToken.kind)) { return visitLogicalBinaryExpression(node); } - else if (node.operatorToken.kind === 25 /* CommaToken */) { + else if (node.operatorToken.kind === 26 /* CommaToken */) { return visitCommaExpression(node); } // [source] @@ -54454,7 +56729,7 @@ var ts; var resultLabel = defineLabel(); var resultLocal = declareLocal(); emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), /*location*/ node.left); - if (node.operatorToken.kind === 52 /* AmpersandAmpersandToken */) { + if (node.operatorToken.kind === 53 /* AmpersandAmpersandToken */) { // Logical `&&` shortcuts when the left-hand operand is falsey. emitBreakWhenFalse(resultLabel, resultLocal, /*location*/ node.left); } @@ -54485,7 +56760,7 @@ var ts; visit(node.right); return ts.inlineExpressions(pendingExpressions); function visit(node) { - if (ts.isBinaryExpression(node) && node.operatorToken.kind === 25 /* CommaToken */) { + if (ts.isBinaryExpression(node) && node.operatorToken.kind === 26 /* CommaToken */) { visit(node.left); visit(node.right); } @@ -54548,11 +56823,13 @@ var ts; // .yield resumeLabel, (a()) // .mark resumeLabel // x = %sent%; - // NOTE: we are explicitly not handling YieldStar at this time. var resumeLabel = defineLabel(); var expression = ts.visitNode(node.expression, visitor, ts.isExpression); if (node.asteriskToken) { - emitYieldStar(expression, /*location*/ node); + var iterator = (ts.getEmitFlags(node.expression) & 8388608 /* Iterator */) === 0 + ? ts.createValuesHelper(context, expression, /*location*/ node) + : expression; + emitYieldStar(iterator, /*location*/ node); } else { emitYield(expression, /*location*/ node); @@ -54586,25 +56863,27 @@ var ts; // .mark resumeLabel // ar = _a.concat([%sent%, 2]); var numInitialElements = countInitialNodesWithoutYield(elements); - var temp = declareLocal(); - var hasAssignedTemp = false; + var temp; if (numInitialElements > 0) { + temp = declareLocal(); var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements); emitAssignment(temp, ts.createArrayLiteral(leadingElement ? [leadingElement].concat(initialElements) : initialElements)); leadingElement = undefined; - hasAssignedTemp = true; } var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements); - return hasAssignedTemp + return temp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.setTextRange(ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine), location); function reduceElement(expressions, element) { if (containsYield(element) && expressions.length > 0) { + var hasAssignedTemp = temp !== undefined; + if (!temp) { + temp = declareLocal(); + } emitAssignment(temp, hasAssignedTemp ? ts.createArrayConcat(temp, [ts.createArrayLiteral(expressions, multiLine)]) : ts.createArrayLiteral(leadingElement ? [leadingElement].concat(expressions) : expressions, multiLine)); - hasAssignedTemp = true; leadingElement = undefined; expressions = []; } @@ -54739,38 +57018,38 @@ var ts; } function transformAndEmitStatementWorker(node) { switch (node.kind) { - case 206 /* Block */: + case 207 /* Block */: return transformAndEmitBlock(node); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return transformAndEmitExpressionStatement(node); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return transformAndEmitIfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return transformAndEmitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return transformAndEmitWhileStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return transformAndEmitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return transformAndEmitForInStatement(node); - case 216 /* ContinueStatement */: + case 217 /* ContinueStatement */: return transformAndEmitContinueStatement(node); - case 217 /* BreakStatement */: + case 218 /* BreakStatement */: return transformAndEmitBreakStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return transformAndEmitReturnStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return transformAndEmitWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return transformAndEmitSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return transformAndEmitLabeledStatement(node); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return transformAndEmitThrowStatement(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return transformAndEmitTryStatement(node); default: - return emitStatement(ts.visitNode(node, visitor, ts.isStatement, /*optional*/ true)); + return emitStatement(ts.visitNode(node, visitor, ts.isStatement)); } } function transformAndEmitBlock(node) { @@ -54979,7 +57258,7 @@ var ts; beginScriptLoopBlock(); } var initializer = node.initializer; - if (ts.isVariableDeclarationList(initializer)) { + if (initializer && ts.isVariableDeclarationList(initializer)) { for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) { var variable = _a[_i]; hoistVariableDeclaration(variable.name); @@ -54987,7 +57266,7 @@ var ts; var variables = ts.getInitializedVariables(initializer); node = ts.updateFor(node, variables.length > 0 ? ts.inlineExpressions(ts.map(variables, transformInitializedVariable)) - : undefined, ts.visitNode(node.condition, visitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.incrementor, visitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -55079,7 +57358,7 @@ var ts; var variable = _a[_i]; hoistVariableDeclaration(variable.name); } - node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + node = ts.updateForIn(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, ts.liftToBlock)); } else { node = ts.visitEachChild(node, visitor, context); @@ -55118,11 +57397,11 @@ var ts; return ts.visitEachChild(node, visitor, context); } function transformAndEmitReturnStatement(node) { - emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true), + emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node); } function visitReturnStatement(node) { - return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression, /*optional*/ true), + return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), /*location*/ node); } function transformAndEmitWithStatement(node) { @@ -55187,7 +57466,7 @@ var ts; for (var i = 0; i < numClauses; i++) { var clause = caseBlock.clauses[i]; clauseLabels.push(defineLabel()); - if (clause.kind === 257 /* DefaultClause */ && defaultClauseIndex === -1) { + if (clause.kind === 258 /* DefaultClause */ && defaultClauseIndex === -1) { defaultClauseIndex = i; } } @@ -55200,7 +57479,7 @@ var ts; var defaultClausesSkipped = 0; for (var i = clausesWritten; i < numClauses; i++) { var clause = caseBlock.clauses[i]; - if (clause.kind === 256 /* CaseClause */) { + if (clause.kind === 257 /* CaseClause */) { var caseClause = clause; if (containsYield(caseClause.expression) && pendingClauses.length > 0) { break; @@ -55356,7 +57635,7 @@ var ts; return node; } function substituteExpressionIdentifier(node) { - if (renamedCatchVariables && renamedCatchVariables.has(node.text)) { + if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(node.text)) { var original = ts.getOriginalNode(node); if (ts.isIdentifier(original) && original.parent) { var declaration = resolver.getReferencedValueDeclaration(original); @@ -55375,7 +57654,7 @@ var ts; } function cacheExpression(node) { var temp; - if (ts.isGeneratedIdentifier(node)) { + if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096 /* HelperName */) { return node; } temp = ts.createTempVariable(hoistVariableDeclaration); @@ -55503,15 +57782,23 @@ var ts; */ function beginCatchBlock(variable) { ts.Debug.assert(peekBlockKind() === 0 /* Exception */); - var text = variable.name.text; - var name = declareLocal(text); - if (!renamedCatchVariables) { - renamedCatchVariables = ts.createMap(); - renamedCatchVariableDeclarations = []; - context.enableSubstitution(70 /* Identifier */); + // generated identifiers should already be unique within a file + var name; + if (ts.isGeneratedIdentifier(variable.name)) { + name = variable.name; + hoistVariableDeclaration(variable.name); + } + else { + var text = variable.name.text; + name = declareLocal(text); + if (!renamedCatchVariables) { + renamedCatchVariables = ts.createMap(); + renamedCatchVariableDeclarations = []; + context.enableSubstitution(71 /* Identifier */); + } + renamedCatchVariables.set(text, true); + renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; } - renamedCatchVariables.set(text, true); - renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name; var exception = peekBlock(); ts.Debug.assert(exception.state < 1 /* Catch */); var endLabel = exception.endLabel; @@ -55781,7 +58068,7 @@ var ts; */ function createInstruction(instruction) { var literal = ts.createLiteral(instruction); - literal.trailingComment = getInstructionName(instruction); + ts.addSyntheticTrailingComment(literal, 3 /* MultiLineCommentTrivia */, getInstructionName(instruction)); return literal; } /** @@ -55959,7 +58246,7 @@ var ts; /*name*/ undefined, /*typeParameters*/ undefined, [ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, ts.createBlock(buildResult, - /*multiLine*/ buildResult.length > 0)), 262144 /* ReuseTempVariableScope */)); + /*multiLine*/ buildResult.length > 0)), 524288 /* ReuseTempVariableScope */)); } /** * Builds the statements for the generator function body. @@ -56398,11 +58685,12 @@ var ts; name: "typescript:generator", scoped: false, priority: 6, - text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t;\n return { next: verb(0), \"throw\": verb(1), \"return\": verb(2) };\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" + text: "\n var __generator = (this && this.__generator) || function (thisArg, body) {\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\n function verb(n) { return function (v) { return step([n, v]); }; }\n function step(op) {\n if (f) throw new TypeError(\"Generator is already executing.\");\n while (_) try {\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\n if (y = 0, t) op = [0, t.value];\n switch (op[0]) {\n case 0: case 1: t = op; break;\n case 4: _.label++; return { value: op[1], done: false };\n case 5: _.label++; y = op[1]; op = [0]; continue;\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\n default:\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\n if (t[2]) _.ops.pop();\n _.trys.pop(); continue;\n }\n op = body.call(thisArg, _);\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\n }\n };" }; })(ts || (ts = {})); /// /// +/// /*@internal*/ var ts; (function (ts) { @@ -56424,12 +58712,12 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. - context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(261 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. - context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers with imported/exported symbols. + context.enableSubstitution(194 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(192 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(193 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(262 /* ShorthandPropertyAssignment */); // Substitutes shorthand property assignments for imported/exported symbols. + context.enableEmitNotification(265 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var currentSourceFile; // The current file. @@ -56442,9 +58730,7 @@ var ts; * @param node The SourceFile node. */ function transformSourceFile(node) { - if (ts.isDeclarationFile(node) - || !(ts.isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (ts.isDeclarationFile(node) || !(ts.isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } currentSourceFile = node; @@ -56457,6 +58743,12 @@ var ts; currentModuleInfo = undefined; return ts.aggregateTransformFlags(updated); } + function shouldEmitUnderscoreUnderscoreESModule() { + if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) { + return true; + } + return false; + } /** * Transforms a SourceFile into a CommonJS module. * @@ -56465,16 +58757,19 @@ var ts; function transformCommonJSModule(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); - ts.addRange(statements, endLexicalEnvironment()); addExportEqualsIfNeeded(statements, /*emitAsReturn*/ false); + ts.addRange(statements, endLexicalEnvironment()); var updated = ts.updateSourceFileNode(node, ts.setTextRange(ts.createNodeArray(statements), node.statements)); if (currentModuleInfo.hasExportStarsToExportValues) { + // If we have any `export * from ...` declarations + // we need to inform the emitter to add the __export helper. ts.addEmitHelper(updated, exportStarHelper); } return updated; @@ -56636,15 +58931,20 @@ var ts; var externalModuleName = ts.getExternalModuleNameLiteral(importNode, currentSourceFile, host, resolver, compilerOptions); // Find the name of the module alias, if there is one var importAliasName = ts.getLocalNameForExternalImport(importNode, currentSourceFile); - if (includeNonAmdDependencies && importAliasName) { - // Set emitFlags on the name of the classDeclaration - // This is so that when printer will not substitute the identifier - ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); - aliasedModuleNames.push(externalModuleName); - importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); - } - else { - unaliasedModuleNames.push(externalModuleName); + // It is possible that externalModuleName is undefined if it is not string literal. + // This can happen in the invalid import syntax. + // E.g : "import * from alias from 'someLib';" + if (externalModuleName) { + if (includeNonAmdDependencies && importAliasName) { + // Set emitFlags on the name of the classDeclaration + // This is so that when printer will not substitute the identifier + ts.setEmitFlags(importAliasName, 4 /* NoSubstitution */); + aliasedModuleNames.push(externalModuleName); + importAliasNames.push(ts.createParameter(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + } + else { + unaliasedModuleNames.push(externalModuleName); + } } } return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames }; @@ -56657,18 +58957,18 @@ var ts; function transformAsynchronousModuleBody(node) { startLexicalEnvironment(); var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); - if (!currentModuleInfo.exportEquals) { + var statementOffset = ts.addPrologue(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + if (shouldEmitUnderscoreUnderscoreESModule()) { ts.append(statements, createUnderscoreUnderscoreESModule()); } // Visit each statement of the module body. - ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true)); + ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement)); ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset)); + // Append the 'export =' statement if provided. + addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); // End the lexical environment for the module body // and merge any new lexical declarations. ts.addRange(statements, endLexicalEnvironment()); - // Append the 'export =' statement if provided. - addExportEqualsIfNeeded(statements, /*emitAsReturn*/ true); var body = ts.createBlock(statements, /*multiLine*/ true); if (currentModuleInfo.hasExportStarsToExportValues) { // If we have any `export * from ...` declarations @@ -56711,23 +59011,23 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return visitExportDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return visitClassDeclaration(node); - case 299 /* MergeDeclarationMarker */: + case 297 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 300 /* EndOfDeclarationMarker */: + case 298 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: // This visitor does not descend into the tree, as export/import statements @@ -57029,7 +59329,7 @@ var ts; // // To balance the declaration, add the exports of the elided variable // statement. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original); } @@ -57041,7 +59341,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -57084,10 +59384,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240 /* NamedImports */: + case 241 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -57217,7 +59517,7 @@ var ts; function createUnderscoreUnderscoreESModule() { var statement; if (languageVersion === 0 /* ES3 */) { - statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(true))); + statement = ts.createStatement(createExportExpression(ts.createIdentifier("__esModule"), ts.createLiteral(/*value*/ true))); } else { statement = ts.createStatement(ts.createCall(ts.createPropertyAccess(ts.createIdentifier("Object"), "defineProperty"), @@ -57225,11 +59525,11 @@ var ts; ts.createIdentifier("exports"), ts.createLiteral("__esModule"), ts.createObjectLiteral([ - ts.createPropertyAssignment("value", ts.createLiteral(true)) + ts.createPropertyAssignment("value", ts.createLiteral(/*value*/ true)) ]) ])); } - ts.setEmitFlags(statement, 524288 /* CustomPrologue */); + ts.setEmitFlags(statement, 1048576 /* CustomPrologue */); return statement; } /** @@ -57269,8 +59569,8 @@ var ts; function modifierVisitor(node) { // Elide module-specific modifiers. switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: return undefined; } return node; @@ -57286,7 +59586,7 @@ var ts; * @param emit A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { currentSourceFile = node; currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)]; noSubstitution = []; @@ -57348,12 +59648,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return substituteBinaryExpression(node); - case 192 /* PostfixUnaryExpression */: - case 191 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -57374,7 +59674,7 @@ var ts; } if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) { var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node)); - if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 265 /* SourceFile */) { return ts.setTextRange(ts.createPropertyAccess(ts.createIdentifier("exports"), ts.getSynthesizedClone(node)), /*location*/ node); } @@ -57442,15 +59742,15 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 /* PostfixUnaryExpression */ - ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 42 /* PlusPlusToken */ ? 58 /* PlusEqualsToken */ : 59 /* MinusEqualsToken */), ts.createLiteral(1)), + var expression = node.kind === 193 /* PostfixUnaryExpression */ + ? ts.setTextRange(ts.createBinary(node.operand, ts.createToken(node.operator === 43 /* PlusPlusToken */ ? 59 /* PlusEqualsToken */ : 60 /* MinusEqualsToken */), ts.createLiteral(1)), /*location*/ node) : node; for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) { @@ -57490,6 +59790,7 @@ var ts; })(ts || (ts = {})); /// /// +/// /*@internal*/ var ts; (function (ts) { @@ -57502,11 +59803,11 @@ var ts; var previousOnEmitNode = context.onEmitNode; context.onSubstituteNode = onSubstituteNode; context.onEmitNode = onEmitNode; - context.enableSubstitution(70 /* Identifier */); // Substitutes expression identifiers for imported symbols. - context.enableSubstitution(193 /* BinaryExpression */); // Substitutes assignments to exported symbols. - context.enableSubstitution(191 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableSubstitution(192 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. - context.enableEmitNotification(264 /* SourceFile */); // Restore state when substituting nodes in a file. + context.enableSubstitution(71 /* Identifier */); // Substitutes expression identifiers for imported symbols. + context.enableSubstitution(194 /* BinaryExpression */); // Substitutes assignments to exported symbols. + context.enableSubstitution(192 /* PrefixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableSubstitution(193 /* PostfixUnaryExpression */); // Substitutes updates to exported symbols. + context.enableEmitNotification(265 /* SourceFile */); // Restore state when substituting nodes in a file. var moduleInfoMap = []; // The ExternalModuleInfo for each file. var deferredExports = []; // Exports to defer until an EndOfDeclarationMarker is found. var exportFunctionsMap = []; // The export function associated with a source file. @@ -57601,18 +59902,20 @@ var ts; for (var i = 0; i < externalImports.length; i++) { var externalImport = externalImports[i]; var externalModuleName = ts.getExternalModuleNameLiteral(externalImport, currentSourceFile, host, resolver, compilerOptions); - var text = externalModuleName.text; - var groupIndex = groupIndices.get(text); - if (groupIndex !== undefined) { - // deduplicate/group entries in dependency list by the dependency name - dependencyGroups[groupIndex].externalImports.push(externalImport); - } - else { - groupIndices.set(text, dependencyGroups.length); - dependencyGroups.push({ - name: externalModuleName, - externalImports: [externalImport] - }); + if (externalModuleName) { + var text = externalModuleName.text; + var groupIndex = groupIndices.get(text); + if (groupIndex !== undefined) { + // deduplicate/group entries in dependency list by the dependency name + dependencyGroups[groupIndex].externalImports.push(externalImport); + } + else { + groupIndices.set(text, dependencyGroups.length); + dependencyGroups.push({ + name: externalModuleName, + externalImports: [externalImport] + }); + } } } return dependencyGroups; @@ -57670,7 +59973,8 @@ var ts; // only in the outer module body and not in the inner one. startLexicalEnvironment(); // Add any prologue directives. - var statementOffset = ts.addPrologueDirectives(statements, node.statements, /*ensureUseStrict*/ !compilerOptions.noImplicitUseStrict, sourceElementVisitor); + var ensureUseStrict = compilerOptions.alwaysStrict || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile)); + var statementOffset = ts.addPrologue(statements, node.statements, ensureUseStrict, sourceElementVisitor); // var __moduleName = context_1 && context_1.id; statements.push(ts.createVariableStatement( /*modifiers*/ undefined, ts.createVariableDeclarationList([ @@ -57678,7 +59982,7 @@ var ts; /*type*/ undefined, ts.createLogicalAnd(contextObject, ts.createPropertyAccess(contextObject, "id"))) ]))); // Visit the synthetic external helpers import declaration if present - ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement, /*optional*/ true); + ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement); // Visit the statements of the source file, emitting any transformations into // the `executeStatements` array. We do this *before* we fill the `setters` array // as we both emit transformations as well as aggregate some data used when creating @@ -57726,7 +60030,7 @@ var ts; var hasExportDeclarationWithExportClause = false; for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) { var externalImport = _a[_i]; - if (externalImport.kind === 243 /* ExportDeclaration */ && externalImport.exportClause) { + if (externalImport.kind === 244 /* ExportDeclaration */ && externalImport.exportClause) { hasExportDeclarationWithExportClause = true; break; } @@ -57751,7 +60055,7 @@ var ts; } for (var _d = 0, _e = moduleInfo.externalImports; _d < _e.length; _d++) { var externalImport = _e[_d]; - if (externalImport.kind !== 243 /* ExportDeclaration */) { + if (externalImport.kind !== 244 /* ExportDeclaration */) { continue; } var exportDecl = externalImport; @@ -57830,19 +60134,19 @@ var ts; var entry = _b[_a]; var importVariableName = ts.getLocalNameForExternalImport(entry, currentSourceFile); switch (entry.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: if (!entry.importClause) { // 'import "..."' case // module is imported only for side-effects, no emit required break; } - // fall-through - case 236 /* ImportEqualsDeclaration */: + // falls through + case 237 /* ImportEqualsDeclaration */: ts.Debug.assert(importVariableName !== undefined); // save import into the local statements.push(ts.createStatement(ts.createAssignment(importVariableName, parameterName))); break; - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: ts.Debug.assert(importVariableName !== undefined); if (entry.exportClause) { // export {a, b as c} from 'foo' @@ -57892,15 +60196,15 @@ var ts; */ function sourceElementVisitor(node) { switch (node.kind) { - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return visitImportDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return visitImportEqualsDeclaration(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: // ExportDeclarations are elided as they are handled via // `appendExportsOfDeclaration`. return undefined; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); default: return nestedElementVisitor(node); @@ -57973,7 +60277,7 @@ var ts; */ function visitFunctionDeclaration(node) { if (ts.hasModifier(node, 1 /* Export */)) { - hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), + hoistedStatements = ts.append(hoistedStatements, ts.updateFunctionDeclaration(node, node.decorators, ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), node.asteriskToken, ts.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, ts.visitNodes(node.parameters, destructuringVisitor, ts.isParameterDeclaration), /*type*/ undefined, ts.visitNode(node.body, destructuringVisitor, ts.isBlock))); } @@ -58075,8 +60379,8 @@ var ts; */ function shouldHoistVariableDeclarationList(node) { // hoist only non-block scoped declarations or block scoped declarations parented by source file - return (ts.getEmitFlags(node) & 1048576 /* NoHoisting */) === 0 - && (enclosingBlockScopedContainer.kind === 264 /* SourceFile */ + return (ts.getEmitFlags(node) & 2097152 /* NoHoisting */) === 0 + && (enclosingBlockScopedContainer.kind === 265 /* SourceFile */ || (ts.getOriginalNode(node).flags & 3 /* BlockScoped */) === 0); } /** @@ -58140,7 +60444,7 @@ var ts; // // To balance the declaration, we defer the exports of the elided variable // statement until we visit this declaration's `EndOfDeclarationMarker`. - if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 207 /* VariableStatement */) { + if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 208 /* VariableStatement */) { var id = ts.getOriginalNodeId(node); var isExportedDeclaration = ts.hasModifier(node.original, 1 /* Export */); deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration); @@ -58153,7 +60457,7 @@ var ts; * @param node The node to test. */ function hasAssociatedEndOfDeclarationMarker(node) { - return (ts.getEmitFlags(node) & 2097152 /* HasEndOfDeclarationMarker */) !== 0; + return (ts.getEmitFlags(node) & 4194304 /* HasEndOfDeclarationMarker */) !== 0; } /** * Visits a DeclarationMarker used as a placeholder for the end of a transformed @@ -58196,10 +60500,10 @@ var ts; var namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: statements = appendExportsOfDeclaration(statements, namedBindings); break; - case 240 /* NamedImports */: + case 241 /* NamedImports */: for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { var importBinding = _a[_i]; statements = appendExportsOfDeclaration(statements, importBinding); @@ -58378,43 +60682,43 @@ var ts; */ function nestedElementVisitor(node) { switch (node.kind) { - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return visitVariableStatement(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return visitFunctionDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return visitClassDeclaration(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return visitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return visitForInStatement(node); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return visitForOfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return visitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return visitWhileStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return visitLabeledStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return visitWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return visitSwitchStatement(node); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return visitCaseBlock(node); - case 256 /* CaseClause */: + case 257 /* CaseClause */: return visitCaseClause(node); - case 257 /* DefaultClause */: + case 258 /* DefaultClause */: return visitDefaultClause(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return visitTryStatement(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return visitCatchClause(node); - case 206 /* Block */: + case 207 /* Block */: return visitBlock(node); - case 299 /* MergeDeclarationMarker */: + case 297 /* MergeDeclarationMarker */: return visitMergeDeclarationMarker(node); - case 300 /* EndOfDeclarationMarker */: + case 298 /* EndOfDeclarationMarker */: return visitEndOfDeclarationMarker(node); default: return destructuringVisitor(node); @@ -58428,7 +60732,7 @@ var ts; function visitForStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression, /*optional*/ true), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); + node = ts.updateFor(node, visitForInitializer(node.initializer), ts.visitNode(node.condition, destructuringVisitor, ts.isExpression), ts.visitNode(node.incrementor, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58440,7 +60744,7 @@ var ts; function visitForInStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + node = ts.updateForIn(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58452,7 +60756,7 @@ var ts; function visitForOfStatement(node) { var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer; enclosingBlockScopedContainer = node; - node = ts.updateForOf(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + node = ts.updateForOf(node, node.awaitModifier, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer; return node; } @@ -58472,6 +60776,9 @@ var ts; * @param node The node to visit. */ function visitForInitializer(node) { + if (!node) { + return node; + } if (shouldHoistForInitializer(node)) { var expressions = void 0; for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) { @@ -58490,7 +60797,7 @@ var ts; * @param node The node to visit. */ function visitDoStatement(node) { - return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); + return ts.updateDo(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock), ts.visitNode(node.expression, destructuringVisitor, ts.isExpression)); } /** * Visits the body of a WhileStatement to hoist declarations. @@ -58498,7 +60805,7 @@ var ts; * @param node The node to visit. */ function visitWhileStatement(node) { - return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + return ts.updateWhile(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } /** * Visits the body of a LabeledStatement to hoist declarations. @@ -58506,7 +60813,7 @@ var ts; * @param node The node to visit. */ function visitLabeledStatement(node) { - return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + return ts.updateLabel(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } /** * Visits the body of a WithStatement to hoist declarations. @@ -58514,7 +60821,7 @@ var ts; * @param node The node to visit. */ function visitWithStatement(node) { - return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, /*optional*/ false, ts.liftToBlock)); + return ts.updateWith(node, ts.visitNode(node.expression, destructuringVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, ts.liftToBlock)); } /** * Visits the body of a SwitchStatement to hoist declarations. @@ -58594,7 +60901,7 @@ var ts; */ function destructuringVisitor(node) { if (node.transformFlags & 1024 /* DestructuringAssignment */ - && node.kind === 193 /* BinaryExpression */) { + && node.kind === 194 /* BinaryExpression */) { return visitDestructuringAssignment(node); } else if (node.transformFlags & 2048 /* ContainsDestructuringAssignment */) { @@ -58622,7 +60929,7 @@ var ts; * @param node The destructuring target. */ function hasExportedReferenceInDestructuringTarget(node) { - if (ts.isAssignmentExpression(node)) { + if (ts.isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { return hasExportedReferenceInDestructuringTarget(node.left); } else if (ts.isSpreadExpression(node)) { @@ -58642,7 +60949,7 @@ var ts; } else if (ts.isIdentifier(node)) { var container = resolver.getReferencedExportContainer(node); - return container !== undefined && container.kind === 264 /* SourceFile */; + return container !== undefined && container.kind === 265 /* SourceFile */; } else { return false; @@ -58658,8 +60965,8 @@ var ts; */ function modifierVisitor(node) { switch (node.kind) { - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: return undefined; } return node; @@ -58675,7 +60982,7 @@ var ts; * @param emitCallback A callback used to emit the node in the printer. */ function onEmitNode(hint, node, emitCallback) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { var id = ts.getOriginalNodeId(node); currentSourceFile = node; moduleInfo = moduleInfoMap[id]; @@ -58720,12 +61027,12 @@ var ts; */ function substituteExpression(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return substituteExpressionIdentifier(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return substituteBinaryExpression(node); - case 191 /* PrefixUnaryExpression */: - case 192 /* PostfixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return substituteUnaryExpression(node); } return node; @@ -58811,22 +61118,22 @@ var ts; // - We do not substitute identifiers that were originally the name of an enum or // namespace due to how they are transformed in TypeScript. // - We only substitute identifiers that are exported at the top level. - if ((node.operator === 42 /* PlusPlusToken */ || node.operator === 43 /* MinusMinusToken */) + if ((node.operator === 43 /* PlusPlusToken */ || node.operator === 44 /* MinusMinusToken */) && ts.isIdentifier(node.operand) && !ts.isGeneratedIdentifier(node.operand) && !ts.isLocalName(node.operand) && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) { var exportedNames = getExports(node.operand); if (exportedNames) { - var expression = node.kind === 192 /* PostfixUnaryExpression */ + var expression = node.kind === 193 /* PostfixUnaryExpression */ ? ts.setTextRange(ts.createPrefix(node.operator, node.operand), node) : node; for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) { var exportName = exportedNames_4[_i]; expression = createExportExpression(exportName, preventSubstitution(expression)); } - if (node.kind === 192 /* PostfixUnaryExpression */) { - expression = node.operator === 42 /* PlusPlusToken */ + if (node.kind === 193 /* PostfixUnaryExpression */) { + expression = node.operator === 43 /* PlusPlusToken */ ? ts.createSubtract(preventSubstitution(expression), ts.createLiteral(1)) : ts.createAdd(preventSubstitution(expression), ts.createLiteral(1)); } @@ -58847,7 +61154,7 @@ var ts; || resolver.getReferencedValueDeclaration(name); if (valueDeclaration) { var exportContainer = resolver.getReferencedExportContainer(name, /*prefixLocals*/ false); - if (exportContainer && exportContainer.kind === 264 /* SourceFile */) { + if (exportContainer && exportContainer.kind === 265 /* SourceFile */) { exportedNames = ts.append(exportedNames, ts.getDeclarationName(valueDeclaration)); } exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]); @@ -58888,8 +61195,8 @@ var ts; var previousOnSubstituteNode = context.onSubstituteNode; context.onEmitNode = onEmitNode; context.onSubstituteNode = onSubstituteNode; - context.enableEmitNotification(264 /* SourceFile */); - context.enableSubstitution(70 /* Identifier */); + context.enableEmitNotification(265 /* SourceFile */); + context.enableSubstitution(71 /* Identifier */); var currentSourceFile; return transformSourceFile; function transformSourceFile(node) { @@ -58900,7 +61207,7 @@ var ts; var externalHelpersModuleName = ts.getOrCreateExternalHelpersModuleNameIfNeeded(node, compilerOptions); if (externalHelpersModuleName) { var statements = []; - var statementOffset = ts.addPrologueDirectives(statements, node.statements); + var statementOffset = ts.addPrologue(statements, node.statements); ts.append(statements, ts.createImportDeclaration( /*decorators*/ undefined, /*modifiers*/ undefined, ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(externalHelpersModuleName)), ts.createLiteral(ts.externalHelpersModuleNameText))); @@ -58915,10 +61222,10 @@ var ts; } function visitor(node) { switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // Elide `import=` as it is not legal with --module ES6 return undefined; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return visitExportAssignment(node); } return node; @@ -59000,16 +61307,24 @@ var ts; return ts.transformModule; } } + var TransformationState; + (function (TransformationState) { + TransformationState[TransformationState["Uninitialized"] = 0] = "Uninitialized"; + TransformationState[TransformationState["Initialized"] = 1] = "Initialized"; + TransformationState[TransformationState["Completed"] = 2] = "Completed"; + TransformationState[TransformationState["Disposed"] = 3] = "Disposed"; + })(TransformationState || (TransformationState = {})); var SyntaxKindFeatureFlags; (function (SyntaxKindFeatureFlags) { SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["Substitution"] = 1] = "Substitution"; SyntaxKindFeatureFlags[SyntaxKindFeatureFlags["EmitNotifications"] = 2] = "EmitNotifications"; })(SyntaxKindFeatureFlags || (SyntaxKindFeatureFlags = {})); - function getTransformers(compilerOptions) { + function getTransformers(compilerOptions, customTransformers) { var jsx = compilerOptions.jsx; var languageVersion = ts.getEmitScriptTarget(compilerOptions); var moduleKind = ts.getEmitModuleKind(compilerOptions); var transformers = []; + ts.addRange(transformers, customTransformers && customTransformers.before); transformers.push(ts.transformTypeScript); if (jsx === 2 /* React */) { transformers.push(ts.transformJsx); @@ -59033,6 +61348,7 @@ var ts; if (languageVersion < 1 /* ES5 */) { transformers.push(ts.transformES5); } + ts.addRange(transformers, customTransformers && customTransformers.after); return transformers; } ts.getTransformers = getTransformers; @@ -59040,13 +61356,14 @@ var ts; * Transforms an array of SourceFiles by passing them through each transformer. * * @param resolver The emit resolver provided by the checker. - * @param host The emit host. - * @param sourceFiles An array of source files - * @param transforms An array of Transformers. + * @param host The emit host object used to interact with the file system. + * @param options Compiler options to surface in the `TransformationContext`. + * @param nodes An array of nodes to transform. + * @param transforms An array of `TransformerFactory` callbacks. + * @param allowDtsFiles A value indicating whether to allow the transformation of .d.ts files. */ - function transformFiles(resolver, host, sourceFiles, transformers) { - var enabledSyntaxKindFeatures = new Array(301 /* Count */); - var lexicalEnvironmentDisabled = false; + function transformNodes(resolver, host, options, nodes, transformers, allowDtsFiles) { + var enabledSyntaxKindFeatures = new Array(299 /* Count */); var lexicalEnvironmentVariableDeclarations; var lexicalEnvironmentFunctionDeclarations; var lexicalEnvironmentVariableDeclarationsStack = []; @@ -59054,10 +61371,13 @@ var ts; var lexicalEnvironmentStackOffset = 0; var lexicalEnvironmentSuspended = false; var emitHelpers; + var onSubstituteNode = function (_, node) { return node; }; + var onEmitNode = function (hint, node, callback) { return callback(hint, node); }; + var state = 0 /* Uninitialized */; // The transformation context is provided to each transformer as part of transformer // initialization. var context = { - getCompilerOptions: function () { return host.getCompilerOptions(); }, + getCompilerOptions: function () { return options; }, getEmitResolver: function () { return resolver; }, getEmitHost: function () { return host; }, startLexicalEnvironment: startLexicalEnvironment, @@ -59068,42 +61388,53 @@ var ts; hoistFunctionDeclaration: hoistFunctionDeclaration, requestEmitHelper: requestEmitHelper, readEmitHelpers: readEmitHelpers, - onSubstituteNode: function (_, node) { return node; }, enableSubstitution: enableSubstitution, - isSubstitutionEnabled: isSubstitutionEnabled, - onEmitNode: function (hint, node, callback) { return callback(hint, node); }, enableEmitNotification: enableEmitNotification, - isEmitNotificationEnabled: isEmitNotificationEnabled + isSubstitutionEnabled: isSubstitutionEnabled, + isEmitNotificationEnabled: isEmitNotificationEnabled, + get onSubstituteNode() { return onSubstituteNode; }, + set onSubstituteNode(value) { + ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onSubstituteNode = value; + }, + get onEmitNode() { return onEmitNode; }, + set onEmitNode(value) { + ts.Debug.assert(state < 1 /* Initialized */, "Cannot modify transformation hooks after initialization has completed."); + ts.Debug.assert(value !== undefined, "Value must not be 'undefined'"); + onEmitNode = value; + } }; + // Ensure the parse tree is clean before applying transformations + for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { + var node = nodes_4[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } ts.performance.mark("beforeTransform"); // Chain together and initialize each transformer. var transformation = ts.chain.apply(void 0, transformers)(context); - // Transform each source file. - var transformed = ts.map(sourceFiles, transformSourceFile); - // Disable modification of the lexical environment. - lexicalEnvironmentDisabled = true; + // prevent modification of transformation hooks. + state = 1 /* Initialized */; + // Transform each node. + var transformed = ts.map(nodes, allowDtsFiles ? transformation : transformRoot); + // prevent modification of the lexical environment. + state = 2 /* Completed */; ts.performance.mark("afterTransform"); ts.performance.measure("transformTime", "beforeTransform", "afterTransform"); return { transformed: transformed, - emitNodeWithSubstitution: emitNodeWithSubstitution, - emitNodeWithNotification: emitNodeWithNotification + substituteNode: substituteNode, + emitNodeWithNotification: emitNodeWithNotification, + dispose: dispose }; - /** - * Transforms a source file. - * - * @param sourceFile The source file to transform. - */ - function transformSourceFile(sourceFile) { - if (ts.isDeclarationFile(sourceFile)) { - return sourceFile; - } - return transformation(sourceFile); + function transformRoot(node) { + return node && (!ts.isSourceFile(node) || !ts.isDeclarationFile(node)) ? transformation(node) : node; } /** * Enables expression substitutions in the pretty printer for the provided SyntaxKind. */ function enableSubstitution(kind) { + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 1 /* Substitution */; } /** @@ -59120,18 +61451,15 @@ var ts; * @param node The node to emit. * @param emitCallback The callback used to emit the node or its substitute. */ - function emitNodeWithSubstitution(hint, node, emitCallback) { - if (node) { - if (isSubstitutionEnabled(node)) { - node = context.onSubstituteNode(hint, node) || node; - } - emitCallback(hint, node); - } + function substituteNode(hint, node) { + ts.Debug.assert(state < 3 /* Disposed */, "Cannot substitute a node after the result is disposed."); + return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node; } /** * Enables before/after emit notifications in the pretty printer for the provided SyntaxKind. */ function enableEmitNotification(kind) { + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); enabledSyntaxKindFeatures[kind] |= 2 /* EmitNotifications */; } /** @@ -59150,9 +61478,10 @@ var ts; * @param emitCallback The callback used to emit the node. */ function emitNodeWithNotification(hint, node, emitCallback) { + ts.Debug.assert(state < 3 /* Disposed */, "Cannot invoke TransformationResult callbacks after the result is disposed."); if (node) { if (isEmitNotificationEnabled(node)) { - context.onEmitNode(hint, node, emitCallback); + onEmitNode(hint, node, emitCallback); } else { emitCallback(hint, node); @@ -59163,7 +61492,8 @@ var ts; * Records a hoisted variable declaration for the provided name within a lexical environment. */ function hoistVariableDeclaration(name) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); var decl = ts.createVariableDeclaration(name); if (!lexicalEnvironmentVariableDeclarations) { lexicalEnvironmentVariableDeclarations = [decl]; @@ -59176,7 +61506,8 @@ var ts; * Records a hoisted function declaration within a lexical environment. */ function hoistFunctionDeclaration(func) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); if (!lexicalEnvironmentFunctionDeclarations) { lexicalEnvironmentFunctionDeclarations = [func]; } @@ -59189,7 +61520,8 @@ var ts; * are pushed onto a stack, and the related storage variables are reset. */ function startLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot start a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); // Save the current lexical environment. Rather than resizing the array we adjust the // stack size variable. This allows us to reuse existing array slots we've @@ -59203,13 +61535,15 @@ var ts; } /** Suspends the current lexical environment, usually after visiting a parameter list. */ function suspendLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot suspend a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended."); lexicalEnvironmentSuspended = true; } /** Resumes a suspended lexical environment, usually before visiting a function body. */ function resumeLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot resume a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended."); lexicalEnvironmentSuspended = false; } @@ -59218,7 +61552,8 @@ var ts; * any hoisted declarations added in this environment are returned. */ function endLexicalEnvironment() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot end a lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the lexical environment during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the lexical environment after transformation has completed."); ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended."); var statements; if (lexicalEnvironmentVariableDeclarations || lexicalEnvironmentFunctionDeclarations) { @@ -59247,18 +61582,39 @@ var ts; return statements; } function requestEmitHelper(helper) { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper."); emitHelpers = ts.append(emitHelpers, helper); } function readEmitHelpers() { - ts.Debug.assert(!lexicalEnvironmentDisabled, "Cannot modify the lexical environment during the print phase."); + ts.Debug.assert(state > 0 /* Uninitialized */, "Cannot modify the transformation context during initialization."); + ts.Debug.assert(state < 2 /* Completed */, "Cannot modify the transformation context after transformation has completed."); var helpers = emitHelpers; emitHelpers = undefined; return helpers; } + function dispose() { + if (state < 3 /* Disposed */) { + // Clean up emit nodes on parse tree + for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { + var node = nodes_5[_i]; + ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node))); + } + // Release references to external entries for GC purposes. + lexicalEnvironmentVariableDeclarations = undefined; + lexicalEnvironmentVariableDeclarationsStack = undefined; + lexicalEnvironmentFunctionDeclarations = undefined; + lexicalEnvironmentFunctionDeclarationsStack = undefined; + onSubstituteNode = undefined; + onEmitNode = undefined; + emitHelpers = undefined; + // Prevent further use of the transformation result. + state = 3 /* Disposed */; + } + } } - ts.transformFiles = transformFiles; + ts.transformNodes = transformNodes; })(ts || (ts = {})); /// /* @internal */ @@ -59341,7 +61697,7 @@ var ts; } if (compilerOptions.mapRoot) { sourceMapDir = ts.normalizeSlashes(compilerOptions.mapRoot); - if (sourceFileOrBundle.kind === 264 /* SourceFile */) { + if (sourceFileOrBundle.kind === 265 /* SourceFile */) { // For modules or multiple emit files the mapRoot will have directory structure like the sources // So if src\a.ts and src\lib\b.ts are compiled together user would be moving the maps into mapRoot\a.js.map and mapRoot\lib\b.js.map sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFileOrBundle, host, sourceMapDir)); @@ -59479,7 +61835,7 @@ var ts; var emitNode = node.emitNode; var emitFlags = emitNode && emitNode.flags; var _a = emitNode && emitNode.sourceMapRange || node, pos = _a.pos, end = _a.end; - if (node.kind !== 297 /* NotEmittedStatement */ + if (node.kind !== 295 /* NotEmittedStatement */ && (emitFlags & 16 /* NoLeadingSourceMap */) === 0 && pos >= 0) { emitPos(ts.skipTrivia(currentSourceText, pos)); @@ -59492,7 +61848,7 @@ var ts; else { emitCallback(hint, node); } - if (node.kind !== 297 /* NotEmittedStatement */ + if (node.kind !== 295 /* NotEmittedStatement */ && (emitFlags & 32 /* NoTrailingSourceMap */) === 0 && end >= 0) { emitPos(end); @@ -59655,24 +62011,19 @@ var ts; return; } if (node) { - var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end; - var emitFlags = ts.getEmitFlags(node); + hasWrittenComment = false; + var emitNode = node.emitNode; + var emitFlags = emitNode && emitNode.flags; + var _a = emitNode && emitNode.commentRange || node, pos = _a.pos, end = _a.end; if ((pos < 0 && end < 0) || (pos === end)) { // Both pos and end are synthesized, so just emit the node without comments. - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); } else { if (extendedDiagnostics) { ts.performance.mark("preEmitNodeWithComment"); } - var isEmittedNode = node.kind !== 297 /* NotEmittedStatement */; + var isEmittedNode = node.kind !== 295 /* NotEmittedStatement */; var skipLeadingComments = pos < 0 || (emitFlags & 512 /* NoLeadingComments */) !== 0; var skipTrailingComments = end < 0 || (emitFlags & 1024 /* NoTrailingComments */) !== 0; // Emit leading comments if the position is not synthesized and the node @@ -59691,23 +62042,16 @@ var ts; containerEnd = end; // To avoid invalid comment emit in a down-level binding pattern, we // keep track of the last declaration list container's end - if (node.kind === 226 /* VariableDeclarationList */) { + if (node.kind === 227 /* VariableDeclarationList */) { declarationListContainerEnd = end; } } if (extendedDiagnostics) { ts.performance.measure("commentTime", "preEmitNodeWithComment"); } - if (emitFlags & 2048 /* NoNestedComments */) { - disabled = true; - emitCallback(hint, node); - disabled = false; - } - else { - emitCallback(hint, node); - } + emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback); if (extendedDiagnostics) { - ts.performance.mark("beginEmitNodeWithComment"); + ts.performance.mark("postEmitNodeWithComment"); } // Restore previous container state. containerPos = savedContainerPos; @@ -59719,11 +62063,75 @@ var ts; emitTrailingComments(end); } if (extendedDiagnostics) { - ts.performance.measure("commentTime", "beginEmitNodeWithComment"); + ts.performance.measure("commentTime", "postEmitNodeWithComment"); } } } } + function emitNodeWithSynthesizedComments(hint, node, emitNode, emitFlags, emitCallback) { + var leadingComments = emitNode && emitNode.leadingComments; + if (ts.some(leadingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("preEmitNodeWithSynthesizedComments"); + } + ts.forEach(leadingComments, emitLeadingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "preEmitNodeWithSynthesizedComments"); + } + } + emitNodeWithNestedComments(hint, node, emitFlags, emitCallback); + var trailingComments = emitNode && emitNode.trailingComments; + if (ts.some(trailingComments)) { + if (extendedDiagnostics) { + ts.performance.mark("postEmitNodeWithSynthesizedComments"); + } + ts.forEach(trailingComments, emitTrailingSynthesizedComment); + if (extendedDiagnostics) { + ts.performance.measure("commentTime", "postEmitNodeWithSynthesizedComments"); + } + } + } + function emitLeadingSynthesizedComment(comment) { + if (comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine || comment.kind === 2 /* SingleLineCommentTrivia */) { + writer.writeLine(); + } + else { + writer.write(" "); + } + } + function emitTrailingSynthesizedComment(comment) { + if (!writer.isAtStartOfLine()) { + writer.write(" "); + } + writeSynthesizedComment(comment); + if (comment.hasTrailingNewLine) { + writer.writeLine(); + } + } + function writeSynthesizedComment(comment) { + var text = formatSynthesizedComment(comment); + var lineMap = comment.kind === 3 /* MultiLineCommentTrivia */ ? ts.computeLineStarts(text) : undefined; + ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine); + } + function formatSynthesizedComment(comment) { + return comment.kind === 3 /* MultiLineCommentTrivia */ + ? "/*" + comment.text + "*/" + : "//" + comment.text; + } + function emitNodeWithNestedComments(hint, node, emitFlags, emitCallback) { + if (emitFlags & 2048 /* NoNestedComments */) { + disabled = true; + emitCallback(hint, node); + disabled = false; + } + else { + emitCallback(hint, node); + } + } function emitBodyWithDetachedComments(node, detachedRange, emitCallback) { if (extendedDiagnostics) { ts.performance.mark("preEmitBodyWithDetachedComments"); @@ -59916,7 +62324,7 @@ var ts; * Determine if the given comment is a triple-slash * * @return true if the comment is a triple-slash comment else false - **/ + */ function isTripleSlashComment(commentPos, commentEnd) { // Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text // so that we don't end up computing comment string and doing match for all // comments @@ -59948,8 +62356,8 @@ var ts; } ts.getDeclarationDiagnostics = getDeclarationDiagnostics; function emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles) { - var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; - var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; + var sourceFiles = sourceFileOrBundle.kind === 266 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var isBundledEmit = sourceFileOrBundle.kind === 266 /* Bundle */; var newLine = host.getNewLine(); var compilerOptions = host.getCompilerOptions(); var write; @@ -60023,7 +62431,7 @@ var ts; var oldWriter = writer; ts.forEach(moduleElementDeclarationEmitInfo, function (aliasEmitInfo) { if (aliasEmitInfo.isVisible && !aliasEmitInfo.asynchronousOutput) { - ts.Debug.assert(aliasEmitInfo.node.kind === 237 /* ImportDeclaration */); + ts.Debug.assert(aliasEmitInfo.node.kind === 238 /* ImportDeclaration */); createAndSetNewTextWriterWithSymbolWriter(); ts.Debug.assert(aliasEmitInfo.indent === 0 || (aliasEmitInfo.indent === 1 && isBundledEmit)); for (var i = 0; i < aliasEmitInfo.indent; i++) { @@ -60099,10 +62507,10 @@ var ts; var oldWriter = writer; ts.forEach(nodes, function (declaration) { var nodeToCheck; - if (declaration.kind === 225 /* VariableDeclaration */) { + if (declaration.kind === 226 /* VariableDeclaration */) { nodeToCheck = declaration.parent.parent; } - else if (declaration.kind === 240 /* NamedImports */ || declaration.kind === 241 /* ImportSpecifier */ || declaration.kind === 238 /* ImportClause */) { + else if (declaration.kind === 241 /* NamedImports */ || declaration.kind === 242 /* ImportSpecifier */ || declaration.kind === 239 /* ImportClause */) { ts.Debug.fail("We should be getting ImportDeclaration instead to write"); } else { @@ -60120,7 +62528,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 === 237 /* ImportDeclaration */) { + if (moduleElementEmitInfo.node.kind === 238 /* 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; @@ -60130,12 +62538,12 @@ var ts; for (var declarationIndent = moduleElementEmitInfo.indent; declarationIndent; declarationIndent--) { increaseIndent(); } - if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 233 /* ModuleDeclaration */) { ts.Debug.assert(asynchronousSubModuleDeclarationEmitInfo === undefined); asynchronousSubModuleDeclarationEmitInfo = []; } writeModuleElement(nodeToCheck); - if (nodeToCheck.kind === 232 /* ModuleDeclaration */) { + if (nodeToCheck.kind === 233 /* ModuleDeclaration */) { moduleElementEmitInfo.subModuleElementDeclarationEmitInfo = asynchronousSubModuleDeclarationEmitInfo; asynchronousSubModuleDeclarationEmitInfo = undefined; } @@ -60201,7 +62609,7 @@ var ts; write(": "); // use the checker's type, not the declared type, // for non-optional initialized parameters that aren't a parameter property - var shouldUseResolverType = declaration.kind === 145 /* Parameter */ && + var shouldUseResolverType = declaration.kind === 146 /* Parameter */ && resolver.isRequiredInitializedParameter(declaration); if (type && !shouldUseResolverType) { // Write the type @@ -60229,15 +62637,15 @@ var ts; } } function emitLines(nodes) { - for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) { - var node = nodes_4[_i]; + for (var _i = 0, nodes_6 = nodes; _i < nodes_6.length; _i++) { + var node = nodes_6[_i]; emit(node); } } function emitSeparatedList(nodes, separator, eachNodeEmitFn, canEmitFn) { var currentWriterPos = writer.getTextPos(); - for (var _i = 0, nodes_5 = nodes; _i < nodes_5.length; _i++) { - var node = nodes_5[_i]; + for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { + var node = nodes_7[_i]; if (!canEmitFn || canEmitFn(node)) { if (currentWriterPos !== writer.getTextPos()) { write(separator); @@ -60264,60 +62672,60 @@ var ts; } function emitType(type) { switch (type.kind) { - case 118 /* AnyKeyword */: - case 135 /* StringKeyword */: - case 132 /* NumberKeyword */: - case 121 /* BooleanKeyword */: - case 133 /* ObjectKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: - case 138 /* UndefinedKeyword */: - case 94 /* NullKeyword */: - case 129 /* NeverKeyword */: - case 168 /* ThisType */: - case 172 /* LiteralType */: + case 119 /* AnyKeyword */: + case 136 /* StringKeyword */: + case 133 /* NumberKeyword */: + case 122 /* BooleanKeyword */: + case 134 /* ObjectKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: + case 139 /* UndefinedKeyword */: + case 95 /* NullKeyword */: + case 130 /* NeverKeyword */: + case 169 /* ThisType */: + case 173 /* LiteralType */: return writeTextOfNode(currentText, type); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(type); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return emitTypeReference(type); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return emitTypeQuery(type); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return emitArrayType(type); - case 164 /* TupleType */: + case 165 /* TupleType */: return emitTupleType(type); - case 165 /* UnionType */: + case 166 /* UnionType */: return emitUnionType(type); - case 166 /* IntersectionType */: + case 167 /* IntersectionType */: return emitIntersectionType(type); - case 167 /* ParenthesizedType */: + case 168 /* ParenthesizedType */: return emitParenType(type); - case 169 /* TypeOperator */: + case 170 /* TypeOperator */: return emitTypeOperator(type); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return emitIndexedAccessType(type); - case 171 /* MappedType */: + case 172 /* MappedType */: return emitMappedType(type); - case 159 /* FunctionType */: - case 160 /* ConstructorType */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: return emitSignatureDeclarationWithJsDocComments(type); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return emitTypeLiteral(type); - case 70 /* Identifier */: + case 71 /* Identifier */: return emitEntityName(type); - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return emitEntityName(type); - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return emitTypePredicate(type); } function writeEntityName(entityName) { - if (entityName.kind === 70 /* Identifier */) { + if (entityName.kind === 71 /* Identifier */) { writeTextOfNode(currentText, entityName); } else { - var left = entityName.kind === 142 /* QualifiedName */ ? entityName.left : entityName.expression; - var right = entityName.kind === 142 /* QualifiedName */ ? entityName.right : entityName.name; + var left = entityName.kind === 143 /* QualifiedName */ ? entityName.left : entityName.expression; + var right = entityName.kind === 143 /* QualifiedName */ ? entityName.right : entityName.name; writeEntityName(left); write("."); writeTextOfNode(currentText, right); @@ -60326,14 +62734,14 @@ var ts; function emitEntityName(entityName) { var visibilityResult = resolver.isEntityNameVisible(entityName, // Aliases can be written asynchronously so use correct enclosing declaration - entityName.parent.kind === 236 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); + entityName.parent.kind === 237 /* ImportEqualsDeclaration */ ? entityName.parent : enclosingDeclaration); handleSymbolAccessibilityError(visibilityResult); recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName)); writeEntityName(entityName); } function emitExpressionWithTypeArguments(node) { if (ts.isEntityNameExpression(node.expression)) { - ts.Debug.assert(node.expression.kind === 70 /* Identifier */ || node.expression.kind === 178 /* PropertyAccessExpression */); + ts.Debug.assert(node.expression.kind === 71 /* Identifier */ || node.expression.kind === 179 /* PropertyAccessExpression */); emitEntityName(node.expression); if (node.typeArguments) { write("<"); @@ -60433,7 +62841,7 @@ var ts; currentIdentifiers = node.identifiers; isCurrentFileExternalModule = ts.isExternalModule(node); enclosingDeclaration = node; - ts.emitDetachedComments(currentText, currentLineMap, writer, ts.writeCommentRange, node, newLine, true /* remove comments */); + ts.emitDetachedComments(currentText, currentLineMap, writer, ts.writeCommentRange, node, newLine, /*removeComents*/ true); emitLines(node.statements); } // Return a temp variable name to be used in `export default` statements. @@ -60455,7 +62863,7 @@ var ts; } } function emitExportAssignment(node) { - if (node.expression.kind === 70 /* Identifier */) { + if (node.expression.kind === 71 /* Identifier */) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } @@ -60478,7 +62886,7 @@ var ts; write(";"); writeLine(); // Make all the declarations visible for the export name - if (node.expression.kind === 70 /* Identifier */) { + if (node.expression.kind === 71 /* Identifier */) { var nodes = resolver.collectLinkedAliases(node.expression); // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); @@ -60497,10 +62905,10 @@ var ts; if (isModuleElementVisible) { writeModuleElement(node); } - else if (node.kind === 236 /* ImportEqualsDeclaration */ || - (node.parent.kind === 264 /* SourceFile */ && isCurrentFileExternalModule)) { + else if (node.kind === 237 /* ImportEqualsDeclaration */ || + (node.parent.kind === 265 /* SourceFile */ && isCurrentFileExternalModule)) { var isVisible = void 0; - if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 264 /* SourceFile */) { + if (asynchronousSubModuleDeclarationEmitInfo && node.parent.kind !== 265 /* SourceFile */) { // Import declaration of another module that is visited async so lets put it in right spot asynchronousSubModuleDeclarationEmitInfo.push({ node: node, @@ -60510,7 +62918,7 @@ var ts; }); } else { - if (node.kind === 237 /* ImportDeclaration */) { + if (node.kind === 238 /* ImportDeclaration */) { var importDeclaration = node; if (importDeclaration.importClause) { isVisible = (importDeclaration.importClause.name && resolver.isDeclarationVisible(importDeclaration.importClause)) || @@ -60528,23 +62936,23 @@ var ts; } function writeModuleElement(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return writeFunctionDeclaration(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return writeVariableStatement(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return writeInterfaceDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return writeClassDeclaration(node); - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return writeTypeAliasDeclaration(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return writeEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return writeModuleDeclaration(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return writeImportEqualsDeclaration(node); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return writeImportDeclaration(node); default: ts.Debug.fail("Unknown symbol kind"); @@ -60552,7 +62960,7 @@ var ts; } function emitModuleElementDeclarationFlags(node) { // If the node is parented in the current source file we need to emit export declare or just export - if (node.parent.kind === 264 /* SourceFile */) { + if (node.parent.kind === 265 /* SourceFile */) { var modifiers = ts.getModifierFlags(node); // If the node is exported if (modifiers & 1 /* Export */) { @@ -60561,7 +62969,7 @@ var ts; if (modifiers & 512 /* Default */) { write("default "); } - else if (node.kind !== 229 /* InterfaceDeclaration */ && !noDeclare) { + else if (node.kind !== 230 /* InterfaceDeclaration */ && !noDeclare) { write("declare "); } } @@ -60613,7 +63021,7 @@ var ts; } function isVisibleNamedBinding(namedBindings) { if (namedBindings) { - if (namedBindings.kind === 239 /* NamespaceImport */) { + if (namedBindings.kind === 240 /* NamespaceImport */) { return resolver.isDeclarationVisible(namedBindings); } else { @@ -60637,7 +63045,7 @@ var ts; // If the default binding was emitted, write the separated write(", "); } - if (node.importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (node.importClause.namedBindings.kind === 240 /* NamespaceImport */) { write("* as "); writeTextOfNode(currentText, node.importClause.namedBindings.name); } @@ -60658,13 +63066,13 @@ var ts; // 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 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 !== 232 /* ModuleDeclaration */; + resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || parent.kind !== 233 /* ModuleDeclaration */; var moduleSpecifier; - if (parent.kind === 236 /* ImportEqualsDeclaration */) { + if (parent.kind === 237 /* ImportEqualsDeclaration */) { var node = parent; moduleSpecifier = ts.getExternalModuleImportEqualsDeclarationExpression(node); } - else if (parent.kind === 232 /* ModuleDeclaration */) { + else if (parent.kind === 233 /* ModuleDeclaration */) { moduleSpecifier = parent.name; } else { @@ -60734,7 +63142,7 @@ var ts; writeTextOfNode(currentText, node.name); } } - while (node.body && node.body.kind !== 233 /* ModuleBlock */) { + while (node.body && node.body.kind !== 234 /* ModuleBlock */) { node = node.body; write("."); writeTextOfNode(currentText, node.name); @@ -60804,7 +63212,7 @@ var ts; writeLine(); } function isPrivateMethodTypeParameter(node) { - return node.parent.kind === 150 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); + return node.parent.kind === 151 /* MethodDeclaration */ && ts.hasModifier(node.parent, 8 /* Private */); } function emitTypeParameters(typeParameters) { function emitTypeParameter(node) { @@ -60815,15 +63223,15 @@ var ts; // If there is constraint present and this is not a type parameter of the private method emit the constraint if (node.constraint && !isPrivateMethodTypeParameter(node)) { write(" extends "); - if (node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || - node.parent.kind === 149 /* MethodSignature */ || - node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - node.parent.kind === 154 /* CallSignature */ || - node.parent.kind === 155 /* ConstructSignature */); + if (node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 163 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 151 /* MethodDeclaration */ || + node.parent.kind === 150 /* MethodSignature */ || + node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + node.parent.kind === 155 /* CallSignature */ || + node.parent.kind === 156 /* ConstructSignature */); emitType(node.constraint); } else { @@ -60832,15 +63240,15 @@ var ts; } if (node.default && !isPrivateMethodTypeParameter(node)) { write(" = "); - if (node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - (node.parent.parent && node.parent.parent.kind === 162 /* TypeLiteral */)) { - ts.Debug.assert(node.parent.kind === 150 /* MethodDeclaration */ || - node.parent.kind === 149 /* MethodSignature */ || - node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - node.parent.kind === 154 /* CallSignature */ || - node.parent.kind === 155 /* ConstructSignature */); + if (node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + (node.parent.parent && node.parent.parent.kind === 163 /* TypeLiteral */)) { + ts.Debug.assert(node.parent.kind === 151 /* MethodDeclaration */ || + node.parent.kind === 150 /* MethodSignature */ || + node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + node.parent.kind === 155 /* CallSignature */ || + node.parent.kind === 156 /* ConstructSignature */); emitType(node.default); } else { @@ -60851,34 +63259,34 @@ var ts; // Type parameter constraints are named by user so we should always be able to name it var diagnosticMessage; switch (node.parent.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1; break; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1; break; - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 154 /* CallSignature */: + case 155 /* CallSignature */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1; break; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.hasModifier(node.parent, 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 === 228 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 229 /* 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 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1; break; - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1; break; default: @@ -60906,7 +63314,7 @@ var ts; if (ts.isEntityNameExpression(node.expression)) { emitTypeWithNewGetSymbolAccessibilityDiagnostic(node, getHeritageClauseVisibilityError); } - else if (!isImplementsList && node.expression.kind === 94 /* NullKeyword */) { + else if (!isImplementsList && node.expression.kind === 95 /* NullKeyword */) { write("null"); } else { @@ -60918,7 +63326,7 @@ var ts; function getHeritageClauseVisibilityError() { var diagnosticMessage; // Heritage clause is written by user so it can always be named - if (node.parent.parent.kind === 228 /* ClassDeclaration */) { + if (node.parent.parent.kind === 229 /* 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 : @@ -61006,7 +63414,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 !== 225 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { + if (node.kind !== 226 /* VariableDeclaration */ || resolver.isDeclarationVisible(node)) { if (ts.isBindingPattern(node.name)) { emitBindingPattern(node.name); } @@ -61017,11 +63425,11 @@ var ts; writeTextOfNode(currentText, node.name); // If optional property emit ? but in the case of parameterProperty declaration with "?" indicating optional parameter for the constructor // we don't want to emit property declaration with "?" - if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */ || - (node.kind === 145 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { + if ((node.kind === 149 /* PropertyDeclaration */ || node.kind === 148 /* PropertySignature */ || + (node.kind === 146 /* Parameter */ && !ts.isParameterPropertyDeclaration(node))) && ts.hasQuestionToken(node)) { write("?"); } - if ((node.kind === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) && node.parent.kind === 162 /* TypeLiteral */) { + if ((node.kind === 149 /* PropertyDeclaration */ || node.kind === 148 /* PropertySignature */) && node.parent.kind === 163 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (resolver.isLiteralConstDeclaration(node)) { @@ -61034,14 +63442,14 @@ var ts; } } function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { - if (node.kind === 225 /* VariableDeclaration */) { + if (node.kind === 226 /* 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 === 148 /* PropertyDeclaration */ || node.kind === 147 /* PropertySignature */) { + else if (node.kind === 149 /* PropertyDeclaration */ || node.kind === 148 /* PropertySignature */) { // TODO(jfreeman): Deal with computed properties in error reporting. if (ts.hasModifier(node, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? @@ -61050,7 +63458,7 @@ var ts; ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* 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 : @@ -61082,7 +63490,7 @@ var ts; var elements = []; for (var _i = 0, _a = bindingPattern.elements; _i < _a.length; _i++) { var element = _a[_i]; - if (element.kind !== 199 /* OmittedExpression */) { + if (element.kind !== 200 /* OmittedExpression */) { elements.push(element); } } @@ -61152,7 +63560,7 @@ var ts; var type = getTypeAnnotationFromAccessor(node); if (!type) { // couldn't get type for the first accessor, try the another one - var anotherAccessor = node.kind === 152 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; + var anotherAccessor = node.kind === 153 /* GetAccessor */ ? accessors.setAccessor : accessors.getAccessor; type = getTypeAnnotationFromAccessor(anotherAccessor); if (type) { accessorWithTypeAnnotation = anotherAccessor; @@ -61165,7 +63573,7 @@ var ts; } function getTypeAnnotationFromAccessor(accessor) { if (accessor) { - return accessor.kind === 152 /* GetAccessor */ + return accessor.kind === 153 /* GetAccessor */ ? accessor.type // Getter - return type : accessor.parameters.length > 0 ? accessor.parameters[0].type // Setter parameter type @@ -61174,7 +63582,7 @@ var ts; } function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; - if (accessorWithTypeAnnotation.kind === 153 /* SetAccessor */) { + if (accessorWithTypeAnnotation.kind === 154 /* SetAccessor */) { // Setters have to have type named and cannot infer it so, the type should always be named if (ts.hasModifier(accessorWithTypeAnnotation.parent, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? @@ -61224,17 +63632,17 @@ var ts; // so no need to verify if the declaration is visible if (!resolver.isImplementationOfOverload(node)) { emitJsDocComments(node); - if (node.kind === 227 /* FunctionDeclaration */) { + if (node.kind === 228 /* FunctionDeclaration */) { emitModuleElementDeclarationFlags(node); } - else if (node.kind === 150 /* MethodDeclaration */ || node.kind === 151 /* Constructor */) { + else if (node.kind === 151 /* MethodDeclaration */ || node.kind === 152 /* Constructor */) { emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); } - if (node.kind === 227 /* FunctionDeclaration */) { + if (node.kind === 228 /* FunctionDeclaration */) { write("function "); writeTextOfNode(currentText, node.name); } - else if (node.kind === 151 /* Constructor */) { + else if (node.kind === 152 /* Constructor */) { write("constructor"); } else { @@ -61254,17 +63662,17 @@ var ts; var prevEnclosingDeclaration = enclosingDeclaration; enclosingDeclaration = node; var closeParenthesizedFunctionType = false; - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { // Index signature can have readonly modifier emitClassMemberDeclarationFlags(ts.getModifierFlags(node)); write("["); } else { // Construct signature or constructor type write new Signature - if (node.kind === 155 /* ConstructSignature */ || node.kind === 160 /* ConstructorType */) { + if (node.kind === 156 /* ConstructSignature */ || node.kind === 161 /* ConstructorType */) { write("new "); } - else if (node.kind === 159 /* FunctionType */) { + else if (node.kind === 160 /* FunctionType */) { var currentOutput = writer.getText(); // Do not generate incorrect type when function type with type parameters is type argument // This could happen if user used space between two '<' making it error free @@ -61279,22 +63687,22 @@ var ts; } // Parameters emitCommaList(node.parameters, emitParameterDeclaration); - if (node.kind === 156 /* IndexSignature */) { + if (node.kind === 157 /* IndexSignature */) { write("]"); } else { write(")"); } // If this is not a constructor and is not private, emit the return type - var isFunctionTypeOrConstructorType = node.kind === 159 /* FunctionType */ || node.kind === 160 /* ConstructorType */; - if (isFunctionTypeOrConstructorType || node.parent.kind === 162 /* TypeLiteral */) { + var isFunctionTypeOrConstructorType = node.kind === 160 /* FunctionType */ || node.kind === 161 /* ConstructorType */; + if (isFunctionTypeOrConstructorType || node.parent.kind === 163 /* TypeLiteral */) { // Emit type literal signature return type only if specified if (node.type) { write(isFunctionTypeOrConstructorType ? " => " : ": "); emitType(node.type); } } - else if (node.kind !== 151 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { + else if (node.kind !== 152 /* Constructor */ && !ts.hasModifier(node, 8 /* Private */)) { writeReturnTypeAtSignature(node, getReturnTypeVisibilityError); } enclosingDeclaration = prevEnclosingDeclaration; @@ -61308,26 +63716,26 @@ var ts; function getReturnTypeVisibilityError(symbolAccessibilityResult) { var diagnosticMessage; switch (node.kind) { - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: // Interfaces cannot have return types that cannot be named 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 154 /* CallSignature */: + case 155 /* CallSignature */: // Interfaces cannot have return types that cannot be named 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 156 /* IndexSignature */: + case 157 /* IndexSignature */: // Interfaces cannot have return types that cannot be named 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 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.hasModifier(node, 32 /* Static */)) { diagnosticMessage = symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -61335,7 +63743,7 @@ var ts; ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 : ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0; } - else if (node.parent.kind === 228 /* ClassDeclaration */) { + else if (node.parent.kind === 229 /* 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 : @@ -61349,7 +63757,7 @@ var ts; ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0; } break; - case 227 /* FunctionDeclaration */: + case 228 /* 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 : @@ -61384,9 +63792,9 @@ var ts; write("?"); } decreaseIndent(); - if (node.parent.kind === 159 /* FunctionType */ || - node.parent.kind === 160 /* ConstructorType */ || - node.parent.parent.kind === 162 /* TypeLiteral */) { + if (node.parent.kind === 160 /* FunctionType */ || + node.parent.kind === 161 /* ConstructorType */ || + node.parent.parent.kind === 163 /* TypeLiteral */) { emitTypeOfVariableDeclarationFromTypeLiteral(node); } else if (!ts.hasModifier(node.parent, 8 /* Private */)) { @@ -61402,29 +63810,29 @@ var ts; } function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) { switch (node.parent.kind) { - case 151 /* Constructor */: + case 152 /* 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 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: // Interfaces cannot have parameter types that cannot be named 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 154 /* CallSignature */: + case 155 /* CallSignature */: // Interfaces cannot have parameter types that cannot be named 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 156 /* IndexSignature */: + case 157 /* IndexSignature */: // Interfaces cannot have parameter types that cannot be named return symbolAccessibilityResult.errorModuleName ? ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: if (ts.hasModifier(node.parent, 32 /* Static */)) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === 2 /* CannotBeNamed */ ? @@ -61432,7 +63840,7 @@ var ts; ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.parent.kind === 228 /* ClassDeclaration */) { + else if (node.parent.parent.kind === 229 /* 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 : @@ -61445,7 +63853,7 @@ var ts; ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 : ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1; } - case 227 /* FunctionDeclaration */: + case 228 /* 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 : @@ -61457,12 +63865,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 === 173 /* ObjectBindingPattern */) { + if (bindingPattern.kind === 174 /* ObjectBindingPattern */) { write("{"); emitCommaList(bindingPattern.elements, emitBindingElement); write("}"); } - else if (bindingPattern.kind === 174 /* ArrayBindingPattern */) { + else if (bindingPattern.kind === 175 /* ArrayBindingPattern */) { write("["); var elements = bindingPattern.elements; emitCommaList(elements, emitBindingElement); @@ -61473,7 +63881,7 @@ var ts; } } function emitBindingElement(bindingElement) { - if (bindingElement.kind === 199 /* OmittedExpression */) { + if (bindingElement.kind === 200 /* 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) @@ -61482,7 +63890,7 @@ var ts; // emit : function foo([ , x, , ]) {} write(" "); } - else if (bindingElement.kind === 175 /* BindingElement */) { + else if (bindingElement.kind === 176 /* 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" @@ -61505,7 +63913,7 @@ var ts; emitBindingPattern(bindingElement.name); } else { - ts.Debug.assert(bindingElement.name.kind === 70 /* Identifier */); + ts.Debug.assert(bindingElement.name.kind === 71 /* Identifier */); // If the node is just an identifier, we will simply emit the text associated with the node's name // Example: // original: function foo({y = 10, x}) {} @@ -61521,40 +63929,40 @@ var ts; } function emitNode(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: - case 232 /* ModuleDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 229 /* InterfaceDeclaration */: - case 228 /* ClassDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 231 /* EnumDeclaration */: + case 228 /* FunctionDeclaration */: + case 233 /* ModuleDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 230 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 232 /* EnumDeclaration */: return emitModuleElement(node, isModuleElementVisible(node)); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return emitModuleElement(node, isVariableStatementVisible(node)); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: // Import declaration without import clause is visible, otherwise it is not visible return emitModuleElement(node, /*isModuleElementVisible*/ !node.importClause); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return emitExportDeclaration(node); - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return writeFunctionDeclaration(node); - case 155 /* ConstructSignature */: - case 154 /* CallSignature */: - case 156 /* IndexSignature */: + case 156 /* ConstructSignature */: + case 155 /* CallSignature */: + case 157 /* IndexSignature */: return emitSignatureDeclarationWithJsDocComments(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return emitAccessorDeclaration(node); - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return emitPropertyDeclaration(node); - case 263 /* EnumMember */: + case 264 /* EnumMember */: return emitEnumMemberDeclaration(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return emitExportAssignment(node); - case 264 /* SourceFile */: + case 265 /* SourceFile */: return emitSourceFile(node); } } @@ -61582,7 +63990,7 @@ var ts; return addedBundledEmitReference; function getDeclFileName(emitFileNames, sourceFileOrBundle) { // Dont add reference path to this file if it is a bundled emit and caller asked not emit bundled file path - var isBundledEmit = sourceFileOrBundle.kind === 265 /* Bundle */; + var isBundledEmit = sourceFileOrBundle.kind === 266 /* Bundle */; if (isBundledEmit && !addBundledFileReference) { return; } @@ -61597,7 +64005,7 @@ var ts; var emitDeclarationResult = emitDeclarations(host, resolver, emitterDiagnostics, declarationFilePath, sourceFileOrBundle, emitOnlyDtsFiles); var emitSkipped = emitDeclarationResult.reportedDeclarationError || host.isEmitBlocked(declarationFilePath) || host.getCompilerOptions().noEmit; if (!emitSkipped) { - var sourceFiles = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; + var sourceFiles = sourceFileOrBundle.kind === 266 /* Bundle */ ? sourceFileOrBundle.sourceFiles : [sourceFileOrBundle]; var declarationOutput = emitDeclarationResult.referencesOutput + getDeclarationOutput(emitDeclarationResult.synchronousDeclarationOutput, emitDeclarationResult.moduleElementDeclarationEmitInfo); ts.writeFile(host, emitterDiagnostics, declarationFilePath, declarationOutput, host.getCompilerOptions().emitBOM, sourceFiles); @@ -61631,14 +64039,13 @@ var ts; var brackets = createBracketsMap(); /*@internal*/ // 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, emitOnlyDtsFiles) { + function emitFiles(resolver, host, targetSourceFile, emitOnlyDtsFiles, transformers) { var compilerOptions = host.getCompilerOptions(); var moduleKind = ts.getEmitModuleKind(compilerOptions); var sourceMapDataList = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined; var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined; var emitterDiagnostics = ts.createDiagnosticCollection(); var newLine = host.getNewLine(); - var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(compilerOptions); var writer = ts.createTextWriter(newLine); var sourceMap = ts.createSourceMapWriter(host, writer); var currentSourceFile; @@ -61647,14 +64054,14 @@ var ts; var emitSkipped = false; var sourceFiles = ts.getSourceFilesToEmit(host, targetSourceFile); // Transform the source files - var transform = ts.transformFiles(resolver, host, sourceFiles, transformers); + var transform = ts.transformNodes(resolver, host, compilerOptions, sourceFiles, transformers, /*allowDtsFiles*/ false); // Create a printer to print the nodes var printer = createPrinter(compilerOptions, { // resolver hooks hasGlobalName: resolver.hasGlobalName, // transform hooks onEmitNode: transform.emitNodeWithNotification, - onSubstituteNode: transform.emitNodeWithSubstitution, + substituteNode: transform.substituteNode, // sourcemap hooks onEmitSourceMapOfNode: sourceMap.emitNodeWithSourceMap, onEmitSourceMapOfToken: sourceMap.emitTokenWithSourceMap, @@ -61668,10 +64075,7 @@ var ts; ts.forEachEmittedFile(host, emitSourceFileOrBundle, transform.transformed, emitOnlyDtsFiles); ts.performance.measure("printTime", "beforePrint"); // Clean up emit nodes on parse tree - for (var _a = 0, sourceFiles_2 = sourceFiles; _a < sourceFiles_2.length; _a++) { - var sourceFile = sourceFiles_2[_a]; - ts.disposeEmitNodes(sourceFile); - } + transform.dispose(); return { emitSkipped: emitSkipped, diagnostics: emitterDiagnostics.getDiagnostics(), @@ -61705,8 +64109,8 @@ var ts; } } function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle) { - var bundle = sourceFileOrBundle.kind === 265 /* Bundle */ ? sourceFileOrBundle : undefined; - var sourceFile = sourceFileOrBundle.kind === 264 /* SourceFile */ ? sourceFileOrBundle : undefined; + var bundle = sourceFileOrBundle.kind === 266 /* Bundle */ ? sourceFileOrBundle : undefined; + var sourceFile = sourceFileOrBundle.kind === 265 /* SourceFile */ ? sourceFileOrBundle : undefined; var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile]; sourceMap.initialize(jsFilePath, sourceMapFilePath, sourceFileOrBundle); if (bundle) { @@ -61746,7 +64150,7 @@ var ts; } function emitHelpers(node, writeLines) { var helpersEmitted = false; - var bundle = node.kind === 265 /* Bundle */ ? node : undefined; + var bundle = node.kind === 266 /* Bundle */ ? node : undefined; if (bundle && moduleKind === ts.ModuleKind.None) { return; } @@ -61791,9 +64195,8 @@ var ts; function createPrinter(printerOptions, handlers) { if (printerOptions === void 0) { printerOptions = {}; } if (handlers === void 0) { handlers = {}; } - var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, onSubstituteNode = handlers.onSubstituteNode; + var hasGlobalName = handlers.hasGlobalName, onEmitSourceMapOfNode = handlers.onEmitSourceMapOfNode, onEmitSourceMapOfToken = handlers.onEmitSourceMapOfToken, onEmitSourceMapOfPosition = handlers.onEmitSourceMapOfPosition, onEmitNode = handlers.onEmitNode, onEmitHelpers = handlers.onEmitHelpers, onSetSourceFile = handlers.onSetSourceFile, substituteNode = handlers.substituteNode, onBeforeEmitNodeArray = handlers.onBeforeEmitNodeArray, onAfterEmitNodeArray = handlers.onAfterEmitNodeArray; var newLine = ts.getNewLineCharacter(printerOptions); - var languageVersion = ts.getEmitScriptTarget(printerOptions); var comments = ts.createCommentWriter(printerOptions, onEmitSourceMapOfPosition); var emitNodeWithComments = comments.emitNodeWithComments, emitBodyWithDetachedComments = comments.emitBodyWithDetachedComments, emitTrailingCommentsOfPosition = comments.emitTrailingCommentsOfPosition, emitLeadingCommentsOfPosition = comments.emitLeadingCommentsOfPosition; var currentSourceFile; @@ -61828,8 +64231,8 @@ var ts; break; } switch (node.kind) { - case 264 /* SourceFile */: return printFile(node); - case 265 /* Bundle */: return printBundle(node); + case 265 /* SourceFile */: return printFile(node); + case 266 /* Bundle */: return printBundle(node); } writeNode(hint, node, sourceFile, beginPrint()); return endPrint(); @@ -61852,6 +64255,8 @@ var ts; function writeBundle(bundle, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(bundle); + emitPrologueDirectivesIfNeeded(bundle); emitHelpersIndirect(bundle); for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) { var sourceFile = _b[_a]; @@ -61863,6 +64268,8 @@ var ts; function writeFile(sourceFile, output) { var previousWriter = writer; setWriter(output); + emitShebangIfNeeded(sourceFile); + emitPrologueDirectivesIfNeeded(sourceFile); print(0 /* SourceFile */, sourceFile, sourceFile); reset(); writer = previousWriter; @@ -61899,9 +64306,8 @@ var ts; comments.reset(); setWriter(/*output*/ undefined); } - function emit(node, hint) { - if (hint === void 0) { hint = 3 /* Unspecified */; } - pipelineEmitWithNotification(hint, node); + function emit(node) { + pipelineEmitWithNotification(3 /* Unspecified */, node); } function emitIdentifierName(node) { pipelineEmitWithNotification(2 /* IdentifierName */, node); @@ -61918,6 +64324,7 @@ var ts; } } function pipelineEmitWithComments(hint, node) { + node = trySubstituteNode(hint, node); if (emitNodeWithComments && hint !== 0 /* SourceFile */) { emitNodeWithComments(hint, node, pipelineEmitWithSourceMap); } @@ -61927,15 +64334,7 @@ var ts; } function pipelineEmitWithSourceMap(hint, node) { if (onEmitSourceMapOfNode && hint !== 0 /* SourceFile */ && hint !== 2 /* IdentifierName */) { - onEmitSourceMapOfNode(hint, node, pipelineEmitWithSubstitution); - } - else { - pipelineEmitWithSubstitution(hint, node); - } - } - function pipelineEmitWithSubstitution(hint, node) { - if (onSubstituteNode) { - onSubstituteNode(hint, node, pipelineEmitWithHint); + onEmitSourceMapOfNode(hint, node, pipelineEmitWithHint); } else { pipelineEmitWithHint(hint, node); @@ -61968,217 +64367,221 @@ var ts; } switch (kind) { // Pseudo-literals - case 13 /* TemplateHead */: - case 14 /* TemplateMiddle */: - case 15 /* TemplateTail */: + case 14 /* TemplateHead */: + case 15 /* TemplateMiddle */: + case 16 /* TemplateTail */: return emitLiteral(node); // Identifiers - case 70 /* Identifier */: + case 71 /* Identifier */: return emitIdentifier(node); // Parse tree nodes // Names - case 142 /* QualifiedName */: + case 143 /* QualifiedName */: return emitQualifiedName(node); - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return emitComputedPropertyName(node); // Signature elements - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: return emitTypeParameter(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return emitParameter(node); - case 146 /* Decorator */: + case 147 /* Decorator */: return emitDecorator(node); // Type members - case 147 /* PropertySignature */: + case 148 /* PropertySignature */: return emitPropertySignature(node); - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: return emitPropertyDeclaration(node); - case 149 /* MethodSignature */: + case 150 /* MethodSignature */: return emitMethodSignature(node); - case 150 /* MethodDeclaration */: + case 151 /* MethodDeclaration */: return emitMethodDeclaration(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return emitConstructor(node); - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return emitAccessorDeclaration(node); - case 154 /* CallSignature */: + case 155 /* CallSignature */: return emitCallSignature(node); - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: return emitConstructSignature(node); - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return emitIndexSignature(node); // Types - case 157 /* TypePredicate */: + case 158 /* TypePredicate */: return emitTypePredicate(node); - case 158 /* TypeReference */: + case 159 /* TypeReference */: return emitTypeReference(node); - case 159 /* FunctionType */: + case 160 /* FunctionType */: return emitFunctionType(node); - case 160 /* ConstructorType */: + case 161 /* ConstructorType */: return emitConstructorType(node); - case 161 /* TypeQuery */: + case 162 /* TypeQuery */: return emitTypeQuery(node); - case 162 /* TypeLiteral */: + case 163 /* TypeLiteral */: return emitTypeLiteral(node); - case 163 /* ArrayType */: + case 164 /* ArrayType */: return emitArrayType(node); - case 164 /* TupleType */: + case 165 /* TupleType */: return emitTupleType(node); - case 165 /* UnionType */: + case 166 /* UnionType */: return emitUnionType(node); - case 166 /* IntersectionType */: + case 167 /* IntersectionType */: return emitIntersectionType(node); - case 167 /* ParenthesizedType */: + case 168 /* ParenthesizedType */: return emitParenthesizedType(node); - case 200 /* ExpressionWithTypeArguments */: + case 201 /* ExpressionWithTypeArguments */: return emitExpressionWithTypeArguments(node); - case 168 /* ThisType */: + case 169 /* ThisType */: return emitThisType(); - case 169 /* TypeOperator */: + case 170 /* TypeOperator */: return emitTypeOperator(node); - case 170 /* IndexedAccessType */: + case 171 /* IndexedAccessType */: return emitIndexedAccessType(node); - case 171 /* MappedType */: + case 172 /* MappedType */: return emitMappedType(node); - case 172 /* LiteralType */: + case 173 /* LiteralType */: return emitLiteralType(node); // Binding patterns - case 173 /* ObjectBindingPattern */: + case 174 /* ObjectBindingPattern */: return emitObjectBindingPattern(node); - case 174 /* ArrayBindingPattern */: + case 175 /* ArrayBindingPattern */: return emitArrayBindingPattern(node); - case 175 /* BindingElement */: + case 176 /* BindingElement */: return emitBindingElement(node); // Misc - case 204 /* TemplateSpan */: + case 205 /* TemplateSpan */: return emitTemplateSpan(node); - case 205 /* SemicolonClassElement */: + case 206 /* SemicolonClassElement */: return emitSemicolonClassElement(); // Statements - case 206 /* Block */: + case 207 /* Block */: return emitBlock(node); - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: return emitVariableStatement(node); - case 208 /* EmptyStatement */: + case 209 /* EmptyStatement */: return emitEmptyStatement(); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: return emitExpressionStatement(node); - case 210 /* IfStatement */: + case 211 /* IfStatement */: return emitIfStatement(node); - case 211 /* DoStatement */: + case 212 /* DoStatement */: return emitDoStatement(node); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: return emitWhileStatement(node); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return emitForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: return emitForInStatement(node); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: return emitForOfStatement(node); - case 216 /* ContinueStatement */: + case 217 /* ContinueStatement */: return emitContinueStatement(node); - case 217 /* BreakStatement */: + case 218 /* BreakStatement */: return emitBreakStatement(node); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: return emitReturnStatement(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: return emitWithStatement(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return emitSwitchStatement(node); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: return emitLabeledStatement(node); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: return emitThrowStatement(node); - case 223 /* TryStatement */: + case 224 /* TryStatement */: return emitTryStatement(node); - case 224 /* DebuggerStatement */: + case 225 /* DebuggerStatement */: return emitDebuggerStatement(node); // Declarations - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: return emitVariableDeclaration(node); - case 226 /* VariableDeclarationList */: + case 227 /* VariableDeclarationList */: return emitVariableDeclarationList(node); - case 227 /* FunctionDeclaration */: + case 228 /* FunctionDeclaration */: return emitFunctionDeclaration(node); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: return emitClassDeclaration(node); - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return emitInterfaceDeclaration(node); - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: return emitTypeAliasDeclaration(node); - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: return emitEnumDeclaration(node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return emitModuleDeclaration(node); - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: return emitModuleBlock(node); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return emitCaseBlock(node); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: return emitImportEqualsDeclaration(node); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: return emitImportDeclaration(node); - case 238 /* ImportClause */: + case 239 /* ImportClause */: return emitImportClause(node); - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: return emitNamespaceImport(node); - case 240 /* NamedImports */: + case 241 /* NamedImports */: return emitNamedImports(node); - case 241 /* ImportSpecifier */: + case 242 /* ImportSpecifier */: return emitImportSpecifier(node); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: return emitExportAssignment(node); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: return emitExportDeclaration(node); - case 244 /* NamedExports */: + case 245 /* NamedExports */: return emitNamedExports(node); - case 245 /* ExportSpecifier */: + case 246 /* ExportSpecifier */: return emitExportSpecifier(node); - case 246 /* MissingDeclaration */: + case 247 /* MissingDeclaration */: return; // Module references - case 247 /* ExternalModuleReference */: + case 248 /* ExternalModuleReference */: return emitExternalModuleReference(node); // JSX (non-expression) case 10 /* JsxText */: return emitJsxText(node); - case 250 /* JsxOpeningElement */: + case 251 /* JsxOpeningElement */: return emitJsxOpeningElement(node); - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: return emitJsxClosingElement(node); - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: return emitJsxAttribute(node); - case 253 /* JsxAttributes */: + case 254 /* JsxAttributes */: return emitJsxAttributes(node); - case 254 /* JsxSpreadAttribute */: + case 255 /* JsxSpreadAttribute */: return emitJsxSpreadAttribute(node); - case 255 /* JsxExpression */: + case 256 /* JsxExpression */: return emitJsxExpression(node); // Clauses - case 256 /* CaseClause */: + case 257 /* CaseClause */: return emitCaseClause(node); - case 257 /* DefaultClause */: + case 258 /* DefaultClause */: return emitDefaultClause(node); - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: return emitHeritageClause(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return emitCatchClause(node); // Property assignments - case 260 /* PropertyAssignment */: + case 261 /* PropertyAssignment */: return emitPropertyAssignment(node); - case 261 /* ShorthandPropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: return emitShorthandPropertyAssignment(node); - case 262 /* SpreadAssignment */: + case 263 /* SpreadAssignment */: return emitSpreadAssignment(node); // Enum - case 263 /* EnumMember */: + case 264 /* EnumMember */: return emitEnumMember(node); } // If the node is an expression, try to emit it as an expression with // substitution. if (ts.isExpression(node)) { - return pipelineEmitWithSubstitution(1 /* Expression */, node); + return pipelineEmitExpression(trySubstituteNode(1 /* Expression */, node)); + } + if (ts.isToken(node)) { + writeTokenText(kind); + return; } } function pipelineEmitExpression(node) { @@ -62188,92 +64591,87 @@ var ts; case 8 /* NumericLiteral */: return emitNumericLiteral(node); case 9 /* StringLiteral */: - case 11 /* RegularExpressionLiteral */: - case 12 /* NoSubstitutionTemplateLiteral */: + case 12 /* RegularExpressionLiteral */: + case 13 /* NoSubstitutionTemplateLiteral */: return emitLiteral(node); // Identifiers - case 70 /* Identifier */: + case 71 /* Identifier */: return emitIdentifier(node); // Reserved words - case 85 /* FalseKeyword */: - case 94 /* NullKeyword */: - case 96 /* SuperKeyword */: - case 100 /* TrueKeyword */: - case 98 /* ThisKeyword */: + case 86 /* FalseKeyword */: + case 95 /* NullKeyword */: + case 97 /* SuperKeyword */: + case 101 /* TrueKeyword */: + case 99 /* ThisKeyword */: writeTokenText(kind); return; // Expressions - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return emitArrayLiteralExpression(node); - case 177 /* ObjectLiteralExpression */: + case 178 /* ObjectLiteralExpression */: return emitObjectLiteralExpression(node); - case 178 /* PropertyAccessExpression */: + case 179 /* PropertyAccessExpression */: return emitPropertyAccessExpression(node); - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return emitElementAccessExpression(node); - case 180 /* CallExpression */: + case 181 /* CallExpression */: return emitCallExpression(node); - case 181 /* NewExpression */: + case 182 /* NewExpression */: return emitNewExpression(node); - case 182 /* TaggedTemplateExpression */: + case 183 /* TaggedTemplateExpression */: return emitTaggedTemplateExpression(node); - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: return emitTypeAssertionExpression(node); - case 184 /* ParenthesizedExpression */: + case 185 /* ParenthesizedExpression */: return emitParenthesizedExpression(node); - case 185 /* FunctionExpression */: + case 186 /* FunctionExpression */: return emitFunctionExpression(node); - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: return emitArrowFunction(node); - case 187 /* DeleteExpression */: + case 188 /* DeleteExpression */: return emitDeleteExpression(node); - case 188 /* TypeOfExpression */: + case 189 /* TypeOfExpression */: return emitTypeOfExpression(node); - case 189 /* VoidExpression */: + case 190 /* VoidExpression */: return emitVoidExpression(node); - case 190 /* AwaitExpression */: + case 191 /* AwaitExpression */: return emitAwaitExpression(node); - case 191 /* PrefixUnaryExpression */: + case 192 /* PrefixUnaryExpression */: return emitPrefixUnaryExpression(node); - case 192 /* PostfixUnaryExpression */: + case 193 /* PostfixUnaryExpression */: return emitPostfixUnaryExpression(node); - case 193 /* BinaryExpression */: + case 194 /* BinaryExpression */: return emitBinaryExpression(node); - case 194 /* ConditionalExpression */: + case 195 /* ConditionalExpression */: return emitConditionalExpression(node); - case 195 /* TemplateExpression */: + case 196 /* TemplateExpression */: return emitTemplateExpression(node); - case 196 /* YieldExpression */: + case 197 /* YieldExpression */: return emitYieldExpression(node); - case 197 /* SpreadElement */: + case 198 /* SpreadElement */: return emitSpreadExpression(node); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return emitClassExpression(node); - case 199 /* OmittedExpression */: + case 200 /* OmittedExpression */: return; - case 201 /* AsExpression */: + case 202 /* AsExpression */: return emitAsExpression(node); - case 202 /* NonNullExpression */: + case 203 /* NonNullExpression */: return emitNonNullExpression(node); - case 203 /* MetaProperty */: + case 204 /* MetaProperty */: return emitMetaProperty(node); // JSX - case 248 /* JsxElement */: + case 249 /* JsxElement */: return emitJsxElement(node); - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: return emitJsxSelfClosingElement(node); // Transformation nodes - case 298 /* PartiallyEmittedExpression */: + case 296 /* PartiallyEmittedExpression */: return emitPartiallyEmittedExpression(node); } } - function emitBodyIndirect(node, elements, emitCallback) { - if (emitBodyWithDetachedComments) { - emitBodyWithDetachedComments(node, elements, emitCallback); - } - else { - emitCallback(node); - } + function trySubstituteNode(hint, node) { + return node && substituteNode && substituteNode(hint, node) || node; } function emitHelpersIndirect(node) { if (onEmitHelpers) { @@ -62286,9 +64684,6 @@ var ts; // SyntaxKind.NumericLiteral function emitNumericLiteral(node) { emitLiteral(node); - if (node.trailingComment) { - write(" /*" + node.trailingComment + "*/"); - } } // SyntaxKind.StringLiteral // SyntaxKind.RegularExpressionLiteral @@ -62321,7 +64716,7 @@ var ts; emit(node.right); } function emitEntityName(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { emitExpression(node); } else { @@ -62346,8 +64741,8 @@ var ts; writeIfPresent(node.dotDotDotToken, "..."); emit(node.name); writeIfPresent(node.questionToken, "?"); - emitExpressionWithPrefix(" = ", node.initializer); emitWithPrefix(": ", node.type); + emitExpressionWithPrefix(" = ", node.initializer); } function emitDecorator(decorator) { write("@"); @@ -62397,7 +64792,7 @@ var ts; function emitAccessorDeclaration(node) { emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); - write(node.kind === 152 /* GetAccessor */ ? "get " : "set "); + write(node.kind === 153 /* GetAccessor */ ? "get " : "set "); emit(node.name); emitSignatureAndBody(node, emitSignatureHead); } @@ -62567,12 +64962,12 @@ var ts; write("{}"); } else { - var indentedFlag = ts.getEmitFlags(node) & 32768 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; if (indentedFlag) { increaseIndent(); } var preferNewLine = node.multiLine ? 32768 /* PreferNewLine */ : 0 /* None */; - var allowTrailingComma = languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; + var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ ? 32 /* AllowTrailingComma */ : 0 /* None */; emitList(node, properties, 978 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine); if (indentedFlag) { decreaseIndent(); @@ -62582,10 +64977,10 @@ var ts; function emitPropertyAccessExpression(node) { var indentBeforeDot = false; var indentAfterDot = false; - if (!(ts.getEmitFlags(node) & 65536 /* NoIndentation */)) { + if (!(ts.getEmitFlags(node) & 131072 /* NoIndentation */)) { var dotRangeStart = node.expression.end; var dotRangeEnd = ts.skipTrivia(currentSourceFile.text, node.expression.end) + 1; - var dotToken = { kind: 22 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; + var dotToken = { kind: 23 /* DotToken */, pos: dotRangeStart, end: dotRangeEnd }; indentBeforeDot = needsIndentation(node, node.expression, dotToken); indentAfterDot = needsIndentation(node, dotToken, node.name); } @@ -62600,12 +64995,12 @@ var ts; // 1..toString is a valid property access, emit a dot after the literal // Also emit a dot if expression is a integer const enum value - it will appear in generated code as numeric literal function needsDotDotForPropertyAccess(expression) { - if (expression.kind === 8 /* NumericLiteral */) { + expression = ts.skipPartiallyEmittedExpressions(expression); + if (ts.isNumericLiteral(expression)) { // check if numeric literal is a decimal literal that was originally written with a dot var text = getLiteralTextOfNode(expression); - return ts.getNumericLiteralFlags(text, /*hint*/ 15 /* All */) === 0 /* None */ - && !expression.isOctalLiteral - && text.indexOf(ts.tokenToString(22 /* DotToken */)) < 0; + return !expression.numericLiteralFlags + && text.indexOf(ts.tokenToString(23 /* DotToken */)) < 0; } else if (ts.isPropertyAccessExpression(expression) || ts.isElementAccessExpression(expression)) { // check if constant enum value is integer @@ -62700,16 +65095,16 @@ var ts; // expression a prefix increment whose operand is a plus expression - (++(+x)) // The same is true of minus of course. var operand = node.operand; - return operand.kind === 191 /* PrefixUnaryExpression */ - && ((node.operator === 36 /* PlusToken */ && (operand.operator === 36 /* PlusToken */ || operand.operator === 42 /* PlusPlusToken */)) - || (node.operator === 37 /* MinusToken */ && (operand.operator === 37 /* MinusToken */ || operand.operator === 43 /* MinusMinusToken */))); + return operand.kind === 192 /* PrefixUnaryExpression */ + && ((node.operator === 37 /* PlusToken */ && (operand.operator === 37 /* PlusToken */ || operand.operator === 43 /* PlusPlusToken */)) + || (node.operator === 38 /* MinusToken */ && (operand.operator === 38 /* MinusToken */ || operand.operator === 44 /* MinusMinusToken */))); } function emitPostfixUnaryExpression(node) { emitExpression(node.operand); writeTokenText(node.operator); } function emitBinaryExpression(node) { - var isCommaOperator = node.operatorToken.kind !== 25 /* CommaToken */; + var isCommaOperator = node.operatorToken.kind !== 26 /* CommaToken */; var indentBeforeOperator = needsIndentation(node, node.left, node.operatorToken); var indentAfterOperator = needsIndentation(node, node.operatorToken, node.right); emitExpression(node.left); @@ -62783,18 +65178,18 @@ var ts; // function emitBlock(node) { if (isSingleLineEmptyBlock(node)) { - writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); write(" "); - writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } else { - writeToken(16 /* OpenBraceToken */, node.pos, /*contextNode*/ node); + writeToken(17 /* OpenBraceToken */, node.pos, /*contextNode*/ node); emitBlockStatements(node); // We have to call emitLeadingComments explicitly here because otherwise leading comments of the close brace token will not be emitted increaseIndent(); emitLeadingCommentsOfPosition(node.statements.end); decreaseIndent(); - writeToken(17 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); + writeToken(18 /* CloseBraceToken */, node.statements.end, /*contextNode*/ node); } } function emitBlockStatements(node) { @@ -62818,16 +65213,16 @@ var ts; write(";"); } function emitIfStatement(node) { - var openParenPos = writeToken(89 /* IfKeyword */, node.pos, node); + var openParenPos = writeToken(90 /* IfKeyword */, node.pos, node); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos, node); + writeToken(19 /* OpenParenToken */, openParenPos, node); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end, node); + writeToken(20 /* CloseParenToken */, node.expression.end, node); emitEmbeddedStatement(node, node.thenStatement); if (node.elseStatement) { writeLineOrSpace(node); - writeToken(81 /* ElseKeyword */, node.thenStatement.end, node); - if (node.elseStatement.kind === 210 /* IfStatement */) { + writeToken(82 /* ElseKeyword */, node.thenStatement.end, node); + if (node.elseStatement.kind === 211 /* IfStatement */) { write(" "); emit(node.elseStatement); } @@ -62856,9 +65251,9 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForStatement(node) { - var openParenPos = writeToken(87 /* ForKeyword */, node.pos); + var openParenPos = writeToken(88 /* ForKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos, /*contextNode*/ node); + writeToken(19 /* OpenParenToken */, openParenPos, /*contextNode*/ node); emitForBinding(node.initializer); write(";"); emitExpressionWithPrefix(" ", node.condition); @@ -62868,28 +65263,29 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitForInStatement(node) { - var openParenPos = writeToken(87 /* ForKeyword */, node.pos); + var openParenPos = writeToken(88 /* ForKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + writeToken(19 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" in "); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end); + writeToken(20 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForOfStatement(node) { - var openParenPos = writeToken(87 /* ForKeyword */, node.pos); + var openParenPos = writeToken(88 /* ForKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + emitWithSuffix(node.awaitModifier, " "); + writeToken(19 /* OpenParenToken */, openParenPos); emitForBinding(node.initializer); write(" of "); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end); + writeToken(20 /* CloseParenToken */, node.expression.end); emitEmbeddedStatement(node, node.statement); } function emitForBinding(node) { if (node !== undefined) { - if (node.kind === 226 /* VariableDeclarationList */) { + if (node.kind === 227 /* VariableDeclarationList */) { emit(node); } else { @@ -62898,17 +65294,17 @@ var ts; } } function emitContinueStatement(node) { - writeToken(76 /* ContinueKeyword */, node.pos); + writeToken(77 /* ContinueKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitBreakStatement(node) { - writeToken(71 /* BreakKeyword */, node.pos); + writeToken(72 /* BreakKeyword */, node.pos); emitWithPrefix(" ", node.label); write(";"); } function emitReturnStatement(node) { - writeToken(95 /* ReturnKeyword */, node.pos, /*contextNode*/ node); + writeToken(96 /* ReturnKeyword */, node.pos, /*contextNode*/ node); emitExpressionWithPrefix(" ", node.expression); write(";"); } @@ -62919,11 +65315,11 @@ var ts; emitEmbeddedStatement(node, node.statement); } function emitSwitchStatement(node) { - var openParenPos = writeToken(97 /* SwitchKeyword */, node.pos); + var openParenPos = writeToken(98 /* SwitchKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + writeToken(19 /* OpenParenToken */, openParenPos); emitExpression(node.expression); - writeToken(19 /* CloseParenToken */, node.expression.end); + writeToken(20 /* CloseParenToken */, node.expression.end); write(" "); emit(node.caseBlock); } @@ -62951,7 +65347,7 @@ var ts; } } function emitDebuggerStatement(node) { - writeToken(77 /* DebuggerKeyword */, node.pos); + writeToken(78 /* DebuggerKeyword */, node.pos); write(";"); } // @@ -62976,22 +65372,35 @@ var ts; emitIdentifierName(node.name); emitSignatureAndBody(node, emitSignatureHead); } + function emitBlockCallback(_hint, body) { + emitBlockFunctionBody(body); + } function emitSignatureAndBody(node, emitSignatureHead) { var body = node.body; if (body) { if (ts.isBlock(body)) { - var indentedFlag = ts.getEmitFlags(node) & 32768 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; if (indentedFlag) { increaseIndent(); } - if (ts.getEmitFlags(node) & 262144 /* ReuseTempVariableScope */) { + if (ts.getEmitFlags(node) & 524288 /* ReuseTempVariableScope */) { emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } } else { pushNameGenerationScope(); emitSignatureHead(node); - emitBlockFunctionBody(body); + if (onEmitNode) { + onEmitNode(3 /* Unspecified */, body, emitBlockCallback); + } + else { + emitBlockFunctionBody(body); + } popNameGenerationScope(); } if (indentedFlag) { @@ -63050,9 +65459,14 @@ var ts; var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body) ? emitBlockFunctionBodyOnSingleLine : emitBlockFunctionBodyWorker; - emitBodyIndirect(body, body.statements, emitBlockFunctionBody); + if (emitBodyWithDetachedComments) { + emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody); + } + else { + emitBlockFunctionBody(body); + } decreaseIndent(); - writeToken(17 /* CloseBraceToken */, body.statements.end, body); + writeToken(18 /* CloseBraceToken */, body.statements.end, body); } function emitBlockFunctionBodyOnSingleLine(body) { emitBlockFunctionBodyWorker(body, /*emitBlockFunctionBodyOnSingleLine*/ true); @@ -63079,7 +65493,7 @@ var ts; emitModifiers(node, node.modifiers); write("class"); emitNodeWithPrefix(" ", node.name, emitIdentifierName); - var indentedFlag = ts.getEmitFlags(node) & 32768 /* Indented */; + var indentedFlag = ts.getEmitFlags(node) & 65536 /* Indented */; if (indentedFlag) { increaseIndent(); } @@ -63130,7 +65544,7 @@ var ts; write(node.flags & 16 /* Namespace */ ? "namespace " : "module "); emit(node.name); var body = node.body; - while (body.kind === 232 /* ModuleDeclaration */) { + while (body.kind === 233 /* ModuleDeclaration */) { write("."); emit(body.name); body = body.body; @@ -63145,16 +65559,15 @@ var ts; else { pushNameGenerationScope(); write("{"); - increaseIndent(); emitBlockStatements(node); write("}"); popNameGenerationScope(); } } function emitCaseBlock(node) { - writeToken(16 /* OpenBraceToken */, node.pos); + writeToken(17 /* OpenBraceToken */, node.pos); emitList(node, node.clauses, 65 /* CaseBlockClauses */); - writeToken(17 /* CloseBraceToken */, node.clauses.end); + writeToken(18 /* CloseBraceToken */, node.clauses.end); } function emitImportEqualsDeclaration(node) { emitModifiers(node, node.modifiers); @@ -63165,7 +65578,7 @@ var ts; write(";"); } function emitModuleReference(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { emitExpression(node); } else { @@ -63303,7 +65716,7 @@ var ts; } } function emitJsxTagName(node) { - if (node.kind === 70 /* Identifier */) { + if (node.kind === 71 /* Identifier */) { emitExpression(node); } else { @@ -63345,11 +65758,11 @@ var ts; emitList(node, node.types, 272 /* HeritageClauseTypes */); } function emitCatchClause(node) { - var openParenPos = writeToken(73 /* CatchKeyword */, node.pos); + var openParenPos = writeToken(74 /* CatchKeyword */, node.pos); write(" "); - writeToken(18 /* OpenParenToken */, openParenPos); + writeToken(19 /* OpenParenToken */, openParenPos); emit(node.variableDeclaration); - writeToken(19 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); + writeToken(20 /* CloseParenToken */, node.variableDeclaration ? node.variableDeclaration.end : openParenPos); write(" "); emit(node.block); } @@ -63398,15 +65811,26 @@ var ts; // function emitSourceFile(node) { writeLine(); - emitShebang(); - emitBodyIndirect(node, node.statements, emitSourceFileWorker); + var statements = node.statements; + if (emitBodyWithDetachedComments) { + // Emit detached comment if there are no prologue directives or if the first node is synthesized. + // The synthesized node will have no leading comment so some comments may be missed. + var shouldEmitDetachedComment = statements.length === 0 || + !ts.isPrologueDirective(statements[0]) || + ts.nodeIsSynthesized(statements[0]); + if (shouldEmitDetachedComment) { + emitBodyWithDetachedComments(node, statements, emitSourceFileWorker); + return; + } + } + emitSourceFileWorker(node); } function emitSourceFileWorker(node) { var statements = node.statements; - var statementOffset = emitPrologueDirectives(statements); pushNameGenerationScope(); emitHelpersIndirect(node); - emitList(node, statements, 1 /* MultiLine */, statementOffset); + var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); }); + emitList(node, statements, 1 /* MultiLine */, index === -1 ? statements.length : index); popNameGenerationScope(); } // Transformation nodes @@ -63417,13 +65841,20 @@ var ts; * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. */ - function emitPrologueDirectives(statements, startWithNewLine) { + function emitPrologueDirectives(statements, startWithNewLine, seenPrologueDirectives) { for (var i = 0; i < statements.length; i++) { - if (ts.isPrologueDirective(statements[i])) { - if (startWithNewLine || i > 0) { - writeLine(); + var statement = statements[i]; + if (ts.isPrologueDirective(statement)) { + var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true; + if (shouldEmitPrologueDirective) { + if (startWithNewLine || i > 0) { + writeLine(); + } + emit(statement); + if (seenPrologueDirectives) { + seenPrologueDirectives.set(statement.expression.text, statement.expression.text); + } } - emit(statements[i]); } else { // return index of the first non prologue directive @@ -63432,16 +65863,42 @@ var ts; } return statements.length; } + function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + setSourceFile(sourceFileOrBundle); + emitPrologueDirectives(sourceFileOrBundle.statements); + } + else { + var seenPrologueDirectives = ts.createMap(); + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + setSourceFile(sourceFile); + emitPrologueDirectives(sourceFile.statements, /*startWithNewLine*/ true, seenPrologueDirectives); + } + } + } + function emitShebangIfNeeded(sourceFileOrBundle) { + if (ts.isSourceFile(sourceFileOrBundle)) { + var shebang = ts.getShebang(sourceFileOrBundle.text); + if (shebang) { + write(shebang); + writeLine(); + return true; + } + } + else { + for (var _a = 0, _b = sourceFileOrBundle.sourceFiles; _a < _b.length; _a++) { + var sourceFile = _b[_a]; + // Emit only the first encountered shebang + if (emitShebangIfNeeded(sourceFile)) { + break; + } + } + } + } // // Helpers // - function emitShebang() { - var shebang = ts.getShebang(currentSourceFile.text); - if (shebang) { - write(shebang); - writeLine(); - } - } function emitModifiers(node, modifiers) { if (modifiers && modifiers.length) { emitList(node, modifiers, 256 /* Modifiers */); @@ -63524,6 +65981,9 @@ var ts; if (format & 7680 /* BracketsMask */) { write(getOpeningBracket(format)); } + if (onBeforeEmitNodeArray) { + onBeforeEmitNodeArray(children); + } if (isEmpty) { // Write a line terminator if the parent node was multi-line if (format & 1 /* MultiLine */) { @@ -63624,6 +66084,9 @@ var ts; write(" "); } } + if (onAfterEmitNodeArray) { + onAfterEmitNodeArray(children); + } if (format & 7680 /* BracketsMask */) { write(getClosingBracket(format)); } @@ -63685,7 +66148,7 @@ var ts; for (var _a = 0, lines_1 = lines; _a < lines_1.length; _a++) { var line = lines_1[_a]; for (var i = 0; i < line.length && (indentation === undefined || i < indentation); i++) { - if (!ts.isWhiteSpace(line.charCodeAt(i))) { + if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) { if (indentation === undefined || i < indentation) { indentation = i; break; @@ -63813,7 +66276,7 @@ var ts; && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile); } function skipSynthesizedParentheses(node) { - while (node.kind === 184 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { + while (node.kind === 185 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) { node = node.expression; } return node; @@ -63843,7 +66306,7 @@ var ts; return getLiteralTextOfNode(textSourceNode); } } - return ts.getLiteralText(node, currentSourceFile, languageVersion); + return ts.getLiteralText(node, currentSourceFile); } /** * Push a new name generation scope. @@ -63991,23 +66454,23 @@ var ts; */ function generateNameForNode(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: return makeUniqueName(getTextOfNode(node)); - case 232 /* ModuleDeclaration */: - case 231 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: return generateNameForModuleOrEnum(node); - case 237 /* ImportDeclaration */: - case 243 /* ExportDeclaration */: + case 238 /* ImportDeclaration */: + case 244 /* ExportDeclaration */: return generateNameForImportOrExportDeclaration(node); - case 227 /* FunctionDeclaration */: - case 228 /* ClassDeclaration */: - case 242 /* ExportAssignment */: + case 228 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + case 243 /* ExportAssignment */: return generateNameForExportDefault(); - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: return generateNameForClassExpression(); - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return generateNameForMethodOrAccessor(node); default: return makeTempVariableName(0 /* Auto */); @@ -64157,6 +66620,7 @@ var ts; var ts; (function (ts) { var emptyArray = []; + var ignoreDiagnosticCommentRegEx = /(^\s*$)|(^\s*\/\/\/?\s*(@ts-ignore)?)/; function findConfigFile(searchPath, fileExists, configName) { if (configName === void 0) { configName = "tsconfig.json"; } while (true) { @@ -64225,8 +66689,6 @@ var ts; // otherwise use toLowerCase as a canonical form. return ts.sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase(); } - // returned by CScript sys environment - var unsupportedFileEncodingErrorCode = -2147024809; function getSourceFile(fileName, languageVersion, onError) { var text; try { @@ -64237,9 +66699,7 @@ var ts; } catch (e) { if (onError) { - onError(e.number === unsupportedFileEncodingErrorCode - ? ts.createCompilerDiagnostic(ts.Diagnostics.Unsupported_file_encoding).messageText - : e.message); + onError(e.message); } text = ""; } @@ -64403,6 +66863,8 @@ var ts; var diagnosticsProducingTypeChecker; var noDiagnosticsTypeChecker; var classifiableNames; + var cachedSemanticDiagnosticsForFile = {}; + var cachedDeclarationDiagnosticsForFile = {}; var resolvedTypeReferenceDirectives = ts.createMap(); var fileProcessingDiagnostics = ts.createDiagnosticCollection(); // The below settings are to track if a .js file should be add to the program if loaded via searching under node_modules. @@ -64622,7 +67084,7 @@ var ts; // combine results of resolutions and predicted results var j = 0; for (var i = 0; i < result.length; i++) { - if (result[i] == predictedToResolveToAmbientModuleMarker) { + if (result[i] === predictedToResolveToAmbientModuleMarker) { result[i] = undefined; } else { @@ -64795,13 +67257,13 @@ var ts; function getTypeChecker() { return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, /*produceDiagnostics:*/ false)); } - function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { - return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles); }); + function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers) { + return runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers); }); } function isEmitBlocked(emitFileName) { return hasEmitBlockingDiagnostics.contains(ts.toPath(emitFileName, currentDirectory, getCanonicalFileName)); } - function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles) { + function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers) { var declarationDiagnostics = []; if (options.noEmit) { return { diagnostics: declarationDiagnostics, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true }; @@ -64833,7 +67295,8 @@ var ts; // checked is to not pass the file to getEmitResolver. var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver((options.outFile || options.out) ? undefined : sourceFile); ts.performance.mark("beforeEmit"); - var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles); + var transformers = emitOnlyDtsFiles ? [] : ts.getTransformers(options, customTransformers); + var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, emitOnlyDtsFiles, transformers); ts.performance.mark("afterEmit"); ts.performance.measure("Emit", "beforeEmit", "afterEmit"); return emitResult; @@ -64906,19 +67369,54 @@ var ts; } } function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedSemanticDiagnosticsForFile, getSemanticDiagnosticsForFileNoCache); + } + function getSemanticDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { + // If skipLibCheck is enabled, skip reporting errors if file is a declaration file. + // If skipDefaultLibCheck is enabled, skip reporting errors if file contains a + // '/// ' directive. + if (options.skipLibCheck && sourceFile.isDeclarationFile || options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) { + return emptyArray; + } var typeChecker = getDiagnosticsProducingTypeChecker(); ts.Debug.assert(!!sourceFile.bindDiagnostics); var bindDiagnostics = sourceFile.bindDiagnostics; - // For JavaScript files, we don't want to report semantic errors. - // Instead, we'll report errors for using TypeScript-only constructs from within a - // JavaScript file when we get syntactic diagnostics for the file. - var checkDiagnostics = ts.isSourceFileJavaScript(sourceFile) ? [] : typeChecker.getDiagnostics(sourceFile, cancellationToken); + // For JavaScript files, we don't want to report semantic errors unless explicitly requested. + var includeCheckDiagnostics = !ts.isSourceFileJavaScript(sourceFile) || ts.isCheckJsEnabledForFile(sourceFile, options); + var checkDiagnostics = includeCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : []; var fileProcessingDiagnosticsInFile = fileProcessingDiagnostics.getDiagnostics(sourceFile.fileName); var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName); - return bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + var diagnostics = bindDiagnostics.concat(checkDiagnostics, fileProcessingDiagnosticsInFile, programDiagnosticsInFile); + return ts.isSourceFileJavaScript(sourceFile) + ? ts.filter(diagnostics, shouldReportDiagnostic) + : diagnostics; }); } + /** + * Skip errors if previous line start with '// @ts-ignore' comment, not counting non-empty non-comment lines + */ + function shouldReportDiagnostic(diagnostic) { + var file = diagnostic.file, start = diagnostic.start; + if (file) { + var lineStarts = ts.getLineStarts(file); + var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line; + while (line > 0) { + var previousLineText = file.text.slice(lineStarts[line - 1], lineStarts[line]); + var result = ignoreDiagnosticCommentRegEx.exec(previousLineText); + if (!result) { + // non-empty line + return true; + } + if (result[3]) { + // @ts-ignore + return false; + } + line--; + } + } + return true; + } function getJavaScriptSyntacticDiagnosticsForFile(sourceFile) { return runWithCancellationToken(function () { var diagnostics = []; @@ -64929,23 +67427,23 @@ var ts; // Return directly from the case if the given node doesnt want to visit each child // Otherwise break to visit each child switch (parent.kind) { - case 145 /* Parameter */: - case 148 /* PropertyDeclaration */: + case 146 /* Parameter */: + case 149 /* PropertyDeclaration */: if (parent.questionToken === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, "?")); return; } - // Pass through - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 225 /* VariableDeclaration */: + // falls through + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 226 /* VariableDeclaration */: // type annotation if (parent.type === node) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.types_can_only_be_used_in_a_ts_file)); @@ -64953,35 +67451,35 @@ var ts; } } switch (node.kind) { - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_a_ts_file)); return; - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: if (node.isExportEquals) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_a_ts_file)); return; } break; - case 258 /* HeritageClause */: + case 259 /* HeritageClause */: var heritageClause = node; - if (heritageClause.token === 107 /* ImplementsKeyword */) { + if (heritageClause.token === 108 /* ImplementsKeyword */) { diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_a_ts_file)); return; } break; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.interface_declarations_can_only_be_used_in_a_ts_file)); return; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.module_declarations_can_only_be_used_in_a_ts_file)); return; - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.type_aliases_can_only_be_used_in_a_ts_file)); return; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.enum_declarations_can_only_be_used_in_a_ts_file)); return; - case 183 /* TypeAssertionExpression */: + case 184 /* TypeAssertionExpression */: var typeAssertionExpression = node; diagnostics.push(createDiagnosticForNode(typeAssertionExpression.type, ts.Diagnostics.type_assertion_expressions_can_only_be_used_in_a_ts_file)); return; @@ -64996,50 +67494,50 @@ var ts; diagnostics.push(createDiagnosticForNode(parent, 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)); } switch (parent.kind) { - case 228 /* ClassDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: + case 229 /* ClassDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: // Check type parameters if (nodes === parent.typeParameters) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_parameter_declarations_can_only_be_used_in_a_ts_file)); return; } - // pass through - case 207 /* VariableStatement */: + // falls through + case 208 /* VariableStatement */: // Check modifiers if (nodes === parent.modifiers) { - return checkModifiers(nodes, parent.kind === 207 /* VariableStatement */); + return checkModifiers(nodes, parent.kind === 208 /* VariableStatement */); } break; - case 148 /* PropertyDeclaration */: + case 149 /* PropertyDeclaration */: // Check modifiers of property declaration if (nodes === parent.modifiers) { for (var _i = 0, _a = nodes; _i < _a.length; _i++) { var modifier = _a[_i]; - if (modifier.kind !== 114 /* StaticKeyword */) { + if (modifier.kind !== 115 /* StaticKeyword */) { diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); } } return; } break; - case 145 /* Parameter */: + case 146 /* Parameter */: // Check modifiers of parameter declaration if (nodes === parent.modifiers) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.parameter_modifiers_can_only_be_used_in_a_ts_file)); return; } break; - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 200 /* ExpressionWithTypeArguments */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 201 /* ExpressionWithTypeArguments */: // Check type arguments if (nodes === parent.typeArguments) { diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.type_arguments_can_only_be_used_in_a_ts_file)); @@ -65047,8 +67545,8 @@ var ts; } break; } - for (var _b = 0, nodes_6 = nodes; _b < nodes_6.length; _b++) { - var node = nodes_6[_b]; + for (var _b = 0, nodes_8 = nodes; _b < nodes_8.length; _b++) { + var node = nodes_8[_b]; walk(node); } } @@ -65056,23 +67554,24 @@ var ts; for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) { var modifier = modifiers_1[_i]; switch (modifier.kind) { - case 75 /* ConstKeyword */: + case 76 /* ConstKeyword */: if (isConstValid) { continue; } - // Fallthrough to report error - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - case 130 /* ReadonlyKeyword */: - case 123 /* DeclareKeyword */: - case 116 /* AbstractKeyword */: + // to report error, + // falls through + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + case 131 /* ReadonlyKeyword */: + case 124 /* DeclareKeyword */: + case 117 /* AbstractKeyword */: diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics._0_can_only_be_used_in_a_ts_file, ts.tokenToString(modifier.kind))); break; // These are all legal modifiers. - case 114 /* StaticKeyword */: - case 83 /* ExportKeyword */: - case 78 /* DefaultKeyword */: + case 115 /* StaticKeyword */: + case 84 /* ExportKeyword */: + case 79 /* DefaultKeyword */: } } } @@ -65088,12 +67587,34 @@ var ts; }); } function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) { + return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache); + } + function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) { return runWithCancellationToken(function () { var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken); // Don't actually write any files since we're just getting diagnostics. return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile); }); } + function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) { + var cachedResult = sourceFile + ? cache.perFile && cache.perFile.get(sourceFile.path) + : cache.allDiagnostics; + if (cachedResult) { + return cachedResult; + } + var result = getDiagnostics(sourceFile, cancellationToken) || emptyArray; + if (sourceFile) { + if (!cache.perFile) { + cache.perFile = ts.createFileMap(); + } + cache.perFile.set(sourceFile.path, result); + } + else { + cache.allDiagnostics = result; + } + return result; + } function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) { return ts.isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } @@ -65137,7 +67658,7 @@ var ts; && !file.isDeclarationFile) { // synthesize 'import "tslib"' declaration var externalHelpersModuleReference = ts.createLiteral(ts.externalHelpersModuleNameText); - var importDecl = ts.createImportDeclaration(undefined, undefined, undefined); + var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined); externalHelpersModuleReference.parent = importDecl; importDecl.parent = file; imports = [externalHelpersModuleReference]; @@ -65155,9 +67676,9 @@ var ts; return; function collectModuleReferences(node, inAmbientModule) { switch (node.kind) { - case 237 /* ImportDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 243 /* ExportDeclaration */: + case 238 /* ImportDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 244 /* ExportDeclaration */: var moduleNameExpr = ts.getExternalModuleName(node); if (!moduleNameExpr || moduleNameExpr.kind !== 9 /* StringLiteral */) { break; @@ -65172,7 +67693,7 @@ var ts; (imports || (imports = [])).push(moduleNameExpr); } break; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasModifier(node, 2 /* Ambient */) || ts.isDeclarationFile(file))) { var moduleName = node.name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. @@ -65272,7 +67793,7 @@ var ts; } // If the file was previously found via a node_modules search, but is now being processed as a root file, // then everything it sucks in may also be marked incorrectly, and needs to be checked again. - if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth == 0) { + if (file_1 && sourceFilesFoundSearchingNodeModules.get(file_1.path) && currentNodeModulesDepth === 0) { sourceFilesFoundSearchingNodeModules.set(file_1.path, false); if (!options.noResolve) { processReferencedFiles(file_1, isDefaultLib); @@ -65451,8 +67972,8 @@ var ts; } function computeCommonSourceDirectory(sourceFiles) { var fileNames = []; - for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { - var file = sourceFiles_3[_i]; + for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) { + var file = sourceFiles_2[_i]; if (!file.isDeclarationFile) { fileNames.push(file.fileName); } @@ -65463,8 +67984,8 @@ var ts; var allFilesBelongToPath = true; if (sourceFiles) { var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory)); - for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { - var sourceFile = sourceFiles_4[_i]; + for (var _i = 0, sourceFiles_3 = sourceFiles; _i < sourceFiles_3.length; _i++) { + var sourceFile = sourceFiles_3[_i]; if (!ts.isDeclarationFile(sourceFile)) { var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { @@ -65558,7 +68079,7 @@ var ts; if (options.lib && options.noLib) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib")); } - if (options.noImplicitUseStrict && options.alwaysStrict) { + if (options.noImplicitUseStrict && (options.alwaysStrict === undefined ? options.strict : options.alwaysStrict)) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict")); } var languageVersion = options.target || 0 /* ES3 */; @@ -65604,6 +68125,9 @@ var ts; if (!options.noEmit && options.allowJs && options.declaration) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "allowJs", "declaration")); } + if (options.checkJs && !options.allowJs) { + programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs")); + } if (options.emitDecoratorMetadata && !options.experimentalDecorators) { programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators")); @@ -65699,40 +68223,13 @@ var ts; ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; /* @internal */ ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, + // CommandLine only options { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, }, { @@ -65740,53 +68237,70 @@ var ts; shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMapFromTemplate({ - "preserve": 1 /* Preserve */, - "react-native": 3 /* ReactNative */, - "react": 2 /* React */ - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", + name: "project", + shortName: "p", type: "string", isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, + description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, + }, + { + name: "pretty", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental + }, + { + name: "watch", + shortName: "w", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Watch_input_files, + }, + // Basic + { + name: "target", + shortName: "t", + type: ts.createMapFromTemplate({ + "es3": 0 /* ES3 */, + "es5": 1 /* ES5 */, + "es6": 2 /* ES2015 */, + "es2015": 2 /* ES2015 */, + "es2016": 3 /* ES2016 */, + "es2017": 4 /* ES2017 */, + "esnext": 5 /* ESNext */, + }), + paramType: ts.Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { name: "module", @@ -65800,300 +68314,10 @@ var ts; "es6": ts.ModuleKind.ES2015, "es2015": ts.ModuleKind.ES2015, }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMapFromTemplate({ - "crlf": 0 /* CarriageReturnLineFeed */, - "lf": 1 /* LineFeed */ - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - // for correct behaviour, please use outFile - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, - { - name: "project", - shortName: "p", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: ts.Diagnostics.FILE_OR_DIRECTORY - }, - { - name: "removeComments", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, - }, - { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", - type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true - }, - { - name: "target", - shortName: "t", - type: ts.createMapFromTemplate({ - "es3": 0 /* ES3 */, - "es5": 1 /* ES5 */, - "es6": 2 /* ES2015 */, - "es2015": 2 /* ES2015 */, - "es2016": 3 /* ES2016 */, - "es2017": 4 /* ES2017 */, - "esnext": 5 /* ESNext */, - }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, - paramType: ts.Diagnostics.VERSION, - }, - { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", - type: ts.createMapFromTemplate({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, - }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - 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: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_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 - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -66108,6 +68332,7 @@ var ts; "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", // Host only "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", @@ -66127,29 +68352,477 @@ var ts; "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1 /* Preserve */, + "react-native": 3 /* ReactNative */, + "react": 2 /* React */ + }), + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + // Strict Type Checks + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + // Additional Checks + { + name: "noUnusedLocals", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + // Module Resolution + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + paramType: ts.Diagnostics.STRATEGY, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: ts.Diagnostics.Module_Resolution_Options, + 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, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + }, + { + // this option can only be specified in tsconfig.json + // use type = object to copy the value as-is + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + // Source Maps + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + // Experimental + { + name: "experimentalDecorators", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + // Advanced + { + name: "jsxFactory", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + { + name: "out", + type: "string", + isFilePath: false, + // for correct behaviour, please use outFile + category: ts.Diagnostics.Advanced_Options, + paramType: ts.Diagnostics.FILE, + description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0 /* CarriageReturnLineFeed */, + "lf": 1 /* LineFeed */ + }), + paramType: ts.Diagnostics.NEWLINE, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, { // A list of plugins to load in the language service name: "plugins", @@ -66158,7 +68831,8 @@ var ts; element: { name: "plugin", type: "object" - } + }, + description: ts.Diagnostics.List_of_language_service_plugins } ]; /* @internal */ @@ -66195,8 +68869,7 @@ var ts; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1 /* ES5 */, - noImplicitAny: false, - sourceMap: false, + strict: true }; var optionNameMapCache; /* @internal */ @@ -66377,9 +69050,9 @@ var ts; } ts.parseCommandLine = parseCommandLine; /** - * Read tsconfig.json file - * @param fileName The path to the config file - */ + * Read tsconfig.json file + * @param fileName The path to the config file + */ function readConfigFile(fileName, readFile) { var text = ""; try { @@ -66392,10 +69065,10 @@ var ts; } ts.readConfigFile = readConfigFile; /** - * Parse the text of the tsconfig.json file - * @param fileName The path to the config file - * @param jsonText The text of the config file - */ + * Parse the text of the tsconfig.json file + * @param fileName The path to the config file + * @param jsonText The text of the config file + */ function parseConfigFileTextToJson(fileName, jsonText, stripComments) { if (stripComments === void 0) { stripComments = true; } try { @@ -66413,7 +69086,7 @@ var ts; * @param fileNames array of filenames to be generated into tsconfig.json */ /* @internal */ - function generateTSConfig(options, fileNames) { + function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -66422,7 +69095,7 @@ var ts; // only set the files property if we have at least one file configurations.files = fileNames; } - return configurations; + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition) { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { // this is of a type CommandLineOptionOfPrimitiveType @@ -66450,44 +69123,117 @@ var ts; if (ts.hasProperty(options, name)) { // tsconfig only options cannot be specified via command line, // so we can assume that only types that can appear here string | number | boolean - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - // There is no map associated with this compiler option then use the value as-is - // This is the case if the value is expect to be string, number, boolean or list of string - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - // There is a typeMap associated with this command-line option so use it to map value back to its name - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + continue; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + // There is no map associated with this compiler option then use the value as-is + // This is the case if the value is expect to be string, number, boolean or list of string + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + // There is a typeMap associated with this command-line option so use it to map value back to its name + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return ts.arrayFrom(option.type.keys())[0]; + } + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + // Filter applicable options to place in the file + var categorizedOptions = ts.reduceLeft(ts.filter(ts.optionDeclarations, function (o) { return o.category !== ts.Diagnostics.Command_line_Options && o.category !== ts.Diagnostics.Advanced_Options; }), function (memo, value) { + if (value.category) { + var name = ts.getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, {}); + // Serialize all options and thier descriptions + var marginLength = 0; + var seenKnownKeys = 0; + var nameColumn = []; + var descriptionColumn = []; + var knownKeysCount = ts.getOwnKeys(configurations.compilerOptions).length; + for (var category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push("/* " + category + " */"); + descriptionColumn.push(""); + for (var _i = 0, _a = categorizedOptions[category]; _i < _a.length; _i++) { + var option = _a[_i]; + var optionName = void 0; + if (ts.hasProperty(configurations.compilerOptions, option.name)) { + optionName = "\"" + option.name + "\": " + JSON.stringify(configurations.compilerOptions[option.name]) + ((seenKnownKeys += 1) === knownKeysCount ? "" : ","); + } + else { + optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + } + nameColumn.push(optionName); + descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + marginLength = Math.max(optionName.length, marginLength); + } + } + // Write the output + var tab = makePadding(2); + var result = []; + result.push("{"); + result.push(tab + "\"compilerOptions\": {"); + // Print out each row, aligning all the descriptions on the same column. + for (var i = 0; i < nameColumn.length; i++) { + var optionName = nameColumn[i]; + var description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(tab + "},"); + result.push(tab + "\"files\": ["); + for (var i = 0; i < configurations.files.length; i++) { + result.push("" + tab + tab + JSON.stringify(configurations.files[i]) + (i === configurations.files.length - 1 ? "" : ",")); + } + result.push(tab + "]"); + } + else { + result.push(tab + "}"); + } + result.push("}"); + return result.join(newLine); + } } ts.generateTSConfig = generateTSConfig; /** @@ -66515,12 +69261,12 @@ var ts; return output; } /** - * Parse the contents of a config file (tsconfig.json). - * @param json The contents of the config file to parse - * @param host Instance of ParseConfigHost used to enumerate files in folder. - * @param basePath A root directory to resolve relative path entries in the config - * file to. e.g. outDir - */ + * Parse the contents of a config file (tsconfig.json). + * @param json The contents of the config file to parse + * @param host Instance of ParseConfigHost used to enumerate files in folder. + * @param basePath A root directory to resolve relative path entries in the config + * file to. e.g. outDir + */ function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions) { if (existingOptions === void 0) { existingOptions = {}; } if (resolutionStack === void 0) { resolutionStack = []; } @@ -66544,10 +69290,11 @@ var ts; // It should be removed in future releases - use typeAcquisition instead. var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -66567,6 +69314,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -66606,7 +69356,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -66966,7 +69716,6 @@ var ts; } } } - ; } return wildcardDirectories; } @@ -67158,8 +69907,7 @@ var ts; ScriptElementKind.typeElement = "type"; /** enum E */ ScriptElementKind.enumElement = "enum"; - // TODO: GH#9983 - ScriptElementKind.enumMemberElement = "const"; + ScriptElementKind.enumMemberElement = "enum member"; /** * Inside module and script only * const v = .. @@ -67204,7 +69952,7 @@ var ts; ScriptElementKind.externalModuleName = "external module name"; /** * - **/ + */ ScriptElementKind.jsxAttribute = "JSX attribute"; })(ScriptElementKind = ts.ScriptElementKind || (ts.ScriptElementKind = {})); var ScriptElementKindModifier; @@ -67291,34 +70039,34 @@ var ts; })(SemanticMeaning = ts.SemanticMeaning || (ts.SemanticMeaning = {})); function getMeaningFromDeclaration(node) { switch (node.kind) { - case 145 /* Parameter */: - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: - case 263 /* EnumMember */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 259 /* CatchClause */: - case 252 /* JsxAttribute */: + case 146 /* Parameter */: + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: + case 264 /* EnumMember */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 260 /* CatchClause */: + case 253 /* JsxAttribute */: return 1 /* Value */; - case 144 /* TypeParameter */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 162 /* TypeLiteral */: + case 145 /* TypeParameter */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 163 /* TypeLiteral */: return 2 /* Type */; - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: return 1 /* Value */ | 2 /* Type */; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (ts.isAmbientModule(node)) { return 4 /* Namespace */ | 1 /* Value */; } @@ -67328,25 +70076,25 @@ var ts; else { return 4 /* Namespace */; } - case 240 /* NamedImports */: - case 241 /* ImportSpecifier */: - case 236 /* ImportEqualsDeclaration */: - case 237 /* ImportDeclaration */: - case 242 /* ExportAssignment */: - case 243 /* ExportDeclaration */: + case 241 /* NamedImports */: + case 242 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 238 /* ImportDeclaration */: + case 243 /* ExportAssignment */: + case 244 /* ExportDeclaration */: return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; // An external module can be a Value - case 264 /* SourceFile */: + case 265 /* SourceFile */: return 4 /* Namespace */ | 1 /* Value */; } return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } ts.getMeaningFromDeclaration = getMeaningFromDeclaration; function getMeaningFromLocation(node) { - if (node.kind === 264 /* SourceFile */) { + if (node.kind === 265 /* SourceFile */) { return 1 /* Value */; } - else if (node.parent.kind === 242 /* ExportAssignment */) { + else if (node.parent.kind === 243 /* ExportAssignment */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } else if (isInRightSideOfImport(node)) { @@ -67367,19 +70115,19 @@ var ts; } ts.getMeaningFromLocation = getMeaningFromLocation; function getMeaningFromRightHandSideOfImportEquals(node) { - ts.Debug.assert(node.kind === 70 /* Identifier */); + ts.Debug.assert(node.kind === 71 /* Identifier */); // import a = |b|; // Namespace // import a = |b.c|; // Value, type, namespace // import a = |b.c|.d; // Namespace - if (node.parent.kind === 142 /* QualifiedName */ && + if (node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node && - node.parent.parent.kind === 236 /* ImportEqualsDeclaration */) { + node.parent.parent.kind === 237 /* ImportEqualsDeclaration */) { return 1 /* Value */ | 2 /* Type */ | 4 /* Namespace */; } return 4 /* Namespace */; } function isInRightSideOfImport(node) { - while (node.parent.kind === 142 /* QualifiedName */) { + while (node.parent.kind === 143 /* QualifiedName */) { node = node.parent; } return ts.isInternalModuleImportEqualsDeclaration(node.parent) && node.parent.moduleReference === node; @@ -67390,27 +70138,27 @@ var ts; function isQualifiedNameNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 142 /* QualifiedName */) { - while (root.parent && root.parent.kind === 142 /* QualifiedName */) { + if (root.parent.kind === 143 /* QualifiedName */) { + while (root.parent && root.parent.kind === 143 /* QualifiedName */) { root = root.parent; } isLastClause = root.right === node; } - return root.parent.kind === 158 /* TypeReference */ && !isLastClause; + return root.parent.kind === 159 /* TypeReference */ && !isLastClause; } function isPropertyAccessNamespaceReference(node) { var root = node; var isLastClause = true; - if (root.parent.kind === 178 /* PropertyAccessExpression */) { - while (root.parent && root.parent.kind === 178 /* PropertyAccessExpression */) { + if (root.parent.kind === 179 /* PropertyAccessExpression */) { + while (root.parent && root.parent.kind === 179 /* PropertyAccessExpression */) { root = root.parent; } isLastClause = root.name === node; } - if (!isLastClause && root.parent.kind === 200 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 258 /* HeritageClause */) { + if (!isLastClause && root.parent.kind === 201 /* ExpressionWithTypeArguments */ && root.parent.parent.kind === 259 /* HeritageClause */) { var decl = root.parent.parent.parent; - return (decl.kind === 228 /* ClassDeclaration */ && root.parent.parent.token === 107 /* ImplementsKeyword */) || - (decl.kind === 229 /* InterfaceDeclaration */ && root.parent.parent.token === 84 /* ExtendsKeyword */); + return (decl.kind === 229 /* ClassDeclaration */ && root.parent.parent.token === 108 /* ImplementsKeyword */) || + (decl.kind === 230 /* InterfaceDeclaration */ && root.parent.parent.token === 85 /* ExtendsKeyword */); } return false; } @@ -67418,17 +70166,17 @@ var ts; if (ts.isRightSideOfQualifiedNameOrPropertyAccess(node)) { node = node.parent; } - return node.parent.kind === 158 /* TypeReference */ || - (node.parent.kind === 200 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || - (node.kind === 98 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || - node.kind === 168 /* ThisType */; + return node.parent.kind === 159 /* TypeReference */ || + (node.parent.kind === 201 /* ExpressionWithTypeArguments */ && !ts.isExpressionWithTypeArgumentsInClassExtendsClause(node.parent)) || + (node.kind === 99 /* ThisKeyword */ && !ts.isPartOfExpression(node)) || + node.kind === 169 /* ThisType */; } function isCallExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 180 /* CallExpression */); + return isCallOrNewExpressionTarget(node, 181 /* CallExpression */); } ts.isCallExpressionTarget = isCallExpressionTarget; function isNewExpressionTarget(node) { - return isCallOrNewExpressionTarget(node, 181 /* NewExpression */); + return isCallOrNewExpressionTarget(node, 182 /* NewExpression */); } ts.isNewExpressionTarget = isNewExpressionTarget; function isCallOrNewExpressionTarget(node, kind) { @@ -67441,7 +70189,7 @@ var ts; ts.climbPastPropertyAccess = climbPastPropertyAccess; function getTargetLabel(referenceNode, labelName) { while (referenceNode) { - if (referenceNode.kind === 221 /* LabeledStatement */ && referenceNode.label.text === labelName) { + if (referenceNode.kind === 222 /* LabeledStatement */ && referenceNode.label.text === labelName) { return referenceNode.label; } referenceNode = referenceNode.parent; @@ -67450,14 +70198,14 @@ var ts; } ts.getTargetLabel = getTargetLabel; function isJumpStatementTarget(node) { - return node.kind === 70 /* Identifier */ && - (node.parent.kind === 217 /* BreakStatement */ || node.parent.kind === 216 /* ContinueStatement */) && + return node.kind === 71 /* Identifier */ && + (node.parent.kind === 218 /* BreakStatement */ || node.parent.kind === 217 /* ContinueStatement */) && node.parent.label === node; } ts.isJumpStatementTarget = isJumpStatementTarget; function isLabelOfLabeledStatement(node) { - return node.kind === 70 /* Identifier */ && - node.parent.kind === 221 /* LabeledStatement */ && + return node.kind === 71 /* Identifier */ && + node.parent.kind === 222 /* LabeledStatement */ && node.parent.label === node; } function isLabelName(node) { @@ -67465,38 +70213,38 @@ var ts; } ts.isLabelName = isLabelName; function isRightSideOfQualifiedName(node) { - return node.parent.kind === 142 /* QualifiedName */ && node.parent.right === node; + return node.parent.kind === 143 /* QualifiedName */ && node.parent.right === node; } ts.isRightSideOfQualifiedName = isRightSideOfQualifiedName; function isRightSideOfPropertyAccess(node) { - return node && node.parent && node.parent.kind === 178 /* PropertyAccessExpression */ && node.parent.name === node; + return node && node.parent && node.parent.kind === 179 /* PropertyAccessExpression */ && node.parent.name === node; } ts.isRightSideOfPropertyAccess = isRightSideOfPropertyAccess; function isNameOfModuleDeclaration(node) { - return node.parent.kind === 232 /* ModuleDeclaration */ && node.parent.name === node; + return node.parent.kind === 233 /* ModuleDeclaration */ && node.parent.name === node; } ts.isNameOfModuleDeclaration = isNameOfModuleDeclaration; function isNameOfFunctionDeclaration(node) { - return node.kind === 70 /* Identifier */ && + return node.kind === 71 /* Identifier */ && ts.isFunctionLike(node.parent) && node.parent.name === node; } ts.isNameOfFunctionDeclaration = isNameOfFunctionDeclaration; function isLiteralNameOfPropertyDeclarationOrIndexAccess(node) { if (node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { switch (node.parent.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 260 /* PropertyAssignment */: - case 263 /* EnumMember */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 232 /* ModuleDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 261 /* PropertyAssignment */: + case 264 /* EnumMember */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 233 /* ModuleDeclaration */: return node.parent.name === node; - case 179 /* ElementAccessExpression */: + case 180 /* ElementAccessExpression */: return node.parent.argumentExpression === node; - case 143 /* ComputedPropertyName */: + case 144 /* ComputedPropertyName */: return true; } } @@ -67545,17 +70293,17 @@ var ts; return undefined; } switch (node.kind) { - case 264 /* SourceFile */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: + case 265 /* SourceFile */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: return node; } } @@ -67563,46 +70311,46 @@ var ts; ts.getContainerNode = getContainerNode; function getNodeKind(node) { switch (node.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: return ts.isExternalModule(node) ? ts.ScriptElementKind.moduleElement : ts.ScriptElementKind.scriptElement; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: return ts.ScriptElementKind.moduleElement; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: return ts.ScriptElementKind.classElement; - case 229 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; - case 230 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; - case 231 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; - case 225 /* VariableDeclaration */: + case 230 /* InterfaceDeclaration */: return ts.ScriptElementKind.interfaceElement; + case 231 /* TypeAliasDeclaration */: return ts.ScriptElementKind.typeElement; + case 232 /* EnumDeclaration */: return ts.ScriptElementKind.enumElement; + case 226 /* VariableDeclaration */: return getKindOfVariableDeclaration(node); - case 175 /* BindingElement */: + case 176 /* BindingElement */: return getKindOfVariableDeclaration(ts.getRootDeclaration(node)); - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return ts.ScriptElementKind.functionElement; - case 152 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; - case 153 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 153 /* GetAccessor */: return ts.ScriptElementKind.memberGetAccessorElement; + case 154 /* SetAccessor */: return ts.ScriptElementKind.memberSetAccessorElement; + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return ts.ScriptElementKind.memberFunctionElement; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return ts.ScriptElementKind.memberVariableElement; - case 156 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; - case 155 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; - case 154 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; - case 151 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; - case 144 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; - case 263 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; - case 145 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; - case 236 /* ImportEqualsDeclaration */: - case 241 /* ImportSpecifier */: - case 238 /* ImportClause */: - case 245 /* ExportSpecifier */: - case 239 /* NamespaceImport */: + case 157 /* IndexSignature */: return ts.ScriptElementKind.indexSignatureElement; + case 156 /* ConstructSignature */: return ts.ScriptElementKind.constructSignatureElement; + case 155 /* CallSignature */: return ts.ScriptElementKind.callSignatureElement; + case 152 /* Constructor */: return ts.ScriptElementKind.constructorImplementationElement; + case 145 /* TypeParameter */: return ts.ScriptElementKind.typeParameterElement; + case 264 /* EnumMember */: return ts.ScriptElementKind.enumMemberElement; + case 146 /* Parameter */: return ts.hasModifier(node, 92 /* ParameterPropertyModifier */) ? ts.ScriptElementKind.memberVariableElement : ts.ScriptElementKind.parameterElement; + case 237 /* ImportEqualsDeclaration */: + case 242 /* ImportSpecifier */: + case 239 /* ImportClause */: + case 246 /* ExportSpecifier */: + case 240 /* NamespaceImport */: return ts.ScriptElementKind.alias; - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return ts.ScriptElementKind.typeElement; default: return ts.ScriptElementKind.unknown; @@ -67616,23 +70364,14 @@ var ts; } } ts.getNodeKind = getNodeKind; - function getStringLiteralTypeForNode(node, typeChecker) { - var searchNode = node.parent.kind === 172 /* LiteralType */ ? node.parent : node; - var type = typeChecker.getTypeAtLocation(searchNode); - if (type && type.flags & 32 /* StringLiteral */) { - return type; - } - return undefined; - } - ts.getStringLiteralTypeForNode = getStringLiteralTypeForNode; function isThis(node) { switch (node.kind) { - case 98 /* ThisKeyword */: + case 99 /* ThisKeyword */: // case SyntaxKind.ThisType: TODO: GH#9267 return true; - case 70 /* Identifier */: + case 71 /* Identifier */: // 'this' as a parameter - return ts.identifierIsThisKeyword(node) && node.parent.kind === 145 /* Parameter */; + return ts.identifierIsThisKeyword(node) && node.parent.kind === 146 /* Parameter */; default: return false; } @@ -67641,7 +70380,7 @@ var ts; // Matches the beginning of a triple slash directive var tripleSlashDirectivePrefixRegex = /^\/\/\/\s*= node.end) { + if (c.kind === 294 /* SyntaxList */ && c.pos <= node.pos && c.end >= node.end) { return c; } }); @@ -67880,7 +70619,7 @@ var ts; if (includeJsDocComment === void 0) { includeJsDocComment = false; } var current = sourceFile; outer: while (true) { - if (isToken(current)) { + if (ts.isToken(current)) { // exit early return current; } @@ -67930,18 +70669,18 @@ var ts; } } /** - * The token on the left of the position is the token that strictly includes the position - * or sits to the left of the cursor if it is on a boundary. For example - * - * fo|o -> will return foo - * foo |bar -> will return foo - * - */ + * The token on the left of the position is the token that strictly includes the position + * or sits to the left of the cursor if it is on a boundary. For example + * + * fo|o -> will return foo + * foo |bar -> will return foo + * + */ function findTokenOnLeftOfPosition(file, position) { // Ideally, getTokenAtPosition should return a token. However, it is currently // broken, so we do a check to make sure the result was indeed a token. var tokenAtPosition = getTokenAtPosition(file, position); - if (isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { + if (ts.isToken(tokenAtPosition) && position > tokenAtPosition.getStart(file) && position < tokenAtPosition.getEnd()) { return tokenAtPosition; } return findPrecedingToken(position, file); @@ -67950,7 +70689,7 @@ var ts; function findNextToken(previousToken, parent) { return find(parent); function find(n) { - if (isToken(n) && n.pos === previousToken.end) { + if (ts.isToken(n) && n.pos === previousToken.end) { // this is token that starts at the end of previous token - return it return n; } @@ -67973,7 +70712,7 @@ var ts; function findPrecedingToken(position, sourceFile, startNode) { return find(startNode || sourceFile); function findRightmostToken(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -67981,7 +70720,7 @@ var ts; return candidate && findRightmostToken(candidate); } function find(n) { - if (isToken(n)) { + if (ts.isToken(n)) { return n; } var children = n.getChildren(); @@ -68010,7 +70749,7 @@ var ts; } } } - ts.Debug.assert(startNode !== undefined || n.kind === 264 /* SourceFile */); + ts.Debug.assert(startNode !== undefined || n.kind === 265 /* 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. @@ -68065,21 +70804,21 @@ var ts; return true; } //
Hello |
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 10 /* JsxText */) { return true; } //
{ |
or
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 255 /* JsxExpression */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 256 /* JsxExpression */) { return true; } //
{ // | // } < /div> - if (token && token.kind === 17 /* CloseBraceToken */ && token.parent.kind === 255 /* JsxExpression */) { + if (token && token.kind === 18 /* CloseBraceToken */ && token.parent.kind === 256 /* JsxExpression */) { return true; } //
|
- if (token.kind === 26 /* LessThanToken */ && token.parent.kind === 251 /* JsxClosingElement */) { + if (token.kind === 27 /* LessThanToken */ && token.parent.kind === 252 /* JsxClosingElement */) { return true; } return false; @@ -68110,10 +70849,10 @@ var ts; // Internally, we represent the end of the comment at the newline and closing '/', respectively. return predicate ? ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && + (c.kind === 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end) && predicate(c); }) : ts.forEach(commentRanges, function (c) { return c.pos < position && - (c.kind == 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); + (c.kind === 2 /* SingleLineCommentTrivia */ ? position <= c.end : position < c.end); }); } return false; } @@ -68134,11 +70873,11 @@ var ts; */ function getJsDocTagAtPosition(sourceFile, position) { var node = ts.getTokenAtPosition(sourceFile, position); - if (isToken(node)) { + if (ts.isToken(node)) { switch (node.kind) { - case 103 /* VarKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: + case 104 /* VarKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: // if the current token is var, let or const, skip the VariableDeclarationList node = node.parent === undefined ? undefined : node.parent.parent; break; @@ -68191,21 +70930,17 @@ var ts; } ts.getNodeModifiers = getNodeModifiers; function getTypeArgumentOrTypeParameterList(node) { - if (node.kind === 158 /* TypeReference */ || node.kind === 180 /* CallExpression */) { + if (node.kind === 159 /* TypeReference */ || node.kind === 181 /* CallExpression */) { return node.typeArguments; } - if (ts.isFunctionLike(node) || node.kind === 228 /* ClassDeclaration */ || node.kind === 229 /* InterfaceDeclaration */) { + if (ts.isFunctionLike(node) || node.kind === 229 /* ClassDeclaration */ || node.kind === 230 /* InterfaceDeclaration */) { return node.typeParameters; } return undefined; } ts.getTypeArgumentOrTypeParameterList = getTypeArgumentOrTypeParameterList; - function isToken(n) { - return n.kind >= 0 /* FirstToken */ && n.kind <= 141 /* LastToken */; - } - ts.isToken = isToken; function isWord(kind) { - return kind === 70 /* Identifier */ || ts.isKeyword(kind); + return kind === 71 /* Identifier */ || ts.isKeyword(kind); } ts.isWord = isWord; function isPropertyName(kind) { @@ -68217,7 +70952,7 @@ var ts; ts.isComment = isComment; function isStringOrRegularExpressionOrTemplateLiteral(kind) { if (kind === 9 /* StringLiteral */ - || kind === 11 /* RegularExpressionLiteral */ + || kind === 12 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(kind)) { return true; } @@ -68225,7 +70960,7 @@ var ts; } ts.isStringOrRegularExpressionOrTemplateLiteral = isStringOrRegularExpressionOrTemplateLiteral; function isPunctuation(kind) { - return 16 /* FirstPunctuation */ <= kind && kind <= 69 /* LastPunctuation */; + return 17 /* FirstPunctuation */ <= kind && kind <= 70 /* LastPunctuation */; } ts.isPunctuation = isPunctuation; function isInsideTemplateLiteral(node, position) { @@ -68235,9 +70970,9 @@ var ts; ts.isInsideTemplateLiteral = isInsideTemplateLiteral; function isAccessibilityModifier(kind) { switch (kind) { - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: return true; } return false; @@ -68260,18 +70995,18 @@ var ts; } ts.compareDataObjects = compareDataObjects; function isArrayLiteralOrObjectLiteralDestructuringPattern(node) { - if (node.kind === 176 /* ArrayLiteralExpression */ || - node.kind === 177 /* ObjectLiteralExpression */) { + if (node.kind === 177 /* ArrayLiteralExpression */ || + node.kind === 178 /* ObjectLiteralExpression */) { // [a,b,c] from: // [a, b, c] = someExpression; - if (node.parent.kind === 193 /* BinaryExpression */ && + if (node.parent.kind === 194 /* BinaryExpression */ && node.parent.left === node && - node.parent.operatorToken.kind === 57 /* EqualsToken */) { + node.parent.operatorToken.kind === 58 /* EqualsToken */) { return true; } // [a, b, c] from: // for([a, b, c] of expression) - if (node.parent.kind === 215 /* ForOfStatement */ && + if (node.parent.kind === 216 /* ForOfStatement */ && node.parent.initializer === node) { return true; } @@ -68279,7 +71014,7 @@ var ts; // [x, [a, b, c] ] = someExpression // or // {x, a: {a, b, c} } = someExpression - if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 260 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { + if (isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent.kind === 261 /* PropertyAssignment */ ? node.parent.parent : node.parent)) { return true; } } @@ -68313,26 +71048,41 @@ var ts; ts.createTextSpanFromNode = createTextSpanFromNode; function isTypeKeyword(kind) { switch (kind) { - case 118 /* AnyKeyword */: - case 121 /* BooleanKeyword */: - case 129 /* NeverKeyword */: - case 132 /* NumberKeyword */: - case 133 /* ObjectKeyword */: - case 135 /* StringKeyword */: - case 136 /* SymbolKeyword */: - case 104 /* VoidKeyword */: + case 119 /* AnyKeyword */: + case 122 /* BooleanKeyword */: + case 130 /* NeverKeyword */: + case 133 /* NumberKeyword */: + case 134 /* ObjectKeyword */: + case 136 /* StringKeyword */: + case 137 /* SymbolKeyword */: + case 105 /* VoidKeyword */: return true; default: return false; } } ts.isTypeKeyword = isTypeKeyword; + /** True if the symbol is for an external module, as opposed to a namespace. */ + function isExternalModuleSymbol(moduleSymbol) { + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + return moduleSymbol.name.charCodeAt(0) === 34 /* doubleQuote */; + } + ts.isExternalModuleSymbol = isExternalModuleSymbol; + /** Returns `true` the first time it encounters a node and `false` afterwards. */ + function nodeSeenTracker() { + var seen = []; + return function (node) { + var id = ts.getNodeId(node); + return !seen[id] && (seen[id] = true); + }; + } + ts.nodeSeenTracker = nodeSeenTracker; })(ts || (ts = {})); // Display-part writer helpers /* @internal */ (function (ts) { function isFirstDeclarationOfSymbolParameter(symbol) { - return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 145 /* Parameter */; + return symbol.declarations && symbol.declarations.length > 0 && symbol.declarations[0].kind === 146 /* Parameter */; } ts.isFirstDeclarationOfSymbolParameter = isFirstDeclarationOfSymbolParameter; var displayPartWriter = getDisplayPartWriter(); @@ -68510,23 +71260,18 @@ var ts; function getDeclaredName(typeChecker, symbol, location) { // If this is an export or import specifier it could have been renamed using the 'as' syntax. // If so we want to search for whatever is under the cursor. - if (isImportOrExportSpecifierName(location)) { - return location.getText(); - } - else if (ts.isStringOrNumericLiteral(location) && - location.parent.kind === 143 /* ComputedPropertyName */) { + if (isImportOrExportSpecifierName(location) || ts.isStringOrNumericLiteral(location) && location.parent.kind === 144 /* ComputedPropertyName */) { return location.text; } // Try to get the local symbol if we're dealing with an 'export default' // since that symbol has the "true" name. var localExportDefaultSymbol = ts.getLocalSymbolForExportDefault(symbol); - var name = typeChecker.symbolToString(localExportDefaultSymbol || symbol); - return name; + return typeChecker.symbolToString(localExportDefaultSymbol || symbol); } ts.getDeclaredName = getDeclaredName; function isImportOrExportSpecifierName(location) { return location.parent && - (location.parent.kind === 241 /* ImportSpecifier */ || location.parent.kind === 245 /* ExportSpecifier */) && + (location.parent.kind === 242 /* ImportSpecifier */ || location.parent.kind === 246 /* ExportSpecifier */) && location.parent.propertyName === location; } ts.isImportOrExportSpecifierName = isImportOrExportSpecifierName; @@ -68542,7 +71287,6 @@ var ts; (name.charCodeAt(0) === 34 /* doubleQuote */ || name.charCodeAt(0) === 39 /* singleQuote */)) { return name.substring(1, length - 1); } - ; return name; } ts.stripQuotes = stripQuotes; @@ -68593,11 +71337,22 @@ var ts; }; } ts.sanitizeConfigFile = sanitizeConfigFile; - function getOpenBraceEnd(constructor, sourceFile) { - // First token is the open curly, this is where we want to put the 'super' call. - return constructor.body.getFirstToken(sourceFile).getEnd(); + function getFirstNonSpaceCharacterPosition(text, position) { + while (ts.isWhiteSpaceLike(text.charCodeAt(position))) { + position += 1; + } + return position; } - ts.getOpenBraceEnd = getOpenBraceEnd; + ts.getFirstNonSpaceCharacterPosition = getFirstNonSpaceCharacterPosition; + function getOpenBrace(constructor, sourceFile) { + // First token is the open curly, this is where we want to put the 'super' call. + return constructor.body.getFirstToken(sourceFile); + } + ts.getOpenBrace = getOpenBrace; + function getOpenBraceOfClassLike(declaration, sourceFile) { + return ts.getTokenAtPosition(sourceFile, declaration.members.pos - 1); + } + ts.getOpenBraceOfClassLike = getOpenBraceOfClassLike; })(ts || (ts = {})); var ts; (function (ts) { @@ -68609,18 +71364,18 @@ var ts; /// we have a series of divide operator. this list allows us to be more accurate by ruling out /// locations where a regexp cannot exist. var noRegexTable = []; - noRegexTable[70 /* Identifier */] = true; + noRegexTable[71 /* Identifier */] = true; noRegexTable[9 /* StringLiteral */] = true; noRegexTable[8 /* NumericLiteral */] = true; - noRegexTable[11 /* RegularExpressionLiteral */] = true; - noRegexTable[98 /* ThisKeyword */] = true; - noRegexTable[42 /* PlusPlusToken */] = true; - noRegexTable[43 /* MinusMinusToken */] = true; - noRegexTable[19 /* CloseParenToken */] = true; - noRegexTable[21 /* CloseBracketToken */] = true; - noRegexTable[17 /* CloseBraceToken */] = true; - noRegexTable[100 /* TrueKeyword */] = true; - noRegexTable[85 /* FalseKeyword */] = true; + noRegexTable[12 /* RegularExpressionLiteral */] = true; + noRegexTable[99 /* ThisKeyword */] = true; + noRegexTable[43 /* PlusPlusToken */] = true; + noRegexTable[44 /* MinusMinusToken */] = true; + noRegexTable[20 /* CloseParenToken */] = true; + noRegexTable[22 /* CloseBracketToken */] = true; + noRegexTable[18 /* CloseBraceToken */] = true; + noRegexTable[101 /* TrueKeyword */] = true; + noRegexTable[86 /* FalseKeyword */] = true; // Just a stack of TemplateHeads and OpenCurlyBraces, used to perform rudimentary (inexact) // classification on template strings. Because of the context free nature of templates, // the only precise way to classify a template portion would be by propagating the stack across @@ -68645,10 +71400,10 @@ var ts; /** Returns true if 'keyword2' can legally follow 'keyword1' in any language construct. */ function canFollow(keyword1, keyword2) { if (ts.isAccessibilityModifier(keyword1)) { - if (keyword2 === 124 /* GetKeyword */ || - keyword2 === 134 /* SetKeyword */ || - keyword2 === 122 /* ConstructorKeyword */ || - keyword2 === 114 /* StaticKeyword */) { + if (keyword2 === 125 /* GetKeyword */ || + keyword2 === 135 /* SetKeyword */ || + keyword2 === 123 /* ConstructorKeyword */ || + keyword2 === 115 /* StaticKeyword */) { // Allow things like "public get", "public constructor" and "public static". // These are all legal. return true; @@ -68667,7 +71422,7 @@ var ts; var lastEnd = 0; for (var i = 0; i < dense.length; i += 3) { var start = dense[i]; - var length_4 = dense[i + 1]; + var length_5 = dense[i + 1]; var type = dense[i + 2]; // Make a whitespace entry between the last item and this one. if (lastEnd >= 0) { @@ -68676,8 +71431,8 @@ var ts; entries.push({ length: whitespaceLength_1, classification: ts.TokenClass.Whitespace }); } } - entries.push({ length: length_4, classification: convertClassification(type) }); - lastEnd = start + length_4; + entries.push({ length: length_5, classification: convertClassification(type) }); + lastEnd = start + length_5; } var whitespaceLength = text.length - lastEnd; if (whitespaceLength > 0) { @@ -68745,9 +71500,9 @@ var ts; case 5 /* InTemplateMiddleOrTail */: text = "}\n" + text; offset = 2; - // fallthrough + // falls through case 6 /* InTemplateSubstitutionPosition */: - templateStack.push(13 /* TemplateHead */); + templateStack.push(14 /* TemplateHead */); break; } scanner.setText(text); @@ -68778,71 +71533,71 @@ var ts; do { token = scanner.scan(); if (!ts.isTrivia(token)) { - if ((token === 40 /* SlashToken */ || token === 62 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { - if (scanner.reScanSlashToken() === 11 /* RegularExpressionLiteral */) { - token = 11 /* RegularExpressionLiteral */; + if ((token === 41 /* SlashToken */ || token === 63 /* SlashEqualsToken */) && !noRegexTable[lastNonTriviaToken]) { + if (scanner.reScanSlashToken() === 12 /* RegularExpressionLiteral */) { + token = 12 /* RegularExpressionLiteral */; } } - else if (lastNonTriviaToken === 22 /* DotToken */ && isKeyword(token)) { - token = 70 /* Identifier */; + else if (lastNonTriviaToken === 23 /* DotToken */ && isKeyword(token)) { + token = 71 /* Identifier */; } else if (isKeyword(lastNonTriviaToken) && isKeyword(token) && !canFollow(lastNonTriviaToken, token)) { // We have two keywords in a row. Only treat the second as a keyword if // it's a sequence that could legally occur in the language. Otherwise // treat it as an identifier. This way, if someone writes "private var" // we recognize that 'var' is actually an identifier here. - token = 70 /* Identifier */; + token = 71 /* Identifier */; } - else if (lastNonTriviaToken === 70 /* Identifier */ && - token === 26 /* LessThanToken */) { + else if (lastNonTriviaToken === 71 /* Identifier */ && + token === 27 /* LessThanToken */) { // Could be the start of something generic. Keep track of that by bumping // up the current count of generic contexts we may be in. angleBracketStack++; } - else if (token === 28 /* GreaterThanToken */ && angleBracketStack > 0) { + else if (token === 29 /* GreaterThanToken */ && angleBracketStack > 0) { // If we think we're currently in something generic, then mark that that // generic entity is complete. angleBracketStack--; } - else if (token === 118 /* AnyKeyword */ || - token === 135 /* StringKeyword */ || - token === 132 /* NumberKeyword */ || - token === 121 /* BooleanKeyword */ || - token === 136 /* SymbolKeyword */) { + else if (token === 119 /* AnyKeyword */ || + token === 136 /* StringKeyword */ || + token === 133 /* NumberKeyword */ || + token === 122 /* BooleanKeyword */ || + token === 137 /* 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, // causing a noisy experience for the user. - token = 70 /* Identifier */; + token = 71 /* Identifier */; } } - else if (token === 13 /* TemplateHead */) { + else if (token === 14 /* TemplateHead */) { templateStack.push(token); } - else if (token === 16 /* OpenBraceToken */) { + else if (token === 17 /* OpenBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { templateStack.push(token); } } - else if (token === 17 /* CloseBraceToken */) { + else if (token === 18 /* CloseBraceToken */) { // If we don't have anything on the template stack, // then we aren't trying to keep track of a previously scanned template head. if (templateStack.length > 0) { var lastTemplateStackToken = ts.lastOrUndefined(templateStack); - if (lastTemplateStackToken === 13 /* TemplateHead */) { + if (lastTemplateStackToken === 14 /* TemplateHead */) { token = scanner.reScanTemplateToken(); // Only pop on a TemplateTail; a TemplateMiddle indicates there is more for us. - if (token === 15 /* TemplateTail */) { + if (token === 16 /* TemplateTail */) { templateStack.pop(); } else { - ts.Debug.assert(token === 14 /* TemplateMiddle */, "Should have been a template middle. Was " + token); + ts.Debug.assert(token === 15 /* TemplateMiddle */, "Should have been a template middle. Was " + token); } } else { - ts.Debug.assert(lastTemplateStackToken === 16 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); + ts.Debug.assert(lastTemplateStackToken === 17 /* OpenBraceToken */, "Should have been an open brace. Was: " + token); templateStack.pop(); } } @@ -68883,10 +71638,10 @@ var ts; } else if (ts.isTemplateLiteralKind(token)) { if (scanner.isUnterminated()) { - if (token === 15 /* TemplateTail */) { + if (token === 16 /* TemplateTail */) { result.endOfLineState = 5 /* InTemplateMiddleOrTail */; } - else if (token === 12 /* NoSubstitutionTemplateLiteral */) { + else if (token === 13 /* NoSubstitutionTemplateLiteral */) { result.endOfLineState = 4 /* InTemplateHeadOrNoSubstitutionTemplate */; } else { @@ -68894,7 +71649,7 @@ var ts; } } } - else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 13 /* TemplateHead */) { + else if (templateStack.length > 0 && ts.lastOrUndefined(templateStack) === 14 /* TemplateHead */) { result.endOfLineState = 6 /* InTemplateSubstitutionPosition */; } } @@ -68924,43 +71679,43 @@ var ts; } function isBinaryExpressionOperatorToken(token) { switch (token) { - case 38 /* AsteriskToken */: - case 40 /* SlashToken */: - case 41 /* PercentToken */: - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 44 /* LessThanLessThanToken */: - case 45 /* GreaterThanGreaterThanToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: - case 26 /* LessThanToken */: - case 28 /* GreaterThanToken */: - case 29 /* LessThanEqualsToken */: - case 30 /* GreaterThanEqualsToken */: - case 92 /* InstanceOfKeyword */: - case 91 /* InKeyword */: - case 117 /* AsKeyword */: - case 31 /* EqualsEqualsToken */: - case 32 /* ExclamationEqualsToken */: - case 33 /* EqualsEqualsEqualsToken */: - case 34 /* ExclamationEqualsEqualsToken */: - case 47 /* AmpersandToken */: - case 49 /* CaretToken */: - case 48 /* BarToken */: - case 52 /* AmpersandAmpersandToken */: - case 53 /* BarBarToken */: - case 68 /* BarEqualsToken */: - case 67 /* AmpersandEqualsToken */: - case 69 /* CaretEqualsToken */: - case 64 /* LessThanLessThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 58 /* PlusEqualsToken */: - case 59 /* MinusEqualsToken */: - case 60 /* AsteriskEqualsToken */: - case 62 /* SlashEqualsToken */: - case 63 /* PercentEqualsToken */: - case 57 /* EqualsToken */: - case 25 /* CommaToken */: + case 39 /* AsteriskToken */: + case 41 /* SlashToken */: + case 42 /* PercentToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 45 /* LessThanLessThanToken */: + case 46 /* GreaterThanGreaterThanToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 27 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 30 /* LessThanEqualsToken */: + case 31 /* GreaterThanEqualsToken */: + case 93 /* InstanceOfKeyword */: + case 92 /* InKeyword */: + case 118 /* AsKeyword */: + case 32 /* EqualsEqualsToken */: + case 33 /* ExclamationEqualsToken */: + case 34 /* EqualsEqualsEqualsToken */: + case 35 /* ExclamationEqualsEqualsToken */: + case 48 /* AmpersandToken */: + case 50 /* CaretToken */: + case 49 /* BarToken */: + case 53 /* AmpersandAmpersandToken */: + case 54 /* BarBarToken */: + case 69 /* BarEqualsToken */: + case 68 /* AmpersandEqualsToken */: + case 70 /* CaretEqualsToken */: + case 65 /* LessThanLessThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 59 /* PlusEqualsToken */: + case 60 /* MinusEqualsToken */: + case 61 /* AsteriskEqualsToken */: + case 63 /* SlashEqualsToken */: + case 64 /* PercentEqualsToken */: + case 58 /* EqualsToken */: + case 26 /* CommaToken */: return true; default: return false; @@ -68968,19 +71723,19 @@ var ts; } function isPrefixUnaryExpressionOperatorToken(token) { switch (token) { - case 36 /* PlusToken */: - case 37 /* MinusToken */: - case 51 /* TildeToken */: - case 50 /* ExclamationToken */: - case 42 /* PlusPlusToken */: - case 43 /* MinusMinusToken */: + case 37 /* PlusToken */: + case 38 /* MinusToken */: + case 52 /* TildeToken */: + case 51 /* ExclamationToken */: + case 43 /* PlusPlusToken */: + case 44 /* MinusMinusToken */: return true; default: return false; } } function isKeyword(token) { - return token >= 71 /* FirstKeyword */ && token <= 141 /* LastKeyword */; + return token >= 72 /* FirstKeyword */ && token <= 142 /* LastKeyword */; } function classFromKind(token) { if (isKeyword(token)) { @@ -68989,7 +71744,7 @@ var ts; else if (isBinaryExpressionOperatorToken(token) || isPrefixUnaryExpressionOperatorToken(token)) { return 5 /* operator */; } - else if (token >= 16 /* FirstPunctuation */ && token <= 69 /* LastPunctuation */) { + else if (token >= 17 /* FirstPunctuation */ && token <= 70 /* LastPunctuation */) { return 10 /* punctuation */; } switch (token) { @@ -68997,7 +71752,7 @@ var ts; return 4 /* numericLiteral */; case 9 /* StringLiteral */: return 6 /* stringLiteral */; - case 11 /* RegularExpressionLiteral */: + case 12 /* RegularExpressionLiteral */: return 7 /* regularExpressionLiteral */; case 7 /* ConflictMarkerTrivia */: case 3 /* MultiLineCommentTrivia */: @@ -69006,7 +71761,7 @@ var ts; case 5 /* WhitespaceTrivia */: case 4 /* NewLineTrivia */: return 8 /* whiteSpace */; - case 70 /* Identifier */: + case 71 /* Identifier */: default: if (ts.isTemplateLiteralKind(token)) { return 6 /* stringLiteral */; @@ -69037,10 +71792,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 232 /* ModuleDeclaration */: - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 227 /* FunctionDeclaration */: + case 233 /* ModuleDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 228 /* FunctionDeclaration */: cancellationToken.throwIfCancellationRequested(); } } @@ -69091,7 +71846,7 @@ var ts; */ function hasValueSideModule(symbol) { return ts.forEach(symbol.declarations, function (declaration) { - return declaration.kind === 232 /* ModuleDeclaration */ && + return declaration.kind === 233 /* ModuleDeclaration */ && ts.getModuleInstanceState(declaration) === 1 /* Instantiated */; }); } @@ -69101,7 +71856,7 @@ var ts; if (node && ts.textSpanIntersectsWith(span, node.getFullStart(), node.getFullWidth())) { var kind = node.kind; checkForClassificationCancellation(cancellationToken, kind); - if (kind === 70 /* Identifier */ && !ts.nodeIsMissing(node)) { + if (kind === 71 /* Identifier */ && !ts.nodeIsMissing(node)) { var identifier = node; // Only bother calling into the typechecker if this is an identifier that // could possibly resolve to a type name. This makes classification run @@ -69255,16 +72010,16 @@ var ts; pushClassification(tag.tagName.pos, tag.tagName.end - tag.tagName.pos, 18 /* docCommentTagName */); pos = tag.tagName.end; switch (tag.kind) { - case 285 /* JSDocParameterTag */: + case 286 /* JSDocParameterTag */: processJSDocParameterTag(tag); break; - case 288 /* JSDocTemplateTag */: + case 289 /* JSDocTemplateTag */: processJSDocTemplateTag(tag); break; - case 287 /* JSDocTypeTag */: + case 288 /* JSDocTypeTag */: processElement(tag.typeExpression); break; - case 286 /* JSDocReturnTag */: + case 287 /* JSDocReturnTag */: processElement(tag.typeExpression); break; } @@ -69351,22 +72106,22 @@ var ts; } function tryClassifyJsxElementName(token) { switch (token.parent && token.parent.kind) { - case 250 /* JsxOpeningElement */: + case 251 /* JsxOpeningElement */: if (token.parent.tagName === token) { return 19 /* jsxOpenTagName */; } break; - case 251 /* JsxClosingElement */: + case 252 /* JsxClosingElement */: if (token.parent.tagName === token) { return 20 /* jsxCloseTagName */; } break; - case 249 /* JsxSelfClosingElement */: + case 250 /* JsxSelfClosingElement */: if (token.parent.tagName === token) { return 21 /* jsxSelfClosingTagName */; } break; - case 252 /* JsxAttribute */: + case 253 /* JsxAttribute */: if (token.parent.name === token) { return 22 /* jsxAttribute */; } @@ -69383,7 +72138,7 @@ var ts; } // Special case < and > If they appear in a generic context they are punctuation, // not operators. - if (tokenKind === 26 /* LessThanToken */ || tokenKind === 28 /* GreaterThanToken */) { + if (tokenKind === 27 /* LessThanToken */ || tokenKind === 29 /* GreaterThanToken */) { // If the node owning the token has a type argument list or type parameter list, then // we can effectively assume that a '<' and '>' belong to those lists. if (token && ts.getTypeArgumentOrTypeParameterList(token.parent)) { @@ -69392,19 +72147,19 @@ var ts; } if (ts.isPunctuation(tokenKind)) { if (token) { - if (tokenKind === 57 /* EqualsToken */) { + if (tokenKind === 58 /* EqualsToken */) { // the '=' in a variable declaration is special cased here. - if (token.parent.kind === 225 /* VariableDeclaration */ || - token.parent.kind === 148 /* PropertyDeclaration */ || - token.parent.kind === 145 /* Parameter */ || - token.parent.kind === 252 /* JsxAttribute */) { + if (token.parent.kind === 226 /* VariableDeclaration */ || + token.parent.kind === 149 /* PropertyDeclaration */ || + token.parent.kind === 146 /* Parameter */ || + token.parent.kind === 253 /* JsxAttribute */) { return 5 /* operator */; } } - if (token.parent.kind === 193 /* BinaryExpression */ || - token.parent.kind === 191 /* PrefixUnaryExpression */ || - token.parent.kind === 192 /* PostfixUnaryExpression */ || - token.parent.kind === 194 /* ConditionalExpression */) { + if (token.parent.kind === 194 /* BinaryExpression */ || + token.parent.kind === 192 /* PrefixUnaryExpression */ || + token.parent.kind === 193 /* PostfixUnaryExpression */ || + token.parent.kind === 195 /* ConditionalExpression */) { return 5 /* operator */; } } @@ -69414,9 +72169,9 @@ var ts; return 4 /* numericLiteral */; } else if (tokenKind === 9 /* StringLiteral */) { - return token.parent.kind === 252 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; + return token.parent.kind === 253 /* JsxAttribute */ ? 24 /* jsxAttributeStringLiteralValue */ : 6 /* stringLiteral */; } - else if (tokenKind === 11 /* RegularExpressionLiteral */) { + else if (tokenKind === 12 /* RegularExpressionLiteral */) { // TODO: we should get another classification type for these literals. return 6 /* stringLiteral */; } @@ -69427,35 +72182,35 @@ var ts; else if (tokenKind === 10 /* JsxText */) { return 23 /* jsxText */; } - else if (tokenKind === 70 /* Identifier */) { + else if (tokenKind === 71 /* Identifier */) { if (token) { switch (token.parent.kind) { - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: if (token.parent.name === token) { return 11 /* className */; } return; - case 144 /* TypeParameter */: + case 145 /* TypeParameter */: if (token.parent.name === token) { return 15 /* typeParameterName */; } return; - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: if (token.parent.name === token) { return 13 /* interfaceName */; } return; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: if (token.parent.name === token) { return 12 /* enumName */; } return; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (token.parent.name === token) { return 14 /* moduleName */; } return; - case 145 /* Parameter */: + case 146 /* Parameter */: if (token.parent.name === token) { return ts.isThisIdentifier(token) ? 3 /* keyword */ : 17 /* parameterName */; } @@ -69486,12 +72241,490 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var Completions; + (function (Completions) { + var PathCompletions; + (function (PathCompletions) { + function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { + var literalValue = ts.normalizeSlashes(node.text); + var scriptPath = node.getSourceFile().path; + var scriptDirectory = ts.getDirectoryPath(scriptPath); + var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); + var entries; + if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { + var extensions = ts.getSupportedExtensions(compilerOptions); + if (compilerOptions.rootDirs) { + entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); + } + else { + entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); + } + } + else { + // Check for node modules + entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); + } + return { + isGlobalCompletion: false, + isMemberCompletion: false, + isNewIdentifierLocation: true, + entries: entries + }; + } + PathCompletions.getStringLiteralCompletionEntriesFromModuleNames = getStringLiteralCompletionEntriesFromModuleNames; + /** + * Takes a script path and returns paths for all potential folders that could be merged with its + * containing folder via the "rootDirs" compiler option + */ + function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { + // Make all paths absolute/normalized if they are not already + rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); + // Determine the path to the directory containing the script relative to the root directory it is contained within + var relativeDirectory; + for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { + var rootDirectory = rootDirs_1[_i]; + if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { + relativeDirectory = scriptPath.substr(rootDirectory.length); + break; + } + } + // Now find a path for each potential directory that is to be merged with the one containing the script + return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); + } + function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { + var basePath = compilerOptions.project || host.getCurrentDirectory(); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); + var result = []; + for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { + var baseDirectory = baseDirectories_1[_i]; + getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); + } + return result; + } + /** + * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. + */ + function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { + if (result === void 0) { result = []; } + if (fragment === undefined) { + fragment = ""; + } + fragment = ts.normalizeSlashes(fragment); + /** + * Remove the basename from the path. Note that we don't use the basename to filter completions; + * the client is responsible for refining completions. + */ + fragment = ts.getDirectoryPath(fragment); + if (fragment === "") { + fragment = "." + ts.directorySeparator; + } + fragment = ts.ensureTrailingDirectorySeparator(fragment); + var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); + var baseDirectory = ts.getDirectoryPath(absolutePath); + var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); + if (tryDirectoryExists(host, baseDirectory)) { + // Enumerate the available files if possible + var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (files) { + /** + * Multiple file entries might map to the same truncated name once we remove extensions + * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: + * + * both foo.ts and foo.tsx become foo + */ + var foundFiles = ts.createMap(); + for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { + var filePath = files_3[_i]; + filePath = ts.normalizePath(filePath); + if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { + continue; + } + var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); + if (!foundFiles.get(foundFileName)) { + foundFiles.set(foundFileName, true); + } + } + ts.forEachKey(foundFiles, function (foundFile) { + result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); + }); + } + // If possible, get folder completion as well + var directories = tryGetDirectories(host, baseDirectory); + if (directories) { + for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { + var directory = directories_2[_a]; + var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); + result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); + } + } + } + return result; + } + /** + * Check all of the declared modules and those in node modules. Possible sources of modules: + * Modules that are found by the type checker + * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) + * Modules from node_modules (i.e. those listed in package.json) + * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions + */ + function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { + var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; + var result; + if (baseUrl) { + var fileExtensions = ts.getSupportedExtensions(compilerOptions); + var projectDir = compilerOptions.project || host.getCurrentDirectory(); + var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); + result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); + if (paths) { + for (var path in paths) { + if (paths.hasOwnProperty(path)) { + if (path === "*") { + if (paths[path]) { + for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { + var pattern = _a[_i]; + for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { + var match = _c[_b]; + result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + else if (ts.startsWith(path, fragment)) { + var entry = paths[path] && paths[path].length === 1 && paths[path][0]; + if (entry) { + result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + } + } + else { + result = []; + } + getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); + for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { + var moduleName = _e[_d]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + return result; + } + function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { + if (host.readDirectory) { + var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; + if (parsed) { + // The prefix has two effective parts: the directory path and the base component after the filepath that is not a + // full directory component. For example: directory/path/of/prefix/base* + var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); + var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); + var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); + var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; + // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call + var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; + var normalizedSuffix = ts.normalizePath(parsed.suffix); + var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); + var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; + // If we have a suffix, then we need to read the directory all the way down. We could create a glob + // that encodes the suffix, but we would have to escape the character "?" which readDirectory + // doesn't support. For now, this is safer but slower + var includeGlob = normalizedSuffix ? "**/*" : "./*"; + var matches = tryReadDirectory(host, baseDirectory, fileExtensions, /*exclude*/ undefined, [includeGlob]); + if (matches) { + var result = []; + // Trim away prefix and suffix + for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { + var match = matches_1[_i]; + var normalizedMatch = ts.normalizePath(match); + if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { + continue; + } + var start = completePrefix.length; + var length_6 = normalizedMatch.length - start - normalizedSuffix.length; + result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_6))); + } + return result; + } + } + } + return undefined; + } + function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { + // Check If this is a nested module + var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; + var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; + // Get modules that the type checker picked up + var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); + var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); + // Nested modules of the form "module-name/sub" need to be adjusted to only return the string + // after the last '/' that appears in the fragment because that's where the replacement span + // starts + if (isNestedModule) { + var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); + nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { + if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { + return moduleName.substr(moduleNameWithSeperator_1.length); + } + return moduleName; + }); + } + if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { + for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { + var visibleModule = _a[_i]; + if (!isNestedModule) { + nonRelativeModules.push(visibleModule.moduleName); + } + else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { + var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); + if (nestedFiles) { + for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { + var f = nestedFiles_1[_b]; + f = ts.normalizePath(f); + var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); + nonRelativeModules.push(nestedModule); + } + } + } + } + } + return ts.deduplicate(nonRelativeModules); + } + function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { + var token = ts.getTokenAtPosition(sourceFile, position); + if (!token) { + return undefined; + } + var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); + if (!commentRanges || !commentRanges.length) { + return undefined; + } + var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); + if (!range) { + return undefined; + } + var completionInfo = { + /** + * We don't want the editor to offer any other completions, such as snippets, inside a comment. + */ + isGlobalCompletion: false, + isMemberCompletion: false, + /** + * The user may type in a path that doesn't yet exist, creating a "new identifier" + * with respect to the collection of identifiers the server is aware of. + */ + isNewIdentifierLocation: true, + entries: [] + }; + var text = sourceFile.text.substr(range.pos, position - range.pos); + var match = tripleSlashDirectiveFragmentRegex.exec(text); + if (match) { + var prefix = match[1]; + var kind = match[2]; + var toComplete = match[3]; + var scriptPath = ts.getDirectoryPath(sourceFile.path); + if (kind === "path") { + // Give completions for a relative path + var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); + completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); + } + else { + // Give completions based on the typings available + var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; + completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); + } + } + return completionInfo; + } + PathCompletions.getTripleSlashReferenceCompletion = getTripleSlashReferenceCompletion; + function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { + if (result === void 0) { result = []; } + // Check for typings specified in compiler options + if (options.types) { + for (var _i = 0, _a = options.types; _i < _a.length; _i++) { + var moduleName = _a[_i]; + result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); + } + } + else if (host.getDirectories) { + var typeRoots = void 0; + try { + // Wrap in try catch because getEffectiveTypeRoots touches the filesystem + typeRoots = ts.getEffectiveTypeRoots(options, host); + } + catch (e) { } + if (typeRoots) { + for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { + var root = typeRoots_2[_b]; + getCompletionEntriesFromDirectories(host, root, span, result); + } + } + } + if (host.getDirectories) { + // Also get all @types typings installed in visible node_modules directories + for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { + var packageJson = _d[_c]; + var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); + getCompletionEntriesFromDirectories(host, typesDir, span, result); + } + } + return result; + } + function getCompletionEntriesFromDirectories(host, directory, span, result) { + if (host.getDirectories && tryDirectoryExists(host, directory)) { + var directories = tryGetDirectories(host, directory); + if (directories) { + for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { + var typeDirectory = directories_3[_i]; + typeDirectory = ts.normalizePath(typeDirectory); + result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); + } + } + } + } + function findPackageJsons(currentDir, host) { + var paths = []; + var currentConfigPath; + while (true) { + currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); + if (currentConfigPath) { + paths.push(currentConfigPath); + currentDir = ts.getDirectoryPath(currentConfigPath); + var parent = ts.getDirectoryPath(currentDir); + if (currentDir === parent) { + break; + } + currentDir = parent; + } + else { + break; + } + } + return paths; + } + function enumerateNodeModulesVisibleToScript(host, scriptPath) { + var result = []; + if (host.readFile && host.fileExists) { + for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { + var packageJson = _a[_i]; + var contents = tryReadingPackageJson(packageJson); + if (!contents) { + return; + } + var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); + var foundModuleNames = []; + // Provide completions for all non @types dependencies + for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { + var key = nodeModulesDependencyKeys_1[_b]; + addPotentialPackageNames(contents[key], foundModuleNames); + } + for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { + var moduleName = foundModuleNames_1[_c]; + var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); + result.push({ + moduleName: moduleName, + moduleDir: moduleDir + }); + } + } + } + return result; + function tryReadingPackageJson(filePath) { + try { + var fileText = tryReadFile(host, filePath); + return fileText ? JSON.parse(fileText) : undefined; + } + catch (e) { + return undefined; + } + } + function addPotentialPackageNames(dependencies, result) { + if (dependencies) { + for (var dep in dependencies) { + if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { + result.push(dep); + } + } + } + } + } + function createCompletionEntryForModule(name, kind, replacementSpan) { + return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; + } + // Replace everything after the last directory seperator that appears + function getDirectoryFragmentTextSpan(text, textStart) { + var index = text.lastIndexOf(ts.directorySeparator); + var offset = index !== -1 ? index + 1 : 0; + return { start: textStart + offset, length: text.length - offset }; + } + // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) + function isPathRelativeToScript(path) { + if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { + var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; + var slashCharCode = path.charCodeAt(slashIndex); + return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; + } + return false; + } + function normalizeAndPreserveTrailingSlash(path) { + return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); + } + /** + * Matches a triple slash reference directive with an incomplete string literal for its path. Used + * to determine if the caret is currently within the string literal and capture the literal fragment + * for completions. + * For example, this matches + * + * /// +/* @internal */ +var ts; (function (ts) { var Completions; (function (Completions) { function getCompletionsAtPosition(host, typeChecker, log, compilerOptions, sourceFile, position) { if (ts.isInReferenceComment(sourceFile, position)) { - return getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); + return Completions.PathCompletions.getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host); } if (ts.isInString(sourceFile, position)) { return getStringLiteralCompletionEntries(sourceFile, position, typeChecker, compilerOptions, host, log); @@ -69500,10 +72733,14 @@ var ts; if (!completionData) { return undefined; } - var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, isJsDocTagName = completionData.isJsDocTagName; - if (isJsDocTagName) { + var symbols = completionData.symbols, isGlobalCompletion = completionData.isGlobalCompletion, isMemberCompletion = completionData.isMemberCompletion, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, requestJsDocTagName = completionData.requestJsDocTagName, requestJsDocTag = completionData.requestJsDocTag; + if (requestJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion - return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getAllJsDocCompletionEntries() }; + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getJSDocTagNameCompletions() }; + } + if (requestJsDocTag) { + // If the current position is a jsDoc tag, only tags should be provided for completion + return { isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, entries: ts.JsDoc.getJSDocTagCompletions() }; } var entries = []; if (ts.isSourceFileJavaScript(sourceFile)) { @@ -69513,7 +72750,7 @@ var ts; else { if (!symbols || symbols.length === 0) { if (sourceFile.languageVariant === 1 /* JSX */ && - location.parent && location.parent.kind === 251 /* JsxClosingElement */) { + location.parent && location.parent.kind === 252 /* 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: @@ -69533,7 +72770,7 @@ var ts; getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } // Add keywords if this is not a member completion list - if (!isMemberCompletion && !isJsDocTagName) { + if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) { ts.addRange(entries, keywordCompletions); } return { isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, entries: entries }; @@ -69609,8 +72846,8 @@ var ts; if (!node || node.kind !== 9 /* StringLiteral */) { return undefined; } - if (node.parent.kind === 260 /* PropertyAssignment */ && - node.parent.parent.kind === 177 /* ObjectLiteralExpression */ && + if (node.parent.kind === 261 /* PropertyAssignment */ && + node.parent.parent.kind === 178 /* ObjectLiteralExpression */ && node.parent.name === node) { // Get quoted name of properties of the object literal expression // i.e. interface ConfigFiles { @@ -69635,12 +72872,12 @@ var ts; // a['/*completion position*/'] return getStringLiteralCompletionEntriesFromElementAccess(node.parent, typeChecker, compilerOptions.target, log); } - else if (node.parent.kind === 237 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, false)) { + else if (node.parent.kind === 238 /* ImportDeclaration */ || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node) || ts.isRequireCall(node.parent, /*checkArgumentIsStringLiteral*/ false)) { // Get all known external module names or complete a path to a module // i.e. import * as ns from "/*completion position*/"; // import x = require("/*completion position*/"); // var y = require("/*completion position*/"); - return getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); + return Completions.PathCompletions.getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker); } else if (isEqualityExpression(node.parent)) { // Get completions from the type of the other operand @@ -69733,427 +72970,6 @@ var ts; }); } } - function getStringLiteralCompletionEntriesFromModuleNames(node, compilerOptions, host, typeChecker) { - var literalValue = ts.normalizeSlashes(node.text); - var scriptPath = node.getSourceFile().path; - var scriptDirectory = ts.getDirectoryPath(scriptPath); - var span = getDirectoryFragmentTextSpan(node.text, node.getStart() + 1); - var entries; - if (isPathRelativeToScript(literalValue) || ts.isRootedDiskPath(literalValue)) { - var extensions = ts.getSupportedExtensions(compilerOptions); - if (compilerOptions.rootDirs) { - entries = getCompletionEntriesForDirectoryFragmentWithRootDirs(compilerOptions.rootDirs, literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, compilerOptions, host, scriptPath); - } - else { - entries = getCompletionEntriesForDirectoryFragment(literalValue, scriptDirectory, extensions, /*includeExtensions*/ false, span, host, scriptPath); - } - } - else { - // Check for node modules - entries = getCompletionEntriesForNonRelativeModules(literalValue, scriptDirectory, span, compilerOptions, host, typeChecker); - } - return { - isGlobalCompletion: false, - isMemberCompletion: false, - isNewIdentifierLocation: true, - entries: entries - }; - } - /** - * Takes a script path and returns paths for all potential folders that could be merged with its - * containing folder via the "rootDirs" compiler option - */ - function getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase) { - // Make all paths absolute/normalized if they are not already - rootDirs = ts.map(rootDirs, function (rootDirectory) { return ts.normalizePath(ts.isRootedDiskPath(rootDirectory) ? rootDirectory : ts.combinePaths(basePath, rootDirectory)); }); - // Determine the path to the directory containing the script relative to the root directory it is contained within - var relativeDirectory; - for (var _i = 0, rootDirs_1 = rootDirs; _i < rootDirs_1.length; _i++) { - var rootDirectory = rootDirs_1[_i]; - if (ts.containsPath(rootDirectory, scriptPath, basePath, ignoreCase)) { - relativeDirectory = scriptPath.substr(rootDirectory.length); - break; - } - } - // Now find a path for each potential directory that is to be merged with the one containing the script - return ts.deduplicate(ts.map(rootDirs, function (rootDirectory) { return ts.combinePaths(rootDirectory, relativeDirectory); })); - } - function getCompletionEntriesForDirectoryFragmentWithRootDirs(rootDirs, fragment, scriptPath, extensions, includeExtensions, span, compilerOptions, host, exclude) { - var basePath = compilerOptions.project || host.getCurrentDirectory(); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - var baseDirectories = getBaseDirectoriesFromRootDirs(rootDirs, basePath, scriptPath, ignoreCase); - var result = []; - for (var _i = 0, baseDirectories_1 = baseDirectories; _i < baseDirectories_1.length; _i++) { - var baseDirectory = baseDirectories_1[_i]; - getCompletionEntriesForDirectoryFragment(fragment, baseDirectory, extensions, includeExtensions, span, host, exclude, result); - } - return result; - } - /** - * Given a path ending at a directory, gets the completions for the path, and filters for those entries containing the basename. - */ - function getCompletionEntriesForDirectoryFragment(fragment, scriptPath, extensions, includeExtensions, span, host, exclude, result) { - if (result === void 0) { result = []; } - if (fragment === undefined) { - fragment = ""; - } - fragment = ts.normalizeSlashes(fragment); - /** - * Remove the basename from the path. Note that we don't use the basename to filter completions; - * the client is responsible for refining completions. - */ - fragment = ts.getDirectoryPath(fragment); - if (fragment === "") { - fragment = "." + ts.directorySeparator; - } - fragment = ts.ensureTrailingDirectorySeparator(fragment); - var absolutePath = normalizeAndPreserveTrailingSlash(ts.isRootedDiskPath(fragment) ? fragment : ts.combinePaths(scriptPath, fragment)); - var baseDirectory = ts.getDirectoryPath(absolutePath); - var ignoreCase = !(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames()); - if (tryDirectoryExists(host, baseDirectory)) { - // Enumerate the available files if possible - var files = tryReadDirectory(host, baseDirectory, extensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (files) { - /** - * Multiple file entries might map to the same truncated name once we remove extensions - * (happens iff includeExtensions === false)so we use a set-like data structure. Eg: - * - * both foo.ts and foo.tsx become foo - */ - var foundFiles = ts.createMap(); - for (var _i = 0, files_3 = files; _i < files_3.length; _i++) { - var filePath = files_3[_i]; - filePath = ts.normalizePath(filePath); - if (exclude && ts.comparePaths(filePath, exclude, scriptPath, ignoreCase) === 0 /* EqualTo */) { - continue; - } - var foundFileName = includeExtensions ? ts.getBaseFileName(filePath) : ts.removeFileExtension(ts.getBaseFileName(filePath)); - if (!foundFiles.get(foundFileName)) { - foundFiles.set(foundFileName, true); - } - } - ts.forEachKey(foundFiles, function (foundFile) { - result.push(createCompletionEntryForModule(foundFile, ts.ScriptElementKind.scriptElement, span)); - }); - } - // If possible, get folder completion as well - var directories = tryGetDirectories(host, baseDirectory); - if (directories) { - for (var _a = 0, directories_2 = directories; _a < directories_2.length; _a++) { - var directory = directories_2[_a]; - var directoryName = ts.getBaseFileName(ts.normalizePath(directory)); - result.push(createCompletionEntryForModule(directoryName, ts.ScriptElementKind.directory, span)); - } - } - } - return result; - } - /** - * Check all of the declared modules and those in node modules. Possible sources of modules: - * Modules that are found by the type checker - * Modules found relative to "baseUrl" compliler options (including patterns from "paths" compiler option) - * Modules from node_modules (i.e. those listed in package.json) - * This includes all files that are found in node_modules/moduleName/ with acceptable file extensions - */ - function getCompletionEntriesForNonRelativeModules(fragment, scriptPath, span, compilerOptions, host, typeChecker) { - var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths; - var result; - if (baseUrl) { - var fileExtensions = ts.getSupportedExtensions(compilerOptions); - var projectDir = compilerOptions.project || host.getCurrentDirectory(); - var absolute = ts.isRootedDiskPath(baseUrl) ? baseUrl : ts.combinePaths(projectDir, baseUrl); - result = getCompletionEntriesForDirectoryFragment(fragment, ts.normalizePath(absolute), fileExtensions, /*includeExtensions*/ false, span, host); - if (paths) { - for (var path in paths) { - if (paths.hasOwnProperty(path)) { - if (path === "*") { - if (paths[path]) { - for (var _i = 0, _a = paths[path]; _i < _a.length; _i++) { - var pattern = _a[_i]; - for (var _b = 0, _c = getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host); _b < _c.length; _b++) { - var match = _c[_b]; - result.push(createCompletionEntryForModule(match, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - else if (ts.startsWith(path, fragment)) { - var entry = paths[path] && paths[path].length === 1 && paths[path][0]; - if (entry) { - result.push(createCompletionEntryForModule(path, ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - } - } - else { - result = []; - } - getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span, result); - for (var _d = 0, _e = enumeratePotentialNonRelativeModules(fragment, scriptPath, compilerOptions, typeChecker, host); _d < _e.length; _d++) { - var moduleName = _e[_d]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - return result; - } - function getModulesForPathsPattern(fragment, baseUrl, pattern, fileExtensions, host) { - if (host.readDirectory) { - var parsed = ts.hasZeroOrOneAsteriskCharacter(pattern) ? ts.tryParsePattern(pattern) : undefined; - if (parsed) { - // The prefix has two effective parts: the directory path and the base component after the filepath that is not a - // full directory component. For example: directory/path/of/prefix/base* - var normalizedPrefix = normalizeAndPreserveTrailingSlash(parsed.prefix); - var normalizedPrefixDirectory = ts.getDirectoryPath(normalizedPrefix); - var normalizedPrefixBase = ts.getBaseFileName(normalizedPrefix); - var fragmentHasPath = fragment.indexOf(ts.directorySeparator) !== -1; - // Try and expand the prefix to include any path from the fragment so that we can limit the readDirectory call - var expandedPrefixDirectory = fragmentHasPath ? ts.combinePaths(normalizedPrefixDirectory, normalizedPrefixBase + ts.getDirectoryPath(fragment)) : normalizedPrefixDirectory; - var normalizedSuffix = ts.normalizePath(parsed.suffix); - var baseDirectory = ts.combinePaths(baseUrl, expandedPrefixDirectory); - var completePrefix = fragmentHasPath ? baseDirectory : ts.ensureTrailingDirectorySeparator(baseDirectory) + normalizedPrefixBase; - // If we have a suffix, then we need to read the directory all the way down. We could create a glob - // that encodes the suffix, but we would have to escape the character "?" which readDirectory - // doesn't support. For now, this is safer but slower - var includeGlob = normalizedSuffix ? "**/*" : "./*"; - var matches = tryReadDirectory(host, baseDirectory, fileExtensions, undefined, [includeGlob]); - if (matches) { - var result = []; - // Trim away prefix and suffix - for (var _i = 0, matches_1 = matches; _i < matches_1.length; _i++) { - var match = matches_1[_i]; - var normalizedMatch = ts.normalizePath(match); - if (!ts.endsWith(normalizedMatch, normalizedSuffix) || !ts.startsWith(normalizedMatch, completePrefix)) { - continue; - } - var start = completePrefix.length; - var length_5 = normalizedMatch.length - start - normalizedSuffix.length; - result.push(ts.removeFileExtension(normalizedMatch.substr(start, length_5))); - } - return result; - } - } - } - return undefined; - } - function enumeratePotentialNonRelativeModules(fragment, scriptPath, options, typeChecker, host) { - // Check If this is a nested module - var isNestedModule = fragment.indexOf(ts.directorySeparator) !== -1; - var moduleNameFragment = isNestedModule ? fragment.substr(0, fragment.lastIndexOf(ts.directorySeparator)) : undefined; - // Get modules that the type checker picked up - var ambientModules = ts.map(typeChecker.getAmbientModules(), function (sym) { return ts.stripQuotes(sym.name); }); - var nonRelativeModules = ts.filter(ambientModules, function (moduleName) { return ts.startsWith(moduleName, fragment); }); - // Nested modules of the form "module-name/sub" need to be adjusted to only return the string - // after the last '/' that appears in the fragment because that's where the replacement span - // starts - if (isNestedModule) { - var moduleNameWithSeperator_1 = ts.ensureTrailingDirectorySeparator(moduleNameFragment); - nonRelativeModules = ts.map(nonRelativeModules, function (moduleName) { - if (ts.startsWith(fragment, moduleNameWithSeperator_1)) { - return moduleName.substr(moduleNameWithSeperator_1.length); - } - return moduleName; - }); - } - if (!options.moduleResolution || options.moduleResolution === ts.ModuleResolutionKind.NodeJs) { - for (var _i = 0, _a = enumerateNodeModulesVisibleToScript(host, scriptPath); _i < _a.length; _i++) { - var visibleModule = _a[_i]; - if (!isNestedModule) { - nonRelativeModules.push(visibleModule.moduleName); - } - else if (ts.startsWith(visibleModule.moduleName, moduleNameFragment)) { - var nestedFiles = tryReadDirectory(host, visibleModule.moduleDir, ts.supportedTypeScriptExtensions, /*exclude*/ undefined, /*include*/ ["./*"]); - if (nestedFiles) { - for (var _b = 0, nestedFiles_1 = nestedFiles; _b < nestedFiles_1.length; _b++) { - var f = nestedFiles_1[_b]; - f = ts.normalizePath(f); - var nestedModule = ts.removeFileExtension(ts.getBaseFileName(f)); - nonRelativeModules.push(nestedModule); - } - } - } - } - } - return ts.deduplicate(nonRelativeModules); - } - function getTripleSlashReferenceCompletion(sourceFile, position, compilerOptions, host) { - var token = ts.getTokenAtPosition(sourceFile, position); - if (!token) { - return undefined; - } - var commentRanges = ts.getLeadingCommentRanges(sourceFile.text, token.pos); - if (!commentRanges || !commentRanges.length) { - return undefined; - } - var range = ts.forEach(commentRanges, function (commentRange) { return position >= commentRange.pos && position <= commentRange.end && commentRange; }); - if (!range) { - return undefined; - } - var completionInfo = { - /** - * We don't want the editor to offer any other completions, such as snippets, inside a comment. - */ - isGlobalCompletion: false, - isMemberCompletion: false, - /** - * The user may type in a path that doesn't yet exist, creating a "new identifier" - * with respect to the collection of identifiers the server is aware of. - */ - isNewIdentifierLocation: true, - entries: [] - }; - var text = sourceFile.text.substr(range.pos, position - range.pos); - var match = tripleSlashDirectiveFragmentRegex.exec(text); - if (match) { - var prefix = match[1]; - var kind = match[2]; - var toComplete = match[3]; - var scriptPath = ts.getDirectoryPath(sourceFile.path); - if (kind === "path") { - // Give completions for a relative path - var span_10 = getDirectoryFragmentTextSpan(toComplete, range.pos + prefix.length); - completionInfo.entries = getCompletionEntriesForDirectoryFragment(toComplete, scriptPath, ts.getSupportedExtensions(compilerOptions), /*includeExtensions*/ true, span_10, host, sourceFile.path); - } - else { - // Give completions based on the typings available - var span_11 = { start: range.pos + prefix.length, length: match[0].length - prefix.length }; - completionInfo.entries = getCompletionEntriesFromTypings(host, compilerOptions, scriptPath, span_11); - } - } - return completionInfo; - } - function getCompletionEntriesFromTypings(host, options, scriptPath, span, result) { - if (result === void 0) { result = []; } - // Check for typings specified in compiler options - if (options.types) { - for (var _i = 0, _a = options.types; _i < _a.length; _i++) { - var moduleName = _a[_i]; - result.push(createCompletionEntryForModule(moduleName, ts.ScriptElementKind.externalModuleName, span)); - } - } - else if (host.getDirectories) { - var typeRoots = void 0; - try { - // Wrap in try catch because getEffectiveTypeRoots touches the filesystem - typeRoots = ts.getEffectiveTypeRoots(options, host); - } - catch (e) { } - if (typeRoots) { - for (var _b = 0, typeRoots_2 = typeRoots; _b < typeRoots_2.length; _b++) { - var root = typeRoots_2[_b]; - getCompletionEntriesFromDirectories(host, root, span, result); - } - } - } - if (host.getDirectories) { - // Also get all @types typings installed in visible node_modules directories - for (var _c = 0, _d = findPackageJsons(scriptPath, host); _c < _d.length; _c++) { - var packageJson = _d[_c]; - var typesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules/@types"); - getCompletionEntriesFromDirectories(host, typesDir, span, result); - } - } - return result; - } - function getCompletionEntriesFromDirectories(host, directory, span, result) { - if (host.getDirectories && tryDirectoryExists(host, directory)) { - var directories = tryGetDirectories(host, directory); - if (directories) { - for (var _i = 0, directories_3 = directories; _i < directories_3.length; _i++) { - var typeDirectory = directories_3[_i]; - typeDirectory = ts.normalizePath(typeDirectory); - result.push(createCompletionEntryForModule(ts.getBaseFileName(typeDirectory), ts.ScriptElementKind.externalModuleName, span)); - } - } - } - } - function findPackageJsons(currentDir, host) { - var paths = []; - var currentConfigPath; - while (true) { - currentConfigPath = ts.findConfigFile(currentDir, function (f) { return tryFileExists(host, f); }, "package.json"); - if (currentConfigPath) { - paths.push(currentConfigPath); - currentDir = ts.getDirectoryPath(currentConfigPath); - var parent = ts.getDirectoryPath(currentDir); - if (currentDir === parent) { - break; - } - currentDir = parent; - } - else { - break; - } - } - return paths; - } - function enumerateNodeModulesVisibleToScript(host, scriptPath) { - var result = []; - if (host.readFile && host.fileExists) { - for (var _i = 0, _a = findPackageJsons(scriptPath, host); _i < _a.length; _i++) { - var packageJson = _a[_i]; - var contents = tryReadingPackageJson(packageJson); - if (!contents) { - return; - } - var nodeModulesDir = ts.combinePaths(ts.getDirectoryPath(packageJson), "node_modules"); - var foundModuleNames = []; - // Provide completions for all non @types dependencies - for (var _b = 0, nodeModulesDependencyKeys_1 = nodeModulesDependencyKeys; _b < nodeModulesDependencyKeys_1.length; _b++) { - var key = nodeModulesDependencyKeys_1[_b]; - addPotentialPackageNames(contents[key], foundModuleNames); - } - for (var _c = 0, foundModuleNames_1 = foundModuleNames; _c < foundModuleNames_1.length; _c++) { - var moduleName = foundModuleNames_1[_c]; - var moduleDir = ts.combinePaths(nodeModulesDir, moduleName); - result.push({ - moduleName: moduleName, - moduleDir: moduleDir - }); - } - } - } - return result; - function tryReadingPackageJson(filePath) { - try { - var fileText = tryReadFile(host, filePath); - return fileText ? JSON.parse(fileText) : undefined; - } - catch (e) { - return undefined; - } - } - function addPotentialPackageNames(dependencies, result) { - if (dependencies) { - for (var dep in dependencies) { - if (dependencies.hasOwnProperty(dep) && !ts.startsWith(dep, "@types/")) { - result.push(dep); - } - } - } - } - } - function createCompletionEntryForModule(name, kind, replacementSpan) { - return { name: name, kind: kind, kindModifiers: ts.ScriptElementKindModifier.none, sortText: name, replacementSpan: replacementSpan }; - } - // Replace everything after the last directory seperator that appears - function getDirectoryFragmentTextSpan(text, textStart) { - var index = text.lastIndexOf(ts.directorySeparator); - var offset = index !== -1 ? index + 1 : 0; - return { start: textStart + offset, length: text.length - offset }; - } - // Returns true if the path is explicitly relative to the script (i.e. relative to . or ..) - function isPathRelativeToScript(path) { - if (path && path.length >= 2 && path.charCodeAt(0) === 46 /* dot */) { - var slashIndex = path.length >= 3 && path.charCodeAt(1) === 46 /* dot */ ? 2 : 1; - var slashCharCode = path.charCodeAt(slashIndex); - return slashCharCode === 47 /* slash */ || slashCharCode === 92 /* backslash */; - } - return false; - } - function normalizeAndPreserveTrailingSlash(path) { - return ts.hasTrailingDirectorySeparator(path) ? ts.ensureTrailingDirectorySeparator(ts.normalizePath(path)) : ts.normalizePath(path); - } function getCompletionEntryDetails(typeChecker, log, compilerOptions, sourceFile, position, entryName) { // Compute all the completion symbols again. var completionData = getCompletionData(typeChecker, log, sourceFile, position); @@ -70165,13 +72981,14 @@ var ts; // completion entry. var symbol = ts.forEach(symbols, function (s) { return getCompletionEntryDisplayNameForSymbol(typeChecker, s, compilerOptions.target, /*performCharacterChecks*/ false, location_1) === entryName ? s : undefined; }); if (symbol) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind; + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, sourceFile, location_1, location_1, 7 /* All */), displayParts = _a.displayParts, documentation = _a.documentation, symbolKind = _a.symbolKind, tags = _a.tags; return { name: entryName, kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), kind: symbolKind, displayParts: displayParts, - documentation: documentation + documentation: documentation, + tags: tags }; } } @@ -70183,7 +73000,8 @@ var ts; kind: ts.ScriptElementKind.keyword, kindModifiers: ts.ScriptElementKindModifier.none, displayParts: [ts.displayPart(entryName, ts.SymbolDisplayPartKind.keyword)], - documentation: undefined + documentation: undefined, + tags: undefined }; } return undefined; @@ -70205,7 +73023,10 @@ var ts; Completions.getCompletionEntrySymbol = getCompletionEntrySymbol; function getCompletionData(typeChecker, log, sourceFile, position) { var isJavaScriptFile = ts.isSourceFileJavaScript(sourceFile); - var isJsDocTagName = false; + // JsDoc tag-name is just the name of the JSDoc tagname (exclude "@") + var requestJsDocTagName = false; + // JsDoc tag includes both "@" and tag-name + var requestJsDocTag = false; var start = ts.timestamp(); var currentToken = ts.getTokenAtPosition(sourceFile, position); log("getCompletionData: Get current token: " + (ts.timestamp() - start)); @@ -70214,10 +73035,32 @@ var ts; var insideComment = ts.isInsideComment(sourceFile, currentToken, position); log("getCompletionData: Is inside comment: " + (ts.timestamp() - start)); if (insideComment) { - // The current position is next to the '@' sign, when no tag name being provided yet. - // Provide a full list of tag names - if (ts.hasDocComment(sourceFile, position) && sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { - isJsDocTagName = true; + if (ts.hasDocComment(sourceFile, position)) { + // The current position is next to the '@' sign, when no tag name being provided yet. + // Provide a full list of tag names + if (sourceFile.text.charCodeAt(position - 1) === 64 /* at */) { + requestJsDocTagName = true; + } + else { + // When completion is requested without "@", we will have check to make sure that + // there are no comments prefix the request position. We will only allow "*" and space. + // e.g + // /** |c| /* + // + // /** + // |c| + // */ + // + // /** + // * |c| + // */ + // + // /** + // * |c| + // */ + var lineStart = ts.getLineStartPositionForPosition(position, sourceFile); + requestJsDocTag = !(sourceFile.text.substring(lineStart, position).match(/[^\*|\s|(/\*\*)]/)); + } } // Completion should work inside certain JsDoc tags. For example: // /** @type {number | string} */ @@ -70226,12 +73069,12 @@ var ts; var tag = ts.getJsDocTagAtPosition(sourceFile, position); if (tag) { if (tag.tagName.pos <= position && position <= tag.tagName.end) { - isJsDocTagName = true; + requestJsDocTagName = true; } switch (tag.kind) { - case 287 /* JSDocTypeTag */: - case 285 /* JSDocParameterTag */: - case 286 /* JSDocReturnTag */: + case 288 /* JSDocTypeTag */: + case 286 /* JSDocParameterTag */: + case 287 /* JSDocReturnTag */: var tagWithExpression = tag; if (tagWithExpression.typeExpression) { insideJsDocTagExpression = tagWithExpression.typeExpression.pos < position && position < tagWithExpression.typeExpression.end; @@ -70239,8 +73082,8 @@ var ts; break; } } - if (isJsDocTagName) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, isJsDocTagName: isJsDocTagName }; + if (requestJsDocTagName || requestJsDocTag) { + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; } if (!insideJsDocTagExpression) { // Proceed if the current position is in jsDoc tag expression; otherwise it is a normal @@ -70276,13 +73119,13 @@ var ts; log("Returning an empty list because completion was requested in an invalid position."); return undefined; } - var parent = contextToken.parent, kind = contextToken.kind; - if (kind === 22 /* DotToken */) { - if (parent.kind === 178 /* PropertyAccessExpression */) { + var parent = contextToken.parent; + if (contextToken.kind === 23 /* DotToken */) { + if (parent.kind === 179 /* PropertyAccessExpression */) { node = contextToken.parent.expression; isRightOfDot = true; } - else if (parent.kind === 142 /* QualifiedName */) { + else if (parent.kind === 143 /* QualifiedName */) { node = contextToken.parent.left; isRightOfDot = true; } @@ -70293,23 +73136,30 @@ var ts; } } else if (sourceFile.languageVariant === 1 /* JSX */) { - switch (contextToken.parent.kind) { - case 251 /* JsxClosingElement */: - if (kind === 40 /* SlashToken */) { + // + // If the tagname is a property access expression, we will then walk up to the top most of property access expression. + // Then, try to get a JSX container and its associated attributes type. + if (parent && parent.kind === 179 /* PropertyAccessExpression */) { + contextToken = parent; + parent = parent.parent; + } + switch (parent.kind) { + case 252 /* JsxClosingElement */: + if (contextToken.kind === 41 /* SlashToken */) { isStartingCloseTag = true; location = contextToken; } break; - case 193 /* BinaryExpression */: - if (!(contextToken.parent.left.flags & 32768 /* ThisNodeHasError */)) { + case 194 /* BinaryExpression */: + if (!(parent.left.flags & 32768 /* ThisNodeHasError */)) { // It has a left-hand side, so we're not in an opening JSX tag. break; } - // fall through - case 249 /* JsxSelfClosingElement */: - case 248 /* JsxElement */: - case 250 /* JsxOpeningElement */: - if (kind === 26 /* LessThanToken */) { + // falls through + case 250 /* JsxSelfClosingElement */: + case 249 /* JsxElement */: + case 251 /* JsxOpeningElement */: + if (contextToken.kind === 27 /* LessThanToken */) { isRightOfOpenTag = true; location = contextToken; } @@ -70354,13 +73204,13 @@ var ts; } } log("getCompletionData: Semantic work: " + (ts.timestamp() - semanticStart)); - return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), isJsDocTagName: isJsDocTagName }; + return { symbols: symbols, isGlobalCompletion: isGlobalCompletion, isMemberCompletion: isMemberCompletion, isNewIdentifierLocation: isNewIdentifierLocation, location: location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName: requestJsDocTagName, requestJsDocTag: requestJsDocTag }; function getTypeScriptMemberSymbols() { // Right of dot member completion list isGlobalCompletion = false; isMemberCompletion = true; isNewIdentifierLocation = false; - if (node.kind === 70 /* Identifier */ || node.kind === 142 /* QualifiedName */ || node.kind === 178 /* PropertyAccessExpression */) { + if (node.kind === 71 /* Identifier */ || node.kind === 143 /* QualifiedName */ || node.kind === 179 /* PropertyAccessExpression */) { var symbol = typeChecker.getSymbolAtLocation(node); // This is an alias, follow what it aliases if (symbol && symbol.flags & 8388608 /* Alias */) { @@ -70416,7 +73266,7 @@ var ts; } if (jsxContainer = tryGetContainingJsxElement(contextToken)) { var attrsType = void 0; - if ((jsxContainer.kind === 249 /* JsxSelfClosingElement */) || (jsxContainer.kind === 250 /* JsxOpeningElement */)) { + if ((jsxContainer.kind === 250 /* JsxSelfClosingElement */) || (jsxContainer.kind === 251 /* JsxOpeningElement */)) { // Cursor is inside a JSX self-closing element or opening element attrsType = typeChecker.getAllAttributesTypeFromJsxOpeningLikeElement(jsxContainer); if (attrsType) { @@ -70464,9 +73314,9 @@ var ts; var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile; if (scopeNode) { isGlobalCompletion = - scopeNode.kind === 264 /* SourceFile */ || - scopeNode.kind === 195 /* TemplateExpression */ || - scopeNode.kind === 255 /* JsxExpression */ || + scopeNode.kind === 265 /* SourceFile */ || + scopeNode.kind === 196 /* TemplateExpression */ || + scopeNode.kind === 256 /* JsxExpression */ || ts.isStatement(scopeNode); } /// TODO filter meaning based on the current context @@ -70498,12 +73348,12 @@ var ts; if (contextToken.kind === 10 /* JsxText */) { return true; } - if (contextToken.kind === 28 /* GreaterThanToken */ && contextToken.parent) { - if (contextToken.parent.kind === 250 /* JsxOpeningElement */) { + if (contextToken.kind === 29 /* GreaterThanToken */ && contextToken.parent) { + if (contextToken.parent.kind === 251 /* JsxOpeningElement */) { return true; } - if (contextToken.parent.kind === 251 /* JsxClosingElement */ || contextToken.parent.kind === 249 /* JsxSelfClosingElement */) { - return contextToken.parent.parent && contextToken.parent.parent.kind === 248 /* JsxElement */; + if (contextToken.parent.kind === 252 /* JsxClosingElement */ || contextToken.parent.kind === 250 /* JsxSelfClosingElement */) { + return contextToken.parent.parent && contextToken.parent.parent.kind === 249 /* JsxElement */; } } return false; @@ -70512,41 +73362,41 @@ var ts; if (previousToken) { var containingNodeKind = previousToken.parent.kind; switch (previousToken.kind) { - case 25 /* CommaToken */: - return containingNodeKind === 180 /* CallExpression */ // func( a, | - || containingNodeKind === 151 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ - || containingNodeKind === 181 /* NewExpression */ // new C(a, | - || containingNodeKind === 176 /* ArrayLiteralExpression */ // [a, | - || containingNodeKind === 193 /* BinaryExpression */ // const x = (a, | - || containingNodeKind === 159 /* FunctionType */; // var x: (s: string, list| - case 18 /* OpenParenToken */: - return containingNodeKind === 180 /* CallExpression */ // func( | - || containingNodeKind === 151 /* Constructor */ // constructor( | - || containingNodeKind === 181 /* NewExpression */ // new C(a| - || containingNodeKind === 184 /* ParenthesizedExpression */ // const x = (a| - || containingNodeKind === 167 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ - case 20 /* OpenBracketToken */: - return containingNodeKind === 176 /* ArrayLiteralExpression */ // [ | - || containingNodeKind === 156 /* IndexSignature */ // [ | : string ] - || containingNodeKind === 143 /* ComputedPropertyName */; // [ | /* this can become an index signature */ - case 127 /* ModuleKeyword */: // module | - case 128 /* NamespaceKeyword */: + case 26 /* CommaToken */: + return containingNodeKind === 181 /* CallExpression */ // func( a, | + || containingNodeKind === 152 /* Constructor */ // constructor( a, | /* public, protected, private keywords are allowed here, so show completion */ + || containingNodeKind === 182 /* NewExpression */ // new C(a, | + || containingNodeKind === 177 /* ArrayLiteralExpression */ // [a, | + || containingNodeKind === 194 /* BinaryExpression */ // const x = (a, | + || containingNodeKind === 160 /* FunctionType */; // var x: (s: string, list| + case 19 /* OpenParenToken */: + return containingNodeKind === 181 /* CallExpression */ // func( | + || containingNodeKind === 152 /* Constructor */ // constructor( | + || containingNodeKind === 182 /* NewExpression */ // new C(a| + || containingNodeKind === 185 /* ParenthesizedExpression */ // const x = (a| + || containingNodeKind === 168 /* ParenthesizedType */; // function F(pred: (a| /* this can become an arrow function, where 'a' is the argument */ + case 21 /* OpenBracketToken */: + return containingNodeKind === 177 /* ArrayLiteralExpression */ // [ | + || containingNodeKind === 157 /* IndexSignature */ // [ | : string ] + || containingNodeKind === 144 /* ComputedPropertyName */; // [ | /* this can become an index signature */ + case 128 /* ModuleKeyword */: // module | + case 129 /* NamespaceKeyword */: return true; - case 22 /* DotToken */: - return containingNodeKind === 232 /* ModuleDeclaration */; // module A.| - case 16 /* OpenBraceToken */: - return containingNodeKind === 228 /* ClassDeclaration */; // class A{ | - case 57 /* EqualsToken */: - return containingNodeKind === 225 /* VariableDeclaration */ // const x = a| - || containingNodeKind === 193 /* BinaryExpression */; // x = a| - case 13 /* TemplateHead */: - return containingNodeKind === 195 /* TemplateExpression */; // `aa ${| - case 14 /* TemplateMiddle */: - return containingNodeKind === 204 /* TemplateSpan */; // `aa ${10} dd ${| - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - return containingNodeKind === 148 /* PropertyDeclaration */; // class A{ public | + case 23 /* DotToken */: + return containingNodeKind === 233 /* ModuleDeclaration */; // module A.| + case 17 /* OpenBraceToken */: + return containingNodeKind === 229 /* ClassDeclaration */; // class A{ | + case 58 /* EqualsToken */: + return containingNodeKind === 226 /* VariableDeclaration */ // const x = a| + || containingNodeKind === 194 /* BinaryExpression */; // x = a| + case 14 /* TemplateHead */: + return containingNodeKind === 196 /* TemplateExpression */; // `aa ${| + case 15 /* TemplateMiddle */: + return containingNodeKind === 205 /* TemplateSpan */; // `aa ${10} dd ${| + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + return containingNodeKind === 149 /* PropertyDeclaration */; // class A{ public | } // Previous token may have been a keyword that was converted to an identifier. switch (previousToken.getText()) { @@ -70560,7 +73410,7 @@ var ts; } function isInStringOrRegularExpressionOrTemplateLiteral(contextToken) { if (contextToken.kind === 9 /* StringLiteral */ - || contextToken.kind === 11 /* RegularExpressionLiteral */ + || contextToken.kind === 12 /* RegularExpressionLiteral */ || ts.isTemplateLiteralKind(contextToken.kind)) { var start_3 = contextToken.getStart(); var end = contextToken.getEnd(); @@ -70573,7 +73423,7 @@ var ts; } if (position === end) { return !!contextToken.isUnterminated - || contextToken.kind === 11 /* RegularExpressionLiteral */; + || contextToken.kind === 12 /* RegularExpressionLiteral */; } } return false; @@ -70589,7 +73439,7 @@ var ts; isMemberCompletion = true; var typeForObject; var existingMembers; - if (objectLikeContainer.kind === 177 /* ObjectLiteralExpression */) { + if (objectLikeContainer.kind === 178 /* ObjectLiteralExpression */) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; @@ -70599,7 +73449,7 @@ var ts; typeForObject = typeForObject && typeForObject.getNonNullableType(); existingMembers = objectLikeContainer.properties; } - else if (objectLikeContainer.kind === 173 /* ObjectBindingPattern */) { + else if (objectLikeContainer.kind === 174 /* ObjectBindingPattern */) { // We are *only* completing on properties from the type being destructured. isNewIdentifierLocation = false; var rootDeclaration = ts.getRootDeclaration(objectLikeContainer.parent); @@ -70610,11 +73460,11 @@ var ts; // Also proceed if rootDeclaration is a parameter and if its containing function expression/arrow function is contextually typed - // type of parameter will flow in from the contextual type of the function var canGetType = !!(rootDeclaration.initializer || rootDeclaration.type); - if (!canGetType && rootDeclaration.kind === 145 /* Parameter */) { + if (!canGetType && rootDeclaration.kind === 146 /* Parameter */) { if (ts.isExpression(rootDeclaration.parent)) { canGetType = !!typeChecker.getContextualType(rootDeclaration.parent); } - else if (rootDeclaration.parent.kind === 150 /* MethodDeclaration */ || rootDeclaration.parent.kind === 153 /* SetAccessor */) { + else if (rootDeclaration.parent.kind === 151 /* MethodDeclaration */ || rootDeclaration.parent.kind === 154 /* SetAccessor */) { canGetType = ts.isExpression(rootDeclaration.parent.parent) && !!typeChecker.getContextualType(rootDeclaration.parent.parent); } } @@ -70656,9 +73506,9 @@ var ts; * @returns true if 'symbols' was successfully populated; false otherwise. */ function tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports) { - var declarationKind = namedImportsOrExports.kind === 240 /* NamedImports */ ? - 237 /* ImportDeclaration */ : - 243 /* ExportDeclaration */; + var declarationKind = namedImportsOrExports.kind === 241 /* NamedImports */ ? + 238 /* ImportDeclaration */ : + 244 /* ExportDeclaration */; var importOrExportDeclaration = ts.getAncestor(namedImportsOrExports, declarationKind); var moduleSpecifier = importOrExportDeclaration.moduleSpecifier; if (!moduleSpecifier) { @@ -70682,10 +73532,10 @@ var ts; function tryGetObjectLikeCompletionContainer(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16 /* OpenBraceToken */: // const x = { | - case 25 /* CommaToken */: + case 17 /* OpenBraceToken */: // const x = { | + case 26 /* CommaToken */: var parent = contextToken.parent; - if (parent && (parent.kind === 177 /* ObjectLiteralExpression */ || parent.kind === 173 /* ObjectBindingPattern */)) { + if (parent && (parent.kind === 178 /* ObjectLiteralExpression */ || parent.kind === 174 /* ObjectBindingPattern */)) { return parent; } break; @@ -70700,11 +73550,11 @@ var ts; function tryGetNamedImportsOrExportsForCompletion(contextToken) { if (contextToken) { switch (contextToken.kind) { - case 16 /* OpenBraceToken */: // import { | - case 25 /* CommaToken */: + case 17 /* OpenBraceToken */: // import { | + case 26 /* CommaToken */: switch (contextToken.parent.kind) { - case 240 /* NamedImports */: - case 244 /* NamedExports */: + case 241 /* NamedImports */: + case 245 /* NamedExports */: return contextToken.parent; } } @@ -70715,16 +73565,17 @@ var ts; if (contextToken) { var parent = contextToken.parent; switch (contextToken.kind) { - case 27 /* LessThanSlashToken */: - case 40 /* SlashToken */: - case 70 /* Identifier */: - case 253 /* JsxAttributes */: - case 252 /* JsxAttribute */: - case 254 /* JsxSpreadAttribute */: - if (parent && (parent.kind === 249 /* JsxSelfClosingElement */ || parent.kind === 250 /* JsxOpeningElement */)) { + case 28 /* LessThanSlashToken */: + case 41 /* SlashToken */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: + case 254 /* JsxAttributes */: + case 253 /* JsxAttribute */: + case 255 /* JsxSpreadAttribute */: + if (parent && (parent.kind === 250 /* JsxSelfClosingElement */ || parent.kind === 251 /* JsxOpeningElement */)) { return parent; } - else if (parent.kind === 252 /* JsxAttribute */) { + else if (parent.kind === 253 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70736,7 +73587,7 @@ var ts; // its parent is a JsxExpression, whose parent is a JsxAttribute, // whose parent is a JsxOpeningLikeElement case 9 /* StringLiteral */: - if (parent && ((parent.kind === 252 /* JsxAttribute */) || (parent.kind === 254 /* JsxSpreadAttribute */))) { + if (parent && ((parent.kind === 253 /* JsxAttribute */) || (parent.kind === 255 /* JsxSpreadAttribute */))) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70744,10 +73595,10 @@ var ts; return parent.parent.parent; } break; - case 17 /* CloseBraceToken */: + case 18 /* CloseBraceToken */: if (parent && - parent.kind === 255 /* JsxExpression */ && - parent.parent && parent.parent.kind === 252 /* JsxAttribute */) { + parent.kind === 256 /* JsxExpression */ && + parent.parent && parent.parent.kind === 253 /* JsxAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70755,7 +73606,7 @@ var ts; // each JsxAttribute can have initializer as JsxExpression return parent.parent.parent.parent; } - if (parent && parent.kind === 254 /* JsxSpreadAttribute */) { + if (parent && parent.kind === 255 /* JsxSpreadAttribute */) { // Currently we parse JsxOpeningLikeElement as: // JsxOpeningLikeElement // attributes: JsxAttributes @@ -70768,20 +73619,17 @@ var ts; return undefined; } function isFunction(kind) { + if (!ts.isFunctionLikeKind(kind)) { + return false; + } switch (kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 156 /* IndexSignature */: + case 152 /* Constructor */: + case 161 /* ConstructorType */: + case 160 /* FunctionType */: + return false; + default: return true; } - return false; } /** * @returns true if we are certain that the currently edited location must define a new location; false otherwise. @@ -70789,67 +73637,67 @@ var ts; function isSolelyIdentifierDefinitionLocation(contextToken) { var containingNodeKind = contextToken.parent.kind; switch (contextToken.kind) { - case 25 /* CommaToken */: - return containingNodeKind === 225 /* VariableDeclaration */ || - containingNodeKind === 226 /* VariableDeclarationList */ || - containingNodeKind === 207 /* VariableStatement */ || - containingNodeKind === 231 /* EnumDeclaration */ || + case 26 /* CommaToken */: + return containingNodeKind === 226 /* VariableDeclaration */ || + containingNodeKind === 227 /* VariableDeclarationList */ || + containingNodeKind === 208 /* VariableStatement */ || + containingNodeKind === 232 /* EnumDeclaration */ || isFunction(containingNodeKind) || - containingNodeKind === 228 /* ClassDeclaration */ || - containingNodeKind === 198 /* ClassExpression */ || - containingNodeKind === 229 /* InterfaceDeclaration */ || - containingNodeKind === 174 /* ArrayBindingPattern */ || - containingNodeKind === 230 /* TypeAliasDeclaration */; // type Map, K, | - case 22 /* DotToken */: - return containingNodeKind === 174 /* ArrayBindingPattern */; // var [.| - case 55 /* ColonToken */: - return containingNodeKind === 175 /* BindingElement */; // var {x :html| - case 20 /* OpenBracketToken */: - return containingNodeKind === 174 /* ArrayBindingPattern */; // var [x| - case 18 /* OpenParenToken */: - return containingNodeKind === 259 /* CatchClause */ || + containingNodeKind === 229 /* ClassDeclaration */ || + containingNodeKind === 199 /* ClassExpression */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || + containingNodeKind === 175 /* ArrayBindingPattern */ || + containingNodeKind === 231 /* TypeAliasDeclaration */; // type Map, K, | + case 23 /* DotToken */: + return containingNodeKind === 175 /* ArrayBindingPattern */; // var [.| + case 56 /* ColonToken */: + return containingNodeKind === 176 /* BindingElement */; // var {x :html| + case 21 /* OpenBracketToken */: + return containingNodeKind === 175 /* ArrayBindingPattern */; // var [x| + case 19 /* OpenParenToken */: + return containingNodeKind === 260 /* CatchClause */ || isFunction(containingNodeKind); - case 16 /* OpenBraceToken */: - return containingNodeKind === 231 /* EnumDeclaration */ || - containingNodeKind === 229 /* InterfaceDeclaration */ || - containingNodeKind === 162 /* TypeLiteral */; // const x : { | - case 24 /* SemicolonToken */: - return containingNodeKind === 147 /* PropertySignature */ && + case 17 /* OpenBraceToken */: + return containingNodeKind === 232 /* EnumDeclaration */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || + containingNodeKind === 163 /* TypeLiteral */; // const x : { | + case 25 /* SemicolonToken */: + return containingNodeKind === 148 /* PropertySignature */ && contextToken.parent && contextToken.parent.parent && - (contextToken.parent.parent.kind === 229 /* InterfaceDeclaration */ || - contextToken.parent.parent.kind === 162 /* TypeLiteral */); // const x : { a; | - case 26 /* LessThanToken */: - return containingNodeKind === 228 /* ClassDeclaration */ || - containingNodeKind === 198 /* ClassExpression */ || - containingNodeKind === 229 /* InterfaceDeclaration */ || - containingNodeKind === 230 /* TypeAliasDeclaration */ || + (contextToken.parent.parent.kind === 230 /* InterfaceDeclaration */ || + contextToken.parent.parent.kind === 163 /* TypeLiteral */); // const x : { a; | + case 27 /* LessThanToken */: + return containingNodeKind === 229 /* ClassDeclaration */ || + containingNodeKind === 199 /* ClassExpression */ || + containingNodeKind === 230 /* InterfaceDeclaration */ || + containingNodeKind === 231 /* TypeAliasDeclaration */ || isFunction(containingNodeKind); - case 114 /* StaticKeyword */: - return containingNodeKind === 148 /* PropertyDeclaration */; - case 23 /* DotDotDotToken */: - return containingNodeKind === 145 /* Parameter */ || + case 115 /* StaticKeyword */: + return containingNodeKind === 149 /* PropertyDeclaration */; + case 24 /* DotDotDotToken */: + return containingNodeKind === 146 /* Parameter */ || (contextToken.parent && contextToken.parent.parent && - contextToken.parent.parent.kind === 174 /* ArrayBindingPattern */); // var [...z| - case 113 /* PublicKeyword */: - case 111 /* PrivateKeyword */: - case 112 /* ProtectedKeyword */: - return containingNodeKind === 145 /* Parameter */; - case 117 /* AsKeyword */: - return containingNodeKind === 241 /* ImportSpecifier */ || - containingNodeKind === 245 /* ExportSpecifier */ || - containingNodeKind === 239 /* NamespaceImport */; - case 74 /* ClassKeyword */: - case 82 /* EnumKeyword */: - case 108 /* InterfaceKeyword */: - case 88 /* FunctionKeyword */: - case 103 /* VarKeyword */: - case 124 /* GetKeyword */: - case 134 /* SetKeyword */: - case 90 /* ImportKeyword */: - case 109 /* LetKeyword */: - case 75 /* ConstKeyword */: - case 115 /* YieldKeyword */: - case 137 /* TypeKeyword */: + contextToken.parent.parent.kind === 175 /* ArrayBindingPattern */); // var [...z| + case 114 /* PublicKeyword */: + case 112 /* PrivateKeyword */: + case 113 /* ProtectedKeyword */: + return containingNodeKind === 146 /* Parameter */; + case 118 /* AsKeyword */: + return containingNodeKind === 242 /* ImportSpecifier */ || + containingNodeKind === 246 /* ExportSpecifier */ || + containingNodeKind === 240 /* NamespaceImport */; + case 75 /* ClassKeyword */: + case 83 /* EnumKeyword */: + case 109 /* InterfaceKeyword */: + case 89 /* FunctionKeyword */: + case 104 /* VarKeyword */: + case 125 /* GetKeyword */: + case 135 /* SetKeyword */: + case 91 /* ImportKeyword */: + case 110 /* LetKeyword */: + case 76 /* ConstKeyword */: + case 116 /* YieldKeyword */: + case 138 /* TypeKeyword */: return true; } // Previous token may have been a keyword that was converted to an identifier. @@ -70919,12 +73767,12 @@ 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 !== 260 /* PropertyAssignment */ && - m.kind !== 261 /* ShorthandPropertyAssignment */ && - m.kind !== 175 /* BindingElement */ && - m.kind !== 150 /* MethodDeclaration */ && - m.kind !== 152 /* GetAccessor */ && - m.kind !== 153 /* SetAccessor */) { + if (m.kind !== 261 /* PropertyAssignment */ && + m.kind !== 262 /* ShorthandPropertyAssignment */ && + m.kind !== 176 /* BindingElement */ && + m.kind !== 151 /* MethodDeclaration */ && + m.kind !== 153 /* GetAccessor */ && + m.kind !== 154 /* SetAccessor */) { continue; } // If this is the current item we are editing right now, do not filter it out @@ -70932,9 +73780,9 @@ var ts; continue; } var existingName = void 0; - if (m.kind === 175 /* BindingElement */ && m.propertyName) { + if (m.kind === 176 /* BindingElement */ && m.propertyName) { // include only identifiers in completion list - if (m.propertyName.kind === 70 /* Identifier */) { + if (m.propertyName.kind === 71 /* Identifier */) { existingName = m.propertyName.text; } } @@ -70962,7 +73810,7 @@ var ts; if (attr.getStart() <= position && position <= attr.getEnd()) { continue; } - if (attr.kind === 252 /* JsxAttribute */) { + if (attr.kind === 253 /* JsxAttribute */) { seenNames.set(attr.name.text, true); } } @@ -71012,7 +73860,7 @@ var ts; } // A cache of completion entries for keywords, these do not change between sessions var keywordCompletions = []; - for (var i = 71 /* FirstKeyword */; i <= 141 /* LastKeyword */; i++) { + for (var i = 72 /* FirstKeyword */; i <= 142 /* LastKeyword */; i++) { keywordCompletions.push({ name: ts.tokenToString(i), kind: ts.ScriptElementKind.keyword, @@ -71020,58 +73868,14 @@ var ts; sortText: "0" }); } - /** - * Matches a triple slash reference directive with an incomplete string literal for its path. Used - * to determine if the caret is currently within the string literal and capture the literal fragment - * for completions. - * For example, this matches - * - * /// = 0; i--) { - if (pushKeywordIf(keywords, loopTokens[i], 105 /* WhileKeyword */)) { + if (pushKeywordIf(keywords, loopTokens[i], 106 /* WhileKeyword */)) { break; } } @@ -71456,7 +74254,7 @@ var ts; var breaksAndContinues = aggregateAllBreakAndContinueStatements(loopNode.statement); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(loopNode, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */, 76 /* ContinueKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */, 77 /* ContinueKeyword */); } }); return keywords; @@ -71465,13 +74263,13 @@ var ts; var owner = getBreakOrContinueOwner(breakOrContinueStatement); if (owner) { switch (owner.kind) { - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 211 /* DoStatement */: - case 212 /* WhileStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 212 /* DoStatement */: + case 213 /* WhileStatement */: return getLoopBreakContinueOccurrences(owner); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: return getSwitchCaseDefaultOccurrences(owner); } } @@ -71479,14 +74277,14 @@ var ts; } function getSwitchCaseDefaultOccurrences(switchStatement) { var keywords = []; - pushKeywordIf(keywords, switchStatement.getFirstToken(), 97 /* SwitchKeyword */); + pushKeywordIf(keywords, switchStatement.getFirstToken(), 98 /* SwitchKeyword */); // Go through each clause in the switch statement, collecting the 'case'/'default' keywords. ts.forEach(switchStatement.caseBlock.clauses, function (clause) { - pushKeywordIf(keywords, clause.getFirstToken(), 72 /* CaseKeyword */, 78 /* DefaultKeyword */); + pushKeywordIf(keywords, clause.getFirstToken(), 73 /* CaseKeyword */, 79 /* DefaultKeyword */); var breaksAndContinues = aggregateAllBreakAndContinueStatements(clause); ts.forEach(breaksAndContinues, function (statement) { if (ownsBreakOrContinueStatement(switchStatement, statement)) { - pushKeywordIf(keywords, statement.getFirstToken(), 71 /* BreakKeyword */); + pushKeywordIf(keywords, statement.getFirstToken(), 72 /* BreakKeyword */); } }); }); @@ -71494,13 +74292,13 @@ var ts; } function getTryCatchFinallyOccurrences(tryStatement, sourceFile) { var keywords = []; - pushKeywordIf(keywords, tryStatement.getFirstToken(), 101 /* TryKeyword */); + pushKeywordIf(keywords, tryStatement.getFirstToken(), 102 /* TryKeyword */); if (tryStatement.catchClause) { - pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 73 /* CatchKeyword */); + pushKeywordIf(keywords, tryStatement.catchClause.getFirstToken(), 74 /* CatchKeyword */); } if (tryStatement.finallyBlock) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); - pushKeywordIf(keywords, finallyKeyword, 86 /* FinallyKeyword */); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); + pushKeywordIf(keywords, finallyKeyword, 87 /* FinallyKeyword */); } return keywords; } @@ -71511,13 +74309,13 @@ var ts; } var keywords = []; ts.forEach(aggregateOwnedThrowStatements(owner), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100 /* ThrowKeyword */); }); // If the "owner" is a function, then we equate 'return' and 'throw' statements in their // ability to "jump out" of the function, and include occurrences for both. if (ts.isFunctionBlock(owner)) { ts.forEachReturnStatement(owner, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96 /* ReturnKeyword */); }); } return keywords; @@ -71525,36 +74323,36 @@ var ts; function getReturnOccurrences(returnStatement) { var func = ts.getContainingFunction(returnStatement); // If we didn't find a containing function with a block body, bail out. - if (!(func && hasKind(func.body, 206 /* Block */))) { + if (!(func && hasKind(func.body, 207 /* Block */))) { return undefined; } var keywords = []; ts.forEachReturnStatement(func.body, function (returnStatement) { - pushKeywordIf(keywords, returnStatement.getFirstToken(), 95 /* ReturnKeyword */); + pushKeywordIf(keywords, returnStatement.getFirstToken(), 96 /* ReturnKeyword */); }); // Include 'throw' statements that do not occur within a try block. ts.forEach(aggregateOwnedThrowStatements(func.body), function (throwStatement) { - pushKeywordIf(keywords, throwStatement.getFirstToken(), 99 /* ThrowKeyword */); + pushKeywordIf(keywords, throwStatement.getFirstToken(), 100 /* ThrowKeyword */); }); return keywords; } function getIfElseOccurrences(ifStatement, sourceFile) { var keywords = []; // Traverse upwards through all parent if-statements linked by their else-branches. - while (hasKind(ifStatement.parent, 210 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { + while (hasKind(ifStatement.parent, 211 /* IfStatement */) && ifStatement.parent.elseStatement === ifStatement) { ifStatement = ifStatement.parent; } // Now traverse back down through the else branches, aggregating if/else keywords of if-statements. while (ifStatement) { var children = ifStatement.getChildren(); - pushKeywordIf(keywords, children[0], 89 /* IfKeyword */); + pushKeywordIf(keywords, children[0], 90 /* IfKeyword */); // Generally the 'else' keyword is second-to-last, so we traverse backwards. for (var i = children.length - 1; i >= 0; i--) { - if (pushKeywordIf(keywords, children[i], 81 /* ElseKeyword */)) { + if (pushKeywordIf(keywords, children[i], 82 /* ElseKeyword */)) { break; } } - if (!hasKind(ifStatement.elseStatement, 210 /* IfStatement */)) { + if (!hasKind(ifStatement.elseStatement, 211 /* IfStatement */)) { break; } ifStatement = ifStatement.elseStatement; @@ -71563,7 +74361,7 @@ var ts; // We'd like to highlight else/ifs together if they are only separated by whitespace // (i.e. the keywords are separated by no comments, no newlines). for (var i = 0; i < keywords.length; i++) { - if (keywords[i].kind === 81 /* ElseKeyword */ && i < keywords.length - 1) { + if (keywords[i].kind === 82 /* ElseKeyword */ && i < keywords.length - 1) { var elseKeyword = keywords[i]; var ifKeyword = keywords[i + 1]; // this *should* always be an 'if' keyword. var shouldCombindElseAndIf = true; @@ -71594,7 +74392,7 @@ var ts; * Note: 'node' cannot be a SourceFile. */ function isLabeledBy(node, labelName) { - for (var owner = node.parent; owner.kind === 221 /* LabeledStatement */; owner = owner.parent) { + for (var owner = node.parent; owner.kind === 222 /* LabeledStatement */; owner = owner.parent) { if (owner.label.text === labelName) { return true; } @@ -71716,271 +74514,988 @@ var ts; } ts.createDocumentRegistry = createDocumentRegistry; })(ts || (ts = {})); +/* Code for finding imports of an exported symbol. Used only by FindAllReferences. */ /* @internal */ var ts; (function (ts) { var FindAllReferences; (function (FindAllReferences) { - function findReferencedSymbols(typeChecker, cancellationToken, sourceFiles, sourceFile, position, findInStrings, findInComments, isForRename) { - var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); - return getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename); + /** Creates the imports map and returns an ImportTracker that uses it. Call this lazily to avoid calling `getDirectImportsMap` unnecessarily. */ + function createImportTracker(sourceFiles, checker, cancellationToken) { + var allDirectImports = getDirectImportsMap(sourceFiles, checker, cancellationToken); + return function (exportSymbol, exportInfo, isForRename) { + var _a = getImportersForExport(sourceFiles, allDirectImports, exportInfo, checker, cancellationToken), directImports = _a.directImports, indirectUsers = _a.indirectUsers; + return __assign({ indirectUsers: indirectUsers }, getSearchesFromDirectImports(directImports, exportSymbol, exportInfo.exportKind, checker, isForRename)); + }; } - FindAllReferences.findReferencedSymbols = findReferencedSymbols; - function convertReferences(referenceSymbols) { - return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); - } - FindAllReferences.convertReferences = convertReferences; - function getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, findInStrings, findInComments, isForRename, implementations) { - if (!implementations) { - var special = getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken); - if (special) { - return special; + FindAllReferences.createImportTracker = createImportTracker; + var ExportKind; + (function (ExportKind) { + ExportKind[ExportKind["Named"] = 0] = "Named"; + ExportKind[ExportKind["Default"] = 1] = "Default"; + ExportKind[ExportKind["ExportEquals"] = 2] = "ExportEquals"; + })(ExportKind = FindAllReferences.ExportKind || (FindAllReferences.ExportKind = {})); + var ImportExport; + (function (ImportExport) { + ImportExport[ImportExport["Import"] = 0] = "Import"; + ImportExport[ImportExport["Export"] = 1] = "Export"; + })(ImportExport = FindAllReferences.ImportExport || (FindAllReferences.ImportExport = {})); + /** Returns import statements that directly reference the exporting module, and a list of files that may access the module through a namespace. */ + function getImportersForExport(sourceFiles, allDirectImports, _a, checker, cancellationToken) { + var exportingModuleSymbol = _a.exportingModuleSymbol, exportKind = _a.exportKind; + var markSeenDirectImport = ts.nodeSeenTracker(); + var markSeenIndirectUser = ts.nodeSeenTracker(); + var directImports = []; + var isAvailableThroughGlobal = !!exportingModuleSymbol.globalExports; + var indirectUserDeclarations = isAvailableThroughGlobal ? undefined : []; + handleDirectImports(exportingModuleSymbol); + return { directImports: directImports, indirectUsers: getIndirectUsers() }; + function getIndirectUsers() { + if (isAvailableThroughGlobal) { + // It has `export as namespace`, so anything could potentially use it. + return sourceFiles; } - } - // `getSymbolAtLocation` normally returns the symbol of the class when given the constructor keyword, - // so we have to specify that we want the constructor symbol. - var symbol = typeChecker.getSymbolAtLocation(node); - // Could not find a symbol e.g. unknown identifier - if (!symbol) { - if (!implementations && node.kind === 9 /* StringLiteral */) { - return getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken); + // Module augmentations may use this module's exports without importing it. + for (var _i = 0, _a = exportingModuleSymbol.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + if (ts.isExternalModuleAugmentation(decl)) { + addIndirectUser(decl); + } } - // Can't have references to something that we have no symbol for. - return undefined; + // This may return duplicates (if there are multiple module declarations in a single source file, all importing the same thing as a namespace), but `State.markSearchedSymbol` will handle that. + return indirectUserDeclarations.map(ts.getSourceFileOfNode); } - var declarations = symbol.declarations; - // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!declarations || !declarations.length) { - return undefined; + function handleDirectImports(exportingModuleSymbol) { + var theseDirectImports = getDirectImports(exportingModuleSymbol); + if (theseDirectImports) + for (var _i = 0, theseDirectImports_1 = theseDirectImports; _i < theseDirectImports_1.length; _i++) { + var direct = theseDirectImports_1[_i]; + if (!markSeenDirectImport(direct)) { + continue; + } + cancellationToken.throwIfCancellationRequested(); + switch (direct.kind) { + case 181 /* CallExpression */: + if (!isAvailableThroughGlobal) { + var parent = direct.parent; + if (exportKind === 2 /* ExportEquals */ && parent.kind === 226 /* VariableDeclaration */) { + var name = parent.name; + if (name.kind === 71 /* Identifier */) { + directImports.push(name); + break; + } + } + // Don't support re-exporting 'require()' calls, so just add a single indirect user. + addIndirectUser(direct.getSourceFile()); + } + break; + case 237 /* ImportEqualsDeclaration */: + handleNamespaceImport(direct, direct.name, ts.hasModifier(direct, 1 /* Export */)); + break; + case 238 /* ImportDeclaration */: + var namedBindings = direct.importClause && direct.importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { + handleNamespaceImport(direct, namedBindings.name); + } + else { + directImports.push(direct); + } + break; + case 244 /* ExportDeclaration */: + if (!direct.exportClause) { + // This is `export * from "foo"`, so imports of this module may import the export too. + handleDirectImports(getContainingModuleSymbol(direct, checker)); + } + else { + // This is `export { foo } from "foo"` and creates an alias symbol, so recursive search will get handle re-exports. + directImports.push(direct); + } + break; + } + } } - var _a = followAliases(symbol, node, typeChecker, isForRename), aliasedSymbol = _a.symbol, shorthandModuleSymbol = _a.shorthandModuleSymbol; - symbol = aliasedSymbol; - // Build the set of symbols to search for, initially it has only the current symbol - var searchSymbols = populateSearchSymbolSet(symbol, node, typeChecker, implementations); - if (shorthandModuleSymbol) { - searchSymbols.push(shorthandModuleSymbol); - } - // Compute the meaning from the location and the symbol it references - var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), declarations); - var result = []; - // Maps from a symbol ID to the ReferencedSymbol entry in 'result'. - var symbolToIndex = []; - var inheritsFromCache = ts.createMap(); - // Get the text to search for. - // Note: if this is an external module symbol, the name doesn't include quotes. - var declaredName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); - // Try to get the smallest valid scope that we can limit our search to; - // otherwise we'll need to search globally (i.e. include each file). - var scope = getSymbolScope(symbol); - if (scope) { - getRefs(scope, declaredName); - } - else { - var isDefault = ts.isExportDefaultSymbol(symbol); - var internedName = isDefault ? symbol.valueDeclaration.localSymbol.name : getInternedName(symbol, node); - for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { - var sourceFile = sourceFiles_5[_i]; - cancellationToken.throwIfCancellationRequested(); - var searchName = (isDefault ? getDefaultImportName(symbol, sourceFile, typeChecker) : undefined) || - (sourceFileHasName(sourceFile, internedName) ? declaredName : undefined); - if (searchName !== undefined) { - getRefs(sourceFile, searchName); + function handleNamespaceImport(importDeclaration, name, isReExport) { + if (exportKind === 2 /* ExportEquals */) { + // This is a direct import, not import-as-namespace. + directImports.push(importDeclaration); + } + else if (!isAvailableThroughGlobal) { + var sourceFileLike = getSourceFileLikeForImportDeclaration(importDeclaration); + ts.Debug.assert(sourceFileLike.kind === 265 /* SourceFile */ || sourceFileLike.kind === 233 /* ModuleDeclaration */); + if (isReExport || findNamespaceReExports(sourceFileLike, name, checker)) { + addIndirectUsers(sourceFileLike); + } + else { + addIndirectUser(sourceFileLike); } } } - return result; - function getRefs(scope, searchName) { - getReferencesInNode(scope, symbol, searchName, node, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache); + function addIndirectUser(sourceFileLike) { + ts.Debug.assert(!isAvailableThroughGlobal); + var isNew = markSeenIndirectUser(sourceFileLike); + if (isNew) { + indirectUserDeclarations.push(sourceFileLike); + } + return isNew; + } + /** Adds a module and all of its transitive dependencies as possible indirect users. */ + function addIndirectUsers(sourceFileLike) { + if (!addIndirectUser(sourceFileLike)) { + return; + } + var moduleSymbol = checker.getMergedSymbol(sourceFileLike.symbol); + ts.Debug.assert(!!(moduleSymbol.flags & 1536 /* Module */)); + var directImports = getDirectImports(moduleSymbol); + if (directImports) + for (var _i = 0, directImports_1 = directImports; _i < directImports_1.length; _i++) { + var directImport = directImports_1[_i]; + addIndirectUsers(getSourceFileLikeForImportDeclaration(directImport)); + } + } + function getDirectImports(moduleSymbol) { + return allDirectImports.get(ts.getSymbolId(moduleSymbol).toString()); } } - FindAllReferences.getReferencedSymbolsForNode = getReferencedSymbolsForNode; - /** getReferencedSymbols for special node kinds. */ - function getReferencedSymbolsSpecial(node, sourceFiles, typeChecker, cancellationToken) { - if (ts.isTypeKeyword(node.kind)) { - return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + /** + * Given the set of direct imports of a module, we need to find which ones import the particular exported symbol. + * The returned `importSearches` will result in the entire source file being searched. + * But re-exports will be placed in 'singleReferences' since they cannot be locally referenced. + */ + function getSearchesFromDirectImports(directImports, exportSymbol, exportKind, checker, isForRename) { + var exportName = exportSymbol.name; + var importSearches = []; + var singleReferences = []; + function addSearch(location, symbol) { + importSearches.push([location, symbol]); } - // Labels - if (ts.isLabelName(node)) { - if (ts.isJumpStatementTarget(node)) { - var labelDefinition = ts.getTargetLabel(node.parent, node.text); - // if we have a label definition, look within its statement for references, if not, then - // the label is undefined and we have no results.. - return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition, cancellationToken); + if (directImports) + for (var _i = 0, directImports_2 = directImports; _i < directImports_2.length; _i++) { + var decl = directImports_2[_i]; + handleImport(decl); + } + return { importSearches: importSearches, singleReferences: singleReferences }; + function handleImport(decl) { + if (decl.kind === 237 /* ImportEqualsDeclaration */) { + if (isExternalModuleImportEquals(decl)) { + handleNamespaceImportLike(decl.name); + } + return; + } + if (decl.kind === 71 /* Identifier */) { + handleNamespaceImportLike(decl); + return; + } + // Ignore if there's a grammar error + if (decl.moduleSpecifier.kind !== 9 /* StringLiteral */) { + return; + } + if (decl.kind === 244 /* ExportDeclaration */) { + searchForNamedImport(decl.exportClause); + return; + } + var importClause = decl.importClause; + var namedBindings = importClause.namedBindings; + if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { + handleNamespaceImportLike(namedBindings.name); + return; + } + if (exportKind === 0 /* Named */) { + searchForNamedImport(namedBindings); } else { - // it is a label definition and not a target, search within the parent labeledStatement - return getLabelReferencesInNode(node.parent, node, cancellationToken); + // `export =` might be imported by a default import if `--allowSyntheticDefaultImports` is on, so this handles both ExportKind.Default and ExportKind.ExportEquals + var name = importClause.name; + // If a default import has the same name as the default export, allow to rename it. + // Given `import f` and `export default function f`, we will rename both, but for `import g` we will rename just that. + if (name && (!isForRename || name.text === symbolName(exportSymbol))) { + var defaultImportAlias = checker.getSymbolAtLocation(name); + addSearch(name, defaultImportAlias); + } + // 'default' might be accessed as a named import `{ default as foo }`. + if (!isForRename && exportKind === 1 /* Default */) { + ts.Debug.assert(exportName === "default"); + searchForNamedImport(namedBindings); + } } } - if (ts.isThis(node)) { - return getReferencesForThisKeyword(node, sourceFiles, typeChecker, cancellationToken); + /** + * `import x = require("./x") or `import * as x from "./x"`. + * An `export =` may be imported by this syntax, so it may be a direct import. + * If it's not a direct import, it will be in `indirectUsers`, so we don't have to do anything here. + */ + function handleNamespaceImportLike(importName) { + // Don't rename an import that already has a different name than the export. + if (exportKind === 2 /* ExportEquals */ && (!isForRename || importName.text === exportName)) { + addSearch(importName, checker.getSymbolAtLocation(importName)); + } } - if (node.kind === 96 /* SuperKeyword */) { - return getReferencesForSuperKeyword(node, typeChecker, cancellationToken); + function searchForNamedImport(namedBindings) { + if (namedBindings) + for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) { + var element = _a[_i]; + var name = element.name, propertyName = element.propertyName; + if ((propertyName || name).text !== exportName) { + continue; + } + if (propertyName) { + // This is `import { foo as bar } from "./a"` or `export { foo as bar } from "./a"`. `foo` isn't a local in the file, so just add it as a single reference. + singleReferences.push(propertyName); + if (!isForRename) { + // Search locally for `bar`. + addSearch(name, checker.getSymbolAtLocation(name)); + } + } + else { + var localSymbol = element.kind === 246 /* ExportSpecifier */ && element.propertyName + ? checker.getExportSpecifierLocalTargetSymbol(element) // For re-exporting under a different name, we want to get the re-exported symbol. + : checker.getSymbolAtLocation(name); + addSearch(name, localSymbol); + } + } } - return undefined; + } + /** Returns 'true' is the namespace 'name' is re-exported from this module, and 'false' if it is only used locally. */ + function findNamespaceReExports(sourceFileLike, name, checker) { + var namespaceImportSymbol = checker.getSymbolAtLocation(name); + return forEachPossibleImportOrExportStatement(sourceFileLike, function (statement) { + if (statement.kind !== 244 /* ExportDeclaration */) + return; + var _a = statement, exportClause = _a.exportClause, moduleSpecifier = _a.moduleSpecifier; + if (moduleSpecifier || !exportClause) + return; + for (var _i = 0, _b = exportClause.elements; _i < _b.length; _i++) { + var element = _b[_i]; + if (checker.getExportSpecifierLocalTargetSymbol(element) === namespaceImportSymbol) { + return true; + } + } + }); + } + /** Returns a map from a module symbol Id to all import statements that directly reference the module. */ + function getDirectImportsMap(sourceFiles, checker, cancellationToken) { + var map = ts.createMap(); + for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) { + var sourceFile = sourceFiles_4[_i]; + cancellationToken.throwIfCancellationRequested(); + forEachImport(sourceFile, function (importDecl, moduleSpecifier) { + var moduleSymbol = checker.getSymbolAtLocation(moduleSpecifier); + if (moduleSymbol) { + var id = ts.getSymbolId(moduleSymbol).toString(); + var imports = map.get(id); + if (!imports) { + map.set(id, imports = []); + } + imports.push(importDecl); + } + }); + } + return map; + } + /** Iterates over all statements at the top level or in module declarations. Returns the first truthy result. */ + function forEachPossibleImportOrExportStatement(sourceFileLike, action) { + return ts.forEach(sourceFileLike.kind === 265 /* SourceFile */ ? sourceFileLike.statements : sourceFileLike.body.statements, function (statement) { + return action(statement) || (isAmbientModuleDeclaration(statement) && ts.forEach(statement.body && statement.body.statements, action)); + }); + } + /** Calls `action` for each import, re-export, or require() in a file. */ + function forEachImport(sourceFile, action) { + if (sourceFile.externalModuleIndicator) { + for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { + var moduleSpecifier = _a[_i]; + action(importerFromModuleSpecifier(moduleSpecifier), moduleSpecifier); + } + } + else { + forEachPossibleImportOrExportStatement(sourceFile, function (statement) { + switch (statement.kind) { + case 244 /* ExportDeclaration */: + case 238 /* ImportDeclaration */: { + var decl = statement; + if (decl.moduleSpecifier && decl.moduleSpecifier.kind === 9 /* StringLiteral */) { + action(decl, decl.moduleSpecifier); + } + break; + } + case 237 /* ImportEqualsDeclaration */: { + var decl = statement; + var moduleReference = decl.moduleReference; + if (moduleReference.kind === 248 /* ExternalModuleReference */ && + moduleReference.expression.kind === 9 /* StringLiteral */) { + action(decl, moduleReference.expression); + } + break; + } + } + }); + if (sourceFile.flags & 65536 /* JavaScriptFile */) { + // Find all 'require()' calls. + sourceFile.forEachChild(function recur(node) { + if (ts.isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { + action(node, node.arguments[0]); + } + else { + node.forEachChild(recur); + } + }); + } + } + } + function importerFromModuleSpecifier(moduleSpecifier) { + var decl = moduleSpecifier.parent; + if (decl.kind === 238 /* ImportDeclaration */ || decl.kind === 244 /* ExportDeclaration */) { + return decl; + } + ts.Debug.assert(decl.kind === 248 /* ExternalModuleReference */); + return decl.parent; } /** - * Follows aliases to get to the original declaration of a symbol. - * For a shorthand ambient module, we don't follow the alias to it, but we will need to add it to the set of search symbols. + * Given a local reference, we might notice that it's an import/export and recursively search for references of that. + * If at an import, look locally for the symbol it imports. + * If an an export, look for all imports of it. + * This doesn't handle export specifiers; that is done in `getReferencesAtExportSpecifier`. + * @param comingFromExport If we are doing a search for all exports, don't bother looking backwards for the imported symbol, since that's the reason we're here. */ - function followAliases(symbol, node, typeChecker, isForRename) { - while (true) { - // When renaming a default import, only rename in the current file - if (isForRename && isImportDefaultSymbol(symbol)) { - return { symbol: symbol }; + function getImportOrExportSymbol(node, symbol, checker, comingFromExport) { + return comingFromExport ? getExport() : getExport() || getImport(); + function getExport() { + var parent = node.parent; + if (symbol.flags & 7340032 /* Export */) { + if (parent.kind === 179 /* PropertyAccessExpression */) { + // When accessing an export of a JS module, there's no alias. The symbol will still be flagged as an export even though we're at the use. + // So check that we are at the declaration. + return symbol.declarations.some(function (d) { return d === parent; }) && parent.parent.kind === 194 /* BinaryExpression */ + ? getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ false) + : undefined; + } + else { + var exportSymbol = symbol.exportSymbol; + ts.Debug.assert(!!exportSymbol); + return exportInfo(exportSymbol, getExportKindForDeclaration(parent)); + } } - var aliasedSymbol = getAliasSymbolForPropertyNameSymbol(symbol, node, typeChecker); - // Don't follow alias if it goes to unknown symbol. This can happen if it points to an untyped module. - if (!aliasedSymbol || !aliasedSymbol.declarations) { - return { symbol: symbol }; + else { + var exportNode = getExportNode(parent); + if (exportNode && ts.hasModifier(exportNode, 1 /* Export */)) { + if (exportNode.kind === 237 /* ImportEqualsDeclaration */ && exportNode.moduleReference === node) { + // We're at `Y` in `export import X = Y`. This is not the exported symbol, the left-hand-side is. So treat this as an import statement. + if (comingFromExport) { + return undefined; + } + var lhsSymbol = checker.getSymbolAtLocation(exportNode.name); + return { kind: 0 /* Import */, symbol: lhsSymbol, isNamedImport: false }; + } + else { + return exportInfo(symbol, getExportKindForDeclaration(exportNode)); + } + } + else if (parent.kind === 243 /* ExportAssignment */) { + // Get the symbol for the `export =` node; its parent is the module it's the export of. + var exportingModuleSymbol = parent.symbol.parent; + ts.Debug.assert(!!exportingModuleSymbol); + return { kind: 1 /* Export */, symbol: symbol, exportInfo: { exportingModuleSymbol: exportingModuleSymbol, exportKind: 2 /* ExportEquals */ } }; + } + else if (parent.kind === 194 /* BinaryExpression */) { + return getSpecialPropertyExport(parent, /*useLhsSymbol*/ true); + } + else if (parent.parent.kind === 194 /* BinaryExpression */) { + return getSpecialPropertyExport(parent.parent, /*useLhsSymbol*/ true); + } } - if (ts.isShorthandAmbientModuleSymbol(aliasedSymbol)) { - return { symbol: symbol, shorthandModuleSymbol: aliasedSymbol }; - } - symbol = aliasedSymbol; - } - } - function sourceFileHasName(sourceFile, name) { - return ts.getNameTable(sourceFile).get(name) !== undefined; - } - /** - * Given a symbol, see if any of the imports in a source file reference it. - * Only call this if `symbol` is a default export. - */ - function getDefaultImportName(symbol, sourceFile, checker) { - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var importSpecifier = _a[_i]; - var importDecl = importSpecifier.parent; - ts.Debug.assert(importDecl.moduleSpecifier === importSpecifier); - var defaultName = importDecl.importClause.name; - var defaultReferencedSymbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(defaultName)); - if (symbol === defaultReferencedSymbol) { - return defaultName.text; + function getSpecialPropertyExport(node, useLhsSymbol) { + var kind; + switch (ts.getSpecialPropertyAssignmentKind(node)) { + case 1 /* ExportsProperty */: + kind = 0 /* Named */; + break; + case 2 /* ModuleExports */: + kind = 2 /* ExportEquals */; + break; + default: + return undefined; + } + var sym = useLhsSymbol ? checker.getSymbolAtLocation(node.left.name) : symbol; + return sym && exportInfo(sym, kind); } } - return undefined; + function getImport() { + var isImport = isNodeImport(node); + if (!isImport) + return; + // A symbol being imported is always an alias. So get what that aliases to find the local symbol. + var importedSymbol = checker.getImmediateAliasedSymbol(symbol); + if (importedSymbol) { + // Search on the local symbol in the exporting module, not the exported symbol. + importedSymbol = skipExportSpecifierSymbol(importedSymbol, checker); + // Similarly, skip past the symbol for 'export =' + if (importedSymbol.name === "export=") { + importedSymbol = checker.getImmediateAliasedSymbol(importedSymbol); + } + if (symbolName(importedSymbol) === symbol.name) { + return __assign({ kind: 0 /* Import */, symbol: importedSymbol }, isImport); + } + } + } + function exportInfo(symbol, kind) { + var exportInfo = getExportInfo(symbol, kind, checker); + return exportInfo && { kind: 1 /* Export */, symbol: symbol, exportInfo: exportInfo }; + } + // Not meant for use with export specifiers or export assignment. + function getExportKindForDeclaration(node) { + return ts.hasModifier(node, 512 /* Default */) ? 1 /* Default */ : 0 /* Named */; + } } - function getDefinition(symbol, node, typeChecker) { - var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; - var name = displayParts.map(function (p) { return p.text; }).join(""); - var declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { + FindAllReferences.getImportOrExportSymbol = getImportOrExportSymbol; + // If a reference is a variable declaration, the exported node would be the variable statement. + function getExportNode(parent) { + if (parent.kind === 226 /* VariableDeclaration */) { + var p = parent; + return p.parent.kind === 260 /* CatchClause */ ? undefined : p.parent.parent.kind === 208 /* VariableStatement */ ? p.parent.parent : undefined; + } + else { + return parent; + } + } + function isNodeImport(node) { + var parent = node.parent; + switch (parent.kind) { + case 237 /* ImportEqualsDeclaration */: + return parent.name === node && isExternalModuleImportEquals(parent) + ? { isNamedImport: false } + : undefined; + case 242 /* ImportSpecifier */: + // For a rename import `{ foo as bar }`, don't search for the imported symbol. Just find local uses of `bar`. + return parent.propertyName ? undefined : { isNamedImport: true }; + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + ts.Debug.assert(parent.name === node); + return { isNamedImport: false }; + default: + return undefined; + } + } + function getExportInfo(exportSymbol, exportKind, checker) { + var exportingModuleSymbol = checker.getMergedSymbol(exportSymbol.parent); // Need to get merged symbol in case there's an augmentation. + // `export` may appear in a namespace. In that case, just rely on global search. + return ts.isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol: exportingModuleSymbol, exportKind: exportKind } : undefined; + } + FindAllReferences.getExportInfo = getExportInfo; + function symbolName(symbol) { + if (symbol.name !== "default") { + return symbol.name; + } + var name = ts.forEach(symbol.declarations, function (_a) { + var name = _a.name; + return name && name.kind === 71 /* Identifier */ && name.text; + }); + ts.Debug.assert(!!name); + return name; + } + /** If at an export specifier, go to the symbol it refers to. */ + function skipExportSpecifierSymbol(symbol, checker) { + // For `export { foo } from './bar", there's nothing to skip, because it does not create a new alias. But `export { foo } does. + if (symbol.declarations) + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.isExportSpecifier(declaration) && !declaration.propertyName && !declaration.parent.parent.moduleSpecifier) { + return checker.getExportSpecifierLocalTargetSymbol(declaration); + } + } + return symbol; + } + function getContainingModuleSymbol(importer, checker) { + return checker.getMergedSymbol(getSourceFileLikeForImportDeclaration(importer).symbol); + } + function getSourceFileLikeForImportDeclaration(node) { + if (node.kind === 181 /* CallExpression */) { + return node.getSourceFile(); + } + var parent = node.parent; + if (parent.kind === 265 /* SourceFile */) { + return parent; + } + ts.Debug.assert(parent.kind === 234 /* ModuleBlock */ && isAmbientModuleDeclaration(parent.parent)); + return parent.parent; + } + function isAmbientModuleDeclaration(node) { + return node.kind === 233 /* ModuleDeclaration */ && node.name.kind === 9 /* StringLiteral */; + } + function isExternalModuleImportEquals(_a) { + var moduleReference = _a.moduleReference; + return moduleReference.kind === 248 /* ExternalModuleReference */ && moduleReference.expression.kind === 9 /* StringLiteral */; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +/// +/* @internal */ +var ts; +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + function nodeEntry(node, isInString) { + return { type: "node", node: node, isInString: isInString }; + } + FindAllReferences.nodeEntry = nodeEntry; + function findReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position) { + var referencedSymbols = findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position); + if (!referencedSymbols || !referencedSymbols.length) { return undefined; } + var out = []; + for (var _i = 0, referencedSymbols_1 = referencedSymbols; _i < referencedSymbols_1.length; _i++) { + var _a = referencedSymbols_1[_i], definition = _a.definition, references = _a.references; + // Only include referenced symbols that have a valid definition. + if (definition) { + out.push({ definition: definitionToReferencedSymbolDefinitionInfo(definition, checker), references: references.map(toReferenceEntry) }); + } + } + return out; + } + FindAllReferences.findReferencedSymbols = findReferencedSymbols; + function getImplementationsAtPosition(checker, cancellationToken, sourceFiles, sourceFile, position) { + var node = ts.getTouchingPropertyName(sourceFile, position); + var referenceEntries = getImplementationReferenceEntries(checker, cancellationToken, sourceFiles, node); + return ts.map(referenceEntries, function (entry) { return toImplementationLocation(entry, checker); }); + } + FindAllReferences.getImplementationsAtPosition = getImplementationsAtPosition; + function getImplementationReferenceEntries(typeChecker, cancellationToken, sourceFiles, node) { + // If invoked directly on a shorthand property assignment, then return + // the declaration of the symbol being assigned (not the symbol being assigned to). + if (node.parent.kind === 262 /* ShorthandPropertyAssignment */) { + var result_4 = []; + FindAllReferences.Core.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, function (node) { return result_4.push(nodeEntry(node)); }); + return result_4; + } + else if (node.kind === 97 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { + // References to and accesses on the super keyword only have one possible implementation, so no + // need to "Find all References" + var symbol = typeChecker.getSymbolAtLocation(node); + return symbol.valueDeclaration && [nodeEntry(symbol.valueDeclaration)]; + } + else { + // Perform "Find all References" and retrieve only those that are implementations + return getReferenceEntriesForNode(node, sourceFiles, typeChecker, cancellationToken, { implementations: true }); + } + } + function findReferencedEntries(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var x = flattenEntries(findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options)); + return ts.map(x, toReferenceEntry); + } + FindAllReferences.findReferencedEntries = findReferencedEntries; + function getReferenceEntriesForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + return flattenEntries(FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options)); + } + FindAllReferences.getReferenceEntriesForNode = getReferenceEntriesForNode; + function findAllReferencedSymbols(checker, cancellationToken, sourceFiles, sourceFile, position, options) { + var node = ts.getTouchingPropertyName(sourceFile, position, /*includeJsDocComment*/ true); + return FindAllReferences.Core.getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options); + } + function flattenEntries(referenceSymbols) { + return referenceSymbols && ts.flatMap(referenceSymbols, function (r) { return r.references; }); + } + function definitionToReferencedSymbolDefinitionInfo(def, checker) { + var info = (function () { + switch (def.type) { + case "symbol": { + var symbol = def.symbol, node_2 = def.node; + var declarations = symbol.declarations; + if (!declarations || declarations.length === 0) { + return undefined; + } + var _a = getDefinitionKindAndDisplayParts(symbol, node_2, checker), displayParts_1 = _a.displayParts, kind_1 = _a.kind; + var name_3 = displayParts_1.map(function (p) { return p.text; }).join(""); + return { node: node_2, name: name_3, kind: kind_1, displayParts: displayParts_1 }; + } + case "label": { + var node_3 = def.node; + return { node: node_3, name: node_3.text, kind: ts.ScriptElementKind.label, displayParts: [ts.displayPart(node_3.text, ts.SymbolDisplayPartKind.text)] }; + } + case "keyword": { + var node_4 = def.node; + var name_4 = ts.tokenToString(node_4.kind); + return { node: node_4, name: name_4, kind: ts.ScriptElementKind.keyword, displayParts: [{ text: name_4, kind: ts.ScriptElementKind.keyword }] }; + } + case "this": { + var node_5 = def.node; + var symbol = checker.getSymbolAtLocation(node_5); + var displayParts_2 = symbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node_5.getSourceFile(), ts.getContainerNode(node_5), node_5).displayParts; + return { node: node_5, name: "this", kind: ts.ScriptElementKind.variableElement, displayParts: displayParts_2 }; + } + case "string": { + var node_6 = def.node; + return { node: node_6, name: node_6.text, kind: ts.ScriptElementKind.variableElement, displayParts: [ts.displayPart(ts.getTextOfNode(node_6), ts.SymbolDisplayPartKind.stringLiteral)] }; + } + } + })(); + if (!info) { + return undefined; + } + var node = info.node, name = info.name, kind = info.kind, displayParts = info.displayParts; + var sourceFile = node.getSourceFile(); return { containerKind: "", containerName: "", + fileName: sourceFile.fileName, + kind: kind, name: name, - kind: symbolKind, - fileName: declarations[0].getSourceFile().fileName, - textSpan: ts.createTextSpan(declarations[0].getStart(), 0), + textSpan: ts.createTextSpanFromNode(node, sourceFile), displayParts: displayParts }; } - function getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) { - if (!(symbol.flags & 8388608 /* Alias */)) { - return undefined; + function getDefinitionKindAndDisplayParts(symbol, node, checker) { + var _a = ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(checker, symbol, node.getSourceFile(), ts.getContainerNode(node), node), displayParts = _a.displayParts, symbolKind = _a.symbolKind; + return { displayParts: displayParts, kind: symbolKind }; + } + function toReferenceEntry(entry) { + if (entry.type === "span") { + return { textSpan: entry.textSpan, fileName: entry.fileName, isWriteAccess: false, isDefinition: false }; } - // Default import get alias - var defaultImport = ts.getDeclarationOfKind(symbol, 238 /* ImportClause */); - if (defaultImport) { - return typeChecker.getAliasedSymbol(symbol); + var node = entry.node, isInString = entry.isInString; + return { + fileName: node.getSourceFile().fileName, + textSpan: getTextSpan(node), + isWriteAccess: isWriteAccess(node), + isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node), + isInString: isInString + }; + } + function toImplementationLocation(entry, checker) { + if (entry.type === "node") { + var node = entry.node; + return __assign({ textSpan: getTextSpan(node), fileName: node.getSourceFile().fileName }, implementationKindDisplayParts(node, checker)); } - var importOrExportSpecifier = ts.forEach(symbol.declarations, function (declaration) { return (declaration.kind === 241 /* ImportSpecifier */ || - declaration.kind === 245 /* ExportSpecifier */) ? declaration : undefined; }); - if (importOrExportSpecifier && - // export { a } - (!importOrExportSpecifier.propertyName || - // export {a as class } where a is location - importOrExportSpecifier.propertyName === location)) { - // If Import specifier -> get alias - // else Export specifier -> get local target - return importOrExportSpecifier.kind === 241 /* ImportSpecifier */ ? - typeChecker.getAliasedSymbol(symbol) : - typeChecker.getExportSpecifierLocalTargetSymbol(importOrExportSpecifier); + else { + var textSpan = entry.textSpan, fileName = entry.fileName; + return { textSpan: textSpan, fileName: fileName, kind: ts.ScriptElementKind.unknown, displayParts: [] }; } } - function followAliasIfNecessary(symbol, location, typeChecker) { - return getAliasSymbolForPropertyNameSymbol(symbol, location, typeChecker) || symbol; - } - function getPropertySymbolOfDestructuringAssignment(location, typeChecker) { - return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && - typeChecker.getPropertySymbolOfDestructuringAssignment(location); - } - function isObjectBindingPatternElementWithoutPropertyName(symbol) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); - return bindingElement && - bindingElement.parent.kind === 173 /* ObjectBindingPattern */ && - !bindingElement.propertyName; - } - function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker) { - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - var bindingElement = ts.getDeclarationOfKind(symbol, 175 /* BindingElement */); - var typeOfPattern = typeChecker.getTypeAtLocation(bindingElement.parent); - return typeOfPattern && typeChecker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + function implementationKindDisplayParts(node, checker) { + var symbol = checker.getSymbolAtLocation(ts.isDeclaration(node) && node.name ? node.name : node); + if (symbol) { + return getDefinitionKindAndDisplayParts(symbol, node, checker); } - return undefined; - } - function getInternedName(symbol, location) { - // If this is an export or import specifier it could have been renamed using the 'as' syntax. - // If so we want to search for whatever under the cursor. - if (ts.isImportOrExportSpecifierName(location)) { - return location.text; + else if (node.kind === 178 /* ObjectLiteralExpression */) { + return { + kind: ts.ScriptElementKind.interfaceElement, + displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("object literal"), ts.punctuationPart(20 /* CloseParenToken */)] + }; } - return ts.stripQuotes(symbol.name); - } - /** - * Determines the smallest scope in which a symbol may have named references. - * Note that not every construct has been accounted for. This function can - * probably be improved. - * - * @returns undefined if the scope cannot be determined, implying that - * a reference to a symbol can occur anywhere. - */ - function getSymbolScope(symbol) { - // 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 === 185 /* FunctionExpression */ || valueDeclaration.kind === 198 /* ClassExpression */)) { - return valueDeclaration; + else if (node.kind === 199 /* ClassExpression */) { + return { + kind: ts.ScriptElementKind.localClassElement, + displayParts: [ts.punctuationPart(19 /* OpenParenToken */), ts.textPart("anonymous local class"), ts.punctuationPart(20 /* CloseParenToken */)] + }; } - // 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 (ts.getModifierFlags(d) & 8 /* Private */) ? d : undefined; }); - if (privateDeclaration) { - return ts.getAncestor(privateDeclaration, 228 /* ClassDeclaration */); + else { + return { kind: ts.getNodeKind(node), displayParts: [] }; + } + } + function toHighlightSpan(entry) { + if (entry.type === "span") { + var fileName_1 = entry.fileName, textSpan = entry.textSpan; + return { fileName: fileName_1, span: { textSpan: textSpan, kind: ts.HighlightSpanKind.reference } }; + } + var node = entry.node, isInString = entry.isInString; + var fileName = entry.node.getSourceFile().fileName; + var writeAccess = isWriteAccess(node); + var span = { + textSpan: getTextSpan(node), + kind: writeAccess ? ts.HighlightSpanKind.writtenReference : ts.HighlightSpanKind.reference, + isInString: isInString + }; + return { fileName: fileName, span: span }; + } + FindAllReferences.toHighlightSpan = toHighlightSpan; + function getTextSpan(node) { + var start = node.getStart(); + var end = node.getEnd(); + if (node.kind === 9 /* StringLiteral */) { + start += 1; + end -= 1; + } + return ts.createTextSpanFromBounds(start, end); + } + /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ + function isWriteAccess(node) { + if (node.kind === 71 /* Identifier */ && ts.isDeclarationName(node)) { + return true; + } + var parent = node.parent; + if (parent) { + if (parent.kind === 193 /* PostfixUnaryExpression */ || parent.kind === 192 /* PrefixUnaryExpression */) { + return true; + } + else if (parent.kind === 194 /* BinaryExpression */ && parent.left === node) { + var operator = parent.operatorToken.kind; + return 58 /* FirstAssignment */ <= operator && operator <= 70 /* LastAssignment */; } } - // If the symbol is an import we would like to find it if we are looking for what it imports. - // So consider it visible outside its declaration scope. - if (symbol.flags & 8388608 /* Alias */) { + return false; + } + })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); +})(ts || (ts = {})); +/** Encapsulates the core find-all-references algorithm. */ +/* @internal */ +(function (ts) { + var FindAllReferences; + (function (FindAllReferences) { + var Core; + (function (Core) { + /** Core find-all-references algorithm. Handles special cases before delegating to `getReferencedSymbolsForSymbol`. */ + function getReferencedSymbolsForNode(node, sourceFiles, checker, cancellationToken, options) { + if (options === void 0) { options = {}; } + if (node.kind === 265 /* SourceFile */) { + return undefined; + } + if (!options.implementations) { + var special = getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken); + if (special) { + return special; + } + } + var symbol = checker.getSymbolAtLocation(node); + // Could not find a symbol e.g. unknown identifier + if (!symbol) { + // String literal might be a property (and thus have a symbol), so do this here rather than in getReferencedSymbolsSpecial. + if (!options.implementations && node.kind === 9 /* StringLiteral */) { + return getReferencesForStringLiteral(node, sourceFiles, cancellationToken); + } + // Can't have references to something that we have no symbol for. + return undefined; + } + // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol + if (!symbol.declarations || !symbol.declarations.length) { + return undefined; + } + return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options); + } + Core.getReferencedSymbolsForNode = getReferencedSymbolsForNode; + /** getReferencedSymbols for special node kinds. */ + function getReferencedSymbolsSpecial(node, sourceFiles, cancellationToken) { + if (ts.isTypeKeyword(node.kind)) { + return getAllReferencesForKeyword(sourceFiles, node.kind, cancellationToken); + } + // Labels + if (ts.isLabelName(node)) { + if (ts.isJumpStatementTarget(node)) { + var labelDefinition = ts.getTargetLabel(node.parent, node.text); + // if we have a label definition, look within its statement for references, if not, then + // the label is undefined and we have no results.. + return labelDefinition && getLabelReferencesInNode(labelDefinition.parent, labelDefinition); + } + else { + // it is a label definition and not a target, search within the parent labeledStatement + return getLabelReferencesInNode(node.parent, node); + } + } + if (ts.isThis(node)) { + return getReferencesForThisKeyword(node, sourceFiles, cancellationToken); + } + if (node.kind === 97 /* SuperKeyword */) { + return getReferencesForSuperKeyword(node); + } return undefined; } - // If symbol is of object binding pattern element without property name we would want to - // look for property too and that could be anywhere - if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + /** Core find-all-references algorithm for a normal symbol. */ + function getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options) { + symbol = skipPastExportOrImportSpecifier(symbol, node, checker); + // Compute the meaning from the location and the symbol it references + var searchMeaning = getIntersectingMeaningFromDeclarations(ts.getMeaningFromLocation(node), symbol.declarations); + var result = []; + var state = createState(sourceFiles, node, checker, cancellationToken, searchMeaning, options, result); + var search = state.createSearch(node, symbol, /*comingFrom*/ undefined, { allSearchSymbols: populateSearchSymbolSet(symbol, node, checker, options.implementations) }); + // Try to get the smallest valid scope that we can limit our search to; + // otherwise we'll need to search globally (i.e. include each file). + var scope = getSymbolScope(symbol); + if (scope) { + getReferencesInContainer(scope, scope.getSourceFile(), search, state); + } + else { + // Global search + for (var _i = 0, _a = state.sourceFiles; _i < _a.length; _i++) { + var sourceFile = _a[_i]; + state.cancellationToken.throwIfCancellationRequested(); + searchForName(sourceFile, search, state); + } + } + return result; + } + /** Handle a few special cases relating to export/import specifiers. */ + function skipPastExportOrImportSpecifier(symbol, node, checker) { + var parent = node.parent; + if (ts.isExportSpecifier(parent)) { + return getLocalSymbolForExportSpecifier(node, symbol, parent, checker); + } + if (ts.isImportSpecifier(parent) && parent.propertyName === node) { + // We're at `foo` in `import { foo as bar }`. Probably intended to find all refs on the original, not just on the import. + return checker.getImmediateAliasedSymbol(symbol); + } + return symbol; + } + function createState(sourceFiles, originalLocation, checker, cancellationToken, searchMeaning, options, result) { + var symbolIdToReferences = []; + var inheritsFromCache = ts.createMap(); + // Source file ID → symbol ID → Whether the symbol has been searched for in the source file. + var sourceFileToSeenSymbols = []; + var isForConstructor = originalLocation.kind === 123 /* ConstructorKeyword */; + var importTracker; + return __assign({}, options, { sourceFiles: sourceFiles, isForConstructor: isForConstructor, checker: checker, cancellationToken: cancellationToken, searchMeaning: searchMeaning, inheritsFromCache: inheritsFromCache, getImportSearches: getImportSearches, createSearch: createSearch, referenceAdder: referenceAdder, addStringOrCommentReference: addStringOrCommentReference, + markSearchedSymbol: markSearchedSymbol, markSeenContainingTypeReference: ts.nodeSeenTracker(), markSeenReExportRHS: ts.nodeSeenTracker() }); + function getImportSearches(exportSymbol, exportInfo) { + if (!importTracker) + importTracker = FindAllReferences.createImportTracker(sourceFiles, checker, cancellationToken); + return importTracker(exportSymbol, exportInfo, options.isForRename); + } + function createSearch(location, symbol, comingFrom, searchOptions) { + if (searchOptions === void 0) { searchOptions = {}; } + // Note: if this is an external module symbol, the name doesn't include quotes. + var _a = searchOptions.text, text = _a === void 0 ? ts.stripQuotes(ts.getDeclaredName(checker, symbol, location)) : _a, _b = searchOptions.allSearchSymbols, allSearchSymbols = _b === void 0 ? undefined : _b; + var escapedText = ts.escapeIdentifier(text); + var parents = options.implementations && getParentSymbolsOfPropertyAccess(location, symbol, checker); + return { location: location, symbol: symbol, comingFrom: comingFrom, text: text, escapedText: escapedText, parents: parents, includes: includes }; + function includes(referenceSymbol) { + return allSearchSymbols ? ts.contains(allSearchSymbols, referenceSymbol) : referenceSymbol === symbol; + } + } + function referenceAdder(referenceSymbol, searchLocation) { + var symbolId = ts.getSymbolId(referenceSymbol); + var references = symbolIdToReferences[symbolId]; + if (!references) { + references = symbolIdToReferences[symbolId] = []; + result.push({ definition: { type: "symbol", symbol: referenceSymbol, node: searchLocation }, references: references }); + } + return function (node) { return references.push(FindAllReferences.nodeEntry(node)); }; + } + function addStringOrCommentReference(fileName, textSpan) { + result.push({ + definition: undefined, + references: [{ type: "span", fileName: fileName, textSpan: textSpan }] + }); + } + function markSearchedSymbol(sourceFile, symbol) { + var sourceId = ts.getNodeId(sourceFile); + var symbolId = ts.getSymbolId(symbol); + var seenSymbols = sourceFileToSeenSymbols[sourceId] || (sourceFileToSeenSymbols[sourceId] = []); + return !seenSymbols[symbolId] && (seenSymbols[symbolId] = true); + } + } + /** Search for all imports of a given exported symbol using `State.getImportSearches`. */ + function searchForImportsOfExport(exportLocation, exportSymbol, exportInfo, state) { + var _a = state.getImportSearches(exportSymbol, exportInfo), importSearches = _a.importSearches, singleReferences = _a.singleReferences, indirectUsers = _a.indirectUsers; + // For `import { foo as bar }` just add the reference to `foo`, and don't otherwise search in the file. + if (singleReferences.length) { + var addRef = state.referenceAdder(exportSymbol, exportLocation); + for (var _i = 0, singleReferences_1 = singleReferences; _i < singleReferences_1.length; _i++) { + var singleRef = singleReferences_1[_i]; + addRef(singleRef); + } + } + // For each import, find all references to that import in its source file. + for (var _b = 0, importSearches_1 = importSearches; _b < importSearches_1.length; _b++) { + var _c = importSearches_1[_b], importLocation = _c[0], importSymbol = _c[1]; + getReferencesInSourceFile(importLocation.getSourceFile(), state.createSearch(importLocation, importSymbol, 1 /* Export */), state); + } + if (indirectUsers.length) { + var indirectSearch = void 0; + switch (exportInfo.exportKind) { + case 0 /* Named */: + indirectSearch = state.createSearch(exportLocation, exportSymbol, 1 /* Export */); + break; + case 1 /* Default */: + // Search for a property access to '.default'. This can't be renamed. + indirectSearch = state.isForRename ? undefined : state.createSearch(exportLocation, exportSymbol, 1 /* Export */, { text: "default" }); + break; + case 2 /* ExportEquals */: + break; + } + if (indirectSearch) { + for (var _d = 0, indirectUsers_1 = indirectUsers; _d < indirectUsers_1.length; _d++) { + var indirectUser = indirectUsers_1[_d]; + searchForName(indirectUser, indirectSearch, state); + } + } + } + } + // Go to the symbol we imported from and find references for it. + function searchForImportedSymbol(symbol, state) { + for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { + var declaration = _a[_i]; + getReferencesInSourceFile(declaration.getSourceFile(), state.createSearch(declaration, symbol, 0 /* Import */), state); + } + } + /** Search for all occurences of an identifier in a source file (and filter out the ones that match). */ + function searchForName(sourceFile, search, state) { + if (ts.getNameTable(sourceFile).get(search.escapedText) !== undefined) { + getReferencesInSourceFile(sourceFile, search, state); + } + } + function getPropertySymbolOfDestructuringAssignment(location, checker) { + return ts.isArrayLiteralOrObjectLiteralDestructuringPattern(location.parent.parent) && + checker.getPropertySymbolOfDestructuringAssignment(location); + } + function isObjectBindingPatternElementWithoutPropertyName(symbol) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176 /* BindingElement */); + return bindingElement && + bindingElement.parent.kind === 174 /* ObjectBindingPattern */ && + !bindingElement.propertyName; + } + function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker) { + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + var bindingElement = ts.getDeclarationOfKind(symbol, 176 /* BindingElement */); + var typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); + return typeOfPattern && checker.getPropertyOfType(typeOfPattern, bindingElement.name.text); + } return undefined; } - // if this symbol is visible from its parent container, e.g. exported, then bail out - // if symbol correspond to the union property - bail out - if (symbol.parent || (symbol.flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */)) { - return undefined; - } - var scope; - var declarations = symbol.getDeclarations(); - if (declarations) { + /** + * Determines the smallest scope in which a symbol may have named references. + * Note that not every construct has been accounted for. This function can + * probably be improved. + * + * @returns undefined if the scope cannot be determined, implying that + * a reference to a symbol can occur anywhere. + */ + function getSymbolScope(symbol) { + // If this is the symbol of a named function expression or named class expression, + // then named references are limited to its own scope. + var declarations = symbol.declarations, flags = symbol.flags, parent = symbol.parent, valueDeclaration = symbol.valueDeclaration; + if (valueDeclaration && (valueDeclaration.kind === 186 /* FunctionExpression */ || valueDeclaration.kind === 199 /* ClassExpression */)) { + return valueDeclaration; + } + if (!declarations) { + return undefined; + } + // If this is private property or method, the scope is the containing class + if (flags & (4 /* Property */ | 8192 /* Method */)) { + var privateDeclaration = ts.find(declarations, function (d) { return !!(ts.getModifierFlags(d) & 8 /* Private */); }); + if (privateDeclaration) { + return ts.getAncestor(privateDeclaration, 229 /* ClassDeclaration */); + } + } + // If symbol is of object binding pattern element without property name we would want to + // look for property too and that could be anywhere + if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { + return undefined; + } + // If the symbol has a parent, it's globally visible. + // Unless that parent is an external module, then we should only search in the module (and recurse on the export later). + // But if the parent is a module that has `export as namespace`, then the symbol *is* globally visible. + if (parent && !((parent.flags & 1536 /* Module */) && ts.isExternalModuleSymbol(parent) && !parent.globalExports)) { + return undefined; + } + // If this is a synthetic property, it's a property and must be searched for globally. + if ((flags & 134217728 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */)) { + return undefined; + } + var scope; for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) { var declaration = declarations_10[_i]; var container = ts.getContainerNode(declaration); - if (!container) { - return undefined; - } if (scope && scope !== container) { // Different declarations have different containers, bail out return undefined; } - if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { + if (!container || container.kind === 265 /* SourceFile */ && !ts.isExternalOrCommonJsModule(container)) { // This is a global variable and not an external module, any declaration defined // within this scope is visible outside the file return undefined; @@ -71988,984 +75503,955 @@ var ts; // The search scope is the container node scope = container; } + // If symbol.parent, this means we are in an export of an external module. (Otherwise we would have returned `undefined` above.) + // For an export of a module, we may be in a declaration file, and it may be accessed elsewhere. E.g.: + // declare module "a" { export type T = number; } + // declare module "b" { import { T } from "a"; export const x: T; } + // So we must search the whole source file. (Because we will mark the source file as seen, we we won't return to it when searching for imports.) + return parent ? scope.getSourceFile() : scope; } - return scope; - } - function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end, cancellationToken) { - var positions = []; - /// TODO: Cache symbol existence for files to save text search - // Also, need to make this work for unicode escapes. - // Be resilient in the face of a symbol with no name or zero length name - if (!symbolName || !symbolName.length) { + function getPossibleSymbolReferencePositions(sourceFile, symbolName, start, end) { + var positions = []; + /// TODO: Cache symbol existence for files to save text search + // Also, need to make this work for unicode escapes. + // Be resilient in the face of a symbol with no name or zero length name + if (!symbolName || !symbolName.length) { + return positions; + } + var text = sourceFile.text; + var sourceLength = text.length; + var symbolNameLength = symbolName.length; + var position = text.indexOf(symbolName, start); + while (position >= 0) { + // If we are past the end, stop looking + if (position > end) + break; + // We found a match. Make sure it's not part of a larger word (i.e. the char + // before and after it have to be a non-identifier char). + var endPosition = position + symbolNameLength; + if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && + (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { + // Found a real match. Keep searching. + positions.push(position); + } + position = text.indexOf(symbolName, position + symbolNameLength + 1); + } return positions; } - var text = sourceFile.text; - var sourceLength = text.length; - var symbolNameLength = symbolName.length; - var position = text.indexOf(symbolName, start); - while (position >= 0) { - cancellationToken.throwIfCancellationRequested(); - // If we are past the end, stop looking - if (position > end) - break; - // We found a match. Make sure it's not part of a larger word (i.e. the char - // before and after it have to be a non-identifier char). - var endPosition = position + symbolNameLength; - if ((position === 0 || !ts.isIdentifierPart(text.charCodeAt(position - 1), 5 /* Latest */)) && - (endPosition === sourceLength || !ts.isIdentifierPart(text.charCodeAt(endPosition), 5 /* Latest */))) { - // Found a real match. Keep searching. - positions.push(position); + function getLabelReferencesInNode(container, targetLabel) { + var references = []; + var sourceFile = container.getSourceFile(); + var labelName = targetLabel.text; + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { + var position = possiblePositions_1[_i]; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.getWidth() !== labelName.length) { + continue; + } + // Only pick labels that are either the target label, or have a target that is the target label + if (node === targetLabel || + (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { + references.push(FindAllReferences.nodeEntry(node)); + } } - position = text.indexOf(symbolName, position + symbolNameLength + 1); + return [{ definition: { type: "label", node: targetLabel }, references: references }]; } - return positions; - } - function getLabelReferencesInNode(container, targetLabel, cancellationToken) { - var references = []; - var sourceFile = container.getSourceFile(); - var labelName = targetLabel.text; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd(), cancellationToken); - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { + function isValidReferencePosition(node, searchSymbolName) { + // Compare the length so we filter out strict superstrings of the symbol we are looking for + switch (node && node.kind) { + case 71 /* Identifier */: + return node.getWidth() === searchSymbolName.length; + case 9 /* StringLiteral */: + return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && + // For string literals we have two additional chars for the quotes + node.getWidth() === searchSymbolName.length + 2; + case 8 /* NumericLiteral */: + return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + default: + return false; + } + } + function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_5 = sourceFiles; _i < sourceFiles_5.length; _i++) { + var sourceFile = sourceFiles_5[_i]; + cancellationToken.throwIfCancellationRequested(); + addReferencesForKeywordInFile(sourceFile, keywordKind, ts.tokenToString(keywordKind), references); + } + return references.length ? [{ definition: { type: "keyword", node: references[0].node }, references: references }] : undefined; + } + function addReferencesForKeywordInFile(sourceFile, kind, searchText, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd()); + for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { + var position = possiblePositions_2[_i]; + var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); + if (referenceLocation.kind === kind) { + references.push(FindAllReferences.nodeEntry(referenceLocation)); + } + } + } + function getReferencesInSourceFile(sourceFile, search, state) { + state.cancellationToken.throwIfCancellationRequested(); + return getReferencesInContainer(sourceFile, sourceFile, search, state); + } + /** + * Search within node "container" for references for a search value, where the search value is defined as a + * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). + * searchLocation: a node where the search value + */ + function getReferencesInContainer(container, sourceFile, search, state) { + if (!state.markSearchedSymbol(sourceFile, search.symbol)) { return; } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (ts.isJumpStatementTarget(node) && ts.getTargetLabel(node, labelName) === targetLabel)) { - references.push(getReferenceEntryFromNode(node)); - } - }); - var definition = { - containerKind: "", - containerName: "", - fileName: targetLabel.getSourceFile().fileName, - kind: ts.ScriptElementKind.label, - name: labelName, - textSpan: ts.createTextSpanFromNode(targetLabel, sourceFile), - displayParts: [ts.displayPart(labelName, ts.SymbolDisplayPartKind.text)] - }; - return [{ definition: definition, references: references }]; - } - function isValidReferencePosition(node, searchSymbolName) { - // Compare the length so we filter out strict superstrings of the symbol we are looking for - switch (node && node.kind) { - case 70 /* Identifier */: - return node.getWidth() === searchSymbolName.length; - case 9 /* StringLiteral */: - return (ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && - // For string literals we have two additional chars for the quotes - node.getWidth() === searchSymbolName.length + 2; - case 8 /* NumericLiteral */: - return ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; - default: - return false; - } - } - function getAllReferencesForKeyword(sourceFiles, keywordKind, cancellationToken) { - var name = ts.tokenToString(keywordKind); - var references = []; - for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { - var sourceFile = sourceFiles_6[_i]; - cancellationToken.throwIfCancellationRequested(); - addReferencesForKeywordInFile(sourceFile, keywordKind, name, cancellationToken, references); - } - if (!references.length) - return undefined; - var definition = { - containerKind: "", - containerName: "", - fileName: references[0].fileName, - kind: ts.ScriptElementKind.keyword, - name: name, - textSpan: references[0].textSpan, - displayParts: [{ text: name, kind: ts.ScriptElementKind.keyword }] - }; - return [{ definition: definition, references: references }]; - } - function addReferencesForKeywordInFile(sourceFile, kind, searchText, cancellationToken, references) { - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_1 = possiblePositions; _i < possiblePositions_1.length; _i++) { - var position = possiblePositions_1[_i]; - cancellationToken.throwIfCancellationRequested(); - var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (referenceLocation.kind === kind) { - references.push({ - textSpan: ts.createTextSpanFromNode(referenceLocation), - fileName: sourceFile.fileName, - isWriteAccess: false, - isDefinition: false, - }); + var start = state.findInComments ? container.getFullStart() : container.getStart(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, search.text, start, container.getEnd()); + for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { + var position = possiblePositions_3[_i]; + getReferencesAtLocation(sourceFile, position, search, state); } } - } - /** Search within node "container" for references for a search value, where the search value is defined as a - * tuple of(searchSymbol, searchText, searchLocation, and searchMeaning). - * searchLocation: a node where the search value - */ - function getReferencesInNode(container, searchSymbol, searchText, searchLocation, searchMeaning, findInStrings, findInComments, result, symbolToIndex, implementations, typeChecker, cancellationToken, searchSymbols, inheritsFromCache) { - var sourceFile = container.getSourceFile(); - var start = findInComments ? container.getFullStart() : container.getStart(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, start, container.getEnd(), cancellationToken); - var parents = getParentSymbolsOfPropertyAccess(); - for (var _i = 0, possiblePositions_2 = possiblePositions; _i < possiblePositions_2.length; _i++) { - var position = possiblePositions_2[_i]; - cancellationToken.throwIfCancellationRequested(); + function getReferencesAtLocation(sourceFile, position, search, state) { var referenceLocation = ts.getTouchingPropertyName(sourceFile, position); - if (!isValidReferencePosition(referenceLocation, searchText)) { + if (!isValidReferencePosition(referenceLocation, search.text)) { // This wasn't the start of a token. Check to see if it might be a // match in a comment or string if that's what the caller is asking // for. - if (!implementations && ((findInStrings && ts.isInString(sourceFile, position)) || - (findInComments && ts.isInNonReferenceComment(sourceFile, position)))) { + if (!state.implementations && (state.findInStrings && ts.isInString(sourceFile, position) || state.findInComments && ts.isInNonReferenceComment(sourceFile, position))) { // In the case where we're looking inside comments/strings, we don't have // an actual definition. So just use 'undefined' here. Features like // 'Rename' won't care (as they ignore the definitions), and features like // 'FindReferences' will just filter out these results. - result.push({ - definition: undefined, - references: [{ - fileName: sourceFile.fileName, - textSpan: ts.createTextSpan(position, searchText.length), - isWriteAccess: false, - isDefinition: false - }] - }); + state.addStringOrCommentReference(sourceFile.fileName, ts.createTextSpan(position, search.text.length)); } - continue; + return; } - if (!(ts.getMeaningFromLocation(referenceLocation) & searchMeaning)) { - continue; + if (!(ts.getMeaningFromLocation(referenceLocation) & state.searchMeaning)) { + return; } - var referenceSymbol = typeChecker.getSymbolAtLocation(referenceLocation); - if (referenceSymbol) { - var referenceSymbolDeclaration = referenceSymbol.valueDeclaration; - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration); - var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, - /*searchLocationIsConstructor*/ searchLocation.kind === 122 /* ConstructorKeyword */, parents, inheritsFromCache, typeChecker); - if (relatedSymbol) { - addReferenceToRelatedSymbol(referenceLocation, relatedSymbol); + var referenceSymbol = state.checker.getSymbolAtLocation(referenceLocation); + if (!referenceSymbol) { + return; + } + var parent = referenceLocation.parent; + if (ts.isImportSpecifier(parent) && parent.propertyName === referenceLocation) { + // This is added through `singleReferences` in ImportsResult. If we happen to see it again, don't add it again. + return; + } + if (ts.isExportSpecifier(parent)) { + ts.Debug.assert(referenceLocation.kind === 71 /* Identifier */); + getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, parent, search, state); + return; + } + var relatedSymbol = getRelatedSymbol(search, referenceSymbol, referenceLocation, state); + if (!relatedSymbol) { + getReferenceForShorthandProperty(referenceSymbol, search, state); + return; + } + if (state.isForConstructor) { + findConstructorReferences(referenceLocation, sourceFile, search, state); + } + else { + addReference(referenceLocation, relatedSymbol, search.location, state); + } + getImportOrExportReferences(referenceLocation, referenceSymbol, search, state); + } + function getReferencesAtExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, search, state) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + var exportDeclaration = parent.parent; + var localSymbol = getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, state.checker); + if (!search.includes(localSymbol)) { + return; + } + if (!propertyName) { + addRef(); + } + else if (referenceLocation === propertyName) { + // For `export { foo as bar } from "baz"`, "`foo`" will be added from the singleReferences for import searches of the original export. + // For `export { foo as bar };`, where `foo` is a local, so add it now. + if (!exportDeclaration.moduleSpecifier) { + addRef(); } - else if (!(referenceSymbol.flags & 134217728 /* Transient */) && ts.contains(searchSymbols, shorthandValueSymbol)) { - addReferenceToRelatedSymbol(referenceSymbolDeclaration.name, shorthandValueSymbol); + if (!state.isForRename && state.markSeenReExportRHS(name)) { + addReference(name, referenceSymbol, name, state); } - else if (searchLocation.kind === 122 /* ConstructorKeyword */) { - findAdditionalConstructorReferences(referenceSymbol, referenceLocation); + } + else { + if (state.markSeenReExportRHS(referenceLocation)) { + addRef(); } } + // For `export { foo as bar }`, rename `foo`, but not `bar`. + if (!(referenceLocation === propertyName && state.isForRename)) { + var exportKind = referenceLocation.originalKeywordKind === 79 /* DefaultKeyword */ ? 1 /* Default */ : 0 /* Named */; + var exportInfo = FindAllReferences.getExportInfo(referenceSymbol, exportKind, state.checker); + ts.Debug.assert(!!exportInfo); + searchForImportsOfExport(referenceLocation, referenceSymbol, exportInfo, state); + } + // At `export { x } from "foo"`, also search for the imported symbol `"foo".x`. + if (search.comingFrom !== 1 /* Export */ && exportDeclaration.moduleSpecifier && !propertyName) { + searchForImportedSymbol(state.checker.getExportSpecifierLocalTargetSymbol(exportSpecifier), state); + } + function addRef() { + addReference(referenceLocation, localSymbol, search.location, state); + } } - return; - /* If we are just looking for implementations and this is a property access expression, we need to get the - * symbol of the local type of the symbol the property is being accessed on. This is because our search - * symbol may have a different parent symbol if the local type's symbol does not declare the property - * being accessed (i.e. it is declared in some parent class or interface) - */ - function getParentSymbolsOfPropertyAccess() { - if (implementations) { - var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(searchLocation); - if (propertyAccessExpression) { - var localParentType = typeChecker.getTypeAtLocation(propertyAccessExpression.expression); - if (localParentType) { - if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== searchSymbol.parent) { - return [localParentType.symbol]; - } - else if (localParentType.flags & 196608 /* UnionOrIntersection */) { - return getSymbolsForClassAndInterfaceComponents(localParentType); - } - } + function getLocalSymbolForExportSpecifier(referenceLocation, referenceSymbol, exportSpecifier, checker) { + return isExportSpecifierAlias(referenceLocation, exportSpecifier) ? checker.getExportSpecifierLocalTargetSymbol(exportSpecifier) : referenceSymbol; + } + function isExportSpecifierAlias(referenceLocation, exportSpecifier) { + var parent = exportSpecifier.parent, propertyName = exportSpecifier.propertyName, name = exportSpecifier.name; + ts.Debug.assert(propertyName === referenceLocation || name === referenceLocation); + if (propertyName) { + // Given `export { foo as bar } [from "someModule"]`: It's an alias at `foo`, but at `bar` it's a new symbol. + return propertyName === referenceLocation; + } + else { + // `export { foo } from "foo"` is a re-export. + // `export { foo };` is not a re-export, it creates an alias for the local variable `foo`. + return !parent.parent.moduleSpecifier; + } + } + function getImportOrExportReferences(referenceLocation, referenceSymbol, search, state) { + var importOrExport = FindAllReferences.getImportOrExportSymbol(referenceLocation, referenceSymbol, state.checker, search.comingFrom === 1 /* Export */); + if (!importOrExport) + return; + var symbol = importOrExport.symbol; + if (importOrExport.kind === 0 /* Import */) { + if (!state.isForRename || importOrExport.isNamedImport) { + searchForImportedSymbol(symbol, state); } } + else { + // We don't check for `state.isForRename`, even for default exports, because importers that previously matched the export name should be updated to continue matching. + searchForImportsOfExport(referenceLocation, symbol, importOrExport.exportInfo, state); + } + } + function getReferenceForShorthandProperty(_a, search, state) { + var flags = _a.flags, valueDeclaration = _a.valueDeclaration; + var shorthandValueSymbol = state.checker.getShorthandAssignmentValueSymbol(valueDeclaration); + /* + * Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment + * has two meanings: property name and property value. Therefore when we do findAllReference at the position where + * an identifier is declared, the language service should return the position of the variable declaration as well as + * the position in short-hand property assignment excluding property accessing. However, if we do findAllReference at the + * position of property accessing, the referenceEntry of such position will be handled in the first case. + */ + if (!(flags & 134217728 /* Transient */) && search.includes(shorthandValueSymbol)) { + addReference(valueDeclaration.name, shorthandValueSymbol, search.location, state); + } + } + function addReference(referenceLocation, relatedSymbol, searchLocation, state) { + var addRef = state.referenceAdder(relatedSymbol, searchLocation); + if (state.implementations) { + addImplementationReferences(referenceLocation, addRef, state); + } + else { + addRef(referenceLocation); + } } /** Adds references when a constructor is used with `new this()` in its own class and `super()` calls in subclasses. */ - function findAdditionalConstructorReferences(referenceSymbol, referenceLocation) { - ts.Debug.assert(ts.isClassLike(searchSymbol.valueDeclaration)); - var referenceClass = referenceLocation.parent; - if (referenceSymbol === searchSymbol && ts.isClassLike(referenceClass)) { - ts.Debug.assert(referenceClass.name === referenceLocation); + function findConstructorReferences(referenceLocation, sourceFile, search, state) { + if (ts.isNewExpressionTarget(referenceLocation)) { + addReference(referenceLocation, search.symbol, search.location, state); + } + var pusher = state.referenceAdder(search.symbol, search.location); + if (ts.isClassLike(referenceLocation.parent)) { + ts.Debug.assert(referenceLocation.parent.name === referenceLocation); // This is the class declaration containing the constructor. - addReferences(findOwnConstructorCalls(searchSymbol, sourceFile)); + findOwnConstructorReferences(search.symbol, sourceFile, pusher); } else { // If this class appears in `extends C`, then the extending class' "super" calls are references. var classExtending = tryGetClassByExtendingIdentifier(referenceLocation); - if (classExtending && ts.isClassLike(classExtending) && followAliasIfNecessary(referenceSymbol, referenceLocation, typeChecker) === searchSymbol) { - addReferences(superConstructorAccesses(classExtending)); + if (classExtending && ts.isClassLike(classExtending)) { + findSuperConstructorAccesses(classExtending, pusher); } } } - function addReferences(references) { - if (references.length) { - var referencedSymbol = getReferencedSymbol(searchSymbol); - ts.addRange(referencedSymbol.references, ts.map(references, getReferenceEntryFromNode)); - } + function getPropertyAccessExpressionFromRightHandSide(node) { + return ts.isRightSideOfPropertyAccess(node) && node.parent; } - function getReferencedSymbol(symbol) { - var symbolId = ts.getSymbolId(symbol); - var index = symbolToIndex[symbolId]; - if (index === undefined) { - index = result.length; - symbolToIndex[symbolId] = index; - result.push({ - definition: getDefinition(symbol, searchLocation, typeChecker), - references: [] - }); + /** + * `classSymbol` is the class where the constructor was defined. + * Reference the constructor and all calls to `new this()`. + */ + function findOwnConstructorReferences(classSymbol, sourceFile, addNode) { + for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + var ctrKeyword = ts.findChildOfKind(decl, 123 /* ConstructorKeyword */, sourceFile); + ts.Debug.assert(decl.kind === 152 /* Constructor */ && !!ctrKeyword); + addNode(ctrKeyword); } - return result[index]; + classSymbol.exports.forEach(function (member) { + var decl = member.valueDeclaration; + if (decl && decl.kind === 151 /* MethodDeclaration */) { + var body = decl.body; + if (body) { + forEachDescendantOfKind(body, 99 /* ThisKeyword */, function (thisKeyword) { + if (ts.isNewExpressionTarget(thisKeyword)) { + addNode(thisKeyword); + } + }); + } + } + }); } - function addReferenceToRelatedSymbol(node, relatedSymbol) { - var references = getReferencedSymbol(relatedSymbol).references; - if (implementations) { - getImplementationReferenceEntryForNode(node, references, typeChecker); + /** Find references to `super` in the constructor of an extending class. */ + function findSuperConstructorAccesses(cls, addNode) { + var symbol = cls.symbol; + var ctr = symbol.members.get("__constructor"); + if (!ctr) { + return; } - else { - references.push(getReferenceEntryFromNode(node)); - } - } - } - function getPropertyAccessExpressionFromRightHandSide(node) { - return ts.isRightSideOfPropertyAccess(node) && node.parent; - } - /** `classSymbol` is the class where the constructor was defined. - * Reference the constructor and all calls to `new this()`. - */ - function findOwnConstructorCalls(classSymbol, sourceFile) { - var result = []; - for (var _i = 0, _a = classSymbol.members.get("__constructor").declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - var ctrKeyword = ts.findChildOfKind(decl, 122 /* ConstructorKeyword */, sourceFile); - ts.Debug.assert(decl.kind === 151 /* Constructor */ && !!ctrKeyword); - result.push(ctrKeyword); - } - classSymbol.exports.forEach(function (member) { - var decl = member.valueDeclaration; - if (decl && decl.kind === 150 /* MethodDeclaration */) { + for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { + var decl = _a[_i]; + ts.Debug.assert(decl.kind === 152 /* Constructor */); var body = decl.body; if (body) { - forEachDescendantOfKind(body, 98 /* ThisKeyword */, function (thisKeyword) { - if (ts.isNewExpressionTarget(thisKeyword)) { - result.push(thisKeyword); + forEachDescendantOfKind(body, 97 /* SuperKeyword */, function (node) { + if (ts.isCallExpressionTarget(node)) { + addNode(node); } }); } } - }); - return result; - } - /** Find references to `super` in the constructor of an extending class. */ - function superConstructorAccesses(cls) { - var symbol = cls.symbol; - var ctr = symbol.members.get("__constructor"); - if (!ctr) { - return []; } - var result = []; - for (var _i = 0, _a = ctr.declarations; _i < _a.length; _i++) { - var decl = _a[_i]; - ts.Debug.assert(decl.kind === 151 /* Constructor */); - var body = decl.body; - if (body) { - forEachDescendantOfKind(body, 96 /* SuperKeyword */, function (node) { - if (ts.isCallExpressionTarget(node)) { - result.push(node); - } - }); + function addImplementationReferences(refNode, addReference, state) { + // Check if we found a function/propertyAssignment/method with an implementation or initializer + if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { + addReference(refNode.parent); + return; } - } - ; - return result; - } - function getImplementationReferenceEntryForNode(refNode, result, typeChecker) { - // Check if we found a function/propertyAssignment/method with an implementation or initializer - if (ts.isDeclarationName(refNode) && isImplementation(refNode.parent)) { - result.push(getReferenceEntryFromNode(refNode.parent)); - } - else if (refNode.kind === 70 /* Identifier */) { - if (refNode.parent.kind === 261 /* ShorthandPropertyAssignment */) { + if (refNode.kind !== 71 /* Identifier */) { + return; + } + if (refNode.parent.kind === 262 /* ShorthandPropertyAssignment */) { // Go ahead and dereference the shorthand assignment by going to its definition - getReferenceEntriesForShorthandPropertyAssignment(refNode, typeChecker, result); + getReferenceEntriesForShorthandPropertyAssignment(refNode, state.checker, addReference); } // Check if the node is within an extends or implements clause var containingClass = getContainingClassIfInHeritageClause(refNode); if (containingClass) { - result.push(getReferenceEntryFromNode(containingClass)); + addReference(containingClass); return; } // If we got a type reference, try and see if the reference applies to any expressions that can implement an interface var containingTypeReference = getContainingTypeReference(refNode); - if (containingTypeReference) { + if (containingTypeReference && state.markSeenContainingTypeReference(containingTypeReference)) { var parent = containingTypeReference.parent; if (ts.isVariableLike(parent) && parent.type === containingTypeReference && parent.initializer && isImplementationExpression(parent.initializer)) { - maybeAdd(getReferenceEntryFromNode(parent.initializer)); + addReference(parent.initializer); } else if (ts.isFunctionLike(parent) && parent.type === containingTypeReference && parent.body) { - if (parent.body.kind === 206 /* Block */) { + if (parent.body.kind === 207 /* Block */) { ts.forEachReturnStatement(parent.body, function (returnStatement) { if (returnStatement.expression && isImplementationExpression(returnStatement.expression)) { - maybeAdd(getReferenceEntryFromNode(returnStatement.expression)); + addReference(returnStatement.expression); } }); } else if (isImplementationExpression(parent.body)) { - maybeAdd(getReferenceEntryFromNode(parent.body)); + addReference(parent.body); } } else if (ts.isAssertionExpression(parent) && isImplementationExpression(parent.expression)) { - maybeAdd(getReferenceEntryFromNode(parent.expression)); + addReference(parent.expression); } } } - // Type nodes can contain multiple references to the same type. For example: - // let x: Foo & (Foo & Bar) = ... - // Because we are returning the implementation locations and not the identifier locations, - // duplicate entries would be returned here as each of the type references is part of - // the same implementation. For that reason, check before we add a new entry - function maybeAdd(a) { - if (!ts.forEach(result, function (b) { return a.fileName === b.fileName && a.textSpan.start === b.textSpan.start && a.textSpan.length === b.textSpan.length; })) { - result.push(a); + function getSymbolsForClassAndInterfaceComponents(type, result) { + if (result === void 0) { result = []; } + for (var _i = 0, _a = type.types; _i < _a.length; _i++) { + var componentType = _a[_i]; + if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { + result.push(componentType.symbol); + } + if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { + getSymbolsForClassAndInterfaceComponents(componentType, result); + } + } + return result; + } + function getContainingTypeReference(node) { + var topLevelTypeReference = undefined; + while (node) { + if (ts.isTypeNode(node)) { + topLevelTypeReference = node; + } + node = node.parent; + } + return topLevelTypeReference; + } + function getContainingClassIfInHeritageClause(node) { + if (node && node.parent) { + if (node.kind === 201 /* ExpressionWithTypeArguments */ + && node.parent.kind === 259 /* HeritageClause */ + && ts.isClassLike(node.parent.parent)) { + return node.parent.parent; + } + else if (node.kind === 71 /* Identifier */ || node.kind === 179 /* PropertyAccessExpression */) { + return getContainingClassIfInHeritageClause(node.parent); + } + } + return undefined; + } + /** + * Returns true if this is an expression that can be considered an implementation + */ + function isImplementationExpression(node) { + switch (node.kind) { + case 185 /* ParenthesizedExpression */: + return isImplementationExpression(node.expression); + case 187 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 178 /* ObjectLiteralExpression */: + case 199 /* ClassExpression */: + case 177 /* ArrayLiteralExpression */: + return true; + default: + return false; } } - } - function getSymbolsForClassAndInterfaceComponents(type, result) { - if (result === void 0) { result = []; } - for (var _i = 0, _a = type.types; _i < _a.length; _i++) { - var componentType = _a[_i]; - if (componentType.symbol && componentType.symbol.getFlags() & (32 /* Class */ | 64 /* Interface */)) { - result.push(componentType.symbol); - } - if (componentType.getFlags() & 196608 /* UnionOrIntersection */) { - getSymbolsForClassAndInterfaceComponents(componentType, result); - } - } - return result; - } - function getContainingTypeReference(node) { - var topLevelTypeReference = undefined; - while (node) { - if (ts.isTypeNode(node)) { - topLevelTypeReference = node; - } - node = node.parent; - } - return topLevelTypeReference; - } - function getContainingClassIfInHeritageClause(node) { - if (node && node.parent) { - if (node.kind === 200 /* ExpressionWithTypeArguments */ - && node.parent.kind === 258 /* HeritageClause */ - && ts.isClassLike(node.parent.parent)) { - return node.parent.parent; - } - else if (node.kind === 70 /* Identifier */ || node.kind === 178 /* PropertyAccessExpression */) { - return getContainingClassIfInHeritageClause(node.parent); - } - } - return undefined; - } - /** - * Returns true if this is an expression that can be considered an implementation - */ - function isImplementationExpression(node) { - switch (node.kind) { - case 184 /* ParenthesizedExpression */: - return isImplementationExpression(node.expression); - case 186 /* ArrowFunction */: - case 185 /* FunctionExpression */: - case 177 /* ObjectLiteralExpression */: - case 198 /* ClassExpression */: - case 176 /* ArrayLiteralExpression */: - return true; - default: - return false; - } - } - /** - * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol - * is an interface, determines if some ancestor of the child symbol extends or inherits from it. - * Also takes in a cache of previous results which makes this slightly more efficient and is - * necessary to avoid potential loops like so: - * class A extends B { } - * class B extends A { } - * - * We traverse the AST rather than using the type checker because users are typically only interested - * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling - * implementations of types that share a common ancestor with the type whose implementation we are - * searching for need to be filtered out of the results. The type checker doesn't let us make the - * distinction between structurally compatible implementations and explicit implementations, so we - * must use the AST. - * - * @param child A class or interface Symbol - * @param parent Another class or interface Symbol - * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results - */ - function explicitlyInheritsFrom(child, parent, cachedResults, typeChecker) { - var parentIsInterface = parent.getFlags() & 64 /* Interface */; - return searchHierarchy(child); - function searchHierarchy(symbol) { - if (symbol === parent) { - return true; - } - var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); - var cached = cachedResults.get(key); - if (cached !== undefined) { - return cached; - } - // Set the key so that we don't infinitely recurse - cachedResults.set(key, false); - var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - if (parentIsInterface) { - var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); - if (interfaceReferences) { - for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { - var typeReference = interfaceReferences_1[_i]; - if (searchTypeReference(typeReference)) { - return true; + /** + * Determines if the parent symbol occurs somewhere in the child's ancestry. If the parent symbol + * is an interface, determines if some ancestor of the child symbol extends or inherits from it. + * Also takes in a cache of previous results which makes this slightly more efficient and is + * necessary to avoid potential loops like so: + * class A extends B { } + * class B extends A { } + * + * We traverse the AST rather than using the type checker because users are typically only interested + * in explicit implementations of an interface/class when calling "Go to Implementation". Sibling + * implementations of types that share a common ancestor with the type whose implementation we are + * searching for need to be filtered out of the results. The type checker doesn't let us make the + * distinction between structurally compatible implementations and explicit implementations, so we + * must use the AST. + * + * @param child A class or interface Symbol + * @param parent Another class or interface Symbol + * @param cachedResults A map of symbol id pairs (i.e. "child,parent") to booleans indicating previous results + */ + function explicitlyInheritsFrom(child, parent, cachedResults, checker) { + var parentIsInterface = parent.getFlags() & 64 /* Interface */; + return searchHierarchy(child); + function searchHierarchy(symbol) { + if (symbol === parent) { + return true; + } + var key = ts.getSymbolId(symbol) + "," + ts.getSymbolId(parent); + var cached = cachedResults.get(key); + if (cached !== undefined) { + return cached; + } + // Set the key so that we don't infinitely recurse + cachedResults.set(key, false); + var inherits = ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + if (parentIsInterface) { + var interfaceReferences = ts.getClassImplementsHeritageClauseElements(declaration); + if (interfaceReferences) { + for (var _i = 0, interfaceReferences_1 = interfaceReferences; _i < interfaceReferences_1.length; _i++) { + var typeReference = interfaceReferences_1[_i]; + if (searchTypeReference(typeReference)) { + return true; + } } } } + return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); } - return searchTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - } - else if (declaration.kind === 229 /* InterfaceDeclaration */) { - if (parentIsInterface) { - return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + else if (declaration.kind === 230 /* InterfaceDeclaration */) { + if (parentIsInterface) { + return ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), searchTypeReference); + } + } + return false; + }); + cachedResults.set(key, inherits); + return inherits; + } + function searchTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type && type.symbol) { + return searchHierarchy(type.symbol); } } return false; - }); - cachedResults.set(key, inherits); - return inherits; - } - function searchTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type && type.symbol) { - return searchHierarchy(type.symbol); - } } - return false; } - } - function getReferencesForSuperKeyword(superKeyword, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); - if (!searchSpaceNode) { - return undefined; - } - // Whether 'super' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - default: + function getReferencesForSuperKeyword(superKeyword) { + var searchSpaceNode = ts.getSuperContainer(superKeyword, /*stopOnFunctions*/ false); + if (!searchSpaceNode) { return undefined; - } - var references = []; - var sourceFile = searchSpaceNode.getSourceFile(); - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - for (var _i = 0, possiblePositions_3 = possiblePositions; _i < possiblePositions_3.length; _i++) { - var position = possiblePositions_3[_i]; - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || node.kind !== 96 /* SuperKeyword */) { - continue; } - var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); - // If we have a 'super' container, we must have an enclosing class. - // Now make sure the owning class is the same as the search-space - // and has the same static qualifier as the original 'super's owner. - if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { - references.push(getReferenceEntryFromNode(node)); - } - } - var definition = getDefinition(searchSpaceNode.symbol, superKeyword, typeChecker); - return [{ definition: definition, references: references }]; - } - function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, typeChecker, cancellationToken) { - var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); - // Whether 'this' occurs in a static context within a class. - var staticFlag = 32 /* Static */; - switch (searchSpaceNode.kind) { - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode)) { + // Whether 'super' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class break; - } - // fall through - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - staticFlag &= ts.getModifierFlags(searchSpaceNode); - searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class - break; - case 264 /* SourceFile */: - if (ts.isExternalModule(searchSpaceNode)) { + default: return undefined; - } - // Fall through - case 227 /* FunctionDeclaration */: - case 185 /* 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. - default: - return undefined; - } - var references = []; - var possiblePositions; - if (searchSpaceNode.kind === 264 /* SourceFile */) { - ts.forEach(sourceFiles, function (sourceFile) { - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); - }); - } - else { + } + var references = []; var sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd(), cancellationToken); - getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); - } - var thisOrSuperSymbol = typeChecker.getSymbolAtLocation(thisOrSuperKeyword); - var displayParts = thisOrSuperSymbol && ts.SymbolDisplay.getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, thisOrSuperSymbol, thisOrSuperKeyword.getSourceFile(), ts.getContainerNode(thisOrSuperKeyword), thisOrSuperKeyword).displayParts; - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: thisOrSuperKeyword.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: "this", - textSpan: ts.createTextSpanFromNode(thisOrSuperKeyword), - displayParts: displayParts - }, - references: references - }]; - function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { - ts.forEach(possiblePositions, function (position) { - cancellationToken.throwIfCancellationRequested(); - var node = ts.getTouchingWord(sourceFile, position); - if (!node || !ts.isThis(node)) { - return; - } - var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); - switch (searchSpaceNode.kind) { - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - if (searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 198 /* ClassExpression */: - case 228 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { - result.push(getReferenceEntryFromNode(node)); - } - break; - case 264 /* SourceFile */: - if (container.kind === 264 /* SourceFile */ && !ts.isExternalModule(container)) { - result.push(getReferenceEntryFromNode(node)); - } - break; - } - }); - } - } - function getReferencesForStringLiteral(node, sourceFiles, typeChecker, cancellationToken) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (!type) { - // nothing to do here. moving on - return undefined; - } - var references = []; - for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { - var sourceFile = sourceFiles_7[_i]; - var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, type.text, sourceFile.getStart(), sourceFile.getEnd(), cancellationToken); - getReferencesForStringLiteralInFile(sourceFile, type, possiblePositions, references); - } - return [{ - definition: { - containerKind: "", - containerName: "", - fileName: node.getSourceFile().fileName, - kind: ts.ScriptElementKind.variableElement, - name: type.text, - textSpan: ts.createTextSpanFromNode(node), - displayParts: [ts.displayPart(ts.getTextOfNode(node), ts.SymbolDisplayPartKind.stringLiteral)] - }, - references: references - }]; - function getReferencesForStringLiteralInFile(sourceFile, searchType, possiblePositions, references) { + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); for (var _i = 0, possiblePositions_4 = possiblePositions; _i < possiblePositions_4.length; _i++) { var position = possiblePositions_4[_i]; - cancellationToken.throwIfCancellationRequested(); - var node_2 = ts.getTouchingWord(sourceFile, position); - if (!node_2 || node_2.kind !== 9 /* StringLiteral */) { - return; + var node = ts.getTouchingWord(sourceFile, position); + if (!node || node.kind !== 97 /* SuperKeyword */) { + continue; } - var type_2 = ts.getStringLiteralTypeForNode(node_2, typeChecker); - if (type_2 === searchType) { - references.push(getReferenceEntryFromNode(node_2)); + var container = ts.getSuperContainer(node, /*stopOnFunctions*/ false); + // If we have a 'super' container, we must have an enclosing class. + // Now make sure the owning class is the same as the search-space + // and has the same static qualifier as the original 'super's owner. + if (container && (32 /* Static */ & ts.getModifierFlags(container)) === staticFlag && container.parent.symbol === searchSpaceNode.symbol) { + references.push(FindAllReferences.nodeEntry(node)); } } + return [{ definition: { type: "symbol", symbol: searchSpaceNode.symbol, node: superKeyword }, references: references }]; } - } - function populateSearchSymbolSet(symbol, location, typeChecker, implementations) { - // The search set contains at least the current symbol - var result = [symbol]; - // If the location is name of property symbol from object literal destructuring pattern - // Search the property symbol - // for ( { property: p2 } of elems) { } - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); - if (containingObjectLiteralElement && containingObjectLiteralElement.kind !== 261 /* ShorthandPropertyAssignment */) { - var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, typeChecker); - if (propertySymbol) { - result.push(propertySymbol); - } - } - // If the location is in a context sensitive location (i.e. in an object literal) try - // to get a contextual type for it, and add the property symbol from the contextual - // type to the search set - if (containingObjectLiteralElement) { - ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - ts.addRange(result, typeChecker.getRootSymbols(contextualSymbol)); - }); - /* Because in short-hand property assignment, location has two meaning : property name and as value of the property - * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of - * property name and variable declaration of the identifier. - * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service - * should show both 'name' in 'obj' and 'name' in variable declaration - * const name = "Foo"; - * const obj = { name }; - * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment - * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration - * will be included correctly. - */ - var shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(location.parent); - if (shorthandValueSymbol) { - result.push(shorthandValueSymbol); - } - } - // 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 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 === 145 /* Parameter */ && - ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { - ts.addRange(result, typeChecker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); - } - // If this is symbol of binding element without propertyName declaration in Object binding pattern - // Include the property in the search - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, typeChecker); - if (bindingElementPropertySymbol) { - result.push(bindingElementPropertySymbol); - } - // If this is a union property, add all the symbols from all its source symbols in all unioned types. - // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list - for (var _i = 0, _a = typeChecker.getRootSymbols(symbol); _i < _a.length; _i++) { - var rootSymbol = _a[_i]; - if (rootSymbol !== symbol) { - result.push(rootSymbol); - } - // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions - if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); - } - } - return result; - } - /** - * 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 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 revisiting of the same symbol. - * The value of previousIterationSymbol is undefined when the function is first called. - */ - function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, typeChecker) { - if (!symbol) { - return; - } - // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited - // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. - // For example: - // interface C extends C { - // /*findRef*/propName: string; - // } - // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, - // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, - // the function will add any found symbol of the property-name, then its sub-routine will call - // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already - // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. - if (previousIterationSymbolsCache.has(symbol.name)) { - return; - } - if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { - ts.forEach(symbol.getDeclarations(), function (declaration) { - if (ts.isClassLike(declaration)) { - getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); - ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); - } - else if (declaration.kind === 229 /* InterfaceDeclaration */) { - ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); - } - }); - } - return; - function getPropertySymbolFromTypeReference(typeReference) { - if (typeReference) { - var type = typeChecker.getTypeAtLocation(typeReference); - if (type) { - var propertySymbol = typeChecker.getPropertyOfType(type, propertyName); - if (propertySymbol) { - result.push.apply(result, typeChecker.getRootSymbols(propertySymbol)); + function getReferencesForThisKeyword(thisOrSuperKeyword, sourceFiles, cancellationToken) { + var searchSpaceNode = ts.getThisContainer(thisOrSuperKeyword, /* includeArrowFunctions */ false); + // Whether 'this' occurs in a static context within a class. + var staticFlag = 32 /* Static */; + switch (searchSpaceNode.kind) { + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode)) { + break; } - // Visit the typeReference as well to see if it directly or indirectly use that property - previousIterationSymbolsCache.set(symbol.name, symbol); - getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, typeChecker); - } - } - } - } - function getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker) { - if (ts.contains(searchSymbols, referenceSymbol)) { - // If we are searching for constructor uses, they must be 'new' expressions. - return (!searchLocationIsConstructor || ts.isNewExpressionTarget(referenceLocation)) ? referenceSymbol : undefined; - } - // If the reference symbol is an alias, check if what it is aliasing is one of the search - // symbols but by looking up for related symbol of this alias so it can handle multiple level of indirectness. - var aliasSymbol = getAliasSymbolForPropertyNameSymbol(referenceSymbol, referenceLocation, typeChecker); - if (aliasSymbol) { - return getRelatedSymbol(searchSymbols, aliasSymbol, referenceLocation, searchLocationIsConstructor, parents, cache, typeChecker); - } - // If the reference location is in an object literal, try to get the contextual type for the - // object literal, lookup the property symbol in the contextual type, and use this symbol to - // compare to our searchSymbol - var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); - if (containingObjectLiteralElement) { - var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, typeChecker), function (contextualSymbol) { - return ts.find(typeChecker.getRootSymbols(contextualSymbol), function (symbol) { return ts.contains(searchSymbols, symbol); }); - }); - if (contextualSymbol) { - return contextualSymbol; - } - // If the reference location is the name of property from object literal destructuring pattern - // Get the property symbol from the object literal's type and look if thats the search symbol - // In below eg. get 'property' from type of elems iterating type - // for ( { property: p2 } of elems) { } - var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, typeChecker); - if (propertySymbol && ts.contains(searchSymbols, propertySymbol)) { - return propertySymbol; - } - } - // If the reference location is the binding element and doesn't have property name - // then include the binding element in the related symbols - // let { a } : { a }; - var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, typeChecker); - if (bindingElementPropertySymbol && ts.contains(searchSymbols, bindingElementPropertySymbol)) { - return bindingElementPropertySymbol; - } - // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) - // Or a union property, use its underlying unioned symbols - return ts.forEach(typeChecker.getRootSymbols(referenceSymbol), function (rootSymbol) { - // if it is in the list, then we are done - if (ts.contains(searchSymbols, rootSymbol)) { - return rootSymbol; - } - // 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 we were passed a parent symbol, only include types that are subtypes of the - // parent symbol - if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { - // Parents will only be defined if implementations is true - if (parents) { - if (!ts.forEach(parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, cache, typeChecker); })) { + // falls through + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + staticFlag &= ts.getModifierFlags(searchSpaceNode); + searchSpaceNode = searchSpaceNode.parent; // re-assign to be the owning class + break; + case 265 /* SourceFile */: + if (ts.isExternalModule(searchSpaceNode)) { return undefined; } - } - var result = []; - getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), typeChecker); - return ts.find(result, function (symbol) { return ts.contains(searchSymbols, symbol); }); + // falls through + case 228 /* FunctionDeclaration */: + case 186 /* 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. + default: + return undefined; } - return undefined; - }); - } - function getNameFromObjectLiteralElement(node) { - if (node.name.kind === 143 /* 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)) { - return nameExpression.text; + var references = []; + var possiblePositions; + if (searchSpaceNode.kind === 265 /* SourceFile */) { + ts.forEach(sourceFiles, function (sourceFile) { + cancellationToken.throwIfCancellationRequested(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); + }); } - return undefined; - } - return node.name.text; - } - /** Gets all symbols for one property. Does not get symbols for every property. */ - function getPropertySymbolsFromContextualType(node, typeChecker) { - var objectLiteral = node.parent; - var contextualType = typeChecker.getContextualType(objectLiteral); - var name = getNameFromObjectLiteralElement(node); - if (name && contextualType) { - var result_4 = []; - var symbol = contextualType.getProperty(name); - if (symbol) { - result_4.push(symbol); + else { + var sourceFile = searchSpaceNode.getSourceFile(); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } - if (contextualType.flags & 65536 /* Union */) { - ts.forEach(contextualType.types, function (t) { - var symbol = t.getProperty(name); - if (symbol) { - result_4.push(symbol); + return [{ + definition: { type: "this", node: thisOrSuperKeyword }, + references: references + }]; + function getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, result) { + ts.forEach(possiblePositions, function (position) { + var node = ts.getTouchingWord(sourceFile, position); + if (!node || !ts.isThis(node)) { + return; + } + var container = ts.getThisContainer(node, /* includeArrowFunctions */ false); + switch (searchSpaceNode.kind) { + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + if (searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + if (ts.isObjectLiteralMethod(searchSpaceNode) && searchSpaceNode.symbol === container.symbol) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 199 /* ClassExpression */: + case 229 /* 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 && (ts.getModifierFlags(container) & 32 /* Static */) === staticFlag) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; + case 265 /* SourceFile */: + if (container.kind === 265 /* SourceFile */ && !ts.isExternalModule(container)) { + result.push(FindAllReferences.nodeEntry(node)); + } + break; } }); } - return result_4; } - return undefined; - } - /** - * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations - * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class - * then we need to widen the search to include type positions as well. - * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated - * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) - * do not intersect in any of the three spaces. - */ - function getIntersectingMeaningFromDeclarations(meaning, declarations) { - if (declarations) { - 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 - // intersects with the class in the value space. - // To achieve that we will keep iterating until the result stabilizes. - // Remember the last meaning - lastIterationMeaning = meaning; - for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { - var declaration = declarations_11[_i]; - var declarationMeaning = ts.getMeaningFromDeclaration(declaration); - if (declarationMeaning & meaning) { - meaning |= declarationMeaning; + function getReferencesForStringLiteral(node, sourceFiles, cancellationToken) { + var references = []; + for (var _i = 0, sourceFiles_6 = sourceFiles; _i < sourceFiles_6.length; _i++) { + var sourceFile = sourceFiles_6[_i]; + cancellationToken.throwIfCancellationRequested(); + var possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text, sourceFile.getStart(), sourceFile.getEnd()); + getReferencesForStringLiteralInFile(sourceFile, node.text, possiblePositions, references); + } + return [{ + definition: { type: "string", node: node }, + references: references + }]; + function getReferencesForStringLiteralInFile(sourceFile, searchText, possiblePositions, references) { + for (var _i = 0, possiblePositions_5 = possiblePositions; _i < possiblePositions_5.length; _i++) { + var position = possiblePositions_5[_i]; + var node_7 = ts.getTouchingWord(sourceFile, position); + if (node_7 && node_7.kind === 9 /* StringLiteral */ && node_7.text === searchText) { + references.push(FindAllReferences.nodeEntry(node_7, /*isInString*/ true)); } } - } while (meaning !== lastIterationMeaning); - } - return meaning; - } - function isImplementation(node) { - if (!node) { - return false; - } - else if (ts.isVariableLike(node)) { - if (node.initializer) { - return true; - } - else if (node.kind === 225 /* VariableDeclaration */) { - var parentStatement = getParentStatementOfVariableDeclaration(node); - return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); } } - else if (ts.isFunctionLike(node)) { - return !!node.body || ts.hasModifier(node, 2 /* Ambient */); - } - else { - switch (node.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: - return true; + // For certain symbol kinds, we need to include other symbols in the search set. + // This is not needed when searching for re-exports. + function populateSearchSymbolSet(symbol, location, checker, implementations) { + // The search set contains at least the current symbol + var result = [symbol]; + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(location); + if (containingObjectLiteralElement) { + // If the location is name of property symbol from object literal destructuring pattern + // Search the property symbol + // for ( { property: p2 } of elems) { } + if (containingObjectLiteralElement.kind !== 262 /* ShorthandPropertyAssignment */) { + var propertySymbol = getPropertySymbolOfDestructuringAssignment(location, checker); + if (propertySymbol) { + result.push(propertySymbol); + } + } + // If the location is in a context sensitive location (i.e. in an object literal) try + // to get a contextual type for it, and add the property symbol from the contextual + // type to the search set + ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, checker), function (contextualSymbol) { + ts.addRange(result, checker.getRootSymbols(contextualSymbol)); + }); + /* Because in short-hand property assignment, location has two meaning : property name and as value of the property + * When we do findAllReference at the position of the short-hand property assignment, we would want to have references to position of + * property name and variable declaration of the identifier. + * Like in below example, when querying for all references for an identifier 'name', of the property assignment, the language service + * should show both 'name' in 'obj' and 'name' in variable declaration + * const name = "Foo"; + * const obj = { name }; + * In order to do that, we will populate the search set with the value symbol of the identifier as a value of the property assignment + * so that when matching with potential reference symbol, both symbols from property declaration and variable declaration + * will be included correctly. + */ + var shorthandValueSymbol = checker.getShorthandAssignmentValueSymbol(location.parent); + if (shorthandValueSymbol) { + result.push(shorthandValueSymbol); + } } + // 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 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 === 146 /* Parameter */ && + ts.isParameterPropertyDeclaration(symbol.valueDeclaration)) { + ts.addRange(result, checker.getSymbolsOfParameterPropertyDeclaration(symbol.valueDeclaration, symbol.name)); + } + // If this is symbol of binding element without propertyName declaration in Object binding pattern + // Include the property in the search + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol, checker); + if (bindingElementPropertySymbol) { + result.push(bindingElementPropertySymbol); + } + // If this is a union property, add all the symbols from all its source symbols in all unioned types. + // If the symbol is an instantiation from a another symbol (e.g. widened symbol) , add the root the list + for (var _i = 0, _a = checker.getRootSymbols(symbol); _i < _a.length; _i++) { + var rootSymbol = _a[_i]; + if (rootSymbol !== symbol) { + result.push(rootSymbol); + } + // Add symbol of properties/methods of the same name in base classes and implemented interfaces definitions + if (!implementations && rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), checker); + } + } + return result; } - return false; - } - function getParentStatementOfVariableDeclaration(node) { - if (node.parent && node.parent.parent && node.parent.parent.kind === 207 /* VariableStatement */) { - ts.Debug.assert(node.parent.kind === 226 /* VariableDeclarationList */); - return node.parent.parent; - } - } - function getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result) { - var refSymbol = typeChecker.getSymbolAtLocation(node); - var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); - if (shorthandSymbol) { - for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { - var declaration = _a[_i]; - if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { - result.push(getReferenceEntryFromNode(declaration)); + /** + * 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 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 revisiting of the same symbol. + * The value of previousIterationSymbol is undefined when the function is first called. + */ + function getPropertySymbolsFromBaseTypes(symbol, propertyName, result, previousIterationSymbolsCache, checker) { + if (!symbol) { + return; + } + // If the current symbol is the same as the previous-iteration symbol, we can just return the symbol that has already been visited + // This is particularly important for the following cases, so that we do not infinitely visit the same symbol. + // For example: + // interface C extends C { + // /*findRef*/propName: string; + // } + // The first time getPropertySymbolsFromBaseTypes is called when finding-all-references at propName, + // the symbol argument will be the symbol of an interface "C" and previousIterationSymbol is undefined, + // the function will add any found symbol of the property-name, then its sub-routine will call + // getPropertySymbolsFromBaseTypes again to walk up any base types to prevent revisiting already + // visited symbol, interface "C", the sub-routine will pass the current symbol as previousIterationSymbol. + if (previousIterationSymbolsCache.has(symbol.name)) { + return; + } + if (symbol.flags & (32 /* Class */ | 64 /* Interface */)) { + ts.forEach(symbol.getDeclarations(), function (declaration) { + if (ts.isClassLike(declaration)) { + getPropertySymbolFromTypeReference(ts.getClassExtendsHeritageClauseElement(declaration)); + ts.forEach(ts.getClassImplementsHeritageClauseElements(declaration), getPropertySymbolFromTypeReference); + } + else if (declaration.kind === 230 /* InterfaceDeclaration */) { + ts.forEach(ts.getInterfaceBaseTypeNodes(declaration), getPropertySymbolFromTypeReference); + } + }); + } + return; + function getPropertySymbolFromTypeReference(typeReference) { + if (typeReference) { + var type = checker.getTypeAtLocation(typeReference); + if (type) { + var propertySymbol = checker.getPropertyOfType(type, propertyName); + if (propertySymbol) { + result.push.apply(result, checker.getRootSymbols(propertySymbol)); + } + // Visit the typeReference as well to see if it directly or indirectly use that property + previousIterationSymbolsCache.set(symbol.name, symbol); + getPropertySymbolsFromBaseTypes(type.symbol, propertyName, result, previousIterationSymbolsCache, checker); + } } } } - } - FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; - function getReferenceEntryFromNode(node) { - var start = node.getStart(); - var end = node.getEnd(); - if (node.kind === 9 /* StringLiteral */) { - start += 1; - end -= 1; - } - return { - fileName: node.getSourceFile().fileName, - textSpan: ts.createTextSpanFromBounds(start, end), - isWriteAccess: isWriteAccess(node), - isDefinition: ts.isDeclarationName(node) || ts.isLiteralComputedPropertyDeclarationName(node) - }; - } - FindAllReferences.getReferenceEntryFromNode = getReferenceEntryFromNode; - /** A node is considered a writeAccess iff it is a name of a declaration or a target of an assignment */ - function isWriteAccess(node) { - if (node.kind === 70 /* Identifier */ && ts.isDeclarationName(node)) { - return true; - } - var parent = node.parent; - if (parent) { - if (parent.kind === 192 /* PostfixUnaryExpression */ || parent.kind === 191 /* PrefixUnaryExpression */) { - return true; + function getRelatedSymbol(search, referenceSymbol, referenceLocation, state) { + if (search.includes(referenceSymbol)) { + return referenceSymbol; } - else if (parent.kind === 193 /* BinaryExpression */ && parent.left === node) { - var operator = parent.operatorToken.kind; - return 57 /* FirstAssignment */ <= operator && operator <= 69 /* LastAssignment */; + // If the reference location is in an object literal, try to get the contextual type for the + // object literal, lookup the property symbol in the contextual type, and use this symbol to + // compare to our searchSymbol + var containingObjectLiteralElement = ts.getContainingObjectLiteralElement(referenceLocation); + if (containingObjectLiteralElement) { + var contextualSymbol = ts.forEach(getPropertySymbolsFromContextualType(containingObjectLiteralElement, state.checker), function (contextualSymbol) { + return ts.find(state.checker.getRootSymbols(contextualSymbol), search.includes); + }); + if (contextualSymbol) { + return contextualSymbol; + } + // If the reference location is the name of property from object literal destructuring pattern + // Get the property symbol from the object literal's type and look if thats the search symbol + // In below eg. get 'property' from type of elems iterating type + // for ( { property: p2 } of elems) { } + var propertySymbol = getPropertySymbolOfDestructuringAssignment(referenceLocation, state.checker); + if (propertySymbol && search.includes(propertySymbol)) { + return propertySymbol; + } + } + // If the reference location is the binding element and doesn't have property name + // then include the binding element in the related symbols + // let { a } : { a }; + var bindingElementPropertySymbol = getPropertySymbolOfObjectBindingPatternWithoutPropertyName(referenceSymbol, state.checker); + if (bindingElementPropertySymbol && search.includes(bindingElementPropertySymbol)) { + return bindingElementPropertySymbol; + } + // Unwrap symbols to get to the root (e.g. transient symbols as a result of widening) + // Or a union property, use its underlying unioned symbols + return ts.forEach(state.checker.getRootSymbols(referenceSymbol), function (rootSymbol) { + // if it is in the list, then we are done + if (search.includes(rootSymbol)) { + return rootSymbol; + } + // 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 we were passed a parent symbol, only include types that are subtypes of the + // parent symbol + if (rootSymbol.parent && rootSymbol.parent.flags & (32 /* Class */ | 64 /* Interface */)) { + // Parents will only be defined if implementations is true + if (search.parents && !ts.some(search.parents, function (parent) { return explicitlyInheritsFrom(rootSymbol.parent, parent, state.inheritsFromCache, state.checker); })) { + return undefined; + } + var result = []; + getPropertySymbolsFromBaseTypes(rootSymbol.parent, rootSymbol.getName(), result, /*previousIterationSymbolsCache*/ ts.createMap(), state.checker); + return ts.find(result, search.includes); + } + return undefined; + }); + } + function getNameFromObjectLiteralElement(node) { + if (node.name.kind === 144 /* 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)) { + return nameExpression.text; + } + return undefined; + } + return node.name.text; + } + /** Gets all symbols for one property. Does not get symbols for every property. */ + function getPropertySymbolsFromContextualType(node, checker) { + var objectLiteral = node.parent; + var contextualType = checker.getContextualType(objectLiteral); + var name = getNameFromObjectLiteralElement(node); + if (name && contextualType) { + var result_5 = []; + var symbol = contextualType.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + if (contextualType.flags & 65536 /* Union */) { + ts.forEach(contextualType.types, function (t) { + var symbol = t.getProperty(name); + if (symbol) { + result_5.push(symbol); + } + }); + } + return result_5; + } + return undefined; + } + /** + * Given an initial searchMeaning, extracted from a location, widen the search scope based on the declarations + * of the corresponding symbol. e.g. if we are searching for "Foo" in value position, but "Foo" references a class + * then we need to widen the search to include type positions as well. + * On the contrary, if we are searching for "Bar" in type position and we trace bar to an interface, and an uninstantiated + * module, we want to keep the search limited to only types, as the two declarations (interface and uninstantiated module) + * do not intersect in any of the three spaces. + */ + function getIntersectingMeaningFromDeclarations(meaning, declarations) { + if (declarations) { + 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 + // intersects with the class in the value space. + // To achieve that we will keep iterating until the result stabilizes. + // Remember the last meaning + lastIterationMeaning = meaning; + for (var _i = 0, declarations_11 = declarations; _i < declarations_11.length; _i++) { + var declaration = declarations_11[_i]; + var declarationMeaning = ts.getMeaningFromDeclaration(declaration); + if (declarationMeaning & meaning) { + meaning |= declarationMeaning; + } + } + } while (meaning !== lastIterationMeaning); + } + return meaning; + } + function isImplementation(node) { + if (!node) { + return false; + } + else if (ts.isVariableLike(node)) { + if (node.initializer) { + return true; + } + else if (node.kind === 226 /* VariableDeclaration */) { + var parentStatement = getParentStatementOfVariableDeclaration(node); + return parentStatement && ts.hasModifier(parentStatement, 2 /* Ambient */); + } + } + else if (ts.isFunctionLike(node)) { + return !!node.body || ts.hasModifier(node, 2 /* Ambient */); + } + else { + switch (node.kind) { + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: + return true; + } + } + return false; + } + function getParentStatementOfVariableDeclaration(node) { + if (node.parent && node.parent.parent && node.parent.parent.kind === 208 /* VariableStatement */) { + ts.Debug.assert(node.parent.kind === 227 /* VariableDeclarationList */); + return node.parent.parent; } } - return false; - } - function forEachDescendantOfKind(node, kind, action) { - ts.forEachChild(node, function (child) { - if (child.kind === kind) { - action(child); + function getReferenceEntriesForShorthandPropertyAssignment(node, checker, addReference) { + var refSymbol = checker.getSymbolAtLocation(node); + var shorthandSymbol = checker.getShorthandAssignmentValueSymbol(refSymbol.valueDeclaration); + if (shorthandSymbol) { + for (var _i = 0, _a = shorthandSymbol.getDeclarations(); _i < _a.length; _i++) { + var declaration = _a[_i]; + if (ts.getMeaningFromDeclaration(declaration) & 1 /* Value */) { + addReference(declaration); + } + } } - forEachDescendantOfKind(child, kind, action); - }); - } - /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ - function tryGetClassByExtendingIdentifier(node) { - return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); - } - function isNameOfExternalModuleImportOrDeclaration(node) { - if (node.kind === 9 /* StringLiteral */) { - return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); } - return false; - } - function isImportDefaultSymbol(symbol) { - return symbol.declarations[0].kind === 238 /* ImportClause */; - } + Core.getReferenceEntriesForShorthandPropertyAssignment = getReferenceEntriesForShorthandPropertyAssignment; + function forEachDescendantOfKind(node, kind, action) { + ts.forEachChild(node, function (child) { + if (child.kind === kind) { + action(child); + } + forEachDescendantOfKind(child, kind, action); + }); + } + /** Get `C` given `N` if `N` is in the position `class C extends N` or `class C extends foo.N` where `N` is an identifier. */ + function tryGetClassByExtendingIdentifier(node) { + return ts.tryGetClassExtendingExpressionWithTypeArguments(ts.climbPastPropertyAccess(node).parent); + } + function isNameOfExternalModuleImportOrDeclaration(node) { + if (node.kind === 9 /* StringLiteral */) { + return ts.isNameOfModuleDeclaration(node) || ts.isExpressionOfExternalModuleImportEqualsDeclaration(node); + } + return false; + } + /** + * If we are just looking for implementations and this is a property access expression, we need to get the + * symbol of the local type of the symbol the property is being accessed on. This is because our search + * symbol may have a different parent symbol if the local type's symbol does not declare the property + * being accessed (i.e. it is declared in some parent class or interface) + */ + function getParentSymbolsOfPropertyAccess(location, symbol, checker) { + var propertyAccessExpression = getPropertyAccessExpressionFromRightHandSide(location); + if (!propertyAccessExpression) { + return undefined; + } + var localParentType = checker.getTypeAtLocation(propertyAccessExpression.expression); + if (!localParentType) { + return undefined; + } + if (localParentType.symbol && localParentType.symbol.flags & (32 /* Class */ | 64 /* Interface */) && localParentType.symbol !== symbol.parent) { + return [localParentType.symbol]; + } + else if (localParentType.flags & 196608 /* UnionOrIntersection */) { + return getSymbolsForClassAndInterfaceComponents(localParentType); + } + } + })(Core = FindAllReferences.Core || (FindAllReferences.Core = {})); })(FindAllReferences = ts.FindAllReferences || (ts.FindAllReferences = {})); })(ts || (ts = {})); /* @internal */ @@ -73022,9 +76508,9 @@ var ts; // (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 === 70 /* Identifier */ && + if (node.kind === 71 /* Identifier */ && (node.parent === declaration || - (declaration.kind === 241 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 240 /* NamedImports */))) { + (declaration.kind === 242 /* ImportSpecifier */ && declaration.parent && declaration.parent.kind === 241 /* NamedImports */))) { symbol = typeChecker.getAliasedSymbol(symbol); } } @@ -73033,7 +76519,7 @@ var ts; // go to the declaration of the property name (in this case stay at the same position). However, if go-to-definition // is performed at the location of property access, we would like to go to definition of the property in the short-hand // assignment. This case and others are handled by the following code. - if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { + if (node.parent.kind === 262 /* ShorthandPropertyAssignment */) { var shorthandSymbol = typeChecker.getShorthandAssignmentValueSymbol(symbol.valueDeclaration); if (!shorthandSymbol) { return []; @@ -73093,13 +76579,13 @@ var ts; return undefined; } if (type.flags & 65536 /* Union */ && !(type.flags & 16 /* Enum */)) { - var result_5 = []; + var result_6 = []; ts.forEach(type.types, function (t) { if (t.symbol) { - ts.addRange(/*to*/ result_5, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); + ts.addRange(/*to*/ result_6, /*from*/ getDefinitionFromSymbol(typeChecker, t.symbol, node)); } }); - return result_5; + return result_6; } if (!type.symbol) { return undefined; @@ -73122,7 +76608,7 @@ var ts; function tryAddConstructSignature(symbol, location, symbolKind, symbolName, containerName, result) { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class - if (ts.isNewExpressionTarget(location) || location.kind === 122 /* ConstructorKeyword */) { + if (ts.isNewExpressionTarget(location) || location.kind === 123 /* ConstructorKeyword */) { if (symbol.flags & 32 /* Class */) { // Find the first class-like declaration and try to get the construct signature. for (var _i = 0, _a = symbol.getDeclarations(); _i < _a.length; _i++) { @@ -73144,11 +76630,14 @@ var ts; return false; } function tryAddSignature(signatureDeclarations, selectConstructors, symbolKind, symbolName, containerName, result) { + if (!signatureDeclarations) { + return false; + } var declarations = []; var definition; for (var _i = 0, signatureDeclarations_1 = signatureDeclarations; _i < signatureDeclarations_1.length; _i++) { var d = signatureDeclarations_1[_i]; - if (selectConstructors ? d.kind === 151 /* Constructor */ : isSignatureDeclaration(d)) { + if (selectConstructors ? d.kind === 152 /* Constructor */ : isSignatureDeclaration(d)) { declarations.push(d); if (d.body) definition = d; @@ -73163,10 +76652,10 @@ var ts; } function isSignatureDeclaration(node) { switch (node.kind) { - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: return true; default: return false; @@ -73243,40 +76732,6 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; -(function (ts) { - var GoToImplementation; - (function (GoToImplementation) { - function getImplementationAtPosition(typeChecker, cancellationToken, sourceFiles, node) { - // If invoked directly on a shorthand property assignment, then return - // the declaration of the symbol being assigned (not the symbol being assigned to). - if (node.parent.kind === 261 /* ShorthandPropertyAssignment */) { - var result = []; - ts.FindAllReferences.getReferenceEntriesForShorthandPropertyAssignment(node, typeChecker, result); - return result.length > 0 ? result : undefined; - } - else if (node.kind === 96 /* SuperKeyword */ || ts.isSuperProperty(node.parent)) { - // References to and accesses on the super keyword only have one possible implementation, so no - // need to "Find all References" - var symbol = typeChecker.getSymbolAtLocation(node); - return symbol.valueDeclaration && [ts.FindAllReferences.getReferenceEntryFromNode(symbol.valueDeclaration)]; - } - else { - // Perform "Find all References" and retrieve only those that are implementations - var referencedSymbols = ts.FindAllReferences.getReferencedSymbolsForNode(typeChecker, cancellationToken, node, sourceFiles, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false, /*implementations*/ true); - var result = ts.flatMap(referencedSymbols, function (symbol) { - return ts.map(symbol.references, function (_a) { - var textSpan = _a.textSpan, fileName = _a.fileName; - return ({ textSpan: textSpan, fileName: fileName }); - }); - }); - return result && result.length > 0 ? result : undefined; - } - } - GoToImplementation.getImplementationAtPosition = getImplementationAtPosition; - })(GoToImplementation = ts.GoToImplementation || (ts.GoToImplementation = {})); -})(ts || (ts = {})); -/* @internal */ -var ts; (function (ts) { var JsDoc; (function (JsDoc) { @@ -73322,7 +76777,8 @@ var ts; "prop", "version" ]; - var jsDocCompletionEntries; + var jsDocTagNameCompletionEntries; + var jsDocTagCompletionEntries; function getJsDocCommentsFromDeclarations(declarations) { // Only collect doc comments from duplicate declarations once: // In case of a union property there might be same declaration multiple times @@ -73349,6 +76805,30 @@ var ts; return documentationComment; } JsDoc.getJsDocCommentsFromDeclarations = getJsDocCommentsFromDeclarations; + function getJsDocTagsFromDeclarations(declarations) { + // Only collect doc comments from duplicate declarations once. + var tags = []; + forEachUnique(declarations, function (declaration) { + var jsDocs = ts.getJSDocs(declaration); + if (!jsDocs) { + return; + } + for (var _i = 0, jsDocs_1 = jsDocs; _i < jsDocs_1.length; _i++) { + var doc = jsDocs_1[_i]; + var tagsForDoc = doc.tags; + if (tagsForDoc) { + tags.push.apply(tags, tagsForDoc.filter(function (tag) { return tag.kind === 284 /* JSDocTag */; }).map(function (jsDocTag) { + return { + name: jsDocTag.tagName.text, + text: jsDocTag.comment + }; + })); + } + } + }); + return tags; + } + JsDoc.getJsDocTagsFromDeclarations = getJsDocTagsFromDeclarations; /** * Iterates through 'array' by index and performs the callback on each element of array until the callback * returns a truthy value, then returns that value. @@ -73367,8 +76847,8 @@ var ts; } return undefined; } - function getAllJsDocCompletionEntries() { - return jsDocCompletionEntries || (jsDocCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + function getJSDocTagNameCompletions() { + return jsDocTagNameCompletionEntries || (jsDocTagNameCompletionEntries = ts.map(jsDocTagNames, function (tagName) { return { name: tagName, kind: ts.ScriptElementKind.keyword, @@ -73377,7 +76857,18 @@ var ts; }; })); } - JsDoc.getAllJsDocCompletionEntries = getAllJsDocCompletionEntries; + JsDoc.getJSDocTagNameCompletions = getJSDocTagNameCompletions; + function getJSDocTagCompletions() { + return jsDocTagCompletionEntries || (jsDocTagCompletionEntries = ts.map(jsDocTagNames, function (tagName) { + return { + name: "@" + tagName, + kind: ts.ScriptElementKind.keyword, + kindModifiers: "", + sortText: "0" + }; + })); + } + JsDoc.getJSDocTagCompletions = getJSDocTagCompletions; /** * Checks if position points to a valid position to add JSDoc comments, and if so, * returns the appropriate template. Otherwise returns an empty string. @@ -73416,19 +76907,19 @@ var ts; var commentOwner; findOwner: for (commentOwner = tokenAtPos; commentOwner; commentOwner = commentOwner.parent) { switch (commentOwner.kind) { - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 151 /* Constructor */: - case 228 /* ClassDeclaration */: - case 207 /* VariableStatement */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: + case 229 /* ClassDeclaration */: + case 208 /* VariableStatement */: break findOwner; - case 264 /* SourceFile */: + case 265 /* SourceFile */: return undefined; - case 232 /* ModuleDeclaration */: + case 233 /* 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 === 232 /* ModuleDeclaration */) { + if (commentOwner.parent.kind === 233 /* ModuleDeclaration */) { return undefined; } break findOwner; @@ -73440,12 +76931,13 @@ var ts; var parameters = getParametersForJsDocOwningNode(commentOwner); var posLineAndChar = sourceFile.getLineAndCharacterOfPosition(position); var lineStart = sourceFile.getLineStarts()[posLineAndChar.line]; - var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character); + // replace non-whitespace characters in prefix with spaces. + var indentationStr = sourceFile.text.substr(lineStart, posLineAndChar.character).replace(/\S/i, function () { return " "; }); var isJavaScriptFile = ts.hasJavaScriptFileExtension(sourceFile.fileName); var docParams = ""; for (var i = 0; i < parameters.length; i++) { var currentName = parameters[i].name; - var paramName = currentName.kind === 70 /* Identifier */ ? + var paramName = currentName.kind === 71 /* Identifier */ ? currentName.text : "param" + i; if (isJavaScriptFile) { @@ -73475,7 +76967,7 @@ var ts; if (ts.isFunctionLike(commentOwner)) { return commentOwner.parameters; } - if (commentOwner.kind === 207 /* VariableStatement */) { + if (commentOwner.kind === 208 /* VariableStatement */) { var varStatement = commentOwner; var varDeclarations = varStatement.declarationList.declarations; if (varDeclarations.length === 1 && varDeclarations[0].initializer) { @@ -73493,17 +76985,17 @@ var ts; * @returns the parameters of a signature found on the RHS if one exists; otherwise 'emptyArray'. */ function getParametersFromRightHandSideOfAssignment(rightHandSide) { - while (rightHandSide.kind === 184 /* ParenthesizedExpression */) { + while (rightHandSide.kind === 185 /* ParenthesizedExpression */) { rightHandSide = rightHandSide.expression; } switch (rightHandSide.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return rightHandSide.parameters; - case 198 /* ClassExpression */: + case 199 /* ClassExpression */: for (var _i = 0, _a = rightHandSide.members; _i < _a.length; _i++) { var member = _a[_i]; - if (member.kind === 151 /* Constructor */) { + if (member.kind === 152 /* Constructor */) { return member.parameters; } } @@ -73523,8 +77015,6 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - ; - ; // A map of loose file names to library names // that we are confident require typings var safeList; @@ -73580,8 +77070,10 @@ var ts; getTypingNamesFromJson(packageJsonPath, filesToWatch); var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components"); + getTypingNamesFromPackagesFolder(bowerComponentsPath); var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); + getTypingNamesFromPackagesFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); // add typings for unresolved imports @@ -73673,20 +77165,22 @@ var ts; } } /** - * Infer typing names from node_module folder - * @param nodeModulesPath is the path to the "node_modules" folder + * Infer typing names from packages folder (ex: node_module, bower_components) + * @param packagesFolderPath is the path to the packages folder */ - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { + function getTypingNamesFromPackagesFolder(packagesFolderPath) { + filesToWatch.push(packagesFolderPath); // Todo: add support for ModuleResolutionHost too - if (!host.directoryExists(nodeModulesPath)) { + if (!host.directoryExists(packagesFolderPath)) { return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); + var fileNames = host.readDirectory(packagesFolderPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + var baseFileName = ts.getBaseFileName(normalizedFileName); + if (baseFileName !== "package.json" && baseFileName !== "bower.json") { continue; } var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); @@ -73697,7 +77191,7 @@ var ts; // npm 3's package.json contains a "_requiredBy" field // we should include all the top level module names for npm 2, and only module names whose // "_requiredBy" field starts with "#" or equals "/" for npm 3. - if (packageJson._requiredBy && + if (baseFileName === "package.json" && packageJson._requiredBy && ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { continue; } @@ -73763,14 +77257,14 @@ var ts; }); }; // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[] - for (var _i = 0, sourceFiles_8 = sourceFiles; _i < sourceFiles_8.length; _i++) { - var sourceFile = sourceFiles_8[_i]; + for (var _i = 0, sourceFiles_7 = sourceFiles; _i < sourceFiles_7.length; _i++) { + var sourceFile = sourceFiles_7[_i]; _loop_4(sourceFile); } // Remove imports when the imported declaration is already in the list and has the same name. rawItems = ts.filter(rawItems, function (item) { var decl = item.declaration; - if (decl.kind === 238 /* ImportClause */ || decl.kind === 241 /* ImportSpecifier */ || decl.kind === 236 /* ImportEqualsDeclaration */) { + if (decl.kind === 239 /* ImportClause */ || decl.kind === 242 /* ImportSpecifier */ || decl.kind === 237 /* ImportEqualsDeclaration */) { var importer = checker.getSymbolAtLocation(decl.name); var imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; @@ -73798,7 +77292,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 /* Identifier */ || + if (node.kind === 71 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -73812,7 +77306,7 @@ var ts; if (text !== undefined) { containers.unshift(text); } - else if (declaration.name.kind === 143 /* ComputedPropertyName */) { + else if (declaration.name.kind === 144 /* ComputedPropertyName */) { return tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ true); } else { @@ -73833,7 +77327,7 @@ var ts; } return true; } - if (expression.kind === 178 /* PropertyAccessExpression */) { + if (expression.kind === 179 /* PropertyAccessExpression */) { var propertyAccess = expression; if (includeLastPortion) { containers.unshift(propertyAccess.name.text); @@ -73846,7 +77340,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 === 143 /* ComputedPropertyName */) { + if (declaration.name.kind === 144 /* ComputedPropertyName */) { if (!tryAddComputedPropertyName(declaration.name.expression, containers, /*includeLastPortion*/ false)) { return undefined; } @@ -73908,22 +77402,61 @@ var ts; (function (ts) { var NavigationBar; (function (NavigationBar) { - function getNavigationBarItems(sourceFile) { + /** + * Matches all whitespace characters in a string. Eg: + * + * "app. + * + * onactivated" + * + * matches because of the newline, whereas + * + * "app.onactivated" + * + * does not match. + */ + var whiteSpaceRegex = /\s+/g; + // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. + var curCancellationToken; + var curSourceFile; + /** + * For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. + * `parent` is the current parent and is *not* stored in parentsStack. + * `startNode` sets a new parent and `endNode` returns to the previous parent. + */ + var parentsStack = []; + var parent; + // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. + var emptyChildItemArray = []; + function getNavigationBarItems(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); - curSourceFile = undefined; - return result; + try { + return ts.map(topLevelItems(rootNavigationBarNode(sourceFile)), convertToTopLevelItem); + } + finally { + reset(); + } } NavigationBar.getNavigationBarItems = getNavigationBarItems; - function getNavigationTree(sourceFile) { + function getNavigationTree(sourceFile, cancellationToken) { + curCancellationToken = cancellationToken; curSourceFile = sourceFile; - var result = convertToTree(rootNavigationBarNode(sourceFile)); - curSourceFile = undefined; - return result; + try { + return convertToTree(rootNavigationBarNode(sourceFile)); + } + finally { + reset(); + } } NavigationBar.getNavigationTree = getNavigationTree; - // Keep sourceFile handy so we don't have to search for it every time we need to call `getText`. - var curSourceFile; + function reset() { + curSourceFile = undefined; + curCancellationToken = undefined; + parentsStack = []; + parent = undefined; + emptyChildItemArray = []; + } function nodeText(node) { return node.getText(curSourceFile); } @@ -73938,13 +77471,6 @@ var ts; parent.children = [child]; } } - /* - For performance, we keep navigation bar parents on a stack rather than passing them through each recursion. - `parent` is the current parent and is *not* stored in parentsStack. - `startNode` sets a new parent and `endNode` returns to the previous parent. - */ - var parentsStack = []; - var parent; function rootNavigationBarNode(sourceFile) { ts.Debug.assert(!parentsStack.length); var root = { node: sourceFile, additionalNodes: undefined, parent: undefined, children: undefined, indent: 0 }; @@ -73995,11 +77521,12 @@ var ts; } /** Look for navigation bar items in node's subtree, adding them to the current `parent`. */ function addChildrenRecursively(node) { + curCancellationToken.throwIfCancellationRequested(); if (!node || ts.isToken(node)) { return; } switch (node.kind) { - case 151 /* Constructor */: + case 152 /* Constructor */: // Get parameter properties, and treat them as being on the *same* level as the constructor, not under it. var ctr = node; addNodeWithRecursiveChild(ctr, ctr.body); @@ -74011,21 +77538,21 @@ var ts; } } break; - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 149 /* MethodSignature */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 150 /* MethodSignature */: if (!ts.hasDynamicName(node)) { addNodeWithRecursiveChild(node, node.body); } break; - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: if (!ts.hasDynamicName(node)) { addLeafNode(node); } break; - case 238 /* ImportClause */: + case 239 /* ImportClause */: var importClause = node; // Handle default import case e.g.: // import d from "mod"; @@ -74037,7 +77564,7 @@ var ts; // import {a, b as B} from "mod"; var namedBindings = importClause.namedBindings; if (namedBindings) { - if (namedBindings.kind === 239 /* NamespaceImport */) { + if (namedBindings.kind === 240 /* NamespaceImport */) { addLeafNode(namedBindings); } else { @@ -74048,8 +77575,8 @@ var ts; } } break; - case 175 /* BindingElement */: - case 225 /* VariableDeclaration */: + case 176 /* BindingElement */: + case 226 /* VariableDeclaration */: var decl = node; var name = decl.name; if (ts.isBindingPattern(name)) { @@ -74063,12 +77590,12 @@ var ts; addNodeWithRecursiveChild(decl, decl.initializer); } break; - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: addNodeWithRecursiveChild(node, node.body); break; - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: startNode(node); for (var _d = 0, _e = node.members; _d < _e.length; _d++) { var member = _e[_d]; @@ -74078,9 +77605,9 @@ var ts; } endNode(); break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: startNode(node); for (var _f = 0, _g = node.members; _f < _g.length; _f++) { var member = _g[_f]; @@ -74088,21 +77615,21 @@ var ts; } endNode(); break; - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: addNodeWithRecursiveChild(node, getInteriorModule(node).body); break; - case 245 /* ExportSpecifier */: - case 236 /* ImportEqualsDeclaration */: - case 156 /* IndexSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 230 /* TypeAliasDeclaration */: + case 246 /* ExportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 157 /* IndexSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 231 /* TypeAliasDeclaration */: addLeafNode(node); break; default: ts.forEach(node.jsDoc, function (jsDoc) { ts.forEach(jsDoc.tags, function (tag) { - if (tag.kind === 289 /* JSDocTypedefTag */) { + if (tag.kind === 290 /* JSDocTypedefTag */) { addLeafNode(tag); } }); @@ -74153,14 +77680,14 @@ var ts; }); /** a and b have the same name, but they may not be mergeable. */ function shouldReallyMerge(a, b) { - return a.kind === b.kind && (a.kind !== 232 /* ModuleDeclaration */ || areSameModule(a, b)); + return a.kind === b.kind && (a.kind !== 233 /* ModuleDeclaration */ || areSameModule(a, b)); // We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes. // Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'! function areSameModule(a, b) { if (a.body.kind !== b.body.kind) { return false; } - if (a.body.kind !== 232 /* ModuleDeclaration */) { + if (a.body.kind !== 233 /* ModuleDeclaration */) { return true; } return areSameModule(a.body, b.body); @@ -74201,7 +77728,7 @@ var ts; * So `new()` can still come before an `aardvark` method. */ function tryGetName(node) { - if (node.kind === 232 /* ModuleDeclaration */) { + if (node.kind === 233 /* ModuleDeclaration */) { return getModuleName(node); } var decl = node; @@ -74209,18 +77736,18 @@ var ts; return ts.getPropertyNameForPropertyNameNode(decl.name); } switch (node.kind) { - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 198 /* ClassExpression */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 199 /* ClassExpression */: return getFunctionOrClassName(node); - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return undefined; } } function getItemName(node) { - if (node.kind === 232 /* ModuleDeclaration */) { + if (node.kind === 233 /* ModuleDeclaration */) { return getModuleName(node); } var name = node.name; @@ -74231,16 +77758,16 @@ var ts; } } switch (node.kind) { - case 264 /* SourceFile */: + case 265 /* SourceFile */: var sourceFile = node; return ts.isExternalModule(sourceFile) ? "\"" + ts.escapeString(ts.getBaseFileName(ts.removeFileExtension(ts.normalizePath(sourceFile.fileName)))) + "\"" : ""; - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: if (ts.getModifierFlags(node) & 512 /* Default */) { return "default"; } @@ -74248,15 +77775,15 @@ var ts; // (eg: "app\n.onactivated"), so we should remove the whitespace for readabiltiy in the // navigation bar. return getFunctionOrClassName(node); - case 151 /* Constructor */: + case 152 /* Constructor */: return "constructor"; - case 155 /* ConstructSignature */: + case 156 /* ConstructSignature */: return "new()"; - case 154 /* CallSignature */: + case 155 /* CallSignature */: return "()"; - case 156 /* IndexSignature */: + case 157 /* IndexSignature */: return "[]"; - case 289 /* JSDocTypedefTag */: + case 290 /* JSDocTypedefTag */: return getJSDocTypedefTagName(node); default: return ""; @@ -74268,10 +77795,10 @@ var ts; } else { var parentNode = node.parent && node.parent.parent; - if (parentNode && parentNode.kind === 207 /* VariableStatement */) { + if (parentNode && parentNode.kind === 208 /* VariableStatement */) { if (parentNode.declarationList.declarations.length > 0) { var nameIdentifier = parentNode.declarationList.declarations[0].name; - if (nameIdentifier.kind === 70 /* Identifier */) { + if (nameIdentifier.kind === 71 /* Identifier */) { return nameIdentifier.text; } } @@ -74297,24 +77824,24 @@ var ts; return topLevel; function isTopLevel(item) { switch (navigationBarNodeKind(item)) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 231 /* EnumDeclaration */: - case 229 /* InterfaceDeclaration */: - case 232 /* ModuleDeclaration */: - case 264 /* SourceFile */: - case 230 /* TypeAliasDeclaration */: - case 289 /* JSDocTypedefTag */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 232 /* EnumDeclaration */: + case 230 /* InterfaceDeclaration */: + case 233 /* ModuleDeclaration */: + case 265 /* SourceFile */: + case 231 /* TypeAliasDeclaration */: + case 290 /* JSDocTypedefTag */: return true; - case 151 /* Constructor */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 225 /* VariableDeclaration */: + case 152 /* Constructor */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 226 /* VariableDeclaration */: return hasSomeImportantChild(item); - case 186 /* ArrowFunction */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: return isTopLevelFunctionDeclaration(item); default: return false; @@ -74324,10 +77851,10 @@ var ts; return false; } switch (navigationBarNodeKind(item.parent)) { - case 233 /* ModuleBlock */: - case 264 /* SourceFile */: - case 150 /* MethodDeclaration */: - case 151 /* Constructor */: + case 234 /* ModuleBlock */: + case 265 /* SourceFile */: + case 151 /* MethodDeclaration */: + case 152 /* Constructor */: return true; default: return hasSomeImportantChild(item); @@ -74336,13 +77863,11 @@ var ts; function hasSomeImportantChild(item) { return ts.forEach(item.children, function (child) { var childKind = navigationBarNodeKind(child); - return childKind !== 225 /* VariableDeclaration */ && childKind !== 175 /* BindingElement */; + return childKind !== 226 /* VariableDeclaration */ && childKind !== 176 /* BindingElement */; }); } } } - // NavigationBarItem requires an array, but will not mutate it, so just give it this for performance. - var emptyChildItemArray = []; function convertToTree(n) { return { text: getItemName(n.node), @@ -74394,7 +77919,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 === 232 /* ModuleDeclaration */) { + while (moduleDeclaration.body && moduleDeclaration.body.kind === 233 /* ModuleDeclaration */) { moduleDeclaration = moduleDeclaration.body; result.push(moduleDeclaration.name.text); } @@ -74405,18 +77930,18 @@ var ts; * We store 'A' as associated with a NavNode, and use getModuleName to traverse down again. */ function getInteriorModule(decl) { - return decl.body.kind === 232 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; + return decl.body.kind === 233 /* ModuleDeclaration */ ? getInteriorModule(decl.body) : decl; } function isComputedProperty(member) { - return !member.name || member.name.kind === 143 /* ComputedPropertyName */; + return !member.name || member.name.kind === 144 /* ComputedPropertyName */; } function getNodeSpan(node) { - return node.kind === 264 /* SourceFile */ + return node.kind === 265 /* SourceFile */ ? ts.createTextSpanFromBounds(node.getFullStart(), node.getEnd()) : ts.createTextSpanFromNode(node, curSourceFile); } function getModifiers(node) { - if (node.parent && node.parent.kind === 225 /* VariableDeclaration */) { + if (node.parent && node.parent.kind === 226 /* VariableDeclaration */) { node = node.parent; } return ts.getNodeModifiers(node); @@ -74425,14 +77950,14 @@ var ts; if (node.name && ts.getFullWidth(node.name) > 0) { return ts.declarationNameToString(node.name); } - else if (node.parent.kind === 225 /* VariableDeclaration */) { + else if (node.parent.kind === 226 /* VariableDeclaration */) { return ts.declarationNameToString(node.parent.name); } - else if (node.parent.kind === 193 /* BinaryExpression */ && - node.parent.operatorToken.kind === 57 /* EqualsToken */) { + else if (node.parent.kind === 194 /* BinaryExpression */ && + node.parent.operatorToken.kind === 58 /* EqualsToken */) { return nodeText(node.parent.left).replace(whiteSpaceRegex, ""); } - else if (node.parent.kind === 260 /* PropertyAssignment */ && node.parent.name) { + else if (node.parent.kind === 261 /* PropertyAssignment */ && node.parent.name) { return nodeText(node.parent.name); } else if (ts.getModifierFlags(node) & 512 /* Default */) { @@ -74443,22 +77968,8 @@ var ts; } } function isFunctionOrClassExpression(node) { - return node.kind === 185 /* FunctionExpression */ || node.kind === 186 /* ArrowFunction */ || node.kind === 198 /* ClassExpression */; + return node.kind === 186 /* FunctionExpression */ || node.kind === 187 /* ArrowFunction */ || node.kind === 199 /* ClassExpression */; } - /** - * Matches all whitespace characters in a string. Eg: - * - * "app. - * - * onactivated" - * - * matches because of the newline, whereas - * - * "app.onactivated" - * - * does not match. - */ - var whiteSpaceRegex = /\s+/g; })(NavigationBar = ts.NavigationBar || (ts.NavigationBar = {})); })(ts || (ts = {})); /* @internal */ @@ -74466,29 +77977,29 @@ var ts; (function (ts) { var OutliningElementsCollector; (function (OutliningElementsCollector) { - function collectElements(sourceFile) { + function collectElements(sourceFile, cancellationToken) { var elements = []; var collapseText = "..."; function addOutliningSpan(hintSpanNode, startElement, endElement, autoCollapse) { if (hintSpanNode && startElement && endElement) { - var span_12 = { + var span_13 = { textSpan: ts.createTextSpanFromBounds(startElement.pos, endElement.end), hintSpan: ts.createTextSpanFromNode(hintSpanNode, sourceFile), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_12); + elements.push(span_13); } } function addOutliningSpanComments(commentSpan, autoCollapse) { if (commentSpan) { - var span_13 = { + var span_14 = { textSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), hintSpan: ts.createTextSpanFromBounds(commentSpan.pos, commentSpan.end), bannerText: collapseText, autoCollapse: autoCollapse }; - elements.push(span_13); + elements.push(span_14); } } function addOutliningForLeadingCommentsForNode(n) { @@ -74500,6 +78011,7 @@ var ts; var singleLineCommentCount = 0; for (var _i = 0, comments_4 = comments; _i < comments_4.length; _i++) { var currentComment = comments_4[_i]; + cancellationToken.throwIfCancellationRequested(); // For single line comments, combine consecutive ones (2 or more) into // a single span from the start of the first till the end of the last if (currentComment.kind === 2 /* SingleLineCommentTrivia */) { @@ -74525,19 +78037,20 @@ var ts; // Only outline spans of two or more consecutive single line comments if (count > 1) { var multipleSingleLineComments = { + kind: 2 /* SingleLineCommentTrivia */, pos: start, end: end, - kind: 2 /* SingleLineCommentTrivia */ }; addOutliningSpanComments(multipleSingleLineComments, /*autoCollapse*/ false); } } function autoCollapse(node) { - return ts.isFunctionBlock(node) && node.parent.kind !== 186 /* ArrowFunction */; + return ts.isFunctionBlock(node) && node.parent.kind !== 187 /* ArrowFunction */; } var depth = 0; var maxDepth = 20; function walk(n) { + cancellationToken.throwIfCancellationRequested(); if (depth > maxDepth) { return; } @@ -74545,26 +78058,26 @@ var ts; addOutliningForLeadingCommentsForNode(n); } switch (n.kind) { - case 206 /* Block */: + case 207 /* Block */: if (!ts.isFunctionBlock(n)) { var parent = n.parent; - var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); // Check if the block is standalone, or 'attached' to some parent statement. // If the latter, we want to collapse the block, but consider its hint span // to be the entire span of the parent. - if (parent.kind === 211 /* DoStatement */ || - parent.kind === 214 /* ForInStatement */ || - parent.kind === 215 /* ForOfStatement */ || - parent.kind === 213 /* ForStatement */ || - parent.kind === 210 /* IfStatement */ || - parent.kind === 212 /* WhileStatement */ || - parent.kind === 219 /* WithStatement */ || - parent.kind === 259 /* CatchClause */) { + if (parent.kind === 212 /* DoStatement */ || + parent.kind === 215 /* ForInStatement */ || + parent.kind === 216 /* ForOfStatement */ || + parent.kind === 214 /* ForStatement */ || + parent.kind === 211 /* IfStatement */ || + parent.kind === 213 /* WhileStatement */ || + parent.kind === 220 /* WithStatement */ || + parent.kind === 260 /* CatchClause */) { addOutliningSpan(parent, openBrace, closeBrace, autoCollapse(n)); break; } - if (parent.kind === 223 /* TryStatement */) { + if (parent.kind === 224 /* TryStatement */) { // Could be the try-block, or the finally-block. var tryStatement = parent; if (tryStatement.tryBlock === n) { @@ -74572,7 +78085,7 @@ var ts; break; } else if (tryStatement.finallyBlock === n) { - var finallyKeyword = ts.findChildOfKind(tryStatement, 86 /* FinallyKeyword */, sourceFile); + var finallyKeyword = ts.findChildOfKind(tryStatement, 87 /* FinallyKeyword */, sourceFile); if (finallyKeyword) { addOutliningSpan(finallyKeyword, openBrace, closeBrace, autoCollapse(n)); break; @@ -74582,35 +78095,35 @@ var ts; } // Block was a standalone block. In this case we want to only collapse // the span of the block, independent of any parent span. - var span_14 = ts.createTextSpanFromNode(n); + var span_15 = ts.createTextSpanFromNode(n); elements.push({ - textSpan: span_14, - hintSpan: span_14, + textSpan: span_15, + hintSpan: span_15, bannerText: collapseText, autoCollapse: autoCollapse(n) }); break; } - // Fallthrough. - case 233 /* ModuleBlock */: { - var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); + // falls through + case 234 /* ModuleBlock */: { + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); addOutliningSpan(n.parent, openBrace, closeBrace, autoCollapse(n)); break; } - case 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 177 /* ObjectLiteralExpression */: - case 234 /* CaseBlock */: { - var openBrace = ts.findChildOfKind(n, 16 /* OpenBraceToken */, sourceFile); - var closeBrace = ts.findChildOfKind(n, 17 /* CloseBraceToken */, sourceFile); + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 178 /* ObjectLiteralExpression */: + case 235 /* CaseBlock */: { + var openBrace = ts.findChildOfKind(n, 17 /* OpenBraceToken */, sourceFile); + var closeBrace = ts.findChildOfKind(n, 18 /* CloseBraceToken */, sourceFile); addOutliningSpan(n, openBrace, closeBrace, autoCollapse(n)); break; } - case 176 /* ArrayLiteralExpression */: - var openBracket = ts.findChildOfKind(n, 20 /* OpenBracketToken */, sourceFile); - var closeBracket = ts.findChildOfKind(n, 21 /* CloseBracketToken */, sourceFile); + case 177 /* ArrayLiteralExpression */: + var openBracket = ts.findChildOfKind(n, 21 /* OpenBracketToken */, sourceFile); + var closeBracket = ts.findChildOfKind(n, 22 /* CloseBracketToken */, sourceFile); addOutliningSpan(n, openBracket, closeBracket, autoCollapse(n)); break; } @@ -74736,10 +78249,10 @@ var ts; // But we would match 'FooAttribute' (since 'Attribute' starts with 'a'). var wordSpans = getWordSpans(candidate); for (var _i = 0, wordSpans_1 = wordSpans; _i < wordSpans_1.length; _i++) { - var span_15 = wordSpans_1[_i]; - if (partStartsWith(candidate, span_15, chunk.text, /*ignoreCase:*/ true)) { + var span_16 = wordSpans_1[_i]; + if (partStartsWith(candidate, span_16, chunk.text, /*ignoreCase:*/ true)) { return createPatternMatch(PatternMatchKind.substring, punctuationStripped, - /*isCaseSensitive:*/ partStartsWith(candidate, span_15, chunk.text, /*ignoreCase:*/ false)); + /*isCaseSensitive:*/ partStartsWith(candidate, span_16, chunk.text, /*ignoreCase:*/ false)); } } } @@ -75201,10 +78714,10 @@ var ts; var externalModule = false; function nextToken() { var token = ts.scanner.scan(); - if (token === 16 /* OpenBraceToken */) { + if (token === 17 /* OpenBraceToken */) { braceNesting++; } - else if (token === 17 /* CloseBraceToken */) { + else if (token === 18 /* CloseBraceToken */) { braceNesting--; } return token; @@ -75255,10 +78768,10 @@ var ts; */ function tryConsumeDeclare() { var token = ts.scanner.getToken(); - if (token === 123 /* DeclareKeyword */) { + if (token === 124 /* DeclareKeyword */) { // declare module "mod" token = nextToken(); - if (token === 127 /* ModuleKeyword */) { + if (token === 128 /* ModuleKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { recordAmbientExternalModule(); @@ -75273,7 +78786,7 @@ var ts; */ function tryConsumeImport() { var token = ts.scanner.getToken(); - if (token === 90 /* ImportKeyword */) { + if (token === 91 /* ImportKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import "mod"; @@ -75281,9 +78794,9 @@ var ts; return true; } else { - if (token === 70 /* Identifier */ || ts.isKeyword(token)) { + if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import d from "mod"; @@ -75291,12 +78804,12 @@ var ts; return true; } } - else if (token === 57 /* EqualsToken */) { + else if (token === 58 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } } - else if (token === 25 /* CommaToken */) { + else if (token === 26 /* CommaToken */) { // consume comma and keep going token = nextToken(); } @@ -75305,16 +78818,16 @@ var ts; return true; } } - if (token === 16 /* OpenBraceToken */) { + if (token === 17 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure that it stops on EOF - while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 17 /* CloseBraceToken */) { + if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import {a as A} from "mod"; @@ -75324,13 +78837,13 @@ var ts; } } } - else if (token === 38 /* AsteriskToken */) { + else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 117 /* AsKeyword */) { + if (token === 118 /* AsKeyword */) { token = nextToken(); - if (token === 70 /* Identifier */ || ts.isKeyword(token)) { + if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // import * as NS from "mod" @@ -75348,19 +78861,19 @@ var ts; } function tryConsumeExport() { var token = ts.scanner.getToken(); - if (token === 83 /* ExportKeyword */) { + if (token === 84 /* ExportKeyword */) { markAsExternalModuleIfTopLevel(); token = nextToken(); - if (token === 16 /* OpenBraceToken */) { + if (token === 17 /* OpenBraceToken */) { token = nextToken(); // consume "{ a as B, c, d as D}" clauses // make sure it stops on EOF - while (token !== 17 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 18 /* CloseBraceToken */ && token !== 1 /* EndOfFileToken */) { token = nextToken(); } - if (token === 17 /* CloseBraceToken */) { + if (token === 18 /* CloseBraceToken */) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export {a as A} from "mod"; @@ -75370,9 +78883,9 @@ var ts; } } } - else if (token === 38 /* AsteriskToken */) { + else if (token === 39 /* AsteriskToken */) { token = nextToken(); - if (token === 139 /* FromKeyword */) { + if (token === 140 /* FromKeyword */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // export * from "mod" @@ -75380,11 +78893,11 @@ var ts; } } } - else if (token === 90 /* ImportKeyword */) { + else if (token === 91 /* ImportKeyword */) { token = nextToken(); - if (token === 70 /* Identifier */ || ts.isKeyword(token)) { + if (token === 71 /* Identifier */ || ts.isKeyword(token)) { token = nextToken(); - if (token === 57 /* EqualsToken */) { + if (token === 58 /* EqualsToken */) { if (tryConsumeRequireCall(/*skipCurrentToken*/ true)) { return true; } @@ -75397,9 +78910,9 @@ var ts; } function tryConsumeRequireCall(skipCurrentToken) { var token = skipCurrentToken ? nextToken() : ts.scanner.getToken(); - if (token === 131 /* RequireKeyword */) { + if (token === 132 /* RequireKeyword */) { token = nextToken(); - if (token === 18 /* OpenParenToken */) { + if (token === 19 /* OpenParenToken */) { token = nextToken(); if (token === 9 /* StringLiteral */) { // require("mod"); @@ -75412,16 +78925,16 @@ var ts; } function tryConsumeDefine() { var token = ts.scanner.getToken(); - if (token === 70 /* Identifier */ && ts.scanner.getTokenValue() === "define") { + if (token === 71 /* Identifier */ && ts.scanner.getTokenValue() === "define") { token = nextToken(); - if (token !== 18 /* OpenParenToken */) { + if (token !== 19 /* OpenParenToken */) { return true; } token = nextToken(); if (token === 9 /* StringLiteral */) { // looks like define ("modname", ... - skip string literal and comma token = nextToken(); - if (token === 25 /* CommaToken */) { + if (token === 26 /* CommaToken */) { token = nextToken(); } else { @@ -75430,14 +78943,14 @@ var ts; } } // should be start of dependency list - if (token !== 20 /* OpenBracketToken */) { + if (token !== 21 /* OpenBracketToken */) { return true; } // skip open bracket token = nextToken(); var i = 0; // scan until ']' or EOF - while (token !== 21 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { + while (token !== 22 /* CloseBracketToken */ && token !== 1 /* EndOfFileToken */) { // record string literals as module names if (token === 9 /* StringLiteral */) { recordModuleName(); @@ -75550,20 +79063,23 @@ var ts; if (ts.some(declarations, isDefinedInLibraryFile)) { return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + // Cannot rename `default` as in `import { default as foo } from "./someModule"; + if (node.kind === 71 /* Identifier */ && + node.originalKeywordKind === 79 /* DefaultKeyword */ && + symbol.parent.flags & 1536 /* Module */) { + return undefined; + } var displayName = ts.stripQuotes(ts.getDeclaredName(typeChecker, symbol, node)); var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node); return kind ? getRenameInfoSuccess(displayName, typeChecker.getFullyQualifiedName(symbol), kind, ts.SymbolDisplay.getSymbolModifiers(symbol), node, sourceFile) : undefined; } } else if (node.kind === 9 /* StringLiteral */) { - var type = ts.getStringLiteralTypeForNode(node, typeChecker); - if (type) { - if (isDefinedInLibraryFile(node)) { - return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); - } - var displayName = ts.stripQuotes(type.text); - return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); + if (isDefinedInLibraryFile(node)) { + return getRenameInfoError(ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library); } + var displayName = ts.stripQuotes(node.text); + return getRenameInfoSuccess(displayName, displayName, ts.ScriptElementKind.variableElement, ts.ScriptElementKindModifier.none, node, sourceFile); } } function getRenameInfoSuccess(displayName, fullDisplayName, kind, kindModifiers, node, sourceFile) { @@ -75599,7 +79115,8 @@ var ts; return ts.createTextSpan(start, width); } function nodeIsEligibleForRename(node) { - return node.kind === 70 /* Identifier */ || node.kind === 9 /* StringLiteral */ || + return node.kind === 71 /* Identifier */ || + node.kind === 9 /* StringLiteral */ || ts.isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || ts.isThis(node); } @@ -75657,7 +79174,7 @@ var ts; // stack++; // break; // case TypeScript.SyntaxKind.CommaToken: - // if (stack == 0) { + // if (stack === 0) { // argumentIndex++; // } // break; @@ -75781,15 +79298,15 @@ var ts; } SignatureHelp.getSignatureHelpItems = getSignatureHelpItems; function createJavaScriptSignatureHelpItems(argumentInfo, program) { - if (argumentInfo.invocation.kind !== 180 /* CallExpression */) { + if (argumentInfo.invocation.kind !== 181 /* CallExpression */) { return undefined; } // See if we can find some symbol with the call expression name that has call signatures. var callExpression = argumentInfo.invocation; var expression = callExpression.expression; - var name = expression.kind === 70 /* Identifier */ + var name = expression.kind === 71 /* Identifier */ ? expression - : expression.kind === 178 /* PropertyAccessExpression */ + : expression.kind === 179 /* PropertyAccessExpression */ ? expression.name : undefined; if (!name || !name.text) { @@ -75822,7 +79339,7 @@ var ts; * in the argument of an invocation; returns undefined otherwise. */ function getImmediatelyContainingArgumentInfo(node, position, sourceFile) { - if (node.parent.kind === 180 /* CallExpression */ || node.parent.kind === 181 /* NewExpression */) { + if (node.parent.kind === 181 /* CallExpression */ || node.parent.kind === 182 /* NewExpression */) { var callExpression = node.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a signature help session @@ -75838,8 +79355,8 @@ var ts; // Case 3: // foo(a#, #b#) -> The token is buried inside a list, and should give signature help // Find out if 'node' is an argument, a type argument, or neither - if (node.kind === 26 /* LessThanToken */ || - node.kind === 18 /* OpenParenToken */) { + if (node.kind === 27 /* LessThanToken */ || + node.kind === 19 /* OpenParenToken */) { // Find the list that starts right *after* the < or ( token. // If the user has just opened a list, consider this item 0. var list = getChildListThatStartsWithOpenerToken(callExpression, node, sourceFile); @@ -75876,27 +79393,27 @@ var ts; } return undefined; } - else if (node.kind === 12 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 182 /* TaggedTemplateExpression */) { + else if (node.kind === 13 /* NoSubstitutionTemplateLiteral */ && node.parent.kind === 183 /* 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, sourceFile); } } - else if (node.kind === 13 /* TemplateHead */ && node.parent.parent.kind === 182 /* TaggedTemplateExpression */) { + else if (node.kind === 14 /* TemplateHead */ && node.parent.parent.kind === 183 /* TaggedTemplateExpression */) { var templateExpression = node.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 196 /* TemplateExpression */); var argumentIndex = ts.isInsideTemplateLiteral(node, position) ? 0 : 1; return getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile); } - else if (node.parent.kind === 204 /* TemplateSpan */ && node.parent.parent.parent.kind === 182 /* TaggedTemplateExpression */) { + else if (node.parent.kind === 205 /* TemplateSpan */ && node.parent.parent.parent.kind === 183 /* TaggedTemplateExpression */) { var templateSpan = node.parent; var templateExpression = templateSpan.parent; var tagExpression = templateExpression.parent; - ts.Debug.assert(templateExpression.kind === 195 /* TemplateExpression */); + ts.Debug.assert(templateExpression.kind === 196 /* TemplateExpression */); // If we're just after a template tail, don't show signature help. - if (node.kind === 15 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { + if (node.kind === 16 /* TemplateTail */ && !ts.isInsideTemplateLiteral(node, position)) { return undefined; } var spanIndex = templateExpression.templateSpans.indexOf(templateSpan); @@ -75941,7 +79458,7 @@ var ts; if (child === node) { break; } - if (child.kind !== 25 /* CommaToken */) { + if (child.kind !== 26 /* CommaToken */) { argumentIndex++; } } @@ -75960,8 +79477,8 @@ var ts; // That will give us 2 non-commas. We then add one for the last comma, giving us an // arg count of 3. var listChildren = argumentsList.getChildren(); - var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 25 /* CommaToken */; }); - if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 25 /* CommaToken */) { + var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 26 /* CommaToken */; }); + if (listChildren.length > 0 && ts.lastOrUndefined(listChildren).kind === 26 /* CommaToken */) { argumentCount++; } return argumentCount; @@ -75991,7 +79508,7 @@ var ts; } function getArgumentListInfoForTemplate(tagExpression, argumentIndex, sourceFile) { // argumentCount is either 1 or (numSpans + 1) to account for the template strings array argument. - var argumentCount = tagExpression.template.kind === 12 /* NoSubstitutionTemplateLiteral */ + var argumentCount = tagExpression.template.kind === 13 /* NoSubstitutionTemplateLiteral */ ? 1 : tagExpression.template.templateSpans.length + 1; ts.Debug.assert(argumentIndex === 0 || argumentIndex < argumentCount, "argumentCount < argumentIndex, " + argumentCount + " < " + argumentIndex); @@ -76029,7 +79546,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 === 195 /* TemplateExpression */) { + if (template.kind === 196 /* TemplateExpression */) { var lastSpan = ts.lastOrUndefined(template.templateSpans); if (lastSpan.literal.getFullWidth() === 0) { applicableSpanEnd = ts.skipTrivia(sourceFile.text, applicableSpanEnd, /*stopAfterLineBreak*/ false); @@ -76038,7 +79555,7 @@ var ts; return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart); } function getContainingArgumentInfo(node, position, sourceFile) { - for (var n = node; n.kind !== 264 /* SourceFile */; n = n.parent) { + for (var n = node; n.kind !== 265 /* SourceFile */; n = n.parent) { if (ts.isFunctionBlock(n)) { return undefined; } @@ -76102,10 +79619,10 @@ var ts; var isVariadic; if (isTypeParameterList) { isVariadic = false; // type parameter lists are not variadic - prefixDisplayParts.push(ts.punctuationPart(26 /* LessThanToken */)); + prefixDisplayParts.push(ts.punctuationPart(27 /* LessThanToken */)); var typeParameters = candidateSignature.typeParameters; signatureHelpParameters = typeParameters && typeParameters.length > 0 ? ts.map(typeParameters, createSignatureHelpParameterForTypeParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(28 /* GreaterThanToken */)); + suffixDisplayParts.push(ts.punctuationPart(29 /* GreaterThanToken */)); var parameterParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildDisplayForParametersAndDelimiters(candidateSignature.thisParameter, candidateSignature.parameters, writer, invocation); }); @@ -76117,10 +79634,10 @@ var ts; return typeChecker.getSymbolDisplayBuilder().buildDisplayForTypeParametersAndDelimiters(candidateSignature.typeParameters, writer, invocation); }); ts.addRange(prefixDisplayParts, typeParameterParts); - prefixDisplayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + prefixDisplayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); var parameters = candidateSignature.parameters; signatureHelpParameters = parameters.length > 0 ? ts.map(parameters, createSignatureHelpParameterForParameter) : emptyArray; - suffixDisplayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + suffixDisplayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); } var returnTypeParts = ts.mapToDisplayParts(function (writer) { return typeChecker.getSymbolDisplayBuilder().buildReturnTypeDisplay(candidateSignature, writer, invocation); @@ -76130,9 +79647,10 @@ var ts; isVariadic: isVariadic, prefixDisplayParts: prefixDisplayParts, suffixDisplayParts: suffixDisplayParts, - separatorDisplayParts: [ts.punctuationPart(25 /* CommaToken */), ts.spacePart()], + separatorDisplayParts: [ts.punctuationPart(26 /* CommaToken */), ts.spacePart()], parameters: signatureHelpParameters, - documentation: candidateSignature.getDocumentationComment() + documentation: candidateSignature.getDocumentationComment(), + tags: candidateSignature.getJsDocTags() }; }); var argumentIndex = argumentListInfo.argumentIndex; @@ -76182,9 +79700,9 @@ var ts; (function (SymbolDisplay) { // TODO(drosen): use contextual SemanticMeaning. function getSymbolKind(typeChecker, symbol, location) { - var flags = symbol.getFlags(); + var flags = symbol.flags; if (flags & 32 /* Class */) - return ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */) ? + return ts.getDeclarationOfKind(symbol, 199 /* ClassExpression */) ? ts.ScriptElementKind.localClassElement : ts.ScriptElementKind.classElement; if (flags & 384 /* Enum */) return ts.ScriptElementKind.enumElement; @@ -76194,12 +79712,12 @@ var ts; return ts.ScriptElementKind.interfaceElement; if (flags & 262144 /* TypeParameter */) return ts.ScriptElementKind.typeParameterElement; - var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location); + var result = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); if (result === ts.ScriptElementKind.unknown) { if (flags & 262144 /* TypeParameter */) return ts.ScriptElementKind.typeParameterElement; if (flags & 8 /* EnumMember */) - return ts.ScriptElementKind.variableElement; + return ts.ScriptElementKind.enumMemberElement; if (flags & 8388608 /* Alias */) return ts.ScriptElementKind.alias; if (flags & 1536 /* Module */) @@ -76208,16 +79726,17 @@ var ts; return result; } SymbolDisplay.getSymbolKind = getSymbolKind; - function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, flags, location) { + function getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) { if (typeChecker.isUndefinedSymbol(symbol)) { return ts.ScriptElementKind.variableElement; } if (typeChecker.isArgumentsSymbol(symbol)) { return ts.ScriptElementKind.localVariableElement; } - if (location.kind === 98 /* ThisKeyword */ && ts.isExpression(location)) { + if (location.kind === 99 /* ThisKeyword */ && ts.isExpression(location)) { return ts.ScriptElementKind.parameterElement; } + var flags = symbol.flags; if (flags & 3 /* Variable */) { if (ts.isFirstDeclarationOfSymbolParameter(symbol)) { return ts.ScriptElementKind.parameterElement; @@ -76241,7 +79760,7 @@ var ts; if (flags & 16384 /* Constructor */) return ts.ScriptElementKind.constructorImplementationElement; if (flags & 4 /* Property */) { - if (flags & 134217728 /* Transient */ && symbol.checkFlags & 2 /* SyntheticProperty */) { + if (flags & 134217728 /* Transient */ && symbol.checkFlags & 6 /* Synthetic */) { // If union property is result of union of non method (property/accessors/variables), it is labeled as property var unionPropertyKind = ts.forEach(typeChecker.getRootSymbols(symbol), function (rootSymbol) { var rootSymbolFlags = rootSymbol.getFlags(); @@ -76279,10 +79798,11 @@ var ts; if (semanticMeaning === void 0) { semanticMeaning = ts.getMeaningFromLocation(location); } var displayParts = []; var documentation; + var tags; var symbolFlags = symbol.flags; - var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, symbolFlags, location); + var symbolKind = getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location); var hasAddedSymbolInfo; - var isThisExpression = location.kind === 98 /* ThisKeyword */ && ts.isExpression(location); + var isThisExpression = location.kind === 99 /* ThisKeyword */ && ts.isExpression(location); var type; // Class at constructor site need to be shown as constructor apart from property,method, vars if (symbolKind !== ts.ScriptElementKind.unknown || symbolFlags & 32 /* Class */ || symbolFlags & 8388608 /* Alias */) { @@ -76293,7 +79813,7 @@ var ts; var signature = void 0; type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location); if (type) { - if (location.parent && location.parent.kind === 178 /* PropertyAccessExpression */) { + if (location.parent && location.parent.kind === 179 /* 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)) { @@ -76302,7 +79822,7 @@ var ts; } // try get the call/construct signature from the type if it matches var callExpressionLike = void 0; - if (location.kind === 180 /* CallExpression */ || location.kind === 181 /* NewExpression */) { + if (location.kind === 181 /* CallExpression */ || location.kind === 182 /* NewExpression */) { callExpressionLike = location; } else if (ts.isCallExpressionTarget(location) || ts.isNewExpressionTarget(location)) { @@ -76318,7 +79838,7 @@ var ts; // Use the first candidate: signature = candidateSignatures[0]; } - var useConstructSignatures = callExpressionLike.kind === 181 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 96 /* SuperKeyword */); + var useConstructSignatures = callExpressionLike.kind === 182 /* NewExpression */ || (ts.isCallExpression(callExpressionLike) && callExpressionLike.expression.kind === 97 /* 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 @@ -76336,7 +79856,7 @@ var ts; pushTypePart(symbolKind); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93 /* NewKeyword */)); + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } addFullSymbolName(symbol); @@ -76353,10 +79873,10 @@ var ts; case ts.ScriptElementKind.parameterElement: case ts.ScriptElementKind.localVariableElement: // If it is call or construct signature of lambda's write type name - displayParts.push(ts.punctuationPart(55 /* ColonToken */)); + displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); if (useConstructSignatures) { - displayParts.push(ts.keywordPart(93 /* NewKeyword */)); + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } if (!(type.flags & 32768 /* Object */ && type.objectFlags & 16 /* Anonymous */) && type.symbol) { @@ -76372,24 +79892,24 @@ var ts; } } else if ((ts.isNameOfFunctionDeclaration(location) && !(symbol.flags & 98304 /* Accessor */)) || - (location.kind === 122 /* ConstructorKeyword */ && location.parent.kind === 151 /* Constructor */)) { + (location.kind === 123 /* ConstructorKeyword */ && location.parent.kind === 152 /* Constructor */)) { // get the signature from the declaration and write it var functionDeclaration = location.parent; - var allSignatures = functionDeclaration.kind === 151 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + var allSignatures = functionDeclaration.kind === 152 /* Constructor */ ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); } else { signature = allSignatures[0]; } - if (functionDeclaration.kind === 151 /* Constructor */) { + if (functionDeclaration.kind === 152 /* Constructor */) { // show (constructor) Type(...) signature symbolKind = ts.ScriptElementKind.constructorImplementationElement; addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); } else { // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 154 /* CallSignature */ && + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === 155 /* CallSignature */ && !(type.symbol.flags & 2048 /* TypeLiteral */ || type.symbol.flags & 4096 /* ObjectLiteral */) ? type.symbol : symbol, symbolKind); } addSignatureDisplayParts(signature, allSignatures); @@ -76398,7 +79918,7 @@ var ts; } } if (symbolFlags & 32 /* Class */ && !hasAddedSymbolInfo && !isThisExpression) { - if (ts.getDeclarationOfKind(symbol, 198 /* ClassExpression */)) { + if (ts.getDeclarationOfKind(symbol, 199 /* 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 @@ -76406,7 +79926,7 @@ var ts; } else { // Class declaration has name which is not local. - displayParts.push(ts.keywordPart(74 /* ClassKeyword */)); + displayParts.push(ts.keywordPart(75 /* ClassKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); @@ -76414,45 +79934,45 @@ var ts; } if ((symbolFlags & 64 /* Interface */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(108 /* InterfaceKeyword */)); + displayParts.push(ts.keywordPart(109 /* InterfaceKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); } if (symbolFlags & 524288 /* TypeAlias */) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(138 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); writeTypeParametersOfSymbol(symbol, sourceFile); displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); ts.addRange(displayParts, ts.typeToDisplayParts(typeChecker, typeChecker.getDeclaredTypeOfSymbol(symbol), enclosingDeclaration, 512 /* InTypeAlias */)); } if (symbolFlags & 384 /* Enum */) { addNewLineIfDisplayPartsExist(); if (ts.forEach(symbol.declarations, ts.isConstEnumDeclaration)) { - displayParts.push(ts.keywordPart(75 /* ConstKeyword */)); + displayParts.push(ts.keywordPart(76 /* ConstKeyword */)); displayParts.push(ts.spacePart()); } - displayParts.push(ts.keywordPart(82 /* EnumKeyword */)); + displayParts.push(ts.keywordPart(83 /* EnumKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if (symbolFlags & 1536 /* Module */) { addNewLineIfDisplayPartsExist(); - var declaration = ts.getDeclarationOfKind(symbol, 232 /* ModuleDeclaration */); - var isNamespace = declaration && declaration.name && declaration.name.kind === 70 /* Identifier */; - displayParts.push(ts.keywordPart(isNamespace ? 128 /* NamespaceKeyword */ : 127 /* ModuleKeyword */)); + var declaration = ts.getDeclarationOfKind(symbol, 233 /* ModuleDeclaration */); + var isNamespace = declaration && declaration.name && declaration.name.kind === 71 /* Identifier */; + displayParts.push(ts.keywordPart(isNamespace ? 129 /* NamespaceKeyword */ : 128 /* ModuleKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); } if ((symbolFlags & 262144 /* TypeParameter */) && (semanticMeaning & 2 /* Type */)) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); displayParts.push(ts.textPart("type parameter")); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(symbol); if (symbol.parent) { @@ -76463,28 +79983,28 @@ var ts; } else { // Method/function type parameter - var declaration = ts.getDeclarationOfKind(symbol, 144 /* TypeParameter */); + var declaration = ts.getDeclarationOfKind(symbol, 145 /* TypeParameter */); ts.Debug.assert(declaration !== undefined); declaration = declaration.parent; if (declaration) { if (ts.isFunctionLikeKind(declaration.kind)) { addInPrefix(); var signature = typeChecker.getSignatureFromDeclaration(declaration); - if (declaration.kind === 155 /* ConstructSignature */) { - displayParts.push(ts.keywordPart(93 /* NewKeyword */)); + if (declaration.kind === 156 /* ConstructSignature */) { + displayParts.push(ts.keywordPart(94 /* NewKeyword */)); displayParts.push(ts.spacePart()); } - else if (declaration.kind !== 154 /* CallSignature */ && declaration.name) { + else if (declaration.kind !== 155 /* CallSignature */ && declaration.name) { addFullSymbolName(declaration.symbol); } ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, sourceFile, 32 /* WriteTypeArgumentsOfSignature */)); } - else if (declaration.kind === 230 /* TypeAliasDeclaration */) { + else if (declaration.kind === 231 /* TypeAliasDeclaration */) { // Type alias type parameter // For example // type list = T[]; // Both T will go through same code path addInPrefix(); - displayParts.push(ts.keywordPart(137 /* TypeKeyword */)); + displayParts.push(ts.keywordPart(138 /* TypeKeyword */)); displayParts.push(ts.spacePart()); addFullSymbolName(declaration.symbol); writeTypeParametersOfSymbol(declaration.symbol, sourceFile); @@ -76493,13 +80013,14 @@ var ts; } } if (symbolFlags & 8 /* EnumMember */) { + symbolKind = ts.ScriptElementKind.enumMemberElement; addPrefixForAnyFunctionOrVar(symbol, "enum member"); var declaration = symbol.declarations[0]; - if (declaration.kind === 263 /* EnumMember */) { + if (declaration.kind === 264 /* EnumMember */) { var constantValue = typeChecker.getConstantValue(declaration); if (constantValue !== undefined) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); displayParts.push(ts.displayPart(constantValue.toString(), ts.SymbolDisplayPartKind.numericLiteral)); } @@ -76507,33 +80028,33 @@ var ts; } if (symbolFlags & 8388608 /* Alias */) { addNewLineIfDisplayPartsExist(); - if (symbol.declarations[0].kind === 235 /* NamespaceExportDeclaration */) { - displayParts.push(ts.keywordPart(83 /* ExportKeyword */)); + if (symbol.declarations[0].kind === 236 /* NamespaceExportDeclaration */) { + displayParts.push(ts.keywordPart(84 /* ExportKeyword */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(128 /* NamespaceKeyword */)); + displayParts.push(ts.keywordPart(129 /* NamespaceKeyword */)); } else { - displayParts.push(ts.keywordPart(90 /* ImportKeyword */)); + displayParts.push(ts.keywordPart(91 /* ImportKeyword */)); } displayParts.push(ts.spacePart()); addFullSymbolName(symbol); ts.forEach(symbol.declarations, function (declaration) { - if (declaration.kind === 236 /* ImportEqualsDeclaration */) { + if (declaration.kind === 237 /* ImportEqualsDeclaration */) { var importEqualsDeclaration = declaration; if (ts.isExternalModuleImportEqualsDeclaration(importEqualsDeclaration)) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(131 /* RequireKeyword */)); - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.keywordPart(132 /* RequireKeyword */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); displayParts.push(ts.displayPart(ts.getTextOfNode(ts.getExternalModuleImportEqualsDeclarationExpression(importEqualsDeclaration)), ts.SymbolDisplayPartKind.stringLiteral)); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); } else { var internalAliasSymbol = typeChecker.getSymbolAtLocation(importEqualsDeclaration.moduleReference); if (internalAliasSymbol) { displayParts.push(ts.spacePart()); - displayParts.push(ts.operatorPart(57 /* EqualsToken */)); + displayParts.push(ts.operatorPart(58 /* EqualsToken */)); displayParts.push(ts.spacePart()); addFullSymbolName(internalAliasSymbol, enclosingDeclaration); } @@ -76547,7 +80068,7 @@ var ts; if (type) { if (isThisExpression) { addNewLineIfDisplayPartsExist(); - displayParts.push(ts.keywordPart(98 /* ThisKeyword */)); + displayParts.push(ts.keywordPart(99 /* ThisKeyword */)); } else { addPrefixForAnyFunctionOrVar(symbol, symbolKind); @@ -76558,7 +80079,7 @@ var ts; symbolFlags & 3 /* Variable */ || symbolKind === ts.ScriptElementKind.localVariableElement || isThisExpression) { - displayParts.push(ts.punctuationPart(55 /* ColonToken */)); + displayParts.push(ts.punctuationPart(56 /* ColonToken */)); displayParts.push(ts.spacePart()); // If the type is type parameter, format it specially if (type.symbol && type.symbol.flags & 262144 /* TypeParameter */) { @@ -76588,14 +80109,15 @@ var ts; } if (!documentation) { documentation = symbol.getDocumentationComment(); + tags = symbol.getJsDocTags(); if (documentation.length === 0 && symbol.flags & 4 /* Property */) { - // For some special property access expressions like `experts.foo = foo` or `module.exports.foo = foo` + // For some special property access expressions like `exports.foo = foo` or `module.exports.foo = foo` // there documentation comments might be attached to the right hand side symbol of their declarations. // The pattern of such special property access is that the parent symbol is the symbol of the file. - if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 264 /* SourceFile */; })) { + if (symbol.parent && ts.forEach(symbol.parent.declarations, function (declaration) { return declaration.kind === 265 /* SourceFile */; })) { for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) { var declaration = _a[_i]; - if (!declaration.parent || declaration.parent.kind !== 193 /* BinaryExpression */) { + if (!declaration.parent || declaration.parent.kind !== 194 /* BinaryExpression */) { continue; } var rhsSymbol = typeChecker.getSymbolAtLocation(declaration.parent.right); @@ -76603,6 +80125,7 @@ var ts; continue; } documentation = rhsSymbol.getDocumentationComment(); + tags = rhsSymbol.getJsDocTags(); if (documentation.length > 0) { break; } @@ -76610,7 +80133,7 @@ var ts; } } } - return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind }; + return { displayParts: displayParts, documentation: documentation, symbolKind: symbolKind, tags: tags }; function addNewLineIfDisplayPartsExist() { if (displayParts.length) { displayParts.push(ts.lineBreakPart()); @@ -76618,7 +80141,7 @@ var ts; } function addInPrefix() { displayParts.push(ts.spacePart()); - displayParts.push(ts.keywordPart(91 /* InKeyword */)); + displayParts.push(ts.keywordPart(92 /* InKeyword */)); displayParts.push(ts.spacePart()); } function addFullSymbolName(symbol, enclosingDeclaration) { @@ -76643,9 +80166,9 @@ var ts; displayParts.push(ts.textOrKeywordPart(symbolKind)); return; default: - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); displayParts.push(ts.textOrKeywordPart(symbolKind)); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); return; } } @@ -76653,14 +80176,15 @@ var ts; ts.addRange(displayParts, ts.signatureToDisplayParts(typeChecker, signature, enclosingDeclaration, flags | 32 /* WriteTypeArgumentsOfSignature */)); if (allSignatures.length > 1) { displayParts.push(ts.spacePart()); - displayParts.push(ts.punctuationPart(18 /* OpenParenToken */)); - displayParts.push(ts.operatorPart(36 /* PlusToken */)); + displayParts.push(ts.punctuationPart(19 /* OpenParenToken */)); + displayParts.push(ts.operatorPart(37 /* PlusToken */)); displayParts.push(ts.displayPart((allSignatures.length - 1).toString(), ts.SymbolDisplayPartKind.numericLiteral)); displayParts.push(ts.spacePart()); displayParts.push(ts.textPart(allSignatures.length === 2 ? "overload" : "overloads")); - displayParts.push(ts.punctuationPart(19 /* CloseParenToken */)); + displayParts.push(ts.punctuationPart(20 /* CloseParenToken */)); } documentation = signature.getDocumentationComment(); + tags = signature.getJsDocTags(); } function writeTypeParametersOfSymbol(symbol, enclosingDeclaration) { var typeParameterParts = ts.mapToDisplayParts(function (writer) { @@ -76676,16 +80200,16 @@ var ts; } return ts.forEach(symbol.declarations, function (declaration) { // Function expressions are local - if (declaration.kind === 185 /* FunctionExpression */) { + if (declaration.kind === 186 /* FunctionExpression */) { return true; } - if (declaration.kind !== 225 /* VariableDeclaration */ && declaration.kind !== 227 /* FunctionDeclaration */) { + if (declaration.kind !== 226 /* VariableDeclaration */ && declaration.kind !== 228 /* FunctionDeclaration */) { return false; } // If the parent is not sourceFile or module block it is local variable for (var parent = declaration.parent; !ts.isFunctionBlock(parent); parent = parent.parent) { // Reached source file or module block - if (parent.kind === 264 /* SourceFile */ || parent.kind === 233 /* ModuleBlock */) { + if (parent.kind === 265 /* SourceFile */ || parent.kind === 234 /* ModuleBlock */) { return false; } } @@ -76790,6 +80314,7 @@ var ts; ts.transpile = transpile; var commandLineOptionsStringToEnum; /** JS users may pass in string values for enum compiler options (such as ModuleKind), so convert. */ + /*@internal*/ function fixupCompilerOptions(options, diagnostics) { // Lazily create this value to fix module loading errors. commandLineOptionsStringToEnum = commandLineOptionsStringToEnum || ts.filter(ts.optionDeclarations, function (o) { @@ -76819,6 +80344,7 @@ var ts; } return options; } + ts.fixupCompilerOptions = fixupCompilerOptions; })(ts || (ts = {})); /// /// @@ -76842,10 +80368,10 @@ var ts; ScanAction[ScanAction["RescanJsxIdentifier"] = 4] = "RescanJsxIdentifier"; ScanAction[ScanAction["RescanJsxText"] = 5] = "RescanJsxText"; })(ScanAction || (ScanAction = {})); - function getFormattingScanner(sourceFile, startPos, endPos) { + function getFormattingScanner(text, languageVariant, startPos, endPos) { ts.Debug.assert(scanner === undefined, "Scanner should be undefined"); - scanner = sourceFile.languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; - scanner.setText(sourceFile.text); + scanner = languageVariant === 1 /* JSX */ ? jsxScanner : standardScanner; + scanner.setText(text); scanner.setTextPos(startPos); var wasNewLine = true; var leadingTrivia; @@ -76910,11 +80436,11 @@ var ts; function shouldRescanGreaterThanToken(node) { if (node) { switch (node.kind) { - case 30 /* GreaterThanEqualsToken */: - case 65 /* GreaterThanGreaterThanEqualsToken */: - case 66 /* GreaterThanGreaterThanGreaterThanEqualsToken */: - case 46 /* GreaterThanGreaterThanGreaterThanToken */: - case 45 /* GreaterThanGreaterThanToken */: + case 31 /* GreaterThanEqualsToken */: + case 66 /* GreaterThanGreaterThanEqualsToken */: + case 67 /* GreaterThanGreaterThanGreaterThanEqualsToken */: + case 47 /* GreaterThanGreaterThanGreaterThanToken */: + case 46 /* GreaterThanGreaterThanToken */: return true; } } @@ -76923,11 +80449,11 @@ var ts; function shouldRescanJsxIdentifier(node) { if (node.parent) { switch (node.parent.kind) { - case 252 /* JsxAttribute */: - case 250 /* JsxOpeningElement */: - case 251 /* JsxClosingElement */: - case 249 /* JsxSelfClosingElement */: - return node.kind === 70 /* Identifier */; + case 253 /* JsxAttribute */: + case 251 /* JsxOpeningElement */: + case 252 /* JsxClosingElement */: + case 250 /* JsxSelfClosingElement */: + return node.kind === 71 /* Identifier */; } } return false; @@ -76936,14 +80462,14 @@ var ts; return node && node.kind === 10 /* JsxText */; } function shouldRescanSlashToken(container) { - return container.kind === 11 /* RegularExpressionLiteral */; + return container.kind === 12 /* RegularExpressionLiteral */; } function shouldRescanTemplateToken(container) { - return container.kind === 14 /* TemplateMiddle */ || - container.kind === 15 /* TemplateTail */; + return container.kind === 15 /* TemplateMiddle */ || + container.kind === 16 /* TemplateTail */; } function startsWithSlashToken(t) { - return t === 40 /* SlashToken */ || t === 62 /* SlashEqualsToken */; + return t === 41 /* SlashToken */ || t === 63 /* SlashEqualsToken */; } function readTokenInfo(n) { ts.Debug.assert(scanner !== undefined); @@ -76984,7 +80510,7 @@ var ts; scanner.scan(); } var currentToken = scanner.getToken(); - if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 28 /* GreaterThanToken */) { + if (expectedScanAction === 1 /* RescanGreaterThanToken */ && currentToken === 29 /* GreaterThanToken */) { currentToken = scanner.reScanGreaterToken(); ts.Debug.assert(n.kind === currentToken); lastScanAction = 1 /* RescanGreaterThanToken */; @@ -76994,11 +80520,11 @@ var ts; ts.Debug.assert(n.kind === currentToken); lastScanAction = 2 /* RescanSlashToken */; } - else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 17 /* CloseBraceToken */) { + else if (expectedScanAction === 3 /* RescanTemplateToken */ && currentToken === 18 /* CloseBraceToken */) { currentToken = scanner.reScanTemplateToken(); lastScanAction = 3 /* RescanTemplateToken */; } - else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 70 /* Identifier */) { + else if (expectedScanAction === 4 /* RescanJsxIdentifier */ && currentToken === 71 /* Identifier */) { currentToken = scanner.scanJsxIdentifier(); lastScanAction = 4 /* RescanJsxIdentifier */; } @@ -77047,8 +80573,8 @@ var ts; } function isOnToken() { ts.Debug.assert(scanner !== undefined); - var current = (lastTokenInfo && lastTokenInfo.token.kind) || scanner.getToken(); - var startPos = (lastTokenInfo && lastTokenInfo.token.pos) || scanner.getStartPos(); + var current = lastTokenInfo ? lastTokenInfo.token.kind : scanner.getToken(); + var startPos = lastTokenInfo ? lastTokenInfo.token.pos : scanner.getStartPos(); return startPos < endPos && current !== 1 /* EndOfFileToken */ && !ts.isTrivia(current); } // when containing node in the tree is token @@ -77141,8 +80667,8 @@ var ts; return startLine === endLine; }; FormattingContext.prototype.BlockIsOnOneLine = function (node) { - var openBrace = ts.findChildOfKind(node, 16 /* OpenBraceToken */, this.sourceFile); - var closeBrace = ts.findChildOfKind(node, 17 /* CloseBraceToken */, this.sourceFile); + var openBrace = ts.findChildOfKind(node, 17 /* OpenBraceToken */, this.sourceFile); + var closeBrace = ts.findChildOfKind(node, 18 /* CloseBraceToken */, this.sourceFile); if (openBrace && closeBrace) { var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line; var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line; @@ -77330,129 +80856,129 @@ 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, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 55 /* 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, 54 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* 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(54 /* 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(54 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeSemicolon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 25 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeColon = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 56 /* 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, 55 /* QuestionToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.SpaceAfterColon = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* 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(55 /* 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(55 /* QuestionToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterSemicolon = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* 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(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 141 /* LastToken */, [19 /* CloseParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsAfterCodeBlockContext), 2 /* Space */)); + this.SpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* CloseBraceToken */, formatting.Shared.TokenRange.FromRange(0 /* FirstToken */, 142 /* LastToken */, [20 /* CloseParenToken */])), 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(17 /* CloseBraceToken */, 81 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* CloseBraceToken */, 105 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([21 /* CloseBracketToken */, 25 /* CommaToken */, 24 /* SemicolonToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBetweenCloseBraceAndElse = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseBraceToken */, 82 /* ElseKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenCloseBraceAndWhile = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* CloseBraceToken */, 106 /* WhileKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* CloseBraceToken */, formatting.Shared.TokenRange.FromTokens([22 /* CloseBracketToken */, 26 /* CommaToken */, 25 /* 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, 22 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* DotToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeDot = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 23 /* DotToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterDot = new formatting.Rule(formatting.RuleDescriptor.create3(23 /* 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, 20 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* CloseBracketToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 21 /* OpenBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterCloseBracket = new formatting.Rule(formatting.RuleDescriptor.create3(22 /* 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, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.SpaceBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a TypeScript declaration that has braces as children (class, module, enum, etc) - this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 3 /* MultiLineCommentTrivia */, 74 /* ClassKeyword */, 83 /* ExportKeyword */, 90 /* ImportKeyword */]); - this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.TypeScriptOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([71 /* Identifier */, 3 /* MultiLineCommentTrivia */, 75 /* ClassKeyword */, 84 /* ExportKeyword */, 91 /* ImportKeyword */]); + this.SpaceBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Place a space before open brace in a control flow construct - this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 80 /* DoKeyword */, 101 /* TryKeyword */, 86 /* FinallyKeyword */, 81 /* ElseKeyword */]); - this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); + this.ControlOpenBraceLeftTokenRange = formatting.Shared.TokenRange.FromTokens([20 /* CloseParenToken */, 3 /* MultiLineCommentTrivia */, 81 /* DoKeyword */, 102 /* TryKeyword */, 87 /* FinallyKeyword */, 82 /* ElseKeyword */]); + this.SpaceBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), 2 /* Space */), 1 /* CanDeleteNewLines */); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); - this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); - this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); - this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 8 /* Delete */)); - this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), 8 /* Delete */)); + this.SpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.SpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsBraceWrappedContext), 2 /* Space */)); + this.NoSpaceAfterOpenBrace = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeCloseBrace = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenBraceToken */, 18 /* 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(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineAfterOpenBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // For functions and control block place } on a new line [multi-line rule] - this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); + this.NewLineBeforeCloseBraceInBlockContext = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.AnyIncludingMultilineComments, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsMultilineBlockContext), 4 /* NewLine */)); // Special handling of unary operators. // Prefix operators generally shouldn't have a space between // them and their target unary expression. this.NoSpaceAfterUnaryPrefixOperator = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.UnaryPrefixOperators, formatting.Shared.TokenRange.UnaryPrefixExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(42 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* 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, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 43 /* MinusMinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPreincrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(43 /* PlusPlusToken */, formatting.Shared.TokenRange.UnaryPreincrementExpressions), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterUnaryPredecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create3(44 /* 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, 43 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeUnaryPostdecrementOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.UnaryPostdecrementExpressions, 44 /* 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(42 /* PlusPlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 36 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(36 /* PlusToken */, 42 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* MinusMinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 37 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); - this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* MinusToken */, 43 /* 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, 25 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([103 /* VarKeyword */, 99 /* ThrowKeyword */, 93 /* NewKeyword */, 79 /* DeleteKeyword */, 95 /* ReturnKeyword */, 102 /* TypeOfKeyword */, 120 /* 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([109 /* LetKeyword */, 75 /* 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, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); - this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(88 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); - this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(104 /* 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(95 /* ReturnKeyword */, 24 /* SemicolonToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterPostincrementWhenFollowedByAdd = new formatting.Rule(formatting.RuleDescriptor.create1(43 /* PlusPlusToken */, 37 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByUnaryPlus = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* PlusToken */, 37 /* PlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterAddWhenFollowedByPreincrement = new formatting.Rule(formatting.RuleDescriptor.create1(37 /* PlusToken */, 43 /* PlusPlusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterPostdecrementWhenFollowedBySubtract = new formatting.Rule(formatting.RuleDescriptor.create1(44 /* MinusMinusToken */, 38 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByUnaryMinus = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* MinusToken */, 38 /* MinusToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), 2 /* Space */)); + this.SpaceAfterSubtractWhenFollowedByPredecrement = new formatting.Rule(formatting.RuleDescriptor.create1(38 /* MinusToken */, 44 /* 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, 26 /* CommaToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterCertainKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([104 /* VarKeyword */, 100 /* ThrowKeyword */, 94 /* NewKeyword */, 80 /* DeleteKeyword */, 96 /* ReturnKeyword */, 103 /* TypeOfKeyword */, 121 /* 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([110 /* LetKeyword */, 76 /* 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, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), 8 /* Delete */)); + this.SpaceAfterFunctionInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create3(89 /* FunctionKeyword */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceBeforeOpenParenInFuncDecl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterVoidOperator = new formatting.Rule(formatting.RuleDescriptor.create3(105 /* 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(96 /* ReturnKeyword */, 25 /* 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([19 /* CloseParenToken */, 80 /* DoKeyword */, 81 /* ElseKeyword */, 72 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNotForContext), 2 /* Space */)); + this.SpaceBetweenStatements = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([20 /* CloseParenToken */, 81 /* DoKeyword */, 82 /* ElseKeyword */, 73 /* CaseKeyword */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, 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([101 /* TryKeyword */, 86 /* FinallyKeyword */]), 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterTryFinally = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([102 /* TryKeyword */, 87 /* FinallyKeyword */]), 17 /* 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([124 /* GetKeyword */, 134 /* SetKeyword */]), 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.SpaceAfterGetSetInMember = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([125 /* GetKeyword */, 135 /* SetKeyword */]), 71 /* 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.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.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(122 /* ConstructorKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123 /* ConstructorKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterConstructor = new formatting.Rule(formatting.RuleDescriptor.create1(123 /* ConstructorKeyword */, 19 /* 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([127 /* ModuleKeyword */, 131 /* RequireKeyword */]), 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterModuleImport = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.FromTokens([128 /* ModuleKeyword */, 132 /* RequireKeyword */]), 19 /* 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([116 /* AbstractKeyword */, 74 /* ClassKeyword */, 123 /* DeclareKeyword */, 78 /* DefaultKeyword */, 82 /* EnumKeyword */, 83 /* ExportKeyword */, 84 /* ExtendsKeyword */, 124 /* GetKeyword */, 107 /* ImplementsKeyword */, 90 /* ImportKeyword */, 108 /* InterfaceKeyword */, 127 /* ModuleKeyword */, 128 /* NamespaceKeyword */, 111 /* PrivateKeyword */, 113 /* PublicKeyword */, 112 /* ProtectedKeyword */, 130 /* ReadonlyKeyword */, 134 /* SetKeyword */, 114 /* StaticKeyword */, 137 /* TypeKeyword */, 139 /* FromKeyword */, 126 /* KeyOfKeyword */]), 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([84 /* ExtendsKeyword */, 107 /* ImplementsKeyword */, 139 /* FromKeyword */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterCertainTypeScriptKeywords = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([117 /* AbstractKeyword */, 75 /* ClassKeyword */, 124 /* DeclareKeyword */, 79 /* DefaultKeyword */, 83 /* EnumKeyword */, 84 /* ExportKeyword */, 85 /* ExtendsKeyword */, 125 /* GetKeyword */, 108 /* ImplementsKeyword */, 91 /* ImportKeyword */, 109 /* InterfaceKeyword */, 128 /* ModuleKeyword */, 129 /* NamespaceKeyword */, 112 /* PrivateKeyword */, 114 /* PublicKeyword */, 113 /* ProtectedKeyword */, 131 /* ReadonlyKeyword */, 135 /* SetKeyword */, 115 /* StaticKeyword */, 138 /* TypeKeyword */, 140 /* FromKeyword */, 127 /* KeyOfKeyword */]), 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([85 /* ExtendsKeyword */, 108 /* ImplementsKeyword */, 140 /* FromKeyword */])), 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 */, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsModuleDeclContext), 2 /* Space */)); + this.SpaceAfterModuleName = new formatting.Rule(formatting.RuleDescriptor.create1(9 /* StringLiteral */, 17 /* 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, 35 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(35 /* EqualsGreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeArrow = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 36 /* EqualsGreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceAfterArrow = new formatting.Rule(formatting.RuleDescriptor.create3(36 /* 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(23 /* DotDotDotToken */, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(54 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([19 /* CloseParenToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBinaryOpContext), 8 /* Delete */)); + this.NoSpaceAfterEllipsis = new formatting.Rule(formatting.RuleDescriptor.create1(24 /* DotDotDotToken */, 71 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOptionalParameters = new formatting.Rule(formatting.RuleDescriptor.create3(55 /* QuestionToken */, formatting.Shared.TokenRange.FromTokens([20 /* CloseParenToken */, 26 /* 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, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* CloseParenToken */, 26 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* 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, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); - this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([18 /* OpenParenToken */, 20 /* OpenBracketToken */, 28 /* GreaterThanToken */, 25 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.TypeNames, 27 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceBetweenCloseParenAndAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* CloseParenToken */, 27 /* LessThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterOpenAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(27 /* 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, 29 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); + this.NoSpaceAfterCloseAngularBracket = new formatting.Rule(formatting.RuleDescriptor.create3(29 /* GreaterThanToken */, formatting.Shared.TokenRange.FromTokens([19 /* OpenParenToken */, 21 /* OpenBracketToken */, 29 /* GreaterThanToken */, 26 /* CommaToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeArgumentOrParameterOrAssertionContext), 8 /* Delete */)); // Remove spaces in empty interface literals. e.g.: x: {} - this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(16 /* OpenBraceToken */, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectTypeContext), 8 /* Delete */)); + this.NoSpaceBetweenEmptyInterfaceBraceBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(17 /* OpenBraceToken */, 18 /* 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, 56 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(56 /* 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([116 /* AbstractKeyword */, 70 /* Identifier */, 83 /* ExportKeyword */, 78 /* DefaultKeyword */, 74 /* ClassKeyword */, 114 /* StaticKeyword */, 113 /* PublicKeyword */, 111 /* PrivateKeyword */, 112 /* ProtectedKeyword */, 124 /* GetKeyword */, 134 /* SetKeyword */, 20 /* OpenBracketToken */, 38 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); - this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 38 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); - this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(38 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); - this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(115 /* YieldKeyword */, 38 /* 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([115 /* YieldKeyword */, 38 /* AsteriskToken */]), formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsYieldOrYieldStarWithOperand), 2 /* Space */)); + this.SpaceBeforeAt = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* AtToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterAt = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* 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([117 /* AbstractKeyword */, 71 /* Identifier */, 84 /* ExportKeyword */, 79 /* DefaultKeyword */, 75 /* ClassKeyword */, 115 /* StaticKeyword */, 114 /* PublicKeyword */, 112 /* PrivateKeyword */, 113 /* ProtectedKeyword */, 125 /* GetKeyword */, 135 /* SetKeyword */, 21 /* OpenBracketToken */, 39 /* AsteriskToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsEndOfDecoratorContextOnSameLine), 2 /* Space */)); + this.NoSpaceBetweenFunctionKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* FunctionKeyword */, 39 /* AsteriskToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 8 /* Delete */)); + this.SpaceAfterStarInGeneratorDeclaration = new formatting.Rule(formatting.RuleDescriptor.create3(39 /* AsteriskToken */, formatting.Shared.TokenRange.FromTokens([71 /* Identifier */, 19 /* OpenParenToken */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclarationOrFunctionExpressionContext), 2 /* Space */)); + this.NoSpaceBetweenYieldKeywordAndStar = new formatting.Rule(formatting.RuleDescriptor.create1(116 /* YieldKeyword */, 39 /* 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([116 /* YieldKeyword */, 39 /* 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(119 /* AsyncKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(119 /* AsyncKeyword */, 88 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndOpenParen = new formatting.Rule(formatting.RuleDescriptor.create1(120 /* AsyncKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsArrowFunctionContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBetweenAsyncAndFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(120 /* AsyncKeyword */, 89 /* FunctionKeyword */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // template string - this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(70 /* Identifier */, formatting.Shared.TokenRange.FromTokens([12 /* NoSubstitutionTemplateLiteral */, 13 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBetweenTagAndTemplateString = new formatting.Rule(formatting.RuleDescriptor.create3(71 /* Identifier */, formatting.Shared.TokenRange.FromTokens([13 /* NoSubstitutionTemplateLiteral */, 14 /* TemplateHead */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // jsx opening element - this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 70 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 40 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(40 /* SlashToken */, 28 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 57 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(57 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceBeforeJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 71 /* Identifier */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNextTokenParentJsxAttribute, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.SpaceBeforeSlashInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 41 /* SlashToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBeforeGreaterThanTokenInJsxOpeningElement = new formatting.Rule(formatting.RuleDescriptor.create1(41 /* SlashToken */, 29 /* GreaterThanToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxSelfClosingElementContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceBeforeEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 58 /* EqualsToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterEqualInJsxAttribute = new formatting.Rule(formatting.RuleDescriptor.create3(58 /* EqualsToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsJsxAttributeContext, Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); // No space before non-null assertion operator - this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 50 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); + this.NoSpaceBeforeNonNullAssertionOperator = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 51 /* ExclamationToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), 8 /* Delete */)); // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -77514,54 +81040,54 @@ var ts; /// Rules controlled by user options /// // Insert space after comma delimiter - this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); - this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 8 /* Delete */)); + this.SpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), 2 /* Space */)); + this.NoSpaceAfterComma = new formatting.Rule(formatting.RuleDescriptor.create3(26 /* CommaToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), 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.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, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); - this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); + this.SpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 2 /* Space */)); + this.NoSpaceAfterKeywordInControl = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Keywords, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext), 8 /* Delete */)); // Open Brace braces after function // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInFunction = new formatting.Rule(formatting.RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new formatting.Rule(formatting.RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, 17 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 16 /* OpenBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), 4 /* NewLine */), 1 /* CanDeleteNewLines */); + this.NewLineBeforeOpenBraceInControl = new formatting.Rule(formatting.RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, 17 /* 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(24 /* 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(24 /* SemicolonToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), 8 /* Delete */)); + this.SpaceAfterSemicolonInFor = new formatting.Rule(formatting.RuleDescriptor.create3(25 /* 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(25 /* 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(18 /* 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, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(18 /* OpenParenToken */, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(18 /* 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, 19 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* 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, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenParens = new formatting.Rule(formatting.RuleDescriptor.create1(19 /* OpenParenToken */, 20 /* CloseParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenParen = new formatting.Rule(formatting.RuleDescriptor.create3(19 /* 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, 20 /* 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(20 /* 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, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); - this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(20 /* OpenBracketToken */, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); - this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(20 /* 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, 21 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.SpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* 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, 22 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceBetweenBrackets = new formatting.Rule(formatting.RuleDescriptor.create1(21 /* OpenBracketToken */, 22 /* CloseBracketToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 8 /* Delete */)); + this.NoSpaceAfterOpenBracket = new formatting.Rule(formatting.RuleDescriptor.create3(21 /* 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, 22 /* 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([13 /* TemplateHead */, 14 /* 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([13 /* TemplateHead */, 14 /* 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([14 /* TemplateMiddle */, 15 /* 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([14 /* TemplateMiddle */, 15 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); + this.NoSpaceAfterTemplateHeadAndMiddle = new formatting.Rule(formatting.RuleDescriptor.create4(formatting.Shared.TokenRange.FromTokens([14 /* TemplateHead */, 15 /* 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([14 /* TemplateHead */, 15 /* 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([15 /* TemplateMiddle */, 16 /* 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([15 /* TemplateMiddle */, 16 /* TemplateTail */])), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), 2 /* Space */)); // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(16 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); - this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 17 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceAfterOpenBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create3(17 /* OpenBraceToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 8 /* Delete */)); + this.SpaceBeforeCloseBraceInJsxExpression = new formatting.Rule(formatting.RuleDescriptor.create2(formatting.Shared.TokenRange.Any, 18 /* CloseBraceToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), 2 /* Space */)); // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); - this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(88 /* FunctionKeyword */, 18 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); + this.SpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* FunctionKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 2 /* Space */)); + this.NoSpaceAfterAnonymousFunctionKeyword = new formatting.Rule(formatting.RuleDescriptor.create1(89 /* FunctionKeyword */, 19 /* OpenParenToken */), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsFunctionDeclContext), 8 /* Delete */)); // No space after type assertion - this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); - this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(28 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); + this.NoSpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 8 /* Delete */)); + this.SpaceAfterTypeAssertion = new formatting.Rule(formatting.RuleDescriptor.create3(29 /* GreaterThanToken */, formatting.Shared.TokenRange.Any), formatting.RuleOperation.create2(new formatting.RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), 2 /* Space */)); } Rules.prototype.getRuleName = function (rule) { var o = this; @@ -77576,44 +81102,44 @@ var ts; /// Contexts /// Rules.IsForContext = function (context) { - return context.contextNode.kind === 213 /* ForStatement */; + return context.contextNode.kind === 214 /* ForStatement */; }; Rules.IsNotForContext = function (context) { return !Rules.IsForContext(context); }; Rules.IsBinaryOpContext = function (context) { switch (context.contextNode.kind) { - case 193 /* BinaryExpression */: - case 194 /* ConditionalExpression */: - case 201 /* AsExpression */: - case 245 /* ExportSpecifier */: - case 241 /* ImportSpecifier */: - case 157 /* TypePredicate */: - case 165 /* UnionType */: - case 166 /* IntersectionType */: + case 194 /* BinaryExpression */: + case 195 /* ConditionalExpression */: + case 202 /* AsExpression */: + case 246 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: + case 158 /* TypePredicate */: + case 166 /* UnionType */: + case 167 /* IntersectionType */: return true; // equals in binding elements: function foo([[x, y] = [1, 2]]) - case 175 /* BindingElement */: + case 176 /* BindingElement */: // equals in type X = ... - case 230 /* TypeAliasDeclaration */: + case 231 /* TypeAliasDeclaration */: // equal in import a = module('a'); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // equal in let a = 0; - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: // equal in p = 0; - case 145 /* Parameter */: - case 263 /* EnumMember */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: - return context.currentTokenSpan.kind === 57 /* EqualsToken */ || context.nextTokenSpan.kind === 57 /* EqualsToken */; + case 146 /* Parameter */: + case 264 /* EnumMember */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: + return context.currentTokenSpan.kind === 58 /* EqualsToken */ || context.nextTokenSpan.kind === 58 /* EqualsToken */; // "in" keyword in for (let x in []) { } - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: // "in" keyword in [P in keyof T]: T[P] - case 144 /* TypeParameter */: - return context.currentTokenSpan.kind === 91 /* InKeyword */ || context.nextTokenSpan.kind === 91 /* InKeyword */; + case 145 /* TypeParameter */: + return context.currentTokenSpan.kind === 92 /* InKeyword */ || context.nextTokenSpan.kind === 92 /* InKeyword */; // Technically, "of" is not a binary operator, but format it the same way as "in" - case 215 /* ForOfStatement */: - return context.currentTokenSpan.kind === 141 /* OfKeyword */ || context.nextTokenSpan.kind === 141 /* OfKeyword */; + case 216 /* ForOfStatement */: + return context.currentTokenSpan.kind === 142 /* OfKeyword */ || context.nextTokenSpan.kind === 142 /* OfKeyword */; } return false; }; @@ -77621,7 +81147,7 @@ var ts; return !Rules.IsBinaryOpContext(context); }; Rules.IsConditionalOperatorContext = function (context) { - return context.contextNode.kind === 194 /* ConditionalExpression */; + return context.contextNode.kind === 195 /* ConditionalExpression */; }; Rules.IsSameLineTokenOrBeforeMultilineBlockContext = function (context) { //// This check is mainly used inside SpaceBeforeOpenBraceInControl and SpaceBeforeOpenBraceInFunction. @@ -77643,7 +81169,7 @@ var ts; return context.TokensAreOnSameLine() || Rules.IsBeforeMultilineBlockContext(context); }; Rules.IsBraceWrappedContext = function (context) { - return context.contextNode.kind === 173 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); + return context.contextNode.kind === 174 /* ObjectBindingPattern */ || Rules.IsSingleLineBlockContext(context); }; // This check is done before an open brace in a control construct, a function, or a typescript block declaration Rules.IsBeforeMultilineBlockContext = function (context) { @@ -77668,70 +81194,70 @@ var ts; return true; } switch (node.kind) { - case 206 /* Block */: - case 234 /* CaseBlock */: - case 177 /* ObjectLiteralExpression */: - case 233 /* ModuleBlock */: + case 207 /* Block */: + case 235 /* CaseBlock */: + case 178 /* ObjectLiteralExpression */: + case 234 /* ModuleBlock */: return true; } return false; }; Rules.IsFunctionDeclContext = function (context) { switch (context.contextNode.kind) { - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: // case SyntaxKind.MemberFunctionDeclaration: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: // case SyntaxKind.MethodSignature: - case 154 /* CallSignature */: - case 185 /* FunctionExpression */: - case 151 /* Constructor */: - case 186 /* ArrowFunction */: + case 155 /* CallSignature */: + case 186 /* FunctionExpression */: + case 152 /* Constructor */: + case 187 /* ArrowFunction */: // case SyntaxKind.ConstructorDeclaration: // case SyntaxKind.SimpleArrowFunctionExpression: // case SyntaxKind.ParenthesizedArrowFunctionExpression: - case 229 /* InterfaceDeclaration */: + case 230 /* InterfaceDeclaration */: return true; } return false; }; Rules.IsFunctionDeclarationOrFunctionExpressionContext = function (context) { - return context.contextNode.kind === 227 /* FunctionDeclaration */ || context.contextNode.kind === 185 /* FunctionExpression */; + return context.contextNode.kind === 228 /* FunctionDeclaration */ || context.contextNode.kind === 186 /* FunctionExpression */; }; Rules.IsTypeScriptDeclWithBlockContext = function (context) { return Rules.NodeIsTypeScriptDeclWithBlockContext(context.contextNode); }; Rules.NodeIsTypeScriptDeclWithBlockContext = function (node) { switch (node.kind) { - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 162 /* TypeLiteral */: - case 232 /* ModuleDeclaration */: - case 243 /* ExportDeclaration */: - case 244 /* NamedExports */: - case 237 /* ImportDeclaration */: - case 240 /* NamedImports */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 163 /* TypeLiteral */: + case 233 /* ModuleDeclaration */: + case 244 /* ExportDeclaration */: + case 245 /* NamedExports */: + case 238 /* ImportDeclaration */: + case 241 /* NamedImports */: return true; } return false; }; Rules.IsAfterCodeBlockContext = function (context) { switch (context.currentTokenParent.kind) { - case 228 /* ClassDeclaration */: - case 232 /* ModuleDeclaration */: - case 231 /* EnumDeclaration */: - case 259 /* CatchClause */: - case 233 /* ModuleBlock */: - case 220 /* SwitchStatement */: + case 229 /* ClassDeclaration */: + case 233 /* ModuleDeclaration */: + case 232 /* EnumDeclaration */: + case 260 /* CatchClause */: + case 234 /* ModuleBlock */: + case 221 /* SwitchStatement */: return true; - case 206 /* Block */: { + case 207 /* Block */: { var blockParent = context.currentTokenParent.parent; - if (blockParent.kind !== 186 /* ArrowFunction */ && - blockParent.kind !== 185 /* FunctionExpression */) { + if (blockParent.kind !== 187 /* ArrowFunction */ && + blockParent.kind !== 186 /* FunctionExpression */) { return true; } } @@ -77740,61 +81266,61 @@ var ts; }; Rules.IsControlDeclContext = function (context) { switch (context.contextNode.kind) { - case 210 /* IfStatement */: - case 220 /* SwitchStatement */: - case 213 /* ForStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 212 /* WhileStatement */: - case 223 /* TryStatement */: - case 211 /* DoStatement */: - case 219 /* WithStatement */: + case 211 /* IfStatement */: + case 221 /* SwitchStatement */: + case 214 /* ForStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 213 /* WhileStatement */: + case 224 /* TryStatement */: + case 212 /* DoStatement */: + case 220 /* WithStatement */: // TODO // case SyntaxKind.ElseClause: - case 259 /* CatchClause */: + case 260 /* CatchClause */: return true; default: return false; } }; Rules.IsObjectContext = function (context) { - return context.contextNode.kind === 177 /* ObjectLiteralExpression */; + return context.contextNode.kind === 178 /* ObjectLiteralExpression */; }; Rules.IsFunctionCallContext = function (context) { - return context.contextNode.kind === 180 /* CallExpression */; + return context.contextNode.kind === 181 /* CallExpression */; }; Rules.IsNewContext = function (context) { - return context.contextNode.kind === 181 /* NewExpression */; + return context.contextNode.kind === 182 /* NewExpression */; }; Rules.IsFunctionCallOrNewContext = function (context) { return Rules.IsFunctionCallContext(context) || Rules.IsNewContext(context); }; Rules.IsPreviousTokenNotComma = function (context) { - return context.currentTokenSpan.kind !== 25 /* CommaToken */; + return context.currentTokenSpan.kind !== 26 /* CommaToken */; }; Rules.IsNextTokenNotCloseBracket = function (context) { - return context.nextTokenSpan.kind !== 21 /* CloseBracketToken */; + return context.nextTokenSpan.kind !== 22 /* CloseBracketToken */; }; Rules.IsArrowFunctionContext = function (context) { - return context.contextNode.kind === 186 /* ArrowFunction */; + return context.contextNode.kind === 187 /* ArrowFunction */; }; Rules.IsNonJsxSameLineTokenContext = function (context) { return context.TokensAreOnSameLine() && context.contextNode.kind !== 10 /* JsxText */; }; Rules.IsNonJsxElementContext = function (context) { - return context.contextNode.kind !== 248 /* JsxElement */; + return context.contextNode.kind !== 249 /* JsxElement */; }; Rules.IsJsxExpressionContext = function (context) { - return context.contextNode.kind === 255 /* JsxExpression */; + return context.contextNode.kind === 256 /* JsxExpression */; }; Rules.IsNextTokenParentJsxAttribute = function (context) { - return context.nextTokenParent.kind === 252 /* JsxAttribute */; + return context.nextTokenParent.kind === 253 /* JsxAttribute */; }; Rules.IsJsxAttributeContext = function (context) { - return context.contextNode.kind === 252 /* JsxAttribute */; + return context.contextNode.kind === 253 /* JsxAttribute */; }; Rules.IsJsxSelfClosingElementContext = function (context) { - return context.contextNode.kind === 249 /* JsxSelfClosingElement */; + return context.contextNode.kind === 250 /* JsxSelfClosingElement */; }; Rules.IsNotBeforeBlockInFunctionDeclarationContext = function (context) { return !Rules.IsFunctionDeclContext(context) && !Rules.IsBeforeBlockContext(context); @@ -77809,42 +81335,42 @@ var ts; while (ts.isPartOfExpression(node)) { node = node.parent; } - return node.kind === 146 /* Decorator */; + return node.kind === 147 /* Decorator */; }; Rules.IsStartOfVariableDeclarationList = function (context) { - return context.currentTokenParent.kind === 226 /* VariableDeclarationList */ && + return context.currentTokenParent.kind === 227 /* 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 === 232 /* ModuleDeclaration */; + return context.contextNode.kind === 233 /* ModuleDeclaration */; }; Rules.IsObjectTypeContext = function (context) { - return context.contextNode.kind === 162 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; + return context.contextNode.kind === 163 /* TypeLiteral */; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; }; Rules.IsTypeArgumentOrParameterOrAssertion = function (token, parent) { - if (token.kind !== 26 /* LessThanToken */ && token.kind !== 28 /* GreaterThanToken */) { + if (token.kind !== 27 /* LessThanToken */ && token.kind !== 29 /* GreaterThanToken */) { return false; } switch (parent.kind) { - case 158 /* TypeReference */: - case 183 /* TypeAssertionExpression */: - case 230 /* TypeAliasDeclaration */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 200 /* ExpressionWithTypeArguments */: + case 159 /* TypeReference */: + case 184 /* TypeAssertionExpression */: + case 231 /* TypeAliasDeclaration */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 201 /* ExpressionWithTypeArguments */: return true; default: return false; @@ -77855,16 +81381,16 @@ var ts; Rules.IsTypeArgumentOrParameterOrAssertion(context.nextTokenSpan, context.nextTokenParent); }; Rules.IsTypeAssertionContext = function (context) { - return context.contextNode.kind === 183 /* TypeAssertionExpression */; + return context.contextNode.kind === 184 /* TypeAssertionExpression */; }; Rules.IsVoidOpContext = function (context) { - return context.currentTokenSpan.kind === 104 /* VoidKeyword */ && context.currentTokenParent.kind === 189 /* VoidExpression */; + return context.currentTokenSpan.kind === 105 /* VoidKeyword */ && context.currentTokenParent.kind === 190 /* VoidExpression */; }; Rules.IsYieldOrYieldStarWithOperand = function (context) { - return context.contextNode.kind === 196 /* YieldExpression */ && context.contextNode.expression !== undefined; + return context.contextNode.kind === 197 /* YieldExpression */ && context.contextNode.expression !== undefined; }; Rules.IsNonNullAssertionContext = function (context) { - return context.contextNode.kind === 202 /* NonNullExpression */; + return context.contextNode.kind === 203 /* NonNullExpression */; }; return Rules; }()); @@ -77888,7 +81414,7 @@ var ts; return result; }; RulesMap.prototype.Initialize = function (rules) { - this.mapRowLength = 141 /* LastToken */ + 1; + this.mapRowLength = 142 /* 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); @@ -77902,7 +81428,7 @@ var ts; }); }; RulesMap.prototype.GetRuleBucketIndex = function (row, column) { - ts.Debug.assert(row <= 141 /* LastKeyword */ && column <= 141 /* LastKeyword */, "Must compute formatting context from tokens"); + ts.Debug.assert(row <= 142 /* LastKeyword */ && column <= 142 /* LastKeyword */, "Must compute formatting context from tokens"); var rulesBucketIndex = (row * this.mapRowLength) + column; return rulesBucketIndex; }; @@ -78083,7 +81609,7 @@ var ts; } TokenAllAccess.prototype.GetTokens = function () { var result = []; - for (var token = 0 /* FirstToken */; token <= 141 /* LastToken */; token++) { + for (var token = 0 /* FirstToken */; token <= 142 /* LastToken */; token++) { result.push(token); } return result; @@ -78127,17 +81653,17 @@ var ts; }()); TokenRange.Any = TokenRange.AllTokens(); TokenRange.AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([3 /* MultiLineCommentTrivia */])); - TokenRange.Keywords = TokenRange.FromRange(71 /* FirstKeyword */, 141 /* LastKeyword */); - TokenRange.BinaryOperators = TokenRange.FromRange(26 /* FirstBinaryOperator */, 69 /* LastBinaryOperator */); - TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([91 /* InKeyword */, 92 /* InstanceOfKeyword */, 141 /* OfKeyword */, 117 /* AsKeyword */, 125 /* IsKeyword */]); - TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([42 /* PlusPlusToken */, 43 /* MinusMinusToken */, 51 /* TildeToken */, 50 /* ExclamationToken */]); - TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 70 /* Identifier */, 18 /* OpenParenToken */, 20 /* OpenBracketToken */, 16 /* OpenBraceToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); - TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); - TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); - TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 18 /* OpenParenToken */, 98 /* ThisKeyword */, 93 /* NewKeyword */]); - TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([70 /* Identifier */, 19 /* CloseParenToken */, 21 /* CloseBracketToken */, 93 /* NewKeyword */]); + TokenRange.Keywords = TokenRange.FromRange(72 /* FirstKeyword */, 142 /* LastKeyword */); + TokenRange.BinaryOperators = TokenRange.FromRange(27 /* FirstBinaryOperator */, 70 /* LastBinaryOperator */); + TokenRange.BinaryKeywordOperators = TokenRange.FromTokens([92 /* InKeyword */, 93 /* InstanceOfKeyword */, 142 /* OfKeyword */, 118 /* AsKeyword */, 126 /* IsKeyword */]); + TokenRange.UnaryPrefixOperators = TokenRange.FromTokens([43 /* PlusPlusToken */, 44 /* MinusMinusToken */, 52 /* TildeToken */, 51 /* ExclamationToken */]); + TokenRange.UnaryPrefixExpressions = TokenRange.FromTokens([8 /* NumericLiteral */, 71 /* Identifier */, 19 /* OpenParenToken */, 21 /* OpenBracketToken */, 17 /* OpenBraceToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]); + TokenRange.UnaryPreincrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]); + TokenRange.UnaryPostincrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]); + TokenRange.UnaryPredecrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 19 /* OpenParenToken */, 99 /* ThisKeyword */, 94 /* NewKeyword */]); + TokenRange.UnaryPostdecrementExpressions = TokenRange.FromTokens([71 /* Identifier */, 20 /* CloseParenToken */, 22 /* CloseBracketToken */, 94 /* NewKeyword */]); TokenRange.Comments = TokenRange.FromTokens([2 /* SingleLineCommentTrivia */, 3 /* MultiLineCommentTrivia */]); - TokenRange.TypeNames = TokenRange.FromTokens([70 /* Identifier */, 132 /* NumberKeyword */, 135 /* StringKeyword */, 121 /* BooleanKeyword */, 136 /* SymbolKeyword */, 104 /* VoidKeyword */, 118 /* AnyKeyword */]); + TokenRange.TypeNames = TokenRange.FromTokens([71 /* Identifier */, 133 /* NumberKeyword */, 136 /* StringKeyword */, 122 /* BooleanKeyword */, 137 /* SymbolKeyword */, 105 /* VoidKeyword */, 119 /* AnyKeyword */]); Shared.TokenRange = TokenRange; })(Shared = formatting.Shared || (formatting.Shared = {})); })(formatting = ts.formatting || (ts.formatting = {})); @@ -78173,6 +81699,9 @@ var ts; RulesProvider.prototype.getRulesMap = function () { return this.rulesMap; }; + RulesProvider.prototype.getFormatOptions = function () { + return this.options; + }; RulesProvider.prototype.ensureUpToDate = function (options) { if (!this.options || !ts.compareDataObjects(this.options, options)) { var activeRules = this.createActiveRules(options); @@ -78340,11 +81869,11 @@ var ts; } formatting.formatOnEnter = formatOnEnter; function formatOnSemicolon(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 24 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); + return formatOutermostParent(position, 25 /* SemicolonToken */, sourceFile, options, rulesProvider, 3 /* FormatOnSemicolon */); } formatting.formatOnSemicolon = formatOnSemicolon; function formatOnClosingCurly(position, sourceFile, rulesProvider, options) { - return formatOutermostParent(position, 17 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); + return formatOutermostParent(position, 18 /* CloseBraceToken */, sourceFile, options, rulesProvider, 4 /* FormatOnClosingCurlyBrace */); } formatting.formatOnClosingCurly = formatOnClosingCurly; function formatDocument(sourceFile, rulesProvider, options) { @@ -78408,17 +81937,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 228 /* ClassDeclaration */: - case 229 /* InterfaceDeclaration */: + case 229 /* ClassDeclaration */: + case 230 /* InterfaceDeclaration */: return ts.rangeContainsRange(parent.members, node); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: var body = parent.body; - return body && body.kind === 233 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); - case 264 /* SourceFile */: - case 206 /* Block */: - case 233 /* ModuleBlock */: + return body && body.kind === 234 /* ModuleBlock */ && ts.rangeContainsRange(body.statements, node); + case 265 /* SourceFile */: + case 207 /* Block */: + case 234 /* ModuleBlock */: return ts.rangeContainsRange(parent.statements, node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return ts.rangeContainsRange(parent.block.statements, node); } return false; @@ -78438,9 +81967,9 @@ var ts; } } /** formatting is not applied to ranges that contain parse errors. - * This function will return a predicate that for a given text range will tell - * if there are any parse errors that overlap with the range. - */ + * This function will return a predicate that for a given text range will tell + * if there are any parse errors that overlap with the range. + */ function prepareRangeContainsErrorFunction(errors, originalRange) { if (!errors.length) { return rangeHasNoErrors; @@ -78478,10 +82007,10 @@ var ts; } } /** - * Start of the original range might fall inside the comment - scanner will not yield appropriate results - * This function will look for token that is located before the start of target range - * and return its end as start position for the scanner. - */ + * Start of the original range might fall inside the comment - scanner will not yield appropriate results + * This function will look for token that is located before the start of target range + * and return its end as start position for the scanner. + */ function getScanStartPosition(enclosingNode, originalRange, sourceFile) { var start = enclosingNode.getStart(sourceFile); if (start === originalRange.pos && enclosingNode.end === originalRange.end) { @@ -78531,14 +82060,21 @@ var ts; } return 0; } + /* @internal */ + function formatNode(node, sourceFileLike, languageVariant, initialIndentation, delta, rulesProvider) { + var range = { pos: 0, end: sourceFileLike.text.length }; + return formatSpanWorker(range, node, initialIndentation, delta, formatting.getFormattingScanner(sourceFileLike.text, languageVariant, range.pos, range.end), rulesProvider.getFormatOptions(), rulesProvider, 1 /* FormatSelection */, function (_) { return false; }, // assume that node does not have any errors + sourceFileLike); + } + formatting.formatNode = formatNode; function formatSpan(originalRange, sourceFile, options, rulesProvider, requestKind) { - var rangeContainsError = prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange); - // formatting context is used by rules provider - var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); // find the smallest node that fully wraps the range and compute the initial indentation for the node var enclosingNode = findEnclosingNode(originalRange, sourceFile); - var formattingScanner = formatting.getFormattingScanner(sourceFile, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end); - var initialIndentation = formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options); + return formatSpanWorker(originalRange, enclosingNode, formatting.SmartIndenter.getIndentationForNode(enclosingNode, originalRange, sourceFile, options), getOwnOrInheritedDelta(enclosingNode, options, sourceFile), formatting.getFormattingScanner(sourceFile.text, sourceFile.languageVariant, getScanStartPosition(enclosingNode, originalRange, sourceFile), originalRange.end), options, rulesProvider, requestKind, prepareRangeContainsErrorFunction(sourceFile.parseDiagnostics, originalRange), sourceFile); + } + function formatSpanWorker(originalRange, enclosingNode, initialIndentation, delta, formattingScanner, options, rulesProvider, requestKind, rangeContainsError, sourceFile) { + // formatting context is used by rules provider + var formattingContext = new formatting.FormattingContext(sourceFile, requestKind); var previousRangeHasError; var previousRange; var previousParent; @@ -78553,13 +82089,12 @@ var ts; if (enclosingNode.decorators) { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(ts.getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } - var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile); processNode(enclosingNode, enclosingNode, startLine, undecoratedStartLine, initialIndentation, delta); } if (!formattingScanner.isOnToken()) { var leadingTrivia = formattingScanner.getCurrentLeadingTrivia(); if (leadingTrivia) { - processTrivia(leadingTrivia, enclosingNode, enclosingNode, undefined); + processTrivia(leadingTrivia, enclosingNode, enclosingNode, /*dynamicIndentation*/ undefined); trimTrailingWhitespacesForRemainingRange(); } } @@ -78567,12 +82102,12 @@ var ts; return edits; // local functions /** Tries to compute the indentation for a list element. - * If list element is not in range then - * function will pick its actual indentation - * so it can be pushed downstream as inherited indentation. - * If list element is in the range - its indentation will be equal - * to inherited indentation from its predecessors. - */ + * If list element is not in range then + * function will pick its actual indentation + * so it can be pushed downstream as inherited indentation. + * If list element is in the range - its indentation will be equal + * to inherited indentation from its predecessors. + */ function tryComputeIndentationForListItem(startPos, endPos, parentStartLine, range, inheritedIndentation) { if (ts.rangeOverlapsWithStartEnd(range, startPos, endPos) || ts.rangeContainsStartEnd(range, startPos, endPos) /* Not to miss zero-range nodes e.g. JsxText */) { @@ -78623,20 +82158,19 @@ var ts; return node.modifiers[0].kind; } switch (node.kind) { - case 228 /* ClassDeclaration */: return 74 /* ClassKeyword */; - case 229 /* InterfaceDeclaration */: return 108 /* InterfaceKeyword */; - case 227 /* FunctionDeclaration */: return 88 /* FunctionKeyword */; - case 231 /* EnumDeclaration */: return 231 /* EnumDeclaration */; - case 152 /* GetAccessor */: return 124 /* GetKeyword */; - case 153 /* SetAccessor */: return 134 /* SetKeyword */; - case 150 /* MethodDeclaration */: + case 229 /* ClassDeclaration */: return 75 /* ClassKeyword */; + case 230 /* InterfaceDeclaration */: return 109 /* InterfaceKeyword */; + case 228 /* FunctionDeclaration */: return 89 /* FunctionKeyword */; + case 232 /* EnumDeclaration */: return 232 /* EnumDeclaration */; + case 153 /* GetAccessor */: return 125 /* GetKeyword */; + case 154 /* SetAccessor */: return 135 /* SetKeyword */; + case 151 /* MethodDeclaration */: if (node.asteriskToken) { - return 38 /* AsteriskToken */; - } /* - fall-through - */ - case 148 /* PropertyDeclaration */: - case 145 /* Parameter */: + return 39 /* AsteriskToken */; + } + // falls through + case 149 /* PropertyDeclaration */: + case 146 /* Parameter */: return node.name.kind; } } @@ -78648,9 +82182,9 @@ var ts; // .. { // // comment // } - case 17 /* CloseBraceToken */: - case 21 /* CloseBracketToken */: - case 19 /* CloseParenToken */: + case 18 /* CloseBraceToken */: + case 22 /* CloseBracketToken */: + case 20 /* CloseParenToken */: return indentation + getEffectiveDelta(delta, container); } return tokenIndentation !== -1 /* Unknown */ ? tokenIndentation : indentation; @@ -78664,26 +82198,26 @@ var ts; } switch (kind) { // open and close brace, 'else' and 'while' (in do statement) tokens has indentation of the parent - case 16 /* OpenBraceToken */: - case 17 /* CloseBraceToken */: - case 18 /* OpenParenToken */: - case 19 /* CloseParenToken */: - case 81 /* ElseKeyword */: - case 105 /* WhileKeyword */: - case 56 /* AtToken */: + case 17 /* OpenBraceToken */: + case 18 /* CloseBraceToken */: + case 19 /* OpenParenToken */: + case 20 /* CloseParenToken */: + case 82 /* ElseKeyword */: + case 106 /* WhileKeyword */: + case 57 /* AtToken */: return indentation; - case 40 /* SlashToken */: - case 28 /* GreaterThanToken */: { - if (container.kind === 250 /* JsxOpeningElement */ || - container.kind === 251 /* JsxClosingElement */ || - container.kind === 249 /* JsxSelfClosingElement */) { + case 41 /* SlashToken */: + case 29 /* GreaterThanToken */: { + if (container.kind === 251 /* JsxOpeningElement */ || + container.kind === 252 /* JsxClosingElement */ || + container.kind === 250 /* JsxSelfClosingElement */) { return indentation; } break; } - case 20 /* OpenBracketToken */: - case 21 /* CloseBracketToken */: { - if (container.kind !== 171 /* MappedType */) { + case 21 /* OpenBracketToken */: + case 22 /* CloseBracketToken */: { + if (container.kind !== 172 /* MappedType */) { return indentation; } break; @@ -78713,7 +82247,7 @@ var ts; }; function getEffectiveDelta(delta, child) { // Delta value should be zero when the node explicitly prevents indentation of the child node - return formatting.SmartIndenter.nodeWillIndentChild(node, child, true) ? delta : 0; + return formatting.SmartIndenter.nodeWillIndentChild(node, child, /*indentByDefault*/ true) ? delta : 0; } } function processNode(node, contextNode, nodeStartLine, undecoratedNodeStartLine, indentation, delta) { @@ -78793,11 +82327,11 @@ var ts; consumeTokenAndAdvanceScanner(tokenInfo, node, parentDynamicIndentation, child); return inheritedIndentation; } - var effectiveParentStartLine = child.kind === 146 /* Decorator */ ? childStartLine : undecoratedParentStartLine; + var effectiveParentStartLine = child.kind === 147 /* Decorator */ ? childStartLine : undecoratedParentStartLine; var childIndentation = computeIndentation(child, childStartLine, childIndentationAmount, node, parentDynamicIndentation, effectiveParentStartLine); processNode(child, childContextNode, childStartLine, undecoratedChildStartLine, childIndentation.indentation, childIndentation.delta); childContextNode = node; - if (isFirstListItem && parent.kind === 176 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { + if (isFirstListItem && parent.kind === 177 /* ArrayLiteralExpression */ && inheritedIndentation === -1 /* Unknown */) { inheritedIndentation = childIndentation.indentation; } return inheritedIndentation; @@ -79154,41 +82688,41 @@ var ts; } function getOpenTokenForList(node, list) { switch (node.kind) { - case 151 /* Constructor */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 186 /* ArrowFunction */: + case 152 /* Constructor */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 187 /* ArrowFunction */: if (node.typeParameters === list) { - return 26 /* LessThanToken */; + return 27 /* LessThanToken */; } else if (node.parameters === list) { - return 18 /* OpenParenToken */; + return 19 /* OpenParenToken */; } break; - case 180 /* CallExpression */: - case 181 /* NewExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: if (node.typeArguments === list) { - return 26 /* LessThanToken */; + return 27 /* LessThanToken */; } else if (node.arguments === list) { - return 18 /* OpenParenToken */; + return 19 /* OpenParenToken */; } break; - case 158 /* TypeReference */: + case 159 /* TypeReference */: if (node.typeArguments === list) { - return 26 /* LessThanToken */; + return 27 /* LessThanToken */; } } return 0 /* Unknown */; } function getCloseTokenForOpenToken(kind) { switch (kind) { - case 18 /* OpenParenToken */: - return 19 /* CloseParenToken */; - case 26 /* LessThanToken */: - return 28 /* GreaterThanToken */; + case 19 /* OpenParenToken */: + return 20 /* CloseParenToken */; + case 27 /* LessThanToken */: + return 29 /* GreaterThanToken */; } return 0 /* Unknown */; } @@ -79256,7 +82790,20 @@ var ts; (function (Value) { Value[Value["Unknown"] = -1] = "Unknown"; })(Value || (Value = {})); - function getIndentation(position, sourceFile, options) { + /** + * Computed indentation for a given position in source file + * @param position - position in file + * @param sourceFile - target source file + * @param options - set of editor options that control indentation + * @param assumeNewLineBeforeCloseBrace - false when getIndentation is called on the text from the real source file. + * true - when we need to assume that position is on the newline. This is usefult for codefixes, i.e. + * function f() { + * |} + * when inserting some text after open brace we would like to get the value of indentation as if newline was already there. + * However by default indentation at position | will be 0 so 'assumeNewLineBeforeCloseBrace' allows to override this behavior, + */ + function getIndentation(position, sourceFile, options, assumeNewLineBeforeCloseBrace) { + if (assumeNewLineBeforeCloseBrace === void 0) { assumeNewLineBeforeCloseBrace = false; } if (position > sourceFile.text.length) { return getBaseIndentation(options); // past EOF } @@ -79284,7 +82831,7 @@ var ts; var current_1 = position; while (current_1 > 0) { var char = sourceFile.text.charCodeAt(current_1); - if (!ts.isWhiteSpace(char)) { + if (!ts.isWhiteSpaceLike(char)) { break; } current_1--; @@ -79292,7 +82839,7 @@ var ts; var lineStart = ts.getLineStartPositionForPosition(current_1, sourceFile); return SmartIndenter.findFirstNonWhitespaceColumn(lineStart, current_1, sourceFile, options); } - if (precedingToken.kind === 25 /* CommaToken */ && precedingToken.parent.kind !== 193 /* BinaryExpression */) { + if (precedingToken.kind === 26 /* CommaToken */ && precedingToken.parent.kind !== 194 /* 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 */) { @@ -79308,8 +82855,10 @@ var ts; while (current) { if (ts.positionBelongsToNode(current, position, sourceFile) && shouldIndentChildNode(current, previous)) { currentStart = getStartLineAndCharacterForNode(current, sourceFile); - if (nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile)) { - indentationDelta = 0; + var nextTokenKind = nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile); + if (nextTokenKind !== 0 /* Unknown */) { + // handle cases when codefix is about to be inserted before the close brace + indentationDelta = assumeNewLineBeforeCloseBrace && nextTokenKind === 2 /* CloseBrace */ ? options.indentSize : 0; } else { indentationDelta = lineAtPosition !== currentStart.line ? options.indentSize : 0; @@ -79415,22 +82964,28 @@ 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.isStatementButNotDeclaration(current)) && - (parent.kind === 264 /* SourceFile */ || !parentAndChildShareLine); + (parent.kind === 265 /* SourceFile */ || !parentAndChildShareLine); if (!useActualIndentation) { return -1 /* Unknown */; } return findColumnForFirstNonWhitespaceCharacterInLine(currentLineAndChar, sourceFile, options); } + var NextTokenKind; + (function (NextTokenKind) { + NextTokenKind[NextTokenKind["Unknown"] = 0] = "Unknown"; + NextTokenKind[NextTokenKind["OpenBrace"] = 1] = "OpenBrace"; + NextTokenKind[NextTokenKind["CloseBrace"] = 2] = "CloseBrace"; + })(NextTokenKind || (NextTokenKind = {})); function nextTokenIsCurlyBraceOnSameLineAsCursor(precedingToken, current, lineAtPosition, sourceFile) { var nextToken = ts.findNextToken(precedingToken, current); if (!nextToken) { - return false; + return 0 /* Unknown */; } - if (nextToken.kind === 16 /* OpenBraceToken */) { + if (nextToken.kind === 17 /* OpenBraceToken */) { // open braces are always indented at the parent level - return true; + return 1 /* OpenBrace */; } - else if (nextToken.kind === 17 /* CloseBraceToken */) { + else if (nextToken.kind === 18 /* CloseBraceToken */) { // close braces are indented at the parent level if they are located on the same line with cursor // this means that if new line will be added at $ position, this case will be indented // class A { @@ -79440,16 +82995,16 @@ var ts; // class A { // $} var nextTokenStartLine = getStartLineAndCharacterForNode(nextToken, sourceFile).line; - return lineAtPosition === nextTokenStartLine; + return lineAtPosition === nextTokenStartLine ? 2 /* CloseBrace */ : 0 /* Unknown */; } - return false; + return 0 /* Unknown */; } function getStartLineAndCharacterForNode(n, sourceFile) { return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)); } function childStartsOnTheSameLineWithElseInIfStatement(parent, child, childStartLine, sourceFile) { - if (parent.kind === 210 /* IfStatement */ && parent.elseStatement === child) { - var elseKeyword = ts.findChildOfKind(parent, 81 /* ElseKeyword */, sourceFile); + if (parent.kind === 211 /* IfStatement */ && parent.elseStatement === child) { + var elseKeyword = ts.findChildOfKind(parent, 82 /* ElseKeyword */, sourceFile); ts.Debug.assert(elseKeyword !== undefined); var elseKeywordStartLine = getStartLineAndCharacterForNode(elseKeyword, sourceFile).line; return elseKeywordStartLine === childStartLine; @@ -79457,53 +83012,49 @@ var ts; return false; } SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement = childStartsOnTheSameLineWithElseInIfStatement; + function getListIfStartEndIsInListRange(list, start, end) { + return list && ts.rangeContainsStartEnd(list, start, end) ? list : undefined; + } function getContainingList(node, sourceFile) { if (node.parent) { switch (node.parent.kind) { - case 158 /* TypeReference */: - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd())) { - return node.parent.typeArguments; - } - break; - case 177 /* ObjectLiteralExpression */: + case 159 /* TypeReference */: + return getListIfStartEndIsInListRange(node.parent.typeArguments, node.getStart(sourceFile), node.getEnd()); + case 178 /* ObjectLiteralExpression */: return node.parent.properties; - case 176 /* ArrayLiteralExpression */: + case 177 /* ArrayLiteralExpression */: return node.parent.elements; - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: { + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 152 /* Constructor */: + case 161 /* ConstructorType */: + case 156 /* ConstructSignature */: { var start = node.getStart(sourceFile); - if (node.parent.typeParameters && - ts.rangeContainsStartEnd(node.parent.typeParameters, start, node.getEnd())) { - return node.parent.typeParameters; - } - if (ts.rangeContainsStartEnd(node.parent.parameters, start, node.getEnd())) { - return node.parent.parameters; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeParameters, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.parameters, start, node.getEnd()); } - case 181 /* NewExpression */: - case 180 /* CallExpression */: { + case 229 /* ClassDeclaration */: + return getListIfStartEndIsInListRange(node.parent.typeParameters, node.getStart(sourceFile), node.getEnd()); + case 182 /* NewExpression */: + case 181 /* CallExpression */: { var start = node.getStart(sourceFile); - if (node.parent.typeArguments && - ts.rangeContainsStartEnd(node.parent.typeArguments, start, node.getEnd())) { - return node.parent.typeArguments; - } - if (node.parent.arguments && - ts.rangeContainsStartEnd(node.parent.arguments, start, node.getEnd())) { - return node.parent.arguments; - } - break; + return getListIfStartEndIsInListRange(node.parent.typeArguments, start, node.getEnd()) || + getListIfStartEndIsInListRange(node.parent.arguments, start, node.getEnd()); } + case 227 /* VariableDeclarationList */: + return getListIfStartEndIsInListRange(node.parent.declarations, node.getStart(sourceFile), node.getEnd()); + case 241 /* NamedImports */: + case 245 /* NamedExports */: + return getListIfStartEndIsInListRange(node.parent.elements, node.getStart(sourceFile), node.getEnd()); } } return undefined; } + SmartIndenter.getContainingList = getContainingList; function getActualIndentationForListItem(node, sourceFile, options) { var containingList = getContainingList(node, sourceFile); return containingList ? getActualIndentationFromList(containingList) : -1 /* Unknown */; @@ -79515,11 +83066,11 @@ var ts; function getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options) { // actual indentation should not be used when: // - node is close parenthesis - this is the end of the expression - if (node.kind === 19 /* CloseParenToken */) { + if (node.kind === 20 /* CloseParenToken */) { return -1 /* Unknown */; } - if (node.parent && (node.parent.kind === 180 /* CallExpression */ || - node.parent.kind === 181 /* NewExpression */) && + if (node.parent && (node.parent.kind === 181 /* CallExpression */ || + node.parent.kind === 182 /* NewExpression */) && node.parent.expression !== node) { var fullCallOrNewExpression = node.parent.expression; var startingExpression = getStartingExpression(fullCallOrNewExpression); @@ -79537,10 +83088,10 @@ var ts; function getStartingExpression(node) { while (true) { switch (node.kind) { - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 178 /* PropertyAccessExpression */: - case 179 /* ElementAccessExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 179 /* PropertyAccessExpression */: + case 180 /* ElementAccessExpression */: node = node.expression; break; default: @@ -79556,7 +83107,7 @@ var ts; // if end line for item [i - 1] differs from the start line for item [i] - find column of the first non-whitespace character on the line of item [i] var lineAndCharacter = getStartLineAndCharacterForNode(node, sourceFile); for (var i = index - 1; i >= 0; i--) { - if (list[i].kind === 25 /* CommaToken */) { + if (list[i].kind === 26 /* CommaToken */) { continue; } // skip list items that ends on the same line with the current list element @@ -79604,49 +83155,49 @@ var ts; SmartIndenter.findFirstNonWhitespaceColumn = findFirstNonWhitespaceColumn; function nodeContentIsAlwaysIndented(kind) { switch (kind) { - case 209 /* ExpressionStatement */: - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 231 /* EnumDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 176 /* ArrayLiteralExpression */: - case 206 /* Block */: - case 233 /* ModuleBlock */: - case 177 /* ObjectLiteralExpression */: - case 162 /* TypeLiteral */: - case 171 /* MappedType */: - case 164 /* TupleType */: - case 234 /* CaseBlock */: - case 257 /* DefaultClause */: - case 256 /* CaseClause */: - case 184 /* ParenthesizedExpression */: - case 178 /* PropertyAccessExpression */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 207 /* VariableStatement */: - case 225 /* VariableDeclaration */: - case 242 /* ExportAssignment */: - case 218 /* ReturnStatement */: - case 194 /* ConditionalExpression */: - case 174 /* ArrayBindingPattern */: - case 173 /* ObjectBindingPattern */: - case 250 /* JsxOpeningElement */: - case 249 /* JsxSelfClosingElement */: - case 255 /* JsxExpression */: - case 149 /* MethodSignature */: - case 154 /* CallSignature */: - case 155 /* ConstructSignature */: - case 145 /* Parameter */: - case 159 /* FunctionType */: - case 160 /* ConstructorType */: - case 167 /* ParenthesizedType */: - case 182 /* TaggedTemplateExpression */: - case 190 /* AwaitExpression */: - case 244 /* NamedExports */: - case 240 /* NamedImports */: - case 245 /* ExportSpecifier */: - case 241 /* ImportSpecifier */: + case 210 /* ExpressionStatement */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 232 /* EnumDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 177 /* ArrayLiteralExpression */: + case 207 /* Block */: + case 234 /* ModuleBlock */: + case 178 /* ObjectLiteralExpression */: + case 163 /* TypeLiteral */: + case 172 /* MappedType */: + case 165 /* TupleType */: + case 235 /* CaseBlock */: + case 258 /* DefaultClause */: + case 257 /* CaseClause */: + case 185 /* ParenthesizedExpression */: + case 179 /* PropertyAccessExpression */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 208 /* VariableStatement */: + case 226 /* VariableDeclaration */: + case 243 /* ExportAssignment */: + case 219 /* ReturnStatement */: + case 195 /* ConditionalExpression */: + case 175 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 251 /* JsxOpeningElement */: + case 250 /* JsxSelfClosingElement */: + case 256 /* JsxExpression */: + case 150 /* MethodSignature */: + case 155 /* CallSignature */: + case 156 /* ConstructSignature */: + case 146 /* Parameter */: + case 160 /* FunctionType */: + case 161 /* ConstructorType */: + case 168 /* ParenthesizedType */: + case 183 /* TaggedTemplateExpression */: + case 191 /* AwaitExpression */: + case 245 /* NamedExports */: + case 241 /* NamedImports */: + case 246 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: return true; } return false; @@ -79655,27 +83206,27 @@ var ts; function nodeWillIndentChild(parent, child, indentByDefault) { var childKind = child ? child.kind : 0 /* Unknown */; switch (parent.kind) { - case 211 /* DoStatement */: - case 212 /* WhileStatement */: - case 214 /* ForInStatement */: - case 215 /* ForOfStatement */: - case 213 /* ForStatement */: - case 210 /* IfStatement */: - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 186 /* ArrowFunction */: - case 151 /* Constructor */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - return childKind !== 206 /* Block */; - case 243 /* ExportDeclaration */: - return childKind !== 244 /* NamedExports */; - case 237 /* ImportDeclaration */: - return childKind !== 238 /* ImportClause */ || - (child.namedBindings && child.namedBindings.kind !== 240 /* NamedImports */); - case 248 /* JsxElement */: - return childKind !== 251 /* JsxClosingElement */; + case 212 /* DoStatement */: + case 213 /* WhileStatement */: + case 215 /* ForInStatement */: + case 216 /* ForOfStatement */: + case 214 /* ForStatement */: + case 211 /* IfStatement */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 187 /* ArrowFunction */: + case 152 /* Constructor */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + return childKind !== 207 /* Block */; + case 244 /* ExportDeclaration */: + return childKind !== 245 /* NamedExports */; + case 238 /* ImportDeclaration */: + return childKind !== 239 /* ImportClause */ || + (child.namedBindings && child.namedBindings.kind !== 241 /* NamedImports */); + case 249 /* JsxElement */: + return childKind !== 252 /* JsxClosingElement */; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; @@ -79693,6 +83244,585 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var textChanges; + (function (textChanges) { + /** + * Currently for simplicity we store recovered positions on the node itself. + * It can be changed to side-table later if we decide that current design is too invasive. + */ + function getPos(n) { + return n["__pos"]; + } + function setPos(n, pos) { + n["__pos"] = pos; + } + function getEnd(n) { + return n["__end"]; + } + function setEnd(n, end) { + n["__end"] = end; + } + var Position; + (function (Position) { + Position[Position["FullStart"] = 0] = "FullStart"; + Position[Position["Start"] = 1] = "Start"; + })(Position = textChanges.Position || (textChanges.Position = {})); + function skipWhitespacesAndLineBreaks(text, start) { + return ts.skipTrivia(text, start, /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + } + function hasCommentsBeforeLineBreak(text, start) { + var i = start; + while (i < text.length) { + var ch = text.charCodeAt(i); + if (ts.isWhiteSpaceSingleLine(ch)) { + i++; + continue; + } + return ch === 47 /* slash */; + } + return false; + } + function getSeparatorCharacter(separator) { + return ts.tokenToString(separator.kind); + } + textChanges.getSeparatorCharacter = getSeparatorCharacter; + function getAdjustedStartPosition(sourceFile, node, options, position) { + if (options.useNonAdjustedStartPosition) { + return node.getFullStart(); + } + var fullStart = node.getFullStart(); + var start = node.getStart(sourceFile); + if (fullStart === start) { + return start; + } + var fullStartLine = ts.getLineStartPositionForPosition(fullStart, sourceFile); + var startLine = ts.getLineStartPositionForPosition(start, sourceFile); + if (startLine === fullStartLine) { + // full start and start of the node are on the same line + // a, b; + // ^ ^ + // | start + // fullstart + // when b is replaced - we usually want to keep the leading trvia + // when b is deleted - we delete it + return position === Position.Start ? start : fullStart; + } + // get start position of the line following the line that contains fullstart position + var adjustedStartPosition = ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, fullStartLine) + 1, sourceFile); + // skip whitespaces/newlines + adjustedStartPosition = skipWhitespacesAndLineBreaks(sourceFile.text, adjustedStartPosition); + return ts.getStartPositionOfLine(ts.getLineOfLocalPosition(sourceFile, adjustedStartPosition), sourceFile); + } + textChanges.getAdjustedStartPosition = getAdjustedStartPosition; + function getAdjustedEndPosition(sourceFile, node, options) { + if (options.useNonAdjustedEndPosition) { + return node.getEnd(); + } + var end = node.getEnd(); + var newEnd = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true); + // check if last character before newPos is linebreak + // if yes - considered all skipped trivia to be trailing trivia of the node + return newEnd !== end && ts.isLineBreak(sourceFile.text.charCodeAt(newEnd - 1)) + ? newEnd + : end; + } + textChanges.getAdjustedEndPosition = getAdjustedEndPosition; + /** + * Checks if 'candidate' argument is a legal separator in the list that contains 'node' as an element + */ + function isSeparator(node, candidate) { + return candidate && node.parent && (candidate.kind === 26 /* CommaToken */ || (candidate.kind === 25 /* SemicolonToken */ && node.parent.kind === 178 /* ObjectLiteralExpression */)); + } + function spaces(count) { + var s = ""; + for (var i = 0; i < count; i++) { + s += " "; + } + return s; + } + var ChangeTracker = (function () { + function ChangeTracker(newLine, rulesProvider, validator) { + this.newLine = newLine; + this.rulesProvider = rulesProvider; + this.validator = validator; + this.changes = []; + this.newLineCharacter = ts.getNewLineCharacter({ newLine: newLine }); + } + ChangeTracker.fromCodeFixContext = function (context) { + return new ChangeTracker(context.newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */, context.rulesProvider); + }; + ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, node, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, node, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteRange = function (sourceFile, range) { + this.changes.push({ sourceFile: sourceFile, range: range }); + return this; + }; + ChangeTracker.prototype.deleteNodeRange = function (sourceFile, startNode, endNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.FullStart); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.deleteNodeInList = function (sourceFile, node) { + var containingList = ts.formatting.SmartIndenter.getContainingList(node, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(node); + if (index < 0) { + return this; + } + if (containingList.length === 1) { + this.deleteNode(sourceFile, node); + return this; + } + if (index !== containingList.length - 1) { + var nextToken = ts.getTokenAtPosition(sourceFile, node.end); + if (nextToken && isSeparator(node, nextToken)) { + // find first non-whitespace position in the leading trivia of the node + var startPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, node, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + var nextElement = containingList[index + 1]; + /// find first non-whitespace position in the leading trivia of the next node + var endPosition = ts.skipTrivia(sourceFile.text, getAdjustedStartPosition(sourceFile, nextElement, {}, Position.FullStart), /*stopAfterLineBreak*/ false, /*stopAtComments*/ true); + // shift next node so its first non-whitespace position will be moved to the first non-whitespace position of the deleted node + this.deleteRange(sourceFile, { pos: startPosition, end: endPosition }); + } + } + else { + var previousToken = ts.getTokenAtPosition(sourceFile, containingList[index - 1].end); + if (previousToken && isSeparator(node, previousToken)) { + this.deleteNodeRange(sourceFile, previousToken, node); + } + } + return this; + }; + ChangeTracker.prototype.replaceRange = function (sourceFile, range, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, range: range, options: options, node: newNode }); + return this; + }; + ChangeTracker.prototype.replaceNode = function (sourceFile, oldNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, oldNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, oldNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.replaceNodeRange = function (sourceFile, startNode, endNode, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, startNode, options, Position.Start); + var endPosition = getAdjustedEndPosition(sourceFile, endNode, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: endPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAt = function (sourceFile, pos, newNode, options) { + if (options === void 0) { options = {}; } + this.changes.push({ sourceFile: sourceFile, options: options, node: newNode, range: { pos: pos, end: pos } }); + return this; + }; + ChangeTracker.prototype.insertNodeBefore = function (sourceFile, before, newNode, options) { + if (options === void 0) { options = {}; } + var startPosition = getAdjustedStartPosition(sourceFile, before, options, Position.Start); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: startPosition, end: startPosition } }); + return this; + }; + ChangeTracker.prototype.insertNodeAfter = function (sourceFile, after, newNode, options) { + if (options === void 0) { options = {}; } + if ((ts.isStatementButNotDeclaration(after)) || + after.kind === 149 /* PropertyDeclaration */ || + after.kind === 148 /* PropertySignature */ || + after.kind === 150 /* MethodSignature */) { + // check if previous statement ends with semicolon + // if not - insert semicolon to preserve the code from changing the meaning due to ASI + if (sourceFile.text.charCodeAt(after.end - 1) !== 59 /* semicolon */) { + this.changes.push({ + sourceFile: sourceFile, + options: {}, + range: { pos: after.end, end: after.end }, + node: ts.createToken(25 /* SemicolonToken */) + }); + } + } + var endPosition = getAdjustedEndPosition(sourceFile, after, options); + this.changes.push({ sourceFile: sourceFile, options: options, useIndentationFromFile: true, node: newNode, range: { pos: endPosition, end: endPosition } }); + return this; + }; + /** + * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, + * i.e. arguments in arguments lists, parameters in parameter lists etc. + * Note that separators are part of the node in statements and class elements. + */ + ChangeTracker.prototype.insertNodeInListAfter = function (sourceFile, after, newNode) { + var containingList = ts.formatting.SmartIndenter.getContainingList(after, sourceFile); + if (!containingList) { + ts.Debug.fail("node is not a list element"); + return this; + } + var index = containingList.indexOf(after); + if (index < 0) { + return this; + } + var end = after.getEnd(); + if (index !== containingList.length - 1) { + // any element except the last one + // use next sibling as an anchor + var nextToken = ts.getTokenAtPosition(sourceFile, after.end); + if (nextToken && isSeparator(after, nextToken)) { + // for list + // a, b, c + // create change for adding 'e' after 'a' as + // - find start of next element after a (it is b) + // - use this start as start and end position in final change + // - build text of change by formatting the text of node + separator + whitespace trivia of b + // in multiline case it will work as + // a, + // b, + // c, + // result - '*' denotes leading trivia that will be inserted after new text (displayed as '#') + // a,* + // ***insertedtext# + // ###b, + // c, + // find line and character of the next element + var lineAndCharOfNextElement = ts.getLineAndCharacterOfPosition(sourceFile, skipWhitespacesAndLineBreaks(sourceFile.text, containingList[index + 1].getFullStart())); + // find line and character of the token that precedes next element (usually it is separator) + var lineAndCharOfNextToken = ts.getLineAndCharacterOfPosition(sourceFile, nextToken.end); + var prefix = void 0; + var startPos = void 0; + if (lineAndCharOfNextToken.line === lineAndCharOfNextElement.line) { + // next element is located on the same line with separator: + // a,$$$$b + // ^ ^ + // | |-next element + // |-separator + // where $$$ is some leading trivia + // for a newly inserted node we'll maintain the same relative position comparing to separator and replace leading trivia with spaces + // a, x,$$$$b + // ^ ^ ^ + // | | |-next element + // | |-new inserted node padded with spaces + // |-separator + startPos = nextToken.end; + prefix = spaces(lineAndCharOfNextElement.character - lineAndCharOfNextToken.character); + } + else { + // next element is located on different line that separator + // let insert position be the beginning of the line that contains next element + startPos = ts.getStartPositionOfLine(lineAndCharOfNextElement.line, sourceFile); + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: startPos, end: containingList[index + 1].getStart(sourceFile) }, + node: newNode, + useIndentationFromFile: true, + options: { + prefix: prefix, + // write separator and leading trivia of the next element as suffix + suffix: "" + ts.tokenToString(nextToken.kind) + sourceFile.text.substring(nextToken.end, containingList[index + 1].getStart(sourceFile)) + } + }); + } + } + else { + var afterStart = after.getStart(sourceFile); + var afterStartLinePosition = ts.getLineStartPositionForPosition(afterStart, sourceFile); + var separator = void 0; + var multilineList = false; + // insert element after the last element in the list that has more than one item + // pick the element preceding the after element to: + // - pick the separator + // - determine if list is a multiline + if (containingList.length === 1) { + // if list has only one element then we'll format is as multiline if node has comment in trailing trivia, or as singleline otherwise + // i.e. var x = 1 // this is x + // | new element will be inserted at this position + separator = 26 /* CommaToken */; + } + else { + // element has more than one element, pick separator from the list + var tokenBeforeInsertPosition = ts.findPrecedingToken(after.pos, sourceFile); + separator = isSeparator(after, tokenBeforeInsertPosition) ? tokenBeforeInsertPosition.kind : 26 /* CommaToken */; + // determine if list is multiline by checking lines of after element and element that precedes it. + var afterMinusOneStartLinePosition = ts.getLineStartPositionForPosition(containingList[index - 1].getStart(sourceFile), sourceFile); + multilineList = afterMinusOneStartLinePosition !== afterStartLinePosition; + } + if (hasCommentsBeforeLineBreak(sourceFile.text, after.end)) { + // in this case we'll always treat containing list as multiline + multilineList = true; + } + if (multilineList) { + // insert separator immediately following the 'after' node to preserve comments in trailing trivia + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: ts.createToken(separator), + options: {} + }); + // use the same indentation as 'after' item + var indentation = ts.formatting.SmartIndenter.findFirstNonWhitespaceColumn(afterStartLinePosition, afterStart, sourceFile, this.rulesProvider.getFormatOptions()); + // insert element before the line break on the line that contains 'after' element + var insertPos = ts.skipTrivia(sourceFile.text, end, /*stopAfterLineBreak*/ true, /*stopAtComments*/ false); + if (insertPos !== end && ts.isLineBreak(sourceFile.text.charCodeAt(insertPos - 1))) { + insertPos--; + } + this.changes.push({ + sourceFile: sourceFile, + range: { pos: insertPos, end: insertPos }, + node: newNode, + options: { indentation: indentation, prefix: this.newLineCharacter } + }); + } + else { + this.changes.push({ + sourceFile: sourceFile, + range: { pos: end, end: end }, + node: newNode, + options: { prefix: ts.tokenToString(separator) + " " } + }); + } + } + return this; + }; + ChangeTracker.prototype.getChanges = function () { + var _this = this; + var changesPerFile = ts.createFileMap(); + // group changes per file + for (var _i = 0, _a = this.changes; _i < _a.length; _i++) { + var c = _a[_i]; + var changesInFile = changesPerFile.get(c.sourceFile.path); + if (!changesInFile) { + changesPerFile.set(c.sourceFile.path, changesInFile = []); + } + changesInFile.push(c); + } + // convert changes + var fileChangesList = []; + changesPerFile.forEachValue(function (path) { + var changesInFile = changesPerFile.get(path); + var sourceFile = changesInFile[0].sourceFile; + var fileTextChanges = { fileName: sourceFile.fileName, textChanges: [] }; + for (var _i = 0, _a = ChangeTracker.normalize(changesInFile); _i < _a.length; _i++) { + var c = _a[_i]; + fileTextChanges.textChanges.push({ + span: _this.computeSpan(c, sourceFile), + newText: _this.computeNewText(c, sourceFile) + }); + } + fileChangesList.push(fileTextChanges); + }); + return fileChangesList; + }; + ChangeTracker.prototype.computeSpan = function (change, _sourceFile) { + return ts.createTextSpanFromBounds(change.range.pos, change.range.end); + }; + ChangeTracker.prototype.computeNewText = function (change, sourceFile) { + if (!change.node) { + // deletion case + return ""; + } + var options = change.options || {}; + var nonFormattedText = getNonformattedText(change.node, sourceFile, this.newLine); + if (this.validator) { + this.validator(nonFormattedText); + } + var formatOptions = this.rulesProvider.getFormatOptions(); + var pos = change.range.pos; + var posStartsLine = ts.getLineStartPositionForPosition(pos, sourceFile) === pos; + var initialIndentation = change.options.indentation !== undefined + ? change.options.indentation + : change.useIndentationFromFile + ? ts.formatting.SmartIndenter.getIndentation(change.range.pos, sourceFile, formatOptions, posStartsLine || (change.options.prefix === this.newLineCharacter)) + : 0; + var delta = change.options.delta !== undefined + ? change.options.delta + : ts.formatting.SmartIndenter.shouldIndentChildNode(change.node) + ? formatOptions.indentSize + : 0; + var text = applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, this.rulesProvider); + // strip initial indentation (spaces or tabs) if text will be inserted in the middle of the line + // however keep indentation if it is was forced + text = posStartsLine || change.options.indentation !== undefined ? text : text.replace(/^\s+/, ""); + return (options.prefix || "") + text + (options.suffix || ""); + }; + ChangeTracker.normalize = function (changes) { + // order changes by start position + var normalized = ts.stableSort(changes, function (a, b) { return a.range.pos - b.range.pos; }); + // verify that change intervals do not overlap, except possibly at end points. + for (var i = 0; i < normalized.length - 2; i++) { + ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); + } + return normalized; + }; + return ChangeTracker; + }()); + textChanges.ChangeTracker = ChangeTracker; + function getNonformattedText(node, sourceFile, newLine) { + var options = { newLine: newLine, target: sourceFile.languageVersion }; + var writer = new Writer(ts.getNewLineCharacter(options)); + var printer = ts.createPrinter(options, writer); + printer.writeNode(3 /* Unspecified */, node, sourceFile, writer); + return { text: writer.getText(), node: assignPositionsToNode(node) }; + } + textChanges.getNonformattedText = getNonformattedText; + function applyFormatting(nonFormattedText, sourceFile, initialIndentation, delta, rulesProvider) { + var lineMap = ts.computeLineStarts(nonFormattedText.text); + var file = { + text: nonFormattedText.text, + lineMap: lineMap, + getLineAndCharacterOfPosition: function (pos) { return ts.computeLineAndCharacterOfPosition(lineMap, pos); } + }; + var changes = ts.formatting.formatNode(nonFormattedText.node, file, sourceFile.languageVariant, initialIndentation, delta, rulesProvider); + return applyChanges(nonFormattedText.text, changes); + } + textChanges.applyFormatting = applyFormatting; + function applyChanges(text, changes) { + for (var i = changes.length - 1; i >= 0; i--) { + var change = changes[i]; + text = "" + text.substring(0, change.span.start) + change.newText + text.substring(ts.textSpanEnd(change.span)); + } + return text; + } + textChanges.applyChanges = applyChanges; + function isTrivia(s) { + return ts.skipTrivia(s, 0) === s.length; + } + var nullTransformationContext = { + enableEmitNotification: ts.noop, + enableSubstitution: ts.noop, + endLexicalEnvironment: function () { return undefined; }, + getCompilerOptions: ts.notImplemented, + getEmitHost: ts.notImplemented, + getEmitResolver: ts.notImplemented, + hoistFunctionDeclaration: ts.noop, + hoistVariableDeclaration: ts.noop, + isEmitNotificationEnabled: ts.notImplemented, + isSubstitutionEnabled: ts.notImplemented, + onEmitNode: ts.noop, + onSubstituteNode: ts.notImplemented, + readEmitHelpers: ts.notImplemented, + requestEmitHelper: ts.noop, + resumeLexicalEnvironment: ts.noop, + startLexicalEnvironment: ts.noop, + suspendLexicalEnvironment: ts.noop + }; + function assignPositionsToNode(node) { + var visited = ts.visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); + // create proxy node for non synthesized nodes + var newNode = ts.nodeIsSynthesized(visited) + ? visited + : (Proxy.prototype = visited, new Proxy()); + newNode.pos = getPos(node); + newNode.end = getEnd(node); + return newNode; + function Proxy() { } + } + function assignPositionsToNodeArray(nodes, visitor, test, start, count) { + var visited = ts.visitNodes(nodes, visitor, test, start, count); + if (!visited) { + return visited; + } + // clone nodearray if necessary + var nodeArray = visited === nodes ? ts.createNodeArray(visited.slice(0)) : visited; + nodeArray.pos = getPos(nodes); + nodeArray.end = getEnd(nodes); + return nodeArray; + } + var Writer = (function () { + function Writer(newLine) { + var _this = this; + this.lastNonTriviaPosition = 0; + this.writer = ts.createTextWriter(newLine); + this.onEmitNode = function (hint, node, printCallback) { + if (node) { + setPos(node, _this.lastNonTriviaPosition); + } + printCallback(hint, node); + if (node) { + setEnd(node, _this.lastNonTriviaPosition); + } + }; + this.onBeforeEmitNodeArray = function (nodes) { + if (nodes) { + setPos(nodes, _this.lastNonTriviaPosition); + } + }; + this.onAfterEmitNodeArray = function (nodes) { + if (nodes) { + setEnd(nodes, _this.lastNonTriviaPosition); + } + }; + } + Writer.prototype.setLastNonTriviaPosition = function (s, force) { + if (force || !isTrivia(s)) { + this.lastNonTriviaPosition = this.writer.getTextPos(); + var i = 0; + while (ts.isWhiteSpaceLike(s.charCodeAt(s.length - i - 1))) { + i++; + } + // trim trailing whitespaces + this.lastNonTriviaPosition -= i; + } + }; + Writer.prototype.write = function (s) { + this.writer.write(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; + Writer.prototype.writeTextOfNode = function (text, node) { + this.writer.writeTextOfNode(text, node); + }; + Writer.prototype.writeLine = function () { + this.writer.writeLine(); + }; + Writer.prototype.increaseIndent = function () { + this.writer.increaseIndent(); + }; + Writer.prototype.decreaseIndent = function () { + this.writer.decreaseIndent(); + }; + Writer.prototype.getText = function () { + return this.writer.getText(); + }; + Writer.prototype.rawWrite = function (s) { + this.writer.rawWrite(s); + this.setLastNonTriviaPosition(s, /*force*/ false); + }; + Writer.prototype.writeLiteral = function (s) { + this.writer.writeLiteral(s); + this.setLastNonTriviaPosition(s, /*force*/ true); + }; + Writer.prototype.getTextPos = function () { + return this.writer.getTextPos(); + }; + Writer.prototype.getLine = function () { + return this.writer.getLine(); + }; + Writer.prototype.getColumn = function () { + return this.writer.getColumn(); + }; + Writer.prototype.getIndent = function () { + return this.writer.getIndent(); + }; + Writer.prototype.isAtStartOfLine = function () { + return this.writer.isAtStartOfLine(); + }; + Writer.prototype.reset = function () { + this.writer.reset(); + this.lastNonTriviaPosition = 0; + }; + return Writer; + }()); + })(textChanges = ts.textChanges || (ts.textChanges = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -79740,55 +83870,48 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); - var classDecl = ts.getContainingClass(token); - if (!classDecl) { + var classDeclaration = ts.getContainingClass(token); + if (!classDeclaration) { return undefined; } - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDecl); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var classType = checker.getTypeAtLocation(classDeclaration); + var implementedTypeNodes = ts.getClassImplementsHeritageClauseElements(classDeclaration); var hasNumericIndexSignature = !!checker.getIndexTypeOfType(classType, 1 /* Number */); var hasStringIndexSignature = !!checker.getIndexTypeOfType(classType, 0 /* String */); var result = []; for (var _i = 0, implementedTypeNodes_2 = implementedTypeNodes; _i < implementedTypeNodes_2.length; _i++) { var implementedTypeNode = implementedTypeNodes_2[_i]; - var implementedType = checker.getTypeFromTypeNode(implementedTypeNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. + var implementedType = checker.getTypeAtLocation(implementedTypeNode); var implementedTypeSymbols = checker.getPropertiesOfType(implementedType); var nonPrivateMembers = implementedTypeSymbols.filter(function (symbol) { return !(ts.getModifierFlags(symbol.valueDeclaration) & 8 /* Private */); }); - var insertion = getMissingIndexSignatureInsertion(implementedType, 1 /* Number */, classDecl, hasNumericIndexSignature); - insertion += getMissingIndexSignatureInsertion(implementedType, 0 /* String */, classDecl, hasStringIndexSignature); - insertion += codefix.getMissingMembersInsertion(classDecl, nonPrivateMembers, checker, context.newLineCharacter); + var newNodes = []; + createAndAddMissingIndexSignatureDeclaration(implementedType, 1 /* Number */, hasNumericIndexSignature, newNodes); + createAndAddMissingIndexSignatureDeclaration(implementedType, 0 /* String */, hasStringIndexSignature, newNodes); + newNodes = newNodes.concat(codefix.createMissingMemberNodes(classDeclaration, nonPrivateMembers, checker)); var message = ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_interface_0), [implementedTypeNode.getText()]); - if (insertion) { - pushAction(result, insertion, message); + if (newNodes.length > 0) { + pushAction(result, newNodes, message); } } return result; - function getMissingIndexSignatureInsertion(type, kind, enclosingDeclaration, hasIndexSigOfKind) { - if (!hasIndexSigOfKind) { - var IndexInfoOfKind = checker.getIndexInfoOfType(type, kind); - if (IndexInfoOfKind) { - var writer = ts.getSingleLineStringWriter(); - checker.getSymbolDisplayBuilder().buildIndexSignatureDisplay(IndexInfoOfKind, writer, kind, enclosingDeclaration); - var result_6 = writer.string(); - ts.releaseStringWriter(writer); - return result_6; - } + function createAndAddMissingIndexSignatureDeclaration(type, kind, hasIndexSigOfKind, newNodes) { + if (hasIndexSigOfKind) { + return; } - return ""; + var indexInfoOfKind = checker.getIndexInfoOfType(type, kind); + if (!indexInfoOfKind) { + return; + } + var newIndexSignatureDeclaration = checker.indexInfoToIndexSignatureDeclaration(indexInfoOfKind, kind, classDeclaration); + newNodes.push(newIndexSignatureDeclaration); } - function pushAction(result, insertion, description) { + function pushAction(result, newNodes, description) { var newAction = { description: description, - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: codefix.newNodesToChanges(newNodes, openBrace, context) }; result.push(newAction); } @@ -79797,6 +83920,117 @@ var ts; })(ts || (ts = {})); /* @internal */ var ts; +(function (ts) { + var codefix; + (function (codefix) { + codefix.registerCodeFix({ + errorCodes: [ts.Diagnostics.Property_0_does_not_exist_on_type_1.code], + getCodeActions: getActionsForAddMissingMember + }); + function getActionsForAddMissingMember(context) { + var sourceFile = context.sourceFile; + var start = context.span.start; + // This is the identifier of the missing property. eg: + // this.missing = 1; + // ^^^^^^^ + var token = ts.getTokenAtPosition(sourceFile, start); + if (token.kind !== 71 /* Identifier */) { + return undefined; + } + if (!ts.isPropertyAccessExpression(token.parent) || token.parent.expression.kind !== 99 /* ThisKeyword */) { + return undefined; + } + var classMemberDeclaration = ts.getThisContainer(token, /*includeArrowFunctions*/ false); + if (!ts.isClassElement(classMemberDeclaration)) { + return undefined; + } + var classDeclaration = classMemberDeclaration.parent; + if (!classDeclaration || !ts.isClassLike(classDeclaration)) { + return undefined; + } + var isStatic = ts.hasModifier(classMemberDeclaration, 32 /* Static */); + return ts.isInJavaScriptFile(sourceFile) ? getActionsForAddMissingMemberInJavaScriptFile() : getActionsForAddMissingMemberInTypeScriptFile(); + function getActionsForAddMissingMemberInJavaScriptFile() { + var memberName = token.getText(); + if (isStatic) { + if (classDeclaration.kind === 199 /* ClassExpression */) { + return undefined; + } + var className = classDeclaration.name.getText(); + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_static_property_0), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classDeclaration.getEnd(), length: 0 }, + newText: "" + context.newLineCharacter + className + "." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + else { + var classConstructor = ts.getFirstConstructorWithBody(classDeclaration); + if (!classConstructor) { + return undefined; + } + return [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Initialize_property_0_in_the_constructor), [memberName]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: classConstructor.body.getEnd() - 1, length: 0 }, + newText: "this." + memberName + " = undefined;" + context.newLineCharacter + }] + }] + }]; + } + } + function getActionsForAddMissingMemberInTypeScriptFile() { + var typeNode; + if (token.parent.parent.kind === 194 /* BinaryExpression */) { + var binaryExpression = token.parent.parent; + var checker = context.program.getTypeChecker(); + var widenedType = checker.getWidenedType(checker.getBaseTypeOfLiteralType(checker.getTypeAtLocation(binaryExpression.right))); + typeNode = checker.typeToTypeNode(widenedType, classDeclaration); + } + typeNode = typeNode || ts.createKeywordTypeNode(119 /* AnyKeyword */); + var openBrace = ts.getOpenBraceOfClassLike(classDeclaration, sourceFile); + var property = ts.createProperty( + /*decorators*/ undefined, + /*modifiers*/ isStatic ? [ts.createToken(115 /* StaticKeyword */)] : undefined, token.getText(sourceFile), + /*questionToken*/ undefined, typeNode, + /*initializer*/ undefined); + var propertyChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + propertyChangeTracker.insertNodeAfter(sourceFile, openBrace, property, { suffix: context.newLineCharacter }); + var actions = [{ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_declaration_for_missing_property_0), [token.getText()]), + changes: propertyChangeTracker.getChanges() + }]; + if (!isStatic) { + var stringTypeNode = ts.createKeywordTypeNode(136 /* StringKeyword */); + var indexingParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "x", + /*questionToken*/ undefined, stringTypeNode, + /*initializer*/ undefined); + var indexSignature = ts.createIndexSignatureDeclaration( + /*decorators*/ undefined, + /*modifiers*/ undefined, [indexingParameter], typeNode); + var indexSignatureChangeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + indexSignatureChangeTracker.insertNodeAfter(sourceFile, openBrace, indexSignature, { suffix: context.newLineCharacter }); + actions.push({ + description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Add_index_signature_for_missing_property_0), [token.getText()]), + changes: indexSignatureChangeTracker.getChanges() + }); + } + return actions; + } + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; (function (ts) { var codefix; (function (codefix) { @@ -79816,25 +84050,19 @@ var ts; var token = ts.getTokenAtPosition(sourceFile, start); var checker = context.program.getTypeChecker(); if (ts.isClassLike(token.parent)) { - var classDecl = token.parent; - var startPos = classDecl.members.pos; - var classType = checker.getTypeAtLocation(classDecl); - var instantiatedExtendsType = checker.getBaseTypes(classType)[0]; + var classDeclaration = token.parent; + var extendsNode = ts.getClassExtendsHeritageClauseElement(classDeclaration); + var instantiatedExtendsType = checker.getTypeAtLocation(extendsNode); // Note that this is ultimately derived from a map indexed by symbol names, // so duplicates cannot occur. var extendsSymbols = checker.getPropertiesOfType(instantiatedExtendsType); var abstractAndNonPrivateExtendsSymbols = extendsSymbols.filter(symbolPointsToNonPrivateAndAbstractMember); - var insertion = codefix.getMissingMembersInsertion(classDecl, abstractAndNonPrivateExtendsSymbols, checker, context.newLineCharacter); - if (insertion.length) { + var newNodes = codefix.createMissingMemberNodes(classDeclaration, abstractAndNonPrivateExtendsSymbols, checker); + var changes = codefix.newNodesToChanges(newNodes, ts.getOpenBraceOfClassLike(classDeclaration, sourceFile), context); + if (changes && changes.length > 0) { return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Implement_inherited_abstract_class), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ - span: { start: startPos, length: 0 }, - newText: insertion - }] - }] + changes: changes }]; } } @@ -79858,7 +84086,7 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 98 /* ThisKeyword */) { + if (token.kind !== 99 /* ThisKeyword */) { return undefined; } var constructor = ts.getContainingFunction(token); @@ -79866,9 +84094,9 @@ var ts; if (!superCall) { return undefined; } - // figure out if the this access is actuall inside the supercall + // figure out if the `this` access is actually inside the supercall // i.e. super(this.a), since in that case we won't suggest a fix - if (superCall.expression && superCall.expression.kind == 180 /* CallExpression */) { + if (superCall.expression && superCall.expression.kind === 181 /* CallExpression */) { var arguments_1 = superCall.expression.arguments; for (var i = 0; i < arguments_1.length; i++) { if (arguments_1[i].expression === token) { @@ -79876,23 +84104,15 @@ var ts; } } } - var newPosition = ts.getOpenBraceEnd(constructor, sourceFile); - var changes = [{ - fileName: sourceFile.fileName, textChanges: [{ - newText: superCall.getText(sourceFile), - span: { start: newPosition, length: 0 } - }, - { - newText: "", - span: { start: superCall.getStart(sourceFile), length: superCall.getWidth(sourceFile) } - }] - }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(constructor, sourceFile), superCall, { suffix: context.newLineCharacter }); + changeTracker.deleteNode(sourceFile, superCall); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Make_super_call_the_first_statement_in_the_constructor), - changes: changes + changes: changeTracker.getChanges() }]; function findSuperCall(n) { - if (n.kind === 209 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { + if (n.kind === 210 /* ExpressionStatement */ && ts.isSuperCall(n.expression)) { return n; } if (ts.isFunctionLike(n)) { @@ -79914,13 +84134,15 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - if (token.kind !== 122 /* ConstructorKeyword */) { + if (token.kind !== 123 /* ConstructorKeyword */) { return undefined; } - var newPosition = ts.getOpenBraceEnd(token.parent, sourceFile); + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + var superCall = ts.createStatement(ts.createCall(ts.createSuper(), /*typeArguments*/ undefined, /*argumentsArray*/ ts.emptyArray)); + changeTracker.insertNodeAfter(sourceFile, ts.getOpenBrace(token.parent, sourceFile), superCall, { suffix: context.newLineCharacter }); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_missing_super_call), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "super();", span: { start: newPosition, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -79938,7 +84160,7 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); var classDeclNode = ts.getContainingClass(token); - if (!(token.kind === 70 /* Identifier */ && ts.isClassLike(classDeclNode))) { + if (!(token.kind === 71 /* Identifier */ && ts.isClassLike(classDeclNode))) { return undefined; } var heritageClauses = classDeclNode.heritageClauses; @@ -79946,27 +84168,21 @@ var ts; return undefined; } var extendsToken = heritageClauses[0].getFirstToken(); - if (!(extendsToken && extendsToken.kind === 84 /* ExtendsKeyword */)) { + if (!(extendsToken && extendsToken.kind === 85 /* ExtendsKeyword */)) { return undefined; } - var changeStart = extendsToken.getStart(sourceFile); - var changeEnd = extendsToken.getEnd(); - var textChanges = [{ newText: " implements", span: { start: changeStart, length: changeEnd - changeStart } }]; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, extendsToken, ts.createToken(108 /* ImplementsKeyword */)); // We replace existing keywords with commas. for (var i = 1; i < heritageClauses.length; i++) { var keywordToken = heritageClauses[i].getFirstToken(); if (keywordToken) { - changeStart = keywordToken.getStart(sourceFile); - changeEnd = keywordToken.getEnd(); - textChanges.push({ newText: ",", span: { start: changeStart, length: changeEnd - changeStart } }); + changeTracker.replaceNode(sourceFile, keywordToken, ts.createToken(26 /* CommaToken */)); } } var result = [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Change_extends_to_implements), - changes: [{ - fileName: sourceFile.fileName, - textChanges: textChanges - }] + changes: changeTracker.getChanges() }]; return result; } @@ -79983,10 +84199,14 @@ var ts; getCodeActions: function (context) { var sourceFile = context.sourceFile; var token = ts.getTokenAtPosition(sourceFile, context.span.start); - var start = token.getStart(sourceFile); + if (token.kind !== 71 /* Identifier */) { + return undefined; + } + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + changeTracker.replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createThis(), token)); return [{ description: ts.getLocaleSpecificMessage(ts.Diagnostics.Add_this_to_unresolved_variable), - changes: [{ fileName: sourceFile.fileName, textChanges: [{ newText: "this.", span: { start: start, length: 0 } }] }] + changes: changeTracker.getChanges() }]; } }); @@ -80007,165 +84227,158 @@ var ts; var start = context.span.start; var token = ts.getTokenAtPosition(sourceFile, start); // this handles var ["computed"] = 12; - if (token.kind === 20 /* OpenBracketToken */) { + if (token.kind === 21 /* OpenBracketToken */) { token = ts.getTokenAtPosition(sourceFile, start + 1); } switch (token.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: switch (token.parent.kind) { - case 225 /* VariableDeclaration */: + case 226 /* VariableDeclaration */: switch (token.parent.parent.parent.kind) { - case 213 /* ForStatement */: + case 214 /* ForStatement */: var forStatement = token.parent.parent.parent; var forInitializer = forStatement.initializer; if (forInitializer.declarations.length === 1) { - return createCodeFixToRemoveNode(forInitializer); + return deleteNode(forInitializer); } else { - return removeSingleItem(forInitializer.declarations, token); + return deleteNodeInList(token.parent); } - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: var forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === 226 /* VariableDeclarationList */) { + if (forOfStatement.initializer.kind === 227 /* VariableDeclarationList */) { var forOfInitializer = forOfStatement.initializer; - return createCodeFix("{}", forOfInitializer.declarations[0].getStart(), forOfInitializer.declarations[0].getWidth()); + return replaceNode(forOfInitializer.declarations[0], ts.createObjectLiteral()); } break; - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: // There is no valid fix in the case of: // for .. in return undefined; - case 259 /* CatchClause */: + case 260 /* CatchClause */: var catchClause = token.parent.parent; var parameter = catchClause.variableDeclaration.getChildren()[0]; - return createCodeFixToRemoveNode(parameter); + return deleteNode(parameter); default: var variableStatement = token.parent.parent.parent; if (variableStatement.declarationList.declarations.length === 1) { - return createCodeFixToRemoveNode(variableStatement); + return deleteNode(variableStatement); } else { - var declarations = variableStatement.declarationList.declarations; - return removeSingleItem(declarations, token); + return deleteNodeInList(token.parent); } } - case 144 /* TypeParameter */: + // TODO: #14885 + // falls through + case 145 /* TypeParameter */: var typeParameters = token.parent.parent.typeParameters; if (typeParameters.length === 1) { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 2); + var previousToken = ts.getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== 27 /* LessThanToken */) { + return deleteRange(typeParameters); + } + var nextToken = ts.getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== 29 /* GreaterThanToken */) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); } else { - return removeSingleItem(typeParameters, token); + return deleteNodeInList(token.parent); } - case 145 /* Parameter */: + case 146 /* Parameter */: var functionDeclaration = token.parent.parent; if (functionDeclaration.parameters.length === 1) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else { - return removeSingleItem(functionDeclaration.parameters, token); + return deleteNodeInList(token.parent); } // handle case where 'import a = A;' - case 236 /* ImportEqualsDeclaration */: - var importEquals = findImportDeclaration(token); - return createCodeFixToRemoveNode(importEquals); - case 241 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + var importEquals = ts.getAncestor(token, 237 /* ImportEqualsDeclaration */); + return deleteNode(importEquals); + case 242 /* ImportSpecifier */: var namedImports = token.parent.parent; if (namedImports.elements.length === 1) { // Only 1 import and it is unused. So the entire declaration should be removed. - var importSpec = findImportDeclaration(token); - return createCodeFixToRemoveNode(importSpec); + var importSpec = ts.getAncestor(token, 238 /* ImportDeclaration */); + return deleteNode(importSpec); } else { - return removeSingleItem(namedImports.elements, token); + // delete import specifier + return deleteNodeInList(token.parent); } // handle case where "import d, * as ns from './file'" // or "'import {a, b as ns} from './file'" - case 238 /* ImportClause */: + case 239 /* ImportClause */: var importClause = token.parent; if (!importClause.namedBindings) { - var importDecl = findImportDeclaration(importClause); - return createCodeFixToRemoveNode(importDecl); + var importDecl = ts.getAncestor(importClause, 238 /* ImportDeclaration */); + return deleteNode(importDecl); } else { // import |d,| * as ns from './file' - var start_4 = importClause.name.getStart(); - var end = findFirstNonSpaceCharPosStarting(importClause.name.end); - if (sourceFile.text.charCodeAt(end) === 44 /* comma */) { - end = findFirstNonSpaceCharPosStarting(end + 1); + var start_4 = importClause.name.getStart(sourceFile); + var nextToken = ts.getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === 26 /* CommaToken */) { + // shift first non-whitespace position after comma to the start position of the node + return deleteRange({ pos: start_4, end: ts.skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) }); + } + else { + return deleteNode(importClause.name); } - return createCodeFix("", start_4, end - start_4); } - case 239 /* NamespaceImport */: + case 240 /* NamespaceImport */: var namespaceImport = token.parent; - if (namespaceImport.name == token && !namespaceImport.parent.name) { - var importDecl = findImportDeclaration(namespaceImport); - return createCodeFixToRemoveNode(importDecl); + if (namespaceImport.name === token && !namespaceImport.parent.name) { + var importDecl = ts.getAncestor(namespaceImport, 238 /* ImportDeclaration */); + return deleteNode(importDecl); } else { - var start_5 = namespaceImport.parent.name.end; - return createCodeFix("", start_5, namespaceImport.parent.namedBindings.end - start_5); + var previousToken = ts.getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === 26 /* CommaToken */) { + var startPosition = ts.textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, ts.textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); } } break; - case 148 /* PropertyDeclaration */: - case 239 /* NamespaceImport */: - return createCodeFixToRemoveNode(token.parent); + case 149 /* PropertyDeclaration */: + case 240 /* NamespaceImport */: + return deleteNode(token.parent); } if (ts.isDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent); + return deleteNode(token.parent); } else if (ts.isLiteralComputedPropertyDeclarationName(token)) { - return createCodeFixToRemoveNode(token.parent.parent); + return deleteNode(token.parent.parent); } else { return undefined; } - function findImportDeclaration(token) { - var importDecl = token; - while (importDecl.kind != 237 /* ImportDeclaration */ && importDecl.parent) { - importDecl = importDecl.parent; - } - return importDecl; + function deleteNode(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNode(sourceFile, n)); } - function createCodeFixToRemoveNode(node) { - var end = node.getEnd(); - var endCharCode = sourceFile.text.charCodeAt(end); - var afterEndCharCode = sourceFile.text.charCodeAt(end + 1); - if (ts.isLineBreak(endCharCode)) { - end += 1; - } - // in the case of CR LF, you could have two consecutive new line characters for one new line. - // this needs to be differenciated from two LF LF chars that actually mean two new lines. - if (ts.isLineBreak(afterEndCharCode) && endCharCode !== afterEndCharCode) { - end += 1; - } - var start = node.getStart(); - return createCodeFix("", start, end - start); + function deleteRange(range) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteRange(sourceFile, range)); } - function findFirstNonSpaceCharPosStarting(start) { - while (ts.isWhiteSpace(sourceFile.text.charCodeAt(start))) { - start += 1; - } - return start; + function deleteNodeInList(n) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeInList(sourceFile, n)); } - function createCodeFix(newText, start, length) { + function deleteNodeRange(start, end) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).deleteNodeRange(sourceFile, start, end)); + } + function replaceNode(n, newNode) { + return makeChange(ts.textChanges.ChangeTracker.fromCodeFixContext(context).replaceNode(sourceFile, n, newNode)); + } + function makeChange(changeTracker) { return [{ description: ts.formatStringFromArgs(ts.getLocaleSpecificMessage(ts.Diagnostics.Remove_declaration_for_Colon_0), { 0: token.getText() }), - changes: [{ - fileName: sourceFile.fileName, - textChanges: [{ newText: newText, span: { start: start, length: length } }] - }] + changes: changeTracker.getChanges() }]; } - function removeSingleItem(elements, token) { - if (elements[0] === token.parent) { - return createCodeFix("", token.parent.pos, token.parent.end - token.parent.pos + 1); - } - else { - return createCodeFix("", token.parent.pos - 1, token.parent.end - token.parent.pos + 1); - } - } } }); })(codefix = ts.codefix || (ts.codefix = {})); @@ -80208,12 +84421,13 @@ var ts; } switch (this.compareModuleSpecifiers(existingAction.moduleSpecifier, newAction.moduleSpecifier)) { case ModuleSpecifierComparison.Better: - // the new one is not worth considering if it is a new improt. + // the new one is not worth considering if it is a new import. // However if it is instead a insertion into existing import, the user might want to use // the module specifier even it is worse by our standards. So keep it. if (newAction.kind === "NewImport") { return; } + // falls through case ModuleSpecifierComparison.Equal: // the current one is safe. But it is still possible that the new one is worse // than another existing one. For example, you may have new imports from "./foo/bar" @@ -80287,21 +84501,21 @@ var ts; var symbolIdActionMap = new ImportCodeActionMap(); // this is a module id -> module import declaration map var cachedImportDeclarations = []; - var cachedNewImportInsertPosition; + var lastImportDeclaration; var currentTokenMeaning = ts.getMeaningFromLocation(token); if (context.errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { var symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); } - var allPotentialModules = checker.getAmbientModules(); + var candidateModules = checker.getAmbientModules(); for (var _i = 0, allSourceFiles_1 = allSourceFiles; _i < allSourceFiles_1.length; _i++) { var otherSourceFile = allSourceFiles_1[_i]; if (otherSourceFile !== sourceFile && ts.isExternalOrCommonJsModule(otherSourceFile)) { - allPotentialModules.push(otherSourceFile.symbol); + candidateModules.push(otherSourceFile.symbol); } } - for (var _a = 0, allPotentialModules_1 = allPotentialModules; _a < allPotentialModules_1.length; _a++) { - var moduleSymbol = allPotentialModules_1[_a]; + for (var _a = 0, candidateModules_1 = candidateModules; _a < candidateModules_1.length; _a++) { + var moduleSymbol = candidateModules_1[_a]; context.cancellationToken.throwIfCancellationRequested(); // check the default export var defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); @@ -80340,10 +84554,10 @@ var ts; function getImportDeclaration(moduleSpecifier) { var node = moduleSpecifier; while (node) { - if (node.kind === 237 /* ImportDeclaration */) { + if (node.kind === 238 /* ImportDeclaration */) { return node; } - if (node.kind === 236 /* ImportEqualsDeclaration */) { + if (node.kind === 237 /* ImportEqualsDeclaration */) { return node; } node = node.parent; @@ -80389,9 +84603,9 @@ var ts; var existingModuleSpecifier; for (var _i = 0, declarations_14 = declarations; _i < declarations_14.length; _i++) { var declaration = declarations_14[_i]; - if (declaration.kind === 237 /* ImportDeclaration */) { + if (declaration.kind === 238 /* ImportDeclaration */) { var namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === 239 /* NamespaceImport */) { + if (namedBindings && namedBindings.kind === 240 /* NamespaceImport */) { // case: // import * as ns from "foo" namespaceImportDeclaration = declaration; @@ -80421,9 +84635,9 @@ var ts; * If the existing import declaration already has a named import list, just * insert the identifier into that list. */ - var textChange = getTextChangeForImportClause(namedImportDeclaration.importClause); + var fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); var moduleSpecifierWithoutQuotes = ts.stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); - actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], textChange.newText, textChange.span, sourceFile.fileName, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); + actions.push(createCodeAction(ts.Diagnostics.Add_0_to_existing_import_declaration_from_1, [name, moduleSpecifierWithoutQuotes], fileTextChanges, "InsertingIntoExistingImport", moduleSpecifierWithoutQuotes)); } else { // we need to create a new import statement, but the existing module specifier can be reused. @@ -80431,55 +84645,35 @@ var ts; } return actions; function getModuleSpecifierFromImportEqualsDeclaration(declaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === 247 /* ExternalModuleReference */) { + if (declaration.moduleReference && declaration.moduleReference.kind === 248 /* ExternalModuleReference */) { return declaration.moduleReference.expression.getText(); } return declaration.moduleReference.getText(); } function getTextChangeForImportClause(importClause) { - var newImportText = isDefault ? "default as " + name : name; var importList = importClause.namedBindings; + var newImportSpecifier = ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name)); // case 1: // original text: import default from "module" // change to: import default, { name } from "module" - if (!importList && importClause.name) { - var start = importClause.name.getEnd(); - return { - newText: ", { " + newImportText + " }", - span: { start: start, length: 0 } - }; - } // case 2: // original text: import {} from "module" // change to: import { name } from "module" - if (importList.elements.length === 0) { - var start = importList.getStart(); - return { - newText: "{ " + newImportText + " }", - span: { start: start, length: importList.getEnd() - start } - }; + if (!importList || importList.elements.length === 0) { + var newImportClause = ts.createImportClause(importClause.name, ts.createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - // case 3: - // original text: import { foo, bar } from "module" - // change to: import { foo, bar, name } from "module" - var insertPoint = importList.elements[importList.elements.length - 1].getEnd(); /** * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element * import { * foo * } from "./module"; */ - var startLine = ts.getLineOfLocalPosition(sourceFile, importList.getStart()); - var endLine = ts.getLineOfLocalPosition(sourceFile, importList.getEnd()); - var oneImportPerLine = endLine - startLine > importList.elements.length; - return { - newText: "," + (oneImportPerLine ? context.newLineCharacter : " ") + newImportText, - span: { start: insertPoint, length: 0 } - }; + return createChangeTracker().insertNodeInListAfter(sourceFile, importList.elements[importList.elements.length - 1], newImportSpecifier).getChanges(); } function getCodeActionForNamespaceImport(declaration) { var namespacePrefix; - if (declaration.kind === 237 /* ImportDeclaration */) { + if (declaration.kind === 238 /* ImportDeclaration */) { namespacePrefix = declaration.importClause.namedBindings.name.getText(); } else { @@ -80496,36 +84690,39 @@ var ts; * namespace instead of altering the import declaration. For example, "foo" would * become "ns.foo" */ - return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], namespacePrefix + ".", { start: token.getStart(), length: 0 }, sourceFile.fileName, "CodeChange"); + return createCodeAction(ts.Diagnostics.Change_0_to_1, [name, namespacePrefix + "." + name], createChangeTracker().replaceNode(sourceFile, token, ts.createPropertyAccess(ts.createIdentifier(namespacePrefix), name)).getChanges(), "CodeChange"); } } function getCodeActionForNewImport(moduleSpecifier) { - if (!cachedNewImportInsertPosition) { + if (!lastImportDeclaration) { // insert after any existing imports - var lastModuleSpecifierEnd = -1; - for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) { - var moduleSpecifier_1 = _a[_i]; - var end = moduleSpecifier_1.getEnd(); - if (!lastModuleSpecifierEnd || end > lastModuleSpecifierEnd) { - lastModuleSpecifierEnd = end; + for (var i = sourceFile.statements.length - 1; i >= 0; i--) { + var statement = sourceFile.statements[i]; + if (statement.kind === 237 /* ImportEqualsDeclaration */ || statement.kind === 238 /* ImportDeclaration */) { + lastImportDeclaration = statement; + break; } } - cachedNewImportInsertPosition = lastModuleSpecifierEnd > 0 ? sourceFile.getLineEndOfPosition(lastModuleSpecifierEnd) : sourceFile.getStart(); } var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames); var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - var importStatementText = isDefault - ? "import " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" + var changeTracker = createChangeTracker(); + var importClause = isDefault + ? ts.createImportClause(ts.createIdentifier(name), /*namedBindings*/ undefined) : isNamespaceImport - ? "import * as " + name + " from \"" + moduleSpecifierWithoutQuotes + "\"" - : "import { " + name + " } from \"" + moduleSpecifierWithoutQuotes + "\""; + ? ts.createImportClause(/*name*/ undefined, ts.createNamespaceImport(ts.createIdentifier(name))) + : ts.createImportClause(/*name*/ undefined, ts.createNamedImports([ts.createImportSpecifier(/*propertyName*/ undefined, ts.createIdentifier(name))])); + var importDecl = ts.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, ts.createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: "" + context.newLineCharacter + context.newLineCharacter }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } // if this file doesn't have any import statements, insert an import statement and then insert a new line // between the only import statement and user code. Otherwise just insert the statement because chances // are there are already a new line seperating code and import statements. - var newText = cachedNewImportInsertPosition === sourceFile.getStart() - ? importStatementText + ";" + context.newLineCharacter + context.newLineCharacter - : "" + context.newLineCharacter + importStatementText + ";"; - return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], newText, { start: cachedNewImportInsertPosition, length: 0 }, sourceFile.fileName, "NewImport", moduleSpecifierWithoutQuotes); + return createCodeAction(ts.Diagnostics.Import_0_from_1, [name, "\"" + moduleSpecifierWithoutQuotes + "\""], changeTracker.getChanges(), "NewImport", moduleSpecifierWithoutQuotes); function getModuleSpecifierForNewImport() { var fileName = sourceFile.fileName; var moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; @@ -80538,7 +84735,7 @@ var ts; tryGetModuleNameFromRootDirs() || ts.removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); function tryGetModuleNameFromAmbientModule() { - if (moduleSymbol.valueDeclaration.kind !== 264 /* SourceFile */) { + if (moduleSymbol.valueDeclaration.kind !== 265 /* SourceFile */) { return moduleSymbol.name; } } @@ -80660,19 +84857,22 @@ var ts; return fileName; } function getRelativePathIfInDirectory(path, directoryPath) { - var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return ts.isRootedDiskPath(relativePath) || ts.startsWith(relativePath, "..") ? undefined : relativePath; } function getRelativePath(path, directoryPath) { - var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false); + var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); return ts.moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; } } } - function createCodeAction(description, diagnosticArgs, newText, span, fileName, kind, moduleSpecifier) { + function createChangeTracker() { + return ts.textChanges.ChangeTracker.fromCodeFixContext(context); + } + function createCodeAction(description, diagnosticArgs, changes, kind, moduleSpecifier) { return { description: ts.formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes: [{ fileName: fileName, textChanges: [{ newText: newText, span: span }] }], + changes: changes, kind: kind, moduleSpecifier: moduleSpecifier }; @@ -80686,45 +84886,147 @@ var ts; (function (ts) { var codefix; (function (codefix) { + codefix.registerCodeFix({ + errorCodes: getApplicableDiagnosticCodes(), + getCodeActions: getDisableJsDiagnosticsCodeActions + }); + function getApplicableDiagnosticCodes() { + var allDiagnostcs = ts.Diagnostics; + return Object.keys(allDiagnostcs) + .filter(function (d) { return allDiagnostcs[d] && allDiagnostcs[d].category === ts.DiagnosticCategory.Error; }) + .map(function (d) { return allDiagnostcs[d].code; }); + } + function getIgnoreCommentLocationForLocation(sourceFile, position, newLineCharacter) { + var line = ts.getLineAndCharacterOfPosition(sourceFile, position).line; + var lineStartPosition = ts.getStartPositionOfLine(line, sourceFile); + var startPosition = ts.getFirstNonSpaceCharacterPosition(sourceFile.text, lineStartPosition); + // First try to see if we can put the '// @ts-ignore' on the previous line. + // We need to make sure that we are not in the middle of a string literal or a comment. + // We also want to check if the previous line holds a comment for a node on the next line + // if so, we do not want to separate the node from its comment if we can. + if (!ts.isInComment(sourceFile, startPosition) && !ts.isInString(sourceFile, startPosition) && !ts.isInTemplateString(sourceFile, startPosition)) { + var token = ts.getTouchingToken(sourceFile, startPosition); + var tokenLeadingCommnets = ts.getLeadingCommentRangesOfNode(token, sourceFile); + if (!tokenLeadingCommnets || !tokenLeadingCommnets.length || tokenLeadingCommnets[0].pos >= startPosition) { + return { + span: { start: startPosition, length: 0 }, + newText: "// @ts-ignore" + newLineCharacter + }; + } + } + // If all fails, add an extra new line immediatlly before the error span. + return { + span: { start: position, length: 0 }, + newText: (position === startPosition ? "" : newLineCharacter) + "// @ts-ignore" + newLineCharacter + }; + } + function getDisableJsDiagnosticsCodeActions(context) { + var sourceFile = context.sourceFile, program = context.program, newLineCharacter = context.newLineCharacter, span = context.span; + if (!ts.isInJavaScriptFile(sourceFile) || !ts.isCheckJsEnabledForFile(sourceFile, program.getCompilerOptions())) { + return undefined; + } + return [{ + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Ignore_this_error_message), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [getIgnoreCommentLocationForLocation(sourceFile, span.start, newLineCharacter)] + }] + }, + { + description: ts.getLocaleSpecificMessage(ts.Diagnostics.Disable_checking_for_this_file), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { + start: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.pos : 0, + length: sourceFile.checkJsDirective ? sourceFile.checkJsDirective.end - sourceFile.checkJsDirective.pos : 0 + }, + newText: "// @ts-nocheck" + newLineCharacter + }] + }] + }]; + } + })(codefix = ts.codefix || (ts.codefix = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var codefix; + (function (codefix) { + function newNodesToChanges(newNodes, insertAfter, context) { + var sourceFile = context.sourceFile; + var changeTracker = ts.textChanges.ChangeTracker.fromCodeFixContext(context); + for (var _i = 0, newNodes_1 = newNodes; _i < newNodes_1.length; _i++) { + var newNode = newNodes_1[_i]; + changeTracker.insertNodeAfter(sourceFile, insertAfter, newNode, { suffix: context.newLineCharacter }); + } + var changes = changeTracker.getChanges(); + if (!ts.some(changes)) { + return changes; + } + ts.Debug.assert(changes.length === 1); + var consolidatedChanges = [{ + fileName: changes[0].fileName, + textChanges: [{ + span: changes[0].textChanges[0].span, + newText: changes[0].textChanges.reduce(function (prev, cur) { return prev + cur.newText; }, "") + }] + }]; + return consolidatedChanges; + } + codefix.newNodesToChanges = newNodesToChanges; /** * Finds members of the resolved type that are missing in the class pointed to by class decl * and generates source code for the missing members. * @param possiblyMissingSymbols The collection of symbols to filter and then get insertions for. * @returns Empty string iff there are no member insertions. */ - function getMissingMembersInsertion(classDeclaration, possiblyMissingSymbols, checker, newlineChar) { + function createMissingMemberNodes(classDeclaration, possiblyMissingSymbols, checker) { var classMembers = classDeclaration.symbol.members; var missingMembers = possiblyMissingSymbols.filter(function (symbol) { return !classMembers.has(symbol.getName()); }); - var insertion = ""; + var newNodes = []; for (var _i = 0, missingMembers_1 = missingMembers; _i < missingMembers_1.length; _i++) { var symbol = missingMembers_1[_i]; - insertion = insertion.concat(getInsertionForMemberSymbol(symbol, classDeclaration, checker, newlineChar)); + var newNode = createNewNodeForMemberSymbol(symbol, classDeclaration, checker); + if (newNode) { + if (Array.isArray(newNode)) { + newNodes = newNodes.concat(newNode); + } + else { + newNodes.push(newNode); + } + } } - return insertion; + return newNodes; } - codefix.getMissingMembersInsertion = getMissingMembersInsertion; + codefix.createMissingMemberNodes = createMissingMemberNodes; /** * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`. */ - function getInsertionForMemberSymbol(symbol, enclosingDeclaration, checker, newlineChar) { - // const name = symbol.getName(); - var type = checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration); + function createNewNodeForMemberSymbol(symbol, enclosingDeclaration, checker) { var declarations = symbol.getDeclarations(); if (!(declarations && declarations.length)) { - return ""; + return undefined; } var declaration = declarations[0]; - var name = declaration.name ? declaration.name.getText() : undefined; - var visibility = getVisibilityPrefix(ts.getModifierFlags(declaration)); + // Clone name to remove leading trivia. + var name = ts.getSynthesizedClone(declaration.name); + var visibilityModifier = createVisibilityModifier(ts.getModifierFlags(declaration)); + var modifiers = visibilityModifier ? ts.createNodeArray([visibilityModifier]) : undefined; + var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); + var optional = !!(symbol.flags & 67108864 /* Optional */); switch (declaration.kind) { - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 147 /* PropertySignature */: - case 148 /* PropertyDeclaration */: - var typeString = checker.typeToString(type, enclosingDeclaration, 0 /* None */); - return "" + visibility + name + ": " + typeString + ";" + newlineChar; - case 149 /* MethodSignature */: - case 150 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 148 /* PropertySignature */: + case 149 /* PropertyDeclaration */: + var typeNode = checker.typeToTypeNode(type, enclosingDeclaration); + var property = ts.createProperty( + /*decorators*/ undefined, modifiers, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeNode, + /*initializer*/ undefined); + return property; + case 150 /* MethodSignature */: + case 151 /* MethodDeclaration */: // The signature for the implementation appears as an entry in `signatures` iff // there is only one signature. // If there are overloads and an implementation signature, it appears as an @@ -80733,95 +85035,118 @@ var ts; // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. var signatures = checker.getSignaturesOfType(type, 0 /* Call */); - if (!(signatures && signatures.length > 0)) { - return ""; + if (!ts.some(signatures)) { + return undefined; } if (declarations.length === 1) { ts.Debug.assert(signatures.length === 1); - var sigString_1 = checker.signatureToString(signatures[0], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); - return "" + visibility + name + sigString_1 + getMethodBodyStub(newlineChar); + var signature = signatures[0]; + return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - var result = ""; + var signatureDeclarations = []; for (var i = 0; i < signatures.length; i++) { - var sigString_2 = checker.signatureToString(signatures[i], enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); - result += "" + visibility + name + sigString_2 + ";" + newlineChar; + var signature = signatures[i]; + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } - // If there is a declaration with a body, it is the last declaration, - // and it isn't caught by `getSignaturesOfType`. - var bodySig = undefined; if (declarations.length > signatures.length) { - bodySig = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]); + var methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); + if (methodDeclaration) { + signatureDeclarations.push(methodDeclaration); + } } else { ts.Debug.assert(declarations.length === signatures.length); - bodySig = createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker); + var methodImplementingSignatures = createMethodImplementingSignatures(signatures, name, optional, modifiers); + signatureDeclarations.push(methodImplementingSignatures); } - var sigString = checker.signatureToString(bodySig, enclosingDeclaration, 2048 /* SuppressAnyReturnType */, 0 /* Call */); - result += "" + visibility + name + sigString + getMethodBodyStub(newlineChar); - return result; + return signatureDeclarations; default: - return ""; + return undefined; + } + function signatureToMethodDeclaration(signature, enclosingDeclaration, body) { + var signatureDeclaration = checker.signatureToSignatureDeclaration(signature, 151 /* MethodDeclaration */, enclosingDeclaration); + if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; + signatureDeclaration.modifiers = modifiers; + signatureDeclaration.name = name; + signatureDeclaration.questionToken = optional ? ts.createToken(55 /* QuestionToken */) : undefined; + signatureDeclaration.body = body; + } + return signatureDeclaration; } } - function createBodySignatureWithAnyTypes(signatures, enclosingDeclaration, checker) { - var newSignatureDeclaration = ts.createNode(154 /* CallSignature */); - newSignatureDeclaration.parent = enclosingDeclaration; - newSignatureDeclaration.name = signatures[0].getDeclaration().name; - var maxNonRestArgs = -1; - var maxArgsIndex = 0; + function createMethodImplementingSignatures(signatures, name, optional, modifiers) { + /** This is *a* signature with the maximal number of arguments, + * such that if there is a "maximal" signature without rest arguments, + * this is one of them. + */ + var maxArgsSignature = signatures[0]; var minArgumentCount = signatures[0].minArgumentCount; - var hasRestParameter = false; + var someSigHasRestParameter = false; for (var i = 0; i < signatures.length; i++) { var sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - hasRestParameter = hasRestParameter || sig.hasRestParameter; - var nonRestLength = sig.parameters.length - (sig.hasRestParameter ? 1 : 0); - if (nonRestLength > maxNonRestArgs) { - maxNonRestArgs = nonRestLength; - maxArgsIndex = i; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } + if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { + maxArgsSignature = sig; } } - var maxArgsParameterSymbolNames = signatures[maxArgsIndex].getParameters().map(function (symbol) { return symbol.getName(); }); - var optionalToken = ts.createToken(54 /* QuestionToken */); - newSignatureDeclaration.parameters = ts.createNodeArray(); + var maxNonRestArgs = maxArgsSignature.parameters.length - (maxArgsSignature.hasRestParameter ? 1 : 0); + var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.getName(); }); + var parameters = []; for (var i = 0; i < maxNonRestArgs; i++) { - var newParameter = createParameterDeclarationWithoutType(i, minArgumentCount, newSignatureDeclaration); - newSignatureDeclaration.parameters.push(newParameter); + var anyType = ts.createKeywordTypeNode(119 /* AnyKeyword */); + var newParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, maxArgsParameterSymbolNames[i], + /*questionToken*/ i >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyType, + /*initializer*/ undefined); + parameters.push(newParameter); } - if (hasRestParameter) { - var restParameter = createParameterDeclarationWithoutType(maxNonRestArgs, minArgumentCount, newSignatureDeclaration); - restParameter.dotDotDotToken = ts.createToken(23 /* DotDotDotToken */); - newSignatureDeclaration.parameters.push(restParameter); - } - return checker.getSignatureFromDeclaration(newSignatureDeclaration); - function createParameterDeclarationWithoutType(index, minArgCount, enclosingSignatureDeclaration) { - var newParameter = ts.createNode(145 /* Parameter */); - newParameter.symbol = new SymbolConstructor(1 /* FunctionScopedVariable */, maxArgsParameterSymbolNames[index] || "rest"); - newParameter.symbol.valueDeclaration = newParameter; - newParameter.symbol.declarations = [newParameter]; - newParameter.parent = enclosingSignatureDeclaration; - if (index >= minArgCount) { - newParameter.questionToken = optionalToken; - } - return newParameter; + if (someSigHasRestParameter) { + var anyArrayType = ts.createArrayTypeNode(ts.createKeywordTypeNode(119 /* AnyKeyword */)); + var restParameter = ts.createParameter( + /*decorators*/ undefined, + /*modifiers*/ undefined, ts.createToken(24 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", + /*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.createToken(55 /* QuestionToken */) : undefined, anyArrayType, + /*initializer*/ undefined); + parameters.push(restParameter); } + return createStubbedMethod(modifiers, name, optional, + /*typeParameters*/ undefined, parameters, + /*returnType*/ undefined); } - function getMethodBodyStub(newLineChar) { - return " {" + newLineChar + "throw new Error('Method not implemented.');" + newLineChar + "}" + newLineChar; + function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType) { + return ts.createMethodDeclaration( + /*decorators*/ undefined, modifiers, + /*asteriskToken*/ undefined, name, optional ? ts.createToken(55 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody()); } - function getVisibilityPrefix(flags) { + codefix.createStubbedMethod = createStubbedMethod; + function createStubbedMethodBody() { + return ts.createBlock([ts.createThrow(ts.createNew(ts.createIdentifier("Error"), + /*typeArguments*/ undefined, [ts.createLiteral("Method not implemented.")]))], + /*multiline*/ true); + } + function createVisibilityModifier(flags) { if (flags & 4 /* Public */) { - return "public "; + return ts.createToken(114 /* PublicKeyword */); } else if (flags & 16 /* Protected */) { - return "protected "; + return ts.createToken(113 /* ProtectedKeyword */); } - return ""; + return undefined; } - var SymbolConstructor = ts.objectAllocator.getSymbolConstructor(); })(codefix = ts.codefix || (ts.codefix = {})); })(ts || (ts = {})); /// +/// /// /// /// @@ -80829,6 +85154,7 @@ var ts; /// /// /// +/// /// /// /// @@ -80841,7 +85167,6 @@ var ts; /// /// /// -/// /// /// /// @@ -80855,6 +85180,7 @@ var ts; /// /// /// +/// /// /// var ts; @@ -80862,8 +85188,8 @@ var ts; /** The version of the language service API */ ts.servicesVersion = "0.5"; function createNode(kind, pos, end, parent) { - var node = kind >= 142 /* FirstNode */ ? new NodeObject(kind, pos, end) : - kind === 70 /* Identifier */ ? new IdentifierObject(70 /* Identifier */, pos, end) : + var node = kind >= 143 /* FirstNode */ ? new NodeObject(kind, pos, end) : + kind === 71 /* Identifier */ ? new IdentifierObject(71 /* Identifier */, pos, end) : new TokenObject(kind, pos, end); node.parent = parent; return node; @@ -80920,11 +85246,11 @@ var ts; return pos; }; NodeObject.prototype.createSyntaxList = function (nodes) { - var list = createNode(296 /* SyntaxList */, nodes.pos, nodes.end, this); + var list = createNode(294 /* SyntaxList */, nodes.pos, nodes.end, this); list._children = []; var pos = nodes.pos; - for (var _i = 0, nodes_7 = nodes; _i < nodes_7.length; _i++) { - var node = nodes_7[_i]; + for (var _i = 0, nodes_9 = nodes; _i < nodes_9.length; _i++) { + var node = nodes_9[_i]; if (pos < node.pos) { pos = this.addSyntheticNodes(list._children, pos, node.pos); } @@ -80939,11 +85265,11 @@ var ts; NodeObject.prototype.createChildren = function (sourceFile) { var _this = this; var children; - if (this.kind >= 142 /* FirstNode */) { + if (this.kind >= 143 /* FirstNode */) { ts.scanner.setText((sourceFile || this.getSourceFile()).text); children = []; var pos_3 = this.pos; - var useJSDocScanner_1 = this.kind >= 282 /* FirstJSDocTagNode */ && this.kind <= 295 /* LastJSDocTagNode */; + var useJSDocScanner_1 = this.kind >= 283 /* FirstJSDocTagNode */ && this.kind <= 293 /* LastJSDocTagNode */; var processNode = function (node) { var isJSDocTagNode = ts.isJSDocTag(node); if (!isJSDocTagNode && pos_3 < node.pos) { @@ -81000,8 +85326,8 @@ var ts; if (!children.length) { return undefined; } - var child = ts.find(children, function (kid) { return kid.kind < 266 /* FirstJSDocNode */ || kid.kind > 295 /* LastJSDocNode */; }); - return child.kind < 142 /* FirstNode */ ? + var child = ts.find(children, function (kid) { return kid.kind < 267 /* FirstJSDocNode */ || kid.kind > 293 /* LastJSDocNode */; }); + return child.kind < 143 /* FirstNode */ ? child : child.getFirstToken(sourceFile); }; @@ -81011,7 +85337,10 @@ var ts; if (!child) { return undefined; } - return child.kind < 142 /* FirstNode */ ? child : child.getLastToken(sourceFile); + return child.kind < 143 /* FirstNode */ ? child : child.getLastToken(sourceFile); + }; + NodeObject.prototype.forEachChild = function (cbNode, cbNodeArray) { + return ts.forEachChild(this, cbNode, cbNodeArray); }; return NodeObject; }()); @@ -81065,6 +85394,9 @@ var ts; TokenOrIdentifierObject.prototype.getLastToken = function () { return undefined; }; + TokenOrIdentifierObject.prototype.forEachChild = function () { + return undefined; + }; return TokenOrIdentifierObject; }()); var SymbolObject = (function () { @@ -81087,6 +85419,12 @@ var ts; } return this.documentationComment; }; + SymbolObject.prototype.getJsDocTags = function () { + if (this.tags === undefined) { + this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations); + } + return this.tags; + }; return SymbolObject; }()); var TokenObject = (function (_super) { @@ -81105,7 +85443,7 @@ var ts; } return IdentifierObject; }(TokenOrIdentifierObject)); - IdentifierObject.prototype.kind = 70 /* Identifier */; + IdentifierObject.prototype.kind = 71 /* Identifier */; var TypeObject = (function () { function TypeObject(checker, flags) { this.checker = checker; @@ -81170,6 +85508,12 @@ var ts; } return this.documentationComment; }; + SignatureObject.prototype.getJsDocTags = function () { + if (this.jsDocTags === undefined) { + this.jsDocTags = this.declaration ? ts.JsDoc.getJsDocTagsFromDeclarations([this.declaration]) : []; + } + return this.jsDocTags; + }; return SignatureObject; }()); var SourceFileObject = (function (_super) { @@ -81232,9 +85576,9 @@ var ts; if (result_7 !== undefined) { return result_7; } - if (declaration.name.kind === 143 /* ComputedPropertyName */) { + if (declaration.name.kind === 144 /* ComputedPropertyName */) { var expr = declaration.name.expression; - if (expr.kind === 178 /* PropertyAccessExpression */) { + if (expr.kind === 179 /* PropertyAccessExpression */) { return expr.name.text; } return getTextOfIdentifierOrLiteral(expr); @@ -81244,7 +85588,7 @@ var ts; } function getTextOfIdentifierOrLiteral(node) { if (node) { - if (node.kind === 70 /* Identifier */ || + if (node.kind === 71 /* Identifier */ || node.kind === 9 /* StringLiteral */ || node.kind === 8 /* NumericLiteral */) { return node.text; @@ -81254,10 +85598,10 @@ var ts; } function visit(node) { switch (node.kind) { - case 227 /* FunctionDeclaration */: - case 185 /* FunctionExpression */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: + case 228 /* FunctionDeclaration */: + case 186 /* FunctionExpression */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: var functionDeclaration = node; var declarationName = getDeclarationName(functionDeclaration); if (declarationName) { @@ -81277,32 +85621,32 @@ var ts; } ts.forEachChild(node, visit); break; - case 228 /* ClassDeclaration */: - case 198 /* ClassExpression */: - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: - case 231 /* EnumDeclaration */: - case 232 /* ModuleDeclaration */: - case 236 /* ImportEqualsDeclaration */: - case 245 /* ExportSpecifier */: - case 241 /* ImportSpecifier */: - case 236 /* ImportEqualsDeclaration */: - case 238 /* ImportClause */: - case 239 /* NamespaceImport */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 162 /* TypeLiteral */: + case 229 /* ClassDeclaration */: + case 199 /* ClassExpression */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: + case 232 /* EnumDeclaration */: + case 233 /* ModuleDeclaration */: + case 237 /* ImportEqualsDeclaration */: + case 246 /* ExportSpecifier */: + case 242 /* ImportSpecifier */: + case 237 /* ImportEqualsDeclaration */: + case 239 /* ImportClause */: + case 240 /* NamespaceImport */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 163 /* TypeLiteral */: addDeclaration(node); ts.forEachChild(node, visit); break; - case 145 /* Parameter */: + case 146 /* Parameter */: // Only consider parameter properties if (!ts.hasModifier(node, 92 /* ParameterPropertyModifier */)) { break; } - // fall through - case 225 /* VariableDeclaration */: - case 175 /* BindingElement */: { + // falls through + case 226 /* VariableDeclaration */: + case 176 /* BindingElement */: { var decl = node; if (ts.isBindingPattern(decl.name)) { ts.forEachChild(decl.name, visit); @@ -81311,19 +85655,20 @@ var ts; if (decl.initializer) visit(decl.initializer); } - case 263 /* EnumMember */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + // falls through + case 264 /* EnumMember */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: addDeclaration(node); break; - case 243 /* ExportDeclaration */: + case 244 /* 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 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: var importClause = node.importClause; if (importClause) { // Handle default import case e.g.: @@ -81335,7 +85680,7 @@ var ts; // import * as NS from "mod"; // import {a, b as B} from "mod"; if (importClause.namedBindings) { - if (importClause.namedBindings.kind === 239 /* NamespaceImport */) { + if (importClause.namedBindings.kind === 240 /* NamespaceImport */) { addDeclaration(importClause.namedBindings); } else { @@ -81584,6 +85929,36 @@ var ts; }; return CancellationTokenObject; }()); + /* @internal */ + /** A cancellation that throttles calls to the host */ + var ThrottledCancellationToken = (function () { + function ThrottledCancellationToken(hostCancellationToken, throttleWaitMilliseconds) { + if (throttleWaitMilliseconds === void 0) { throttleWaitMilliseconds = 20; } + this.hostCancellationToken = hostCancellationToken; + this.throttleWaitMilliseconds = throttleWaitMilliseconds; + // Store when we last tried to cancel. Checking cancellation can be expensive (as we have + // to marshall over to the host layer). So we only bother actually checking once enough + // time has passed. + this.lastCancellationCheckTime = 0; + } + ThrottledCancellationToken.prototype.isCancellationRequested = function () { + var time = ts.timestamp(); + var duration = Math.abs(time - this.lastCancellationCheckTime); + if (duration >= this.throttleWaitMilliseconds) { + // Check no more than once every throttle wait milliseconds + this.lastCancellationCheckTime = time; + return this.hostCancellationToken.isCancellationRequested(); + } + return false; + }; + ThrottledCancellationToken.prototype.throwIfCancellationRequested = function () { + if (this.isCancellationRequested()) { + throw new ts.OperationCanceledException(); + } + }; + return ThrottledCancellationToken; + }()); + ts.ThrottledCancellationToken = ThrottledCancellationToken; function createLanguageService(host, documentRegistry) { if (documentRegistry === void 0) { documentRegistry = ts.createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory()); } var syntaxTreeCache = new SyntaxTreeCache(host); @@ -81865,12 +86240,12 @@ var ts; if (!symbol || typeChecker.isUnknownSymbol(symbol)) { // Try getting just type at this position and show switch (node.kind) { - case 70 /* Identifier */: - case 178 /* PropertyAccessExpression */: - case 142 /* QualifiedName */: - case 98 /* ThisKeyword */: - case 168 /* ThisType */: - case 96 /* SuperKeyword */: + case 71 /* Identifier */: + case 179 /* PropertyAccessExpression */: + case 143 /* QualifiedName */: + case 99 /* ThisKeyword */: + case 169 /* ThisType */: + case 97 /* SuperKeyword */: // For the identifiers/this/super etc get the type at position var type = typeChecker.getTypeAtLocation(node); if (type) { @@ -81879,7 +86254,8 @@ var ts; kindModifiers: ts.ScriptElementKindModifier.none, textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: ts.typeToDisplayParts(typeChecker, type, ts.getContainerNode(node)), - documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined + documentation: type.symbol ? type.symbol.getDocumentationComment() : undefined, + tags: type.symbol ? type.symbol.getJsDocTags() : undefined }; } } @@ -81891,7 +86267,8 @@ var ts; kindModifiers: ts.SymbolDisplay.getSymbolModifiers(symbol), textSpan: ts.createTextSpan(node.getStart(), node.getWidth()), displayParts: displayPartsDocumentationsAndKind.displayParts, - documentation: displayPartsDocumentationsAndKind.documentation + documentation: displayPartsDocumentationsAndKind.documentation, + tags: displayPartsDocumentationsAndKind.tags }; } /// Goto definition @@ -81899,15 +86276,16 @@ var ts; synchronizeHostData(); return ts.GoToDefinition.getDefinitionAtPosition(program, getValidSourceFile(fileName), position); } - /// Goto implementation - function getImplementationAtPosition(fileName, position) { - synchronizeHostData(); - return ts.GoToImplementation.getImplementationAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), ts.getTouchingPropertyName(getValidSourceFile(fileName), position)); - } function getTypeDefinitionAtPosition(fileName, position) { synchronizeHostData(); return ts.GoToDefinition.getTypeDefinitionAtPosition(program.getTypeChecker(), getValidSourceFile(fileName), position); } + /// Goto implementation + function getImplementationAtPosition(fileName, position) { + synchronizeHostData(); + return ts.FindAllReferences.getImplementationsAtPosition(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); + } + /// References and Occurrences function getOccurrencesAtPosition(fileName, position) { var results = getOccurrencesAtPositionCore(fileName, position); if (results) { @@ -81924,9 +86302,7 @@ var ts; var sourceFile = getValidSourceFile(fileName); return ts.DocumentHighlights.getDocumentHighlights(program.getTypeChecker(), cancellationToken, sourceFile, position, sourceFilesToSearch); } - /// References and Occurrences function getOccurrencesAtPositionCore(fileName, position) { - synchronizeHostData(); return convertDocumentHighlights(getDocumentHighlights(fileName, position, [fileName])); function convertDocumentHighlights(documentHighlights) { if (!documentHighlights) { @@ -81941,7 +86317,8 @@ var ts; fileName: entry.fileName, textSpan: highlightSpan.textSpan, isWriteAccess: highlightSpan.kind === ts.HighlightSpanKind.writtenReference, - isDefinition: false + isDefinition: false, + isInString: highlightSpan.isInString, }); } } @@ -81949,21 +86326,18 @@ var ts; } } function findRenameLocations(fileName, position, findInStrings, findInComments) { - var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments, /*isForRename*/ true); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position, { findInStrings: findInStrings, findInComments: findInComments, isForRename: true }); } function getReferencesAtPosition(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); - return ts.FindAllReferences.convertReferences(referencedSymbols); + return getReferences(fileName, position); + } + function getReferences(fileName, position, options) { + synchronizeHostData(); + return ts.FindAllReferences.findReferencedEntries(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, options); } function findReferences(fileName, position) { - var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings*/ false, /*findInComments*/ false, /*isForRename*/ false); - // Only include referenced symbols that have a valid definition. - return ts.filter(referencedSymbols, function (rs) { return !!rs.definition; }); - } - function findReferencedSymbols(fileName, position, findInStrings, findInComments, isForRename) { synchronizeHostData(); - return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position, findInStrings, findInComments, isForRename); + return ts.FindAllReferences.findReferencedSymbols(program.getTypeChecker(), cancellationToken, program.getSourceFiles(), getValidSourceFile(fileName), position); } /// NavigateTo function getNavigateToItems(searchValue, maxResultCount, fileName, excludeDtsFiles) { @@ -81982,7 +86356,8 @@ var ts; text: data }); } - var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles); + var customTransformers = host.getCustomTransformers && host.getCustomTransformers(); + var emitOutput = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); return { outputFiles: outputFiles, emitSkipped: emitOutput.emitSkipped @@ -82012,16 +86387,16 @@ var ts; return; } switch (node.kind) { - case 178 /* PropertyAccessExpression */: - case 142 /* QualifiedName */: + case 179 /* PropertyAccessExpression */: + case 143 /* QualifiedName */: case 9 /* StringLiteral */: - case 85 /* FalseKeyword */: - case 100 /* TrueKeyword */: - case 94 /* NullKeyword */: - case 96 /* SuperKeyword */: - case 98 /* ThisKeyword */: - case 168 /* ThisType */: - case 70 /* Identifier */: + case 86 /* FalseKeyword */: + case 101 /* TrueKeyword */: + case 95 /* NullKeyword */: + case 97 /* SuperKeyword */: + case 99 /* ThisKeyword */: + case 169 /* ThisType */: + case 71 /* Identifier */: break; // Cant create the text span default: @@ -82037,7 +86412,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 === 232 /* ModuleDeclaration */ && + if (nodeForStartPos.parent.parent.kind === 233 /* ModuleDeclaration */ && nodeForStartPos.parent.parent.body === nodeForStartPos.parent) { // Use parent module declarations name for start pos nodeForStartPos = nodeForStartPos.parent.parent.name; @@ -82060,10 +86435,10 @@ var ts; return ts.BreakpointResolver.spanInSourceFileAtLocation(sourceFile, position); } function getNavigationBarItems(fileName) { - return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationBarItems(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function getNavigationTree(fileName) { - return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName)); + return ts.NavigationBar.getNavigationTree(syntaxTreeCache.getCurrentSourceFile(fileName), cancellationToken); } function isTsOrTsxFile(fileName) { var kind = ts.getScriptKind(fileName, host); @@ -82096,7 +86471,7 @@ var ts; function getOutliningSpans(fileName) { // doesn't use compiler - no need to synchronize with host var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); - return ts.OutliningElementsCollector.collectElements(sourceFile); + return ts.OutliningElementsCollector.collectElements(sourceFile, cancellationToken); } function getBraceMatchingAtPosition(fileName, position) { var sourceFile = syntaxTreeCache.getCurrentSourceFile(fileName); @@ -82128,14 +86503,14 @@ var ts; return result; function getMatchingTokenKind(token) { switch (token.kind) { - case 16 /* OpenBraceToken */: return 17 /* CloseBraceToken */; - case 18 /* OpenParenToken */: return 19 /* CloseParenToken */; - case 20 /* OpenBracketToken */: return 21 /* CloseBracketToken */; - case 26 /* LessThanToken */: return 28 /* GreaterThanToken */; - case 17 /* CloseBraceToken */: return 16 /* OpenBraceToken */; - case 19 /* CloseParenToken */: return 18 /* OpenParenToken */; - case 21 /* CloseBracketToken */: return 20 /* OpenBracketToken */; - case 28 /* GreaterThanToken */: return 26 /* LessThanToken */; + case 17 /* OpenBraceToken */: return 18 /* CloseBraceToken */; + case 19 /* OpenParenToken */: return 20 /* CloseParenToken */; + case 21 /* OpenBracketToken */: return 22 /* CloseBracketToken */; + case 27 /* LessThanToken */: return 29 /* GreaterThanToken */; + case 18 /* CloseBraceToken */: return 17 /* OpenBraceToken */; + case 20 /* CloseParenToken */: return 19 /* OpenParenToken */; + case 22 /* CloseBracketToken */: return 21 /* OpenBracketToken */; + case 29 /* GreaterThanToken */: return 27 /* LessThanToken */; } return undefined; } @@ -82174,7 +86549,7 @@ var ts; } return []; } - function getCodeFixesAtPosition(fileName, start, end, errorCodes) { + function getCodeFixesAtPosition(fileName, start, end, errorCodes, formatOptions) { synchronizeHostData(); var sourceFile = getValidSourceFile(fileName); var span = { start: start, length: end - start }; @@ -82189,7 +86564,8 @@ var ts; program: program, newLineCharacter: newLineChar, host: host, - cancellationToken: cancellationToken + cancellationToken: cancellationToken, + rulesProvider: getRuleProvider(formatOptions) }; var fixes = ts.codefix.getFixes(context); if (fixes) { @@ -82400,6 +86776,7 @@ var ts; } ts.createLanguageService = createLanguageService; /* @internal */ + /** Names in the name table are escaped, so an identifier `__foo` will have a name table entry `___foo`. */ function getNameTable(sourceFile) { if (!sourceFile.nameTable) { initializeNameTable(sourceFile); @@ -82413,7 +86790,7 @@ var ts; sourceFile.nameTable = nameTable; function walk(node) { switch (node.kind) { - case 70 /* Identifier */: + case 71 /* Identifier */: setNameTable(node.text, node); break; case 9 /* StringLiteral */: @@ -82423,7 +86800,7 @@ var ts; // then we want 'something' to be in the name table. Similarly, if we have // "a['propname']" then we want to store "propname" in the name table. if (ts.isDeclarationName(node) || - node.parent.kind === 247 /* ExternalModuleReference */ || + node.parent.kind === 248 /* ExternalModuleReference */ || isArgumentOfElementAccessExpression(node) || ts.isLiteralComputedPropertyDeclarationName(node)) { setNameTable(node.text, node); @@ -82445,13 +86822,13 @@ var ts; } function isObjectLiteralElement(node) { switch (node.kind) { - case 252 /* JsxAttribute */: - case 254 /* JsxSpreadAttribute */: - case 260 /* PropertyAssignment */: - case 261 /* ShorthandPropertyAssignment */: - case 150 /* MethodDeclaration */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: + case 253 /* JsxAttribute */: + case 255 /* JsxSpreadAttribute */: + case 261 /* PropertyAssignment */: + case 262 /* ShorthandPropertyAssignment */: + case 151 /* MethodDeclaration */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: return true; } return false; @@ -82464,13 +86841,13 @@ var ts; switch (node.kind) { case 9 /* StringLiteral */: case 8 /* NumericLiteral */: - if (node.parent.kind === 143 /* ComputedPropertyName */) { + if (node.parent.kind === 144 /* ComputedPropertyName */) { return isObjectLiteralElement(node.parent.parent) ? node.parent.parent : undefined; } - // intentionally fall through - case 70 /* Identifier */: + // falls through + case 71 /* Identifier */: return isObjectLiteralElement(node.parent) && - (node.parent.parent.kind === 177 /* ObjectLiteralExpression */ || node.parent.parent.kind === 253 /* JsxAttributes */) && + (node.parent.parent.kind === 178 /* ObjectLiteralExpression */ || node.parent.parent.kind === 254 /* JsxAttributes */) && node.parent.name === node ? node.parent : undefined; } return undefined; @@ -82504,14 +86881,14 @@ var ts; function isArgumentOfElementAccessExpression(node) { return node && node.parent && - node.parent.kind === 179 /* ElementAccessExpression */ && + node.parent.kind === 180 /* ElementAccessExpression */ && node.parent.argumentExpression === node; } /** - * Get the path of the default library files (lib.d.ts) as distributed with the typescript - * node package. - * The functionality is not supported if the ts module is consumed outside of a node module. - */ + * Get the path of the default library files (lib.d.ts) as distributed with the typescript + * node package. + * The functionality is not supported if the ts module is consumed outside of a node module. + */ function getDefaultLibFilePath(options) { // Check __dirname is defined and that we are on a node.js system. if (typeof __dirname !== "undefined") { @@ -82585,143 +86962,144 @@ var ts; function spanInNode(node) { if (node) { switch (node.kind) { - case 207 /* VariableStatement */: + case 208 /* VariableStatement */: // Span on first variable declaration return spanInVariableDeclaration(node.declarationList.declarations[0]); - case 225 /* VariableDeclaration */: - case 148 /* PropertyDeclaration */: - case 147 /* PropertySignature */: + case 226 /* VariableDeclaration */: + case 149 /* PropertyDeclaration */: + case 148 /* PropertySignature */: return spanInVariableDeclaration(node); - case 145 /* Parameter */: + case 146 /* Parameter */: return spanInParameterDeclaration(node); - case 227 /* FunctionDeclaration */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 151 /* Constructor */: - case 185 /* FunctionExpression */: - case 186 /* ArrowFunction */: + case 228 /* FunctionDeclaration */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 152 /* Constructor */: + case 186 /* FunctionExpression */: + case 187 /* ArrowFunction */: return spanInFunctionDeclaration(node); - case 206 /* Block */: + case 207 /* Block */: if (ts.isFunctionBlock(node)) { return spanInFunctionBlock(node); } - // Fall through - case 233 /* ModuleBlock */: + // falls through + case 234 /* ModuleBlock */: return spanInBlock(node); - case 259 /* CatchClause */: + case 260 /* CatchClause */: return spanInBlock(node.block); - case 209 /* ExpressionStatement */: + case 210 /* ExpressionStatement */: // span on the expression return textSpan(node.expression); - case 218 /* ReturnStatement */: + case 219 /* ReturnStatement */: // span on return keyword and expression if present return textSpan(node.getChildAt(0), node.expression); - case 212 /* WhileStatement */: + case 213 /* WhileStatement */: // Span on while(...) return textSpanEndingAtNextToken(node, node.expression); - case 211 /* DoStatement */: + case 212 /* DoStatement */: // span in statement of the do statement return spanInNode(node.statement); - case 224 /* DebuggerStatement */: + case 225 /* DebuggerStatement */: // span on debugger keyword return textSpan(node.getChildAt(0)); - case 210 /* IfStatement */: + case 211 /* IfStatement */: // set on if(..) span return textSpanEndingAtNextToken(node, node.expression); - case 221 /* LabeledStatement */: + case 222 /* LabeledStatement */: // span in statement return spanInNode(node.statement); - case 217 /* BreakStatement */: - case 216 /* ContinueStatement */: + case 218 /* BreakStatement */: + case 217 /* ContinueStatement */: // On break or continue keyword and label if present return textSpan(node.getChildAt(0), node.label); - case 213 /* ForStatement */: + case 214 /* ForStatement */: return spanInForStatement(node); - case 214 /* ForInStatement */: + case 215 /* ForInStatement */: // span of for (a in ...) return textSpanEndingAtNextToken(node, node.expression); - case 215 /* ForOfStatement */: + case 216 /* ForOfStatement */: // span in initializer return spanInInitializerOfForLike(node); - case 220 /* SwitchStatement */: + case 221 /* SwitchStatement */: // span on switch(...) return textSpanEndingAtNextToken(node, node.expression); - case 256 /* CaseClause */: - case 257 /* DefaultClause */: + case 257 /* CaseClause */: + case 258 /* DefaultClause */: // span in first statement of the clause return spanInNode(node.statements[0]); - case 223 /* TryStatement */: + case 224 /* TryStatement */: // span in try block return spanInBlock(node.tryBlock); - case 222 /* ThrowStatement */: + case 223 /* ThrowStatement */: // span in throw ... return textSpan(node, node.expression); - case 242 /* ExportAssignment */: + case 243 /* ExportAssignment */: // span on export = id return textSpan(node, node.expression); - case 236 /* ImportEqualsDeclaration */: + case 237 /* ImportEqualsDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleReference); - case 237 /* ImportDeclaration */: + case 238 /* ImportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 243 /* ExportDeclaration */: + case 244 /* ExportDeclaration */: // import statement without including semicolon return textSpan(node, node.moduleSpecifier); - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: // span on complete module if it is instantiated if (ts.getModuleInstanceState(node) !== 1 /* Instantiated */) { return undefined; } - case 228 /* ClassDeclaration */: - case 231 /* EnumDeclaration */: - case 263 /* EnumMember */: - case 175 /* BindingElement */: + // falls through + case 229 /* ClassDeclaration */: + case 232 /* EnumDeclaration */: + case 264 /* EnumMember */: + case 176 /* BindingElement */: // span on complete node return textSpan(node); - case 219 /* WithStatement */: + case 220 /* WithStatement */: // span in statement return spanInNode(node.statement); - case 146 /* Decorator */: + case 147 /* Decorator */: return spanInNodeArray(node.parent.decorators); - case 173 /* ObjectBindingPattern */: - case 174 /* ArrayBindingPattern */: + case 174 /* ObjectBindingPattern */: + case 175 /* ArrayBindingPattern */: return spanInBindingPattern(node); // No breakpoint in interface, type alias - case 229 /* InterfaceDeclaration */: - case 230 /* TypeAliasDeclaration */: + case 230 /* InterfaceDeclaration */: + case 231 /* TypeAliasDeclaration */: return undefined; // Tokens: - case 24 /* SemicolonToken */: + case 25 /* SemicolonToken */: case 1 /* EndOfFileToken */: return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile)); - case 25 /* CommaToken */: + case 26 /* CommaToken */: return spanInPreviousNode(node); - case 16 /* OpenBraceToken */: + case 17 /* OpenBraceToken */: return spanInOpenBraceToken(node); - case 17 /* CloseBraceToken */: + case 18 /* CloseBraceToken */: return spanInCloseBraceToken(node); - case 21 /* CloseBracketToken */: + case 22 /* CloseBracketToken */: return spanInCloseBracketToken(node); - case 18 /* OpenParenToken */: + case 19 /* OpenParenToken */: return spanInOpenParenToken(node); - case 19 /* CloseParenToken */: + case 20 /* CloseParenToken */: return spanInCloseParenToken(node); - case 55 /* ColonToken */: + case 56 /* ColonToken */: return spanInColonToken(node); - case 28 /* GreaterThanToken */: - case 26 /* LessThanToken */: + case 29 /* GreaterThanToken */: + case 27 /* LessThanToken */: return spanInGreaterThanOrLessThanToken(node); // Keywords: - case 105 /* WhileKeyword */: + case 106 /* WhileKeyword */: return spanInWhileKeyword(node); - case 81 /* ElseKeyword */: - case 73 /* CatchKeyword */: - case 86 /* FinallyKeyword */: + case 82 /* ElseKeyword */: + case 74 /* CatchKeyword */: + case 87 /* FinallyKeyword */: return spanInNextNode(node); - case 141 /* OfKeyword */: + case 142 /* OfKeyword */: return spanInOfKeyword(node); default: // Destructuring pattern in destructuring assignment @@ -82733,14 +87111,14 @@ var ts; // Set breakpoint on identifier element of destructuring pattern // a or ...c or d: x from // [a, b, ...c] or { a, b } or { d: x } from destructuring pattern - if ((node.kind === 70 /* Identifier */ || - node.kind == 197 /* SpreadElement */ || - node.kind === 260 /* PropertyAssignment */ || - node.kind === 261 /* ShorthandPropertyAssignment */) && + if ((node.kind === 71 /* Identifier */ || + node.kind === 198 /* SpreadElement */ || + node.kind === 261 /* PropertyAssignment */ || + node.kind === 262 /* ShorthandPropertyAssignment */) && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(node.parent)) { return textSpan(node); } - if (node.kind === 193 /* BinaryExpression */) { + if (node.kind === 194 /* BinaryExpression */) { var binaryExpression = node; // Set breakpoint in destructuring pattern if its destructuring assignment // [a, b, c] or {a, b, c} of @@ -82749,7 +87127,7 @@ var ts; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left)) { return spanInArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left); } - if (binaryExpression.operatorToken.kind === 57 /* EqualsToken */ && + if (binaryExpression.operatorToken.kind === 58 /* EqualsToken */ && ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.parent)) { // Set breakpoint on assignment expression element of destructuring pattern // a = expression of @@ -82757,28 +87135,28 @@ var ts; // { a = expression, b, c } = someExpression return textSpan(node); } - if (binaryExpression.operatorToken.kind === 25 /* CommaToken */) { + if (binaryExpression.operatorToken.kind === 26 /* CommaToken */) { return spanInNode(binaryExpression.left); } } if (ts.isPartOfExpression(node)) { switch (node.parent.kind) { - case 211 /* DoStatement */: + case 212 /* DoStatement */: // Set span as if on while keyword return spanInPreviousNode(node); - case 146 /* Decorator */: + case 147 /* Decorator */: // Set breakpoint on the decorator emit return spanInNode(node.parent); - case 213 /* ForStatement */: - case 215 /* ForOfStatement */: + case 214 /* ForStatement */: + case 216 /* ForOfStatement */: return textSpan(node); - case 193 /* BinaryExpression */: - if (node.parent.operatorToken.kind === 25 /* CommaToken */) { + case 194 /* BinaryExpression */: + if (node.parent.operatorToken.kind === 26 /* CommaToken */) { // If this is a comma expression, the breakpoint is possible in this expression return textSpan(node); } break; - case 186 /* ArrowFunction */: + case 187 /* ArrowFunction */: if (node.parent.body === node) { // If this is body of arrow function, it is allowed to have the breakpoint return textSpan(node); @@ -82787,13 +87165,13 @@ var ts; } } // If this is name of property assignment, set breakpoint in the initializer - if (node.parent.kind === 260 /* PropertyAssignment */ && + if (node.parent.kind === 261 /* 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 === 183 /* TypeAssertionExpression */ && node.parent.type === node) { + if (node.parent.kind === 184 /* TypeAssertionExpression */ && node.parent.type === node) { return spanInNextNode(node.parent.type); } // return type of function go to previous token @@ -82801,8 +87179,8 @@ var ts; return spanInPreviousNode(node); } // initializer of variable/parameter declaration go to previous node - if ((node.parent.kind === 225 /* VariableDeclaration */ || - node.parent.kind === 145 /* Parameter */)) { + if ((node.parent.kind === 226 /* VariableDeclaration */ || + node.parent.kind === 146 /* Parameter */)) { var paramOrVarDecl = node.parent; if (paramOrVarDecl.initializer === node || paramOrVarDecl.type === node || @@ -82810,7 +87188,7 @@ var ts; return spanInPreviousNode(node); } } - if (node.parent.kind === 193 /* BinaryExpression */) { + if (node.parent.kind === 194 /* BinaryExpression */) { var binaryExpression = node.parent; if (ts.isArrayLiteralOrObjectLiteralDestructuringPattern(binaryExpression.left) && (binaryExpression.right === node || @@ -82824,8 +87202,8 @@ var ts; } } function textSpanFromVariableDeclaration(variableDeclaration) { - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] === variableDeclaration) { + if (variableDeclaration.parent.kind === 227 /* VariableDeclarationList */ && + variableDeclaration.parent.declarations[0] === variableDeclaration) { // First declaration - include let keyword return textSpan(ts.findPrecedingToken(variableDeclaration.pos, sourceFile, variableDeclaration.parent), variableDeclaration); } @@ -82836,7 +87214,7 @@ var ts; } function spanInVariableDeclaration(variableDeclaration) { // If declaration of for in statement, just set the span in parent - if (variableDeclaration.parent.parent.kind === 214 /* ForInStatement */) { + if (variableDeclaration.parent.parent.kind === 215 /* ForInStatement */) { return spanInNode(variableDeclaration.parent.parent); } // If this is a destructuring pattern, set breakpoint in binding pattern @@ -82847,11 +87225,11 @@ var ts; // or its declaration from 'for of' if (variableDeclaration.initializer || ts.hasModifier(variableDeclaration, 1 /* Export */) || - variableDeclaration.parent.parent.kind === 215 /* ForOfStatement */) { + variableDeclaration.parent.parent.kind === 216 /* ForOfStatement */) { return textSpanFromVariableDeclaration(variableDeclaration); } - var declarations = variableDeclaration.parent.declarations; - if (declarations && declarations[0] !== variableDeclaration) { + if (variableDeclaration.parent.kind === 227 /* VariableDeclarationList */ && + variableDeclaration.parent.declarations[0] !== variableDeclaration) { // If we cannot set breakpoint on this declaration, set it on previous one // Because the variable declaration may be binding pattern and // we would like to set breakpoint in last binding element if that's the case, @@ -82887,7 +87265,7 @@ var ts; } function canFunctionHaveSpanInWholeDeclaration(functionDeclaration) { return ts.hasModifier(functionDeclaration, 1 /* Export */) || - (functionDeclaration.parent.kind === 228 /* ClassDeclaration */ && functionDeclaration.kind !== 151 /* Constructor */); + (functionDeclaration.parent.kind === 229 /* ClassDeclaration */ && functionDeclaration.kind !== 152 /* Constructor */); } function spanInFunctionDeclaration(functionDeclaration) { // No breakpoints in the function signature @@ -82910,25 +87288,26 @@ var ts; } function spanInBlock(block) { switch (block.parent.kind) { - case 232 /* ModuleDeclaration */: + case 233 /* ModuleDeclaration */: if (ts.getModuleInstanceState(block.parent) !== 1 /* Instantiated */) { return undefined; } + // falls through // Set on parent if on same line otherwise on first statement - case 212 /* WhileStatement */: - case 210 /* IfStatement */: - case 214 /* ForInStatement */: + case 213 /* WhileStatement */: + case 211 /* IfStatement */: + case 215 /* 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 213 /* ForStatement */: - case 215 /* ForOfStatement */: + case 214 /* ForStatement */: + case 216 /* 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(forLikeStatement) { - if (forLikeStatement.initializer.kind === 226 /* VariableDeclarationList */) { + if (forLikeStatement.initializer.kind === 227 /* VariableDeclarationList */) { // Declaration list - set breakpoint in first declaration var variableDeclarationList = forLikeStatement.initializer; if (variableDeclarationList.declarations.length > 0) { @@ -82953,23 +87332,23 @@ var ts; } function spanInBindingPattern(bindingPattern) { // Set breakpoint in first binding element - var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(bindingPattern.elements, function (element) { return element.kind !== 200 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } // Empty binding pattern of binding element, set breakpoint on binding element - if (bindingPattern.parent.kind === 175 /* BindingElement */) { + if (bindingPattern.parent.kind === 176 /* BindingElement */) { return textSpan(bindingPattern.parent); } // Variable declaration is used as the span return textSpanFromVariableDeclaration(bindingPattern.parent); } function spanInArrayLiteralOrObjectLiteralDestructuringPattern(node) { - ts.Debug.assert(node.kind !== 174 /* ArrayBindingPattern */ && node.kind !== 173 /* ObjectBindingPattern */); - var elements = node.kind === 176 /* ArrayLiteralExpression */ ? + ts.Debug.assert(node.kind !== 175 /* ArrayBindingPattern */ && node.kind !== 174 /* ObjectBindingPattern */); + var elements = node.kind === 177 /* ArrayLiteralExpression */ ? node.elements : node.properties; - var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 199 /* OmittedExpression */ ? element : undefined; }); + var firstBindingElement = ts.forEach(elements, function (element) { return element.kind !== 200 /* OmittedExpression */ ? element : undefined; }); if (firstBindingElement) { return spanInNode(firstBindingElement); } @@ -82977,18 +87356,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 === 193 /* BinaryExpression */ ? node.parent : node); + return textSpan(node.parent.kind === 194 /* BinaryExpression */ ? node.parent : node); } // Tokens: function spanInOpenBraceToken(node) { switch (node.parent.kind) { - case 231 /* EnumDeclaration */: + case 232 /* EnumDeclaration */: var enumDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), enumDeclaration.members.length ? enumDeclaration.members[0] : enumDeclaration.getLastToken(sourceFile)); - case 228 /* ClassDeclaration */: + case 229 /* ClassDeclaration */: var classDeclaration = node.parent; return spanInNodeIfStartsOnSameLine(ts.findPrecedingToken(node.pos, sourceFile, node.parent), classDeclaration.members.length ? classDeclaration.members[0] : classDeclaration.getLastToken(sourceFile)); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: return spanInNodeIfStartsOnSameLine(node.parent.parent, node.parent.clauses[0]); } // Default to parent node @@ -82996,24 +87375,25 @@ var ts; } function spanInCloseBraceToken(node) { switch (node.parent.kind) { - case 233 /* ModuleBlock */: + case 234 /* ModuleBlock */: // If this is not an instantiated module block, no bp span if (ts.getModuleInstanceState(node.parent.parent) !== 1 /* Instantiated */) { return undefined; } - case 231 /* EnumDeclaration */: - case 228 /* ClassDeclaration */: + // falls through + case 232 /* EnumDeclaration */: + case 229 /* ClassDeclaration */: // Span on close brace token return textSpan(node); - case 206 /* Block */: + case 207 /* Block */: if (ts.isFunctionBlock(node.parent)) { // Span on close brace token return textSpan(node); } - // fall through - case 259 /* CatchClause */: + // falls through + case 260 /* CatchClause */: return spanInNode(ts.lastOrUndefined(node.parent.statements)); - case 234 /* CaseBlock */: + case 235 /* CaseBlock */: // breakpoint in last statement of the last clause var caseBlock = node.parent; var lastClause = ts.lastOrUndefined(caseBlock.clauses); @@ -83021,7 +87401,7 @@ var ts; return spanInNode(ts.lastOrUndefined(lastClause.statements)); } return undefined; - case 173 /* ObjectBindingPattern */: + case 174 /* 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); @@ -83037,7 +87417,7 @@ var ts; } function spanInCloseBracketToken(node) { switch (node.parent.kind) { - case 174 /* ArrayBindingPattern */: + case 175 /* 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); @@ -83052,12 +87432,12 @@ var ts; } } function spanInOpenParenToken(node) { - if (node.parent.kind === 211 /* DoStatement */ || - node.parent.kind === 180 /* CallExpression */ || - node.parent.kind === 181 /* NewExpression */) { + if (node.parent.kind === 212 /* DoStatement */ || + node.parent.kind === 181 /* CallExpression */ || + node.parent.kind === 182 /* NewExpression */) { return spanInPreviousNode(node); } - if (node.parent.kind === 184 /* ParenthesizedExpression */) { + if (node.parent.kind === 185 /* ParenthesizedExpression */) { return spanInNextNode(node); } // Default to parent node @@ -83066,21 +87446,21 @@ var ts; function spanInCloseParenToken(node) { // Is this close paren token of parameter list, set span in previous token switch (node.parent.kind) { - case 185 /* FunctionExpression */: - case 227 /* FunctionDeclaration */: - case 186 /* ArrowFunction */: - case 150 /* MethodDeclaration */: - case 149 /* MethodSignature */: - case 152 /* GetAccessor */: - case 153 /* SetAccessor */: - case 151 /* Constructor */: - case 212 /* WhileStatement */: - case 211 /* DoStatement */: - case 213 /* ForStatement */: - case 215 /* ForOfStatement */: - case 180 /* CallExpression */: - case 181 /* NewExpression */: - case 184 /* ParenthesizedExpression */: + case 186 /* FunctionExpression */: + case 228 /* FunctionDeclaration */: + case 187 /* ArrowFunction */: + case 151 /* MethodDeclaration */: + case 150 /* MethodSignature */: + case 153 /* GetAccessor */: + case 154 /* SetAccessor */: + case 152 /* Constructor */: + case 213 /* WhileStatement */: + case 212 /* DoStatement */: + case 214 /* ForStatement */: + case 216 /* ForOfStatement */: + case 181 /* CallExpression */: + case 182 /* NewExpression */: + case 185 /* ParenthesizedExpression */: return spanInPreviousNode(node); // Default to parent node default: @@ -83090,20 +87470,20 @@ var ts; function spanInColonToken(node) { // Is this : specifying return annotation of the function declaration if (ts.isFunctionLike(node.parent) || - node.parent.kind === 260 /* PropertyAssignment */ || - node.parent.kind === 145 /* Parameter */) { + node.parent.kind === 261 /* PropertyAssignment */ || + node.parent.kind === 146 /* Parameter */) { return spanInPreviousNode(node); } return spanInNode(node.parent); } function spanInGreaterThanOrLessThanToken(node) { - if (node.parent.kind === 183 /* TypeAssertionExpression */) { + if (node.parent.kind === 184 /* TypeAssertionExpression */) { return spanInNextNode(node); } return spanInNode(node.parent); } function spanInWhileKeyword(node) { - if (node.parent.kind === 211 /* DoStatement */) { + if (node.parent.kind === 212 /* DoStatement */) { // Set span on while expression return textSpanEndingAtNextToken(node, node.parent.expression); } @@ -83111,7 +87491,7 @@ var ts; return spanInNode(node.parent); } function spanInOfKeyword(node) { - if (node.parent.kind === 215 /* ForOfStatement */) { + if (node.parent.kind === 216 /* ForOfStatement */) { // Set using next token return spanInNextNode(node); } @@ -83123,6 +87503,26 @@ var ts; BreakpointResolver.spanInSourceFileAtLocation = spanInSourceFileAtLocation; })(BreakpointResolver = ts.BreakpointResolver || (ts.BreakpointResolver = {})); })(ts || (ts = {})); +/// +/// +var ts; +(function (ts) { + /** + * Transform one or more nodes using the supplied transformers. + * @param source A single `Node` or an array of `Node` objects. + * @param transformers An array of `TransformerFactory` callbacks used to process the transformation. + * @param compilerOptions Optional compiler options. + */ + function transform(source, transformers, compilerOptions) { + var diagnostics = []; + compilerOptions = ts.fixupCompilerOptions(compilerOptions, diagnostics); + var nodes = ts.isArray(source) ? source : [source]; + var result = ts.transformNodes(/*resolver*/ undefined, /*emitHost*/ undefined, compilerOptions, nodes, transformers, /*allowDtsFiles*/ true); + result.diagnostics = ts.concatenate(result.diagnostics, diagnostics); + return result; + } + ts.transform = transform; +})(ts || (ts = {})); // // Copyright (c) Microsoft Corporation. All rights reserved. // @@ -83164,8 +87564,7 @@ var ts; ScriptSnapshotShimAdapter.prototype.getChangeRange = function (oldSnapshot) { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); - // TODO: should this be '==='? - if (encoded == null) { + if (encoded === null) { return null; } var decoded = JSON.parse(encoded); @@ -83238,8 +87637,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCompilationSettings = function () { var settingsJson = this.shimHost.getCompilationSettings(); - // TODO: should this be '==='? - if (settingsJson == null || settingsJson == "") { + if (settingsJson === null || settingsJson === "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); } var compilerOptions = JSON.parse(settingsJson); @@ -83268,7 +87666,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getLocalizedDiagnosticMessages = function () { var diagnosticMessagesJson = this.shimHost.getLocalizedDiagnosticMessages(); - if (diagnosticMessagesJson == null || diagnosticMessagesJson == "") { + if (diagnosticMessagesJson === null || diagnosticMessagesJson === "") { return null; } try { @@ -83281,7 +87679,7 @@ var ts; }; LanguageServiceShimHostAdapter.prototype.getCancellationToken = function () { var hostCancellationToken = this.shimHost.getCancellationToken(); - return new ThrottledCancellationToken(hostCancellationToken); + return new ts.ThrottledCancellationToken(hostCancellationToken); }; LanguageServiceShimHostAdapter.prototype.getCurrentDirectory = function () { return this.shimHost.getCurrentDirectory(); @@ -83305,27 +87703,6 @@ var ts; return LanguageServiceShimHostAdapter; }()); ts.LanguageServiceShimHostAdapter = LanguageServiceShimHostAdapter; - /** A cancellation that throttles calls to the host */ - var ThrottledCancellationToken = (function () { - function ThrottledCancellationToken(hostCancellationToken) { - this.hostCancellationToken = hostCancellationToken; - // Store when we last tried to cancel. Checking cancellation can be expensive (as we have - // to marshall over to the host layer). So we only bother actually checking once enough - // time has passed. - this.lastCancellationCheckTime = 0; - } - ThrottledCancellationToken.prototype.isCancellationRequested = function () { - var time = ts.timestamp(); - var duration = Math.abs(time - this.lastCancellationCheckTime); - if (duration > 10) { - // Check no more than once every 10 ms. - this.lastCancellationCheckTime = time; - return this.hostCancellationToken.isCancellationRequested(); - } - return false; - }; - return ThrottledCancellationToken; - }()); var CoreServicesShimHostAdapter = (function () { function CoreServicesShimHostAdapter(shimHost) { var _this = this; @@ -83926,4 +88303,4 @@ 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 = "2.3"; +var toolsVersion = "2.4"; diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index a009c63ec7d..f610c4fd273 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -37,6 +37,16 @@ var ts; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + NodeBuilderFlags[NodeBuilderFlags["allowThisInObjectLiteral"] = 1] = "allowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["allowQualifedNameInPlaceOfIdentifier"] = 2] = "allowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowTypeParameterInQualifiedName"] = 4] = "allowTypeParameterInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["allowAnonymousIdentifier"] = 8] = "allowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyUnionOrIntersection"] = 16] = "allowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["allowEmptyTuple"] = 32] = "allowEmptyTuple"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); var TypeReferenceSerializationKind; (function (TypeReferenceSerializationKind) { TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown"; @@ -142,7 +152,7 @@ var ts; })(ts || (ts = {})); var ts; (function (ts) { - ts.version = "2.3.0"; + ts.version = "2.4.0"; })(ts || (ts = {})); (function (ts) { ts.collator = typeof Intl === "object" && typeof Intl.Collator === "function" ? new Intl.Collator(undefined, { usage: "sort", sensitivity: "accent" }) : undefined; @@ -294,6 +304,20 @@ var ts; return undefined; } ts.forEach = forEach; + function findAncestor(node, callback) { + while (node) { + var result = callback(node); + if (result === "quit") { + return undefined; + } + else if (result) { + return node; + } + node = node.parent; + } + return undefined; + } + ts.findAncestor = findAncestor; function zipWith(arrayA, arrayB, callback) { Debug.assert(arrayA.length === arrayB.length); for (var i = 0; i < arrayA.length; i++) { @@ -847,10 +871,10 @@ var ts; return keys; } ts.getOwnKeys = getOwnKeys; - function arrayFrom(iterator) { + function arrayFrom(iterator, map) { var result = []; for (var _a = iterator.next(), value = _a.value, done = _a.done; !done; _b = iterator.next(), value = _b.value, done = _b.done, _b) { - result.push(value); + result.push(map ? map(value) : value); } return result; var _b; @@ -903,10 +927,10 @@ var ts; } for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { var arg = args_1[_a]; - for (var _b = 0, _c = getOwnKeys(arg); _b < _c.length; _b++) { - var p = _c[_b]; - t[p] = arg[p]; - } + for (var p in arg) + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } } return t; } @@ -2032,136 +2056,29 @@ var ts; } } ts.tryGetExtensionFromPath = tryGetExtensionFromPath; + function isCheckJsEnabledForFile(sourceFile, compilerOptions) { + return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs; + } + ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile; })(ts || (ts = {})); var ts; (function (ts) { - ts.sys = (function () { - function getWScriptSystem() { - var fso = new ActiveXObject("Scripting.FileSystemObject"); - var shell = new ActiveXObject("WScript.Shell"); - var fileStream = new ActiveXObject("ADODB.Stream"); - fileStream.Type = 2; - var binaryStream = new ActiveXObject("ADODB.Stream"); - binaryStream.Type = 1; - var args = []; - for (var i = 0; i < WScript.Arguments.length; i++) { - args[i] = WScript.Arguments.Item(i); - } - function readFile(fileName, encoding) { - if (!fso.FileExists(fileName)) { - return undefined; - } - fileStream.Open(); - try { - if (encoding) { - fileStream.Charset = encoding; - fileStream.LoadFromFile(fileName); - } - else { - fileStream.Charset = "x-ansi"; - fileStream.LoadFromFile(fileName); - var bom = fileStream.ReadText(2) || ""; - fileStream.Position = 0; - fileStream.Charset = bom.length >= 2 && (bom.charCodeAt(0) === 0xFF && bom.charCodeAt(1) === 0xFE || bom.charCodeAt(0) === 0xFE && bom.charCodeAt(1) === 0xFF) ? "unicode" : "utf-8"; - } - return fileStream.ReadText(); - } - catch (e) { - throw e; - } - finally { - fileStream.Close(); - } - } - function writeFile(fileName, data, writeByteOrderMark) { - fileStream.Open(); - binaryStream.Open(); - try { - fileStream.Charset = "utf-8"; - fileStream.WriteText(data); - if (writeByteOrderMark) { - fileStream.Position = 0; - } - else { - fileStream.Position = 3; - } - fileStream.CopyTo(binaryStream); - binaryStream.SaveToFile(fileName, 2); - } - finally { - binaryStream.Close(); - fileStream.Close(); - } - } - function getNames(collection) { - var result = []; - for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) { - result.push(e.item().Name); - } - return result.sort(); - } - function getDirectories(path) { - var folder = fso.GetFolder(path); - return getNames(folder.subfolders); - } - function getAccessibleFileSystemEntries(path) { - try { - var folder = fso.GetFolder(path || "."); - var files = getNames(folder.files); - var directories = getNames(folder.subfolders); - return { files: files, directories: directories }; - } - catch (e) { - return { files: [], directories: [] }; - } - } - function readDirectory(path, extensions, excludes, includes) { - return ts.matchFiles(path, extensions, excludes, includes, false, shell.CurrentDirectory, getAccessibleFileSystemEntries); - } - var wscriptSystem = { - args: args, - newLine: "\r\n", - useCaseSensitiveFileNames: false, - write: function (s) { - WScript.StdOut.Write(s); - }, - readFile: readFile, - writeFile: writeFile, - resolvePath: function (path) { - return fso.GetAbsolutePathName(path); - }, - fileExists: function (path) { - return fso.FileExists(path); - }, - directoryExists: function (path) { - return fso.FolderExists(path); - }, - createDirectory: function (directoryName) { - if (!wscriptSystem.directoryExists(directoryName)) { - fso.CreateFolder(directoryName); - } - }, - getExecutingFilePath: function () { - return WScript.ScriptFullName; - }, - getCurrentDirectory: function () { - return shell.CurrentDirectory; - }, - getDirectories: getDirectories, - getEnvironmentVariable: function (name) { - return new ActiveXObject("WScript.Shell").ExpandEnvironmentStrings("%" + name + "%"); - }, - readDirectory: readDirectory, - exit: function (exitCode) { - try { - WScript.Quit(exitCode); - } - catch (e) { - } - } - }; - return wscriptSystem; + function getNodeMajorVersion() { + if (typeof process === "undefined") { + return undefined; } + var version = process.version; + if (!version) { + return undefined; + } + var dot = version.indexOf("."); + if (dot === -1) { + return undefined; + } + return parseInt(version.substring(1, dot)); + } + ts.getNodeMajorVersion = getNodeMajorVersion; + ts.sys = (function () { function getNodeSystem() { var _fs = require("fs"); var _path = require("path"); @@ -2225,9 +2142,8 @@ var ts; } } var watchedFileSet = createWatchedFileSet(); - function isNode4OrLater() { - return parseInt(process.version.charAt(1)) >= 4; - } + var nodeVersion = getNodeMajorVersion(); + var isNode4OrLater = nodeVersion >= 4; function isFileSystemCaseSensitive() { if (platform === "win32" || platform === "win64") { return false; @@ -2361,10 +2277,10 @@ var ts; }, watchDirectory: function (directoryName, callback, recursive) { var options; - if (!directoryExists(directoryName) || (isUNCPath(directoryName) && process.platform === "win32")) { + if (!directoryExists(directoryName)) { return noOpFileWatcher; } - if (isNode4OrLater() && (process.platform === "win32" || process.platform === "darwin")) { + if (isNode4OrLater && (process.platform === "win32" || process.platform === "darwin")) { options = { persistent: true, recursive: !!recursive }; } else { @@ -2374,11 +2290,7 @@ var ts; if (eventName === "rename") { callback(!relativeFileName ? relativeFileName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName))); } - ; }); - function isUNCPath(s) { - return s.length > 2 && s.charCodeAt(0) === 47 && s.charCodeAt(1) === 47; - } }, resolvePath: function (path) { return _path.resolve(path); @@ -2494,9 +2406,6 @@ var ts; if (typeof ChakraHost !== "undefined") { sys = getChakraSystem(); } - else if (typeof WScript !== "undefined" && typeof ActiveXObject === "function") { - sys = getWScriptSystem(); - } else if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") { sys = getNodeSystem(); } @@ -2565,11 +2474,11 @@ var ts; Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Promise_compatible_constructor_value: { code: 1055, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_valid_async_function_return_type_in_ES5_SlashES3_because_it_does_not_refer_to_a_Prom_1055", message: "Type '{0}' is not a valid async function return type in ES5/ES3 because it does not refer to a Promise-compatible constructor value." }, Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher: { code: 1056, category: ts.DiagnosticCategory.Error, key: "Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher_1056", message: "Accessors are only available when targeting ECMAScript 5 and higher." }, An_async_function_or_method_must_have_a_valid_awaitable_return_type: { code: 1057, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_must_have_a_valid_awaitable_return_type_1057", message: "An async function or method must have a valid awaitable return type." }, - Operand_for_await_does_not_have_a_valid_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "Operand_for_await_does_not_have_a_valid_callable_then_member_1058", message: "Operand for 'await' does not have a valid callable 'then' member." }, - Return_expression_in_async_function_does_not_have_a_valid_callable_then_member: { code: 1059, category: ts.DiagnosticCategory.Error, key: "Return_expression_in_async_function_does_not_have_a_valid_callable_then_member_1059", message: "Return expression in async function does not have a valid callable 'then' member." }, - Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member: { code: 1060, category: ts.DiagnosticCategory.Error, key: "Expression_body_for_async_arrow_function_does_not_have_a_valid_callable_then_member_1060", message: "Expression body for async arrow function does not have a valid callable 'then' member." }, + The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1058, category: ts.DiagnosticCategory.Error, key: "The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_t_1058", message: "The return type of an async function must either be a valid promise or must not contain a callable 'then' member." }, + A_promise_must_have_a_then_method: { code: 1059, category: ts.DiagnosticCategory.Error, key: "A_promise_must_have_a_then_method_1059", message: "A promise must have a 'then' method." }, + The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback: { code: 1060, category: ts.DiagnosticCategory.Error, key: "The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback_1060", message: "The first parameter of the 'then' method of a promise must be a callback." }, 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." }, + Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method: { code: 1062, category: ts.DiagnosticCategory.Error, key: "Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method_1062", message: "Type 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." }, @@ -2594,6 +2503,7 @@ var ts; Invalid_use_of_0_in_strict_mode: { code: 1100, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_in_strict_mode_1100", message: "Invalid use of '{0}' in strict mode." }, with_statements_are_not_allowed_in_strict_mode: { code: 1101, category: ts.DiagnosticCategory.Error, key: "with_statements_are_not_allowed_in_strict_mode_1101", message: "'with' statements are not allowed in strict mode." }, delete_cannot_be_called_on_an_identifier_in_strict_mode: { code: 1102, category: ts.DiagnosticCategory.Error, key: "delete_cannot_be_called_on_an_identifier_in_strict_mode_1102", message: "'delete' cannot be called on an identifier in strict mode." }, + A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator: { code: 1103, category: ts.DiagnosticCategory.Error, key: "A_for_await_of_statement_is_only_allowed_within_an_async_function_or_async_generator_1103", message: "A 'for-await-of' statement is only allowed within an async function or async generator." }, A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement: { code: 1104, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement_1104", message: "A 'continue' statement can only be used within an enclosing iteration statement." }, A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement: { code: 1105, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement_1105", message: "A 'break' statement can only be used within an enclosing iteration or switch statement." }, Jump_target_cannot_cross_function_boundary: { code: 1107, category: ts.DiagnosticCategory.Error, key: "Jump_target_cannot_cross_function_boundary_1107", message: "Jump target cannot cross function boundary." }, @@ -2601,7 +2511,7 @@ var ts; Expression_expected: { code: 1109, category: ts.DiagnosticCategory.Error, key: "Expression_expected_1109", message: "Expression expected." }, Type_expected: { code: 1110, category: ts.DiagnosticCategory.Error, key: "Type_expected_1110", message: "Type expected." }, A_default_clause_cannot_appear_more_than_once_in_a_switch_statement: { code: 1113, category: ts.DiagnosticCategory.Error, key: "A_default_clause_cannot_appear_more_than_once_in_a_switch_statement_1113", message: "A 'default' clause cannot appear more than once in a 'switch' statement." }, - Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'" }, + Duplicate_label_0: { code: 1114, category: ts.DiagnosticCategory.Error, key: "Duplicate_label_0_1114", message: "Duplicate label '{0}'." }, A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement: { code: 1115, category: ts.DiagnosticCategory.Error, key: "A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement_1115", message: "A 'continue' statement can only jump to a label of an enclosing iteration statement." }, A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement: { code: 1116, category: ts.DiagnosticCategory.Error, key: "A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement_1116", message: "A 'break' statement can only jump to a label of an enclosing statement." }, An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode: { code: 1117, category: ts.DiagnosticCategory.Error, key: "An_object_literal_cannot_have_multiple_properties_with_the_same_name_in_strict_mode_1117", message: "An object literal cannot have multiple properties with the same name in strict mode." }, @@ -2633,9 +2543,9 @@ var ts; 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_use_imports_exports_or_module_augmentations_when_module_is_none: { code: 1148, category: ts.DiagnosticCategory.Error, key: "Cannot_use_imports_exports_or_module_augmentations_when_module_is_none_1148", message: "Cannot use imports, exports, or module augmentations when '--module' is 'none'." }, - 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" }, + 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" }, + const_declarations_must_be_initialized: { code: 1155, category: ts.DiagnosticCategory.Error, key: "const_declarations_must_be_initialized_1155", message: "'const' declarations must be initialized." }, const_declarations_can_only_be_declared_inside_a_block: { code: 1156, category: ts.DiagnosticCategory.Error, key: "const_declarations_can_only_be_declared_inside_a_block_1156", message: "'const' declarations can only be declared inside a block." }, let_declarations_can_only_be_declared_inside_a_block: { code: 1157, category: ts.DiagnosticCategory.Error, key: "let_declarations_can_only_be_declared_inside_a_block_1157", message: "'let' declarations can only be declared inside a block." }, Unterminated_template_literal: { code: 1160, category: ts.DiagnosticCategory.Error, key: "Unterminated_template_literal_1160", message: "Unterminated template literal." }, @@ -2684,8 +2594,8 @@ var ts; Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided: { code: 1208, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided_1208", message: "Cannot compile namespaces when the '--isolatedModules' flag is provided." }, Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided: { code: 1209, category: ts.DiagnosticCategory.Error, key: "Ambient_const_enums_are_not_allowed_when_the_isolatedModules_flag_is_provided_1209", message: "Ambient const enums are not allowed when the '--isolatedModules' flag is provided." }, Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode: { code: 1210, category: ts.DiagnosticCategory.Error, key: "Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode_1210", message: "Invalid use of '{0}'. Class definitions are automatically in strict mode." }, - A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name" }, - Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode" }, + A_class_declaration_without_the_default_modifier_must_have_a_name: { code: 1211, category: ts.DiagnosticCategory.Error, key: "A_class_declaration_without_the_default_modifier_must_have_a_name_1211", message: "A class declaration without the 'default' modifier must have a name." }, + Identifier_expected_0_is_a_reserved_word_in_strict_mode: { code: 1212, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_1212", message: "Identifier expected. '{0}' is a reserved word in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode: { code: 1213, category: ts.DiagnosticCategory.Error, key: "Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_stric_1213", message: "Identifier expected. '{0}' is a reserved word in strict mode. Class definitions are automatically in strict mode." }, Identifier_expected_0_is_a_reserved_word_in_strict_mode_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." }, @@ -2737,6 +2647,9 @@ var ts; A_parameter_property_cannot_be_declared_using_a_rest_parameter: { code: 1317, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_cannot_be_declared_using_a_rest_parameter_1317", message: "A parameter property cannot be declared using a rest parameter." }, An_abstract_accessor_cannot_have_an_implementation: { code: 1318, category: ts.DiagnosticCategory.Error, key: "An_abstract_accessor_cannot_have_an_implementation_1318", message: "An abstract accessor cannot have an implementation." }, A_default_export_can_only_be_used_in_an_ECMAScript_style_module: { code: 1319, category: ts.DiagnosticCategory.Error, key: "A_default_export_can_only_be_used_in_an_ECMAScript_style_module_1319", message: "A default export can only be used in an ECMAScript-style module." }, + Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1320, category: ts.DiagnosticCategory.Error, key: "Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320", message: "Type of 'await' operand must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1321, category: ts.DiagnosticCategory.Error, key: "Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321", message: "Type of 'yield' operand in an async generator must either be a valid promise or must not contain a callable 'then' member." }, + Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member: { code: 1322, category: ts.DiagnosticCategory.Error, key: "Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322", message: "Type of iterated elements of a 'yield*' operand must either be a valid promise or must not contain a callable 'then' member." }, Duplicate_identifier_0: { code: 2300, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_2300", message: "Duplicate identifier '{0}'." }, Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: ts.DiagnosticCategory.Error, key: "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", message: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." }, Static_members_cannot_reference_class_type_parameters: { code: 2302, category: ts.DiagnosticCategory.Error, key: "Static_members_cannot_reference_class_type_parameters_2302", message: "Static members cannot reference class type parameters." }, @@ -2798,13 +2711,13 @@ var ts; The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2358, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_paramete_2358", message: "The left-hand side of an 'instanceof' expression must be of type 'any', an object type or a type parameter." }, The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_Function_interface_type: { code: 2359, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_instanceof_expression_must_be_of_type_any_or_of_a_type_assignable_to_the_F_2359", message: "The right-hand side of an 'instanceof' expression must be of type 'any' or of a type assignable to the 'Function' interface type." }, The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol: { code: 2360, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol_2360", message: "The left-hand side of an 'in' expression must be of type 'any', 'string', 'number', or 'symbol'." }, - The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter" }, + The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2361, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_in_expression_must_be_of_type_any_an_object_type_or_a_type_parameter_2361", message: "The right-hand side of an 'in' expression must be of type 'any', an object type or a type parameter." }, The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2362, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2362", message: "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type: { code: 2363, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type_2363", message: "The right-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." }, The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access: { code: 2364, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access_2364", message: "The left-hand side of an assignment expression must be a variable or a property access." }, Operator_0_cannot_be_applied_to_types_1_and_2: { code: 2365, category: ts.DiagnosticCategory.Error, key: "Operator_0_cannot_be_applied_to_types_1_and_2_2365", message: "Operator '{0}' cannot be applied to types '{1}' and '{2}'." }, Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined: { code: 2366, category: ts.DiagnosticCategory.Error, key: "Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined_2366", message: "Function lacks ending return statement and return type does not include 'undefined'." }, - Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'" }, + Type_parameter_name_cannot_be_0: { code: 2368, category: ts.DiagnosticCategory.Error, key: "Type_parameter_name_cannot_be_0_2368", message: "Type parameter name cannot be '{0}'." }, A_parameter_property_is_only_allowed_in_a_constructor_implementation: { code: 2369, category: ts.DiagnosticCategory.Error, key: "A_parameter_property_is_only_allowed_in_a_constructor_implementation_2369", message: "A parameter property is only allowed in a constructor implementation." }, A_rest_parameter_must_be_of_an_array_type: { code: 2370, category: ts.DiagnosticCategory.Error, key: "A_rest_parameter_must_be_of_an_array_type_2370", message: "A rest parameter must be of an array type." }, A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation: { code: 2371, category: ts.DiagnosticCategory.Error, key: "A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation_2371", message: "A parameter initializer is only allowed in a function or constructor implementation." }, @@ -2844,12 +2757,12 @@ var ts; The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access: { code: 2406, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_must_be_a_variable_or_a_property_access_2406", message: "The left-hand side of a 'for...in' statement must be a variable or a property access." }, The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter: { code: 2407, category: ts.DiagnosticCategory.Error, key: "The_right_hand_side_of_a_for_in_statement_must_be_of_type_any_an_object_type_or_a_type_parameter_2407", message: "The right-hand side of a 'for...in' statement must be of type 'any', an object type or a type parameter." }, Setters_cannot_return_a_value: { code: 2408, category: ts.DiagnosticCategory.Error, key: "Setters_cannot_return_a_value_2408", message: "Setters cannot return a value." }, - Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class" }, + Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class: { code: 2409, category: ts.DiagnosticCategory.Error, key: "Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class_2409", message: "Return type of constructor signature must be assignable to the instance type of the class." }, The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any: { code: 2410, category: ts.DiagnosticCategory.Error, key: "The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any_2410", message: "The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'." }, Property_0_of_type_1_is_not_assignable_to_string_index_type_2: { code: 2411, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_string_index_type_2_2411", message: "Property '{0}' of type '{1}' is not assignable to string index type '{2}'." }, Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2: { code: 2412, category: ts.DiagnosticCategory.Error, key: "Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2_2412", message: "Property '{0}' of type '{1}' is not assignable to numeric index type '{2}'." }, Numeric_index_type_0_is_not_assignable_to_string_index_type_1: { code: 2413, category: ts.DiagnosticCategory.Error, key: "Numeric_index_type_0_is_not_assignable_to_string_index_type_1_2413", message: "Numeric index type '{0}' is not assignable to string index type '{1}'." }, - 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_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}'." }, 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}'." }, @@ -2858,19 +2771,19 @@ var ts; Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_property: { code: 2424, category: ts.DiagnosticCategory.Error, key: "Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_proper_2424", message: "Class '{0}' defines instance member function '{1}', but extended class '{2}' defines it as instance member property." }, 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}'" }, + 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_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}'" }, + 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." }, - A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged" }, - A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged" }, + A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged: { code: 2433, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merg_2433", message: "A namespace declaration cannot be in a different file from a class or function with which it is merged." }, + A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged: { code: 2434, category: ts.DiagnosticCategory.Error, key: "A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged_2434", message: "A namespace declaration cannot be located prior to a class or function with which it is merged." }, Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces: { code: 2435, category: ts.DiagnosticCategory.Error, key: "Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces_2435", message: "Ambient modules cannot be nested in other modules or namespaces." }, Ambient_module_declaration_cannot_specify_relative_module_name: { code: 2436, category: ts.DiagnosticCategory.Error, key: "Ambient_module_declaration_cannot_specify_relative_module_name_2436", message: "Ambient module declaration cannot specify relative module name." }, - Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name" }, - Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'" }, + Module_0_is_hidden_by_a_local_declaration_with_the_same_name: { code: 2437, category: ts.DiagnosticCategory.Error, key: "Module_0_is_hidden_by_a_local_declaration_with_the_same_name_2437", message: "Module '{0}' is hidden by a local declaration with the same name." }, + Import_name_cannot_be_0: { code: 2438, category: ts.DiagnosticCategory.Error, key: "Import_name_cannot_be_0_2438", message: "Import name cannot be '{0}'." }, Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name: { code: 2439, category: ts.DiagnosticCategory.Error, key: "Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relati_2439", message: "Import or export declaration in an ambient module declaration cannot reference module through relative module name." }, - Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'" }, + Import_declaration_conflicts_with_local_declaration_of_0: { code: 2440, category: ts.DiagnosticCategory.Error, key: "Import_declaration_conflicts_with_local_declaration_of_0_2440", message: "Import declaration conflicts with local declaration of '{0}'." }, Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module: { code: 2441, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_reserves_name_1_in_top_level_scope_of_a_module_2441", message: "Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module." }, Types_have_separate_declarations_of_a_private_property_0: { code: 2442, category: ts.DiagnosticCategory.Error, key: "Types_have_separate_declarations_of_a_private_property_0_2442", message: "Types have separate declarations of a private property '{0}'." }, Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2: { code: 2443, category: ts.DiagnosticCategory.Error, key: "Property_0_is_protected_but_type_1_is_not_a_class_derived_from_2_2443", message: "Property '{0}' is protected but type '{1}' is not a class derived from '{2}'." }, @@ -2879,18 +2792,20 @@ 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." }, + Class_0_used_before_its_declaration: { code: 2449, category: ts.DiagnosticCategory.Error, key: "Class_0_used_before_its_declaration_2449", message: "Class '{0}' used before its declaration." }, + Enum_0_used_before_its_declaration: { code: 2450, category: ts.DiagnosticCategory.Error, key: "Enum_0_used_before_its_declaration_2450", message: "Enum '{0}' used before its declaration." }, 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." }, Variable_0_is_used_before_being_assigned: { code: 2454, category: ts.DiagnosticCategory.Error, key: "Variable_0_is_used_before_being_assigned_2454", message: "Variable '{0}' is used before being assigned." }, Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0: { code: 2455, category: ts.DiagnosticCategory.Error, key: "Type_argument_candidate_1_is_not_a_valid_type_argument_because_it_is_not_a_supertype_of_candidate_0_2455", message: "Type argument candidate '{1}' is not a valid type argument because it is not a supertype of candidate '{0}'." }, Type_alias_0_circularly_references_itself: { code: 2456, category: ts.DiagnosticCategory.Error, key: "Type_alias_0_circularly_references_itself_2456", message: "Type alias '{0}' circularly references itself." }, - Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'" }, + Type_alias_name_cannot_be_0: { code: 2457, category: ts.DiagnosticCategory.Error, key: "Type_alias_name_cannot_be_0_2457", message: "Type alias name cannot be '{0}'." }, An_AMD_module_cannot_have_multiple_name_assignments: { code: 2458, category: ts.DiagnosticCategory.Error, key: "An_AMD_module_cannot_have_multiple_name_assignments_2458", message: "An AMD module cannot have multiple name assignments." }, Type_0_has_no_property_1_and_no_string_index_signature: { code: 2459, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_and_no_string_index_signature_2459", message: "Type '{0}' has no property '{1}' and no string index signature." }, Type_0_has_no_property_1: { code: 2460, category: ts.DiagnosticCategory.Error, key: "Type_0_has_no_property_1_2460", message: "Type '{0}' has no property '{1}'." }, Type_0_is_not_an_array_type: { code: 2461, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_2461", message: "Type '{0}' is not an array type." }, - A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern" }, + A_rest_element_must_be_last_in_a_destructuring_pattern: { code: 2462, category: ts.DiagnosticCategory.Error, key: "A_rest_element_must_be_last_in_a_destructuring_pattern_2462", message: "A rest element must be last in a destructuring pattern." }, A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature: { code: 2463, category: ts.DiagnosticCategory.Error, key: "A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature_2463", message: "A binding pattern parameter cannot be optional in an implementation signature." }, A_computed_property_name_must_be_of_type_string_number_symbol_or_any: { code: 2464, category: ts.DiagnosticCategory.Error, key: "A_computed_property_name_must_be_of_type_string_number_symbol_or_any_2464", message: "A computed property name must be of type 'string', 'number', 'symbol', or 'any'." }, this_cannot_be_referenced_in_a_computed_property_name: { code: 2465, category: ts.DiagnosticCategory.Error, key: "this_cannot_be_referenced_in_a_computed_property_name_2465", message: "'this' cannot be referenced in a computed property name." }, @@ -2911,13 +2826,13 @@ var ts; let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations: { code: 2480, category: ts.DiagnosticCategory.Error, key: "let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations_2480", message: "'let' is not allowed to be used as a name in 'let' or 'const' declarations." }, 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}'" }, + 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_must_be_a_variable_or_a_property_access: { code: 2487, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_of_statement_must_be_a_variable_or_a_property_access_2487", message: "The left-hand side of a 'for...of' statement must be a variable or a property access." }, 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." }, The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property_2490", message: "The type returned by the 'next()' method of an iterator must have a 'value' property." }, The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: ts.DiagnosticCategory.Error, key: "The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern_2491", message: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." }, - Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause" }, + Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: ts.DiagnosticCategory.Error, key: "Cannot_redeclare_identifier_0_in_catch_clause_2492", message: "Cannot redeclare identifier '{0}' in catch clause." }, Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2: { code: 2493, category: ts.DiagnosticCategory.Error, key: "Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2_2493", message: "Tuple type '{0}' with length '{1}' cannot be assigned to tuple with length '{2}'." }, Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher: { code: 2494, category: ts.DiagnosticCategory.Error, key: "Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher_2494", message: "Using a string in a 'for...of' statement is only supported in ECMAScript 5 and higher." }, Type_0_is_not_an_array_type_or_a_string_type: { code: 2495, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_2495", message: "Type '{0}' is not an array type or a string type." }, @@ -2929,6 +2844,7 @@ var ts; A_rest_element_cannot_contain_a_binding_pattern: { code: 2501, category: ts.DiagnosticCategory.Error, key: "A_rest_element_cannot_contain_a_binding_pattern_2501", message: "A rest element cannot contain a binding pattern." }, _0_is_referenced_directly_or_indirectly_in_its_own_type_annotation: { code: 2502, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_type_annotation_2502", message: "'{0}' is referenced directly or indirectly in its own type annotation." }, Cannot_find_namespace_0: { code: 2503, category: ts.DiagnosticCategory.Error, key: "Cannot_find_namespace_0_2503", message: "Cannot find namespace '{0}'." }, + Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator: { code: 2504, category: ts.DiagnosticCategory.Error, key: "Type_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator_2504", message: "Type must have a '[Symbol.asyncIterator]()' method that returns an async iterator." }, A_generator_cannot_have_a_void_type_annotation: { code: 2505, category: ts.DiagnosticCategory.Error, key: "A_generator_cannot_have_a_void_type_annotation_2505", message: "A generator cannot have a 'void' type annotation." }, _0_is_referenced_directly_or_indirectly_in_its_own_base_expression: { code: 2506, category: ts.DiagnosticCategory.Error, key: "_0_is_referenced_directly_or_indirectly_in_its_own_base_expression_2506", message: "'{0}' is referenced directly or indirectly in its own base expression." }, Type_0_is_not_a_constructor_function_type: { code: 2507, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_a_constructor_function_type_2507", message: "Type '{0}' is not a constructor function type." }, @@ -2943,6 +2859,7 @@ var ts; All_declarations_of_an_abstract_method_must_be_consecutive: { code: 2516, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_an_abstract_method_must_be_consecutive_2516", message: "All declarations of an abstract method must be consecutive." }, Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type: { code: 2517, category: ts.DiagnosticCategory.Error, key: "Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type_2517", message: "Cannot assign an abstract constructor type to a non-abstract constructor type." }, A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard: { code: 2518, category: ts.DiagnosticCategory.Error, key: "A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard_2518", message: "A 'this'-based type guard is not compatible with a parameter-based type guard." }, + An_async_iterator_must_have_a_next_method: { code: 2519, category: ts.DiagnosticCategory.Error, key: "An_async_iterator_must_have_a_next_method_2519", message: "An async iterator must have a 'next()' method." }, Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions: { code: 2520, category: ts.DiagnosticCategory.Error, key: "Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions_2520", message: "Duplicate identifier '{0}'. Compiler uses declaration '{1}' to support async functions." }, Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions: { code: 2521, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_0_that_compiler_uses_to_support_async_functions_2521", message: "Expression resolves to variable declaration '{0}' that compiler uses to support async functions." }, The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_using_a_standard_function_or_method: { code: 2522, category: ts.DiagnosticCategory.Error, key: "The_arguments_object_cannot_be_referenced_in_an_async_function_or_method_in_ES3_and_ES5_Consider_usi_2522", message: "The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method." }, @@ -2970,25 +2887,29 @@ var ts; Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference: { code: 2544, category: ts.DiagnosticCategory.Error, key: "Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta__2544", message: "Expression resolves to variable declaration '_newTarget' that compiler uses to capture 'new.target' meta-property reference." }, A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any: { code: 2545, category: ts.DiagnosticCategory.Error, key: "A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any_2545", message: "A mixin class must have a constructor with a single rest parameter of type 'any[]'." }, Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1: { code: 2546, category: ts.DiagnosticCategory.Error, key: "Property_0_has_conflicting_declarations_and_is_inaccessible_in_type_1_2546", message: "Property '{0}' has conflicting declarations and is inaccessible in type '{1}'." }, + The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value_property: { code: 2547, category: ts.DiagnosticCategory.Error, key: "The_type_returned_by_the_next_method_of_an_async_iterator_must_be_a_promise_for_a_type_with_a_value__2547", message: "The type returned by the 'next()' method of an async iterator must be a promise for a type with a 'value' property." }, + Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2548, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator_2548", message: "Type '{0}' is not an array type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2549, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_an_array_type_or_a_string_type_or_does_not_have_a_Symbol_iterator_method_that_returns__2549", message: "Type '{0}' is not an array type or a string type or does not have a '[Symbol.iterator]()' method that returns an iterator." }, + Generic_type_instantiation_is_excessively_deep_and_possibly_infinite: { code: 2550, category: ts.DiagnosticCategory.Error, key: "Generic_type_instantiation_is_excessively_deep_and_possibly_infinite_2550", message: "Generic type instantiation is excessively deep and possibly infinite." }, 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." }, - Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'" }, + Property_0_in_type_1_is_not_assignable_to_type_2: { code: 2603, category: ts.DiagnosticCategory.Error, key: "Property_0_in_type_1_is_not_assignable_to_type_2_2603", message: "Property '{0}' in type '{1}' is not assignable to type '{2}'." }, JSX_element_type_0_does_not_have_any_construct_or_call_signatures: { code: 2604, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_does_not_have_any_construct_or_call_signatures_2604", message: "JSX element type '{0}' does not have any construct or call signatures." }, JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements: { code: 2605, category: ts.DiagnosticCategory.Error, key: "JSX_element_type_0_is_not_a_constructor_function_for_JSX_elements_2605", message: "JSX element type '{0}' is not a constructor function for JSX elements." }, Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property: { code: 2606, category: ts.DiagnosticCategory.Error, key: "Property_0_of_JSX_spread_attribute_is_not_assignable_to_target_property_2606", message: "Property '{0}' of JSX spread attribute is not assignable to target property." }, - JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property" }, - The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property" }, + JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property: { code: 2607, category: ts.DiagnosticCategory.Error, key: "JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property_2607", message: "JSX element class does not support attributes because it does not have a '{0}' property." }, + The_global_type_JSX_0_may_not_have_more_than_one_property: { code: 2608, category: ts.DiagnosticCategory.Error, key: "The_global_type_JSX_0_may_not_have_more_than_one_property_2608", message: "The global type 'JSX.{0}' may not have more than one property." }, JSX_spread_child_must_be_an_array_type: { code: 2609, category: ts.DiagnosticCategory.Error, key: "JSX_spread_child_must_be_an_array_type_2609", message: "JSX spread child must be an array type." }, Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity: { code: 2649, category: ts.DiagnosticCategory.Error, key: "Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity_2649", message: "Cannot augment module '{0}' with value exports because it resolves to a non-module entity." }, - Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React" }, + Cannot_emit_namespaced_JSX_elements_in_React: { code: 2650, category: ts.DiagnosticCategory.Error, key: "Cannot_emit_namespaced_JSX_elements_in_React_2650", message: "Cannot emit namespaced JSX elements in React." }, A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums: { code: 2651, category: ts.DiagnosticCategory.Error, key: "A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_memb_2651", message: "A member initializer in a enum declaration cannot reference members declared after it, including members defined in other enums." }, Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead: { code: 2652, category: ts.DiagnosticCategory.Error, key: "Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_d_2652", message: "Merged declaration '{0}' cannot include a default export declaration. Consider adding a separate 'export default {0}' declaration instead." }, Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1: { code: 2653, category: ts.DiagnosticCategory.Error, key: "Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1_2653", message: "Non-abstract class expression does not implement inherited abstract member '{0}' from class '{1}'." }, Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_package_author_to_update_the_package_definition: { code: 2654, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_cannot_contain_tripleslash_references_Please_contact_the_pack_2654", message: "Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition." }, Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_the_package_definition: { code: 2656, category: ts.DiagnosticCategory.Error, key: "Exported_external_package_typings_file_0_is_not_a_module_Please_contact_the_package_author_to_update_2656", message: "Exported external package typings file '{0}' is not a module. Please contact the package author to update the package definition." }, - JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element" }, - Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'" }, + JSX_expressions_must_have_one_parent_element: { code: 2657, category: ts.DiagnosticCategory.Error, key: "JSX_expressions_must_have_one_parent_element_2657", message: "JSX expressions must have one parent element." }, + Type_0_provides_no_match_for_the_signature_1: { code: 2658, category: ts.DiagnosticCategory.Error, key: "Type_0_provides_no_match_for_the_signature_1_2658", message: "Type '{0}' provides no match for the signature '{1}'." }, super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher: { code: 2659, category: ts.DiagnosticCategory.Error, key: "super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_highe_2659", message: "'super' is only allowed in members of object literal expressions when option 'target' is 'ES2015' or higher." }, super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions: { code: 2660, category: ts.DiagnosticCategory.Error, key: "super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions_2660", message: "'super' can only be referenced in members of derived classes or object literal expressions." }, Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module: { code: 2661, category: ts.DiagnosticCategory.Error, key: "Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module_2661", message: "Cannot export '{0}'. Only local declarations can be exported from a module." }, @@ -3020,7 +2941,6 @@ var ts; All_declarations_of_0_must_have_identical_modifiers: { code: 2687, category: ts.DiagnosticCategory.Error, key: "All_declarations_of_0_must_have_identical_modifiers_2687", message: "All declarations of '{0}' must have identical modifiers." }, Cannot_find_type_definition_file_for_0: { code: 2688, category: ts.DiagnosticCategory.Error, key: "Cannot_find_type_definition_file_for_0_2688", message: "Cannot find type definition file for '{0}'." }, Cannot_extend_an_interface_0_Did_you_mean_implements: { code: 2689, category: ts.DiagnosticCategory.Error, key: "Cannot_extend_an_interface_0_Did_you_mean_implements_2689", message: "Cannot extend an interface '{0}'. Did you mean 'implements'?" }, - A_class_must_be_declared_after_its_base_class: { code: 2690, category: ts.DiagnosticCategory.Error, key: "A_class_must_be_declared_after_its_base_class_2690", message: "A class must be declared after its base class." }, An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead: { code: 2691, category: ts.DiagnosticCategory.Error, key: "An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead_2691", message: "An import path cannot end with a '{0}' extension. Consider importing '{1}' instead." }, _0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible: { code: 2692, category: ts.DiagnosticCategory.Error, key: "_0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible_2692", message: "'{0}' is a primitive, but '{1}' is a wrapper object. Prefer using '{0}' when possible." }, _0_only_refers_to_a_type_but_is_being_used_as_a_value_here: { code: 2693, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_value_here_2693", message: "'{0}' only refers to a type, but is being used as a value here." }, @@ -3033,11 +2953,14 @@ var ts; Rest_types_may_only_be_created_from_object_types: { code: 2700, category: ts.DiagnosticCategory.Error, key: "Rest_types_may_only_be_created_from_object_types_2700", message: "Rest types may only be created from object types." }, The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access: { code: 2701, category: ts.DiagnosticCategory.Error, key: "The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access_2701", message: "The target of an object rest assignment must be a variable or a property access." }, _0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here: { code: 2702, category: ts.DiagnosticCategory.Error, key: "_0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here_2702", message: "'{0}' only refers to a type, but is being used as a namespace here." }, - The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference" }, - The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property" }, + The_operand_of_a_delete_operator_must_be_a_property_reference: { code: 2703, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_must_be_a_property_reference_2703", message: "The operand of a delete operator must be a property reference." }, + The_operand_of_a_delete_operator_cannot_be_a_read_only_property: { code: 2704, category: ts.DiagnosticCategory.Error, key: "The_operand_of_a_delete_operator_cannot_be_a_read_only_property_2704", message: "The operand of a delete operator cannot be a read-only property." }, An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_declaration_for_the_Promise_constructor_or_include_ES2015_in_your_lib_option: { code: 2705, category: ts.DiagnosticCategory.Error, key: "An_async_function_or_method_in_ES5_SlashES3_requires_the_Promise_constructor_Make_sure_you_have_a_de_2705", message: "An async function or method in ES5/ES3 requires the 'Promise' constructor. Make sure you have a declaration for the 'Promise' constructor or include 'ES2015' in your `--lib` option." }, Required_type_parameters_may_not_follow_optional_type_parameters: { code: 2706, category: ts.DiagnosticCategory.Error, key: "Required_type_parameters_may_not_follow_optional_type_parameters_2706", message: "Required type parameters may not follow optional type parameters." }, Generic_type_0_requires_between_1_and_2_type_arguments: { code: 2707, category: ts.DiagnosticCategory.Error, key: "Generic_type_0_requires_between_1_and_2_type_arguments_2707", message: "Generic type '{0}' requires between {1} and {2} type arguments." }, + Cannot_use_namespace_0_as_a_value: { code: 2708, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_value_2708", message: "Cannot use namespace '{0}' as a value." }, + Cannot_use_namespace_0_as_a_type: { code: 2709, category: ts.DiagnosticCategory.Error, key: "Cannot_use_namespace_0_as_a_type_2709", message: "Cannot use namespace '{0}' as a type." }, + _0_are_specified_twice_The_attribute_named_0_will_be_overwritten: { code: 2710, category: ts.DiagnosticCategory.Error, key: "_0_are_specified_twice_The_attribute_named_0_will_be_overwritten_2710", message: "'{0}' are specified twice. The attribute named '{0}' will be overwritten." }, 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}'." }, @@ -3117,12 +3040,11 @@ var ts; Cannot_find_the_common_subdirectory_path_for_the_input_files: { code: 5009, category: ts.DiagnosticCategory.Error, key: "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", message: "Cannot find the common subdirectory path for the input files." }, File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5010, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", message: "File specification cannot end in a recursive directory wildcard ('**'): '{0}'." }, File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0: { code: 5011, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_multiple_recursive_directory_wildcards_Asterisk_Asterisk_Colon_0_5011", message: "File specification cannot contain multiple recursive directory wildcards ('**'): '{0}'." }, - Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}" }, - Unsupported_file_encoding: { code: 5013, category: ts.DiagnosticCategory.Error, key: "Unsupported_file_encoding_5013", message: "Unsupported file encoding." }, + Cannot_read_file_0_Colon_1: { code: 5012, category: ts.DiagnosticCategory.Error, key: "Cannot_read_file_0_Colon_1_5012", message: "Cannot read file '{0}': {1}." }, Failed_to_parse_file_0_Colon_1: { code: 5014, category: ts.DiagnosticCategory.Error, key: "Failed_to_parse_file_0_Colon_1_5014", message: "Failed to parse file '{0}': {1}." }, Unknown_compiler_option_0: { code: 5023, category: ts.DiagnosticCategory.Error, key: "Unknown_compiler_option_0_5023", message: "Unknown compiler option '{0}'." }, Compiler_option_0_requires_a_value_of_type_1: { code: 5024, category: ts.DiagnosticCategory.Error, key: "Compiler_option_0_requires_a_value_of_type_1_5024", message: "Compiler option '{0}' requires a value of type {1}." }, - Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}" }, + Could_not_write_file_0_Colon_1: { code: 5033, category: ts.DiagnosticCategory.Error, key: "Could_not_write_file_0_Colon_1_5033", message: "Could not write file '{0}': {1}." }, Option_project_cannot_be_mixed_with_source_files_on_a_command_line: { code: 5042, category: ts.DiagnosticCategory.Error, key: "Option_project_cannot_be_mixed_with_source_files_on_a_command_line_5042", message: "Option 'project' cannot be mixed with source files on a command line." }, Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher: { code: 5047, category: ts.DiagnosticCategory.Error, key: "Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES_5047", message: "Option 'isolatedModules' can only be used when either option '--module' is provided or option 'target' is 'ES2015' or higher." }, Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided: { code: 5051, category: ts.DiagnosticCategory.Error, key: "Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided_5051", message: "Option '{0} can only be used when either option '--inlineSourceMap' or option '--sourceMap' is provided." }, @@ -3131,12 +3053,12 @@ var ts; A_tsconfig_json_file_is_already_defined_at_Colon_0: { code: 5054, category: ts.DiagnosticCategory.Error, key: "A_tsconfig_json_file_is_already_defined_at_Colon_0_5054", message: "A 'tsconfig.json' file is already defined at: '{0}'." }, Cannot_write_file_0_because_it_would_overwrite_input_file: { code: 5055, category: ts.DiagnosticCategory.Error, key: "Cannot_write_file_0_because_it_would_overwrite_input_file_5055", message: "Cannot write file '{0}' because it would overwrite input file." }, 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}'" }, + 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}'." }, 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" }, + 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." }, Substitutions_for_pattern_0_should_be_an_array: { code: 5063, category: ts.DiagnosticCategory.Error, key: "Substitutions_for_pattern_0_should_be_an_array_5063", message: "Substitutions for pattern '{0}' should be an array." }, Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: { code: 5064, category: ts.DiagnosticCategory.Error, key: "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", message: "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'." }, File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: { code: 5065, category: ts.DiagnosticCategory.Error, key: "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", message: "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'." }, @@ -3154,11 +3076,11 @@ var ts; Do_not_emit_outputs: { code: 6010, category: ts.DiagnosticCategory.Message, key: "Do_not_emit_outputs_6010", message: "Do not emit outputs." }, Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking: { code: 6011, category: ts.DiagnosticCategory.Message, key: "Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typech_6011", message: "Allow default imports from modules with no default export. This does not affect code emit, just typechecking." }, Skip_type_checking_of_declaration_files: { code: 6012, category: ts.DiagnosticCategory.Message, key: "Skip_type_checking_of_declaration_files_6012", message: "Skip type checking of declaration files." }, - Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'" }, - Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'" }, + Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT: { code: 6015, category: ts.DiagnosticCategory.Message, key: "Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT_6015", message: "Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'." }, + Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015: { code: 6016, category: ts.DiagnosticCategory.Message, key: "Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015_6016", message: "Specify module code generation: 'commonjs', 'amd', 'system', 'umd' or 'es2015'." }, Print_this_message: { code: 6017, category: ts.DiagnosticCategory.Message, key: "Print_this_message_6017", message: "Print this message." }, Print_the_compiler_s_version: { code: 6019, category: ts.DiagnosticCategory.Message, key: "Print_the_compiler_s_version_6019", message: "Print the compiler's version." }, - Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'" }, + Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json: { code: 6020, category: ts.DiagnosticCategory.Message, key: "Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json_6020", message: "Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'." }, Syntax_Colon_0: { code: 6023, category: ts.DiagnosticCategory.Message, key: "Syntax_Colon_0_6023", message: "Syntax: {0}" }, options: { code: 6024, category: ts.DiagnosticCategory.Message, key: "options_6024", message: "options" }, file: { code: 6025, category: ts.DiagnosticCategory.Message, key: "file_6025", message: "file" }, @@ -3178,7 +3100,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_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}" }, + Argument_for_0_option_must_be_Colon_1: { code: 6046, category: ts.DiagnosticCategory.Error, key: "Argument_for_0_option_must_be_Colon_1_6046", message: "Argument for '{0}' option must be: {1}." }, 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}'." }, Unable_to_open_file_0: { code: 6050, category: ts.DiagnosticCategory.Error, key: "Unable_to_open_file_0_6050", message: "Unable to open file '{0}'." }, @@ -3200,18 +3122,18 @@ var ts; Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file: { code: 6070, category: ts.DiagnosticCategory.Message, key: "Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file_6070", message: "Initializes a TypeScript project and creates a tsconfig.json file." }, Successfully_created_a_tsconfig_json_file: { code: 6071, category: ts.DiagnosticCategory.Message, key: "Successfully_created_a_tsconfig_json_file_6071", message: "Successfully created a tsconfig.json file." }, Suppress_excess_property_checks_for_object_literals: { code: 6072, category: ts.DiagnosticCategory.Message, key: "Suppress_excess_property_checks_for_object_literals_6072", message: "Suppress excess property checks for object literals." }, - Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context. (experimental)" }, + Stylize_errors_and_messages_using_color_and_context_experimental: { code: 6073, category: ts.DiagnosticCategory.Message, key: "Stylize_errors_and_messages_using_color_and_context_experimental_6073", message: "Stylize errors and messages using color and context (experimental)." }, Do_not_report_errors_on_unused_labels: { code: 6074, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unused_labels_6074", message: "Do not report errors on unused labels." }, Report_error_when_not_all_code_paths_in_function_return_a_value: { code: 6075, category: ts.DiagnosticCategory.Message, key: "Report_error_when_not_all_code_paths_in_function_return_a_value_6075", message: "Report error when not all code paths in function return a value." }, Report_errors_for_fallthrough_cases_in_switch_statement: { code: 6076, category: ts.DiagnosticCategory.Message, key: "Report_errors_for_fallthrough_cases_in_switch_statement_6076", message: "Report errors for fallthrough cases in switch statement." }, Do_not_report_errors_on_unreachable_code: { code: 6077, category: ts.DiagnosticCategory.Message, key: "Do_not_report_errors_on_unreachable_code_6077", message: "Do not report errors on unreachable code." }, Disallow_inconsistently_cased_references_to_the_same_file: { code: 6078, category: ts.DiagnosticCategory.Message, key: "Disallow_inconsistently_cased_references_to_the_same_file_6078", message: "Disallow inconsistently-cased references to the same file." }, Specify_library_files_to_be_included_in_the_compilation_Colon: { code: 6079, category: ts.DiagnosticCategory.Message, key: "Specify_library_files_to_be_included_in_the_compilation_Colon_6079", message: "Specify library files to be included in the compilation: " }, - Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'" }, + Specify_JSX_code_generation_Colon_preserve_react_native_or_react: { code: 6080, category: ts.DiagnosticCategory.Message, key: "Specify_JSX_code_generation_Colon_preserve_react_native_or_react_6080", message: "Specify JSX code generation: 'preserve', 'react-native', or 'react'." }, File_0_has_an_unsupported_extension_so_skipping_it: { code: 6081, category: ts.DiagnosticCategory.Message, key: "File_0_has_an_unsupported_extension_so_skipping_it_6081", message: "File '{0}' has an unsupported extension, so skipping it." }, 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}." }, 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." }, - Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit_6084", message: "Specify the object invoked for createElement and __spread when targeting 'react' JSX emit" }, + Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit: { code: 6084, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react__6084", message: "[Deprecated] Use '--jsxFactory' instead. Specify the object invoked for createElement when targeting 'react' JSX emit" }, Enable_tracing_of_the_name_resolution_process: { code: 6085, category: ts.DiagnosticCategory.Message, key: "Enable_tracing_of_the_name_resolution_process_6085", message: "Enable tracing of the name 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}'." }, @@ -3233,12 +3155,12 @@ var ts; 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_0_field_in_package_json_to_be_string_got_1: { code: 6105, category: ts.DiagnosticCategory.Message, key: "Expected_type_of_0_field_in_package_json_to_be_string_got_1_6105", message: "Expected type of '{0}' field in 'package.json' to be 'string', got '{1}'." }, - 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" }, + 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." }, Enable_strict_null_checks: { code: 6113, category: ts.DiagnosticCategory.Message, key: "Enable_strict_null_checks_6113", message: "Enable strict null checks." }, Unknown_option_excludes_Did_you_mean_exclude: { code: 6114, category: ts.DiagnosticCategory.Error, key: "Unknown_option_excludes_Did_you_mean_exclude_6114", message: "Unknown option 'excludes'. Did you mean 'exclude'?" }, @@ -3248,26 +3170,26 @@ var ts; Resolving_from_node_modules_folder: { code: 6118, category: ts.DiagnosticCategory.Message, key: "Resolving_from_node_modules_folder_6118", message: "Resolving from node_modules folder..." }, Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2: { code: 6119, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2_6119", message: "======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========" }, Type_reference_directive_0_was_not_resolved: { code: 6120, category: ts.DiagnosticCategory.Message, key: "Type_reference_directive_0_was_not_resolved_6120", message: "======== Type reference directive '{0}' was not resolved. ========" }, - Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'" }, + Resolving_with_primary_search_path_0: { code: 6121, category: ts.DiagnosticCategory.Message, key: "Resolving_with_primary_search_path_0_6121", message: "Resolving with primary search path '{0}'." }, Root_directory_cannot_be_determined_skipping_primary_search_paths: { code: 6122, category: ts.DiagnosticCategory.Message, key: "Root_directory_cannot_be_determined_skipping_primary_search_paths_6122", message: "Root directory cannot be determined, skipping primary search paths." }, Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set: { code: 6123, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set_6123", message: "======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========" }, Type_declaration_files_to_be_included_in_compilation: { code: 6124, category: ts.DiagnosticCategory.Message, key: "Type_declaration_files_to_be_included_in_compilation_6124", message: "Type declaration files to be included in compilation." }, - Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'" }, + Looking_up_in_node_modules_folder_initial_location_0: { code: 6125, category: ts.DiagnosticCategory.Message, key: "Looking_up_in_node_modules_folder_initial_location_0_6125", message: "Looking up in 'node_modules' folder, initial location '{0}'." }, Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder: { code: 6126, category: ts.DiagnosticCategory.Message, key: "Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_mod_6126", message: "Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder." }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1: { code: 6127, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1_6127", message: "======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========" }, Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set: { code: 6128, category: ts.DiagnosticCategory.Message, key: "Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set_6128", message: "======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========" }, The_config_file_0_found_doesn_t_contain_any_source_files: { code: 6129, category: ts.DiagnosticCategory.Error, key: "The_config_file_0_found_doesn_t_contain_any_source_files_6129", message: "The config file '{0}' found doesn't contain any source files." }, - Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'" }, + Resolving_real_path_for_0_result_1: { code: 6130, category: ts.DiagnosticCategory.Message, key: "Resolving_real_path_for_0_result_1_6130", message: "Resolving real path for '{0}', result '{1}'." }, Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system: { code: 6131, category: ts.DiagnosticCategory.Error, key: "Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system_6131", message: "Cannot compile modules using option '{0}' unless the '--module' flag is 'amd' or 'system'." }, - File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it" }, + File_name_0_has_a_1_extension_stripping_it: { code: 6132, category: ts.DiagnosticCategory.Message, key: "File_name_0_has_a_1_extension_stripping_it_6132", message: "File name '{0}' has a '{1}' extension - stripping it." }, _0_is_declared_but_never_used: { code: 6133, category: ts.DiagnosticCategory.Error, key: "_0_is_declared_but_never_used_6133", message: "'{0}' is declared but never used." }, Report_errors_on_unused_locals: { code: 6134, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_locals_6134", message: "Report errors on unused locals." }, Report_errors_on_unused_parameters: { code: 6135, category: ts.DiagnosticCategory.Message, key: "Report_errors_on_unused_parameters_6135", message: "Report errors on unused parameters." }, - The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files" }, + The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files: { code: 6136, category: ts.DiagnosticCategory.Message, key: "The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files_6136", message: "The maximum dependency depth to search under node_modules and load JavaScript files." }, Property_0_is_declared_but_never_used: { code: 6138, category: ts.DiagnosticCategory.Error, key: "Property_0_is_declared_but_never_used_6138", message: "Property '{0}' is declared but never used." }, Import_emit_helpers_from_tslib: { code: 6139, category: ts.DiagnosticCategory.Message, key: "Import_emit_helpers_from_tslib_6139", message: "Import emit helpers from 'tslib'." }, Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using_cache_location_2: { code: 6140, category: ts.DiagnosticCategory.Error, key: "Auto_discovery_for_typings_is_enabled_in_project_0_Running_extra_resolution_pass_for_module_1_using__6140", message: "Auto discovery for typings is enabled in project '{0}'. Running extra resolution pass for module '{1}' using cache location '{2}'." }, - Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file" }, + Parse_in_strict_mode_and_emit_use_strict_for_each_source_file: { code: 6141, category: ts.DiagnosticCategory.Message, key: "Parse_in_strict_mode_and_emit_use_strict_for_each_source_file_6141", message: "Parse in strict mode and emit \"use strict\" for each source file." }, Module_0_was_resolved_to_1_but_jsx_is_not_set: { code: 6142, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_jsx_is_not_set_6142", message: "Module '{0}' was resolved to '{1}', but '--jsx' is not set." }, Module_0_was_resolved_to_1_but_allowJs_is_not_set: { code: 6143, category: ts.DiagnosticCategory.Error, key: "Module_0_was_resolved_to_1_but_allowJs_is_not_set_6143", message: "Module '{0}' was resolved to '{1}', but '--allowJs' is not set." }, Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1: { code: 6144, category: ts.DiagnosticCategory.Message, key: "Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1_6144", message: "Module '{0}' was resolved as locally declared ambient module in file '{1}'." }, @@ -3275,6 +3197,40 @@ var ts; Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h: { code: 6146, category: ts.DiagnosticCategory.Message, key: "Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h_6146", message: "Specify the JSX factory function to use when targeting 'react' JSX emit, e.g. 'React.createElement' or 'h'." }, Resolution_for_module_0_was_found_in_cache: { code: 6147, category: ts.DiagnosticCategory.Message, key: "Resolution_for_module_0_was_found_in_cache_6147", message: "Resolution for module '{0}' was found in cache." }, Directory_0_does_not_exist_skipping_all_lookups_in_it: { code: 6148, category: ts.DiagnosticCategory.Message, key: "Directory_0_does_not_exist_skipping_all_lookups_in_it_6148", message: "Directory '{0}' does not exist, skipping all lookups in it." }, + Show_diagnostic_information: { code: 6149, category: ts.DiagnosticCategory.Message, key: "Show_diagnostic_information_6149", message: "Show diagnostic information." }, + Show_verbose_diagnostic_information: { code: 6150, category: ts.DiagnosticCategory.Message, key: "Show_verbose_diagnostic_information_6150", message: "Show verbose diagnostic information." }, + Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file: { code: 6151, category: ts.DiagnosticCategory.Message, key: "Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file_6151", message: "Emit a single file with source maps instead of having a separate file." }, + Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set: { code: 6152, category: ts.DiagnosticCategory.Message, key: "Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap__6152", message: "Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set." }, + Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule: { code: 6153, category: ts.DiagnosticCategory.Message, key: "Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule_6153", message: "Transpile each file as a separate module (similar to 'ts.transpileModule')." }, + Print_names_of_generated_files_part_of_the_compilation: { code: 6154, category: ts.DiagnosticCategory.Message, key: "Print_names_of_generated_files_part_of_the_compilation_6154", message: "Print names of generated files part of the compilation." }, + Print_names_of_files_part_of_the_compilation: { code: 6155, category: ts.DiagnosticCategory.Message, key: "Print_names_of_files_part_of_the_compilation_6155", message: "Print names of files part of the compilation." }, + The_locale_used_when_displaying_messages_to_the_user_e_g_en_us: { code: 6156, category: ts.DiagnosticCategory.Message, key: "The_locale_used_when_displaying_messages_to_the_user_e_g_en_us_6156", message: "The locale used when displaying messages to the user (e.g. 'en-us')" }, + Do_not_generate_custom_helper_functions_like_extends_in_compiled_output: { code: 6157, category: ts.DiagnosticCategory.Message, key: "Do_not_generate_custom_helper_functions_like_extends_in_compiled_output_6157", message: "Do not generate custom helper functions like '__extends' in compiled output." }, + Do_not_include_the_default_library_file_lib_d_ts: { code: 6158, category: ts.DiagnosticCategory.Message, key: "Do_not_include_the_default_library_file_lib_d_ts_6158", message: "Do not include the default library file (lib.d.ts)." }, + Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files: { code: 6159, category: ts.DiagnosticCategory.Message, key: "Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files_6159", message: "Do not add triple-slash references or imported modules to the list of compiled files." }, + Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files: { code: 6160, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files_6160", message: "[Deprecated] Use '--skipLibCheck' instead. Skip type checking of default library declaration files." }, + List_of_folders_to_include_type_definitions_from: { code: 6161, category: ts.DiagnosticCategory.Message, key: "List_of_folders_to_include_type_definitions_from_6161", message: "List of folders to include type definitions from." }, + Disable_size_limitations_on_JavaScript_projects: { code: 6162, category: ts.DiagnosticCategory.Message, key: "Disable_size_limitations_on_JavaScript_projects_6162", message: "Disable size limitations on JavaScript projects." }, + The_character_set_of_the_input_files: { code: 6163, category: ts.DiagnosticCategory.Message, key: "The_character_set_of_the_input_files_6163", message: "The character set of the input files." }, + Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files: { code: 6164, category: ts.DiagnosticCategory.Message, key: "Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files_6164", message: "Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files." }, + Do_not_truncate_error_messages: { code: 6165, category: ts.DiagnosticCategory.Message, key: "Do_not_truncate_error_messages_6165", message: "Do not truncate error messages." }, + Output_directory_for_generated_declaration_files: { code: 6166, category: ts.DiagnosticCategory.Message, key: "Output_directory_for_generated_declaration_files_6166", message: "Output directory for generated declaration files." }, + A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl: { code: 6167, category: ts.DiagnosticCategory.Message, key: "A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl_6167", message: "A series of entries which re-map imports to lookup locations relative to the 'baseUrl'." }, + List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime: { code: 6168, category: ts.DiagnosticCategory.Message, key: "List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime_6168", message: "List of root folders whose combined content represents the structure of the project at runtime." }, + Show_all_compiler_options: { code: 6169, category: ts.DiagnosticCategory.Message, key: "Show_all_compiler_options_6169", message: "Show all compiler options." }, + Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file: { code: 6170, category: ts.DiagnosticCategory.Message, key: "Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file_6170", message: "[Deprecated] Use '--outFile' instead. Concatenate and emit output to single file" }, + Command_line_Options: { code: 6171, category: ts.DiagnosticCategory.Message, key: "Command_line_Options_6171", message: "Command-line Options" }, + Basic_Options: { code: 6172, category: ts.DiagnosticCategory.Message, key: "Basic_Options_6172", message: "Basic Options" }, + Strict_Type_Checking_Options: { code: 6173, category: ts.DiagnosticCategory.Message, key: "Strict_Type_Checking_Options_6173", message: "Strict Type-Checking Options" }, + Module_Resolution_Options: { code: 6174, category: ts.DiagnosticCategory.Message, key: "Module_Resolution_Options_6174", message: "Module Resolution Options" }, + Source_Map_Options: { code: 6175, category: ts.DiagnosticCategory.Message, key: "Source_Map_Options_6175", message: "Source Map Options" }, + Additional_Checks: { code: 6176, category: ts.DiagnosticCategory.Message, key: "Additional_Checks_6176", message: "Additional Checks" }, + Experimental_Options: { code: 6177, category: ts.DiagnosticCategory.Message, key: "Experimental_Options_6177", message: "Experimental Options" }, + Advanced_Options: { code: 6178, category: ts.DiagnosticCategory.Message, key: "Advanced_Options_6178", message: "Advanced Options" }, + Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3: { code: 6179, category: ts.DiagnosticCategory.Message, key: "Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3_6179", message: "Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'." }, + Enable_all_strict_type_checking_options: { code: 6180, category: ts.DiagnosticCategory.Message, key: "Enable_all_strict_type_checking_options_6180", message: "Enable all strict type-checking options." }, + List_of_language_service_plugins: { code: 6181, category: ts.DiagnosticCategory.Message, key: "List_of_language_service_plugins_6181", message: "List of language service plugins." }, + Scoped_package_detected_looking_in_0: { code: 6182, category: ts.DiagnosticCategory.Message, key: "Scoped_package_detected_looking_in_0_6182", message: "Scoped package detected, looking in '{0}'" }, 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." }, @@ -3292,7 +3248,7 @@ var ts; _0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: ts.DiagnosticCategory.Error, key: "_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_reference_7023", message: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: ts.DiagnosticCategory.Error, key: "Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_ref_7024", message: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." }, Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: ts.DiagnosticCategory.Error, key: "Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_typ_7025", message: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." }, - JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists" }, + JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists: { code: 7026, category: ts.DiagnosticCategory.Error, key: "JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists_7026", message: "JSX element implicitly has type 'any' because no interface 'JSX.{0}' exists." }, Unreachable_code_detected: { code: 7027, category: ts.DiagnosticCategory.Error, key: "Unreachable_code_detected_7027", message: "Unreachable code detected." }, Unused_label: { code: 7028, category: ts.DiagnosticCategory.Error, key: "Unused_label_7028", message: "Unused label." }, Fallthrough_case_in_switch: { code: 7029, category: ts.DiagnosticCategory.Error, key: "Fallthrough_case_in_switch_7029", message: "Fallthrough case in switch." }, @@ -3301,6 +3257,7 @@ var ts; Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation: { code: 7032, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation_7032", message: "Property '{0}' implicitly has type 'any', because its set accessor lacks a parameter type annotation." }, Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation: { code: 7033, category: ts.DiagnosticCategory.Error, key: "Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation_7033", message: "Property '{0}' implicitly has type 'any', because its get accessor lacks a return type annotation." }, Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined: { code: 7034, category: ts.DiagnosticCategory.Error, key: "Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined_7034", message: "Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined." }, + Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_module_0: { code: 7035, category: ts.DiagnosticCategory.Error, key: "Try_npm_install_types_Slash_0_if_it_exists_or_add_a_new_declaration_d_ts_file_containing_declare_mod_7035", message: "Try `npm install @types/{0}` if it exists or add a new declaration (.d.ts) file containing `declare module '{0}';`" }, You_cannot_rename_this_element: { code: 8000, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_this_element_8000", message: "You cannot rename this element." }, You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: { code: 8001, category: ts.DiagnosticCategory.Error, key: "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", message: "You cannot rename elements that are defined in the standard TypeScript library." }, import_can_only_be_used_in_a_ts_file: { code: 8002, category: ts.DiagnosticCategory.Error, key: "import_can_only_be_used_in_a_ts_file_8002", message: "'import ... =' can only be used in a .ts file." }, @@ -3324,14 +3281,14 @@ var ts; Expected_corresponding_JSX_closing_tag_for_0: { code: 17002, category: ts.DiagnosticCategory.Error, key: "Expected_corresponding_JSX_closing_tag_for_0_17002", message: "Expected corresponding JSX closing tag for '{0}'." }, JSX_attribute_expected: { code: 17003, category: ts.DiagnosticCategory.Error, key: "JSX_attribute_expected_17003", message: "JSX attribute expected." }, Cannot_use_JSX_unless_the_jsx_flag_is_provided: { code: 17004, category: ts.DiagnosticCategory.Error, key: "Cannot_use_JSX_unless_the_jsx_flag_is_provided_17004", message: "Cannot use JSX unless the '--jsx' flag is provided." }, - A_constructor_cannot_contain_a_super_call_when_its_class_extends_null: { code: 17005, category: ts.DiagnosticCategory.Error, key: "A_constructor_cannot_contain_a_super_call_when_its_class_extends_null_17005", message: "A constructor cannot contain a 'super' call when its class extends 'null'" }, + 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." }, 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." }, Unknown_type_acquisition_option_0: { code: 17010, category: ts.DiagnosticCategory.Error, key: "Unknown_type_acquisition_option_0_17010", message: "Unknown type acquisition option '{0}'." }, super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class: { code: 17011, category: ts.DiagnosticCategory.Error, key: "super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class_17011", message: "'super' must be called before accessing a property of 'super' in the constructor of a derived class." }, - _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_0_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{0}'?" }, + _0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2: { code: 17012, category: ts.DiagnosticCategory.Error, key: "_0_is_not_a_valid_meta_property_for_keyword_1_Did_you_mean_2_17012", message: "'{0}' is not a valid meta-property for keyword '{1}'. Did you mean '{2}'?" }, Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor: { code: 17013, category: ts.DiagnosticCategory.Error, key: "Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constru_17013", message: "Meta-property '{0}' is only allowed in the body of a function declaration, function expression, or constructor." }, Circularity_detected_while_resolving_configuration_Colon_0: { code: 18000, category: ts.DiagnosticCategory.Error, key: "Circularity_detected_while_resolving_configuration_Colon_0_18000", message: "Circularity detected while resolving configuration: {0}" }, A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not: { code: 18001, category: ts.DiagnosticCategory.Error, key: "A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not_18001", message: "A path in an 'extends' option must be relative or rooted, but '{0}' is not." }, @@ -3340,151 +3297,158 @@ var ts; Add_missing_super_call: { code: 90001, category: ts.DiagnosticCategory.Message, key: "Add_missing_super_call_90001", message: "Add missing 'super()' call." }, Make_super_call_the_first_statement_in_the_constructor: { code: 90002, category: ts.DiagnosticCategory.Message, key: "Make_super_call_the_first_statement_in_the_constructor_90002", message: "Make 'super()' call the first statement in the constructor." }, Change_extends_to_implements: { code: 90003, category: ts.DiagnosticCategory.Message, key: "Change_extends_to_implements_90003", message: "Change 'extends' to 'implements'." }, - Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: {0}" }, + Remove_declaration_for_Colon_0: { code: 90004, category: ts.DiagnosticCategory.Message, key: "Remove_declaration_for_Colon_0_90004", message: "Remove declaration for: '{0}'." }, Implement_interface_0: { code: 90006, category: ts.DiagnosticCategory.Message, key: "Implement_interface_0_90006", message: "Implement interface '{0}'." }, Implement_inherited_abstract_class: { code: 90007, category: ts.DiagnosticCategory.Message, key: "Implement_inherited_abstract_class_90007", message: "Implement inherited abstract class." }, Add_this_to_unresolved_variable: { code: 90008, category: ts.DiagnosticCategory.Message, key: "Add_this_to_unresolved_variable_90008", message: "Add 'this.' to unresolved variable." }, - Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig" }, + Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript_files_Learn_more_at_https_Colon_Slash_Slashaka_ms_Slashtsconfig: { code: 90009, category: ts.DiagnosticCategory.Error, key: "Adding_a_tsconfig_json_file_will_help_organize_projects_that_contain_both_TypeScript_and_JavaScript__90009", message: "Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig." }, Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated: { code: 90010, category: ts.DiagnosticCategory.Error, key: "Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated_90010", message: "Type '{0}' is not assignable to type '{1}'. Two different types with this name exist, but they are unrelated." }, - Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}" }, - Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}" }, - Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}" }, + Import_0_from_1: { code: 90013, category: ts.DiagnosticCategory.Message, key: "Import_0_from_1_90013", message: "Import {0} from {1}." }, + Change_0_to_1: { code: 90014, category: ts.DiagnosticCategory.Message, key: "Change_0_to_1_90014", message: "Change {0} to {1}." }, + Add_0_to_existing_import_declaration_from_1: { code: 90015, category: ts.DiagnosticCategory.Message, key: "Add_0_to_existing_import_declaration_from_1_90015", message: "Add {0} to existing import declaration from {1}." }, + Add_declaration_for_missing_property_0: { code: 90016, category: ts.DiagnosticCategory.Message, key: "Add_declaration_for_missing_property_0_90016", message: "Add declaration for missing property '{0}'." }, + Add_index_signature_for_missing_property_0: { code: 90017, category: ts.DiagnosticCategory.Message, key: "Add_index_signature_for_missing_property_0_90017", message: "Add index signature for missing property '{0}'." }, + Disable_checking_for_this_file: { code: 90018, category: ts.DiagnosticCategory.Message, key: "Disable_checking_for_this_file_90018", message: "Disable checking for this file." }, + Ignore_this_error_message: { code: 90019, category: ts.DiagnosticCategory.Message, key: "Ignore_this_error_message_90019", message: "Ignore this error message." }, + Initialize_property_0_in_the_constructor: { code: 90020, category: ts.DiagnosticCategory.Message, key: "Initialize_property_0_in_the_constructor_90020", message: "Initialize property '{0}' in the constructor." }, + Initialize_static_property_0: { code: 90021, category: ts.DiagnosticCategory.Message, key: "Initialize_static_property_0_90021", message: "Initialize static property '{0}'." }, Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0: { code: 8017, category: ts.DiagnosticCategory.Error, key: "Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0_8017", message: "Octal literal types must use ES2015 syntax. Use the syntax '{0}'." }, Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0: { code: 8018, category: ts.DiagnosticCategory.Error, key: "Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0_8018", message: "Octal literals are not allowed in enums members initializer. Use the syntax '{0}'." }, + Report_errors_in_js_files: { code: 8019, category: ts.DiagnosticCategory.Message, key: "Report_errors_in_js_files_8019", message: "Report errors in .js files." }, }; })(ts || (ts = {})); var ts; (function (ts) { function tokenIsIdentifierOrKeyword(token) { - return token >= 70; + return token >= 71; } ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword; var textToToken = ts.createMapFromTemplate({ - "abstract": 116, - "any": 118, - "as": 117, - "boolean": 121, - "break": 71, - "case": 72, - "catch": 73, - "class": 74, - "continue": 76, - "const": 75, - "constructor": 122, - "debugger": 77, - "declare": 123, - "default": 78, - "delete": 79, - "do": 80, - "else": 81, - "enum": 82, - "export": 83, - "extends": 84, - "false": 85, - "finally": 86, - "for": 87, - "from": 139, - "function": 88, - "get": 124, - "if": 89, - "implements": 107, - "import": 90, - "in": 91, - "instanceof": 92, - "interface": 108, - "is": 125, - "keyof": 126, - "let": 109, - "module": 127, - "namespace": 128, - "never": 129, - "new": 93, - "null": 94, - "number": 132, - "object": 133, - "package": 110, - "private": 111, - "protected": 112, - "public": 113, - "readonly": 130, - "require": 131, - "global": 140, - "return": 95, - "set": 134, - "static": 114, - "string": 135, - "super": 96, - "switch": 97, - "symbol": 136, - "this": 98, - "throw": 99, - "true": 100, - "try": 101, - "type": 137, - "typeof": 102, - "undefined": 138, - "var": 103, - "void": 104, - "while": 105, - "with": 106, - "yield": 115, - "async": 119, - "await": 120, - "of": 141, - "{": 16, - "}": 17, - "(": 18, - ")": 19, - "[": 20, - "]": 21, - ".": 22, - "...": 23, - ";": 24, - ",": 25, - "<": 26, - ">": 28, - "<=": 29, - ">=": 30, - "==": 31, - "!=": 32, - "===": 33, - "!==": 34, - "=>": 35, - "+": 36, - "-": 37, - "**": 39, - "*": 38, - "/": 40, - "%": 41, - "++": 42, - "--": 43, - "<<": 44, - ">": 45, - ">>>": 46, - "&": 47, - "|": 48, - "^": 49, - "!": 50, - "~": 51, - "&&": 52, - "||": 53, - "?": 54, - ":": 55, - "=": 57, - "+=": 58, - "-=": 59, - "*=": 60, - "**=": 61, - "/=": 62, - "%=": 63, - "<<=": 64, - ">>=": 65, - ">>>=": 66, - "&=": 67, - "|=": 68, - "^=": 69, - "@": 56, + "abstract": 117, + "any": 119, + "as": 118, + "boolean": 122, + "break": 72, + "case": 73, + "catch": 74, + "class": 75, + "continue": 77, + "const": 76, + "constructor": 123, + "debugger": 78, + "declare": 124, + "default": 79, + "delete": 80, + "do": 81, + "else": 82, + "enum": 83, + "export": 84, + "extends": 85, + "false": 86, + "finally": 87, + "for": 88, + "from": 140, + "function": 89, + "get": 125, + "if": 90, + "implements": 108, + "import": 91, + "in": 92, + "instanceof": 93, + "interface": 109, + "is": 126, + "keyof": 127, + "let": 110, + "module": 128, + "namespace": 129, + "never": 130, + "new": 94, + "null": 95, + "number": 133, + "object": 134, + "package": 111, + "private": 112, + "protected": 113, + "public": 114, + "readonly": 131, + "require": 132, + "global": 141, + "return": 96, + "set": 135, + "static": 115, + "string": 136, + "super": 97, + "switch": 98, + "symbol": 137, + "this": 99, + "throw": 100, + "true": 101, + "try": 102, + "type": 138, + "typeof": 103, + "undefined": 139, + "var": 104, + "void": 105, + "while": 106, + "with": 107, + "yield": 116, + "async": 120, + "await": 121, + "of": 142, + "{": 17, + "}": 18, + "(": 19, + ")": 20, + "[": 21, + "]": 22, + ".": 23, + "...": 24, + ";": 25, + ",": 26, + "<": 27, + ">": 29, + "<=": 30, + ">=": 31, + "==": 32, + "!=": 33, + "===": 34, + "!==": 35, + "=>": 36, + "+": 37, + "-": 38, + "**": 40, + "*": 39, + "/": 41, + "%": 42, + "++": 43, + "--": 44, + "<<": 45, + ">": 46, + ">>>": 47, + "&": 48, + "|": 49, + "^": 50, + "!": 51, + "~": 52, + "&&": 53, + "||": 54, + "?": 55, + ":": 56, + "=": 58, + "+=": 59, + "-=": 60, + "*=": 61, + "**=": 62, + "/=": 63, + "%=": 64, + "<<=": 65, + ">>=": 66, + ">>>=": 67, + "&=": 68, + "|=": 69, + "^=": 70, + "@": 57, }); var unicodeES3IdentifierStart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1610, 1649, 1747, 1749, 1749, 1765, 1766, 1786, 1788, 1808, 1808, 1810, 1836, 1920, 1957, 2309, 2361, 2365, 2365, 2384, 2384, 2392, 2401, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2524, 2525, 2527, 2529, 2544, 2545, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2649, 2652, 2654, 2654, 2674, 2676, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2749, 2749, 2768, 2768, 2784, 2784, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2877, 2877, 2908, 2909, 2911, 2913, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3168, 3169, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3294, 3294, 3296, 3297, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3424, 3425, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3585, 3632, 3634, 3635, 3648, 3654, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3760, 3762, 3763, 3773, 3773, 3776, 3780, 3782, 3782, 3804, 3805, 3840, 3840, 3904, 3911, 3913, 3946, 3976, 3979, 4096, 4129, 4131, 4135, 4137, 4138, 4176, 4181, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6067, 6176, 6263, 6272, 6312, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8319, 8319, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12329, 12337, 12341, 12344, 12346, 12353, 12436, 12445, 12446, 12449, 12538, 12540, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64285, 64287, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65136, 65138, 65140, 65140, 65142, 65276, 65313, 65338, 65345, 65370, 65382, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; var unicodeES3IdentifierPart = [170, 170, 181, 181, 186, 186, 192, 214, 216, 246, 248, 543, 546, 563, 592, 685, 688, 696, 699, 705, 720, 721, 736, 740, 750, 750, 768, 846, 864, 866, 890, 890, 902, 902, 904, 906, 908, 908, 910, 929, 931, 974, 976, 983, 986, 1011, 1024, 1153, 1155, 1158, 1164, 1220, 1223, 1224, 1227, 1228, 1232, 1269, 1272, 1273, 1329, 1366, 1369, 1369, 1377, 1415, 1425, 1441, 1443, 1465, 1467, 1469, 1471, 1471, 1473, 1474, 1476, 1476, 1488, 1514, 1520, 1522, 1569, 1594, 1600, 1621, 1632, 1641, 1648, 1747, 1749, 1756, 1759, 1768, 1770, 1773, 1776, 1788, 1808, 1836, 1840, 1866, 1920, 1968, 2305, 2307, 2309, 2361, 2364, 2381, 2384, 2388, 2392, 2403, 2406, 2415, 2433, 2435, 2437, 2444, 2447, 2448, 2451, 2472, 2474, 2480, 2482, 2482, 2486, 2489, 2492, 2492, 2494, 2500, 2503, 2504, 2507, 2509, 2519, 2519, 2524, 2525, 2527, 2531, 2534, 2545, 2562, 2562, 2565, 2570, 2575, 2576, 2579, 2600, 2602, 2608, 2610, 2611, 2613, 2614, 2616, 2617, 2620, 2620, 2622, 2626, 2631, 2632, 2635, 2637, 2649, 2652, 2654, 2654, 2662, 2676, 2689, 2691, 2693, 2699, 2701, 2701, 2703, 2705, 2707, 2728, 2730, 2736, 2738, 2739, 2741, 2745, 2748, 2757, 2759, 2761, 2763, 2765, 2768, 2768, 2784, 2784, 2790, 2799, 2817, 2819, 2821, 2828, 2831, 2832, 2835, 2856, 2858, 2864, 2866, 2867, 2870, 2873, 2876, 2883, 2887, 2888, 2891, 2893, 2902, 2903, 2908, 2909, 2911, 2913, 2918, 2927, 2946, 2947, 2949, 2954, 2958, 2960, 2962, 2965, 2969, 2970, 2972, 2972, 2974, 2975, 2979, 2980, 2984, 2986, 2990, 2997, 2999, 3001, 3006, 3010, 3014, 3016, 3018, 3021, 3031, 3031, 3047, 3055, 3073, 3075, 3077, 3084, 3086, 3088, 3090, 3112, 3114, 3123, 3125, 3129, 3134, 3140, 3142, 3144, 3146, 3149, 3157, 3158, 3168, 3169, 3174, 3183, 3202, 3203, 3205, 3212, 3214, 3216, 3218, 3240, 3242, 3251, 3253, 3257, 3262, 3268, 3270, 3272, 3274, 3277, 3285, 3286, 3294, 3294, 3296, 3297, 3302, 3311, 3330, 3331, 3333, 3340, 3342, 3344, 3346, 3368, 3370, 3385, 3390, 3395, 3398, 3400, 3402, 3405, 3415, 3415, 3424, 3425, 3430, 3439, 3458, 3459, 3461, 3478, 3482, 3505, 3507, 3515, 3517, 3517, 3520, 3526, 3530, 3530, 3535, 3540, 3542, 3542, 3544, 3551, 3570, 3571, 3585, 3642, 3648, 3662, 3664, 3673, 3713, 3714, 3716, 3716, 3719, 3720, 3722, 3722, 3725, 3725, 3732, 3735, 3737, 3743, 3745, 3747, 3749, 3749, 3751, 3751, 3754, 3755, 3757, 3769, 3771, 3773, 3776, 3780, 3782, 3782, 3784, 3789, 3792, 3801, 3804, 3805, 3840, 3840, 3864, 3865, 3872, 3881, 3893, 3893, 3895, 3895, 3897, 3897, 3902, 3911, 3913, 3946, 3953, 3972, 3974, 3979, 3984, 3991, 3993, 4028, 4038, 4038, 4096, 4129, 4131, 4135, 4137, 4138, 4140, 4146, 4150, 4153, 4160, 4169, 4176, 4185, 4256, 4293, 4304, 4342, 4352, 4441, 4447, 4514, 4520, 4601, 4608, 4614, 4616, 4678, 4680, 4680, 4682, 4685, 4688, 4694, 4696, 4696, 4698, 4701, 4704, 4742, 4744, 4744, 4746, 4749, 4752, 4782, 4784, 4784, 4786, 4789, 4792, 4798, 4800, 4800, 4802, 4805, 4808, 4814, 4816, 4822, 4824, 4846, 4848, 4878, 4880, 4880, 4882, 4885, 4888, 4894, 4896, 4934, 4936, 4954, 4969, 4977, 5024, 5108, 5121, 5740, 5743, 5750, 5761, 5786, 5792, 5866, 6016, 6099, 6112, 6121, 6160, 6169, 6176, 6263, 6272, 6313, 7680, 7835, 7840, 7929, 7936, 7957, 7960, 7965, 7968, 8005, 8008, 8013, 8016, 8023, 8025, 8025, 8027, 8027, 8029, 8029, 8031, 8061, 8064, 8116, 8118, 8124, 8126, 8126, 8130, 8132, 8134, 8140, 8144, 8147, 8150, 8155, 8160, 8172, 8178, 8180, 8182, 8188, 8255, 8256, 8319, 8319, 8400, 8412, 8417, 8417, 8450, 8450, 8455, 8455, 8458, 8467, 8469, 8469, 8473, 8477, 8484, 8484, 8486, 8486, 8488, 8488, 8490, 8493, 8495, 8497, 8499, 8505, 8544, 8579, 12293, 12295, 12321, 12335, 12337, 12341, 12344, 12346, 12353, 12436, 12441, 12442, 12445, 12446, 12449, 12542, 12549, 12588, 12593, 12686, 12704, 12727, 13312, 19893, 19968, 40869, 40960, 42124, 44032, 55203, 63744, 64045, 64256, 64262, 64275, 64279, 64285, 64296, 64298, 64310, 64312, 64316, 64318, 64318, 64320, 64321, 64323, 64324, 64326, 64433, 64467, 64829, 64848, 64911, 64914, 64967, 65008, 65019, 65056, 65059, 65075, 65076, 65101, 65103, 65136, 65138, 65140, 65140, 65142, 65276, 65296, 65305, 65313, 65338, 65343, 65343, 65345, 65370, 65381, 65470, 65474, 65479, 65482, 65487, 65490, 65495, 65498, 65500,]; @@ -3596,10 +3560,10 @@ var ts; return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position); } ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition; - function isWhiteSpace(ch) { + function isWhiteSpaceLike(ch) { return isWhiteSpaceSingleLine(ch) || isLineBreak(ch); } - ts.isWhiteSpace = isWhiteSpace; + ts.isWhiteSpaceLike = isWhiteSpaceLike; function isWhiteSpaceSingleLine(ch) { return ch === 32 || ch === 9 || @@ -3715,7 +3679,7 @@ var ts; } break; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { pos++; continue; } @@ -3849,7 +3813,7 @@ var ts; } break scan; default: - if (ch > 127 && (isWhiteSpace(ch))) { + if (ch > 127 && (isWhiteSpaceLike(ch))) { if (hasPendingCommentRange && isLineBreak(ch)) { pendingHasTrailingNewLine = true; } @@ -3884,7 +3848,7 @@ var ts; if (!comments) { comments = []; } - comments.push({ pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine, kind: kind }); + comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine }); return comments; } function getLeadingCommentRanges(text, pos) { @@ -3936,6 +3900,7 @@ var ts; var precedingLineBreak; var hasExtendedUnicodeEscape; var tokenIsUnterminated; + var numericLiteralFlags; setText(text, start, length); return { getStartPos: function () { return startPos; }, @@ -3946,9 +3911,10 @@ var ts; getTokenValue: function () { return tokenValue; }, hasExtendedUnicodeEscape: function () { return hasExtendedUnicodeEscape; }, hasPrecedingLineBreak: function () { return precedingLineBreak; }, - isIdentifier: function () { return token === 70 || token > 106; }, - isReservedWord: function () { return token >= 71 && token <= 106; }, + isIdentifier: function () { return token === 71 || token > 107; }, + isReservedWord: function () { return token >= 72 && token <= 107; }, isUnterminated: function () { return tokenIsUnterminated; }, + getNumericLiteralFlags: function () { return numericLiteralFlags; }, reScanGreaterToken: reScanGreaterToken, reScanSlashToken: reScanSlashToken, reScanTemplateToken: reScanTemplateToken, @@ -3985,6 +3951,7 @@ var ts; var end = pos; if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) { pos++; + numericLiteralFlags = 2; if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45) pos++; if (isDigit(text.charCodeAt(pos))) { @@ -4083,20 +4050,20 @@ var ts; contents += text.substring(start, pos); tokenIsUnterminated = true; error(ts.Diagnostics.Unterminated_template_literal); - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } var currChar = text.charCodeAt(pos); if (currChar === 96) { contents += text.substring(start, pos); pos++; - resultingToken = startedWithBacktick ? 12 : 15; + resultingToken = startedWithBacktick ? 13 : 16; break; } if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) { contents += text.substring(start, pos); pos += 2; - resultingToken = startedWithBacktick ? 13 : 14; + resultingToken = startedWithBacktick ? 14 : 15; break; } if (currChar === 92) { @@ -4261,7 +4228,7 @@ var ts; } } } - return token = 70; + return token = 71; } function scanBinaryOrOctalDigits(base) { ts.Debug.assert(base === 2 || base === 8, "Expected either base 2 or base 8"); @@ -4287,6 +4254,7 @@ var ts; hasExtendedUnicodeEscape = false; precedingLineBreak = false; tokenIsUnterminated = false; + numericLiteralFlags = 0; while (true) { tokenPos = pos; if (pos >= end) { @@ -4336,12 +4304,12 @@ var ts; case 33: if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 34; + return pos += 3, token = 35; } - return pos += 2, token = 32; + return pos += 2, token = 33; } pos++; - return token = 50; + return token = 51; case 34: case 39: tokenValue = scanString(); @@ -4350,51 +4318,39 @@ var ts; return token = scanTemplateAndSetTokenValue(); case 37: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 63; + return pos += 2, token = 64; } pos++; - return token = 41; + return token = 42; case 38: if (text.charCodeAt(pos + 1) === 38) { - return pos += 2, token = 52; + return pos += 2, token = 53; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 67; + return pos += 2, token = 68; } pos++; - return token = 47; + return token = 48; case 40: pos++; - return token = 18; + return token = 19; case 41: pos++; - return token = 19; + return token = 20; case 42: if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 60; + return pos += 2, token = 61; } if (text.charCodeAt(pos + 1) === 42) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 61; + return pos += 3, token = 62; } - return pos += 2, token = 39; + return pos += 2, token = 40; } pos++; - return token = 38; + return token = 39; case 43: if (text.charCodeAt(pos + 1) === 43) { - return pos += 2, token = 42; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 58; - } - pos++; - return token = 36; - case 44: - pos++; - return token = 25; - case 45: - if (text.charCodeAt(pos + 1) === 45) { return pos += 2, token = 43; } if (text.charCodeAt(pos + 1) === 61) { @@ -4402,16 +4358,28 @@ var ts; } pos++; return token = 37; + case 44: + pos++; + return token = 26; + case 45: + if (text.charCodeAt(pos + 1) === 45) { + return pos += 2, token = 44; + } + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 60; + } + pos++; + return token = 38; case 46: if (isDigit(text.charCodeAt(pos + 1))) { tokenValue = scanNumber(); return token = 8; } if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) { - return pos += 3, token = 23; + return pos += 3, token = 24; } pos++; - return token = 22; + return token = 23; case 47: if (text.charCodeAt(pos + 1) === 47) { pos += 2; @@ -4455,10 +4423,10 @@ var ts; } } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 62; + return pos += 2, token = 63; } pos++; - return token = 40; + return token = 41; case 48: if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) { pos += 2; @@ -4468,6 +4436,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 8; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) { @@ -4478,6 +4447,7 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 16; return token = 8; } else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) { @@ -4488,10 +4458,12 @@ var ts; value = 0; } tokenValue = "" + value; + numericLiteralFlags = 32; return token = 8; } if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) { tokenValue = "" + scanOctalDigits(); + numericLiteralFlags = 4; return token = 8; } case 49: @@ -4507,10 +4479,10 @@ var ts; return token = 8; case 58: pos++; - return token = 55; + return token = 56; case 59: pos++; - return token = 24; + return token = 25; case 60: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4523,20 +4495,20 @@ var ts; } if (text.charCodeAt(pos + 1) === 60) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 64; + return pos += 3, token = 65; } - return pos += 2, token = 44; + return pos += 2, token = 45; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 29; + return pos += 2, token = 30; } if (languageVariant === 1 && text.charCodeAt(pos + 1) === 47 && text.charCodeAt(pos + 2) !== 42) { - return pos += 2, token = 27; + return pos += 2, token = 28; } pos++; - return token = 26; + return token = 27; case 61: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4549,15 +4521,15 @@ var ts; } if (text.charCodeAt(pos + 1) === 61) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 33; + return pos += 3, token = 34; } - return pos += 2, token = 31; + return pos += 2, token = 32; } if (text.charCodeAt(pos + 1) === 62) { - return pos += 2, token = 35; + return pos += 2, token = 36; } pos++; - return token = 57; + return token = 58; case 62: if (isConflictMarkerTrivia(text, pos)) { pos = scanConflictMarkerTrivia(text, pos, error); @@ -4569,43 +4541,43 @@ var ts; } } pos++; - return token = 28; + return token = 29; case 63: pos++; - return token = 54; + return token = 55; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 94: + if (text.charCodeAt(pos + 1) === 61) { + return pos += 2, token = 70; + } + pos++; + return token = 50; + case 123: + pos++; + return token = 17; + case 124: + if (text.charCodeAt(pos + 1) === 124) { + return pos += 2, token = 54; + } if (text.charCodeAt(pos + 1) === 61) { return pos += 2, token = 69; } pos++; return token = 49; - case 123: - pos++; - return token = 16; - case 124: - if (text.charCodeAt(pos + 1) === 124) { - return pos += 2, token = 53; - } - if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 68; - } - pos++; - return token = 48; case 125: pos++; - return token = 17; + return token = 18; case 126: pos++; - return token = 51; + return token = 52; case 64: pos++; - return token = 56; + return token = 57; case 92: var cookedChar = peekUnicodeEscape(); if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) { @@ -4643,29 +4615,29 @@ var ts; } } function reScanGreaterToken() { - if (token === 28) { + if (token === 29) { if (text.charCodeAt(pos) === 62) { if (text.charCodeAt(pos + 1) === 62) { if (text.charCodeAt(pos + 2) === 61) { - return pos += 3, token = 66; + return pos += 3, token = 67; } - return pos += 2, token = 46; + return pos += 2, token = 47; } if (text.charCodeAt(pos + 1) === 61) { - return pos += 2, token = 65; + return pos += 2, token = 66; } pos++; - return token = 45; + return token = 46; } if (text.charCodeAt(pos) === 61) { pos++; - return token = 30; + return token = 31; } } return token; } function reScanSlashToken() { - if (token === 40 || token === 62) { + if (token === 41 || token === 63) { var p = tokenPos + 1; var inEscape = false; var inCharacterClass = false; @@ -4704,12 +4676,12 @@ var ts; } pos = p; tokenValue = text.substring(tokenPos, pos); - token = 11; + token = 12; } return token; } function reScanTemplateToken() { - ts.Debug.assert(token === 17, "'reScanTemplateToken' should only be called on a '}'"); + ts.Debug.assert(token === 18, "'reScanTemplateToken' should only be called on a '}'"); pos = tokenPos; return token = scanTemplateAndSetTokenValue(); } @@ -4726,23 +4698,37 @@ var ts; if (char === 60) { if (text.charCodeAt(pos + 1) === 47) { pos += 2; - return token = 27; + return token = 28; } pos++; - return token = 26; + return token = 27; } if (char === 123) { pos++; - return token = 16; + return token = 17; } + var firstNonWhitespace = 0; while (pos < end) { - pos++; char = text.charCodeAt(pos); - if ((char === 123) || (char === 60)) { + if (char === 123) { break; } + if (char === 60) { + if (isConflictMarkerTrivia(text, pos)) { + pos = scanConflictMarkerTrivia(text, pos, error); + return token = 7; + } + break; + } + if (isLineBreak(char) && firstNonWhitespace === 0) { + firstNonWhitespace = -1; + } + else if (!isWhiteSpaceLike(char)) { + firstNonWhitespace = pos; + } + pos++; } - return token = 10; + return firstNonWhitespace === -1 ? 11 : 10; } function scanJsxIdentifier() { if (tokenIsIdentifierOrKeyword(token)) { @@ -4789,42 +4775,42 @@ var ts; return token = 5; case 64: pos++; - return token = 56; + return token = 57; case 10: case 13: pos++; return token = 4; case 42: pos++; - return token = 38; + return token = 39; case 123: pos++; - return token = 16; + return token = 17; case 125: pos++; - return token = 17; + return token = 18; case 91: pos++; - return token = 20; + return token = 21; case 93: pos++; - return token = 21; + return token = 22; case 61: pos++; - return token = 57; + return token = 58; case 44: pos++; - return token = 25; + return token = 26; case 46: pos++; - return token = 22; + return token = 23; } if (isIdentifierStart(ch, 5)) { pos++; while (isIdentifierPart(text.charCodeAt(pos), 5) && pos < end) { pos++; } - return token = 70; + return token = 71; } else { return pos += 1, token = 0; @@ -4912,40 +4898,12 @@ var ts; (function (ts) { ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" }; ts.optionDeclarations = [ - { - name: "charset", - type: "string", - }, - ts.compileOnSaveCommandLineOption, - { - name: "declaration", - shortName: "d", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_d_ts_file, - }, - { - name: "declarationDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "diagnostics", - type: "boolean", - }, - { - name: "extendedDiagnostics", - type: "boolean", - experimental: true - }, - { - name: "emitBOM", - type: "boolean" - }, { name: "help", shortName: "h", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Print_this_message, }, { @@ -4953,215 +4911,52 @@ var ts; shortName: "?", type: "boolean" }, + { + name: "all", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Show_all_compiler_options, + }, + { + name: "version", + shortName: "v", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Print_the_compiler_s_version, + }, { name: "init", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file, }, - { - name: "inlineSourceMap", - type: "boolean", - }, - { - name: "inlineSources", - type: "boolean", - }, - { - name: "jsx", - type: ts.createMapFromTemplate({ - "preserve": 1, - "react-native": 3, - "react": 2 - }), - paramType: ts.Diagnostics.KIND, - description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, - }, - { - name: "reactNamespace", - type: "string", - description: ts.Diagnostics.Specify_the_object_invoked_for_createElement_and_spread_when_targeting_react_JSX_emit - }, - { - name: "jsxFactory", - type: "string", - description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h - }, - { - name: "listFiles", - type: "boolean", - }, - { - name: "locale", - type: "string", - }, - { - name: "mapRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "module", - shortName: "m", - type: ts.createMapFromTemplate({ - "none": ts.ModuleKind.None, - "commonjs": ts.ModuleKind.CommonJS, - "amd": ts.ModuleKind.AMD, - "system": ts.ModuleKind.System, - "umd": ts.ModuleKind.UMD, - "es6": ts.ModuleKind.ES2015, - "es2015": ts.ModuleKind.ES2015, - }), - description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, - paramType: ts.Diagnostics.KIND, - }, - { - name: "newLine", - type: ts.createMapFromTemplate({ - "crlf": 0, - "lf": 1 - }), - description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, - paramType: ts.Diagnostics.NEWLINE, - }, - { - name: "noEmit", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs, - }, - { - name: "noEmitHelpers", - type: "boolean" - }, - { - name: "noEmitOnError", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, - }, - { - name: "noErrorTruncation", - type: "boolean" - }, - { - name: "noImplicitAny", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, - }, - { - name: "noImplicitThis", - type: "boolean", - description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, - }, - { - name: "noUnusedLocals", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_locals, - }, - { - name: "noUnusedParameters", - type: "boolean", - description: ts.Diagnostics.Report_errors_on_unused_parameters, - }, - { - name: "noLib", - type: "boolean", - }, - { - name: "noResolve", - type: "boolean", - }, - { - name: "skipDefaultLibCheck", - type: "boolean", - }, - { - name: "skipLibCheck", - type: "boolean", - description: ts.Diagnostics.Skip_type_checking_of_declaration_files, - }, - { - name: "out", - type: "string", - isFilePath: false, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outFile", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, - paramType: ts.Diagnostics.FILE, - }, - { - name: "outDir", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Redirect_output_structure_to_the_directory, - paramType: ts.Diagnostics.DIRECTORY, - }, - { - name: "preserveConstEnums", - type: "boolean", - description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code - }, - { - name: "pretty", - description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental, - type: "boolean" - }, { name: "project", shortName: "p", type: "string", isFilePath: true, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + paramType: ts.Diagnostics.FILE_OR_DIRECTORY, description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json, - paramType: ts.Diagnostics.FILE_OR_DIRECTORY }, { - name: "removeComments", + name: "pretty", type: "boolean", - description: ts.Diagnostics.Do_not_emit_comments_to_output, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental }, { - name: "rootDir", - type: "string", - isFilePath: true, - paramType: ts.Diagnostics.LOCATION, - description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, - }, - { - name: "isolatedModules", + name: "watch", + shortName: "w", type: "boolean", - }, - { - name: "sourceMap", - type: "boolean", - description: ts.Diagnostics.Generates_corresponding_map_file, - }, - { - name: "sourceRoot", - type: "string", - isFilePath: true, - description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, - paramType: ts.Diagnostics.LOCATION, - }, - { - name: "suppressExcessPropertyErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, - experimental: true - }, - { - name: "suppressImplicitAnyIndexErrors", - type: "boolean", - description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, - }, - { - name: "stripInternal", - type: "boolean", - description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, - experimental: true + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Command_line_Options, + description: ts.Diagnostics.Watch_input_files, }, { name: "target", @@ -5175,133 +4970,27 @@ var ts; "es2017": 4, "esnext": 5, }), - description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, paramType: ts.Diagnostics.VERSION, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_or_ESNEXT, }, { - name: "version", - shortName: "v", - type: "boolean", - description: ts.Diagnostics.Print_the_compiler_s_version, - }, - { - name: "watch", - shortName: "w", - type: "boolean", - description: ts.Diagnostics.Watch_input_files, - }, - { - name: "experimentalDecorators", - type: "boolean", - description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators - }, - { - name: "emitDecoratorMetadata", - type: "boolean", - experimental: true, - description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators - }, - { - name: "moduleResolution", + name: "module", + shortName: "m", type: ts.createMapFromTemplate({ - "node": ts.ModuleResolutionKind.NodeJs, - "classic": ts.ModuleResolutionKind.Classic, + "none": ts.ModuleKind.None, + "commonjs": ts.ModuleKind.CommonJS, + "amd": ts.ModuleKind.AMD, + "system": ts.ModuleKind.System, + "umd": ts.ModuleKind.UMD, + "es6": ts.ModuleKind.ES2015, + "es2015": ts.ModuleKind.ES2015, }), - description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, - paramType: ts.Diagnostics.STRATEGY, - }, - { - name: "allowUnusedLabels", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unused_labels - }, - { - name: "noImplicitReturns", - type: "boolean", - description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value - }, - { - name: "noFallthroughCasesInSwitch", - type: "boolean", - description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement - }, - { - name: "allowUnreachableCode", - type: "boolean", - description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code - }, - { - name: "forceConsistentCasingInFileNames", - type: "boolean", - description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file - }, - { - 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: "list", - isTSConfigOnly: true, - element: { - name: "rootDirs", - type: "string", - isFilePath: true - } - }, - { - name: "typeRoots", - type: "list", - element: { - name: "typeRoots", - type: "string", - isFilePath: true - } - }, - { - name: "types", - type: "list", - element: { - name: "types", - type: "string" - }, - description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation - }, - { - name: "traceResolution", - type: "boolean", - description: ts.Diagnostics.Enable_tracing_of_the_name_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 - }, - { - name: "maxNodeModuleJsDepth", - type: "number", - description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files - }, - { - name: "listEmittedFiles", - type: "boolean" + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015, }, { name: "lib", @@ -5315,6 +5004,7 @@ var ts; "es7": "lib.es2016.d.ts", "es2016": "lib.es2016.d.ts", "es2017": "lib.es2017.d.ts", + "esnext": "lib.esnext.d.ts", "dom": "lib.dom.d.ts", "dom.iterable": "lib.dom.iterable.d.ts", "webworker": "lib.webworker.d.ts", @@ -5332,29 +5022,466 @@ var ts; "es2017.object": "lib.es2017.object.d.ts", "es2017.sharedmemory": "lib.es2017.sharedmemory.d.ts", "es2017.string": "lib.es2017.string.d.ts", + "esnext.asynciterable": "lib.esnext.asynciterable.d.ts", }), }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation_Colon }, { - name: "disableSizeLimit", - type: "boolean" + name: "allowJs", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Allow_javascript_files_to_be_compiled }, { - name: "strictNullChecks", + name: "checkJs", type: "boolean", - description: ts.Diagnostics.Enable_strict_null_checks + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Report_errors_in_js_files + }, + { + name: "jsx", + type: ts.createMapFromTemplate({ + "preserve": 1, + "react-native": 3, + "react": 2 + }), + paramType: ts.Diagnostics.KIND, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_or_react, + }, + { + name: "declaration", + shortName: "d", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_d_ts_file, + }, + { + name: "sourceMap", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Generates_corresponding_map_file, + }, + { + name: "outFile", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.FILE, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file, + }, + { + name: "outDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Redirect_output_structure_to_the_directory, + }, + { + name: "rootDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir, + }, + { + name: "removeComments", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_comments_to_output, + }, + { + name: "noEmit", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Do_not_emit_outputs, }, { name: "importHelpers", type: "boolean", + category: ts.Diagnostics.Basic_Options, description: ts.Diagnostics.Import_emit_helpers_from_tslib }, + { + name: "downlevelIteration", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3 + }, + { + name: "isolatedModules", + type: "boolean", + category: ts.Diagnostics.Basic_Options, + description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule + }, + { + name: "strict", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_all_strict_type_checking_options + }, + { + name: "noImplicitAny", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type, + }, + { + name: "strictNullChecks", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Enable_strict_null_checks + }, + { + name: "noImplicitThis", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, + description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type, + }, { name: "alwaysStrict", type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Strict_Type_Checking_Options, description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file }, + { + name: "noUnusedLocals", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_locals, + }, + { + name: "noUnusedParameters", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_on_unused_parameters, + }, + { + name: "noImplicitReturns", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value + }, + { + name: "noFallthroughCasesInSwitch", + type: "boolean", + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Additional_Checks, + description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement + }, + { + name: "moduleResolution", + type: ts.createMapFromTemplate({ + "node": ts.ModuleResolutionKind.NodeJs, + "classic": ts.ModuleResolutionKind.Classic, + }), + paramType: ts.Diagnostics.STRATEGY, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6, + }, + { + name: "baseUrl", + type: "string", + isFilePath: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names + }, + { + name: "paths", + type: "object", + isTSConfigOnly: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl + }, + { + name: "rootDirs", + type: "list", + isTSConfigOnly: true, + element: { + name: "rootDirs", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime + }, + { + name: "typeRoots", + type: "list", + element: { + name: "typeRoots", + type: "string", + isFilePath: true + }, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from + }, + { + name: "types", + type: "list", + element: { + name: "types", + type: "string" + }, + showInSimplifiedHelpView: true, + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation + }, + { + name: "allowSyntheticDefaultImports", + type: "boolean", + category: ts.Diagnostics.Module_Resolution_Options, + description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking + }, + { + name: "sourceRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations, + }, + { + name: "mapRoot", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.LOCATION, + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations, + }, + { + name: "inlineSourceMap", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file + }, + { + name: "inlineSources", + type: "boolean", + category: ts.Diagnostics.Source_Map_Options, + description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set + }, + { + name: "experimentalDecorators", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators + }, + { + name: "emitDecoratorMetadata", + type: "boolean", + category: ts.Diagnostics.Experimental_Options, + description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators + }, + { + name: "jsxFactory", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h + }, + { + name: "diagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_diagnostic_information + }, + { + name: "extendedDiagnostics", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Show_verbose_diagnostic_information + }, + { + name: "traceResolution", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process + }, + { + name: "listFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation + }, + { + name: "listEmittedFiles", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation + }, + { + name: "out", + type: "string", + isFilePath: false, + category: ts.Diagnostics.Advanced_Options, + paramType: ts.Diagnostics.FILE, + description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file, + }, + { + name: "reactNamespace", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit + }, + { + name: "skipDefaultLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files + }, + { + name: "charset", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_character_set_of_the_input_files + }, + { + name: "emitBOM", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files + }, + { + name: "locale", + type: "string", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us + }, + { + name: "newLine", + type: ts.createMapFromTemplate({ + "crlf": 0, + "lf": 1 + }), + paramType: ts.Diagnostics.NEWLINE, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix, + }, + { + name: "noErrorTruncation", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_truncate_error_messages + }, + { + name: "noLib", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts + }, + { + name: "noResolve", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files + }, + { + name: "stripInternal", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation, + }, + { + name: "disableSizeLimit", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects + }, + { + name: "noImplicitUseStrict", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output + }, + { + name: "noEmitHelpers", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output + }, + { + name: "noEmitOnError", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported, + }, + { + name: "preserveConstEnums", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code + }, + { + name: "declarationDir", + type: "string", + isFilePath: true, + paramType: ts.Diagnostics.DIRECTORY, + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Output_directory_for_generated_declaration_files + }, + { + name: "skipLibCheck", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Skip_type_checking_of_declaration_files, + }, + { + name: "allowUnusedLabels", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unused_labels + }, + { + name: "allowUnreachableCode", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code + }, + { + name: "suppressExcessPropertyErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals, + }, + { + name: "suppressImplicitAnyIndexErrors", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures, + }, + { + name: "forceConsistentCasingInFileNames", + type: "boolean", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file + }, + { + name: "maxNodeModuleJsDepth", + type: "number", + category: ts.Diagnostics.Advanced_Options, + description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files + }, { name: "plugins", type: "list", @@ -5362,7 +5489,8 @@ var ts; element: { name: "plugin", type: "object" - } + }, + description: ts.Diagnostics.List_of_language_service_plugins } ]; ts.typeAcquisitionDeclarations = [ @@ -5394,8 +5522,7 @@ var ts; ts.defaultInitCompilerOptions = { module: ts.ModuleKind.CommonJS, target: 1, - noImplicitAny: false, - sourceMap: false, + strict: true }; var optionNameMapCache; function convertEnableAutoDiscoveryToEnable(typeAcquisition) { @@ -5586,7 +5713,7 @@ var ts; } } ts.parseConfigFileTextToJson = parseConfigFileTextToJson; - function generateTSConfig(options, fileNames) { + function generateTSConfig(options, fileNames, newLine) { var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions); var configurations = { compilerOptions: serializeCompilerOptions(compilerOptions) @@ -5594,7 +5721,7 @@ var ts; if (fileNames && fileNames.length) { configurations.files = fileNames; } - return configurations; + return writeConfigurations(); function getCustomTypeMapOfCommandLineOption(optionDefinition) { if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean") { return undefined; @@ -5618,41 +5745,110 @@ var ts; var optionsNameMap = getOptionNameMap().optionNameMap; for (var name in options) { if (ts.hasProperty(options, name)) { - switch (name) { - case "init": - case "watch": - case "version": - case "help": - case "project": - break; - default: - var value = options[name]; - var optionDefinition = optionsNameMap.get(name.toLowerCase()); - if (optionDefinition) { - var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); - if (!customTypeMap) { - result[name] = value; - } - else { - if (optionDefinition.type === "list") { - var convertedValue = []; - for (var _i = 0, _a = value; _i < _a.length; _i++) { - var element = _a[_i]; - convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); - } - result[name] = convertedValue; - } - else { - result[name] = getNameOfCompilerOptionValue(value, customTypeMap); - } + if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) { + continue; + } + var value = options[name]; + var optionDefinition = optionsNameMap.get(name.toLowerCase()); + if (optionDefinition) { + var customTypeMap = getCustomTypeMapOfCommandLineOption(optionDefinition); + if (!customTypeMap) { + result[name] = value; + } + else { + if (optionDefinition.type === "list") { + var convertedValue = []; + for (var _i = 0, _a = value; _i < _a.length; _i++) { + var element = _a[_i]; + convertedValue.push(getNameOfCompilerOptionValue(element, customTypeMap)); } + result[name] = convertedValue; } - break; + else { + result[name] = getNameOfCompilerOptionValue(value, customTypeMap); + } + } } } } return result; } + function getDefaultValueForOption(option) { + switch (option.type) { + case "number": + return 1; + case "boolean": + return true; + case "string": + return option.isFilePath ? "./" : ""; + case "list": + return []; + case "object": + return {}; + default: + return ts.arrayFrom(option.type.keys())[0]; + } + } + function makePadding(paddingLength) { + return Array(paddingLength + 1).join(" "); + } + function writeConfigurations() { + var categorizedOptions = ts.reduceLeft(ts.filter(ts.optionDeclarations, function (o) { return o.category !== ts.Diagnostics.Command_line_Options && o.category !== ts.Diagnostics.Advanced_Options; }), function (memo, value) { + if (value.category) { + var name = ts.getLocaleSpecificMessage(value.category); + (memo[name] || (memo[name] = [])).push(value); + } + return memo; + }, {}); + var marginLength = 0; + var seenKnownKeys = 0; + var nameColumn = []; + var descriptionColumn = []; + var knownKeysCount = ts.getOwnKeys(configurations.compilerOptions).length; + for (var category in categorizedOptions) { + if (nameColumn.length !== 0) { + nameColumn.push(""); + descriptionColumn.push(""); + } + nameColumn.push("/* " + category + " */"); + descriptionColumn.push(""); + for (var _i = 0, _a = categorizedOptions[category]; _i < _a.length; _i++) { + var option = _a[_i]; + var optionName = void 0; + if (ts.hasProperty(configurations.compilerOptions, option.name)) { + optionName = "\"" + option.name + "\": " + JSON.stringify(configurations.compilerOptions[option.name]) + ((seenKnownKeys += 1) === knownKeysCount ? "" : ","); + } + else { + optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ","; + } + nameColumn.push(optionName); + descriptionColumn.push("/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"); + marginLength = Math.max(optionName.length, marginLength); + } + } + var tab = makePadding(2); + var result = []; + result.push("{"); + result.push(tab + "\"compilerOptions\": {"); + for (var i = 0; i < nameColumn.length; i++) { + var optionName = nameColumn[i]; + var description = descriptionColumn[i]; + result.push(tab + tab + optionName + makePadding(marginLength - optionName.length + 2) + description); + } + if (configurations.files && configurations.files.length) { + result.push(tab + "},"); + result.push(tab + "\"files\": ["); + for (var i = 0; i < configurations.files.length; i++) { + result.push("" + tab + tab + JSON.stringify(configurations.files[i]) + (i === configurations.files.length - 1 ? "" : ",")); + } + result.push(tab + "]"); + } + else { + result.push(tab + "}"); + } + result.push("}"); + return result.join(newLine); + } } ts.generateTSConfig = generateTSConfig; function removeComments(jsonText) { @@ -5693,10 +5889,11 @@ var ts; var options = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); var jsonOptions = json["typeAcquisition"] || json["typingOptions"]; var typeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); + var baseCompileOnSave; if (json["extends"]) { var _a = [undefined, undefined, undefined, {}], include = _a[0], exclude = _a[1], files = _a[2], baseOptions = _a[3]; if (typeof json["extends"] === "string") { - _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseOptions = _b[3]; + _b = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]), include = _b[0], exclude = _b[1], files = _b[2], baseCompileOnSave = _b[3], baseOptions = _b[4]; } else { errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); @@ -5716,6 +5913,9 @@ var ts; options.configFilePath = configFileName; var _c = getFileNames(errors), fileNames = _c.fileNames, wildcardDirectories = _c.wildcardDirectories; var compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); + if (baseCompileOnSave && json[ts.compileOnSaveCommandLineOption.name] === undefined) { + compileOnSave = baseCompileOnSave; + } return { options: options, fileNames: fileNames, @@ -5753,7 +5953,7 @@ var ts; return ts.map(extendedResult.config[key], updatePath); } }), include = _a[0], exclude = _a[1], files = _a[2]; - return [include, exclude, files, result.options]; + return [include, exclude, files, result.compileOnSave, result.options]; } function getFileNames(errors) { var fileNames; @@ -5996,7 +6196,6 @@ var ts; } } } - ; } return wildcardDirectories; } @@ -6045,8 +6244,6 @@ var ts; (function (ts) { var JsTyping; (function (JsTyping) { - ; - ; var safeList; var EmptySafeList = ts.createMap(); JsTyping.nodeCoreModuleList = [ @@ -6087,8 +6284,10 @@ var ts; getTypingNamesFromJson(packageJsonPath, filesToWatch); var bowerJsonPath = ts.combinePaths(searchDir, "bower.json"); getTypingNamesFromJson(bowerJsonPath, filesToWatch); + var bowerComponentsPath = ts.combinePaths(searchDir, "bower_components"); + getTypingNamesFromPackagesFolder(bowerComponentsPath); var nodeModulesPath = ts.combinePaths(searchDir, "node_modules"); - getTypingNamesFromNodeModuleFolder(nodeModulesPath); + getTypingNamesFromPackagesFolder(nodeModulesPath); } getTypingNamesFromSourceFileNames(fileNames); if (unresolvedImports) { @@ -6164,16 +6363,18 @@ var ts; mergeTypings(["react"]); } } - function getTypingNamesFromNodeModuleFolder(nodeModulesPath) { - if (!host.directoryExists(nodeModulesPath)) { + function getTypingNamesFromPackagesFolder(packagesFolderPath) { + filesToWatch.push(packagesFolderPath); + if (!host.directoryExists(packagesFolderPath)) { return; } var typingNames = []; - var fileNames = host.readDirectory(nodeModulesPath, [".json"], undefined, undefined, 2); + var fileNames = host.readDirectory(packagesFolderPath, [".json"], undefined, undefined, 2); for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) { var fileName = fileNames_2[_i]; var normalizedFileName = ts.normalizePath(fileName); - if (ts.getBaseFileName(normalizedFileName) !== "package.json") { + var baseFileName = ts.getBaseFileName(normalizedFileName); + if (baseFileName !== "package.json" && baseFileName !== "bower.json") { continue; } var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); }); @@ -6181,7 +6382,7 @@ var ts; continue; } var packageJson = result.config; - if (packageJson._requiredBy && + if (baseFileName === "package.json" && packageJson._requiredBy && ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) { continue; } @@ -6210,11 +6411,13 @@ var ts; server.ActionInvalidate = "action::invalidate"; server.EventBeginInstallTypes = "event::beginInstallTypes"; server.EventEndInstallTypes = "event::endInstallTypes"; + server.EventInitializationFailed = "event::initializationFailed"; var Arguments; (function (Arguments) { Arguments.GlobalCacheLocation = "--globalTypingsCacheLocation"; Arguments.LogFile = "--logFile"; Arguments.EnableTelemetry = "--enableTelemetry"; + Arguments.TypingSafeListLocation = "--typingSafeListLocation"; })(Arguments = server.Arguments || (server.Arguments = {})); function hasArgument(argumentName) { return ts.sys.args.indexOf(argumentName) >= 0; @@ -6317,7 +6520,7 @@ var ts; return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)]; } var typeRoots; - forEachAncestorDirectory(currentDirectory, function (directory) { + forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) { var atTypes = ts.combinePaths(directory, nodeModulesAtTypes); if (host.directoryExists(atTypes)) { (typeRoots || (typeRoots = [])).push(atTypes); @@ -6485,7 +6688,7 @@ var ts; } directoryPathMap.set(parent, result); current = parent; - if (current == commonPrefix) { + if (current === commonPrefix) { break; } } @@ -6907,9 +7110,22 @@ var ts; } nodeModulesAtTypesExists = false; } - return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, moduleName, nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); + return loadModuleFromNodeModulesFolder(Extensions.DtsOnly, mangleScopedPackage(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, failedLookupLocations, state); } } + function mangleScopedPackage(moduleName, state) { + if (ts.startsWith(moduleName, "@")) { + var replaceSlash = moduleName.replace(ts.directorySeparator, "__"); + if (replaceSlash !== moduleName) { + var mangled = replaceSlash.slice(1); + if (state.traceEnabled) { + trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled); + } + return mangled; + } + } + return moduleName; + } function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, traceEnabled, host) { var result = cache && cache.get(containingDirectory); if (result) { @@ -7370,17 +7586,23 @@ var ts; var FileLog = (function () { function FileLog(logFile) { this.logFile = logFile; + this.logEnabled = true; } FileLog.prototype.isEnabled = function () { - return this.logFile !== undefined; + return this.logEnabled && this.logFile !== undefined; }; FileLog.prototype.writeLine = function (text) { - fs.appendFileSync(this.logFile, text + ts.sys.newLine); + try { + fs.appendFileSync(this.logFile, text + ts.sys.newLine); + } + catch (e) { + this.logEnabled = false; + } }; return FileLog; }()); function getNPMLocation(processName) { - if (path.basename(processName).indexOf("node") == 0) { + if (path.basename(processName).indexOf("node") === 0) { return "\"" + path.join(path.dirname(process.argv[0]), "npm") + "\""; } else { @@ -7411,8 +7633,8 @@ var ts; } var NodeTypingsInstaller = (function (_super) { __extends(NodeTypingsInstaller, _super); - function NodeTypingsInstaller(globalTypingsCacheLocation, throttleLimit, log) { - var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; + function NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, throttleLimit, log) { + var _this = _super.call(this, ts.sys, globalTypingsCacheLocation, typingSafeListLocation ? ts.toPath(typingSafeListLocation, "", ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)) : ts.toPath("typingSafeList.json", __dirname, ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)), throttleLimit, log) || this; if (_this.log.isEnabled()) { _this.log.writeLine("Process id: " + process.pid); } @@ -7429,6 +7651,10 @@ var ts; if (_this.log.isEnabled()) { _this.log.writeLine("Error updating " + TypesRegistryPackageName + " package: " + e.message); } + _this.delayedInitializationError = { + kind: "event::initializationFailed", + message: e.message + }; } _this.typesRegistry = loadTypesRegistryFile(getTypesRegistryFileLocation(globalTypingsCacheLocation), _this.installTypingHost, _this.log); return _this; @@ -7436,6 +7662,10 @@ var ts; NodeTypingsInstaller.prototype.listen = function () { var _this = this; process.on("message", function (req) { + if (_this.delayedInitializationError) { + _this.sendResponse(_this.delayedInitializationError); + _this.delayedInitializationError = undefined; + } switch (req.kind) { case "discover": _this.install(req); @@ -7481,6 +7711,7 @@ var ts; typingsInstaller.NodeTypingsInstaller = NodeTypingsInstaller; var logFilePath = server.findArgument(server.Arguments.LogFile); var globalTypingsCacheLocation = server.findArgument(server.Arguments.GlobalCacheLocation); + var typingSafeListLocation = server.findArgument(server.Arguments.TypingSafeListLocation); var log = new FileLog(logFilePath); if (log.isEnabled()) { process.on("uncaughtException", function (e) { @@ -7493,7 +7724,7 @@ var ts; } process.exit(0); }); - var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, 5, log); + var installer = new NodeTypingsInstaller(globalTypingsCacheLocation, typingSafeListLocation, 5, log); installer.listen(); })(typingsInstaller = server.typingsInstaller || (server.typingsInstaller = {})); })(server = ts.server || (ts.server = {})); diff --git a/lib/watchGuard.js b/lib/watchGuard.js new file mode 100644 index 00000000000..c9b3e69882b --- /dev/null +++ b/lib/watchGuard.js @@ -0,0 +1,27 @@ +/*! ***************************************************************************** +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. +***************************************************************************** */ + +if (process.argv.length < 3) { + process.exit(1); +} +var directoryName = process.argv[2]; +var fs = require("fs"); +try { + var watcher = fs.watch(directoryName, { recursive: true }, function () { return ({}); }); + watcher.close(); +} +catch (_e) { +} +process.exit(0); diff --git a/package.json b/package.json index 3ffab4bfb13..ea3262902b1 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "http://typescriptlang.org/", - "version": "2.3.0", + "version": "2.4.0", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ @@ -39,7 +39,6 @@ "@types/gulp-help": "latest", "@types/gulp-newer": "latest", "@types/gulp-sourcemaps": "latest", - "@types/gulp-typescript": "latest", "@types/merge2": "latest", "@types/minimatch": "latest", "@types/minimist": "latest", diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 27b3067278c..1940231a6d1 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -149,7 +149,7 @@ namespace ts { inStrictMode = bindInStrictMode(file, opts); classifiableNames = createMap(); symbolCount = 0; - skipTransformFlagAggregation = isDeclarationFile(file); + skipTransformFlagAggregation = file.isDeclarationFile; Symbol = objectAllocator.getSymbolConstructor(); @@ -182,7 +182,7 @@ namespace ts { return bindSourceFile; function bindInStrictMode(file: SourceFile, opts: CompilerOptions): boolean { - if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !isDeclarationFile(file)) { + if ((opts.alwaysStrict === undefined ? opts.strict : opts.alwaysStrict) && !file.isDeclarationFile) { // bind in strict mode source files with alwaysStrict option return true; } @@ -221,18 +221,19 @@ namespace ts { // other kinds of value declarations take precedence over modules symbol.valueDeclaration = node; } - } + } } // Should not be called on a declaration with a computed property name, // unless it is a well known Symbol. function getDeclarationName(node: Declaration): string { - if (node.name) { + const name = getNameOfDeclaration(node); + if (name) { if (isAmbientModule(node)) { - return isGlobalScopeAugmentation(node) ? "__global" : `"${(node.name).text}"`; + return isGlobalScopeAugmentation(node) ? "__global" : `"${(name).text}"`; } - if (node.name.kind === SyntaxKind.ComputedPropertyName) { - const nameExpression = (node.name).expression; + if (name.kind === SyntaxKind.ComputedPropertyName) { + const nameExpression = (name).expression; // treat computed property names where expression is string/numeric literal as just string/numeric literal if (isStringOrNumericLiteral(nameExpression)) { return nameExpression.text; @@ -241,7 +242,7 @@ namespace ts { Debug.assert(isWellKnownSymbolSyntactically(nameExpression)); return getPropertyNameForKnownSymbolName((nameExpression).name.text); } - return (node.name).text; + return (name).text; } switch (node.kind) { case SyntaxKind.Constructor: @@ -303,7 +304,7 @@ namespace ts { } function getDisplayName(node: Declaration): string { - return node.name ? declarationNameToString(node.name) : getDeclarationName(node); + return (node as NamedDeclaration).name ? declarationNameToString((node as NamedDeclaration).name) : getDeclarationName(node); } /** @@ -366,8 +367,8 @@ namespace ts { symbolTable.set(name, symbol = createSymbol(SymbolFlags.None, name)); } else { - if (node.name) { - node.name.parent = node; + if ((node as NamedDeclaration).name) { + (node as NamedDeclaration).name.parent = node; } // Report errors every position with duplicate declaration @@ -389,16 +390,16 @@ namespace ts { // 1. multiple export default of class declaration or function declaration by checking NodeFlags.Default // 2. multiple export default of export assignment. This one doesn't have NodeFlags.Default on (as export default doesn't considered as modifiers) if (symbol.declarations && symbol.declarations.length && - (isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(node).isExportEquals))) { - message = Diagnostics.A_module_cannot_have_multiple_default_exports; - } + (isDefaultExport || (node.kind === SyntaxKind.ExportAssignment && !(node).isExportEquals))) { + message = Diagnostics.A_module_cannot_have_multiple_default_exports; + } } } forEach(symbol.declarations, declaration => { - file.bindDiagnostics.push(createDiagnosticForNode(declaration.name || declaration, message, getDisplayName(declaration))); + file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(declaration) || declaration, message, getDisplayName(declaration))); }); - file.bindDiagnostics.push(createDiagnosticForNode(node.name || node, message, getDisplayName(node))); + file.bindDiagnostics.push(createDiagnosticForNode(getNameOfDeclaration(node) || node, message, getDisplayName(node))); symbol = createSymbol(SymbolFlags.None, name); } @@ -439,9 +440,9 @@ namespace ts { // 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. const isJSDocTypedefInJSDocNamespace = node.kind === SyntaxKind.JSDocTypedefTag && - node.name && - node.name.kind === SyntaxKind.Identifier && - (node.name).isInJSDocNamespace; + (node as JSDocTypedefTag).name && + (node as JSDocTypedefTag).name.kind === SyntaxKind.Identifier && + ((node as JSDocTypedefTag).name as Identifier).isInJSDocNamespace; if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypedefInJSDocNamespace) { const exportKind = (symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0) | @@ -1414,7 +1415,7 @@ namespace ts { if (isObjectLiteralOrClassExpressionMethod(node)) { return ContainerFlags.IsContainer | ContainerFlags.IsControlFlowContainer | ContainerFlags.HasLocals | ContainerFlags.IsFunctionLike | ContainerFlags.IsObjectLiteralOrClassExpressionMethod; } - // falls through + // falls through case SyntaxKind.Constructor: case SyntaxKind.FunctionDeclaration: case SyntaxKind.MethodSignature: @@ -1716,7 +1717,7 @@ namespace ts { declareModuleMember(node, symbolFlags, symbolExcludes); break; } - // falls through + // falls through default: if (!blockScopeContainer.locals) { blockScopeContainer.locals = createMap(); @@ -2010,7 +2011,7 @@ namespace ts { bindBlockScopedDeclaration(parentNode, SymbolFlags.TypeAlias, SymbolFlags.TypeAliasExcludes); break; } - // falls through + // falls through case SyntaxKind.ThisKeyword: if (currentFlow && (isExpression(node) || parent.kind === SyntaxKind.ShorthandPropertyAssignment)) { node.flowNode = currentFlow; @@ -2186,7 +2187,7 @@ namespace ts { if (!isFunctionLike(node.parent)) { return; } - // falls through + // falls through case SyntaxKind.ModuleBlock: return updateStrictModeStatementList((node).statements); } @@ -2211,7 +2212,7 @@ namespace ts { } function bindSourceFileAsExternalModule() { - bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName) }"`); + bindAnonymousDeclaration(file, SymbolFlags.ValueModule, `"${removeFileExtension(file.fileName)}"`); } function bindExportAssignment(node: ExportAssignment | BinaryExpression) { @@ -2504,7 +2505,7 @@ namespace ts { } function bindParameter(node: ParameterDeclaration) { - if (inStrictMode) { + if (inStrictMode && !isInAmbientContext(node)) { // It is a SyntaxError if the identifier eval or arguments appears within a FormalParameterList of a // strict mode FunctionLikeDeclaration or FunctionExpression(13.1) checkStrictModeEvalOrArguments(node, node.name); @@ -2526,7 +2527,7 @@ namespace ts { } function bindFunctionDeclaration(node: FunctionDeclaration) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (!file.isDeclarationFile && !isInAmbientContext(node)) { if (isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; } @@ -2543,7 +2544,7 @@ namespace ts { } function bindFunctionExpression(node: FunctionExpression) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (!file.isDeclarationFile && !isInAmbientContext(node)) { if (isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; } @@ -2557,7 +2558,7 @@ namespace ts { } function bindPropertyOrMethodOrAccessor(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) { - if (!isDeclarationFile(file) && !isInAmbientContext(node)) { + if (!file.isDeclarationFile && !isInAmbientContext(node)) { if (isAsyncFunction(node)) { emitFlags |= NodeFlags.HasAsyncFunctions; } diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ee46e78774a..3f2955f61fa 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -205,7 +205,11 @@ namespace ts { // since we are only interested in declarations of the module itself return tryFindAmbientModule(moduleName, /*withAugmentations*/ false); }, - getApparentType + getApparentType, + getAllPossiblePropertiesOfType, + getSuggestionForNonexistentProperty, + getSuggestionForNonexistentSymbol, + getBaseConstraintOfType, }; const tupleTypes: GenericType[] = []; @@ -316,6 +320,8 @@ namespace ts { const resolutionResults: boolean[] = []; const resolutionPropertyNames: TypeSystemPropertyName[] = []; + let suggestionCount = 0; + const maximumSuggestionCount = 10; const mergedSymbols: Symbol[] = []; const symbolLinks: SymbolLinks[] = []; const nodeLinks: NodeLinks[] = []; @@ -580,16 +586,16 @@ namespace ts { recordMergedSymbol(target, source); } else if (target.flags & SymbolFlags.NamespaceModule) { - error(source.declarations[0].name, Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); + error(getNameOfDeclaration(source.declarations[0]), Diagnostics.Cannot_augment_module_0_with_value_exports_because_it_resolves_to_a_non_module_entity, symbolToString(target)); } else { const message = target.flags & SymbolFlags.BlockScopedVariable || source.flags & SymbolFlags.BlockScopedVariable ? Diagnostics.Cannot_redeclare_block_scoped_variable_0 : Diagnostics.Duplicate_identifier_0; forEach(source.declarations, node => { - error(node.name ? node.name : node, message, symbolToString(source)); + error(getNameOfDeclaration(node) || node, message, symbolToString(source)); }); forEach(target.declarations, node => { - error(node.name ? node.name : node, message, symbolToString(source)); + error(getNameOfDeclaration(node) || node, message, symbolToString(source)); }); } } @@ -679,10 +685,6 @@ namespace ts { return type.flags & TypeFlags.Object ? (type).objectFlags : 0; } - function getCheckFlags(symbol: Symbol): CheckFlags { - return symbol.flags & SymbolFlags.Transient ? (symbol).checkFlags : 0; - } - function isGlobalSourceFile(node: Node) { return node.kind === SyntaxKind.SourceFile && !isExternalOrCommonJsModule(node); } @@ -732,7 +734,8 @@ namespace ts { const useFile = getSourceFileOfNode(usage); if (declarationFile !== useFile) { if ((modulekind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) || - (!compilerOptions.outFile && !compilerOptions.out)) { + (!compilerOptions.outFile && !compilerOptions.out) || + isInAmbientContext(declaration)) { // nodes are in different files and order cannot be determined return true; } @@ -840,7 +843,25 @@ namespace ts { // Resolve a given name for a given meaning at a given location. An error is reported if the name was not found and // the nameNotFoundMessage argument is not undefined. Returns the resolved symbol, or undefined if no symbol with // the given name can be found. - function resolveName(location: Node | undefined, name: string, meaning: SymbolFlags, nameNotFoundMessage: DiagnosticMessage, nameArg: string | Identifier): Symbol { + function resolveName( + location: Node | undefined, + name: string, + meaning: SymbolFlags, + nameNotFoundMessage: DiagnosticMessage, + nameArg: string | Identifier, + suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { + return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, getSymbol, suggestedNameNotFoundMessage); + } + + function resolveNameHelper( + location: Node | undefined, + name: string, + meaning: SymbolFlags, + nameNotFoundMessage: DiagnosticMessage, + nameArg: string | Identifier, + lookup: (symbols: SymbolTable, name: string, meaning: SymbolFlags) => Symbol, + suggestedNameNotFoundMessage?: DiagnosticMessage): Symbol { + const originalLocation = location; // needed for did-you-mean error reporting, which gathers candidates starting from the original location let result: Symbol; let lastLocation: Node; let propertyWithInvalidInitializer: Node; @@ -851,7 +872,7 @@ namespace ts { loop: while (location) { // Locals of a source file are not in scope (because they get merged into the global symbol table) if (location.locals && !isGlobalSourceFile(location)) { - if (result = getSymbol(location.locals, name, meaning)) { + if (result = lookup(location.locals, name, meaning)) { let useResult = true; if (isFunctionLike(location) && lastLocation && lastLocation !== (location).body) { // symbol lookup restrictions for function-like declarations @@ -929,12 +950,12 @@ namespace ts { } } - if (result = getSymbol(moduleExports, name, meaning & SymbolFlags.ModuleMember)) { + if (result = lookup(moduleExports, name, meaning & SymbolFlags.ModuleMember)) { break loop; } break; case SyntaxKind.EnumDeclaration: - if (result = getSymbol(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) { + if (result = lookup(getSymbolOfNode(location).exports, name, meaning & SymbolFlags.EnumMember)) { break loop; } break; @@ -949,7 +970,7 @@ namespace ts { if (isClassLike(location.parent) && !(getModifierFlags(location) & ModifierFlags.Static)) { const ctor = findConstructorDeclaration(location.parent); if (ctor && ctor.locals) { - if (getSymbol(ctor.locals, name, meaning & SymbolFlags.Value)) { + if (lookup(ctor.locals, name, meaning & SymbolFlags.Value)) { // Remember the property node, it will be used later to report appropriate error propertyWithInvalidInitializer = location; } @@ -959,7 +980,7 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: - if (result = getSymbol(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { + if (result = lookup(getSymbolOfNode(location).members, name, meaning & SymbolFlags.Type)) { if (!isTypeParameterSymbolDeclaredInContainer(result, location)) { // ignore type parameters not declared in this container result = undefined; @@ -995,7 +1016,7 @@ namespace ts { grandparent = location.parent.parent; if (isClassLike(grandparent) || grandparent.kind === SyntaxKind.InterfaceDeclaration) { // A reference to this grandparent's type parameters would be an error - if (result = getSymbol(getSymbolOfNode(grandparent).members, name, meaning & SymbolFlags.Type)) { + if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & SymbolFlags.Type)) { error(errorLocation, Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type); return undefined; } @@ -1059,7 +1080,7 @@ namespace ts { } if (!result) { - result = getSymbol(globals, name, meaning); + result = lookup(globals, name, meaning); } if (!result) { @@ -1070,7 +1091,17 @@ namespace ts { !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) && !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) && !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning)) { - error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); + let suggestion: string | undefined; + if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) { + suggestion = getSuggestionForNonexistentSymbol(originalLocation, name, meaning); + if (suggestion) { + suggestionCount++; + error(errorLocation, suggestedNameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg), suggestion); + } + } + if (!suggestion) { + error(errorLocation, nameNotFoundMessage, typeof nameArg === "string" ? nameArg : declarationNameToString(nameArg)); + } } } return undefined; @@ -1204,6 +1235,10 @@ namespace ts { function checkAndReportErrorForUsingTypeAsValue(errorLocation: Node, name: string, meaning: SymbolFlags): boolean { if (meaning & (SymbolFlags.Value & ~SymbolFlags.NamespaceModule)) { + if (name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never") { + error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, name); + return true; + } const symbol = resolveSymbol(resolveName(errorLocation, name, SymbolFlags.Type & ~SymbolFlags.Value, /*nameNotFoundMessage*/undefined, /*nameArg*/ undefined)); if (symbol && !(symbol.flags & SymbolFlags.NamespaceModule)) { error(errorLocation, Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, name); @@ -1240,13 +1275,13 @@ namespace ts { if (!isInAmbientContext(declaration) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) { if (result.flags & SymbolFlags.BlockScopedVariable) { - error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(declaration.name)); + error(errorLocation, Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration))); } else if (result.flags & SymbolFlags.Class) { - error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(declaration.name)); + error(errorLocation, Diagnostics.Class_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration))); } - else if (result.flags & SymbolFlags.Enum) { - error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(declaration.name)); + else if (result.flags & SymbolFlags.RegularEnum) { + error(errorLocation, Diagnostics.Enum_0_used_before_its_declaration, declarationNameToString(getNameOfDeclaration(declaration))); } } } @@ -1265,7 +1300,7 @@ namespace ts { return node; } - return findAncestor(node, n => n.kind === SyntaxKind.ImportDeclaration) as ImportDeclaration; + return findAncestor(node, isImportDeclaration); } } @@ -1400,10 +1435,10 @@ namespace ts { return resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias); } - function getTargetOfExportSpecifier(node: ExportSpecifier, dontResolveAlias?: boolean): Symbol { - return (node.parent.parent).moduleSpecifier ? - getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : - resolveEntityName(node.propertyName || node.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, /*ignoreErrors*/ false, dontResolveAlias); + function getTargetOfExportSpecifier(node: ExportSpecifier, meaning: SymbolFlags, dontResolveAlias?: boolean) { + return node.parent.parent.moduleSpecifier ? + getExternalModuleMember(node.parent.parent, node, dontResolveAlias) : + resolveEntityName(node.propertyName || node.name, meaning, /*ignoreErrors*/ false, dontResolveAlias); } function getTargetOfExportAssignment(node: ExportAssignment, dontResolveAlias: boolean): Symbol { @@ -1421,7 +1456,7 @@ namespace ts { case SyntaxKind.ImportSpecifier: return getTargetOfImportSpecifier(node, dontRecursivelyResolve); case SyntaxKind.ExportSpecifier: - return getTargetOfExportSpecifier(node, dontRecursivelyResolve); + return getTargetOfExportSpecifier(node, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace, dontRecursivelyResolve); case SyntaxKind.ExportAssignment: return getTargetOfExportAssignment(node, dontRecursivelyResolve); case SyntaxKind.NamespaceExportDeclaration: @@ -1683,10 +1718,9 @@ namespace ts { // references a symbol that is at least declared as a module or a variable. The target of the 'export =' may // combine other declarations with the module or variable (e.g. a class/module, function/module, interface/variable). function resolveESModuleSymbol(moduleSymbol: Symbol, moduleReferenceExpression: Expression, dontResolveAlias: boolean): Symbol { - let symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); + const symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias); if (!dontResolveAlias && symbol && !(symbol.flags & (SymbolFlags.Module | SymbolFlags.Variable))) { error(moduleReferenceExpression, Diagnostics.Module_0_resolves_to_a_non_module_entity_and_cannot_be_imported_using_this_construct, symbolToString(moduleSymbol)); - symbol = undefined; } return symbol; } @@ -2241,48 +2275,74 @@ namespace ts { } function typeToString(type: Type, enclosingDeclaration?: Node, flags?: TypeFormatFlags): string { - const writer = getSingleLineStringWriter(); - getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); - let result = writer.string(); - releaseStringWriter(writer); + const typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | NodeBuilderFlags.IgnoreErrors | NodeBuilderFlags.WriteTypeParametersInQualifiedName); + Debug.assert(typeNode !== undefined, "should always get typenode?"); + const options = { removeComments: true }; + const writer = createTextWriter(""); + const printer = createPrinter(options, writer); + const sourceFile = enclosingDeclaration && getSourceFileOfNode(enclosingDeclaration); + printer.writeNode(EmitHint.Unspecified, typeNode, /*sourceFile*/ sourceFile, writer); + const result = writer.getText(); const maxLength = compilerOptions.noErrorTruncation || flags & TypeFormatFlags.NoTruncation ? undefined : 100; if (maxLength && result.length >= maxLength) { - result = result.substr(0, maxLength - "...".length) + "..."; + return result.substr(0, maxLength - "...".length) + "..."; } return result; + + function toNodeBuilderFlags(flags?: TypeFormatFlags): NodeBuilderFlags { + let result = NodeBuilderFlags.None; + if (!flags) { + return result; + } + if (flags & TypeFormatFlags.NoTruncation) { + result |= NodeBuilderFlags.NoTruncation; + } + if (flags & TypeFormatFlags.UseFullyQualifiedType) { + result |= NodeBuilderFlags.UseFullyQualifiedType; + } + if (flags & TypeFormatFlags.SuppressAnyReturnType) { + result |= NodeBuilderFlags.SuppressAnyReturnType; + } + if (flags & TypeFormatFlags.WriteArrayAsGenericType) { + result |= NodeBuilderFlags.WriteArrayAsGenericType; + } + if (flags & TypeFormatFlags.WriteTypeArgumentsOfSignature) { + result |= NodeBuilderFlags.WriteTypeArgumentsOfSignature; + } + + return result; + } } function createNodeBuilder() { - let context: NodeBuilderContext; - return { typeToTypeNode: (type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { - context = createNodeBuilderContext(enclosingDeclaration, flags); - const resultingNode = typeToTypeNodeHelper(type); + const context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = typeToTypeNodeHelper(type, context); const result = context.encounteredError ? undefined : resultingNode; return result; }, indexInfoToIndexSignatureDeclaration: (indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { - context = createNodeBuilderContext(enclosingDeclaration, flags); - const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind); + const context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context); const result = context.encounteredError ? undefined : resultingNode; return result; }, signatureToSignatureDeclaration: (signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags) => { - context = createNodeBuilderContext(enclosingDeclaration, flags); - const resultingNode = signatureToSignatureDeclarationHelper(signature, kind); + const context = createNodeBuilderContext(enclosingDeclaration, flags); + const resultingNode = signatureToSignatureDeclarationHelper(signature, kind, context); const result = context.encounteredError ? undefined : resultingNode; return result; } }; interface NodeBuilderContext { - readonly enclosingDeclaration: Node | undefined; - readonly flags: NodeBuilderFlags | undefined; + enclosingDeclaration: Node | undefined; + flags: NodeBuilderFlags | undefined; + + // State encounteredError: boolean; - inObjectTypeLiteral: boolean; - checkAlias: boolean; symbolStack: Symbol[] | undefined; } @@ -2291,16 +2351,16 @@ namespace ts { enclosingDeclaration, flags, encounteredError: false, - inObjectTypeLiteral: false, - checkAlias: true, symbolStack: undefined }; } - function typeToTypeNodeHelper(type: Type): TypeNode { + function typeToTypeNodeHelper(type: Type, context: NodeBuilderContext): TypeNode { + const inTypeAlias = context.flags & NodeBuilderFlags.InTypeAlias; + context.flags &= ~NodeBuilderFlags.InTypeAlias; + if (!type) { context.encounteredError = true; - // TODO(aozgaa): should we return implict any (undefined) or explicit any (keywordtypenode)? return undefined; } @@ -2316,12 +2376,21 @@ namespace ts { if (type.flags & TypeFlags.Boolean) { return createKeywordTypeNode(SyntaxKind.BooleanKeyword); } - if (type.flags & TypeFlags.EnumLike && !(type.flags & TypeFlags.Union)) { - const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + if (type.flags & TypeFlags.EnumLiteral && !(type.flags & TypeFlags.Union)) { + const parentSymbol = getParentOfSymbol(type.symbol); + const parentName = symbolToName(parentSymbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false); + const enumLiteralName = getDeclaredTypeOfSymbol(parentSymbol) === type ? parentName : createQualifiedName(parentName, getNameOfSymbol(type.symbol, context)); + return createTypeReferenceNode(enumLiteralName, /*typeArguments*/ undefined); + } + if (type.flags & TypeFlags.EnumLike) { + const name = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false); return createTypeReferenceNode(name, /*typeArguments*/ undefined); } - if (type.flags & (TypeFlags.StringLiteral | TypeFlags.NumberLiteral)) { - return createLiteralTypeNode(createLiteral((type).value)); + if (type.flags & (TypeFlags.StringLiteral)) { + return createLiteralTypeNode(setEmitFlags(createLiteral((type).value), EmitFlags.NoAsciiEscaping)); + } + if (type.flags & (TypeFlags.NumberLiteral)) { + return createLiteralTypeNode((createLiteral((type).value))); } if (type.flags & TypeFlags.BooleanLiteral) { return (type).intrinsicName === "true" ? createTrue() : createFalse(); @@ -2345,8 +2414,8 @@ namespace ts { return createKeywordTypeNode(SyntaxKind.ObjectKeyword); } if (type.flags & TypeFlags.TypeParameter && (type as TypeParameter).isThisType) { - if (context.inObjectTypeLiteral) { - if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowThisInObjectLiteral)) { + if (context.flags & NodeBuilderFlags.InObjectTypeLiteral) { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowThisInObjectLiteral)) { context.encounteredError = true; } } @@ -2359,84 +2428,58 @@ namespace ts { Debug.assert(!!(type.flags & TypeFlags.Object)); return typeReferenceToTypeNode(type); } - if (objectFlags & ObjectFlags.ClassOrInterface) { - Debug.assert(!!(type.flags & TypeFlags.Object)); - const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); - // TODO(aozgaa): handle type arguments. - return createTypeReferenceNode(name, /*typeArguments*/ undefined); - } - if (type.flags & TypeFlags.TypeParameter) { - const name = symbolToName(type.symbol, /*expectsIdentifier*/ false); + if (type.flags & TypeFlags.TypeParameter || objectFlags & ObjectFlags.ClassOrInterface) { + const name = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false); // Ignore constraint/default when creating a usage (as opposed to declaration) of a type parameter. return createTypeReferenceNode(name, /*typeArguments*/ undefined); } - - if (context.checkAlias && type.aliasSymbol) { - const name = symbolToName(type.aliasSymbol, /*expectsIdentifier*/ false); - const typeArgumentNodes = type.aliasTypeArguments && mapToTypeNodeArray(type.aliasTypeArguments); + if (!inTypeAlias && type.aliasSymbol && + isSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration, SymbolFlags.Type, /*shouldComputeAliasesToMakeVisible*/ false).accessibility === SymbolAccessibility.Accessible) { + const name = symbolToTypeReferenceName(type.aliasSymbol); + const typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context); return createTypeReferenceNode(name, typeArgumentNodes); } - context.checkAlias = false; - - if (type.flags & TypeFlags.Union) { - const formattedUnionTypes = formatUnionTypes((type).types); - const unionTypeNodes = formattedUnionTypes && mapToTypeNodeArray(formattedUnionTypes); - if (unionTypeNodes && unionTypeNodes.length > 0) { - return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, unionTypeNodes); + if (type.flags & (TypeFlags.Union | TypeFlags.Intersection)) { + const types = type.flags & TypeFlags.Union ? formatUnionTypes((type).types) : (type).types; + const typeNodes = mapToTypeNodes(types, context); + if (typeNodes && typeNodes.length > 0) { + const unionOrIntersectionTypeNode = createUnionOrIntersectionTypeNode(type.flags & TypeFlags.Union ? SyntaxKind.UnionType : SyntaxKind.IntersectionType, typeNodes); + return unionOrIntersectionTypeNode; } else { - if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyUnionOrIntersection)) { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowEmptyUnionOrIntersection)) { context.encounteredError = true; } return undefined; } } - - if (type.flags & TypeFlags.Intersection) { - return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, mapToTypeNodeArray((type as UnionType).types)); - } - if (objectFlags & (ObjectFlags.Anonymous | ObjectFlags.Mapped)) { Debug.assert(!!(type.flags & TypeFlags.Object)); // The type is an object literal type. return createAnonymousTypeNode(type); } - if (type.flags & TypeFlags.Index) { const indexedType = (type).type; - const indexTypeNode = typeToTypeNodeHelper(indexedType); + const indexTypeNode = typeToTypeNodeHelper(indexedType, context); return createTypeOperatorNode(indexTypeNode); } if (type.flags & TypeFlags.IndexedAccess) { - const objectTypeNode = typeToTypeNodeHelper((type).objectType); - const indexTypeNode = typeToTypeNodeHelper((type).indexType); + const objectTypeNode = typeToTypeNodeHelper((type).objectType, context); + const indexTypeNode = typeToTypeNodeHelper((type).indexType, context); return createIndexedAccessTypeNode(objectTypeNode, indexTypeNode); } Debug.fail("Should be unreachable."); - function mapToTypeNodeArray(types: Type[]): TypeNode[] { - const result = []; - for (const type of types) { - const typeNode = typeToTypeNodeHelper(type); - if (typeNode) { - result.push(typeNode); - } - } - return result; - } - function createMappedTypeNodeFromType(type: MappedType) { Debug.assert(!!(type.flags & TypeFlags.Object)); - const typeParameter = getTypeParameterFromMappedType(type); - const typeParameterNode = typeParameterToDeclaration(typeParameter); - - const templateType = getTemplateTypeFromMappedType(type); - const templateTypeNode = typeToTypeNodeHelper(templateType); const readonlyToken = type.declaration && type.declaration.readonlyToken ? createToken(SyntaxKind.ReadonlyKeyword) : undefined; const questionToken = type.declaration && type.declaration.questionToken ? createToken(SyntaxKind.QuestionToken) : undefined; + const typeParameterNode = typeParameterToDeclaration(getTypeParameterFromMappedType(type), context); + const templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context); - return createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + const mappedTypeNode = createMappedTypeNode(readonlyToken, typeParameterNode, questionToken, templateTypeNode); + return setEmitFlags(mappedTypeNode, EmitFlags.SingleLine); } function createAnonymousTypeNode(type: ObjectType): TypeNode { @@ -2446,14 +2489,14 @@ namespace ts { if (symbol.flags & SymbolFlags.Class && !getBaseTypeVariableOfClass(symbol) || symbol.flags & (SymbolFlags.Enum | SymbolFlags.ValueModule) || shouldWriteTypeOfFunctionSymbol()) { - return createTypeQueryNodeFromSymbol(symbol); + return createTypeQueryNodeFromSymbol(symbol, SymbolFlags.Value); } else if (contains(context.symbolStack, symbol)) { // If type is an anonymous type literal in a type alias declaration, use type alias name const typeAlias = getTypeAliasForTypeLiteral(type); if (typeAlias) { // The specified symbol flags need to be reinterpreted as type flags - const entityName = symbolToName(typeAlias, /*expectsIdentifier*/ false); + const entityName = symbolToName(typeAlias, context, SymbolFlags.Type, /*expectsIdentifier*/ false); return createTypeReferenceNode(entityName, /*typeArguments*/ undefined); } else { @@ -2501,45 +2544,61 @@ namespace ts { const resolved = resolveStructuredTypeMembers(type); if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) { if (!resolved.callSignatures.length && !resolved.constructSignatures.length) { - return createTypeLiteralNode(/*members*/ undefined); + return setEmitFlags(createTypeLiteralNode(/*members*/ undefined), EmitFlags.SingleLine); } if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) { const signature = resolved.callSignatures[0]; - return signatureToSignatureDeclarationHelper(signature, SyntaxKind.FunctionType); + const signatureNode = signatureToSignatureDeclarationHelper(signature, SyntaxKind.FunctionType, context); + return signatureNode; + } + if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) { const signature = resolved.constructSignatures[0]; - return signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructorType); + const signatureNode = signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructorType, context); + return signatureNode; } } - const saveInObjectTypeLiteral = context.inObjectTypeLiteral; - context.inObjectTypeLiteral = true; + const savedFlags = context.flags; + context.flags |= NodeBuilderFlags.InObjectTypeLiteral; const members = createTypeNodesFromResolvedType(resolved); - context.inObjectTypeLiteral = saveInObjectTypeLiteral; - return createTypeLiteralNode(members); + context.flags = savedFlags; + const typeLiteralNode = createTypeLiteralNode(members); + return setEmitFlags(typeLiteralNode, EmitFlags.SingleLine); } - function createTypeQueryNodeFromSymbol(symbol: Symbol) { - const entityName = symbolToName(symbol, /*expectsIdentifier*/ false); + function createTypeQueryNodeFromSymbol(symbol: Symbol, symbolFlags: SymbolFlags) { + const entityName = symbolToName(symbol, context, symbolFlags, /*expectsIdentifier*/ false); return createTypeQueryNode(entityName); } + function symbolToTypeReferenceName(symbol: Symbol) { + // Unnamed function expressions and arrow functions have reserved names that we don't want to display + const entityName = symbol.flags & SymbolFlags.Class || !isReservedMemberName(symbol.name) ? symbolToName(symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ false) : createIdentifier(""); + return entityName; + } + function typeReferenceToTypeNode(type: TypeReference) { const typeArguments: Type[] = type.typeArguments || emptyArray; if (type.target === globalArrayType) { - const elementType = typeToTypeNodeHelper(typeArguments[0]); + if (context.flags & NodeBuilderFlags.WriteArrayAsGenericType) { + const typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context); + return createTypeReferenceNode("Array", [typeArgumentNode]); + } + + const elementType = typeToTypeNodeHelper(typeArguments[0], context); return createArrayTypeNode(elementType); } else if (type.target.objectFlags & ObjectFlags.Tuple) { if (typeArguments.length > 0) { - const tupleConstituentNodes = mapToTypeNodeArray(typeArguments.slice(0, getTypeReferenceArity(type))); + const tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, getTypeReferenceArity(type)), context); if (tupleConstituentNodes && tupleConstituentNodes.length > 0) { return createTupleTypeNode(tupleConstituentNodes); } } - if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowEmptyTuple)) { + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowEmptyTuple)) { context.encounteredError = true; } return undefined; @@ -2547,7 +2606,7 @@ namespace ts { else { const outerTypeParameters = type.target.outerTypeParameters; let i = 0; - let qualifiedName: QualifiedName | undefined = undefined; + let qualifiedName: QualifiedName | undefined; if (outerTypeParameters) { const length = outerTypeParameters.length; while (i < length) { @@ -2560,47 +2619,80 @@ namespace ts { // 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 (!rangeEquals(outerTypeParameters, typeArguments, start, i)) { - const qualifiedNamePart = symbolToName(parent, /*expectsIdentifier*/ true); - if (!qualifiedName) { - qualifiedName = createQualifiedName(qualifiedNamePart, /*right*/ undefined); + const typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context); + const typeArgumentNodes = typeArgumentSlice && createNodeArray(typeArgumentSlice); + const namePart = symbolToTypeReferenceName(parent); + (namePart.kind === SyntaxKind.Identifier ? namePart : namePart.right).typeArguments = typeArgumentNodes; + + if (qualifiedName) { + Debug.assert(!qualifiedName.right); + qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, namePart); + qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); } else { - Debug.assert(!qualifiedName.right); - qualifiedName.right = qualifiedNamePart; - qualifiedName = createQualifiedName(qualifiedName, /*right*/ undefined); + qualifiedName = createQualifiedName(namePart, /*right*/ undefined); } } } } + let entityName: EntityName = undefined; - const nameIdentifier = symbolToName(type.symbol, /*expectsIdentifier*/ true); + const nameIdentifier = symbolToTypeReferenceName(type.symbol); if (qualifiedName) { Debug.assert(!qualifiedName.right); - qualifiedName.right = nameIdentifier; + qualifiedName = addToQualifiedNameMissingRightIdentifier(qualifiedName, nameIdentifier); entityName = qualifiedName; } else { entityName = nameIdentifier; } - const typeParameterCount = (type.target.typeParameters || emptyArray).length; - const typeArgumentNodes = some(typeArguments) ? mapToTypeNodeArray(typeArguments.slice(i, typeParameterCount - i)) : undefined; + + let typeArgumentNodes: TypeNode[] | undefined; + if (typeArguments.length > 0) { + const typeParameterCount = (type.target.typeParameters || emptyArray).length; + typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context); + } + + if (typeArgumentNodes) { + const lastIdentifier = entityName.kind === SyntaxKind.Identifier ? entityName : entityName.right; + lastIdentifier.typeArguments = undefined; + } + return createTypeReferenceNode(entityName, typeArgumentNodes); } } + function addToQualifiedNameMissingRightIdentifier(left: QualifiedName, right: Identifier | QualifiedName) { + Debug.assert(left.right === undefined); + + if (right.kind === SyntaxKind.Identifier) { + left.right = right; + return left; + } + + let rightPart = right; + while (rightPart.left.kind !== SyntaxKind.Identifier) { + rightPart = rightPart.left; + } + + left.right = rightPart.left; + rightPart.left = left; + return right; + } + function createTypeNodesFromResolvedType(resolvedType: ResolvedType): TypeElement[] { const typeElements: TypeElement[] = []; for (const signature of resolvedType.callSignatures) { - typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.CallSignature, context)); } for (const signature of resolvedType.constructSignatures) { - typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature)); + typeElements.push(signatureToSignatureDeclarationHelper(signature, SyntaxKind.ConstructSignature, context)); } if (resolvedType.stringIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, IndexKind.String, context)); } if (resolvedType.numberIndexInfo) { - typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number)); + typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, IndexKind.Number, context)); } const properties = resolvedType.properties; @@ -2610,39 +2702,55 @@ namespace ts { for (const propertySymbol of properties) { const propertyType = getTypeOfSymbol(propertySymbol); - const oldDeclaration = propertySymbol.declarations && propertySymbol.declarations[0] as TypeElement; - if (!oldDeclaration) { - return; - } - const propertyName = oldDeclaration.name; + const saveEnclosingDeclaration = context.enclosingDeclaration; + context.enclosingDeclaration = undefined; + const propertyName = symbolToName(propertySymbol, context, SymbolFlags.Value, /*expectsIdentifier*/ true); + context.enclosingDeclaration = saveEnclosingDeclaration; const optionalToken = propertySymbol.flags & SymbolFlags.Optional ? createToken(SyntaxKind.QuestionToken) : undefined; if (propertySymbol.flags & (SymbolFlags.Function | SymbolFlags.Method) && !getPropertiesOfObjectType(propertyType).length) { const signatures = getSignaturesOfType(propertyType, SignatureKind.Call); for (const signature of signatures) { - const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature); + const methodDeclaration = signatureToSignatureDeclarationHelper(signature, SyntaxKind.MethodSignature, context); methodDeclaration.name = propertyName; methodDeclaration.questionToken = optionalToken; typeElements.push(methodDeclaration); } } else { + const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType, context) : createKeywordTypeNode(SyntaxKind.AnyKeyword); - // TODO(aozgaa): should we create a node with explicit or implict any? - const propertyTypeNode = propertyType ? typeToTypeNodeHelper(propertyType) : createKeywordTypeNode(SyntaxKind.AnyKeyword); - typeElements.push(createPropertySignature( + const modifiers = isReadonlySymbol(propertySymbol) ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined; + const propertySignature = createPropertySignature( + modifiers, propertyName, optionalToken, propertyTypeNode, - /*initializer*/ undefined)); + /*initializer*/ undefined); + typeElements.push(propertySignature); } } return typeElements.length ? typeElements : undefined; } } - function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind): IndexSignatureDeclaration { + function mapToTypeNodes(types: Type[], context: NodeBuilderContext): TypeNode[] { + if (some(types)) { + const result = []; + for (let i = 0; i < types.length; ++i) { + const type = types[i]; + const typeNode = typeToTypeNodeHelper(type, context); + if (typeNode) { + result.push(typeNode); + } + } + + return result; + } + } + + function indexInfoToIndexSignatureDeclarationHelper(indexInfo: IndexInfo, kind: IndexKind, context: NodeBuilderContext): IndexSignatureDeclaration { + const name = getNameFromIndexInfo(indexInfo) || "x"; const indexerTypeNode = createKeywordTypeNode(kind === IndexKind.String ? SyntaxKind.StringKeyword : SyntaxKind.NumberKeyword); - const name = getNameFromIndexInfo(indexInfo); const indexingParameter = createParameter( /*decorators*/ undefined, @@ -2652,69 +2760,101 @@ namespace ts { /*questionToken*/ undefined, indexerTypeNode, /*initializer*/ undefined); - const typeNode = typeToTypeNodeHelper(indexInfo.type); - return createIndexSignatureDeclaration( + const typeNode = typeToTypeNodeHelper(indexInfo.type, context); + return createIndexSignature( /*decorators*/ undefined, indexInfo.isReadonly ? [createToken(SyntaxKind.ReadonlyKeyword)] : undefined, [indexingParameter], typeNode); } - function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind): SignatureDeclaration { - - const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter)); - const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter)); - let returnTypeNode: TypeNode | TypePredicate; + function signatureToSignatureDeclarationHelper(signature: Signature, kind: SyntaxKind, context: NodeBuilderContext): SignatureDeclaration { + const typeParameters = signature.typeParameters && signature.typeParameters.map(parameter => typeParameterToDeclaration(parameter, context)); + const parameters = signature.parameters.map(parameter => symbolToParameterDeclaration(parameter, context)); + if (signature.thisParameter) { + const thisParameter = symbolToParameterDeclaration(signature.thisParameter, context); + parameters.unshift(thisParameter); + } + let returnTypeNode: TypeNode; if (signature.typePredicate) { const typePredicate = signature.typePredicate; - const parameterName = typePredicate.kind === TypePredicateKind.Identifier ? createIdentifier((typePredicate).parameterName) : createThisTypeNode(); - const typeNode = typeToTypeNodeHelper(typePredicate.type); + const parameterName = typePredicate.kind === TypePredicateKind.Identifier ? + setEmitFlags(createIdentifier((typePredicate).parameterName), EmitFlags.NoAsciiEscaping) : + createThisTypeNode(); + const typeNode = typeToTypeNodeHelper(typePredicate.type, context); returnTypeNode = createTypePredicateNode(parameterName, typeNode); } else { const returnType = getReturnTypeOfSignature(signature); - returnTypeNode = returnType && typeToTypeNodeHelper(returnType); + returnTypeNode = returnType && typeToTypeNodeHelper(returnType, context); } - const returnTypeNodeExceptAny = returnTypeNode && returnTypeNode.kind !== SyntaxKind.AnyKeyword ? returnTypeNode : undefined; - - return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNodeExceptAny); + if (context.flags & NodeBuilderFlags.SuppressAnyReturnType) { + if (returnTypeNode && returnTypeNode.kind === SyntaxKind.AnyKeyword) { + returnTypeNode = undefined; + } + } + else if (!returnTypeNode) { + returnTypeNode = createKeywordTypeNode(SyntaxKind.AnyKeyword); + } + return createSignatureDeclaration(kind, typeParameters, parameters, returnTypeNode); } - function typeParameterToDeclaration(type: TypeParameter): TypeParameterDeclaration { + function typeParameterToDeclaration(type: TypeParameter, context: NodeBuilderContext): TypeParameterDeclaration { + const name = symbolToName(type.symbol, context, SymbolFlags.Type, /*expectsIdentifier*/ true); const constraint = getConstraintFromTypeParameter(type); - const constraintNode = constraint && typeToTypeNodeHelper(constraint); + const constraintNode = constraint && typeToTypeNodeHelper(constraint, context); const defaultParameter = getDefaultFromTypeParameter(type); - const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter); - const name = symbolToName(type.symbol, /*expectsIdentifier*/ true); + const defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context); return createTypeParameterDeclaration(name, constraintNode, defaultParameterNode); } - function symbolToParameterDeclaration(parameterSymbol: Symbol): ParameterDeclaration { - const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); - const parameterType = getTypeOfSymbol(parameterSymbol); - const parameterTypeNode = typeToTypeNodeHelper(parameterType); - // TODO(aozgaa): In the future, check initializer accessibility. + function symbolToParameterDeclaration(parameterSymbol: Symbol, context: NodeBuilderContext): ParameterDeclaration { + const parameterDeclaration = getDeclarationOfKind(parameterSymbol, SyntaxKind.Parameter); + const modifiers = parameterDeclaration.modifiers && parameterDeclaration.modifiers.map(getSynthesizedClone); + const dotDotDotToken = isRestParameter(parameterDeclaration) ? createToken(SyntaxKind.DotDotDotToken) : undefined; + const name = parameterDeclaration.name.kind === SyntaxKind.Identifier ? + setEmitFlags(getSynthesizedClone(parameterDeclaration.name), EmitFlags.NoAsciiEscaping) : + cloneBindingName(parameterDeclaration.name); + const questionToken = isOptionalParameter(parameterDeclaration) ? createToken(SyntaxKind.QuestionToken) : undefined; + + let parameterType = getTypeOfSymbol(parameterSymbol); + if (isRequiredInitializedParameter(parameterDeclaration)) { + parameterType = getNullableType(parameterType, TypeFlags.Undefined); + } + const parameterTypeNode = typeToTypeNodeHelper(parameterType, context); + const parameterNode = createParameter( - parameterDeclaration.decorators, - parameterDeclaration.modifiers, - parameterDeclaration.dotDotDotToken && createToken(SyntaxKind.DotDotDotToken), - // Clone name to remove trivia. - getSynthesizedClone(parameterDeclaration.name), - parameterDeclaration.questionToken && createToken(SyntaxKind.QuestionToken), + /*decorators*/ undefined, + modifiers, + dotDotDotToken, + name, + questionToken, parameterTypeNode, - parameterDeclaration.initializer); + /*initializer*/ undefined); return parameterNode; + + function cloneBindingName(node: BindingName): BindingName { + return elideInitializerAndSetEmitFlags(node); + function elideInitializerAndSetEmitFlags(node: Node): Node { + const visited = visitEachChild(node, elideInitializerAndSetEmitFlags, nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags); + const clone = nodeIsSynthesized(visited) ? visited : getSynthesizedClone(visited); + if (clone.kind === SyntaxKind.BindingElement) { + (clone).initializer = undefined; + } + return setEmitFlags(clone, EmitFlags.SingleLine | EmitFlags.NoAsciiEscaping); + } + } } - function symbolToName(symbol: Symbol, expectsIdentifier: true): Identifier; - function symbolToName(symbol: Symbol, expectsIdentifier: false): EntityName; - function symbolToName(symbol: Symbol, expectsIdentifier: boolean): EntityName { + function symbolToName(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, expectsIdentifier: true): Identifier; + function symbolToName(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, expectsIdentifier: false): EntityName; + function symbolToName(symbol: Symbol, context: NodeBuilderContext, meaning: SymbolFlags, expectsIdentifier: boolean): EntityName { // Try to get qualified name if the symbol is not a type parameter and there is an enclosing declaration. let chain: Symbol[]; const isTypeParameter = symbol.flags & SymbolFlags.TypeParameter; - if (!isTypeParameter && context.enclosingDeclaration) { - chain = getSymbolChain(symbol, SymbolFlags.None, /*endOfChain*/ true); + if (!isTypeParameter && (context.enclosingDeclaration || context.flags & NodeBuilderFlags.UseFullyQualifiedType)) { + chain = getSymbolChain(symbol, meaning, /*endOfChain*/ true); Debug.assert(chain && chain.length > 0); } else { @@ -2723,18 +2863,16 @@ namespace ts { if (expectsIdentifier && chain.length !== 1 && !context.encounteredError - && !(context.flags & NodeBuilderFlags.allowQualifedNameInPlaceOfIdentifier)) { + && !(context.flags & NodeBuilderFlags.AllowQualifedNameInPlaceOfIdentifier)) { context.encounteredError = true; } return createEntityNameFromSymbolChain(chain, chain.length - 1); function createEntityNameFromSymbolChain(chain: Symbol[], index: number): EntityName { Debug.assert(chain && 0 <= index && index < chain.length); - // const parentIndex = index - 1; const symbol = chain[index]; - let typeParameterString = ""; - if (index > 0) { - + let typeParameterNodes: TypeNode[] | undefined; + if (context.flags & NodeBuilderFlags.WriteTypeParametersInQualifiedName && index > 0) { const parentSymbol = chain[index - 1]; let typeParameters: TypeParameter[]; if (getCheckFlags(symbol) & CheckFlags.Instantiated) { @@ -2746,21 +2884,12 @@ namespace ts { typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol); } } - if (typeParameters && typeParameters.length > 0) { - if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowTypeParameterInQualifiedName)) { - context.encounteredError = true; - } - const writer = getSingleLineStringWriter(); - const displayBuilder = getSymbolDisplayBuilder(); - displayBuilder.buildDisplayForTypeParametersAndDelimiters(typeParameters, writer, context.enclosingDeclaration, 0); - typeParameterString = writer.string(); - releaseStringWriter(writer); - } + typeParameterNodes = mapToTypeNodes(typeParameters, context); } - const symbolName = getNameOfSymbol(symbol); - const symbolNameWithTypeParameters = typeParameterString.length > 0 ? `${symbolName}<${typeParameterString}>` : symbolName; - const identifier = createIdentifier(symbolNameWithTypeParameters); + + const symbolName = getNameOfSymbol(symbol, context); + const identifier = setEmitFlags(createIdentifier(symbolName, typeParameterNodes), EmitFlags.NoAsciiEscaping); return index > 0 ? createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier; } @@ -2798,29 +2927,30 @@ namespace ts { return [symbol]; } } + } - function getNameOfSymbol(symbol: Symbol): string { - const declaration = firstOrUndefined(symbol.declarations); - if (declaration) { - if (declaration.name) { - return declarationNameToString(declaration.name); - } - if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { - return declarationNameToString((declaration.parent).name); - } - if (!context.encounteredError && !(context.flags & NodeBuilderFlags.allowAnonymousIdentifier)) { - context.encounteredError = true; - } - switch (declaration.kind) { - case SyntaxKind.ClassExpression: - return "(Anonymous class)"; - case SyntaxKind.FunctionExpression: - case SyntaxKind.ArrowFunction: - return "(Anonymous function)"; - } + function getNameOfSymbol(symbol: Symbol, context: NodeBuilderContext): string { + const declaration = firstOrUndefined(symbol.declarations); + if (declaration) { + const name = getNameOfDeclaration(declaration); + if (name) { + return declarationNameToString(name); + } + if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { + return declarationNameToString((declaration.parent).name); + } + if (!context.encounteredError && !(context.flags & NodeBuilderFlags.AllowAnonymousIdentifier)) { + context.encounteredError = true; + } + switch (declaration.kind) { + case SyntaxKind.ClassExpression: + return "(Anonymous class)"; + case SyntaxKind.FunctionExpression: + case SyntaxKind.ArrowFunction: + return "(Anonymous function)"; } - return symbol.name; } + return symbol.name; } } @@ -2892,8 +3022,9 @@ namespace ts { function getNameOfSymbol(symbol: Symbol): string { if (symbol.declarations && symbol.declarations.length) { const declaration = symbol.declarations[0]; - if (declaration.name) { - return declarationNameToString(declaration.name); + const name = getNameOfDeclaration(declaration); + if (name) { + return declarationNameToString(name); } if (declaration.parent && declaration.parent.kind === SyntaxKind.VariableDeclaration) { return declarationNameToString((declaration.parent).name); @@ -3635,8 +3766,8 @@ namespace ts { case SyntaxKind.BindingElement: return isDeclarationVisible(node.parent.parent); case SyntaxKind.VariableDeclaration: - if (isBindingPattern(node.name) && - !(node.name).elements.length) { + if (isBindingPattern((node as VariableDeclaration).name) && + !((node as VariableDeclaration).name as BindingPattern).elements.length) { // If the binding pattern is empty, this variable declaration is not visible return false; } @@ -3721,10 +3852,7 @@ namespace ts { exportSymbol = resolveName(node.parent, node.text, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias, Diagnostics.Cannot_find_name_0, node); } else if (node.parent.kind === SyntaxKind.ExportSpecifier) { - const exportSpecifier = node.parent; - exportSymbol = (exportSpecifier.parent.parent).moduleSpecifier ? - getExternalModuleMember(exportSpecifier.parent.parent, exportSpecifier) : - resolveEntityName(exportSpecifier.propertyName || exportSpecifier.name, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); + exportSymbol = getTargetOfExportSpecifier(node.parent, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace | SymbolFlags.Alias); } const result: Node[] = []; if (exportSymbol) { @@ -4067,7 +4195,7 @@ namespace ts { const func = declaration.parent; // For a parameter of a set accessor, use the type of the get accessor if one is present if (func.kind === SyntaxKind.SetAccessor && !hasDynamicName(func)) { - const getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); + const getter = getDeclarationOfKind(declaration.parent.symbol, SyntaxKind.GetAccessor); if (getter) { const getterSignature = getSignatureFromDeclaration(getter); const thisParameter = getAccessorThisParameter(func as AccessorDeclaration); @@ -4122,6 +4250,7 @@ namespace ts { const types: Type[] = []; let definedInConstructor = false; let definedInMethod = false; + let jsDocType: Type; for (const declaration of symbol.declarations) { const expression = declaration.kind === SyntaxKind.BinaryExpression ? declaration : declaration.kind === SyntaxKind.PropertyAccessExpression ? getAncestor(declaration, SyntaxKind.BinaryExpression) : @@ -4140,19 +4269,26 @@ namespace ts { } } - if (expression.flags & NodeFlags.JavaScriptFile) { - // If there is a JSDoc type, use it - const type = getTypeForDeclarationFromJSDocComment(expression.parent); - if (type && type !== unknownType) { - types.push(getWidenedType(type)); - continue; + // If there is a JSDoc type, use it + const type = getTypeForDeclarationFromJSDocComment(expression.parent); + if (type) { + const declarationType = getWidenedType(type); + if (!jsDocType) { + jsDocType = declarationType; + } + else if (jsDocType !== unknownType && declarationType !== unknownType && !isTypeIdenticalTo(jsDocType, declarationType)) { + const name = getNameOfDeclaration(declaration); + error(name, Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2, declarationNameToString(name), typeToString(jsDocType), typeToString(declarationType)); } } - - types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); + else if (!jsDocType) { + // If we don't have an explicit JSDoc type, get the type from the expression. + types.push(getWidenedLiteralType(checkExpressionCached(expression.right))); + } } - return getWidenedType(addOptionality(getUnionType(types, /*subtypeReduction*/ true), definedInMethod && !definedInConstructor)); + const type = jsDocType || getUnionType(types, /*subtypeReduction*/ true); + return getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor)); } // Return the type implied by a binding pattern element. This is the type of the initializer of the element if @@ -4348,8 +4484,8 @@ namespace ts { function getTypeOfAccessors(symbol: Symbol): Type { const links = getSymbolLinks(symbol); if (!links.type) { - const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); - const setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); + const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); + const setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); if (getter && getter.flags & NodeFlags.JavaScriptFile) { const jsDocType = getTypeForDeclarationFromJSDocComment(getter); @@ -4398,7 +4534,7 @@ namespace ts { if (!popTypeResolution()) { type = anyType; if (noImplicitAny) { - const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); + const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); error(getter, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, symbolToString(symbol)); } } @@ -4717,7 +4853,7 @@ namespace ts { // When base constructor type is a class with no captured type arguments we know that the constructors all have the same type parameters as the // class and all return the instance type of the class. There is no need for further checks and we can apply the // type arguments in the same manner as a type reference to get the same error reporting experience. - baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol); + baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol, typeArgumentsFromTypeReferenceNode(baseTypeNode)); } else if (baseConstructorType.flags & TypeFlags.Any) { baseType = baseConstructorType; @@ -4875,7 +5011,7 @@ namespace ts { return unknownType; } - let declaration: JSDocTypedefTag | TypeAliasDeclaration = getDeclarationOfKind(symbol, SyntaxKind.JSDocTypedefTag); + let declaration: JSDocTypedefTag | TypeAliasDeclaration = getDeclarationOfKind(symbol, SyntaxKind.JSDocTypedefTag); let type: Type; if (declaration) { if (declaration.jsDocTypeLiteral) { @@ -4886,7 +5022,7 @@ namespace ts { } } else { - declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); + declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeAliasDeclaration); type = getTypeFromTypeNode(declaration.type); } @@ -5244,7 +5380,7 @@ namespace ts { } const baseTypeNode = getBaseTypeNodeOfClass(classType); const isJavaScript = isInJavaScriptFile(baseTypeNode); - const typeArguments = map(baseTypeNode.typeArguments, getTypeFromTypeNode); + const typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode); const typeArgCount = length(typeArguments); const result: Signature[] = []; for (const baseSig of baseSignatures) { @@ -5654,6 +5790,22 @@ namespace ts { getPropertiesOfObjectType(type); } + function getAllPossiblePropertiesOfType(type: Type): Symbol[] { + if (type.flags & TypeFlags.Union) { + const props = createMap(); + for (const memberType of (type as UnionType).types) { + for (const { name } of getPropertiesOfType(memberType)) { + if (!props.has(name)) { + props.set(name, createUnionOrIntersectionProperty(type as UnionType, name)); + } + } + } + return arrayFrom(props.values()); + } else { + return getPropertiesOfType(type); + } + } + function getConstraintOfType(type: TypeVariable | UnionOrIntersectionType): Type { return type.flags & TypeFlags.TypeParameter ? getConstraintOfTypeParameter(type) : type.flags & TypeFlags.IndexedAccess ? getConstraintOfIndexedAccess(type) : @@ -5781,11 +5933,11 @@ namespace ts { const t = type.flags & TypeFlags.TypeVariable ? getBaseConstraintOfType(type) || emptyObjectType : type; return t.flags & TypeFlags.Intersection ? getApparentTypeOfIntersectionType(t) : t.flags & TypeFlags.StringLike ? globalStringType : - t.flags & TypeFlags.NumberLike ? globalNumberType : - t.flags & TypeFlags.BooleanLike ? globalBooleanType : - t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : - t.flags & TypeFlags.NonPrimitive ? emptyObjectType : - t; + t.flags & TypeFlags.NumberLike ? globalNumberType : + t.flags & TypeFlags.BooleanLike ? globalBooleanType : + t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType(/*reportErrors*/ languageVersion >= ScriptTarget.ES2015) : + t.flags & TypeFlags.NonPrimitive ? emptyObjectType : + t; } function createUnionOrIntersectionProperty(containingType: UnionOrIntersectionType, name: string): Symbol { @@ -6166,7 +6318,7 @@ namespace ts { !hasDynamicName(declaration) && (!hasThisParameter || !thisParameter)) { const otherKind = declaration.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const other = getDeclarationOfKind(declaration.symbol, otherKind); + const other = getDeclarationOfKind(declaration.symbol, otherKind); if (other) { thisParameter = getAnnotatedAccessorThisParameter(other); } @@ -6209,7 +6361,7 @@ namespace ts { // TypeScript 1.0 spec (April 2014): // If only one accessor includes a type annotation, the other behaves as if it had the same type annotation. if (declaration.kind === SyntaxKind.GetAccessor && !hasDynamicName(declaration)) { - const setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); + const setter = getDeclarationOfKind(declaration.symbol, SyntaxKind.SetAccessor); return getAnnotatedAccessorType(setter); } @@ -6240,8 +6392,8 @@ namespace ts { case SyntaxKind.MethodDeclaration: case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: - return (node).name.kind === SyntaxKind.ComputedPropertyName - && traverse((node).name); + return (node).name.kind === SyntaxKind.ComputedPropertyName + && traverse((node).name); default: return !nodeStartsNewLexicalEnvironment(node) && !isPartOfTypeNode(node) && forEachChild(node, traverse); @@ -6321,8 +6473,9 @@ namespace ts { type = anyType; if (noImplicitAny) { const declaration = signature.declaration; - if (declaration.name) { - error(declaration.name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(declaration.name)); + const name = getNameOfDeclaration(declaration); + if (name) { + error(name, Diagnostics._0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions, declarationNameToString(name)); } else { error(declaration, Diagnostics.Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions); @@ -6421,7 +6574,7 @@ namespace ts { } function getConstraintDeclaration(type: TypeParameter) { - return (getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter)).constraint; + return getDeclarationOfKind(type.symbol, SyntaxKind.TypeParameter).constraint; } function getConstraintFromTypeParameter(typeParameter: TypeParameter): Type { @@ -6507,7 +6660,7 @@ namespace ts { } // Get type from reference to class or interface - function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { + function getTypeFromClassOrInterfaceReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol, typeArgs: Type[]): Type { const type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol)); const typeParameters = type.localTypeParameters; if (typeParameters) { @@ -6526,7 +6679,7 @@ namespace ts { // In a type reference, the outer type parameters of the referenced class or interface are automatically // supplied as type arguments and the type reference only specifies arguments for the local type parameters // of the class or interface. - const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(map(node.typeArguments, getTypeFromTypeNode), typeParameters, minTypeArgumentCount, node)); + const typeArguments = concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgs, typeParameters, minTypeArgumentCount, node)); return createTypeReference(type, typeArguments); } if (node.typeArguments) { @@ -6551,7 +6704,7 @@ namespace ts { // Get type from reference to type alias. When a type alias is generic, the declared type of the type alias may include // references to the type parameters of the alias. We replace those with the actual type arguments by instantiating the // declared type. Instantiations are cached using the type identities of the type arguments as the key. - function getTypeFromTypeAliasReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol): Type { + function getTypeFromTypeAliasReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol, typeArguments: Type[]): Type { const type = getDeclaredTypeOfSymbol(symbol); const typeParameters = getSymbolLinks(symbol).typeParameters; if (typeParameters) { @@ -6567,7 +6720,6 @@ namespace ts { typeParameters.length); return unknownType; } - const typeArguments = map(node.typeArguments, getTypeFromTypeNode); return getTypeAliasInstantiation(symbol, typeArguments); } if (node.typeArguments) { @@ -6615,16 +6767,18 @@ namespace ts { } function getTypeReferenceType(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference, symbol: Symbol) { + const typeArguments = typeArgumentsFromTypeReferenceNode(node); // Do unconditionally so we mark type arguments as referenced. + if (symbol === unknownSymbol) { return unknownType; } if (symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface)) { - return getTypeFromClassOrInterfaceReference(node, symbol); + return getTypeFromClassOrInterfaceReference(node, symbol, typeArguments); } if (symbol.flags & SymbolFlags.TypeAlias) { - return getTypeFromTypeAliasReference(node, symbol); + return getTypeFromTypeAliasReference(node, symbol, typeArguments); } if (symbol.flags & SymbolFlags.Value && node.kind === SyntaxKind.JSDocTypeReference) { @@ -6692,10 +6846,7 @@ namespace ts { ? (node).expression : undefined; symbol = typeNameOrExpression && resolveEntityName(typeNameOrExpression, SymbolFlags.Type) || unknownSymbol; - type = symbol === unknownSymbol ? unknownType : - symbol.flags & (SymbolFlags.Class | SymbolFlags.Interface) ? getTypeFromClassOrInterfaceReference(node, symbol) : - symbol.flags & SymbolFlags.TypeAlias ? getTypeFromTypeAliasReference(node, symbol) : - getTypeFromNonGenericTypeReference(node, symbol); + type = getTypeReferenceType(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. @@ -6705,6 +6856,10 @@ namespace ts { return links.resolvedType; } + function typeArgumentsFromTypeReferenceNode(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type[] { + return map(node.typeArguments, getTypeFromTypeNode); + } + function getTypeFromTypeQueryNode(node: TypeQueryNode): Type { const links = getNodeLinks(node); if (!links.resolvedType) { @@ -7260,7 +7415,7 @@ namespace ts { accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, /*reportError*/ false) ? getPropertyNameForKnownSymbolName(((accessExpression.argumentExpression).name).text) : undefined; - if (propName) { + if (propName !== undefined) { const prop = getPropertyOfType(objectType, propName); if (prop) { if (accessExpression) { @@ -8705,29 +8860,6 @@ namespace ts { return Ternary.False; } - // Check if a property with the given name is known anywhere in the given type. In an object type, a property - // is considered known if the object type is empty and the check is for assignability, if the object type has - // index signatures, or if the property is actually declared in the object type. In a union or intersection - // type, a property is considered known if it is known in any constituent type. - function isKnownProperty(type: Type, name: string, isComparingJsxAttributes: boolean): boolean { - if (type.flags & TypeFlags.Object) { - const resolved = resolveStructuredTypeMembers(type); - if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || - getPropertyOfType(type, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { - // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. - return true; - } - } - else if (type.flags & TypeFlags.UnionOrIntersection) { - for (const t of (type).types) { - if (isKnownProperty(t, name, isComparingJsxAttributes)) { - return true; - } - } - } - return false; - } - function hasExcessProperties(source: FreshObjectLiteralType, target: Type, reportErrors: boolean): boolean { if (maybeTypeOfKind(target, TypeFlags.Object) && !(getObjectFlags(target) & ObjectFlags.ObjectLiteralPatternWithComputedProperties)) { const isComparingJsxAttributes = !!(source.flags & TypeFlags.JsxAttributes); @@ -9242,25 +9374,39 @@ namespace ts { let result = Ternary.True; const saveErrorInfo = errorInfo; - outer: for (const t of targetSignatures) { - // Only elaborate errors from the first failure - let shouldElaborateErrors = reportErrors; - for (const s of sourceSignatures) { - const related = signatureRelatedTo(s, t, shouldElaborateErrors); - if (related) { - result &= related; - errorInfo = saveErrorInfo; - continue outer; + if (getObjectFlags(source) & ObjectFlags.Instantiated && getObjectFlags(target) & ObjectFlags.Instantiated && source.symbol === target.symbol) { + // We instantiations of the same anonymous type (which typically will be the type of a method). + // Simply do a pairwise comparison of the signatures in the two signature lists instead of the + // much more expensive N * M comparison matrix we explore below. + for (let i = 0; i < targetSignatures.length; i++) { + const related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], reportErrors); + if (!related) { + return Ternary.False; } - shouldElaborateErrors = false; + result &= related; } + } + else { + outer: for (const t of targetSignatures) { + // Only elaborate errors from the first failure + let shouldElaborateErrors = reportErrors; + for (const s of sourceSignatures) { + const related = signatureRelatedTo(s, t, shouldElaborateErrors); + if (related) { + result &= related; + errorInfo = saveErrorInfo; + continue outer; + } + shouldElaborateErrors = false; + } - if (shouldElaborateErrors) { - reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1, - typeToString(source), - signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); + if (shouldElaborateErrors) { + reportError(Diagnostics.Type_0_provides_no_match_for_the_signature_1, + typeToString(source), + signatureToString(t, /*enclosingDeclaration*/ undefined, /*flags*/ undefined, kind)); + } + return Ternary.False; } - return Ternary.False; } return result; } @@ -9931,7 +10077,7 @@ namespace ts { case SyntaxKind.SetAccessor: case SyntaxKind.FunctionExpression: case SyntaxKind.ArrowFunction: - if (!declaration.name) { + if (!(declaration as NamedDeclaration).name) { error(declaration, Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString); return; } @@ -9940,7 +10086,7 @@ namespace ts { default: diagnostic = Diagnostics.Variable_0_implicitly_has_an_1_type; } - error(declaration, diagnostic, declarationNameToString(declaration.name), typeAsString); + error(declaration, diagnostic, declarationNameToString(getNameOfDeclaration(declaration)), typeAsString); } function reportErrorsFromWidening(declaration: Declaration, type: Type) { @@ -10033,7 +10179,7 @@ namespace ts { const templateType = getTemplateTypeFromMappedType(target); const readonlyMask = target.declaration.readonlyToken ? false : true; const optionalMask = target.declaration.questionToken ? 0 : SymbolFlags.Optional; - const members = createSymbolTable(properties); + const members = createMap(); for (const prop of properties) { const inferredPropType = inferTargetType(getTypeOfSymbol(prop)); if (!inferredPropType) { @@ -10068,22 +10214,11 @@ namespace ts { } function inferTypes(typeVariables: TypeVariable[], typeInferences: TypeInferences[], originalSource: Type, originalTarget: Type) { - let sourceStack: Type[]; - let targetStack: Type[]; - let depth = 0; + let symbolStack: Symbol[]; + let visited: Map; let inferiority = 0; - const visited = createMap(); inferFromTypes(originalSource, originalTarget); - function isInProcess(source: Type, target: Type) { - for (let i = 0; i < depth; i++) { - if (source === sourceStack[i] && target === targetStack[i]) { - return true; - } - } - return false; - } - function inferFromTypes(source: Type, target: Type) { if (!couldContainTypeVariables(target)) { return; @@ -10211,26 +10346,29 @@ namespace ts { else { source = getApparentType(source); if (source.flags & TypeFlags.Object) { - if (isInProcess(source, target)) { - return; - } - if (isDeeplyNestedType(source, sourceStack, depth) && isDeeplyNestedType(target, targetStack, depth)) { - return; - } const key = source.id + "," + target.id; - if (visited.get(key)) { + if (visited && visited.get(key)) { return; } - visited.set(key, true); - if (depth === 0) { - sourceStack = []; - targetStack = []; + (visited || (visited = createMap())).set(key, true); + // If we are already processing another target type with the same associated symbol (such as + // an instantiation of the same generic type), we do not explore this target as it would yield + // no further inferences. We exclude the static side of classes from this check since it shares + // its symbol with the instance side which would lead to false positives. + const isNonConstructorObject = target.flags & TypeFlags.Object && + !(getObjectFlags(target) & ObjectFlags.Anonymous && target.symbol && target.symbol.flags & SymbolFlags.Class); + const symbol = isNonConstructorObject ? target.symbol : undefined; + if (symbol) { + if (contains(symbolStack, symbol)) { + return; + } + (symbolStack || (symbolStack = [])).push(symbol); + inferFromObjectTypes(source, target); + symbolStack.pop(); + } + else { + inferFromObjectTypes(source, target); } - sourceStack[depth] = source; - targetStack[depth] = target; - depth++; - inferFromObjectTypes(source, target); - depth--; } } } @@ -10433,7 +10571,7 @@ namespace ts { function getResolvedSymbol(node: Identifier): Symbol { const links = getNodeLinks(node); if (!links.resolvedSymbol) { - links.resolvedSymbol = !nodeIsMissing(node) && resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, node) || unknownSymbol; + links.resolvedSymbol = !nodeIsMissing(node) && resolveName(node, node.text, SymbolFlags.Value | SymbolFlags.ExportValue, Diagnostics.Cannot_find_name_0, node, Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol; } return links.resolvedSymbol; } @@ -10450,11 +10588,13 @@ namespace ts { // Return the flow cache key for a "dotted name" (i.e. a sequence of identifiers // separated by dots). The key consists of the id of the symbol referenced by the // leftmost identifier followed by zero or more property names separated by dots. - // The result is undefined if the reference isn't a dotted name. + // The result is undefined if the reference isn't a dotted name. We prefix nodes + // occurring in an apparent type position with '@' because the control flow type + // of such nodes may be based on the apparent type instead of the declared type. function getFlowCacheKey(node: Node): string { if (node.kind === SyntaxKind.Identifier) { const symbol = getResolvedSymbol(node); - return symbol !== unknownSymbol ? "" + getSymbolId(symbol) : undefined; + return symbol !== unknownSymbol ? (isApparentTypePosition(node) ? "@" : "") + getSymbolId(symbol) : undefined; } if (node.kind === SyntaxKind.ThisKeyword) { return "0"; @@ -11720,6 +11860,29 @@ namespace ts { return annotationIncludesUndefined ? getTypeWithFacts(declaredType, TypeFacts.NEUndefined) : declaredType; } + function isApparentTypePosition(node: Node) { + const parent = node.parent; + return parent.kind === SyntaxKind.PropertyAccessExpression || + parent.kind === SyntaxKind.CallExpression && (parent).expression === node || + parent.kind === SyntaxKind.ElementAccessExpression && (parent).expression === node; + } + + function typeHasNullableConstraint(type: Type) { + return type.flags & TypeFlags.TypeVariable && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, TypeFlags.Nullable); + } + + function getDeclaredOrApparentType(symbol: Symbol, node: Node) { + // When a node is the left hand expression of a property access, element access, or call expression, + // and the type of the node includes type variables with constraints that are nullable, we fetch the + // apparent type of the node *before* performing control flow analysis such that narrowings apply to + // the constraint type. + const type = getTypeOfSymbol(symbol); + if (isApparentTypePosition(node) && forEachType(type, typeHasNullableConstraint)) { + return mapType(getWidenedType(type), getApparentType); + } + return type; + } + function checkIdentifier(node: Identifier): Type { const symbol = getResolvedSymbol(node); if (symbol === unknownSymbol) { @@ -11795,7 +11958,7 @@ namespace ts { checkCollisionWithCapturedNewTargetVariable(node, node); checkNestedBlockScopedBinding(node, symbol); - const type = getTypeOfSymbol(localOrExportSymbol); + const type = getDeclaredOrApparentType(localOrExportSymbol, node); const declaration = localOrExportSymbol.valueDeclaration; const assignmentKind = getAssignmentTargetKind(node); @@ -11846,7 +12009,7 @@ namespace ts { if (type === autoType || type === autoArrayType) { if (flowType === autoType || flowType === autoArrayType) { if (noImplicitAny) { - error(declaration.name, Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); + error(getNameOfDeclaration(declaration), Diagnostics.Variable_0_implicitly_has_type_1_in_some_locations_where_its_type_cannot_be_determined, symbolToString(symbol), typeToString(flowType)); error(node, Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType)); } return convertAutoToAny(flowType); @@ -12514,7 +12677,7 @@ namespace ts { // corresponding set accessor has a type annotation, return statements in the function are contextually typed if (functionDecl.type || functionDecl.kind === SyntaxKind.Constructor || - functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) { + functionDecl.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(functionDecl.symbol, SyntaxKind.SetAccessor))) { return getReturnTypeOfSignature(getSignatureFromDeclaration(functionDecl)); } @@ -12723,7 +12886,7 @@ namespace ts { * @param node the expression whose contextual type will be returned. * @returns the contextual type of an expression. */ - function getContextualType(node: Expression): Type { + function getContextualType(node: Expression): Type | undefined { if (isInsideWithStatementBody(node)) { // We cannot answer semantic questions within a with block, do not proceed any further return undefined; @@ -13197,7 +13360,7 @@ namespace ts { } return result; } - } + } function isValidSpreadType(type: Type): boolean { return !!(type.flags & (TypeFlags.Any | TypeFlags.Null | TypeFlags.Undefined | TypeFlags.NonPrimitive) || @@ -13260,6 +13423,11 @@ namespace ts { let attributesTable = createMap(); let spread: Type = emptyObjectType; let attributesArray: Symbol[] = []; + let hasSpreadAnyType = false; + let typeToIntersect: Type; + let explicitlySpecifyChildrenAttribute = false; + const jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); + for (const attributeDecl of attributes.properties) { const member = attributeDecl.symbol; if (isJsxAttribute(attributeDecl)) { @@ -13277,6 +13445,9 @@ namespace ts { attributeSymbol.target = member; attributesTable.set(attributeSymbol.name, attributeSymbol); attributesArray.push(attributeSymbol); + if (attributeDecl.name.text === jsxChildrenPropertyName) { + explicitlySpecifyChildrenAttribute = true; + } } else { Debug.assert(attributeDecl.kind === SyntaxKind.JsxSpreadAttribute); @@ -13286,33 +13457,32 @@ namespace ts { attributesTable = createMap(); } const exprType = checkExpression(attributeDecl.expression); - if (!isValidSpreadType(exprType)) { - error(attributeDecl, Diagnostics.Spread_types_may_only_be_created_from_object_types); - return anyType; - } if (isTypeAny(exprType)) { - return anyType; + hasSpreadAnyType = true; + } + if (isValidSpreadType(exprType)) { + spread = getSpreadType(spread, exprType); + } + else { + typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType; } - spread = getSpreadType(spread, exprType); } } - if (spread !== emptyObjectType) { - if (attributesArray.length > 0) { - spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); - attributesArray = []; - attributesTable = createMap(); + if (!hasSpreadAnyType) { + if (spread !== emptyObjectType) { + if (attributesArray.length > 0) { + spread = getSpreadType(spread, createJsxAttributesType(attributes.symbol, attributesTable)); + } + attributesArray = getPropertiesOfType(spread); } - attributesArray = getPropertiesOfType(spread); - } - attributesTable = createMap(); - if (attributesArray) { - forEach(attributesArray, (attr) => { + attributesTable = createMap(); + for (const attr of attributesArray) { if (!filter || filter(attr)) { attributesTable.set(attr.name, attr); } - }); + } } // Handle children attribute @@ -13333,11 +13503,11 @@ namespace ts { } } - // Error if there is a attribute named "children" and children element. - // This is because children element will overwrite the value from attributes - const jsxChildrenPropertyName = getJsxElementChildrenPropertyname(); - if (jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { - if (attributesTable.has(jsxChildrenPropertyName)) { + if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") { + // Error if there is a attribute named "children" explicitly specified and children element. + // This is because children element will overwrite the value from attributes. + // Note: we will not warn "children" attribute overwritten if "children" attribute is specified in object spread. + if (explicitlySpecifyChildrenAttribute) { error(attributes, Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, jsxChildrenPropertyName); } @@ -13350,7 +13520,13 @@ namespace ts { } } - return createJsxAttributesType(attributes.symbol, attributesTable); + if (hasSpreadAnyType) { + return anyType; + } + + const attributeType = createJsxAttributesType(attributes.symbol, attributesTable); + return typeToIntersect && attributesTable.size ? getIntersectionType([typeToIntersect, attributeType]) : + typeToIntersect ? typeToIntersect : attributeType; /** * Create anonymous type from given attributes symbol table. @@ -13359,8 +13535,7 @@ namespace ts { */ function createJsxAttributesType(symbol: Symbol, attributesTable: Map) { const result = createAnonymousType(symbol, attributesTable, emptyArray, emptyArray, /*stringIndexInfo*/ undefined, /*numberIndexInfo*/ undefined); - const freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : TypeFlags.FreshLiteral; - result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral | freshObjectLiteralFlag; + result.flags |= TypeFlags.JsxAttributes | TypeFlags.ContainsObjectLiteral; result.objectFlags |= ObjectFlags.ObjectLiteral; return result; } @@ -13446,7 +13621,18 @@ namespace ts { } } - return getUnionType(map(signatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); + const instantiatedSignatures = []; + for (const signature of signatures) { + if (signature.typeParameters) { + const typeArguments = fillMissingTypeArguments(/*typeArguments*/ undefined, signature.typeParameters, /*minTypeArgumentCount*/ 0); + instantiatedSignatures.push(getSignatureInstantiation(signature, typeArguments)); + } + else { + instantiatedSignatures.push(signature); + } + } + + return getUnionType(map(instantiatedSignatures, getReturnTypeOfSignature), /*subtypeReduction*/ true); } /** @@ -13506,6 +13692,20 @@ namespace ts { return _jsxElementChildrenPropertyName; } + function getApparentTypeOfJsxPropsType(propsType: Type): Type { + if (!propsType) { + return undefined; + } + if (propsType.flags & TypeFlags.Intersection) { + const propsApparentType: Type[] = []; + for (const t of (propsType).types) { + propsApparentType.push(getApparentType(t)); + } + return getIntersectionType(propsApparentType); + } + return getApparentType(propsType); + } + /** * Get JSX attributes type by trying to resolve openingLikeElement as a stateless function component. * Return only attributes type of successfully resolved call signature. @@ -13526,6 +13726,7 @@ namespace ts { if (callSignature !== unknownSignature) { const callReturnType = callSignature && getReturnTypeOfSignature(callSignature); let paramType = callReturnType && (callSignature.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(callSignature.parameters[0])); + paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { // Intersect in JSX.IntrinsicAttributes if it exists const intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes); @@ -13563,7 +13764,8 @@ namespace ts { let allMatchingAttributesType: Type; for (const candidate of candidatesOutArray) { const callReturnType = getReturnTypeOfSignature(candidate); - const paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + let paramType = callReturnType && (candidate.parameters.length === 0 ? emptyObjectType : getTypeOfSymbol(candidate.parameters[0])); + paramType = getApparentTypeOfJsxPropsType(paramType); if (callReturnType && isTypeAssignableTo(callReturnType, jsxStatelessElementType)) { let shouldBeCandidate = true; for (const attribute of openingLikeElement.attributes.properties) { @@ -13868,6 +14070,34 @@ namespace ts { checkJsxAttributesAssignableToTagNameAttributes(node); } + /** + * Check if a property with the given name is known anywhere in the given type. In an object type, a property + * is considered known if the object type is empty and the check is for assignability, if the object type has + * index signatures, or if the property is actually declared in the object type. In a union or intersection + * type, a property is considered known if it is known in any constituent type. + * @param targetType a type to search a given name in + * @param name a property name to search + * @param isComparingJsxAttributes a boolean flag indicating whether we are searching in JsxAttributesType + */ + function isKnownProperty(targetType: Type, name: string, isComparingJsxAttributes: boolean): boolean { + if (targetType.flags & TypeFlags.Object) { + const resolved = resolveStructuredTypeMembers(targetType); + if (resolved.stringIndexInfo || resolved.numberIndexInfo && isNumericLiteralName(name) || + getPropertyOfType(targetType, name) || isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) { + // For JSXAttributes, if the attribute has a hyphenated name, consider that the attribute to be known. + return true; + } + } + else if (targetType.flags & TypeFlags.UnionOrIntersection) { + for (const t of (targetType).types) { + if (isKnownProperty(t, name, isComparingJsxAttributes)) { + return true; + } + } + } + return false; + } + /** * Check whether the given attributes of JSX opening-like element is assignable to the tagName attributes. * Get the attributes type of the opening-like element through resolving the tagName, "target attributes" @@ -13900,7 +14130,19 @@ namespace ts { error(openingLikeElement, Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, getJsxElementPropertiesName()); } else { - checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); + // Check if sourceAttributesType assignable to targetAttributesType though this check will allow excess properties + const isSourceAttributeTypeAssignableToTarget = checkTypeAssignableTo(sourceAttributesType, targetAttributesType, openingLikeElement.attributes.properties.length > 0 ? openingLikeElement.attributes : openingLikeElement); + // After we check for assignability, we will do another pass to check that all explicitly specified attributes have correct name corresponding in targetAttributeType. + // This will allow excess properties in spread type as it is very common pattern to spread outter attributes into React component in its render method. + if (isSourceAttributeTypeAssignableToTarget && !isTypeAny(sourceAttributesType) && !isTypeAny(targetAttributesType)) { + for (const attribute of openingLikeElement.attributes.properties) { + if (isJsxAttribute(attribute) && !isKnownProperty(targetAttributesType, attribute.name.text, /*isComparingJsxAttributes*/ true)) { + error(attribute, Diagnostics.Property_0_does_not_exist_on_type_1, attribute.name.text, typeToString(targetAttributesType)); + // We break here so that errors won't be cascading + break; + } + } + } } } @@ -13923,25 +14165,6 @@ namespace ts { return s.valueDeclaration ? s.valueDeclaration.kind : SyntaxKind.PropertyDeclaration; } - function getDeclarationModifierFlagsFromSymbol(s: Symbol): ModifierFlags { - if (s.valueDeclaration) { - const flags = getCombinedModifierFlags(s.valueDeclaration); - return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier; - } - if (getCheckFlags(s) & CheckFlags.Synthetic) { - const checkFlags = (s).checkFlags; - const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private : - checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public : - ModifierFlags.Protected; - const staticModifier = checkFlags & CheckFlags.ContainsStatic ? ModifierFlags.Static : 0; - return accessModifier | staticModifier; - } - if (s.flags & SymbolFlags.Prototype) { - return ModifierFlags.Public | ModifierFlags.Static; - } - return 0; - } - function getDeclarationNodeFlagsFromSymbol(s: Symbol): NodeFlags { return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0; } @@ -14074,44 +14297,6 @@ namespace ts { return checkPropertyAccessExpressionOrQualifiedName(node, node.left, node.right); } - function reportNonexistentProperty(propNode: Identifier, containingType: Type) { - let errorInfo: DiagnosticMessageChain; - if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) { - for (const subtype of (containingType as UnionType).types) { - if (!getPropertyOfType(subtype, propNode.text)) { - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(subtype)); - break; - } - } - } - errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType)); - diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); - } - - function markPropertyAsReferenced(prop: Symbol) { - if (prop && - noUnusedIdentifiers && - (prop.flags & SymbolFlags.ClassMember) && - prop.valueDeclaration && (getModifierFlags(prop.valueDeclaration) & ModifierFlags.Private)) { - if (getCheckFlags(prop) & CheckFlags.Instantiated) { - getSymbolLinks(prop).target.isReferenced = true; - } - else { - prop.isReferenced = true; - } - } - } - - function isInPropertyInitializer(node: Node): boolean { - while (node) { - if (node.parent && node.parent.kind === SyntaxKind.PropertyDeclaration && (node.parent as PropertyDeclaration).initializer === node) { - return true; - } - node = node.parent; - } - return false; - } - function checkPropertyAccessExpressionOrQualifiedName(node: PropertyAccessExpression | QualifiedName, left: Expression | QualifiedName, right: Identifier) { const type = checkNonNullExpression(left); if (isTypeAny(type) || type === silentNeverType) { @@ -14153,7 +14338,7 @@ namespace ts { checkPropertyAccessibility(node, left, apparentType, prop); - const propType = getTypeOfSymbol(prop); + const propType = getDeclaredOrApparentType(prop, node); const assignmentKind = getAssignmentTargetKind(node); if (assignmentKind) { @@ -14175,6 +14360,130 @@ namespace ts { return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType; } + function reportNonexistentProperty(propNode: Identifier, containingType: Type) { + let errorInfo: DiagnosticMessageChain; + if (containingType.flags & TypeFlags.Union && !(containingType.flags & TypeFlags.Primitive)) { + for (const subtype of (containingType as UnionType).types) { + if (!getPropertyOfType(subtype, propNode.text)) { + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(subtype)); + break; + } + } + } + const suggestion = getSuggestionForNonexistentProperty(propNode, containingType); + if (suggestion) { + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, declarationNameToString(propNode), typeToString(containingType), suggestion); + } + else { + errorInfo = chainDiagnosticMessages(errorInfo, Diagnostics.Property_0_does_not_exist_on_type_1, declarationNameToString(propNode), typeToString(containingType)); + } + diagnostics.add(createDiagnosticForNodeFromMessageChain(propNode, errorInfo)); + } + + function getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined { + const suggestion = getSpellingSuggestionForName(node.text, getPropertiesOfObjectType(containingType), SymbolFlags.Value); + return suggestion && suggestion.name; + } + + function getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string { + const result = resolveNameHelper(location, name, meaning, /*nameNotFoundMessage*/ undefined, name, (symbols, name, meaning) => { + const symbol = getSymbol(symbols, name, meaning); + if (symbol) { + // Sometimes the symbol is found when location is a return type of a function: `typeof x` and `x` is declared in the body of the function + // So the table *contains* `x` but `x` isn't actually in scope. + // However, resolveNameHelper will continue and call this callback again, so we'll eventually get a correct suggestion. + return symbol; + } + return getSpellingSuggestionForName(name, arrayFrom(symbols.values()), meaning); + }); + if (result) { + return result.name; + } + } + + /** + * Given a name and a list of symbols whose names are *not* equal to the name, return a spelling suggestion if there is one that is close enough. + * Names less than length 3 only check for case-insensitive equality, not levenshtein distance. + * + * If there is a candidate that's the same except for case, return that. + * If there is a candidate that's within one edit of the name, return that. + * Otherwise, return the candidate with the smallest Levenshtein distance, + * except for candidates: + * * With no name + * * Whose meaning doesn't match the `meaning` parameter. + * * Whose length differs from the target name by more than 0.3 of the length of the name. + * * Whose levenshtein distance is more than 0.4 of the length of the name + * (0.4 allows 1 substitution/transposition for every 5 characters, + * and 1 insertion/deletion at 3 characters) + * Names longer than 30 characters don't get suggestions because Levenshtein distance is an n**2 algorithm. + */ + function getSpellingSuggestionForName(name: string, symbols: Symbol[], meaning: SymbolFlags): Symbol | undefined { + const worstDistance = name.length * 0.4; + const maximumLengthDifference = Math.min(3, name.length * 0.34); + let bestDistance = Number.MAX_VALUE; + let bestCandidate = undefined; + if (name.length > 30) { + return undefined; + } + name = name.toLowerCase(); + for (const candidate of symbols) { + if (candidate.flags & meaning && + candidate.name && + Math.abs(candidate.name.length - name.length) < maximumLengthDifference) { + const candidateName = candidate.name.toLowerCase(); + if (candidateName === name) { + return candidate; + } + if (candidateName.length < 3 || + name.length < 3 || + candidateName === "eval" || + candidateName === "intl" || + candidateName === "undefined" || + candidateName === "map" || + candidateName === "nan" || + candidateName === "set") { + continue; + } + const distance = levenshtein(name, candidateName); + if (distance > worstDistance) { + continue; + } + if (distance < 3) { + return candidate; + } + else if (distance < bestDistance) { + bestDistance = distance; + bestCandidate = candidate; + } + } + } + return bestCandidate; + } + + function markPropertyAsReferenced(prop: Symbol) { + if (prop && + noUnusedIdentifiers && + (prop.flags & SymbolFlags.ClassMember) && + prop.valueDeclaration && (getModifierFlags(prop.valueDeclaration) & ModifierFlags.Private)) { + if (getCheckFlags(prop) & CheckFlags.Instantiated) { + getSymbolLinks(prop).target.isReferenced = true; + } + else { + prop.isReferenced = true; + } + } + } + + function isInPropertyInitializer(node: Node): boolean { + while (node) { + if (node.parent && node.parent.kind === SyntaxKind.PropertyDeclaration && (node.parent as PropertyDeclaration).initializer === node) { + return true; + } + node = node.parent; + } + return false; + } + function isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean { const left = node.kind === SyntaxKind.PropertyAccessExpression ? (node).expression @@ -14315,7 +14624,18 @@ namespace ts { return true; } + function callLikeExpressionMayHaveTypeArguments(node: CallLikeExpression): node is CallExpression | NewExpression { + // TODO: Also include tagged templates (https://github.com/Microsoft/TypeScript/issues/11947) + return isCallOrNewExpression(node); + } + function resolveUntypedCall(node: CallLikeExpression): Signature { + if (callLikeExpressionMayHaveTypeArguments(node)) { + // Check type arguments even though we will give an error that untyped calls may not accept type arguments. + // This gets us diagnostics for the type arguments and marks them as referenced. + forEach(node.typeArguments, checkSourceElement); + } + if (node.kind === SyntaxKind.TaggedTemplateExpression) { checkExpression((node).template); } @@ -14469,7 +14789,7 @@ namespace ts { // If spread arguments are present, check that they correspond to a rest parameter. If so, no // further checking is necessary. if (spreadArgIndex >= 0) { - return isRestParameterIndex(signature, spreadArgIndex); + return isRestParameterIndex(signature, spreadArgIndex) || spreadArgIndex >= signature.minArgumentCount; } // Too many arguments implies incorrect arity. @@ -15383,7 +15703,7 @@ namespace ts { // only the class declaration node will have the Abstract flag set. const valueDecl = expressionType.symbol && getClassLikeDeclarationOfSymbol(expressionType.symbol); if (valueDecl && getModifierFlags(valueDecl) & ModifierFlags.Abstract) { - error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(valueDecl.name)); + error(node, Diagnostics.Cannot_create_an_instance_of_the_abstract_class_0, declarationNameToString(getNameOfDeclaration(valueDecl))); return resolveErrorCall(node); } @@ -15847,11 +16167,11 @@ namespace ts { const links = getSymbolLinks(parameter); if (!links.type) { links.type = instantiateType(contextualType, mapper); + const name = getNameOfDeclaration(parameter.valueDeclaration); // if inference didn't come up with anything but {}, fall back to the binding pattern if present. if (links.type === emptyObjectType && - (parameter.valueDeclaration.name.kind === SyntaxKind.ObjectBindingPattern || - parameter.valueDeclaration.name.kind === SyntaxKind.ArrayBindingPattern)) { - links.type = getTypeFromBindingPattern(parameter.valueDeclaration.name); + (name.kind === SyntaxKind.ObjectBindingPattern || name.kind === SyntaxKind.ArrayBindingPattern)) { + links.type = getTypeFromBindingPattern(name); } assignBindingElementTypes(parameter.valueDeclaration); } @@ -15996,7 +16316,7 @@ namespace ts { // From within an async function you can return either a non-promise value or a promise. Any // Promise/A+ compatible implementation will always assimilate any foreign promise, so the // return type of the body is awaited type of the body, wrapped in a native Promise type. - return (functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async + return (functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async ? createPromiseReturnType(func, widenedType) // Async function : widenedType; // Generator function, AsyncGenerator function, or normal function } @@ -16212,7 +16532,7 @@ namespace ts { const functionFlags = getFunctionFlags(node); const returnOrPromisedType = node.type && - ((functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async ? + ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async ? checkAsyncFunctionReturnType(node) : // Async function getTypeFromTypeNode(node.type)); // AsyncGenerator function, Generator function, or normal function @@ -16242,7 +16562,7 @@ namespace ts { // its return type annotation. const exprType = checkExpression(node.body); if (returnOrPromisedType) { - if ((functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async) { // Async function + if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) { // Async function const awaitedType = checkAwaitedType(exprType, node.body, Diagnostics.The_return_type_of_an_async_function_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); checkTypeAssignableTo(awaitedType, returnOrPromisedType, node.body); } @@ -16982,12 +17302,16 @@ namespace ts { // we are in a yield context. const functionFlags = func && getFunctionFlags(func); if (node.asteriskToken) { - if (functionFlags & FunctionFlags.Async) { - if (languageVersion < ScriptTarget.ES2017) { - checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncDelegator); - } + // Async generator functions prior to ESNext require the __await, __asyncDelegator, + // and __asyncValues helpers + if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.AsyncGenerator && + languageVersion < ScriptTarget.ESNext) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncDelegatorIncludes); } - else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + + // Generator functions prior to ES2015 require the __values helper + if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Generator && + languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Values); } } @@ -17506,18 +17830,20 @@ namespace ts { } const functionFlags = getFunctionFlags(node); - if ((functionFlags & FunctionFlags.InvalidAsyncOrAsyncGenerator) === FunctionFlags.Async && languageVersion < ScriptTarget.ES2017) { - checkExternalEmitHelpers(node, ExternalEmitHelpers.Awaiter); - if (languageVersion < ScriptTarget.ES2015) { - checkExternalEmitHelpers(node, ExternalEmitHelpers.Generator); + if (!(functionFlags & FunctionFlags.Invalid)) { + // Async generators prior to ESNext require the __await and __asyncGenerator helpers + if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.AsyncGenerator && languageVersion < ScriptTarget.ESNext) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncGeneratorIncludes); } - } - if ((functionFlags & FunctionFlags.InvalidGenerator) === FunctionFlags.Generator) { - if (functionFlags & FunctionFlags.Async && languageVersion < ScriptTarget.ES2017) { - checkExternalEmitHelpers(node, ExternalEmitHelpers.AsyncGenerator); + // Async functions prior to ES2017 require the __awaiter helper + if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async && languageVersion < ScriptTarget.ES2017) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.Awaiter); } - else if (languageVersion < ScriptTarget.ES2015) { + + // Generator functions, Async functions, and Async Generator functions prior to + // ES2015 require the __generator helper + if ((functionFlags & FunctionFlags.AsyncGenerator) !== FunctionFlags.Normal && languageVersion < ScriptTarget.ES2015) { checkExternalEmitHelpers(node, ExternalEmitHelpers.Generator); } } @@ -17545,7 +17871,7 @@ namespace ts { if (node.type) { const functionFlags = getFunctionFlags(node); - if ((functionFlags & FunctionFlags.InvalidGenerator) === FunctionFlags.Generator) { + if ((functionFlags & (FunctionFlags.Invalid | FunctionFlags.Generator)) === FunctionFlags.Generator) { const returnType = getTypeFromTypeNode(node.type); if (returnType === voidType) { error(node.type, Diagnostics.A_generator_cannot_have_a_void_type_annotation); @@ -17565,7 +17891,7 @@ namespace ts { checkTypeAssignableTo(iterableIteratorInstantiation, returnType, node.type); } } - else if ((functionFlags & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async) { + else if ((functionFlags & FunctionFlags.AsyncGenerator) === FunctionFlags.Async) { checkAsyncFunctionReturnType(node); } } @@ -17689,7 +18015,7 @@ namespace ts { } if (names.get(memberName)) { - error(member.symbol.valueDeclaration.name, Diagnostics.Duplicate_identifier_0, memberName); + error(getNameOfDeclaration(member.symbol.valueDeclaration), Diagnostics.Duplicate_identifier_0, memberName); error(member.name, Diagnostics.Duplicate_identifier_0, memberName); } else { @@ -17790,7 +18116,8 @@ namespace ts { } function containsSuperCallAsComputedPropertyName(n: Declaration): boolean { - return n.name && containsSuperCall(n.name); + const name = getNameOfDeclaration(n); + return name && containsSuperCall(name); } function containsSuperCall(n: Node): boolean { @@ -17893,7 +18220,7 @@ namespace ts { // TypeScript 1.0 spec (April 2014): 8.4.3 // Accessors for the same member name must specify the same accessibility. const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const otherAccessor = getDeclarationOfKind(node.symbol, otherKind); + const otherAccessor = getDeclarationOfKind(node.symbol, otherKind); if (otherAccessor) { if ((getModifierFlags(node) & ModifierFlags.AccessibilityModifier) !== (getModifierFlags(otherAccessor) & ModifierFlags.AccessibilityModifier)) { error(node.name, Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility); @@ -18085,16 +18412,16 @@ namespace ts { forEach(overloads, o => { const deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags; if (deviation & ModifierFlags.Export) { - error(o.name, Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); + error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported); } else if (deviation & ModifierFlags.Ambient) { - error(o.name, Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); + error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient); } else if (deviation & (ModifierFlags.Private | ModifierFlags.Protected)) { - error(o.name || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); + error(getNameOfDeclaration(o) || o, Diagnostics.Overload_signatures_must_all_be_public_private_or_protected); } else if (deviation & ModifierFlags.Abstract) { - error(o.name, Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); + error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract); } }); } @@ -18106,7 +18433,7 @@ namespace ts { forEach(overloads, o => { const deviation = hasQuestionToken(o) !== canonicalHasQuestionToken; if (deviation) { - error(o.name, Diagnostics.Overload_signatures_must_all_be_optional_or_required); + error(getNameOfDeclaration(o), Diagnostics.Overload_signatures_must_all_be_optional_or_required); } }); } @@ -18242,7 +18569,7 @@ namespace ts { if (duplicateFunctionDeclaration) { forEach(declarations, declaration => { - error(declaration.name, Diagnostics.Duplicate_function_implementation); + error(getNameOfDeclaration(declaration), Diagnostics.Duplicate_function_implementation); }); } @@ -18324,12 +18651,13 @@ namespace ts { for (const d of symbol.declarations) { const declarationSpaces = getDeclarationSpaces(d); + const name = getNameOfDeclaration(d); // Only error on the declarations that contributed to the intersecting spaces. if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) { - error(d.name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(d.name)); + error(name, Diagnostics.Merged_declaration_0_cannot_include_a_default_export_declaration_Consider_adding_a_separate_export_default_0_declaration_instead, declarationNameToString(name)); } else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) { - error(d.name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(d.name)); + error(name, Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, declarationNameToString(name)); } } } @@ -18695,7 +19023,10 @@ namespace ts { * marked as referenced to prevent import elision. */ function markTypeNodeAsReferenced(node: TypeNode) { - const typeName = node && getEntityNameFromTypeNode(node); + markEntityNameOrEntityExpressionAsReference(node && getEntityNameFromTypeNode(node)); + } + + function markEntityNameOrEntityExpressionAsReference(typeName: EntityNameOrEntityNameExpression) { const rootName = typeName && getFirstIdentifier(typeName); const rootSymbol = rootName && resolveName(rootName, rootName.text, (typeName.kind === SyntaxKind.Identifier ? SymbolFlags.Type : SymbolFlags.Namespace) | SymbolFlags.Alias, /*nameNotFoundMessage*/ undefined, /*nameArg*/ undefined); if (rootSymbol @@ -18706,6 +19037,61 @@ namespace ts { } } + /** + * This function marks the type used for metadata decorator as referenced if it is import + * from external module. + * This is different from markTypeNodeAsReferenced because it tries to simplify type nodes in + * union and intersection type + * @param node + */ + function markDecoratorMedataDataTypeNodeAsReferenced(node: TypeNode): void { + const entityName = getEntityNameForDecoratorMetadata(node); + if (entityName && isEntityName(entityName)) { + markEntityNameOrEntityExpressionAsReference(entityName); + } + } + + function getEntityNameForDecoratorMetadata(node: TypeNode): EntityName { + if (node) { + switch (node.kind) { + case SyntaxKind.IntersectionType: + case SyntaxKind.UnionType: + let commonEntityName: EntityName; + for (const typeNode of (node).types) { + const individualEntityName = getEntityNameForDecoratorMetadata(typeNode); + if (!individualEntityName) { + // Individual is something like string number + // So it would be serialized to either that type or object + // Safe to return here + return undefined; + } + + if (commonEntityName) { + // Note this is in sync with the transformation that happens for type node. + // Keep this in sync with serializeUnionOrIntersectionType + // Verify if they refer to same entity and is identifier + // return undefined if they dont match because we would emit object + if (!isIdentifier(commonEntityName) || + !isIdentifier(individualEntityName) || + commonEntityName.text !== individualEntityName.text) { + return undefined; + } + } + else { + commonEntityName = individualEntityName; + } + } + return commonEntityName; + + case SyntaxKind.ParenthesizedType: + return getEntityNameForDecoratorMetadata((node).type); + + case SyntaxKind.TypeReference: + return (node).typeName; + } + } + } + function getParameterTypeNodeForDecoratorCheck(node: ParameterDeclaration): TypeNode { return node.dotDotDotToken ? getRestParameterElementType(node.type) : node.type; } @@ -18741,7 +19127,7 @@ namespace ts { const constructor = getFirstConstructorWithBody(node); if (constructor) { for (const parameter of constructor.parameters) { - markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); + markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } } break; @@ -18750,17 +19136,17 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: for (const parameter of (node).parameters) { - markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); + markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } - markTypeNodeAsReferenced((node).type); + markDecoratorMedataDataTypeNodeAsReferenced((node).type); break; case SyntaxKind.PropertyDeclaration: - markTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); + markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); break; case SyntaxKind.Parameter: - markTypeNodeAsReferenced((node).type); + markDecoratorMedataDataTypeNodeAsReferenced((node).type); break; } } @@ -18910,15 +19296,16 @@ namespace ts { if (!local.isReferenced) { if (local.valueDeclaration && getRootDeclaration(local.valueDeclaration).kind === SyntaxKind.Parameter) { const parameter = getRootDeclaration(local.valueDeclaration); + const name = getNameOfDeclaration(local.valueDeclaration); if (compilerOptions.noUnusedParameters && !isParameterPropertyDeclaration(parameter) && !parameterIsThisKeyword(parameter) && - !parameterNameStartsWithUnderscore(local.valueDeclaration.name)) { - error(local.valueDeclaration.name, Diagnostics._0_is_declared_but_never_used, local.name); + !parameterNameStartsWithUnderscore(name)) { + error(name, Diagnostics._0_is_declared_but_never_used, local.name); } } else if (compilerOptions.noUnusedLocals) { - forEach(local.declarations, d => errorUnusedLocal(d.name || d, local.name)); + forEach(local.declarations, d => errorUnusedLocal(getNameOfDeclaration(d) || d, local.name)); } } }); @@ -19002,7 +19389,7 @@ namespace ts { if (!local.isReferenced && !local.exportSymbol) { for (const declaration of local.declarations) { if (!isAmbientModule(declaration)) { - errorUnusedLocal(declaration.name, local.name); + errorUnusedLocal(getNameOfDeclaration(declaration), local.name); } } } @@ -19081,7 +19468,7 @@ namespace ts { if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureThis) { const isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { - error((node).name, Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); + error(getNameOfDeclaration(node), Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference); } else { error(node, Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference); @@ -19096,7 +19483,7 @@ namespace ts { if (getNodeCheckFlags(current) & NodeCheckFlags.CaptureNewTarget) { const isDeclaration = node.kind !== SyntaxKind.Identifier; if (isDeclaration) { - error((node).name, Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); + error(getNameOfDeclaration(node), Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference); } else { error(node, Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference); @@ -19395,7 +19782,7 @@ namespace ts { checkTypeAssignableTo(checkExpressionCached(node.initializer), declarationType, node, /*headMessage*/ undefined); } if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { - error(symbol.valueDeclaration.name, Diagnostics.All_declarations_of_0_must_have_identical_modifiers, declarationNameToString(node.name)); + error(getNameOfDeclaration(symbol.valueDeclaration), Diagnostics.All_declarations_of_0_must_have_identical_modifiers, declarationNameToString(node.name)); error(node.name, Diagnostics.All_declarations_of_0_must_have_identical_modifiers, declarationNameToString(node.name)); } } @@ -19532,11 +19919,14 @@ namespace ts { if (node.kind === SyntaxKind.ForOfStatement) { if ((node).awaitModifier) { - if (languageVersion < ScriptTarget.ES2017) { + const functionFlags = getFunctionFlags(getContainingFunction(node)); + if ((functionFlags & (FunctionFlags.Invalid | FunctionFlags.Async)) === FunctionFlags.Async && languageVersion < ScriptTarget.ESNext) { + // for..await..of in an async function or async generator function prior to ESNext requires the __asyncValues helper checkExternalEmitHelpers(node, ExternalEmitHelpers.ForAwaitOfIncludes); } } - else if (languageVersion < ScriptTarget.ES2015 && compilerOptions.downlevelIteration) { + else if (compilerOptions.downlevelIteration && languageVersion < ScriptTarget.ES2015) { + // for..of prior to ES2015 requires the __values helper when downlevelIteration is enabled checkExternalEmitHelpers(node, ExternalEmitHelpers.ForOfIncludes); } } @@ -19962,11 +20352,11 @@ namespace ts { } function isGetAccessorWithAnnotatedSetAccessor(node: FunctionLikeDeclaration) { - return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor))); + return !!(node.kind === SyntaxKind.GetAccessor && getSetAccessorTypeAnnotationNode(getDeclarationOfKind(node.symbol, SyntaxKind.SetAccessor))); } function isUnwrappedReturnTypeVoidOrAny(func: FunctionLikeDeclaration, returnType: Type): boolean { - const unwrappedReturnType = (getFunctionFlags(func) & FunctionFlags.AsyncOrAsyncGenerator) === FunctionFlags.Async + const unwrappedReturnType = (getFunctionFlags(func) & FunctionFlags.AsyncGenerator) === FunctionFlags.Async ? getPromisedTypeOfPromise(returnType) // Async function : returnType; // AsyncGenerator function, Generator function, or normal function return unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, TypeFlags.Void | TypeFlags.Any); @@ -20223,14 +20613,17 @@ namespace ts { const propDeclaration = prop.valueDeclaration; // index is numeric and property name is not valid numeric literal - if (indexKind === IndexKind.Number && !(propDeclaration ? isNumericName(propDeclaration.name) : isNumericLiteralName(prop.name))) { + if (indexKind === IndexKind.Number && !(propDeclaration ? isNumericName(getNameOfDeclaration(propDeclaration)) : isNumericLiteralName(prop.name))) { return; } // 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 + // this allows us to rule out cases when both property and indexer are inherited from the base class let errorNode: Node; - if (propDeclaration && (propDeclaration.name.kind === SyntaxKind.ComputedPropertyName || prop.parent === containingType.symbol)) { + if (propDeclaration && + (propDeclaration.kind === SyntaxKind.BinaryExpression || + getNameOfDeclaration(propDeclaration).kind === SyntaxKind.ComputedPropertyName || + prop.parent === containingType.symbol)) { errorNode = propDeclaration; } else if (indexDeclaration) { @@ -20567,11 +20960,6 @@ namespace ts { continue; } - if ((baseDeclarationFlags & ModifierFlags.Static) !== (derivedDeclarationFlags & ModifierFlags.Static)) { - // value of 'static' is not the same for properties - not override, skip it - continue; - } - if (isMethodLike(base) && isMethodLike(derived) || base.flags & SymbolFlags.PropertyOrAccessor && derived.flags & SymbolFlags.PropertyOrAccessor) { // method is overridden with method or property/accessor is overridden with property/accessor - correct case continue; @@ -20593,7 +20981,7 @@ namespace ts { errorMessage = Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function; } - error(derived.valueDeclaration.name || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); + error(getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type)); } } } @@ -20652,7 +21040,7 @@ namespace ts { checkTypeParameterListsIdentical(symbol); // Only check this symbol once - const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); + const firstInterfaceDecl = getDeclarationOfKind(symbol, SyntaxKind.InterfaceDeclaration); if (node === firstInterfaceDecl) { const type = getDeclaredTypeOfSymbol(symbol); const typeWithThis = getTypeWithThisArgument(type); @@ -20874,7 +21262,7 @@ namespace ts { // check that const is placed\omitted on all enum declarations forEach(enumSymbol.declarations, decl => { if (isConstEnumDeclaration(decl) !== enumIsConst) { - error(decl.name, Diagnostics.Enum_declarations_must_all_be_const_or_non_const); + error(getNameOfDeclaration(decl), Diagnostics.Enum_declarations_must_all_be_const_or_non_const); } }); } @@ -21148,6 +21536,11 @@ namespace ts { Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0; error(node, message, symbolToString(symbol)); } + + // Don't allow to re-export something with no value side when `--isolatedModules` is set. + if (node.kind === SyntaxKind.ExportSpecifier && compilerOptions.isolatedModules && !(target.flags & SymbolFlags.Value)) { + error(node, Diagnostics.Cannot_re_export_a_type_when_the_isolatedModules_flag_is_provided); + } } } @@ -21767,7 +22160,7 @@ namespace ts { function isTypeDeclarationName(name: Node): boolean { return name.kind === SyntaxKind.Identifier && isTypeDeclaration(name.parent) && - (name.parent).name === name; + (name.parent).name === name; } function isTypeDeclaration(node: Node): boolean { @@ -21956,7 +22349,7 @@ namespace ts { return undefined; } - if (isDeclarationName(node)) { + if (isDeclarationNameOrImportPropertyName(node)) { // This is a declaration, call getSymbolOfNode return getSymbolOfNode(node.parent); } @@ -22103,7 +22496,7 @@ namespace ts { return getTypeOfSymbol(symbol); } - if (isDeclarationName(node)) { + if (isDeclarationNameOrImportPropertyName(node)) { const symbol = getSymbolAtLocation(node); return symbol && getTypeOfSymbol(symbol); } @@ -22313,7 +22706,7 @@ namespace ts { const symbolIsUmdExport = symbolFile !== referenceFile; return symbolIsUmdExport ? undefined : symbolFile; } - return findAncestor(node.parent, n => isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol) as ModuleDeclaration | EnumDeclaration; + return findAncestor(node.parent, (n): n is ModuleDeclaration | EnumDeclaration => isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol); } } } @@ -22614,16 +23007,6 @@ namespace ts { getSymbolDisplayBuilder().buildTypeDisplay(type, writer, enclosingDeclaration, flags); } - function writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter) { - const classType = getDeclaredTypeOfSymbol(getSymbolOfNode(node)); - resolveBaseTypesOfClass(classType); - const baseType = classType.resolvedBaseTypes.length ? classType.resolvedBaseTypes[0] : unknownType; - if (!baseType.symbol) { - writer.reportIllegalExtends(); - } - getSymbolDisplayBuilder().buildTypeDisplay(baseType, writer, enclosingDeclaration, flags); - } - function hasGlobalName(name: string): boolean { return globals.has(name); } @@ -22717,7 +23100,6 @@ namespace ts { writeTypeOfDeclaration, writeReturnTypeOfSignatureDeclaration, writeTypeOfExpression, - writeBaseConstructorTypeOfClass, isSymbolAccessible, isEntityNameVisible, getConstantValue: node => { @@ -22923,6 +23305,7 @@ namespace ts { case ExternalEmitHelpers.Values: return "__values"; case ExternalEmitHelpers.Read: return "__read"; case ExternalEmitHelpers.Spread: return "__spread"; + case ExternalEmitHelpers.Await: return "__await"; case ExternalEmitHelpers.AsyncGenerator: return "__asyncGenerator"; case ExternalEmitHelpers.AsyncDelegator: return "__asyncDelegator"; case ExternalEmitHelpers.AsyncValues: return "__asyncValues"; @@ -24142,4 +24525,19 @@ namespace ts { return result; } } + + /** Like 'isDeclarationName', but returns true for LHS of `import { x as y }` or `export { x as y }`. */ + function isDeclarationNameOrImportPropertyName(name: Node): boolean { + switch (name.parent.kind) { + case SyntaxKind.ImportSpecifier: + case SyntaxKind.ExportSpecifier: + if ((name.parent as ImportOrExportSpecifier).propertyName) { + return true; + } + // falls through + default: + return isDeclarationName(name); + + } + } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index a5990a5a31b..9494098c072 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -1088,58 +1088,38 @@ namespace ts { * @param host Instance of ParseConfigHost used to enumerate files in folder. * @param basePath A root directory to resolve relative path entries in the config * file to. e.g. outDir + * @param resolutionStack Only present for backwards-compatibility. Should be empty. */ - export function parseJsonConfigFileContent(json: any, host: ParseConfigHost, basePath: string, existingOptions: CompilerOptions = {}, configFileName?: string, resolutionStack: Path[] = [], extraFileExtensions: JsFileExtensionInfo[] = []): ParsedCommandLine { + export function parseJsonConfigFileContent( + json: any, + host: ParseConfigHost, + basePath: string, + existingOptions: CompilerOptions = {}, + configFileName?: string, + resolutionStack: Path[] = [], + extraFileExtensions: JsFileExtensionInfo[] = [], + ): ParsedCommandLine { const errors: Diagnostic[] = []; - basePath = normalizeSlashes(basePath); - const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); - const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName); - if (resolutionStack.indexOf(resolvedPath) >= 0) { - return { - options: {}, - fileNames: [], - typeAcquisition: {}, - raw: json, - errors: [createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))], - wildcardDirectories: {} - }; - } - let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json["compilerOptions"], basePath, errors, configFileName); + let options = (() => { + const { include, exclude, files, options, compileOnSave } = parseConfig(json, host, basePath, configFileName, resolutionStack, errors); + if (include) { json.include = include; } + if (exclude) { json.exclude = exclude; } + if (files) { json.files = files; } + if (compileOnSave !== undefined) { json.compileOnSave = compileOnSave; } + return options; + })(); + + options = extend(existingOptions, options); + options.configFilePath = configFileName; + // typingOptions has been deprecated and is only supported for backward compatibility purposes. // It should be removed in future releases - use typeAcquisition instead. const jsonOptions = json["typeAcquisition"] || json["typingOptions"]; const typeAcquisition: TypeAcquisition = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName); - let baseCompileOnSave: boolean; - if (json["extends"]) { - let [include, exclude, files, baseOptions]: [string[], string[], string[], CompilerOptions] = [undefined, undefined, undefined, {}]; - if (typeof json["extends"] === "string") { - [include, exclude, files, baseCompileOnSave, baseOptions] = (tryExtendsName(json["extends"]) || [include, exclude, files, baseCompileOnSave, baseOptions]); - } - else { - errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); - } - if (include && !json["include"]) { - json["include"] = include; - } - if (exclude && !json["exclude"]) { - json["exclude"] = exclude; - } - if (files && !json["files"]) { - json["files"] = files; - } - options = assign({}, baseOptions, options); - } - - options = extend(existingOptions, options); - options.configFilePath = configFileName; - - const { fileNames, wildcardDirectories } = getFileNames(errors); - let compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); - if (baseCompileOnSave && json[compileOnSaveCommandLineOption.name] === undefined) { - compileOnSave = baseCompileOnSave; - } + const { fileNames, wildcardDirectories } = getFileNames(); + const compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors); return { options, @@ -1151,40 +1131,7 @@ namespace ts { compileOnSave }; - function tryExtendsName(extendedConfig: string): [string[], string[], string[], boolean, CompilerOptions] { - // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) - if (!(isRootedDiskPath(extendedConfig) || startsWith(normalizeSlashes(extendedConfig), "./") || startsWith(normalizeSlashes(extendedConfig), "../"))) { - errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extendedConfig)); - return; - } - let extendedConfigPath = toPath(extendedConfig, basePath, getCanonicalFileName); - if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) { - extendedConfigPath = `${extendedConfigPath}.json` as Path; - if (!host.fileExists(extendedConfigPath)) { - errors.push(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, extendedConfig)); - return; - } - } - const extendedResult = readConfigFile(extendedConfigPath, path => host.readFile(path)); - if (extendedResult.error) { - errors.push(extendedResult.error); - return; - } - const extendedDirname = getDirectoryPath(extendedConfigPath); - const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); - const updatePath: (path: string) => string = path => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); - // Merge configs (copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios) - const result = parseJsonConfigFileContent(extendedResult.config, host, extendedDirname, /*existingOptions*/ undefined, getBaseFileName(extendedConfigPath), resolutionStack.concat([resolvedPath])); - errors.push(...result.errors); - const [include, exclude, files] = map(["include", "exclude", "files"], key => { - if (!json[key] && extendedResult.config[key]) { - return map(extendedResult.config[key], updatePath); - } - }); - return [include, exclude, files, result.compileOnSave, result.options]; - } - - function getFileNames(errors: Diagnostic[]): ExpandResult { + function getFileNames(): ExpandResult { let fileNames: string[]; if (hasProperty(json, "files")) { if (isArray(json["files"])) { @@ -1217,9 +1164,6 @@ namespace ts { errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "exclude", "Array")); } } - else if (hasProperty(json, "excludes")) { - errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); - } else { // If no includes were specified, exclude common package folders and the outDir excludeSpecs = includeSpecs ? [] : ["node_modules", "bower_components", "jspm_packages"]; @@ -1249,7 +1193,106 @@ namespace ts { } } - export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean | undefined { + interface ParsedTsconfig { + include: string[] | undefined; + exclude: string[] | undefined; + files: string[] | undefined; + options: CompilerOptions; + compileOnSave: boolean | undefined; + } + + /** + * This *just* extracts options/include/exclude/files out of a config file. + * It does *not* resolve the included files. + */ + function parseConfig( + json: any, + host: ParseConfigHost, + basePath: string, + configFileName: string, + resolutionStack: Path[], + errors: Diagnostic[], + ): ParsedTsconfig { + + basePath = normalizeSlashes(basePath); + const getCanonicalFileName = createGetCanonicalFileName(host.useCaseSensitiveFileNames); + const resolvedPath = toPath(configFileName || "", basePath, getCanonicalFileName); + + if (resolutionStack.indexOf(resolvedPath) >= 0) { + errors.push(createCompilerDiagnostic(Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, [...resolutionStack, resolvedPath].join(" -> "))); + return { include: undefined, exclude: undefined, files: undefined, options: {}, compileOnSave: undefined }; + } + + if (hasProperty(json, "excludes")) { + errors.push(createCompilerDiagnostic(Diagnostics.Unknown_option_excludes_Did_you_mean_exclude)); + } + + let options: CompilerOptions = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName); + let include: string[] | undefined = json.include, exclude: string[] | undefined = json.exclude, files: string[] | undefined = json.files; + let compileOnSave: boolean | undefined = json.compileOnSave; + + if (json.extends) { + // copy the resolution stack so it is never reused between branches in potential diamond-problem scenarios. + resolutionStack = resolutionStack.concat([resolvedPath]); + const base = getExtendedConfig(json.extends, host, basePath, getCanonicalFileName, resolutionStack, errors); + if (base) { + include = include || base.include; + exclude = exclude || base.exclude; + files = files || base.files; + if (compileOnSave === undefined) { + compileOnSave = base.compileOnSave; + } + options = assign({}, base.options, options); + } + } + + return { include, exclude, files, options, compileOnSave }; + } + + function getExtendedConfig( + extended: any, // Usually a string. + host: ts.ParseConfigHost, + basePath: string, + getCanonicalFileName: (fileName: string) => string, + resolutionStack: Path[], + errors: Diagnostic[], + ): ParsedTsconfig | undefined { + if (typeof extended !== "string") { + errors.push(createCompilerDiagnostic(Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string")); + return undefined; + } + + extended = normalizeSlashes(extended); + + // If the path isn't a rooted or relative path, don't try to resolve it (we reserve the right to special case module-id like paths in the future) + if (!(isRootedDiskPath(extended) || startsWith(extended, "./") || startsWith(extended, "../"))) { + errors.push(createCompilerDiagnostic(Diagnostics.A_path_in_an_extends_option_must_be_relative_or_rooted_but_0_is_not, extended)); + return undefined; + } + + let extendedConfigPath = toPath(extended, basePath, getCanonicalFileName); + if (!host.fileExists(extendedConfigPath) && !endsWith(extendedConfigPath, ".json")) { + extendedConfigPath = extendedConfigPath + ".json" as Path; + if (!host.fileExists(extendedConfigPath)) { + errors.push(createCompilerDiagnostic(Diagnostics.File_0_does_not_exist, extended)); + return undefined; + } + } + + const extendedResult = readConfigFile(extendedConfigPath, path => host.readFile(path)); + if (extendedResult.error) { + errors.push(extendedResult.error); + return undefined; + } + + const extendedDirname = getDirectoryPath(extendedConfigPath); + const relativeDifference = convertToRelativePath(extendedDirname, basePath, getCanonicalFileName); + const updatePath: (path: string) => string = path => isRootedDiskPath(path) ? path : combinePaths(relativeDifference, path); + const { include, exclude, files, options, compileOnSave } = parseConfig(extendedResult.config, host, extendedDirname, getBaseFileName(extendedConfigPath), resolutionStack, errors); + return { include: map(include, updatePath), exclude: map(exclude, updatePath), files: map(files, updatePath), compileOnSave, options }; + } + + export function convertCompileOnSaveOptionFromJson(jsonOption: any, basePath: string, errors: Diagnostic[]): boolean { if (!hasProperty(jsonOption, compileOnSaveCommandLineOption.name)) { return false; } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index 3c867024485..60553fdab01 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -3,7 +3,7 @@ namespace ts { /** The version of the TypeScript compiler release */ - export const version = "2.3.0"; + export const version = "2.4.0"; } /* @internal */ @@ -230,6 +230,8 @@ namespace ts { * If no such value is found, it applies the callback until the parent pointer is undefined or the callback returns "quit" * At that point findAncestor returns undefined. */ + export function findAncestor(node: Node, callback: (element: Node) => element is T): T | undefined; + export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node | undefined; export function findAncestor(node: Node, callback: (element: Node) => boolean | "quit"): Node { while (node) { const result = callback(node); @@ -251,6 +253,15 @@ namespace ts { } } + export function zipToMap(keys: string[], values: T[]): Map { + Debug.assert(keys.length === values.length); + const map = createMap(); + for (let i = 0; i < keys.length; ++i) { + map.set(keys[i], values[i]); + } + return map; + } + /** * Iterates through `array` by index and performs the callback on each element of array until the callback * returns a falsey value, then returns false. @@ -481,6 +492,35 @@ namespace ts { return result; } + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * Avoids allocation if all elements map to themselves. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ + export function sameFlatMap(array: T[], mapfn: (x: T, i: number) => T | T[]): T[] { + let result: T[]; + if (array) { + for (let i = 0; i < array.length; i++) { + const item = array[i]; + const mapped = mapfn(item, i); + if (result || item !== mapped || isArray(mapped)) { + if (!result) { + result = array.slice(0, i); + } + if (isArray(mapped)) { + addRange(result, mapped); + } + else { + result.push(mapped); + } + } + } + } + return result || array; + } + /** * Computes the first matching span of elements and returns a tuple of the first span * and the remaining elements. diff --git a/src/compiler/declarationEmitter.ts b/src/compiler/declarationEmitter.ts index 495713ac07a..d68744e9735 100644 --- a/src/compiler/declarationEmitter.ts +++ b/src/compiler/declarationEmitter.ts @@ -67,7 +67,7 @@ namespace ts { let errorNameNode: DeclarationName; const emitJsDocComments = compilerOptions.removeComments ? noop : writeJsDocComments; const emit = compilerOptions.stripInternal ? stripInternal : emitNode; - let noDeclare: boolean; + let needsDeclare = true; let moduleElementDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[] = []; let asynchronousSubModuleDeclarationEmitInfo: ModuleElementDeclarationEmitInfo[]; @@ -110,11 +110,11 @@ namespace ts { resultHasExternalModuleIndicator = false; if (!isBundledEmit || !isExternalModule(sourceFile)) { - noDeclare = false; + needsDeclare = true; emitSourceFile(sourceFile); } else if (isExternalModule(sourceFile)) { - noDeclare = true; + needsDeclare = false; write(`declare module "${getResolvedExternalModuleName(host, sourceFile)}" {`); writeLine(); increaseIndent(); @@ -594,12 +594,11 @@ namespace ts { emitLines(node.statements); } - // Return a temp variable name to be used in `export default` statements. + // Return a temp variable name to be used in `export default`/`export class ... extends` statements. // The temp name will be of the form _default_counter. // Note that export default is only allowed at most once in a module, so we // do not need to keep track of created temp names. - function getExportDefaultTempVariableName(): string { - const baseName = "_default"; + function getExportTempVariableName(baseName: string): string { if (!currentIdentifiers.has(baseName)) { return baseName; } @@ -613,24 +612,31 @@ namespace ts { } } + function emitTempVariableDeclaration(expr: Expression, baseName: string, diagnostic: SymbolAccessibilityDiagnostic, needsDeclare: boolean): string { + const tempVarName = getExportTempVariableName(baseName); + if (needsDeclare) { + write("declare "); + } + write("const "); + write(tempVarName); + write(": "); + writer.getSymbolAccessibilityDiagnostic = () => diagnostic; + resolver.writeTypeOfExpression(expr, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); + write(";"); + writeLine(); + return tempVarName; + } + function emitExportAssignment(node: ExportAssignment) { if (node.expression.kind === SyntaxKind.Identifier) { write(node.isExportEquals ? "export = " : "export default "); writeTextOfNode(currentText, node.expression); } else { - // Expression - const tempVarName = getExportDefaultTempVariableName(); - if (!noDeclare) { - write("declare "); - } - write("var "); - write(tempVarName); - write(": "); - writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic; - resolver.writeTypeOfExpression(node.expression, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); - write(";"); - writeLine(); + const tempVarName = emitTempVariableDeclaration(node.expression, "_default", { + diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, + errorNode: node + }, needsDeclare); write(node.isExportEquals ? "export = " : "export default "); write(tempVarName); } @@ -644,13 +650,6 @@ namespace ts { // write each of these declarations asynchronously writeAsynchronousModuleElements(nodes); } - - function getDefaultExportAccessibilityDiagnostic(): SymbolAccessibilityDiagnostic { - return { - diagnosticMessage: Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0, - errorNode: node - }; - } } function isModuleElementVisible(node: Declaration) { @@ -729,7 +728,7 @@ namespace ts { if (modifiers & ModifierFlags.Default) { write("default "); } - else if (node.kind !== SyntaxKind.InterfaceDeclaration && !noDeclare) { + else if (node.kind !== SyntaxKind.InterfaceDeclaration && needsDeclare) { write("declare "); } } @@ -1097,7 +1096,7 @@ namespace ts { } } - function emitHeritageClause(className: Identifier, typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) { + function emitHeritageClause(typeReferences: ExpressionWithTypeArguments[], isImplementsList: boolean) { if (typeReferences) { write(isImplementsList ? " implements " : " extends "); emitCommaList(typeReferences, emitTypeOfTypeReference); @@ -1110,12 +1109,6 @@ namespace ts { else if (!isImplementsList && node.expression.kind === SyntaxKind.NullKeyword) { write("null"); } - else { - writer.getSymbolAccessibilityDiagnostic = getHeritageClauseVisibilityError; - errorNameNode = className; - resolver.writeBaseConstructorTypeOfClass(enclosingDeclaration, enclosingDeclaration, TypeFormatFlags.UseTypeOfFunction | TypeFormatFlags.UseTypeAliasValue, writer); - errorNameNode = undefined; - } function getHeritageClauseVisibilityError(): SymbolAccessibilityDiagnostic { let diagnosticMessage: DiagnosticMessage; @@ -1134,7 +1127,7 @@ namespace ts { return { diagnosticMessage, errorNode: node, - typeName: (node.parent.parent).name + typeName: getNameOfDeclaration(node.parent.parent) }; } } @@ -1151,23 +1144,43 @@ namespace ts { } } + const prevEnclosingDeclaration = enclosingDeclaration; + enclosingDeclaration = node; + const baseTypeNode = getClassExtendsHeritageClauseElement(node); + let tempVarName: string; + if (baseTypeNode && !isEntityNameExpression(baseTypeNode.expression)) { + tempVarName = baseTypeNode.expression.kind === SyntaxKind.NullKeyword ? + "null" : + emitTempVariableDeclaration(baseTypeNode.expression, `${node.name.text}_base`, { + diagnosticMessage: Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1, + errorNode: baseTypeNode, + typeName: node.name + }, !findAncestor(node, n => n.kind === SyntaxKind.ModuleDeclaration)); + } + emitJsDocComments(node); emitModuleElementDeclarationFlags(node); if (hasModifier(node, ModifierFlags.Abstract)) { write("abstract "); } - write("class "); writeTextOfNode(currentText, node.name); - const prevEnclosingDeclaration = enclosingDeclaration; - enclosingDeclaration = node; emitTypeParameters(node.typeParameters); - const baseTypeNode = getClassExtendsHeritageClauseElement(node); if (baseTypeNode) { - node.name; - emitHeritageClause(node.name, [baseTypeNode], /*isImplementsList*/ false); + if (!isEntityNameExpression(baseTypeNode.expression)) { + write(" extends "); + write(tempVarName); + if (baseTypeNode.typeArguments) { + write("<"); + emitCommaList(baseTypeNode.typeArguments, emitType); + write(">"); + } + } + else { + emitHeritageClause([baseTypeNode], /*isImplementsList*/ false); + } } - emitHeritageClause(node.name, getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); + emitHeritageClause(getClassImplementsHeritageClauseElements(node), /*isImplementsList*/ true); write(" {"); writeLine(); increaseIndent(); @@ -1189,7 +1202,7 @@ namespace ts { emitTypeParameters(node.typeParameters); const interfaceExtendsTypes = filter(getInterfaceBaseTypeNodes(node), base => isEntityNameExpression(base.expression)); if (interfaceExtendsTypes && interfaceExtendsTypes.length) { - emitHeritageClause(node.name, interfaceExtendsTypes, /*isImplementsList*/ false); + emitHeritageClause(interfaceExtendsTypes, /*isImplementsList*/ false); } write(" {"); writeLine(); @@ -1253,7 +1266,9 @@ namespace ts { Diagnostics.Exported_variable_0_has_or_is_using_private_name_1; } // This check is to ensure we don't report error on constructor parameter property as that error would be reported during parameter emit - else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) { + // The only exception here is if the constructor was marked as private. we are not emitting the constructor parameters at all. + else if (node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature || + (node.kind === SyntaxKind.Parameter && hasModifier(node.parent, ModifierFlags.Private))) { // TODO(jfreeman): Deal with computed properties in error reporting. if (hasModifier(node, ModifierFlags.Static)) { return symbolAccessibilityResult.errorModuleName ? @@ -1262,7 +1277,7 @@ namespace ts { Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 : Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1; } - else if (node.parent.kind === SyntaxKind.ClassDeclaration) { + else if (node.parent.kind === SyntaxKind.ClassDeclaration || node.kind === SyntaxKind.Parameter) { return symbolAccessibilityResult.errorModuleName ? symbolAccessibilityResult.accessibility === SymbolAccessibility.CannotBeNamed ? Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named : @@ -1488,6 +1503,11 @@ namespace ts { write("["); } else { + if (node.kind === SyntaxKind.Constructor && hasModifier(node, ModifierFlags.Private)) { + write("();"); + writeLine(); + return; + } // Construct signature or constructor type write new Signature if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) { write("new "); @@ -1820,7 +1840,7 @@ namespace ts { function writeReferencePath(referencedFile: SourceFile, addBundledFileReference: boolean, emitOnlyDtsFiles: boolean): boolean { let declFileName: string; let addedBundledEmitReference = false; - if (isDeclarationFile(referencedFile)) { + if (referencedFile.isDeclarationFile) { // Declaration file, use declaration file name declFileName = referencedFile.fileName; } diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 43c1c6334cd..36a5303cd58 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -635,6 +635,10 @@ "category": "Error", "code": 1203 }, + "Cannot re-export a type when the '--isolatedModules' flag is provided.": { + "category": "Error", + "code": 1205 + }, "Decorators are not valid here.": { "category": "Error", "code": 1206 @@ -1843,10 +1847,18 @@ "category": "Error", "code": 2550 }, - "Computed values are not permitted in an enum with string valued members.": { + "Property '{0}' does not exist on type '{1}'. Did you mean '{2}'?": { "category": "Error", "code": 2551 }, + "Cannot find name '{0}'. Did you mean '{1}'?": { + "category": "Error", + "code": 2552 + }, + "Computed values are not permitted in an enum with string valued members.": { + "category": "Error", + "code": 2553 + }, "JSX element attributes type '{0}' may not be a union type.": { "category": "Error", "code": 2600 @@ -3207,9 +3219,16 @@ }, "Scoped package detected, looking in '{0}'": { "category": "Message", - "code": "6182" + "code": 6182 + }, + "Reusing resolution of module '{0}' to file '{1}' from old program.": { + "category": "Message", + "code": 6183 + }, + "Reusing module resolutions originating in '{0}' since resolutions are unchanged from old program.": { + "category": "Message", + "code": 6184 }, - "Variable '{0}' implicitly has an '{1}' type.": { "category": "Error", "code": 7005 @@ -3536,7 +3555,10 @@ "category": "Message", "code": 90021 }, - + "Change spelling to '{0}'.": { + "category": "Message", + "code": 90022 + }, "Octal literal types must use ES2015 syntax. Use the syntax '{0}'.": { "category": "Error", diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 0f00f664e0d..e5ff7de8353 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -153,7 +153,7 @@ namespace ts { for (let i = 0; i < numNodes; i++) { const currentNode = bundle ? bundle.sourceFiles[i] : node; const sourceFile = isSourceFile(currentNode) ? currentNode : currentSourceFile; - const shouldSkip = compilerOptions.noEmitHelpers || (sourceFile && getExternalHelpersModuleName(sourceFile) !== undefined); + const shouldSkip = compilerOptions.noEmitHelpers || getExternalHelpersModuleName(sourceFile) !== undefined; const shouldBundle = isSourceFile(currentNode) && !isOwnFileEmit; const helpers = getEmitHelpers(currentNode); if (helpers) { @@ -212,7 +212,7 @@ namespace ts { emitLeadingCommentsOfPosition, } = comments; - let currentSourceFile: SourceFile; + let currentSourceFile: SourceFile | undefined; let nodeIdToGeneratedName: string[]; // Map of generated names for specific nodes. let autoGeneratedIdToGeneratedName: string[]; // Map of generated names for temp and loop variables. let generatedNames: Map; // Set of names generated by the NameGenerator. @@ -264,7 +264,12 @@ namespace ts { return endPrint(); } - function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter) { + /** + * If `sourceFile` is `undefined`, `node` must be a synthesized `TypeNode`. + */ + function writeNode(hint: EmitHint, node: TypeNode, sourceFile: undefined, output: EmitTextWriter): void; + function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, output: EmitTextWriter): void; + function writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, output: EmitTextWriter) { const previousWriter = writer; setWriter(output); print(hint, node, sourceFile); @@ -305,8 +310,10 @@ namespace ts { return text; } - function print(hint: EmitHint, node: Node, sourceFile: SourceFile) { - setSourceFile(sourceFile); + function print(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined) { + if (sourceFile) { + setSourceFile(sourceFile); + } pipelineEmitWithNotification(hint, node); } @@ -733,6 +740,9 @@ namespace ts { // Transformation nodes case SyntaxKind.PartiallyEmittedExpression: return emitPartiallyEmittedExpression(node); + + case SyntaxKind.CommaListExpression: + return emitCommaList(node); } } @@ -778,6 +788,7 @@ namespace ts { function emitIdentifier(node: Identifier) { write(getTextOfNode(node, /*includeTrivia*/ false)); + emitTypeArguments(node, node.typeArguments); } // @@ -812,6 +823,7 @@ namespace ts { function emitTypeParameter(node: TypeParameterDeclaration) { emit(node.name); emitWithPrefix(" extends ", node.constraint); + emitWithPrefix(" = ", node.default); } function emitParameter(node: ParameterDeclaration) { @@ -952,7 +964,10 @@ namespace ts { function emitTypeLiteral(node: TypeLiteralNode) { write("{"); - emitList(node, node.members, ListFormat.TypeLiteralMembers); + // If the literal is empty, do not add spaces between braces. + if (node.members.length > 0) { + emitList(node, node.members, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.SingleLineTypeLiteralMembers : ListFormat.MultiLineTypeLiteralMembers); + } write("}"); } @@ -999,9 +1014,15 @@ namespace ts { } function emitMappedType(node: MappedTypeNode) { + const emitFlags = getEmitFlags(node); write("{"); - writeLine(); - increaseIndent(); + if (emitFlags & EmitFlags.SingleLine) { + write(" "); + } + else { + writeLine(); + increaseIndent(); + } writeIfPresent(node.readonlyToken, "readonly "); write("["); emit(node.typeParameter.name); @@ -1012,8 +1033,13 @@ namespace ts { write(": "); emit(node.type); write(";"); - writeLine(); - decreaseIndent(); + if (emitFlags & EmitFlags.SingleLine) { + write(" "); + } + else { + writeLine(); + decreaseIndent(); + } write("}"); } @@ -1032,7 +1058,7 @@ namespace ts { } else { write("{"); - emitList(node, elements, ListFormat.ObjectBindingPatternElements); + emitList(node, elements, getEmitFlags(node) & EmitFlags.SingleLine ? ListFormat.ObjectBindingPatternElements : ListFormat.ObjectBindingPatternElementsWithSpaceBetweenBraces); write("}"); } } @@ -2101,6 +2127,10 @@ namespace ts { emitExpression(node.expression); } + function emitCommaList(node: CommaListExpression) { + emitExpressionList(node, node.elements, ListFormat.CommaListElements); + } + /** * Emits any prologue directives at the start of a Statement list, returning the * number of prologue directives written to the output. @@ -2630,7 +2660,9 @@ namespace ts { if (node.kind === SyntaxKind.StringLiteral && (node).textSourceNode) { const textSourceNode = (node).textSourceNode; if (isIdentifier(textSourceNode)) { - return "\"" + escapeNonAsciiCharacters(escapeString(getTextOfNode(textSourceNode))) + "\""; + return getEmitFlags(node) & EmitFlags.NoAsciiEscaping ? + `"${escapeString(getTextOfNode(textSourceNode))}"` : + `"${escapeNonAsciiString(getTextOfNode(textSourceNode))}"`; } else { return getLiteralTextOfNode(textSourceNode); @@ -2943,14 +2975,18 @@ namespace ts { // Precomputed Formats Modifiers = SingleLine | SpaceBetweenSiblings, HeritageClauses = SingleLine | SpaceBetweenSiblings, - TypeLiteralMembers = MultiLine | Indented, + SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings | Indented, + MultiLineTypeLiteralMembers = MultiLine | Indented, + TupleTypeElements = CommaDelimited | SpaceBetweenSiblings | SingleLine | Indented, UnionTypeConstituents = BarDelimited | SpaceBetweenSiblings | SingleLine, IntersectionTypeConstituents = AmpersandDelimited | SpaceBetweenSiblings | SingleLine, - ObjectBindingPatternElements = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings, + ObjectBindingPatternElements = SingleLine | CommaDelimited | SpaceBetweenSiblings, + ObjectBindingPatternElementsWithSpaceBetweenBraces = SingleLine | AllowTrailingComma | SpaceBetweenBraces | CommaDelimited | SpaceBetweenSiblings, ArrayBindingPatternElements = SingleLine | AllowTrailingComma | CommaDelimited | SpaceBetweenSiblings, ObjectLiteralExpressionProperties = PreserveLines | CommaDelimited | SpaceBetweenSiblings | SpaceBetweenBraces | Indented | Braces, ArrayLiteralExpressionElements = PreserveLines | CommaDelimited | SpaceBetweenSiblings | AllowTrailingComma | Indented | SquareBrackets, + CommaListElements = CommaDelimited | SpaceBetweenSiblings | SingleLine, CallExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis, NewExpressionArguments = CommaDelimited | SpaceBetweenSiblings | SingleLine | Parenthesis | OptionalIfUndefined, TemplateExpressionSpans = SingleLine | NoInterveningComments, diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index 074e6489a73..63c2028c424 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -107,15 +107,27 @@ namespace ts { // Identifiers - export function createIdentifier(text: string): Identifier { + export function createIdentifier(text: string): Identifier; + /* @internal */ + export function createIdentifier(text: string, typeArguments: TypeNode[]): Identifier; + export function createIdentifier(text: string, typeArguments?: TypeNode[]): Identifier { const node = createSynthesizedNode(SyntaxKind.Identifier); node.text = escapeIdentifier(text); node.originalKeywordKind = text ? stringToToken(text) : SyntaxKind.Unknown; node.autoGenerateKind = GeneratedIdentifierKind.None; node.autoGenerateId = 0; + if (typeArguments) { + node.typeArguments = createNodeArray(typeArguments); + } return node; } + export function updateIdentifier(node: Identifier, typeArguments: NodeArray | undefined): Identifier { + return node.typeArguments !== typeArguments + ? updateNode(createIdentifier(node.text, typeArguments), node) + : node; + } + let nextAutoGenerateId = 0; /** Create a unique temporary variable. */ @@ -214,236 +226,14 @@ namespace ts { : node; } - // Type Elements - - export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { - const signatureDeclaration = createSynthesizedNode(kind) as SignatureDeclaration; - signatureDeclaration.typeParameters = asNodeArray(typeParameters); - signatureDeclaration.parameters = asNodeArray(parameters); - signatureDeclaration.type = type; - return signatureDeclaration; - } - - function updateSignatureDeclaration(node: SignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { - return node.typeParameters !== typeParameters - || node.parameters !== parameters - || node.type !== type - ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) - : node; - } - - export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { - return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode; - } - - export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { - return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode; - } - - export function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createCallSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { - return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration; - } - - export function updateCallSignatureDeclaration(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createConstructSignatureDeclaration(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { - return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration; - } - - export function updateConstructSignatureDeclaration(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { - return updateSignatureDeclaration(node, typeParameters, parameters, type); - } - - export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined) { - const methodSignature = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature; - methodSignature.name = asName(name); - methodSignature.questionToken = questionToken; - return methodSignature; - } - - export function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined) { - return node.typeParameters !== typeParameters - || node.parameters !== parameters - || node.type !== type - || node.name !== name - || node.questionToken !== questionToken - ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) - : node; - } - - // Types - - export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]) { - return createSynthesizedNode(kind); - } - - export function createThisTypeNode() { - return createSynthesizedNode(SyntaxKind.ThisType); - } - - export function createLiteralTypeNode(literal: Expression) { - const literalTypeNode = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; - literalTypeNode.literal = literal; - return literalTypeNode; - } - - export function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression) { - return node.literal !== literal - ? updateNode(createLiteralTypeNode(literal), node) - : node; - } - - export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined) { - const typeReference = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; - typeReference.typeName = asName(typeName); - typeReference.typeArguments = asNodeArray(typeArguments); - return typeReference; - } - - export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined) { - return node.typeName !== typeName - || node.typeArguments !== typeArguments - ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) - : node; - } - - export function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode) { - const typePredicateNode = createSynthesizedNode(SyntaxKind.TypePredicate) as TypePredicateNode; - typePredicateNode.parameterName = asName(parameterName); - typePredicateNode.type = type; - return typePredicateNode; - } - - export function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode) { - return node.parameterName !== parameterName - || node.type !== type - ? updateNode(createTypePredicateNode(parameterName, type), node) - : node; - } - - export function createTypeQueryNode(exprName: EntityName) { - const typeQueryNode = createSynthesizedNode(SyntaxKind.TypeQuery) as TypeQueryNode; - typeQueryNode.exprName = exprName; - return typeQueryNode; - } - - export function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName) { - return node.exprName !== exprName ? updateNode(createTypeQueryNode(exprName), node) : node; - } - - export function createArrayTypeNode(elementType: TypeNode) { - const arrayTypeNode = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; - arrayTypeNode.elementType = elementType; - return arrayTypeNode; - } - - export function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode { - return node.elementType !== elementType - ? updateNode(createArrayTypeNode(elementType), node) - : node; - } - - export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType, types: TypeNode[]): UnionTypeNode; - export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.IntersectionType, types: TypeNode[]): IntersectionTypeNode; - export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]): UnionOrIntersectionTypeNode; - export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]) { - const unionTypeNode = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode; - unionTypeNode.types = createNodeArray(types); - return unionTypeNode; - } - - export function updateUnionOrIntersectionTypeNode(node: UnionOrIntersectionTypeNode, types: NodeArray) { - return node.types !== types - ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) - : node; - } - - export function createTypeLiteralNode(members: TypeElement[]) { - const typeLiteralNode = createSynthesizedNode(SyntaxKind.TypeLiteral) as TypeLiteralNode; - typeLiteralNode.members = createNodeArray(members); - return typeLiteralNode; - } - - export function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray) { - return node.members !== members - ? updateNode(createTypeLiteralNode(members), node) - : node; - } - - export function createTupleTypeNode(elementTypes: TypeNode[]) { - const tupleTypeNode = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; - tupleTypeNode.elementTypes = createNodeArray(elementTypes); - return tupleTypeNode; - } - - export function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]) { - return node.elementTypes !== elementTypes - ? updateNode(createTupleTypeNode(elementTypes), node) - : node; - } - - export function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { - const mappedTypeNode = createSynthesizedNode(SyntaxKind.MappedType) as MappedTypeNode; - mappedTypeNode.readonlyToken = readonlyToken; - mappedTypeNode.typeParameter = typeParameter; - mappedTypeNode.questionToken = questionToken; - mappedTypeNode.type = type; - return mappedTypeNode; - } - - export function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { - return node.readonlyToken !== readonlyToken - || node.typeParameter !== typeParameter - || node.questionToken !== questionToken - || node.type !== type - ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) - : node; - } - - export function createTypeOperatorNode(type: TypeNode) { - const typeOperatorNode = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; - typeOperatorNode.operator = SyntaxKind.KeyOfKeyword; - typeOperatorNode.type = type; - return typeOperatorNode; - } - - export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) { - return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; - } - - export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { - const indexedAccessTypeNode = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode; - indexedAccessTypeNode.objectType = objectType; - indexedAccessTypeNode.indexType = indexType; - return indexedAccessTypeNode; - } - - export function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) { - return node.objectType !== objectType - || node.indexType !== indexType - ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) - : node; - } - - // Type Declarations + // Signature elements export function createTypeParameterDeclaration(name: string | Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) { - const typeParameter = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; - typeParameter.name = asName(name); - typeParameter.constraint = constraint; - typeParameter.default = defaultType; - - return typeParameter; + const node = createSynthesizedNode(SyntaxKind.TypeParameter) as TypeParameterDeclaration; + node.name = asName(name); + node.constraint = constraint; + node.default = defaultType; + return node; } export function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined) { @@ -454,46 +244,6 @@ namespace ts { : node; } - // Signature elements - - export function createPropertySignature(name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { - const propertySignature = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; - propertySignature.name = asName(name); - propertySignature.questionToken = questionToken; - propertySignature.type = type; - propertySignature.initializer = initializer; - return propertySignature; - } - - export function updatePropertySignature(node: PropertySignature, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { - return node.name !== name - || node.questionToken !== questionToken - || node.type !== type - || node.initializer !== initializer - ? updateNode(createPropertySignature(name, questionToken, type, initializer), node) - : node; - } - - export function createIndexSignatureDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration { - const indexSignature = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; - indexSignature.decorators = asNodeArray(decorators); - indexSignature.modifiers = asNodeArray(modifiers); - indexSignature.parameters = createNodeArray(parameters); - indexSignature.type = type; - return indexSignature; - } - - export function updateIndexSignatureDeclaration(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode) { - return node.parameters !== parameters - || node.type !== type - || node.decorators !== decorators - || node.modifiers !== modifiers - ? updateNode(createIndexSignatureDeclaration(decorators, modifiers, parameters, type), node) - : node; - } - - // Signature elements - export function createParameter(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression) { const node = createSynthesizedNode(SyntaxKind.Parameter); node.decorators = asNodeArray(decorators); @@ -530,7 +280,28 @@ namespace ts { : node; } - // Type members + + // Type Elements + + export function createPropertySignature(modifiers: Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertySignature { + const node = createSynthesizedNode(SyntaxKind.PropertySignature) as PropertySignature; + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.questionToken = questionToken; + node.type = type; + node.initializer = initializer; + return node; + } + + export function updatePropertySignature(node: PropertySignature, modifiers: Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { + return node.modifiers !== modifiers + || node.name !== name + || node.questionToken !== questionToken + || node.type !== type + || node.initializer !== initializer + ? updateNode(createPropertySignature(modifiers, name, questionToken, type, initializer), node) + : node; + } export function createProperty(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression) { const node = createSynthesizedNode(SyntaxKind.PropertyDeclaration); @@ -553,7 +324,24 @@ namespace ts { : node; } - export function createMethodDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { + export function createMethodSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined) { + const node = createSignatureDeclaration(SyntaxKind.MethodSignature, typeParameters, parameters, type) as MethodSignature; + node.name = asName(name); + node.questionToken = questionToken; + return node; + } + + export function updateMethodSignature(node: MethodSignature, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined, name: PropertyName, questionToken: QuestionToken | undefined) { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + || node.name !== name + || node.questionToken !== questionToken + ? updateNode(createMethodSignature(typeParameters, parameters, type, name, questionToken), node) + : node; + } + + export function createMethod(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.MethodDeclaration); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); @@ -576,7 +364,7 @@ namespace ts { || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateNode(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) + ? updateNode(createMethod(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } @@ -644,6 +432,254 @@ namespace ts { : node; } + export function createCallSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.CallSignature, typeParameters, parameters, type) as CallSignatureDeclaration; + } + + export function updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructSignature(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.ConstructSignature, typeParameters, parameters, type) as ConstructSignatureDeclaration; + } + + export function updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createIndexSignature(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration { + const node = createSynthesizedNode(SyntaxKind.IndexSignature) as IndexSignatureDeclaration; + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.parameters = createNodeArray(parameters); + node.type = type; + return node; + } + + export function updateIndexSignature(node: IndexSignatureDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, parameters: ParameterDeclaration[], type: TypeNode) { + return node.parameters !== parameters + || node.type !== type + || node.decorators !== decorators + || node.modifiers !== modifiers + ? updateNode(createIndexSignature(decorators, modifiers, parameters, type), node) + : node; + } + + /* @internal */ + export function createSignatureDeclaration(kind: SyntaxKind, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + const node = createSynthesizedNode(kind) as SignatureDeclaration; + node.typeParameters = asNodeArray(typeParameters); + node.parameters = asNodeArray(parameters); + node.type = type; + return node; + } + + function updateSignatureDeclaration(node: T, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): T { + return node.typeParameters !== typeParameters + || node.parameters !== parameters + || node.type !== type + ? updateNode(createSignatureDeclaration(node.kind, typeParameters, parameters, type), node) + : node; + } + + // Types + + export function createKeywordTypeNode(kind: KeywordTypeNode["kind"]) { + return createSynthesizedNode(kind); + } + + export function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.TypePredicate) as TypePredicateNode; + node.parameterName = asName(parameterName); + node.type = type; + return node; + } + + export function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode) { + return node.parameterName !== parameterName + || node.type !== type + ? updateNode(createTypePredicateNode(parameterName, type), node) + : node; + } + + export function createTypeReferenceNode(typeName: string | EntityName, typeArguments: TypeNode[] | undefined) { + const node = createSynthesizedNode(SyntaxKind.TypeReference) as TypeReferenceNode; + node.typeName = asName(typeName); + node.typeArguments = typeArguments && parenthesizeTypeParameters(typeArguments); + return node; + } + + export function updateTypeReferenceNode(node: TypeReferenceNode, typeName: EntityName, typeArguments: NodeArray | undefined) { + return node.typeName !== typeName + || node.typeArguments !== typeArguments + ? updateNode(createTypeReferenceNode(typeName, typeArguments), node) + : node; + } + + export function createFunctionTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.FunctionType, typeParameters, parameters, type) as FunctionTypeNode; + } + + export function updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createConstructorTypeNode(typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined) { + return createSignatureDeclaration(SyntaxKind.ConstructorType, typeParameters, parameters, type) as ConstructorTypeNode; + } + + export function updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) { + return updateSignatureDeclaration(node, typeParameters, parameters, type); + } + + export function createTypeQueryNode(exprName: EntityName) { + const node = createSynthesizedNode(SyntaxKind.TypeQuery) as TypeQueryNode; + node.exprName = exprName; + return node; + } + + export function updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName) { + return node.exprName !== exprName + ? updateNode(createTypeQueryNode(exprName), node) + : node; + } + + export function createTypeLiteralNode(members: TypeElement[]) { + const node = createSynthesizedNode(SyntaxKind.TypeLiteral) as TypeLiteralNode; + node.members = createNodeArray(members); + return node; + } + + export function updateTypeLiteralNode(node: TypeLiteralNode, members: NodeArray) { + return node.members !== members + ? updateNode(createTypeLiteralNode(members), node) + : node; + } + + export function createArrayTypeNode(elementType: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.ArrayType) as ArrayTypeNode; + node.elementType = parenthesizeElementTypeMember(elementType); + return node; + } + + export function updateArrayTypeNode(node: ArrayTypeNode, elementType: TypeNode): ArrayTypeNode { + return node.elementType !== elementType + ? updateNode(createArrayTypeNode(elementType), node) + : node; + } + + export function createTupleTypeNode(elementTypes: TypeNode[]) { + const node = createSynthesizedNode(SyntaxKind.TupleType) as TupleTypeNode; + node.elementTypes = createNodeArray(elementTypes); + return node; + } + + export function updateTypleTypeNode(node: TupleTypeNode, elementTypes: TypeNode[]) { + return node.elementTypes !== elementTypes + ? updateNode(createTupleTypeNode(elementTypes), node) + : node; + } + + export function createUnionTypeNode(types: TypeNode[]): UnionTypeNode { + return createUnionOrIntersectionTypeNode(SyntaxKind.UnionType, types); + } + + export function updateUnionTypeNode(node: UnionTypeNode, types: NodeArray) { + return updateUnionOrIntersectionTypeNode(node, types); + } + + export function createIntersectionTypeNode(types: TypeNode[]): IntersectionTypeNode { + return createUnionOrIntersectionTypeNode(SyntaxKind.IntersectionType, types); + } + + export function updateIntersectionTypeNode(node: IntersectionTypeNode, types: NodeArray) { + return updateUnionOrIntersectionTypeNode(node, types); + } + + export function createUnionOrIntersectionTypeNode(kind: SyntaxKind.UnionType | SyntaxKind.IntersectionType, types: TypeNode[]) { + const node = createSynthesizedNode(kind) as UnionTypeNode | IntersectionTypeNode; + node.types = parenthesizeElementTypeMembers(types); + return node; + } + + function updateUnionOrIntersectionTypeNode(node: T, types: NodeArray): T { + return node.types !== types + ? updateNode(createUnionOrIntersectionTypeNode(node.kind, types), node) + : node; + } + + export function createParenthesizedType(type: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.ParenthesizedType); + node.type = type; + return node; + } + + export function updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode) { + return node.type !== type + ? updateNode(createParenthesizedType(type), node) + : node; + } + + export function createThisTypeNode() { + return createSynthesizedNode(SyntaxKind.ThisType); + } + + export function createTypeOperatorNode(type: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.TypeOperator) as TypeOperatorNode; + node.operator = SyntaxKind.KeyOfKeyword; + node.type = parenthesizeElementTypeMember(type); + return node; + } + + export function updateTypeOperatorNode(node: TypeOperatorNode, type: TypeNode) { + return node.type !== type ? updateNode(createTypeOperatorNode(type), node) : node; + } + + export function createIndexedAccessTypeNode(objectType: TypeNode, indexType: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.IndexedAccessType) as IndexedAccessTypeNode; + node.objectType = parenthesizeElementTypeMember(objectType); + node.indexType = indexType; + return node; + } + + export function updateIndexedAccessTypeNode(node: IndexedAccessTypeNode, objectType: TypeNode, indexType: TypeNode) { + return node.objectType !== objectType + || node.indexType !== indexType + ? updateNode(createIndexedAccessTypeNode(objectType, indexType), node) + : node; + } + + export function createMappedTypeNode(readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + const node = createSynthesizedNode(SyntaxKind.MappedType) as MappedTypeNode; + node.readonlyToken = readonlyToken; + node.typeParameter = typeParameter; + node.questionToken = questionToken; + node.type = type; + return node; + } + + export function updateMappedTypeNode(node: MappedTypeNode, readonlyToken: ReadonlyToken | undefined, typeParameter: TypeParameterDeclaration, questionToken: QuestionToken | undefined, type: TypeNode | undefined): MappedTypeNode { + return node.readonlyToken !== readonlyToken + || node.typeParameter !== typeParameter + || node.questionToken !== questionToken + || node.type !== type + ? updateNode(createMappedTypeNode(readonlyToken, typeParameter, questionToken, type), node) + : node; + } + + export function createLiteralTypeNode(literal: Expression) { + const node = createSynthesizedNode(SyntaxKind.LiteralType) as LiteralTypeNode; + node.literal = literal; + return node; + } + + export function updateLiteralTypeNode(node: LiteralTypeNode, literal: Expression) { + return node.literal !== literal + ? updateNode(createLiteralTypeNode(literal), node) + : node; + } + // Binding Patterns export function createObjectBindingPattern(elements: BindingElement[]) { @@ -693,10 +729,7 @@ namespace ts { export function createArrayLiteral(elements?: Expression[], multiLine?: boolean) { const node = createSynthesizedNode(SyntaxKind.ArrayLiteralExpression); node.elements = parenthesizeListElements(createNodeArray(elements)); - if (multiLine) { - node.multiLine = true; - } - + if (multiLine) node.multiLine = true; return node; } @@ -709,9 +742,7 @@ namespace ts { export function createObjectLiteral(properties?: ObjectLiteralElementLike[], multiLine?: boolean) { const node = createSynthesizedNode(SyntaxKind.ObjectLiteralExpression); node.properties = createNodeArray(properties); - if (multiLine) { - node.multiLine = true; - } + if (multiLine) node.multiLine = true; return node; } @@ -761,9 +792,9 @@ namespace ts { } export function updateCall(node: CallExpression, expression: Expression, typeArguments: TypeNode[] | undefined, argumentsArray: Expression[]) { - return expression !== node.expression - || typeArguments !== node.typeArguments - || argumentsArray !== node.arguments + return node.expression !== expression + || node.typeArguments !== typeArguments + || node.arguments !== argumentsArray ? updateNode(createCall(expression, typeArguments, argumentsArray), node) : node; } @@ -1087,6 +1118,19 @@ namespace ts { : node; } + export function createMetaProperty(keywordToken: MetaProperty["keywordToken"], name: Identifier) { + const node = createSynthesizedNode(SyntaxKind.MetaProperty); + node.keywordToken = keywordToken; + node.name = name; + return node; + } + + export function updateMetaProperty(node: MetaProperty, name: Identifier) { + return node.name !== name + ? updateNode(createMetaProperty(node.keywordToken, name), node) + : node; + } + // Misc export function createTemplateSpan(expression: Expression, literal: TemplateMiddle | TemplateTail) { @@ -1103,6 +1147,10 @@ namespace ts { : node; } + export function createSemicolonClassElement() { + return createSynthesizedNode(SyntaxKind.SemicolonClassElement); + } + // Element export function createBlock(statements: Statement[], multiLine?: boolean): Block { @@ -1113,7 +1161,7 @@ namespace ts { } export function updateBlock(node: Block, statements: Statement[]) { - return statements !== node.statements + return node.statements !== statements ? updateNode(createBlock(statements, node.multiLine), node) : node; } @@ -1133,35 +1181,6 @@ namespace ts { : node; } - export function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags) { - const node = createSynthesizedNode(SyntaxKind.VariableDeclarationList); - node.flags |= flags; - node.declarations = createNodeArray(declarations); - return node; - } - - export function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]) { - return node.declarations !== declarations - ? updateNode(createVariableDeclarationList(declarations, node.flags), node) - : node; - } - - export function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression) { - const node = createSynthesizedNode(SyntaxKind.VariableDeclaration); - node.name = asName(name); - node.type = type; - node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; - return node; - } - - export function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined) { - return node.name !== name - || node.type !== type - || node.initializer !== initializer - ? updateNode(createVariableDeclaration(name, type, initializer), node) - : node; - } - export function createEmptyStatement() { return createSynthesizedNode(SyntaxKind.EmptyStatement); } @@ -1380,6 +1399,39 @@ namespace ts { : node; } + export function createDebuggerStatement() { + return createSynthesizedNode(SyntaxKind.DebuggerStatement); + } + + export function createVariableDeclaration(name: string | BindingName, type?: TypeNode, initializer?: Expression) { + const node = createSynthesizedNode(SyntaxKind.VariableDeclaration); + node.name = asName(name); + node.type = type; + node.initializer = initializer !== undefined ? parenthesizeExpressionForList(initializer) : undefined; + return node; + } + + export function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined) { + return node.name !== name + || node.type !== type + || node.initializer !== initializer + ? updateNode(createVariableDeclaration(name, type, initializer), node) + : node; + } + + export function createVariableDeclarationList(declarations: VariableDeclaration[], flags?: NodeFlags) { + const node = createSynthesizedNode(SyntaxKind.VariableDeclarationList); + node.flags |= flags & NodeFlags.BlockScoped; + node.declarations = createNodeArray(declarations); + return node; + } + + export function updateVariableDeclarationList(node: VariableDeclarationList, declarations: VariableDeclaration[]) { + return node.declarations !== declarations + ? updateNode(createVariableDeclarationList(declarations, node.flags), node) + : node; + } + export function createFunctionDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) { const node = createSynthesizedNode(SyntaxKind.FunctionDeclaration); node.decorators = asNodeArray(decorators); @@ -1428,6 +1480,44 @@ namespace ts { : node; } + export function createInterfaceDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]) { + const node = createSynthesizedNode(SyntaxKind.InterfaceDeclaration); + node.decorators = asNodeArray(decorators); + node.modifiers = asNodeArray(modifiers); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.heritageClauses = asNodeArray(heritageClauses); + node.members = createNodeArray(members); + return node; + } + + export function updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, heritageClauses: HeritageClause[] | undefined, members: TypeElement[]) { + return node.decorators !== decorators + || node.modifiers !== modifiers + || node.name !== name + || node.typeParameters !== typeParameters + || node.heritageClauses !== heritageClauses + || node.members !== members + ? updateNode(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + : node; + } + + export function createTypeAliasDeclaration(name: string | Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) { + const node = createSynthesizedNode(SyntaxKind.TypeAliasDeclaration); + node.name = asName(name); + node.typeParameters = asNodeArray(typeParameters); + node.type = type; + return node; + } + + export function updateTypeAliasDeclaration(node: TypeAliasDeclaration, name: Identifier, typeParameters: TypeParameterDeclaration[] | undefined, type: TypeNode) { + return node.name !== name + || node.typeParameters !== typeParameters + || node.type !== type + ? updateNode(createTypeAliasDeclaration(name, typeParameters, type), node) + : node; + } + export function createEnumDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, members: EnumMember[]) { const node = createSynthesizedNode(SyntaxKind.EnumDeclaration); node.decorators = asNodeArray(decorators); @@ -1448,7 +1538,7 @@ namespace ts { export function createModuleDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags) { const node = createSynthesizedNode(SyntaxKind.ModuleDeclaration); - node.flags |= flags; + node.flags |= flags & (NodeFlags.Namespace | NodeFlags.NestedNamespace | NodeFlags.GlobalAugmentation); node.decorators = asNodeArray(decorators); node.modifiers = asNodeArray(modifiers); node.name = name; @@ -1489,6 +1579,18 @@ namespace ts { : node; } + export function createNamespaceExportDeclaration(name: string | Identifier) { + const node = createSynthesizedNode(SyntaxKind.NamespaceExportDeclaration); + node.name = asName(name); + return node; + } + + export function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier) { + return node.name !== name + ? updateNode(createNamespaceExportDeclaration(name), node) + : node; + } + export function createImportEqualsDeclaration(decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, name: string | Identifier, moduleReference: ModuleReference) { const node = createSynthesizedNode(SyntaxKind.ImportEqualsDeclaration); node.decorators = asNodeArray(decorators); @@ -1519,7 +1621,8 @@ namespace ts { export function updateImportDeclaration(node: ImportDeclaration, decorators: Decorator[] | undefined, modifiers: Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression | undefined) { return node.decorators !== decorators || node.modifiers !== modifiers - || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier + || node.importClause !== importClause + || node.moduleSpecifier !== moduleSpecifier ? updateNode(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node) : node; } @@ -1709,19 +1812,6 @@ namespace ts { : node; } - export function createJsxAttributes(properties: JsxAttributeLike[]) { - const jsxAttributes = createSynthesizedNode(SyntaxKind.JsxAttributes); - jsxAttributes.properties = createNodeArray(properties); - return jsxAttributes; - } - - export function updateJsxAttributes(jsxAttributes: JsxAttributes, properties: JsxAttributeLike[]) { - if (jsxAttributes.properties !== properties) { - return updateNode(createJsxAttributes(properties), jsxAttributes); - } - return jsxAttributes; - } - export function createJsxAttribute(name: Identifier, initializer: StringLiteral | JsxExpression) { const node = createSynthesizedNode(SyntaxKind.JsxAttribute); node.name = name; @@ -1736,6 +1826,18 @@ namespace ts { : node; } + export function createJsxAttributes(properties: JsxAttributeLike[]) { + const node = createSynthesizedNode(SyntaxKind.JsxAttributes); + node.properties = createNodeArray(properties); + return node; + } + + export function updateJsxAttributes(node: JsxAttributes, properties: JsxAttributeLike[]) { + return node.properties !== properties + ? updateNode(createJsxAttributes(properties), node) + : node; + } + export function createJsxSpreadAttribute(expression: Expression) { const node = createSynthesizedNode(SyntaxKind.JsxSpreadAttribute); node.expression = expression; @@ -1763,20 +1865,6 @@ namespace ts { // Clauses - export function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]) { - const node = createSynthesizedNode(SyntaxKind.HeritageClause); - node.token = token; - node.types = createNodeArray(types); - return node; - } - - export function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]) { - if (node.types !== types) { - return updateNode(createHeritageClause(node.token, types), node); - } - return node; - } - export function createCaseClause(expression: Expression, statements: Statement[]) { const node = createSynthesizedNode(SyntaxKind.CaseClause); node.expression = parenthesizeExpressionForList(expression); @@ -1785,10 +1873,10 @@ namespace ts { } export function updateCaseClause(node: CaseClause, expression: Expression, statements: Statement[]) { - if (node.expression !== expression || node.statements !== statements) { - return updateNode(createCaseClause(expression, statements), node); - } - return node; + return node.expression !== expression + || node.statements !== statements + ? updateNode(createCaseClause(expression, statements), node) + : node; } export function createDefaultClause(statements: Statement[]) { @@ -1798,12 +1886,24 @@ namespace ts { } export function updateDefaultClause(node: DefaultClause, statements: Statement[]) { - if (node.statements !== statements) { - return updateNode(createDefaultClause(statements), node); - } + return node.statements !== statements + ? updateNode(createDefaultClause(statements), node) + : node; + } + + export function createHeritageClause(token: HeritageClause["token"], types: ExpressionWithTypeArguments[]) { + const node = createSynthesizedNode(SyntaxKind.HeritageClause); + node.token = token; + node.types = createNodeArray(types); return node; } + export function updateHeritageClause(node: HeritageClause, types: ExpressionWithTypeArguments[]) { + return node.types !== types + ? updateNode(createHeritageClause(node.token, types), node) + : node; + } + export function createCatchClause(variableDeclaration: string | VariableDeclaration, block: Block) { const node = createSynthesizedNode(SyntaxKind.CatchClause); node.variableDeclaration = typeof variableDeclaration === "string" ? createVariableDeclaration(variableDeclaration) : variableDeclaration; @@ -1812,10 +1912,10 @@ namespace ts { } export function updateCatchClause(node: CatchClause, variableDeclaration: VariableDeclaration, block: Block) { - if (node.variableDeclaration !== variableDeclaration || node.block !== block) { - return updateNode(createCatchClause(variableDeclaration, block), node); - } - return node; + return node.variableDeclaration !== variableDeclaration + || node.block !== block + ? updateNode(createCatchClause(variableDeclaration, block), node) + : node; } // Property assignments @@ -1829,10 +1929,10 @@ namespace ts { } export function updatePropertyAssignment(node: PropertyAssignment, name: PropertyName, initializer: Expression) { - if (node.name !== name || node.initializer !== initializer) { - return updateNode(createPropertyAssignment(name, initializer), node); - } - return node; + return node.name !== name + || node.initializer !== initializer + ? updateNode(createPropertyAssignment(name, initializer), node) + : node; } export function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression) { @@ -1843,10 +1943,10 @@ namespace ts { } export function updateShorthandPropertyAssignment(node: ShorthandPropertyAssignment, name: Identifier, objectAssignmentInitializer: Expression | undefined) { - if (node.name !== name || node.objectAssignmentInitializer !== objectAssignmentInitializer) { - return updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node); - } - return node; + return node.name !== name + || node.objectAssignmentInitializer !== objectAssignmentInitializer + ? updateNode(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node) + : node; } export function createSpreadAssignment(expression: Expression) { @@ -1856,10 +1956,9 @@ namespace ts { } export function updateSpreadAssignment(node: SpreadAssignment, expression: Expression) { - if (node.expression !== expression) { - return updateNode(createSpreadAssignment(expression), node); - } - return node; + return node.expression !== expression + ? updateNode(createSpreadAssignment(expression), node) + : node; } // Enum @@ -1992,6 +2091,30 @@ namespace ts { return node; } + function flattenCommaElements(node: Expression): Expression | Expression[] { + if (nodeIsSynthesized(node) && !isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) { + if (node.kind === SyntaxKind.CommaListExpression) { + return (node).elements; + } + if (isBinaryExpression(node) && node.operatorToken.kind === SyntaxKind.CommaToken) { + return [node.left, node.right]; + } + } + return node; + } + + export function createCommaList(elements: Expression[]) { + const node = createSynthesizedNode(SyntaxKind.CommaListExpression); + node.elements = createNodeArray(sameFlatMap(elements, flattenCommaElements)); + return node; + } + + export function updateCommaList(node: CommaListExpression, elements: Expression[]) { + return node.elements !== elements + ? updateNode(createCommaList(elements), node) + : node; + } + export function createBundle(sourceFiles: SourceFile[]) { const node = createNode(SyntaxKind.Bundle); node.sourceFiles = sourceFiles; @@ -2380,6 +2503,25 @@ namespace ts { /* @internal */ namespace ts { + export const nullTransformationContext: TransformationContext = { + enableEmitNotification: noop, + enableSubstitution: noop, + endLexicalEnvironment: () => undefined, + getCompilerOptions: notImplemented, + getEmitHost: notImplemented, + getEmitResolver: notImplemented, + hoistFunctionDeclaration: noop, + hoistVariableDeclaration: noop, + isEmitNotificationEnabled: notImplemented, + isSubstitutionEnabled: notImplemented, + onEmitNode: noop, + onSubstituteNode: notImplemented, + readEmitHelpers: notImplemented, + requestEmitHelper: noop, + resumeLexicalEnvironment: noop, + startLexicalEnvironment: noop, + suspendLexicalEnvironment: noop + }; // Compound nodes @@ -2780,7 +2922,11 @@ namespace ts { } export function inlineExpressions(expressions: Expression[]) { - return reduceLeft(expressions, createComma); + // Avoid deeply nested comma expressions as traversing them during emit can result in "Maximum call + // stack size exceeded" errors. + return expressions.length > 10 + ? createCommaList(expressions) + : reduceLeft(expressions, createComma); } export function createExpressionFromEntityName(node: EntityName | Expression): Expression { @@ -2937,6 +3083,28 @@ namespace ts { ); } + /** + * Gets the internal name of a declaration. This is primarily used for declarations that can be + * referred to by name in the body of an ES5 class function body. An internal name will *never* + * be prefixed with an module or namespace export modifier like "exports." when emitted as an + * expression. An internal name will also *never* be renamed due to a collision with a block + * scoped variable. + * + * @param node The declaration. + * @param allowComments A value indicating whether comments may be emitted for the name. + * @param allowSourceMaps A value indicating whether source maps may be emitted for the name. + */ + export function getInternalName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean) { + return getName(node, allowComments, allowSourceMaps, EmitFlags.LocalName | EmitFlags.InternalName); + } + + /** + * Gets whether an identifier should only be referred to by its internal name. + */ + export function isInternalName(node: Identifier) { + return (getEmitFlags(node) & EmitFlags.InternalName) !== 0; + } + /** * Gets the local name of a declaration. This is primarily used for declarations that can be * referred to by name in the declaration's immediate scope (classes, enums, namespaces). A @@ -2992,9 +3160,10 @@ namespace ts { } function getName(node: Declaration, allowComments?: boolean, allowSourceMaps?: boolean, emitFlags?: EmitFlags) { - if (node.name && isIdentifier(node.name) && !isGeneratedIdentifier(node.name)) { - const name = getMutableClone(node.name); - emitFlags |= getEmitFlags(node.name); + const nodeName = getNameOfDeclaration(node); + if (nodeName && isIdentifier(nodeName) && !isGeneratedIdentifier(nodeName)) { + const name = getMutableClone(nodeName); + emitFlags |= getEmitFlags(nodeName); if (!allowSourceMaps) emitFlags |= EmitFlags.NoSourceMap; if (!allowComments) emitFlags |= EmitFlags.NoComments; if (emitFlags) setEmitFlags(name, emitFlags); @@ -3153,16 +3322,6 @@ namespace ts { return statements; } - export function parenthesizeConditionalHead(condition: Expression) { - const conditionalPrecedence = getOperatorPrecedence(SyntaxKind.ConditionalExpression, SyntaxKind.QuestionToken); - const emittedCondition = skipPartiallyEmittedExpressions(condition); - const conditionPrecedence = getExpressionPrecedence(emittedCondition); - if (compareValues(conditionPrecedence, conditionalPrecedence) === Comparison.LessThan) { - return createParen(condition); - } - return condition; - } - /** * Wraps the operand to a BinaryExpression in parentheses if they are needed to preserve the intended * order of operations. @@ -3464,6 +3623,35 @@ namespace ts { return expression; } + export function parenthesizeElementTypeMember(member: TypeNode) { + switch (member.kind) { + case SyntaxKind.UnionType: + case SyntaxKind.IntersectionType: + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return createParenthesizedType(member); + } + return member; + } + + export function parenthesizeElementTypeMembers(members: TypeNode[]) { + return createNodeArray(sameMap(members, parenthesizeElementTypeMember)); + } + + export function parenthesizeTypeParameters(typeParameters: TypeNode[]) { + if (some(typeParameters)) { + const nodeArray = createNodeArray() as NodeArray; + for (let i = 0; i < typeParameters.length; ++i) { + const entry = typeParameters[i]; + nodeArray.push(i === 0 && isFunctionOrConstructorTypeNode(entry) && entry.typeParameters ? + createParenthesizedType(entry) : + entry); + } + + return nodeArray; + } + } + /** * Clones a series of not-emitted expressions with a new inner expression. * @@ -3670,7 +3858,7 @@ namespace ts { if (file.moduleName) { return createLiteral(file.moduleName); } - if (!isDeclarationFile(file) && (options.out || options.outFile)) { + if (!file.isDeclarationFile && (options.out || options.outFile)) { return createLiteral(getExternalModuleNameFromPath(host, file.fileName)); } return undefined; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index d511b31b331..12a42b6899c 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -2,7 +2,6 @@ /// namespace ts { - /* @internal */ export function trace(host: ModuleResolutionHost, message: DiagnosticMessage, ...args: any[]): void; export function trace(host: ModuleResolutionHost): void { @@ -15,6 +14,7 @@ namespace ts { } /** Array that is only intended to be pushed to, never read. */ + /* @internal */ export interface Push { push(value: T): void; } @@ -47,13 +47,11 @@ namespace ts { return resolved.path; } - /** Adds `isExernalLibraryImport` to a Resolved to get a ResolvedModule. */ - function resolvedModuleFromResolved({ path, extension }: Resolved, isExternalLibraryImport: boolean): ResolvedModuleFull { - return { resolvedFileName: path, extension, isExternalLibraryImport }; - } - function createResolvedModuleWithFailedLookupLocations(resolved: Resolved | undefined, isExternalLibraryImport: boolean, failedLookupLocations: string[]): ResolvedModuleWithFailedLookupLocations { - return { resolvedModule: resolved && resolvedModuleFromResolved(resolved, isExternalLibraryImport), failedLookupLocations }; + return { + resolvedModule: resolved && { resolvedFileName: resolved.path, extension: resolved.extension, isExternalLibraryImport }, + failedLookupLocations + }; } export function moduleHasNonRelativeName(moduleName: string): boolean { @@ -442,6 +440,8 @@ namespace ts { case ModuleResolutionKind.Classic: result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache); break; + default: + Debug.fail(`Unexpected moduleResolution: ${moduleResolution}`); } if (perFolderCache) { @@ -675,12 +675,25 @@ namespace ts { } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache): ResolvedModuleWithFailedLookupLocations { - return nodeModuleNameResolverWorker(moduleName, containingFile, compilerOptions, host, cache, /*jsOnly*/ false); + return nodeModuleNameResolverWorker(moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, /*jsOnly*/ false); } + /** + * Expose resolution logic to allow us to use Node module resolution logic from arbitrary locations. + * No way to do this with `require()`: https://github.com/nodejs/node/issues/5963 + * Throws an error if the module can't be resolved. + */ /* @internal */ - export function nodeModuleNameResolverWorker(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, jsOnly = false): ResolvedModuleWithFailedLookupLocations { - const containingDirectory = getDirectoryPath(containingFile); + export function resolveJavaScriptModule(moduleName: string, initialDir: string, host: ModuleResolutionHost): string { + const { resolvedModule, failedLookupLocations } = + nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, /*cache*/ undefined, /*jsOnly*/ true); + if (!resolvedModule) { + throw new Error(`Could not resolve JS module ${moduleName} starting at ${initialDir}. Looked in: ${failedLookupLocations.join(", ")}`); + } + return resolvedModule.resolvedFileName; + } + + function nodeModuleNameResolverWorker(moduleName: string, containingDirectory: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache: ModuleResolutionCache | undefined, jsOnly: boolean): ResolvedModuleWithFailedLookupLocations { const traceEnabled = isTraceEnabled(compilerOptions, host); const failedLookupLocations: string[] = []; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index d355ff24583..2d9806bcbf4 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -23,19 +23,19 @@ namespace ts { } } - function visitNode(cbNode: (node: Node) => T, node: Node): T { + function visitNode(cbNode: (node: Node) => T, node: Node): T | undefined { if (node) { return cbNode(node); } } - function visitNodeArray(cbNodes: (nodes: Node[]) => T, nodes: Node[]) { + function visitNodeArray(cbNodes: (nodes: Node[]) => T, nodes: Node[]): T | undefined { if (nodes) { return cbNodes(nodes); } } - function visitEachNode(cbNode: (node: Node) => T, nodes: Node[]) { + function visitEachNode(cbNode: (node: Node) => T, nodes: Node[]): T | undefined { if (nodes) { for (const node of nodes) { const result = cbNode(node); @@ -50,7 +50,7 @@ namespace ts { // stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise, // embedded arrays are flattened and the 'cbNode' callback is invoked for each element. If a callback returns // a truthy value, iteration stops and that value is returned. Otherwise, undefined is returned. - export function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T { + export function forEachChild(node: Node, cbNode: (node: Node) => T, cbNodeArray?: (nodes: Node[]) => T): T | undefined { if (!node) { return; } @@ -362,6 +362,8 @@ namespace ts { return visitNode(cbNode, (node).expression); case SyntaxKind.MissingDeclaration: return visitNodes(cbNodes, node.decorators); + case SyntaxKind.CommaListExpression: + return visitNodes(cbNodes, (node).elements); case SyntaxKind.JsxElement: return visitNode(cbNode, (node).openingElement) || @@ -6502,6 +6504,8 @@ namespace ts { case "augments": tag = parseAugmentsTag(atToken, tagName); break; + case "arg": + case "argument": case "param": tag = parseParamTag(atToken, tagName); break; diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 347e6e97ebd..2fde21afec6 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -241,6 +241,101 @@ namespace ts { return output; } + const redForegroundEscapeSequence = "\u001b[91m"; + const yellowForegroundEscapeSequence = "\u001b[93m"; + const blueForegroundEscapeSequence = "\u001b[93m"; + const gutterStyleSequence = "\u001b[100;30m"; + const gutterSeparator = " "; + const resetEscapeSequence = "\u001b[0m"; + const ellipsis = "..."; + function getCategoryFormat(category: DiagnosticCategory): string { + switch (category) { + case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; + case DiagnosticCategory.Error: return redForegroundEscapeSequence; + case DiagnosticCategory.Message: return blueForegroundEscapeSequence; + } + } + + function formatAndReset(text: string, formatStyle: string) { + return formatStyle + text + resetEscapeSequence; + } + + function padLeft(s: string, length: number) { + while (s.length < length) { + s = " " + s; + } + return s; + } + + export function formatDiagnosticsWithColorAndContext(diagnostics: Diagnostic[], host: FormatDiagnosticsHost): string { + let output = ""; + for (const diagnostic of diagnostics) { + if (diagnostic.file) { + const { start, length, file } = diagnostic; + const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); + const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); + const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line; + const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName; + + const hasMoreThanFiveLines = (lastLine - firstLine) >= 4; + let gutterWidth = (lastLine + 1 + "").length; + if (hasMoreThanFiveLines) { + gutterWidth = Math.max(ellipsis.length, gutterWidth); + } + + output += sys.newLine; + for (let i = firstLine; i <= lastLine; i++) { + // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, + // so we'll skip ahead to the second-to-last line. + if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { + output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine; + i = lastLine - 1; + } + + const lineStart = getPositionOfLineAndCharacter(file, i, 0); + const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; + let lineContent = file.text.slice(lineStart, lineEnd); + lineContent = lineContent.replace(/\s+$/g, ""); // trim from end + lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces + + // Output the gutter and the actual contents of the line. + output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; + output += lineContent + sys.newLine; + + // Output the gutter and the error span for the line using tildes. + output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; + output += redForegroundEscapeSequence; + if (i === firstLine) { + // If we're on the last line, then limit it to the last character of the last line. + // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. + const lastCharForLine = i === lastLine ? lastLineChar : undefined; + + output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); + output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); + } + else if (i === lastLine) { + output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); + } + else { + // Squiggle the entire line. + output += lineContent.replace(/./g, "~"); + } + output += resetEscapeSequence; + + output += sys.newLine; + } + + output += sys.newLine; + output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; + } + + const categoryColor = getCategoryFormat(diagnostic.category); + const category = DiagnosticCategory[diagnostic.category].toLowerCase(); + output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; + } + return output; + } + export function flattenDiagnosticMessageText(messageText: string | DiagnosticMessageChain, newLine: string): string { if (typeof messageText === "string") { return messageText; @@ -298,6 +393,7 @@ namespace ts { let diagnosticsProducingTypeChecker: TypeChecker; let noDiagnosticsTypeChecker: TypeChecker; let classifiableNames: Map; + let modifiedFilePaths: Path[] | undefined; const cachedSemanticDiagnosticsForFile: DiagnosticCache = {}; const cachedDeclarationDiagnosticsForFile: DiagnosticCache = {}; @@ -367,7 +463,8 @@ namespace ts { // used to track cases when two file names differ only in casing const filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? createFileMap(fileName => fileName.toLowerCase()) : undefined; - if (!tryReuseStructureFromOldProgram()) { + const structuralIsReused = tryReuseStructureFromOldProgram(); + if (structuralIsReused !== StructureIsReused.Completely) { forEach(rootNames, name => processRootFile(name, /*isDefaultLib*/ false)); // load type declarations specified via 'types' argument or implicitly from types/ and node_modules/@types folders @@ -476,89 +573,114 @@ namespace ts { } interface OldProgramState { - program: Program; + program: Program | undefined; file: SourceFile; + /** The collection of paths modified *since* the old program. */ modifiedFilePaths: Path[]; } - function resolveModuleNamesReusingOldState(moduleNames: string[], containingFile: string, file: SourceFile, oldProgramState?: OldProgramState) { - if (!oldProgramState && !file.ambientModuleNames.length) { - // if old program state is not supplied and file does not contain locally defined ambient modules - // then the best we can do is fallback to the default logic + function resolveModuleNamesReusingOldState(moduleNames: string[], containingFile: string, file: SourceFile, oldProgramState: OldProgramState) { + if (structuralIsReused === StructureIsReused.Not && !file.ambientModuleNames.length) { + // If the old program state does not permit reusing resolutions and `file` does not contain locally defined ambient modules, + // the best we can do is fallback to the default logic. return resolveModuleNamesWorker(moduleNames, containingFile); } - // at this point we know that either + const oldSourceFile = oldProgramState.program && oldProgramState.program.getSourceFile(containingFile); + if (oldSourceFile !== file && file.resolvedModules) { + // `file` was created for the new program. + // + // We only set `file.resolvedModules` via work from the current function, + // so it is defined iff we already called the current function on `file`. + // That call happened no later than the creation of the `file` object, + // which per above occured during the current program creation. + // Since we assume the filesystem does not change during program creation, + // it is safe to reuse resolutions from the earlier call. + const result: ResolvedModuleFull[] = []; + for (const moduleName of moduleNames) { + const resolvedModule = file.resolvedModules.get(moduleName); + result.push(resolvedModule); + } + return result; + } + // At this point, we know at least one of the following hold: // - file has local declarations for ambient modules - // OR // - old program state is available - // OR - // - both of items above - // With this it is possible that we can tell how some module names from the initial list will be resolved - // without doing actual resolution (in particular if some name was resolved to ambient module). - // Such names should be excluded from the list of module names that will be provided to `resolveModuleNamesWorker` - // since we don't want to resolve them again. + // With this information, we can infer some module resolutions without performing resolution. - // this is a list of modules for which we cannot predict resolution so they should be actually resolved + /** An ordered list of module names for which we cannot recover the resolution. */ let unknownModuleNames: string[]; - // this is a list of combined results assembles from predicted and resolved results. - // Order in this list matches the order in the original list of module names `moduleNames` which is important - // so later we can split results to resolutions of modules and resolutions of module augmentations. + /** + * The indexing of elements in this list matches that of `moduleNames`. + * + * Before combining results, result[i] is in one of the following states: + * * undefined: needs to be recomputed, + * * predictedToResolveToAmbientModuleMarker: known to be an ambient module. + * Needs to be reset to undefined before returning, + * * ResolvedModuleFull instance: can be reused. + */ let result: ResolvedModuleFull[]; - // a transient placeholder that is used to mark predicted resolution in the result list + /** A transient placeholder used to mark predicted resolution in the result list. */ const predictedToResolveToAmbientModuleMarker: ResolvedModuleFull = {}; + for (let i = 0; i < moduleNames.length; i++) { const moduleName = moduleNames[i]; - // module name is known to be resolved to ambient module if - // - module name is contained in the list of ambient modules that are locally declared in the file - // - in the old program module name was resolved to ambient module whose declaration is in non-modified file + // If we want to reuse resolutions more aggressively, we can refine this to check for whether the + // text of the corresponding modulenames has changed. + if (file === oldSourceFile) { + const oldResolvedModule = oldSourceFile && oldSourceFile.resolvedModules.get(moduleName); + if (oldResolvedModule) { + if (isTraceEnabled(options, host)) { + trace(host, Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, containingFile); + } + (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule; + continue; + } + } + // We know moduleName resolves to an ambient module provided that moduleName: + // - is in the list of ambient modules locally declared in the current source file. + // - resolved to an ambient module in the old program whose declaration is in an unmodified file // (so the same module declaration will land in the new program) - let isKnownToResolveToAmbientModule = false; + let resolvesToAmbientModuleInNonModifiedFile = false; if (contains(file.ambientModuleNames, moduleName)) { - isKnownToResolveToAmbientModule = true; + resolvesToAmbientModuleInNonModifiedFile = true; if (isTraceEnabled(options, host)) { trace(host, Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, containingFile); } } else { - isKnownToResolveToAmbientModule = checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); + resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName, oldProgramState); } - if (isKnownToResolveToAmbientModule) { - if (!unknownModuleNames) { - // found a first module name for which result can be prediced - // this means that this module name should not be passed to `resolveModuleNamesWorker`. - // We'll use a separate list for module names that are definitely unknown. - result = new Array(moduleNames.length); - // copy all module names that appear before the current one in the list - // since they are known to be unknown - unknownModuleNames = moduleNames.slice(0, i); - } - // mark prediced resolution in the result list - result[i] = predictedToResolveToAmbientModuleMarker; + if (resolvesToAmbientModuleInNonModifiedFile) { + (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker; } - else if (unknownModuleNames) { - // found unknown module name and we are already using separate list for those - add it to the list - unknownModuleNames.push(moduleName); + else { + // Resolution failed in the old program, or resolved to an ambient module for which we can't reuse the result. + (unknownModuleNames || (unknownModuleNames = [])).push(moduleName); } } - if (!unknownModuleNames) { - // we've looked throught the list but have not seen any predicted resolution - // use default logic - return resolveModuleNamesWorker(moduleNames, containingFile); - } - - const resolutions = unknownModuleNames.length + const resolutions = unknownModuleNames && unknownModuleNames.length ? resolveModuleNamesWorker(unknownModuleNames, containingFile) : emptyArray; - // combine results of resolutions and predicted results + // Combine results of resolutions and predicted results + if (!result) { + // There were no unresolved/ambient resolutions. + Debug.assert(resolutions.length === moduleNames.length); + return resolutions; + } + let j = 0; for (let i = 0; i < result.length; i++) { - if (result[i] === predictedToResolveToAmbientModuleMarker) { - result[i] = undefined; + if (result[i]) { + // `result[i]` is either a `ResolvedModuleFull` or a marker. + // If it is the former, we can leave it as is. + if (result[i] === predictedToResolveToAmbientModuleMarker) { + result[i] = undefined; + } } else { result[i] = resolutions[j]; @@ -566,18 +688,18 @@ namespace ts { } } Debug.assert(j === resolutions.length); + return result; - function checkModuleNameResolvedToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState?: OldProgramState): boolean { - if (!oldProgramState) { - return false; - } + // If we change our policy of rechecking failed lookups on each program create, + // we should adjust the value returned here. + function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName: string, oldProgramState: OldProgramState): boolean { const resolutionToFile = getResolvedModule(oldProgramState.file, moduleName); if (resolutionToFile) { // module used to be resolved to file - ignore it return false; } - const ambientModule = oldProgram.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); + const ambientModule = oldProgramState.program && oldProgramState.program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(moduleName); if (!(ambientModule && ambientModule.declarations)) { return false; } @@ -599,99 +721,107 @@ namespace ts { } } - function tryReuseStructureFromOldProgram(): boolean { + function tryReuseStructureFromOldProgram(): StructureIsReused { if (!oldProgram) { - return false; + return StructureIsReused.Not; } // check properties that can affect structure of the program or module resolution strategy // if any of these properties has changed - structure cannot be reused const oldOptions = oldProgram.getCompilerOptions(); if (changesAffectModuleResolution(oldOptions, options)) { - return false; + return oldProgram.structureIsReused = StructureIsReused.Not; } - Debug.assert(!oldProgram.structureIsReused); + Debug.assert(!(oldProgram.structureIsReused & (StructureIsReused.Completely | StructureIsReused.SafeModules))); // there is an old program, check if we can reuse its structure const oldRootNames = oldProgram.getRootFileNames(); if (!arrayIsEqualTo(oldRootNames, rootNames)) { - return false; + return oldProgram.structureIsReused = StructureIsReused.Not; } if (!arrayIsEqualTo(options.types, oldOptions.types)) { - return false; + return oldProgram.structureIsReused = StructureIsReused.Not; } // check if program source files has changed in the way that can affect structure of the program const newSourceFiles: SourceFile[] = []; const filePaths: Path[] = []; const modifiedSourceFiles: { oldFile: SourceFile, newFile: SourceFile }[] = []; + oldProgram.structureIsReused = StructureIsReused.Completely; for (const oldSourceFile of oldProgram.getSourceFiles()) { - let newSourceFile = host.getSourceFileByPath + const newSourceFile = host.getSourceFileByPath ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.path, options.target) : host.getSourceFile(oldSourceFile.fileName, options.target); if (!newSourceFile) { - return false; + return oldProgram.structureIsReused = StructureIsReused.Not; } newSourceFile.path = oldSourceFile.path; filePaths.push(newSourceFile.path); if (oldSourceFile !== newSourceFile) { + // The `newSourceFile` object was created for the new program. + if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) { // value of no-default-lib has changed // this will affect if default library is injected into the list of files - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; } // check tripleslash references if (!arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) { // tripleslash references has changed - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; } // check imports and module augmentations collectExternalModuleReferences(newSourceFile); if (!arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) { // imports has changed - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; } if (!arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) { // moduleAugmentations has changed - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; } if (!arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) { // 'types' references has changed - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; } // tentatively approve the file modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile }); } - else { - // file has no changes - use it as is - newSourceFile = oldSourceFile; - } // if file has passed all checks it should be safe to reuse it newSourceFiles.push(newSourceFile); } - const modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path); + if (oldProgram.structureIsReused !== StructureIsReused.Completely) { + return oldProgram.structureIsReused; + } + + modifiedFilePaths = modifiedSourceFiles.map(f => f.newFile.path); // try to verify results of module resolution for (const { oldFile: oldSourceFile, newFile: newSourceFile } of modifiedSourceFiles) { const newSourceFilePath = getNormalizedAbsolutePath(newSourceFile.fileName, currentDirectory); if (resolveModuleNamesWorker) { const moduleNames = map(concatenate(newSourceFile.imports, newSourceFile.moduleAugmentations), getTextOfLiteral); - const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, { file: oldSourceFile, program: oldProgram, modifiedFilePaths }); + const oldProgramState = { program: oldProgram, file: oldSourceFile, modifiedFilePaths }; + const resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFilePath, newSourceFile, oldProgramState); // ensure that module resolution results are still correct const resolutionsChanged = hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, moduleResolutionIsEqualTo); if (resolutionsChanged) { - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; + newSourceFile.resolvedModules = zipToMap(moduleNames, resolutions); + } + else { + newSourceFile.resolvedModules = oldSourceFile.resolvedModules; } } if (resolveTypeReferenceDirectiveNamesWorker) { @@ -700,12 +830,17 @@ namespace ts { // ensure that types resolutions are still correct const resolutionsChanged = hasChangesInResolutions(typesReferenceDirectives, resolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, typeDirectiveIsEqualTo); if (resolutionsChanged) { - return false; + oldProgram.structureIsReused = StructureIsReused.SafeModules; + newSourceFile.resolvedTypeReferenceDirectiveNames = zipToMap(typesReferenceDirectives, resolutions); + } + else { + newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; } } - // pass the cache of module/types resolutions from the old source file - newSourceFile.resolvedModules = oldSourceFile.resolvedModules; - newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames; + } + + if (oldProgram.structureIsReused !== StructureIsReused.Completely) { + return oldProgram.structureIsReused; } // update fileName -> file mapping @@ -720,9 +855,8 @@ namespace ts { fileProcessingDiagnostics.reattachFileDiagnostics(modifiedFile.newFile); } resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives(); - oldProgram.structureIsReused = true; - return true; + return oldProgram.structureIsReused = StructureIsReused.Completely; } function getEmitHost(writeFileCallback?: WriteFileCallback): EmitHost { @@ -1175,7 +1309,7 @@ namespace ts { } function getDeclarationDiagnosticsForFile(sourceFile: SourceFile, cancellationToken: CancellationToken): Diagnostic[] { - return isDeclarationFile(sourceFile) ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); + return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken); } function getOptionsDiagnostics(): Diagnostic[] { @@ -1214,7 +1348,6 @@ namespace ts { const isJavaScriptFile = isSourceFileJavaScript(file); const isExternalModuleFile = isExternalModule(file); - const isDtsFile = isDeclarationFile(file); let imports: LiteralExpression[]; let moduleAugmentations: LiteralExpression[]; @@ -1267,7 +1400,7 @@ namespace ts { } break; case SyntaxKind.ModuleDeclaration: - if (isAmbientModule(node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || isDeclarationFile(file))) { + if (isAmbientModule(node) && (inAmbientModule || hasModifier(node, ModifierFlags.Ambient) || file.isDeclarationFile)) { const moduleName = (node).name; // Ambient module declarations can be interpreted as augmentations for some existing external modules. // This will happen in two cases: @@ -1278,7 +1411,7 @@ namespace ts { (moduleAugmentations || (moduleAugmentations = [])).push(moduleName); } else if (!inAmbientModule) { - if (isDtsFile) { + if (file.isDeclarationFile) { // for global .d.ts files record name of ambient module (ambientModules || (ambientModules = [])).push(moduleName.text); } @@ -1528,11 +1661,11 @@ namespace ts { function processImportedModules(file: SourceFile) { collectExternalModuleReferences(file); if (file.imports.length || file.moduleAugmentations.length) { - file.resolvedModules = createMap(); // Because global augmentation doesn't have string literal name, we can check for global augmentation as such. const nonGlobalAugmentation = filter(file.moduleAugmentations, (moduleAugmentation) => moduleAugmentation.kind === SyntaxKind.StringLiteral); const moduleNames = map(concatenate(file.imports, nonGlobalAugmentation), getTextOfLiteral); - const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file); + const oldProgramState = { program: oldProgram, file, modifiedFilePaths }; + const resolutions = resolveModuleNamesReusingOldState(moduleNames, getNormalizedAbsolutePath(file.fileName, currentDirectory), file, oldProgramState); Debug.assert(resolutions.length === moduleNames.length); for (let i = 0; i < moduleNames.length; i++) { const resolution = resolutions[i]; @@ -1596,7 +1729,7 @@ namespace ts { const absoluteRootDirectoryPath = host.getCanonicalFileName(getNormalizedAbsolutePath(rootDirectory, currentDirectory)); for (const sourceFile of sourceFiles) { - if (!isDeclarationFile(sourceFile)) { + if (!sourceFile.isDeclarationFile) { const absoluteSourceFilePath = host.getCanonicalFileName(getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory)); if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, sourceFile.fileName, options.rootDir)); @@ -1709,13 +1842,13 @@ namespace ts { const languageVersion = options.target || ScriptTarget.ES3; const outFile = options.outFile || options.out; - const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); + const firstNonAmbientExternalModuleSourceFile = forEach(files, f => isExternalModule(f) && !f.isDeclarationFile ? f : undefined); if (options.isolatedModules) { if (options.module === ModuleKind.None && languageVersion < ScriptTarget.ES2015) { programDiagnostics.add(createCompilerDiagnostic(Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher)); } - const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !isDeclarationFile(f) ? f : undefined); + const firstNonExternalModuleSourceFile = forEach(files, f => !isExternalModule(f) && !f.isDeclarationFile ? f : undefined); if (firstNonExternalModuleSourceFile) { const span = getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile); programDiagnostics.add(createFileDiagnostic(firstNonExternalModuleSourceFile, span.start, span.length, Diagnostics.Cannot_compile_namespaces_when_the_isolatedModules_flag_is_provided)); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 659c2f416ab..d27bbf879fe 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -712,11 +712,11 @@ namespace ts { return accumulator; } - export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) { + export function forEachLeadingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined { return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ false, cb, state); } - export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T) { + export function forEachTrailingCommentRange(text: string, pos: number, cb: (pos: number, end: number, kind: CommentKind, hasTrailingNewLine: boolean, state: T) => U, state?: T): U | undefined { return iterateCommentRanges(/*reduce*/ false, text, pos, /*trailing*/ true, cb, state); } @@ -746,10 +746,11 @@ namespace ts { } /** Optionally, get the shebang */ - export function getShebang(text: string): string { - return shebangTriviaRegex.test(text) - ? shebangTriviaRegex.exec(text)[0] - : undefined; + export function getShebang(text: string): string | undefined { + const match = shebangTriviaRegex.exec(text); + if (match) { + return match[0]; + } } export function isIdentifierStart(ch: number, languageVersion: ScriptTarget): boolean { diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index bb1732b57ea..75f9c43c6fe 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -165,7 +165,7 @@ namespace ts { }; function transformRoot(node: T) { - return node && (!isSourceFile(node) || !isDeclarationFile(node)) ? transformation(node) : node; + return node && (!isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node; } /** diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 3ac5dc5d878..63c10145165 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -295,7 +295,7 @@ namespace ts { return transformSourceFile; function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } @@ -813,7 +813,7 @@ namespace ts { // Create a synthetic text range for the return statement. const closingBraceLocation = createTokenRange(skipTrivia(currentText, node.members.end), SyntaxKind.CloseBraceToken); - const localName = getLocalName(node); + const localName = getInternalName(node); // The following partially-emitted expression exists purely to align our sourcemap // emit with the original emitter. @@ -870,7 +870,7 @@ namespace ts { /*decorators*/ undefined, /*modifiers*/ undefined, /*asteriskToken*/ undefined, - getDeclarationName(node), + getInternalName(node), /*typeParameters*/ undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), /*type*/ undefined, @@ -2009,13 +2009,14 @@ namespace ts { } else { assignment = createBinary(decl.name, SyntaxKind.EqualsToken, visitNode(decl.initializer, visitor, isExpression)); + setTextRange(assignment, decl); } assignments = append(assignments, assignment); } } if (assignments) { - updated = setTextRange(createStatement(reduceLeft(assignments, (acc, v) => createBinary(v, SyntaxKind.CommaToken, acc))), node); + updated = setTextRange(createStatement(inlineExpressions(assignments)), node); } else { // none of declarations has initializer - the entire variable statement can be deleted @@ -3180,7 +3181,20 @@ namespace ts { const savedConvertedLoopState = convertedLoopState; convertedLoopState = undefined; const ancestorFacts = enterSubtree(HierarchyFacts.FunctionExcludes, HierarchyFacts.FunctionIncludes); - const updated = visitEachChild(node, visitor, context); + let updated: AccessorDeclaration; + if (node.transformFlags & TransformFlags.ContainsCapturedLexicalThis) { + const parameters = visitParameterList(node.parameters, visitor, context); + const body = transformFunctionBody(node); + if (node.kind === SyntaxKind.GetAccessor) { + updated = updateGetAccessor(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + } + else { + updated = updateSetAccessor(node, node.decorators, node.modifiers, node.name, parameters, body); + } + } + else { + updated = visitEachChild(node, visitor, context); + } exitSubtree(ancestorFacts, HierarchyFacts.PropagateNewTargetMask, HierarchyFacts.None); convertedLoopState = savedConvertedLoopState; return updated; @@ -3712,7 +3726,7 @@ namespace ts { function substituteIdentifier(node: Identifier) { // Only substitute the identifier if we have enabled substitutions for block-scoped // bindings. - if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { + if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings && !isInternalName(node)) { const original = getParseTreeNode(node, isIdentifier); if (original && isNameOfDeclarationWithCollidingName(original)) { return setTextRange(getGeneratedNameForNode(original), node); @@ -3735,7 +3749,7 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.EnumDeclaration: case SyntaxKind.VariableDeclaration: - return (parent).name === node + return (parent).name === node && resolver.isDeclarationWithCollidingName(parent); } @@ -3765,16 +3779,42 @@ namespace ts { * @param node An Identifier node. */ function substituteExpressionIdentifier(node: Identifier): Identifier { - if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings) { + if (enabledSubstitutions & ES2015SubstitutionFlags.BlockScopedBindings && !isInternalName(node)) { const declaration = resolver.getReferencedDeclarationWithCollidingName(node); - if (declaration) { - return setTextRange(getGeneratedNameForNode(declaration.name), node); + if (declaration && !(isClassLike(declaration) && isPartOfClassBody(declaration, node))) { + return setTextRange(getGeneratedNameForNode(getNameOfDeclaration(declaration)), node); } } return node; } + function isPartOfClassBody(declaration: ClassLikeDeclaration, node: Identifier) { + let currentNode = getParseTreeNode(node); + if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) { + // if the node has no correlation to a parse tree node, its definitely not + // part of the body. + // if the node is outside of the document range of the declaration, its + // definitely not part of the body. + return false; + } + const blockScope = getEnclosingBlockScopeContainer(declaration); + while (currentNode) { + if (currentNode === blockScope || currentNode === declaration) { + // if we are in the enclosing block scope of the declaration, we are definitely + // not inside the class body. + return false; + } + if (isClassElement(currentNode) && currentNode.parent === declaration) { + // we are in the class body, but we treat static fields as outside of the class body + return currentNode.kind !== SyntaxKind.PropertyDeclaration + || (getModifierFlags(currentNode) & ModifierFlags.Static) === 0; + } + currentNode = currentNode.parent; + } + return false; + } + /** * Substitutes `this` when contained within an arrow function. * @@ -3789,8 +3829,9 @@ namespace ts { } function getClassMemberPrefix(node: ClassExpression | ClassDeclaration, member: ClassElement) { - const expression = getLocalName(node); - return hasModifier(member, ModifierFlags.Static) ? expression : createPropertyAccess(expression, "prototype"); + return hasModifier(member, ModifierFlags.Static) + ? getInternalName(node) + : createPropertyAccess(getInternalName(node), "prototype"); } function hasSynthesizedDefaultSuperCall(constructor: ConstructorDeclaration, hasExtendsClause: boolean) { diff --git a/src/compiler/transformers/es2016.ts b/src/compiler/transformers/es2016.ts index 1118e6ad9b6..a9468991776 100644 --- a/src/compiler/transformers/es2016.ts +++ b/src/compiler/transformers/es2016.ts @@ -9,7 +9,7 @@ namespace ts { return transformSourceFile; function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 3bbb3b3123f..3565547d78a 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -47,7 +47,7 @@ namespace ts { return transformSourceFile; function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 3aa5be551a6..6e2f70b5c35 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -33,7 +33,7 @@ namespace ts { return transformSourceFile; function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } @@ -106,15 +106,11 @@ namespace ts { } } - function visitAwaitExpression(node: AwaitExpression) { + function visitAwaitExpression(node: AwaitExpression): Expression { if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) { - const expression = visitNode(node.expression, visitor, isExpression); return setOriginalNode( setTextRange( - createYield( - /*asteriskToken*/ undefined, - createArrayLiteral([createLiteral("await"), expression]) - ), + createYield(createAwaitHelper(context, visitNode(node.expression, visitor, isExpression))), /*location*/ node ), node @@ -124,18 +120,26 @@ namespace ts { } function visitYieldExpression(node: YieldExpression) { - if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator) { + if (enclosingFunctionFlags & FunctionFlags.Async && enclosingFunctionFlags & FunctionFlags.Generator && node.asteriskToken) { const expression = visitNode(node.expression, visitor, isExpression); - return updateYield( - node, - node.asteriskToken, - node.asteriskToken - ? createAsyncDelegatorHelper(context, expression, expression) - : createArrayLiteral( - expression - ? [createLiteral("yield"), expression] - : [createLiteral("yield")] - ) + return setOriginalNode( + setTextRange( + createYield( + createAwaitHelper(context, + updateYield( + node, + node.asteriskToken, + createAsyncDelegatorHelper( + context, + createAsyncValuesHelper(context, expression, expression), + expression + ) + ) + ) + ), + node + ), + node ); } return visitEachChild(node, visitor, context); @@ -347,6 +351,10 @@ namespace ts { ); } + function awaitAsYield(expression: Expression) { + return createYield(/*asteriskToken*/ undefined, enclosingFunctionFlags & FunctionFlags.Generator ? createAwaitHelper(context, expression) : expression); + } + function transformForAwaitOfStatement(node: ForOfStatement, outermostLabeledStatement: LabeledStatement) { const expression = visitNode(node.expression, visitor, isExpression); const iterator = isIdentifier(expression) ? getGeneratedNameForNode(expression) : createTempVariable(/*recordTempVariable*/ undefined); @@ -354,16 +362,11 @@ namespace ts { const errorRecord = createUniqueName("e"); const catchVariable = getGeneratedNameForNode(errorRecord); const returnMethod = createTempVariable(/*recordTempVariable*/ undefined); - const values = createAsyncValuesHelper(context, expression, /*location*/ node.expression); - const next = createYield( - /*asteriskToken*/ undefined, - enclosingFunctionFlags & FunctionFlags.Generator - ? createArrayLiteral([ - createLiteral("await"), - createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) - ]) - : createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []) - ); + const callValues = createAsyncValuesHelper(context, expression, /*location*/ node.expression); + const callNext = createCall(createPropertyAccess(iterator, "next" ), /*typeArguments*/ undefined, []); + const getDone = createPropertyAccess(result, "done"); + const getValue = createPropertyAccess(result, "value"); + const callReturn = createFunctionCall(returnMethod, iterator, []); hoistVariableDeclaration(errorRecord); hoistVariableDeclaration(returnMethod); @@ -374,16 +377,19 @@ namespace ts { /*initializer*/ setEmitFlags( setTextRange( createVariableDeclarationList([ - setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, values), node.expression), - createVariableDeclaration(result, /*type*/ undefined, next) + setTextRange(createVariableDeclaration(iterator, /*type*/ undefined, callValues), node.expression), + createVariableDeclaration(result) ]), node.expression ), EmitFlags.NoHoisting ), - /*condition*/ createLogicalNot(createPropertyAccess(result, "done")), - /*incrementor*/ createAssignment(result, next), - /*statement*/ convertForOfStatementHead(node, createPropertyAccess(result, "value")) + /*condition*/ createComma( + createAssignment(result, awaitAsYield(callNext)), + createLogicalNot(getDone) + ), + /*incrementor*/ undefined, + /*statement*/ convertForOfStatementHead(node, awaitAsYield(getValue)) ), /*location*/ node ), @@ -421,26 +427,14 @@ namespace ts { createLogicalAnd( createLogicalAnd( result, - createLogicalNot( - createPropertyAccess(result, "done") - ) + createLogicalNot(getDone) ), createAssignment( returnMethod, createPropertyAccess(iterator, "return") ) ), - createStatement( - createYield( - /*asteriskToken*/ undefined, - enclosingFunctionFlags & FunctionFlags.Generator - ? createArrayLiteral([ - createLiteral("await"), - createFunctionCall(returnMethod, iterator, []) - ]) - : createFunctionCall(returnMethod, iterator, []) - ) - ) + createStatement(awaitAsYield(callReturn)) ), EmitFlags.SingleLine ) @@ -880,27 +874,39 @@ namespace ts { ); } + const awaitHelper: EmitHelper = { + name: "typescript:await", + scoped: false, + text: ` + var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } + ` + }; + + function createAwaitHelper(context: TransformationContext, expression: Expression) { + context.requestEmitHelper(awaitHelper); + return createCall(getHelperName("__await"), /*typeArguments*/ undefined, [expression]); + } + const asyncGeneratorHelper: EmitHelper = { name: "typescript:asyncGenerator", scoped: false, text: ` var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), q = [], c, i; - return i = { next: verb("next"), "throw": verb("throw"), "return": verb("return") }, i[Symbol.asyncIterator] = function () { return this; }, i; - function verb(n) { return function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]), next(); }); }; } - function next() { if (!c && q.length) resume((c = q.shift())[0], c[1]); } - function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(c[3], e); } } - function step(r) { r.done ? settle(c[2], r) : Promise.resolve(r.value[1]).then(r.value[0] === "yield" ? send : fulfill, reject); } - function send(value) { settle(c[2], { value: value, done: false }); } + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } - function settle(f, v) { c = void 0, f(v), next(); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } }; ` }; function createAsyncGeneratorHelper(context: TransformationContext, generatorFunc: FunctionExpression) { + context.requestEmitHelper(awaitHelper); context.requestEmitHelper(asyncGeneratorHelper); // Mark this node as originally an async function @@ -922,16 +928,16 @@ namespace ts { scoped: false, text: ` var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { - var i = { next: verb("next"), "throw": verb("throw", function (e) { throw e; }), "return": verb("return", function (v) { return { value: v, done: true }; }) }, p; - return o = __asyncValues(o), i[Symbol.iterator] = function () { return this; }, i; - function verb(n, f) { return function (v) { return v = p && n === "throw" ? f(v) : p && v.done ? v : { value: p ? ["yield", v.value] : ["await", (o[n] || f).call(o, v)], done: false }, p = !p, v; }; } + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { if (o[n]) i[n] = function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; }; } }; ` }; function createAsyncDelegatorHelper(context: TransformationContext, expression: Expression, location?: TextRange) { + context.requestEmitHelper(awaitHelper); context.requestEmitHelper(asyncDelegator); - context.requestEmitHelper(asyncValues); return setTextRange( createCall( getHelperName("__asyncDelegator"), diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 286892f9d3b..9aadd6bc686 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -293,8 +293,7 @@ namespace ts { return transformSourceFile; function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node) - || (node.transformFlags & TransformFlags.ContainsGenerator) === 0) { + if (node.isDeclarationFile || (node.transformFlags & TransformFlags.ContainsGenerator) === 0) { return node; } diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index e9455490a5d..09f361d1b13 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -15,7 +15,7 @@ namespace ts { * @param node A SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } diff --git a/src/compiler/transformers/module/es2015.ts b/src/compiler/transformers/module/es2015.ts index 660293e074f..3951d08109d 100644 --- a/src/compiler/transformers/module/es2015.ts +++ b/src/compiler/transformers/module/es2015.ts @@ -16,7 +16,7 @@ namespace ts { return transformSourceFile; function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index d387a1a3a24..b3e544a3f8b 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -55,7 +55,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node) || !(isExternalModule(node) || compilerOptions.isolatedModules)) { + if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 5711d9f1116..3355ad35633 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -50,9 +50,7 @@ namespace ts { * @param node The SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node) - || !(isExternalModule(node) - || compilerOptions.isolatedModules)) { + if (node.isDeclarationFile || !(isExternalModule(node) || compilerOptions.isolatedModules)) { return node; } diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 5b0623094c3..cc7f89acfb8 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -76,7 +76,7 @@ namespace ts { * @param node A SourceFile node. */ function transformSourceFile(node: SourceFile) { - if (isDeclarationFile(node)) { + if (node.isDeclarationFile) { return node; } @@ -1762,23 +1762,19 @@ namespace ts { } function serializeUnionOrIntersectionType(node: UnionOrIntersectionTypeNode): SerializedTypeNode { + // Note when updating logic here also update getEntityNameForDecoratorMetadata + // so that aliases can be marked as referenced let serializedUnion: SerializedTypeNode; for (const typeNode of node.types) { const serializedIndividual = serializeTypeNode(typeNode); - if (isVoidExpression(serializedIndividual)) { - // If we dont have any other type already set, set the initial type - if (!serializedUnion) { - serializedUnion = serializedIndividual; - } - } - else if (isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { + if (isIdentifier(serializedIndividual) && serializedIndividual.text === "Object") { // One of the individual is global object, return immediately return serializedIndividual; } // If there exists union that is not void 0 expression, check if the the common type is identifier. // anything more complex and we will just default to Object - else if (serializedUnion && !isVoidExpression(serializedUnion)) { + else if (serializedUnion) { // Different types if (!isIdentifier(serializedUnion) || !isIdentifier(serializedIndividual) || @@ -2606,14 +2602,16 @@ namespace ts { * Adds a leading VariableStatement for a enum or module declaration. */ function addVarForEnumOrModuleDeclaration(statements: Statement[], node: ModuleDeclaration | EnumDeclaration) { - // Emit a variable statement for the module. + // Emit a variable statement for the module. We emit top-level enums as a `var` + // declaration to avoid static errors in global scripts scripts due to redeclaration. + // enums in any other scope are emitted as a `let` declaration. const statement = createVariableStatement( visitNodes(node.modifiers, modifierVisitor, isModifier), - [ + createVariableDeclarationList([ createVariableDeclaration( getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) ) - ] + ], currentScope.kind === SyntaxKind.SourceFile ? NodeFlags.None : NodeFlags.Let) ); setOriginalNode(statement, node); @@ -2925,7 +2923,7 @@ namespace ts { function visitExportDeclaration(node: ExportDeclaration): VisitResult { if (!node.exportClause) { // Elide a star export if the module it references does not export a value. - return resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; + return compilerOptions.isolatedModules || resolver.moduleExportsSomeValue(node.moduleSpecifier) ? node : undefined; } if (!resolver.isValueAliasDeclaration(node)) { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index 8981da65ba3..834c7326e22 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -60,93 +60,8 @@ namespace ts { sys.write(ts.formatDiagnostics([diagnostic], host)); } - const redForegroundEscapeSequence = "\u001b[91m"; - const yellowForegroundEscapeSequence = "\u001b[93m"; - const blueForegroundEscapeSequence = "\u001b[93m"; - const gutterStyleSequence = "\u001b[100;30m"; - const gutterSeparator = " "; - const resetEscapeSequence = "\u001b[0m"; - const ellipsis = "..."; - function getCategoryFormat(category: DiagnosticCategory): string { - switch (category) { - case DiagnosticCategory.Warning: return yellowForegroundEscapeSequence; - case DiagnosticCategory.Error: return redForegroundEscapeSequence; - case DiagnosticCategory.Message: return blueForegroundEscapeSequence; - } - } - - function formatAndReset(text: string, formatStyle: string) { - return formatStyle + text + resetEscapeSequence; - } - function reportDiagnosticWithColorAndContext(diagnostic: Diagnostic, host: FormatDiagnosticsHost): void { - let output = ""; - - if (diagnostic.file) { - const { start, length, file } = diagnostic; - const { line: firstLine, character: firstLineChar } = getLineAndCharacterOfPosition(file, start); - const { line: lastLine, character: lastLineChar } = getLineAndCharacterOfPosition(file, start + length); - const lastLineInFile = getLineAndCharacterOfPosition(file, file.text.length).line; - const relativeFileName = host ? convertToRelativePath(file.fileName, host.getCurrentDirectory(), fileName => host.getCanonicalFileName(fileName)) : file.fileName; - - const hasMoreThanFiveLines = (lastLine - firstLine) >= 4; - let gutterWidth = (lastLine + 1 + "").length; - if (hasMoreThanFiveLines) { - gutterWidth = Math.max(ellipsis.length, gutterWidth); - } - - output += sys.newLine; - for (let i = firstLine; i <= lastLine; i++) { - // If the error spans over 5 lines, we'll only show the first 2 and last 2 lines, - // so we'll skip ahead to the second-to-last line. - if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) { - output += formatAndReset(padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + sys.newLine; - i = lastLine - 1; - } - - const lineStart = getPositionOfLineAndCharacter(file, i, 0); - const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length; - let lineContent = file.text.slice(lineStart, lineEnd); - lineContent = lineContent.replace(/\s+$/g, ""); // trim from end - lineContent = lineContent.replace("\t", " "); // convert tabs to single spaces - - // Output the gutter and the actual contents of the line. - output += formatAndReset(padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += lineContent + sys.newLine; - - // Output the gutter and the error span for the line using tildes. - output += formatAndReset(padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator; - output += redForegroundEscapeSequence; - if (i === firstLine) { - // If we're on the last line, then limit it to the last character of the last line. - // Otherwise, we'll just squiggle the rest of the line, giving 'slice' no end position. - const lastCharForLine = i === lastLine ? lastLineChar : undefined; - - output += lineContent.slice(0, firstLineChar).replace(/\S/g, " "); - output += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~"); - } - else if (i === lastLine) { - output += lineContent.slice(0, lastLineChar).replace(/./g, "~"); - } - else { - // Squiggle the entire line. - output += lineContent.replace(/./g, "~"); - } - output += resetEscapeSequence; - - output += sys.newLine; - } - - output += sys.newLine; - output += `${ relativeFileName }(${ firstLine + 1 },${ firstLineChar + 1 }): `; - } - - const categoryColor = getCategoryFormat(diagnostic.category); - const category = DiagnosticCategory[diagnostic.category].toLowerCase(); - output += `${ formatAndReset(category, categoryColor) } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }`; - output += sys.newLine + sys.newLine; - - sys.write(output); + sys.write(ts.formatDiagnosticsWithColorAndContext([diagnostic], host) + sys.newLine + sys.newLine); } function reportWatchDiagnostic(diagnostic: Diagnostic) { diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 55b5492b43e..567cfa7f773 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -389,6 +389,7 @@ namespace ts { // Transformation nodes NotEmittedStatement, PartiallyEmittedExpression, + CommaListExpression, MergeDeclarationMarker, EndOfDeclarationMarker, @@ -571,11 +572,16 @@ namespace ts { export interface Identifier extends PrimaryExpression { kind: SyntaxKind.Identifier; - text: string; // Text of identifier (with escapes converted to characters) - originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later + /** + * Text of identifier (with escapes converted to characters). + * If the identifier begins with two underscores, this will begin with three. + */ + text: string; + originalKeywordKind?: SyntaxKind; // Original syntaxKind which get set so that we can report an error later /*@internal*/ autoGenerateKind?: GeneratedIdentifierKind; // Specifies whether to auto-generate the text for an identifier. - /*@internal*/ autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name. - isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace + /*@internal*/ autoGenerateId?: number; // Ensures unique generated identifiers get unique names, but clones get the same name. + isInJSDocNamespace?: boolean; // if the node is a member in a JSDoc namespace + /*@internal*/ typeArguments?: NodeArray; // Only defined on synthesized nodes. Though not syntactically valid, used in emitting diagnostics. } // Transient identifier node (marked by id === -1) @@ -605,10 +611,13 @@ namespace ts { export interface Declaration extends Node { _declarationBrand: any; + } + + export interface NamedDeclaration extends Declaration { name?: DeclarationName; } - export interface DeclarationStatement extends Declaration, Statement { + export interface DeclarationStatement extends NamedDeclaration, Statement { name?: Identifier | StringLiteral | NumericLiteral; } @@ -622,7 +631,7 @@ namespace ts { expression: LeftHandSideExpression; } - export interface TypeParameterDeclaration extends Declaration { + export interface TypeParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.TypeParameter; parent?: DeclarationWithTypeParameters; name: Identifier; @@ -633,7 +642,7 @@ namespace ts { expression?: Expression; } - export interface SignatureDeclaration extends Declaration { + export interface SignatureDeclaration extends NamedDeclaration { name?: PropertyName; typeParameters?: NodeArray; parameters: NodeArray; @@ -650,7 +659,7 @@ namespace ts { export type BindingName = Identifier | BindingPattern; - export interface VariableDeclaration extends Declaration { + export interface VariableDeclaration extends NamedDeclaration { kind: SyntaxKind.VariableDeclaration; parent?: VariableDeclarationList | CatchClause; name: BindingName; // Declared variable name @@ -664,7 +673,7 @@ namespace ts { declarations: NodeArray; } - export interface ParameterDeclaration extends Declaration { + export interface ParameterDeclaration extends NamedDeclaration { kind: SyntaxKind.Parameter; parent?: SignatureDeclaration; dotDotDotToken?: DotDotDotToken; // Present on rest parameter @@ -674,7 +683,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface BindingElement extends Declaration { + export interface BindingElement extends NamedDeclaration { kind: SyntaxKind.BindingElement; parent?: BindingPattern; propertyName?: PropertyName; // Binding property name (in object binding pattern) @@ -699,7 +708,7 @@ namespace ts { initializer?: Expression; // Optional initializer } - export interface ObjectLiteralElement extends Declaration { + export interface ObjectLiteralElement extends NamedDeclaration { _objectLiteralBrandBrand: any; name?: PropertyName; } @@ -743,7 +752,7 @@ namespace ts { // SyntaxKind.ShorthandPropertyAssignment // SyntaxKind.EnumMember // SyntaxKind.JSDocPropertyTag - export interface VariableLikeDeclaration extends Declaration { + export interface VariableLikeDeclaration extends NamedDeclaration { propertyName?: PropertyName; dotDotDotToken?: DotDotDotToken; name: DeclarationName; @@ -752,7 +761,7 @@ namespace ts { initializer?: Expression; } - export interface PropertyLikeDeclaration extends Declaration { + export interface PropertyLikeDeclaration extends NamedDeclaration { name: PropertyName; } @@ -1216,8 +1225,7 @@ namespace ts { export type BinaryOperatorToken = Token; - // Binary expressions can be declarations if they are 'exports.foo = bar' expressions in JS files - export interface BinaryExpression extends Expression, Declaration { + export interface BinaryExpression extends Expression, Declaration { kind: SyntaxKind.BinaryExpression; left: Expression; operatorToken: BinaryOperatorToken; @@ -1417,7 +1425,7 @@ namespace ts { export type EntityNameExpression = Identifier | PropertyAccessEntityNameExpression | ParenthesizedExpression; export type EntityNameOrEntityNameExpression = EntityName | EntityNameExpression; - export interface PropertyAccessExpression extends MemberExpression, Declaration { + export interface PropertyAccessExpression extends MemberExpression, NamedDeclaration { kind: SyntaxKind.PropertyAccessExpression; expression: LeftHandSideExpression; name: Identifier; @@ -1506,7 +1514,7 @@ namespace ts { // for the same reasons we treat NewExpression as a PrimaryExpression. export interface MetaProperty extends PrimaryExpression { kind: SyntaxKind.MetaProperty; - keywordToken: SyntaxKind; + keywordToken: SyntaxKind.NewKeyword; name: Identifier; } @@ -1597,6 +1605,14 @@ namespace ts { kind: SyntaxKind.EndOfDeclarationMarker; } + /** + * A list of comma-seperated expressions. This node is only created by transformations. + */ + export interface CommaListExpression extends Expression { + kind: SyntaxKind.CommaListExpression; + elements: NodeArray; + } + /** * Marks the beginning of a merged transformed declaration. */ @@ -1762,7 +1778,7 @@ namespace ts { export type DeclarationWithTypeParameters = SignatureDeclaration | ClassLikeDeclaration | InterfaceDeclaration | TypeAliasDeclaration; - export interface ClassLikeDeclaration extends Declaration { + export interface ClassLikeDeclaration extends NamedDeclaration { name?: Identifier; typeParameters?: NodeArray; heritageClauses?: NodeArray; @@ -1778,12 +1794,12 @@ namespace ts { kind: SyntaxKind.ClassExpression; } - export interface ClassElement extends Declaration { + export interface ClassElement extends NamedDeclaration { _classElementBrand: any; name?: PropertyName; } - export interface TypeElement extends Declaration { + export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; name?: PropertyName; questionToken?: QuestionToken; @@ -1811,7 +1827,7 @@ namespace ts { type: TypeNode; } - export interface EnumMember extends Declaration { + export interface EnumMember extends NamedDeclaration { kind: SyntaxKind.EnumMember; parent?: EnumDeclaration; // This does include ComputedPropertyName, but the parser will give an error @@ -1900,14 +1916,14 @@ namespace ts { // import d, * as ns from "mod" => name = d, namedBinding: NamespaceImport = { name: ns } // import { a, b as x } from "mod" => name = undefined, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} // import d, { a, b as x } from "mod" => name = d, namedBinding: NamedImports = { elements: [{ name: a }, { name: x, propertyName: b}]} - export interface ImportClause extends Declaration { + export interface ImportClause extends NamedDeclaration { kind: SyntaxKind.ImportClause; parent?: ImportDeclaration; name?: Identifier; // Default binding namedBindings?: NamedImportBindings; } - export interface NamespaceImport extends Declaration { + export interface NamespaceImport extends NamedDeclaration { kind: SyntaxKind.NamespaceImport; parent?: ImportClause; name: Identifier; @@ -1940,14 +1956,14 @@ namespace ts { export type NamedImportsOrExports = NamedImports | NamedExports; - export interface ImportSpecifier extends Declaration { + export interface ImportSpecifier extends NamedDeclaration { kind: SyntaxKind.ImportSpecifier; parent?: NamedImports; propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) name: Identifier; // Declared name } - export interface ExportSpecifier extends Declaration { + export interface ExportSpecifier extends NamedDeclaration { kind: SyntaxKind.ExportSpecifier; parent?: NamedExports; propertyName?: Identifier; // Name preceding "as" keyword (or undefined when "as" is absent) @@ -2113,7 +2129,7 @@ namespace ts { typeExpression: JSDocTypeExpression; } - export interface JSDocTypedefTag extends JSDocTag, Declaration { + export interface JSDocTypedefTag extends JSDocTag, NamedDeclaration { kind: SyntaxKind.JSDocTypedefTag; fullName?: JSDocNamespaceDeclaration | Identifier; name?: Identifier; @@ -2408,7 +2424,14 @@ namespace ts { /* @internal */ getResolvedTypeReferenceDirectives(): Map; /* @internal */ isSourceFileFromExternalLibrary(file: SourceFile): boolean; // For testing purposes only. - /* @internal */ structureIsReused?: boolean; + /* @internal */ structureIsReused?: StructureIsReused; + } + + /* @internal */ + export const enum StructureIsReused { + Not = 0, + SafeModules = 1 << 0, + Completely = 1 << 1, } export interface CustomTransformers { @@ -2505,11 +2528,11 @@ namespace ts { indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration; getSymbolsInScope(location: Node, meaning: SymbolFlags): Symbol[]; - getSymbolAtLocation(node: Node): Symbol; + getSymbolAtLocation(node: Node): Symbol | undefined; getSymbolsOfParameterPropertyDeclaration(parameter: ParameterDeclaration, parameterName: string): Symbol[]; - getShorthandAssignmentValueSymbol(location: Node): Symbol; - getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol; - getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol; + getShorthandAssignmentValueSymbol(location: Node): Symbol | undefined; + getExportSpecifierLocalTargetSymbol(location: ExportSpecifier): Symbol | undefined; + getPropertySymbolOfDestructuringAssignment(location: Identifier): Symbol | undefined; getTypeAtLocation(node: Node): Type; getTypeFromTypeNode(node: TypeNode): Type; signatureToString(signature: Signature, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): string; @@ -2519,16 +2542,16 @@ namespace ts { getFullyQualifiedName(symbol: Symbol): string; getAugmentedPropertiesOfType(type: Type): Symbol[]; getRootSymbols(symbol: Symbol): Symbol[]; - getContextualType(node: Expression): Type; - getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature; - getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + getContextualType(node: Expression): Type | undefined; + getResolvedSignature(node: CallLikeExpression, candidatesOutArray?: Signature[]): Signature | undefined; + getSignatureFromDeclaration(declaration: SignatureDeclaration): Signature | undefined; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined; isUndefinedSymbol(symbol: Symbol): boolean; isArgumentsSymbol(symbol: Symbol): boolean; isUnknownSymbol(symbol: Symbol): boolean; /* @internal */ getMergedSymbol(symbol: Symbol): Symbol; - getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number; + getConstantValue(node: EnumMember | PropertyAccessExpression | ElementAccessExpression): string | number | undefined; isValidPropertyAccess(node: PropertyAccessExpression | QualifiedName, propertyName: string): boolean; /** Follow all aliases to get the original symbol. */ getAliasedSymbol(symbol: Symbol): Symbol; @@ -2538,15 +2561,18 @@ namespace ts { /** Unlike `getExportsOfModule`, this includes properties of an `export =` value. */ /* @internal */ getExportsAndPropertiesOfModule(moduleSymbol: Symbol): Symbol[]; - getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type; + getAllAttributesTypeFromJsxOpeningLikeElement(elementNode: JsxOpeningLikeElement): Type | undefined; getJsxIntrinsicTagNames(): Symbol[]; isOptionalParameter(node: ParameterDeclaration): boolean; getAmbientModules(): Symbol[]; tryGetMemberInModuleExports(memberName: string, moduleSymbol: Symbol): Symbol | undefined; getApparentType(type: Type): Type; + getSuggestionForNonexistentProperty(node: Identifier, containingType: Type): string | undefined; + getSuggestionForNonexistentSymbol(location: Node, name: string, meaning: SymbolFlags): string | undefined; + /* @internal */ getBaseConstraintOfType(type: Type): Type | undefined; - /* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol; + /* @internal */ tryFindAmbientModuleWithoutAugmentations(moduleName: string): Symbol | undefined; // Should not be called directly. Should only be accessed through the Program instance. /* @internal */ getDiagnostics(sourceFile?: SourceFile, cancellationToken?: CancellationToken): Diagnostic[]; @@ -2557,22 +2583,42 @@ namespace ts { /* @internal */ getIdentifierCount(): number; /* @internal */ getSymbolCount(): number; /* @internal */ getTypeCount(): number; + + /** + * For a union, will include a property if it's defined in *any* of the member types. + * So for `{ a } | { b }`, this will include both `a` and `b`. + */ + /* @internal */ getAllPossiblePropertiesOfType(type: Type): Symbol[]; } export enum NodeBuilderFlags { None = 0, - allowThisInObjectLiteral = 1 << 0, - allowQualifedNameInPlaceOfIdentifier = 1 << 1, - allowTypeParameterInQualifiedName = 1 << 2, - allowAnonymousIdentifier = 1 << 3, - allowEmptyUnionOrIntersection = 1 << 4, - allowEmptyTuple = 1 << 5 + // Options + NoTruncation = 1 << 0, // Don't truncate result + WriteArrayAsGenericType = 1 << 1, // Write Array instead T[] + WriteTypeArgumentsOfSignature = 1 << 5, // Write the type arguments instead of type parameters of the signature + UseFullyQualifiedType = 1 << 6, // Write out the fully qualified type name (eg. Module.Type, instead of Type) + SuppressAnyReturnType = 1 << 8, // If the return type is any-like, don't offer a return type. + WriteTypeParametersInQualifiedName = 1 << 9, + + // Error handling + AllowThisInObjectLiteral = 1 << 10, + AllowQualifedNameInPlaceOfIdentifier = 1 << 11, + AllowAnonymousIdentifier = 1 << 13, + AllowEmptyUnionOrIntersection = 1 << 14, + AllowEmptyTuple = 1 << 15, + + IgnoreErrors = AllowThisInObjectLiteral | AllowQualifedNameInPlaceOfIdentifier | AllowAnonymousIdentifier | AllowEmptyUnionOrIntersection | AllowEmptyTuple, + + // State + InObjectTypeLiteral = 1 << 20, + InTypeAlias = 1 << 23, // Writing type in type alias declaration } export interface SymbolDisplayBuilder { buildTypeDisplay(type: Type, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildSymbolDisplay(symbol: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, meaning?: SymbolFlags, flags?: SymbolFormatFlags): void; - buildSignatureDisplay(signatures: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; + buildSignatureDisplay(signature: Signature, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags, kind?: SignatureKind): void; buildIndexSignatureDisplay(info: IndexInfo, writer: SymbolWriter, kind: IndexKind, enclosingDeclaration?: Node, globalFlags?: TypeFormatFlags, symbolStack?: Symbol[]): void; buildParameterDisplay(parameter: Symbol, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; buildTypeParameterDisplay(tp: TypeParameter, writer: SymbolWriter, enclosingDeclaration?: Node, flags?: TypeFormatFlags): void; @@ -2722,12 +2768,11 @@ namespace ts { getNodeCheckFlags(node: Node): NodeCheckFlags; isDeclarationVisible(node: Declaration): boolean; collectLinkedAliases(node: Identifier): Node[]; - isImplementationOfOverload(node: FunctionLikeDeclaration): boolean; + isImplementationOfOverload(node: FunctionLikeDeclaration): boolean | undefined; isRequiredInitializedParameter(node: ParameterDeclaration): boolean; writeTypeOfDeclaration(declaration: AccessorDeclaration | VariableLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeReturnTypeOfSignatureDeclaration(signatureDeclaration: SignatureDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; writeTypeOfExpression(expr: Expression, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; - writeBaseConstructorTypeOfClass(node: ClassLikeDeclaration, enclosingDeclaration: Node, flags: TypeFormatFlags, writer: SymbolWriter): void; isSymbolAccessible(symbol: Symbol, enclosingDeclaration: Node, meaning: SymbolFlags, shouldComputeAliasToMarkVisible: boolean): SymbolAccessibilityResult; isEntityNameVisible(entityName: EntityNameOrEntityNameExpression, enclosingDeclaration: Node): SymbolVisibilityResult; // Returns the constant value this property access resolves to, or 'undefined' for a non-constant @@ -3114,7 +3159,7 @@ namespace ts { */ export interface TypeReference extends ObjectType { target: GenericType; // Type reference target - typeArguments: Type[]; // Type reference type arguments (undefined if none) + typeArguments?: Type[]; // Type reference type arguments (undefined if none) } // Generic class and interface types @@ -3244,7 +3289,7 @@ namespace ts { export interface Signature { declaration: SignatureDeclaration; // Originating declaration - typeParameters: TypeParameter[]; // Type parameters (undefined if non-generic) + typeParameters?: TypeParameter[]; // Type parameters (undefined if non-generic) parameters: Symbol[]; // Parameters /* @internal */ thisParameter?: Symbol; // symbol of this-type parameter @@ -3355,9 +3400,9 @@ namespace ts { } export interface Diagnostic { - file: SourceFile; - start: number; - length: number; + file: SourceFile | undefined; + start: number | undefined; + length: number | undefined; messageText: string | DiagnosticMessageChain; category: DiagnosticCategory; code: number; @@ -3506,7 +3551,7 @@ namespace ts { export const enum NewLineKind { CarriageReturnLineFeed = 0, - LineFeed = 1, + LineFeed = 1 } export interface LineAndCharacter { @@ -3949,14 +3994,16 @@ namespace ts { HelperName = 1 << 12, ExportName = 1 << 13, // Ensure an export prefix is added for an identifier that points to an exported declaration with a local name (see SymbolFlags.ExportHasLocal). LocalName = 1 << 14, // Ensure an export prefix is not added for an identifier that points to an exported declaration. - Indented = 1 << 15, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). - NoIndentation = 1 << 16, // Do not indent the node. - AsyncFunctionBody = 1 << 17, - ReuseTempVariableScope = 1 << 18, // Reuse the existing temp variable scope during emit. - CustomPrologue = 1 << 19, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed). - NoHoisting = 1 << 20, // Do not hoist this declaration in --module system - HasEndOfDeclarationMarker = 1 << 21, // Declaration has an associated NotEmittedStatement to mark the end of the declaration - Iterator = 1 << 22, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. + InternalName = 1 << 15, // The name is internal to an ES5 class body function. + Indented = 1 << 16, // Adds an explicit extra indentation level for class and function bodies when printing (used to match old emitter). + NoIndentation = 1 << 17, // Do not indent the node. + AsyncFunctionBody = 1 << 18, + ReuseTempVariableScope = 1 << 19, // Reuse the existing temp variable scope during emit. + CustomPrologue = 1 << 20, // Treat the statement as if it were a prologue directive (NOTE: Prologue directives are *not* transformed). + NoHoisting = 1 << 21, // Do not hoist this declaration in --module system + HasEndOfDeclarationMarker = 1 << 22, // Declaration has an associated NotEmittedStatement to mark the end of the declaration + Iterator = 1 << 23, // The expression to a `yield*` should be treated as an Iterator when down-leveling, not an Iterable. + NoAsciiEscaping = 1 << 24, // When synthesizing nodes that lack an original node or textSourceNode, we want to write the text on the node with ASCII escaping substitutions. } export interface EmitHelper { @@ -3981,11 +4028,12 @@ namespace ts { Awaiter = 1 << 6, // __awaiter (used by ES2017 async functions transformation) Generator = 1 << 7, // __generator (used by ES2015 generator transformation) Values = 1 << 8, // __values (used by ES2015 for..of and yield* transformations) - Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation) + Read = 1 << 9, // __read (used by ES2015 iterator destructuring transformation) Spread = 1 << 10, // __spread (used by ES2015 array spread and argument list spread transformations) - AsyncGenerator = 1 << 11, // __asyncGenerator (used by ES2017 async generator transformation) - AsyncDelegator = 1 << 12, // __asyncDelegator (used by ES2017 async generator yield* transformation) - AsyncValues = 1 << 13, // __asyncValues (used by ES2017 for..await..of transformation) + Await = 1 << 11, // __await (used by ES2017 async generator transformation) + AsyncGenerator = 1 << 12, // __asyncGenerator (used by ES2017 async generator transformation) + AsyncDelegator = 1 << 13, // __asyncDelegator (used by ES2017 async generator yield* transformation) + AsyncValues = 1 << 14, // __asyncValues (used by ES2017 for..await..of transformation) // Helpers included by ES2015 for..of ForOfIncludes = Values, @@ -3993,6 +4041,12 @@ namespace ts { // Helpers included by ES2017 for..await..of ForAwaitOfIncludes = AsyncValues, + // Helpers included by ES2017 async generators + AsyncGeneratorIncludes = Await | AsyncGenerator, + + // Helpers included by yield* in ES2017 async generators + AsyncDelegatorIncludes = Await | AsyncDelegator | AsyncValues, + // Helpers included by ES2015 spread SpreadIncludes = Read | Spread, @@ -4162,7 +4216,7 @@ namespace ts { * Prints a bundle of source files as-is, without any emit transformations. */ printBundle(bundle: Bundle): string; - /*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile, writer: EmitTextWriter): void; + /*@internal*/ writeNode(hint: EmitHint, node: Node, sourceFile: SourceFile | undefined, writer: EmitTextWriter): void; /*@internal*/ writeFile(sourceFile: SourceFile, writer: EmitTextWriter): void; /*@internal*/ writeBundle(bundle: Bundle, writer: EmitTextWriter): void; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 624136b26a6..2b6831f8814 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -11,12 +11,12 @@ namespace ts { isTypeReferenceDirective?: boolean; } - export function getDeclarationOfKind(symbol: Symbol, kind: SyntaxKind): Declaration { + export function getDeclarationOfKind(symbol: Symbol, kind: T["kind"]): T { const declarations = symbol.declarations; if (declarations) { for (const declaration of declarations) { if (declaration.kind === kind) { - return declaration; + return declaration as T; } } } @@ -122,9 +122,8 @@ namespace ts { /* @internal */ export function hasChangesInResolutions(names: string[], newResolutions: T[], oldResolutions: Map, comparer: (oldResolution: T, newResolution: T) => boolean): boolean { - if (names.length !== newResolutions.length) { - return false; - } + Debug.assert(names.length === newResolutions.length); + for (let i = 0; i < names.length; i++) { const newResolution = newResolutions[i]; const oldResolution = oldResolutions && oldResolutions.get(names[i]); @@ -329,19 +328,21 @@ namespace ts { return getSourceTextOfNodeFromSourceFile(sourceFile, node); } + const escapeText = getEmitFlags(node) & EmitFlags.NoAsciiEscaping ? escapeString : escapeNonAsciiString; + // If we can't reach the original source text, use the canonical form if it's a number, - // or an escaped quoted form of the original text if it's string-like. + // or a (possibly escaped) quoted form of the original text if it's string-like. switch (node.kind) { case SyntaxKind.StringLiteral: - return getQuotedEscapedLiteralText('"', node.text, '"'); + return '"' + escapeText(node.text) + '"'; case SyntaxKind.NoSubstitutionTemplateLiteral: - return getQuotedEscapedLiteralText("`", node.text, "`"); + return "`" + escapeText(node.text) + "`"; case SyntaxKind.TemplateHead: - return getQuotedEscapedLiteralText("`", node.text, "${"); + return "`" + escapeText(node.text) + "${"; case SyntaxKind.TemplateMiddle: - return getQuotedEscapedLiteralText("}", node.text, "${"); + return "}" + escapeText(node.text) + "${"; case SyntaxKind.TemplateTail: - return getQuotedEscapedLiteralText("}", node.text, "`"); + return "}" + escapeText(node.text) + "`"; case SyntaxKind.NumericLiteral: return node.text; } @@ -350,11 +351,7 @@ namespace ts { } export function getTextOfConstantValue(value: string | number) { - return typeof value === "string" ? getQuotedEscapedLiteralText('"', value, '"') : "" + value; - } - - function getQuotedEscapedLiteralText(leftQuote: string, text: string, rightQuote: string) { - return leftQuote + escapeNonAsciiCharacters(escapeString(text)) + rightQuote; + return typeof value === "string" ? '"' + escapeNonAsciiString(value) + '"' : "" + value; } // Add an extra underscore to identifiers that start with two underscores to avoid issues with magic names like '__proto__' @@ -470,7 +467,7 @@ namespace ts { return getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name); } - export function getNameFromIndexInfo(info: IndexInfo) { + export function getNameFromIndexInfo(info: IndexInfo): string | undefined { return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined; } @@ -571,7 +568,7 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.TypeAliasDeclaration: - errorNode = (node).name; + errorNode = (node).name; break; case SyntaxKind.ArrowFunction: return getErrorSpanForArrowFunction(sourceFile, node); @@ -594,10 +591,6 @@ namespace ts { return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined; } - export function isDeclarationFile(file: SourceFile): boolean { - return file.isDeclarationFile; - } - export function isConstEnumDeclaration(node: Node): boolean { return node.kind === SyntaxKind.EnumDeclaration && isConst(node); } @@ -886,6 +879,16 @@ namespace ts { return false; } + export function isFunctionOrConstructorTypeNode(node: Node): node is FunctionTypeNode | ConstructorTypeNode { + switch (node.kind) { + case SyntaxKind.FunctionType: + case SyntaxKind.ConstructorType: + return true; + } + + return false; + } + export function introducesArgumentsExoticObject(node: Node) { switch (node.kind) { case SyntaxKind.MethodDeclaration: @@ -1147,6 +1150,10 @@ namespace ts { } } + export function isCallOrNewExpression(node: Node): node is CallExpression | NewExpression { + return node.kind === SyntaxKind.CallExpression || node.kind === SyntaxKind.NewExpression; + } + export function getInvokedExpression(node: CallLikeExpression): Expression { if (node.kind === SyntaxKind.TaggedTemplateExpression) { return (node).tag; @@ -1759,22 +1766,44 @@ namespace ts { // True if the given identifier, string literal, or number literal is the name of a declaration node export function isDeclarationName(name: Node): boolean { - if (name.kind !== SyntaxKind.Identifier && name.kind !== SyntaxKind.StringLiteral && name.kind !== SyntaxKind.NumericLiteral) { - return false; + switch (name.kind) { + case SyntaxKind.Identifier: + case SyntaxKind.StringLiteral: + case SyntaxKind.NumericLiteral: + return isDeclaration(name.parent) && name.parent.name === name; + default: + return false; } + } - const parent = name.parent; - if (parent.kind === SyntaxKind.ImportSpecifier || parent.kind === SyntaxKind.ExportSpecifier) { - if ((parent).propertyName) { - return true; + export function getNameOfDeclaration(declaration: Declaration): DeclarationName { + if (!declaration) { + return undefined; + } + if (declaration.kind === SyntaxKind.BinaryExpression) { + const kind = getSpecialPropertyAssignmentKind(declaration as BinaryExpression); + const lhs = (declaration as BinaryExpression).left; + switch (kind) { + case SpecialPropertyAssignmentKind.None: + case SpecialPropertyAssignmentKind.ModuleExports: + return undefined; + case SpecialPropertyAssignmentKind.ExportsProperty: + if (lhs.kind === SyntaxKind.Identifier) { + return (lhs as PropertyAccessExpression).name; + } + else { + return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name; + } + case SpecialPropertyAssignmentKind.ThisProperty: + case SpecialPropertyAssignmentKind.Property: + return (lhs as PropertyAccessExpression).name; + case SpecialPropertyAssignmentKind.PrototypeProperty: + return ((lhs as PropertyAccessExpression).expression as PropertyAccessExpression).name; } } - - if (isDeclaration(parent)) { - return (parent).name === name; + else { + return (declaration as NamedDeclaration).name; } - - return false; } export function isLiteralComputedPropertyDeclarationName(node: Node) { @@ -1797,7 +1826,7 @@ namespace ts { case SyntaxKind.PropertyAssignment: case SyntaxKind.PropertyAccessExpression: // Name in member declaration or property name in property access - return (parent).name === node; + return (parent).name === node; case SyntaxKind.QualifiedName: // Name on right hand side of dot in a type query if ((parent).right === node) { @@ -1929,16 +1958,18 @@ namespace ts { } export const enum FunctionFlags { - Normal = 0, - Generator = 1 << 0, - Async = 1 << 1, - AsyncOrAsyncGenerator = Async | Generator, - Invalid = 1 << 2, - InvalidAsyncOrAsyncGenerator = AsyncOrAsyncGenerator | Invalid, - InvalidGenerator = Generator | Invalid, + Normal = 0, // Function is a normal function + Generator = 1 << 0, // Function is a generator function or async generator function + Async = 1 << 1, // Function is an async function or an async generator function + Invalid = 1 << 2, // Function is a signature or overload and does not have a body. + AsyncGenerator = Async | Generator, // Function is an async generator function } - export function getFunctionFlags(node: FunctionLikeDeclaration) { + export function getFunctionFlags(node: FunctionLikeDeclaration | undefined) { + if (!node) { + return FunctionFlags.Invalid; + } + let flags = FunctionFlags.Normal; switch (node.kind) { case SyntaxKind.FunctionDeclaration: @@ -1993,7 +2024,8 @@ namespace ts { * Symbol. */ export function hasDynamicName(declaration: Declaration): boolean { - return declaration.name && isDynamicName(declaration.name); + const name = getNameOfDeclaration(declaration); + return name && isDynamicName(name); } export function isDynamicName(name: DeclarationName): boolean { @@ -2303,6 +2335,9 @@ namespace ts { case SyntaxKind.SpreadElement: return 1; + case SyntaxKind.CommaListExpression: + return 0; + default: return -1; } @@ -2435,7 +2470,8 @@ namespace ts { } const nonAsciiCharacters = /[^\u0000-\u007F]/g; - export function escapeNonAsciiCharacters(s: string): string { + export function escapeNonAsciiString(s: string): string { + s = escapeString(s); // Replace non-ASCII characters with '\uNNNN' escapes if any exist. // Otherwise just return the original string. return nonAsciiCharacters.test(s) ? @@ -2539,7 +2575,7 @@ namespace ts { export function getExternalModuleNameFromDeclaration(host: EmitHost, resolver: EmitResolver, declaration: ImportEqualsDeclaration | ImportDeclaration | ExportDeclaration | ModuleDeclaration): string { const file = resolver.getExternalModuleFileFromDeclaration(declaration); - if (!file || isDeclarationFile(file)) { + if (!file || file.isDeclarationFile) { return undefined; } return getResolvedExternalModuleName(host, file); @@ -2612,7 +2648,7 @@ namespace ts { /** Don't call this for `--outFile`, just for `--outDir` or plain emit. `--outFile` needs additional checks. */ export function sourceFileMayBeEmitted(sourceFile: SourceFile, options: CompilerOptions, isSourceFileFromExternalLibrary: (file: SourceFile) => boolean) { - return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !isDeclarationFile(sourceFile) && !isSourceFileFromExternalLibrary(sourceFile); + return !(options.noEmitForJsFiles && isSourceFileJavaScript(sourceFile)) && !sourceFile.isDeclarationFile && !isSourceFileFromExternalLibrary(sourceFile); } /** @@ -2758,7 +2794,7 @@ namespace ts { forEach(declarations, (member: Declaration) => { if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) && hasModifier(member, ModifierFlags.Static) === hasModifier(accessor, ModifierFlags.Static)) { - const memberName = getPropertyNameForPropertyNameNode(member.name); + const memberName = getPropertyNameForPropertyNameNode((member as NamedDeclaration).name); const accessorName = getPropertyNameForPropertyNameNode(accessor.name); if (memberName === accessorName) { if (!firstAccessor) { @@ -3228,13 +3264,13 @@ namespace ts { const carriageReturnLineFeed = "\r\n"; const lineFeed = "\n"; export function getNewLineCharacter(options: CompilerOptions | PrinterOptions): string { - if (options.newLine === NewLineKind.CarriageReturnLineFeed) { - return carriageReturnLineFeed; + switch (options.newLine) { + case NewLineKind.CarriageReturnLineFeed: + return carriageReturnLineFeed; + case NewLineKind.LineFeed: + return lineFeed; } - else if (options.newLine === NewLineKind.LineFeed) { - return lineFeed; - } - else if (sys) { + if (sys) { return sys.newLine; } return carriageReturnLineFeed; @@ -3573,10 +3609,6 @@ namespace ts { return node.kind === SyntaxKind.Identifier; } - export function isVoidExpression(node: Node): node is VoidExpression { - return node.kind === SyntaxKind.VoidExpression; - } - export function isGeneratedIdentifier(node: Node): node is GeneratedIdentifier { // Using `>` here catches both `GeneratedIdentifierKind.None` and `undefined`. return isIdentifier(node) && node.autoGenerateKind > GeneratedIdentifierKind.None; @@ -3653,7 +3685,18 @@ namespace ts { || kind === SyntaxKind.GetAccessor || kind === SyntaxKind.SetAccessor || kind === SyntaxKind.IndexSignature - || kind === SyntaxKind.SemicolonClassElement; + || kind === SyntaxKind.SemicolonClassElement + || kind === SyntaxKind.MissingDeclaration; + } + + export function isTypeElement(node: Node): node is TypeElement { + const kind = node.kind; + return kind === SyntaxKind.ConstructSignature + || kind === SyntaxKind.CallSignature + || kind === SyntaxKind.PropertySignature + || kind === SyntaxKind.MethodSignature + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.MissingDeclaration; } export function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike { @@ -3884,6 +3927,7 @@ namespace ts { || kind === SyntaxKind.SpreadElement || kind === SyntaxKind.AsExpression || kind === SyntaxKind.OmittedExpression + || kind === SyntaxKind.CommaListExpression || isUnaryExpressionKind(kind); } @@ -3975,6 +4019,10 @@ namespace ts { return node.kind === SyntaxKind.ImportEqualsDeclaration; } + export function isImportDeclaration(node: Node): node is ImportDeclaration { + return node.kind === SyntaxKind.ImportDeclaration; + } + export function isImportClause(node: Node): node is ImportClause { return node.kind === SyntaxKind.ImportClause; } @@ -3997,6 +4045,10 @@ namespace ts { return node.kind === SyntaxKind.ExportSpecifier; } + export function isExportAssignment(node: Node): node is ExportAssignment { + return node.kind === SyntaxKind.ExportAssignment; + } + export function isModuleOrEnumDeclaration(node: Node): node is ModuleDeclaration | EnumDeclaration { return node.kind === SyntaxKind.ModuleDeclaration || node.kind === SyntaxKind.EnumDeclaration; } @@ -4074,7 +4126,7 @@ namespace ts { || kind === SyntaxKind.MergeDeclarationMarker; } - export function isDeclaration(node: Node): node is Declaration { + export function isDeclaration(node: Node): node is NamedDeclaration { return isDeclarationKind(node.kind); } @@ -4203,6 +4255,52 @@ namespace ts { // Firefox has Object.prototype.watch return options.watch && options.hasOwnProperty("watch"); } + + export function getCheckFlags(symbol: Symbol): CheckFlags { + return symbol.flags & SymbolFlags.Transient ? (symbol).checkFlags : 0; + } + + export function getDeclarationModifierFlagsFromSymbol(s: Symbol): ModifierFlags { + if (s.valueDeclaration) { + const flags = getCombinedModifierFlags(s.valueDeclaration); + return s.parent && s.parent.flags & SymbolFlags.Class ? flags : flags & ~ModifierFlags.AccessibilityModifier; + } + if (getCheckFlags(s) & CheckFlags.Synthetic) { + const checkFlags = (s).checkFlags; + const accessModifier = checkFlags & CheckFlags.ContainsPrivate ? ModifierFlags.Private : + checkFlags & CheckFlags.ContainsPublic ? ModifierFlags.Public : + ModifierFlags.Protected; + const staticModifier = checkFlags & CheckFlags.ContainsStatic ? ModifierFlags.Static : 0; + return accessModifier | staticModifier; + } + if (s.flags & SymbolFlags.Prototype) { + return ModifierFlags.Public | ModifierFlags.Static; + } + return 0; + } + + export function levenshtein(s1: string, s2: string): number { + let previous: number[] = new Array(s2.length + 1); + let current: number[] = new Array(s2.length + 1); + for (let i = 0; i < s2.length + 1; i++) { + previous[i] = i; + current[i] = -1; + } + for (let i = 1; i < s1.length + 1; i++) { + current[0] = i; + for (let j = 1; j < s2.length + 1; j++) { + current[j] = Math.min( + previous[j] + 1, + current[j - 1] + 1, + previous[j - 1] + (s1[i - 1] === s2[j - 1] ? 0 : 2)); + } + // shift current back to previous, and then reuse previous' array + const tmp = previous; + previous = current; + current = tmp; + } + return previous[previous.length - 1]; + } } namespace ts { diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index 7850155ed25..eb28721a142 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -218,17 +218,12 @@ namespace ts { return node; } - switch (node.kind) { - case SyntaxKind.SemicolonClassElement: - case SyntaxKind.EmptyStatement: - case SyntaxKind.OmittedExpression: - case SyntaxKind.DebuggerStatement: - case SyntaxKind.EndOfDeclarationMarker: - case SyntaxKind.MissingDeclaration: - // No need to visit nodes with no children. - return node; - + switch (kind) { // Names + + case SyntaxKind.Identifier: + return updateIdentifier(node, nodesVisitor((node).typeArguments, visitor, isTypeNode)); + case SyntaxKind.QualifiedName: return updateQualifiedName(node, visitNode((node).left, visitor, isEntityName), @@ -238,45 +233,13 @@ namespace ts { return updateComputedPropertyName(node, visitNode((node).expression, visitor, isExpression)); - // Signatures and Signature Elements - case SyntaxKind.FunctionType: - return updateFunctionTypeNode(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode)); + // Signature elements - case SyntaxKind.ConstructorType: - return updateConstructorTypeNode(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode)); - - case SyntaxKind.CallSignature: - return updateCallSignatureDeclaration(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode)); - - case SyntaxKind.ConstructSignature: - return updateConstructSignatureDeclaration(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode)); - - case SyntaxKind.MethodSignature: - return updateMethodSignature(node, - nodesVisitor((node).typeParameters, visitor, isTypeParameter), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode), - visitNode((node).name, visitor, isPropertyName), - visitNode((node).questionToken, tokenVisitor, isToken)); - - case SyntaxKind.IndexSignature: - return updateIndexSignatureDeclaration(node, - nodesVisitor((node).decorators, visitor, isDecorator), - nodesVisitor((node).modifiers, visitor, isModifier), - visitParameterList((node).parameters, visitor, context, nodesVisitor), - visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.TypeParameter: + return updateTypeParameterDeclaration(node, + visitNode((node).name, visitor, isIdentifier), + visitNode((node).constraint, visitor, isTypeNode), + visitNode((node).default, visitor, isTypeNode)); case SyntaxKind.Parameter: return updateParameter(node, @@ -292,69 +255,11 @@ namespace ts { return updateDecorator(node, visitNode((node).expression, visitor, isExpression)); - // Types - - case SyntaxKind.TypeReference: - return updateTypeReferenceNode(node, - visitNode((node).typeName, visitor, isEntityName), - nodesVisitor((node).typeArguments, visitor, isTypeNode)); - - case SyntaxKind.TypePredicate: - return updateTypePredicateNode(node, - visitNode((node).parameterName, visitor), - visitNode((node).type, visitor, isTypeNode)); - - case SyntaxKind.TypeQuery: - return updateTypeQueryNode((node), visitNode((node).exprName, visitor, isEntityName)); - - case SyntaxKind.TypeLiteral: - return updateTypeLiteralNode((node), nodesVisitor((node).members, visitor)); - - case SyntaxKind.ArrayType: - return updateArrayTypeNode(node, visitNode((node).elementType, visitor, isTypeNode)); - - case SyntaxKind.TupleType: - return updateTypleTypeNode((node), nodesVisitor((node).elementTypes, visitor, isTypeNode)); - - case SyntaxKind.UnionType: - case SyntaxKind.IntersectionType: - return updateUnionOrIntersectionTypeNode(node, - nodesVisitor((node).types, visitor, isTypeNode)); - - case SyntaxKind.ParenthesizedType: - throw Debug.fail("not implemented."); - - case SyntaxKind.TypeOperator: - return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); - - case SyntaxKind.IndexedAccessType: - return updateIndexedAccessTypeNode((node), - visitNode((node).objectType, visitor, isTypeNode), - visitNode((node).indexType, visitor, isTypeNode)); - - case SyntaxKind.MappedType: - return updateMappedTypeNode((node), - visitNode((node).readonlyToken, tokenVisitor, isToken), - visitNode((node).typeParameter, visitor, isTypeParameter), - visitNode((node).questionToken, tokenVisitor, isToken), - visitNode((node).type, visitor, isTypeNode)); - - case SyntaxKind.LiteralType: - return updateLiteralTypeNode(node, - visitNode((node).literal, visitor, isExpression)); - - // Type Declarations - - case SyntaxKind.TypeParameter: - return updateTypeParameterDeclaration(node, - visitNode((node).name, visitor, isIdentifier), - visitNode((node).constraint, visitor, isTypeNode), - visitNode((node).default, visitor, isTypeNode)); - - // Type members + // Type elements case SyntaxKind.PropertySignature: return updatePropertySignature((node), + nodesVisitor((node).modifiers, visitor, isToken), visitNode((node).name, visitor, isPropertyName), visitNode((node).questionToken, tokenVisitor, isToken), visitNode((node).type, visitor, isTypeNode), @@ -368,6 +273,14 @@ namespace ts { visitNode((node).type, visitor, isTypeNode), visitNode((node).initializer, visitor, isExpression)); + case SyntaxKind.MethodSignature: + return updateMethodSignature(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).parameters, visitor, isParameterDeclaration), + visitNode((node).type, visitor, isTypeNode), + visitNode((node).name, visitor, isPropertyName), + visitNode((node).questionToken, tokenVisitor, isToken)); + case SyntaxKind.MethodDeclaration: return updateMethod(node, nodesVisitor((node).decorators, visitor, isDecorator), @@ -404,7 +317,99 @@ namespace ts { visitParameterList((node).parameters, visitor, context, nodesVisitor), visitFunctionBody((node).body, visitor, context)); + case SyntaxKind.CallSignature: + return updateCallSignature(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).parameters, visitor, isParameterDeclaration), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.ConstructSignature: + return updateConstructSignature(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).parameters, visitor, isParameterDeclaration), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.IndexSignature: + return updateIndexSignature(node, + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), + nodesVisitor((node).parameters, visitor, isParameterDeclaration), + visitNode((node).type, visitor, isTypeNode)); + + // Types + + case SyntaxKind.TypePredicate: + return updateTypePredicateNode(node, + visitNode((node).parameterName, visitor), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.TypeReference: + return updateTypeReferenceNode(node, + visitNode((node).typeName, visitor, isEntityName), + nodesVisitor((node).typeArguments, visitor, isTypeNode)); + + case SyntaxKind.FunctionType: + return updateFunctionTypeNode(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).parameters, visitor, isParameterDeclaration), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.ConstructorType: + return updateConstructorTypeNode(node, + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).parameters, visitor, isParameterDeclaration), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.TypeQuery: + return updateTypeQueryNode((node), + visitNode((node).exprName, visitor, isEntityName)); + + case SyntaxKind.TypeLiteral: + return updateTypeLiteralNode((node), + nodesVisitor((node).members, visitor, isTypeElement)); + + case SyntaxKind.ArrayType: + return updateArrayTypeNode(node, + visitNode((node).elementType, visitor, isTypeNode)); + + case SyntaxKind.TupleType: + return updateTypleTypeNode((node), + nodesVisitor((node).elementTypes, visitor, isTypeNode)); + + case SyntaxKind.UnionType: + return updateUnionTypeNode(node, + nodesVisitor((node).types, visitor, isTypeNode)); + + case SyntaxKind.IntersectionType: + return updateIntersectionTypeNode(node, + nodesVisitor((node).types, visitor, isTypeNode)); + + case SyntaxKind.ParenthesizedType: + return updateParenthesizedType(node, + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.TypeOperator: + return updateTypeOperatorNode(node, + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.IndexedAccessType: + return updateIndexedAccessTypeNode((node), + visitNode((node).objectType, visitor, isTypeNode), + visitNode((node).indexType, visitor, isTypeNode)); + + case SyntaxKind.MappedType: + return updateMappedTypeNode((node), + visitNode((node).readonlyToken, tokenVisitor, isToken), + visitNode((node).typeParameter, visitor, isTypeParameter), + visitNode((node).questionToken, tokenVisitor, isToken), + visitNode((node).type, visitor, isTypeNode)); + + case SyntaxKind.LiteralType: + return updateLiteralTypeNode(node, + visitNode((node).literal, visitor, isExpression)); + // Binding patterns + case SyntaxKind.ObjectBindingPattern: return updateObjectBindingPattern(node, nodesVisitor((node).elements, visitor, isBindingElement)); @@ -421,6 +426,7 @@ namespace ts { visitNode((node).initializer, visitor, isExpression)); // Expression + case SyntaxKind.ArrayLiteralExpression: return updateArrayLiteral(node, nodesVisitor((node).elements, visitor, isExpression)); @@ -499,11 +505,6 @@ namespace ts { return updateAwait(node, visitNode((node).expression, visitor, isExpression)); - case SyntaxKind.BinaryExpression: - return updateBinary(node, - visitNode((node).left, visitor, isExpression), - visitNode((node).right, visitor, isExpression)); - case SyntaxKind.PrefixUnaryExpression: return updatePrefix(node, visitNode((node).operand, visitor, isExpression)); @@ -512,6 +513,11 @@ namespace ts { return updatePostfix(node, visitNode((node).operand, visitor, isExpression)); + case SyntaxKind.BinaryExpression: + return updateBinary(node, + visitNode((node).left, visitor, isExpression), + visitNode((node).right, visitor, isExpression)); + case SyntaxKind.ConditionalExpression: return updateConditional(node, visitNode((node).condition, visitor, isExpression), @@ -554,13 +560,19 @@ namespace ts { return updateNonNullExpression(node, visitNode((node).expression, visitor, isExpression)); + case SyntaxKind.MetaProperty: + return updateMetaProperty(node, + visitNode((node).name, visitor, isIdentifier)); + // Misc + case SyntaxKind.TemplateSpan: return updateTemplateSpan(node, visitNode((node).expression, visitor, isExpression), visitNode((node).literal, visitor, isTemplateMiddleOrTemplateTail)); // Element + case SyntaxKind.Block: return updateBlock(node, nodesVisitor((node).statements, visitor, isStatement)); @@ -677,6 +689,21 @@ namespace ts { nodesVisitor((node).heritageClauses, visitor, isHeritageClause), nodesVisitor((node).members, visitor, isClassElement)); + case SyntaxKind.InterfaceDeclaration: + return updateInterfaceDeclaration(node, + nodesVisitor((node).decorators, visitor, isDecorator), + nodesVisitor((node).modifiers, visitor, isModifier), + visitNode((node).name, visitor, isIdentifier), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + nodesVisitor((node).heritageClauses, visitor, isHeritageClause), + nodesVisitor((node).members, visitor, isTypeElement)); + + case SyntaxKind.TypeAliasDeclaration: + return updateTypeAliasDeclaration(node, + visitNode((node).name, visitor, isIdentifier), + nodesVisitor((node).typeParameters, visitor, isTypeParameter), + visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.EnumDeclaration: return updateEnumDeclaration(node, nodesVisitor((node).decorators, visitor, isDecorator), @@ -699,6 +726,10 @@ namespace ts { return updateCaseBlock(node, nodesVisitor((node).clauses, visitor, isCaseOrDefaultClause)); + case SyntaxKind.NamespaceExportDeclaration: + return updateNamespaceExportDeclaration(node, + visitNode((node).name, visitor, isIdentifier)); + case SyntaxKind.ImportEqualsDeclaration: return updateImportEqualsDeclaration(node, nodesVisitor((node).decorators, visitor, isDecorator), @@ -754,21 +785,19 @@ namespace ts { visitNode((node).name, visitor, isIdentifier)); // Module references + case SyntaxKind.ExternalModuleReference: return updateExternalModuleReference(node, visitNode((node).expression, visitor, isExpression)); // JSX + case SyntaxKind.JsxElement: return updateJsxElement(node, visitNode((node).openingElement, visitor, isJsxOpeningElement), nodesVisitor((node).children, visitor, isJsxChild), visitNode((node).closingElement, visitor, isJsxClosingElement)); - case SyntaxKind.JsxAttributes: - return updateJsxAttributes(node, - nodesVisitor((node).properties, visitor, isJsxAttributeLike)); - case SyntaxKind.JsxSelfClosingElement: return updateJsxSelfClosingElement(node, visitNode((node).tagName, visitor, isJsxTagNameExpression), @@ -788,6 +817,10 @@ namespace ts { visitNode((node).name, visitor, isIdentifier), visitNode((node).initializer, visitor, isStringLiteralOrJsxExpression)); + case SyntaxKind.JsxAttributes: + return updateJsxAttributes(node, + nodesVisitor((node).properties, visitor, isJsxAttributeLike)); + case SyntaxKind.JsxSpreadAttribute: return updateJsxSpreadAttribute(node, visitNode((node).expression, visitor, isExpression)); @@ -797,6 +830,7 @@ namespace ts { visitNode((node).expression, visitor, isExpression)); // Clauses + case SyntaxKind.CaseClause: return updateCaseClause(node, visitNode((node).expression, visitor, isExpression), @@ -816,6 +850,7 @@ namespace ts { visitNode((node).block, visitor, isBlock)); // Property assignments + case SyntaxKind.PropertyAssignment: return updatePropertyAssignment(node, visitNode((node).name, visitor, isPropertyName), @@ -846,9 +881,15 @@ namespace ts { return updatePartiallyEmittedExpression(node, visitNode((node).expression, visitor, isExpression)); + case SyntaxKind.CommaListExpression: + return updateCommaList(node, + nodesVisitor((node).elements, visitor, isExpression)); + default: + // No need to visit nodes with no children. return node; } + } /** @@ -934,6 +975,15 @@ namespace ts { break; // Type member + + case SyntaxKind.PropertySignature: + result = reduceNodes((node).modifiers, cbNodes, result); + result = reduceNode((node).name, cbNode, result); + result = reduceNode((node).questionToken, cbNode, result); + result = reduceNode((node).type, cbNode, result); + result = reduceNode((node).initializer, cbNode, result); + break; + case SyntaxKind.PropertyDeclaration: result = reduceNodes((node).decorators, cbNodes, result); result = reduceNodes((node).modifiers, cbNodes, result); @@ -1357,6 +1407,10 @@ namespace ts { result = reduceNode((node).expression, cbNode, result); break; + case SyntaxKind.CommaListExpression: + result = reduceNodes((node).elements, cbNodes, result); + break; + default: break; } diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a56d21ae345..70b67f3326e 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -655,7 +655,7 @@ namespace FourSlash { ts.zipWith(endMarkers, definitions, (endMarker, definition, i) => { const marker = this.getMarkerByName(endMarker); if (marker.fileName !== definition.fileName || marker.position !== definition.textSpan.start) { - this.raiseError(`goToDefinition failed for definition ${i}: expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`); + this.raiseError(`goToDefinition failed for definition ${endMarker} (${i}): expected ${marker.fileName} at ${marker.position}, got ${definition.fileName} at ${definition.textSpan.start}`); } }); } @@ -3417,6 +3417,18 @@ namespace FourSlashInterface { export class VerifyNegatable { public not: VerifyNegatable; + public allowedClassElementKeywords = [ + "public", + "private", + "protected", + "static", + "abstract", + "readonly", + "get", + "set", + "constructor", + "async" + ]; constructor(protected state: FourSlash.TestState, private negative = false) { if (!negative) { @@ -3453,6 +3465,12 @@ namespace FourSlashInterface { this.state.verifyCompletionListIsEmpty(this.negative); } + public completionListContainsClassElementKeywords() { + for (const keyword of this.allowedClassElementKeywords) { + this.completionListContains(keyword, keyword, /*documentation*/ undefined, "keyword"); + } + } + public completionListIsGlobal(expected: boolean) { this.state.verifyCompletionListIsGlobal(expected); } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index b0efcf4c389..28d59fe35bd 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -372,7 +372,7 @@ class ProjectRunner extends RunnerBase { const compilerOptions = compilerResult.program.getCompilerOptions(); ts.forEach(compilerResult.program.getSourceFiles(), sourceFile => { - if (ts.isDeclarationFile(sourceFile)) { + if (sourceFile.isDeclarationFile) { allInputFiles.unshift({ emittedFileName: sourceFile.fileName, code: sourceFile.text }); } else if (!(compilerOptions.outFile || compilerOptions.out)) { diff --git a/src/harness/unittests/cachingInServerLSHost.ts b/src/harness/unittests/cachingInServerLSHost.ts index 0725bf36a3b..1b87fc848b5 100644 --- a/src/harness/unittests/cachingInServerLSHost.ts +++ b/src/harness/unittests/cachingInServerLSHost.ts @@ -201,14 +201,13 @@ namespace ts { assert.isTrue(diags.length === 1, "one diagnostic expected"); assert.isTrue(typeof diags[0].messageText === "string" && ((diags[0].messageText).indexOf("Cannot find module") === 0), "should be 'cannot find module' message"); - // assert that import will success once file appear on disk fileMap.set(imported.name, imported); fileExistsCalledForBar = false; rootScriptInfo.editContent(0, root.content.length, `import {y} from "bar"`); diags = project.getLanguageService().getSemanticDiagnostics(root.name); - assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called"); - assert.isTrue(diags.length === 0); + assert.isTrue(fileExistsCalledForBar, "'fileExists' should be called."); + assert.isTrue(diags.length === 0, "The import should succeed once the imported file appears on disk."); }); }); } diff --git a/src/harness/unittests/jsDocParsing.ts b/src/harness/unittests/jsDocParsing.ts index 98c32c77778..309e49bd6b8 100644 --- a/src/harness/unittests/jsDocParsing.ts +++ b/src/harness/unittests/jsDocParsing.ts @@ -241,6 +241,18 @@ namespace ts { */`); + parsesCorrectly("argSynonymForParamTag", +`/** + * @arg {number} name1 Description + */`); + + + parsesCorrectly("argumentSynonymForParamTag", +`/** + * @argument {number} name1 Description + */`); + + parsesCorrectly("templateTag", `/** * @template T diff --git a/src/harness/unittests/moduleResolution.ts b/src/harness/unittests/moduleResolution.ts index 14e13b60457..a4220f50321 100644 --- a/src/harness/unittests/moduleResolution.ts +++ b/src/harness/unittests/moduleResolution.ts @@ -1042,7 +1042,7 @@ import b = require("./moduleB"); assert.equal(diagnostics1.length, 1, "expected one diagnostic"); createProgram(names, {}, compilerHost, program1); - assert.isTrue(program1.structureIsReused); + assert.isTrue(program1.structureIsReused === StructureIsReused.Completely); const diagnostics2 = program1.getFileProcessingDiagnostics().getDiagnostics(); assert.equal(diagnostics2.length, 1, "expected one diagnostic"); assert.equal(diagnostics1[0].messageText, diagnostics2[0].messageText, "expected one diagnostic"); diff --git a/src/harness/unittests/reuseProgramStructure.ts b/src/harness/unittests/reuseProgramStructure.ts index 43014f25afb..2eb3d1f0890 100644 --- a/src/harness/unittests/reuseProgramStructure.ts +++ b/src/harness/unittests/reuseProgramStructure.ts @@ -159,12 +159,14 @@ namespace ts { return program; } - function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void) { - const texts: NamedSourceText[] = (oldProgram).sourceTexts.slice(0); - updater(texts); - const host = createTestCompilerHost(texts, options.target, oldProgram); + function updateProgram(oldProgram: ProgramWithSourceTexts, rootNames: string[], options: CompilerOptions, updater: (files: NamedSourceText[]) => void, newTexts?: NamedSourceText[]) { + if (!newTexts) { + newTexts = (oldProgram).sourceTexts.slice(0); + } + updater(newTexts); + const host = createTestCompilerHost(newTexts, options.target, oldProgram); const program = createProgram(rootNames, options, host, oldProgram); - program.sourceTexts = texts; + program.sourceTexts = newTexts; program.host = host; return program; } @@ -217,13 +219,15 @@ namespace ts { describe("Reuse program structure", () => { const target = ScriptTarget.Latest; - const files = [ - { name: "a.ts", text: SourceText.New( - ` + const files: NamedSourceText[] = [ + { + name: "a.ts", text: SourceText.New( + ` /// /// /// -`, "", `var x = 1`) }, +`, "", `var x = 1`) + }, { name: "b.ts", text: SourceText.New(`/// `, "", `var y = 2`) }, { name: "c.ts", text: SourceText.New("", "", `var z = 1;`) }, { name: "types/typerefs/index.d.ts", text: SourceText.New("", "", `declare let z: number;`) }, @@ -234,7 +238,7 @@ namespace ts { const program_2 = updateProgram(program_1, ["a.ts"], { target }, files => { files[0].text = files[0].text.updateProgram("var x = 100"); }); - assert.isTrue(program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely); const program1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("a.ts")); const program2Diagnostics = program_2.getSemanticDiagnostics(program_1.getSourceFile("a.ts")); assert.equal(program1Diagnostics.length, program2Diagnostics.length); @@ -245,7 +249,7 @@ namespace ts { const program_2 = updateProgram(program_1, ["a.ts"], { target }, files => { files[0].text = files[0].text.updateProgram("var x = 100"); }); - assert.isTrue(program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely); const program1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("a.ts")); const program2Diagnostics = program_2.getSemanticDiagnostics(program_1.getSourceFile("a.ts")); assert.equal(program1Diagnostics.length, program2Diagnostics.length); @@ -259,19 +263,19 @@ namespace ts { `; files[0].text = files[0].text.updateReferences(newReferences); }); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.SafeModules); }); it("fails if change affects type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); updateProgram(program_1, ["a.ts"], { types: ["b"] }, noop); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Not); }); it("succeeds if change doesn't affect type references", () => { const program_1 = newProgram(files, ["a.ts"], { types: ["a"] }); updateProgram(program_1, ["a.ts"], { types: ["a"] }, noop); - assert.isTrue(program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely); }); it("fails if change affects imports", () => { @@ -279,7 +283,7 @@ namespace ts { updateProgram(program_1, ["a.ts"], { target }, files => { files[2].text = files[2].text.updateImportsAndExports("import x from 'b'"); }); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.SafeModules); }); it("fails if change affects type directives", () => { @@ -291,25 +295,25 @@ namespace ts { /// `; files[0].text = files[0].text.updateReferences(newReferences); }); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.SafeModules); }); it("fails if module kind changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS }); updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.AMD }, noop); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Not); }); it("fails if rootdir changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/b" }); updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, rootDir: "/a/c" }, noop); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Not); }); it("fails if config path changes", () => { const program_1 = newProgram(files, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/b/tsconfig.json" }); updateProgram(program_1, ["a.ts"], { target, module: ModuleKind.CommonJS, configFilePath: "/a/c/tsconfig.json" }, noop); - assert.isTrue(!program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Not); }); it("resolution cache follows imports", () => { @@ -328,7 +332,7 @@ namespace ts { const program_2 = updateProgram(program_1, ["a.ts"], options, files => { files[0].text = files[0].text.updateProgram("var x = 2"); }); - assert.isTrue(program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely); // content of resolution cache should not change checkResolvedModulesCache(program_1, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts") })); @@ -338,7 +342,7 @@ namespace ts { const program_3 = updateProgram(program_2, ["a.ts"], options, files => { files[0].text = files[0].text.updateImportsAndExports(""); }); - assert.isTrue(!program_2.structureIsReused); + assert.isTrue(program_2.structureIsReused === StructureIsReused.SafeModules); checkResolvedModulesCache(program_3, "a.ts", /*expectedContent*/ undefined); const program_4 = updateProgram(program_3, ["a.ts"], options, files => { @@ -347,7 +351,7 @@ namespace ts { `; files[0].text = files[0].text.updateImportsAndExports(newImports); }); - assert.isTrue(!program_3.structureIsReused); + assert.isTrue(program_3.structureIsReused === StructureIsReused.SafeModules); checkResolvedModulesCache(program_4, "a.ts", createMapFromTemplate({ "b": createResolvedModule("b.ts"), "c": undefined })); }); @@ -365,7 +369,7 @@ namespace ts { const program_2 = updateProgram(program_1, ["/a.ts"], options, files => { files[0].text = files[0].text.updateProgram("var x = 2"); }); - assert.isTrue(program_1.structureIsReused); + assert.isTrue(program_1.structureIsReused === StructureIsReused.Completely); // content of resolution cache should not change checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); @@ -376,7 +380,7 @@ namespace ts { files[0].text = files[0].text.updateReferences(""); }); - assert.isTrue(!program_2.structureIsReused); + assert.isTrue(program_2.structureIsReused === StructureIsReused.SafeModules); checkResolvedTypeDirectivesCache(program_3, "/a.ts", /*expectedContent*/ undefined); updateProgram(program_3, ["/a.ts"], options, files => { @@ -385,10 +389,74 @@ namespace ts { `; files[0].text = files[0].text.updateReferences(newReferences); }); - assert.isTrue(!program_3.structureIsReused); + assert.isTrue(program_3.structureIsReused === StructureIsReused.SafeModules); checkResolvedTypeDirectivesCache(program_1, "/a.ts", createMapFromTemplate({ "typedefs": { resolvedFileName: "/types/typedefs/index.d.ts", primary: true } })); }); + it("fetches imports after npm install", () => { + const file1Ts = { name: "file1.ts", text: SourceText.New("", `import * as a from "a";`, "const myX: number = a.x;") }; + const file2Ts = { name: "file2.ts", text: SourceText.New("", "", "") }; + const indexDTS = { name: "node_modules/a/index.d.ts", text: SourceText.New("", "export declare let x: number;", "") }; + const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.NodeJs }; + const rootFiles = [file1Ts, file2Ts]; + const filesAfterNpmInstall = [file1Ts, file2Ts, indexDTS]; + + const initialProgram = newProgram(rootFiles, rootFiles.map(f => f.name), options); + { + assert.deepEqual(initialProgram.host.getTrace(), + [ + "======== Resolving module 'a' from 'file1.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a.ts' does not exist.", + "File 'node_modules/a.tsx' does not exist.", + "File 'node_modules/a.d.ts' does not exist.", + "File 'node_modules/a/package.json' does not exist.", + "File 'node_modules/a/index.ts' does not exist.", + "File 'node_modules/a/index.tsx' does not exist.", + "File 'node_modules/a/index.d.ts' does not exist.", + "File 'node_modules/@types/a.d.ts' does not exist.", + "File 'node_modules/@types/a/package.json' does not exist.", + "File 'node_modules/@types/a/index.d.ts' does not exist.", + "Loading module 'a' from 'node_modules' folder, target file type 'JavaScript'.", + "File 'node_modules/a.js' does not exist.", + "File 'node_modules/a.jsx' does not exist.", + "File 'node_modules/a/package.json' does not exist.", + "File 'node_modules/a/index.js' does not exist.", + "File 'node_modules/a/index.jsx' does not exist.", + "======== Module name 'a' was not resolved. ========" + ], + "initialProgram: execute module resolution normally."); + + const initialProgramDiagnostics = initialProgram.getSemanticDiagnostics(initialProgram.getSourceFile("file1.ts")); + assert(initialProgramDiagnostics.length === 1, `initialProgram: import should fail.`); + } + + const afterNpmInstallProgram = updateProgram(initialProgram, rootFiles.map(f => f.name), options, f => { + f[1].text = f[1].text.updateReferences(`/// `); + }, filesAfterNpmInstall); + { + assert.deepEqual(afterNpmInstallProgram.host.getTrace(), + [ + "======== Resolving module 'a' from 'file1.ts'. ========", + "Explicitly specified module resolution kind: 'NodeJs'.", + "Loading module 'a' from 'node_modules' folder, target file type 'TypeScript'.", + "File 'node_modules/a.ts' does not exist.", + "File 'node_modules/a.tsx' does not exist.", + "File 'node_modules/a.d.ts' does not exist.", + "File 'node_modules/a/package.json' does not exist.", + "File 'node_modules/a/index.ts' does not exist.", + "File 'node_modules/a/index.tsx' does not exist.", + "File 'node_modules/a/index.d.ts' exist - use it as a name resolution result.", + "======== Module name 'a' was successfully resolved to 'node_modules/a/index.d.ts'. ========" + ], + "afterNpmInstallProgram: execute module resolution normally."); + + const afterNpmInstallProgramDiagnostics = afterNpmInstallProgram.getSemanticDiagnostics(afterNpmInstallProgram.getSourceFile("file1.ts")); + assert(afterNpmInstallProgramDiagnostics.length === 0, `afterNpmInstallProgram: program is well-formed with import.`); + } + }); + it("can reuse ambient module declarations from non-modified files", () => { const files = [ { name: "/a/b/app.ts", text: SourceText.New("", "import * as fs from 'fs'", "") }, @@ -468,7 +536,206 @@ namespace ts { "File '/fs.jsx' does not exist.", "======== Module name 'fs' was not resolved. ========", ], "should look for 'fs' again since node.d.ts was changed"); + }); + it("can reuse module resolutions from non-modified files", () => { + const files = [ + { name: "a1.ts", text: SourceText.New("", "", "let x = 1;") }, + { name: "a2.ts", text: SourceText.New("", "", "let x = 1;") }, + { name: "b1.ts", text: SourceText.New("", "export class B { x: number; }", "") }, + { name: "b2.ts", text: SourceText.New("", "export class B { x: number; }", "") }, + { name: "node_modules/@types/typerefs1/index.d.ts", text: SourceText.New("", "", "declare let z: string;") }, + { name: "node_modules/@types/typerefs2/index.d.ts", text: SourceText.New("", "", "declare let z: string;") }, + { + name: "f1.ts", + text: + SourceText.New( + `/// ${newLine}/// ${newLine}/// `, + `import { B } from './b1';${newLine}export let BB = B;`, + "declare module './b1' { interface B { y: string; } }") + }, + { + name: "f2.ts", + text: SourceText.New( + `/// ${newLine}/// `, + `import { B } from './b2';${newLine}import { BB } from './f1';`, + "(new BB).x; (new BB).y;") + }, + ]; + + const options: CompilerOptions = { target: ScriptTarget.ES2015, traceResolution: true, moduleResolution: ModuleResolutionKind.Classic }; + const program_1 = newProgram(files, files.map(f => f.name), options); + let expectedErrors = 0; + { + assert.deepEqual(program_1.host.getTrace(), + [ + "======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs1/package.json' does not exist.", + "File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========", + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "======== Resolving module './b2' from 'f2.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b2.ts' exist - use it as a name resolution result.", + "======== Module name './b2' was successfully resolved to 'b2.ts'. ========", + "======== Resolving module './f1' from 'f2.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'f1.ts' exist - use it as a name resolution result.", + "======== Module name './f1' was successfully resolved to 'f1.ts'. ========" + ], + "program_1: execute module reoslution normally."); + + const program_1Diagnostics = program_1.getSemanticDiagnostics(program_1.getSourceFile("f2.ts")); + assert(program_1Diagnostics.length === expectedErrors, `initial program should be well-formed`); + } + const indexOfF1 = 6; + const program_2 = updateProgram(program_1, program_1.getRootFileNames(), options, f => { + const newSourceText = f[indexOfF1].text.updateReferences(`/// ${newLine}/// `); + f[indexOfF1] = { name: "f1.ts", text: newSourceText }; + }); + + { + const program_2Diagnostics = program_2.getSemanticDiagnostics(program_2.getSourceFile("f2.ts")); + assert(program_2Diagnostics.length === expectedErrors, `removing no-default-lib shouldn't affect any types used.`); + + assert.deepEqual(program_2.host.getTrace(), [ + "======== Resolving type reference directive 'typerefs1', containing file 'f1.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs1/package.json' does not exist.", + "File 'node_modules/@types/typerefs1/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs1' was successfully resolved to 'node_modules/@types/typerefs1/index.d.ts', primary: true. ========", + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], "program_2: reuse module resolutions in f2 since it is unchanged"); + } + + const program_3 = updateProgram(program_2, program_2.getRootFileNames(), options, f => { + const newSourceText = f[indexOfF1].text.updateReferences(`/// `); + f[indexOfF1] = { name: "f1.ts", text: newSourceText }; + }); + + { + const program_3Diagnostics = program_3.getSemanticDiagnostics(program_3.getSourceFile("f2.ts")); + assert(program_3Diagnostics.length === expectedErrors, `typerefs2 was unused, so diagnostics should be unaffected.`); + + assert.deepEqual(program_3.host.getTrace(), [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], "program_3: reuse module resolutions in f2 since it is unchanged"); + } + + + const program_4 = updateProgram(program_3, program_3.getRootFileNames(), options, f => { + const newSourceText = f[indexOfF1].text.updateReferences(""); + f[indexOfF1] = { name: "f1.ts", text: newSourceText }; + }); + + { + const program_4Diagnostics = program_4.getSemanticDiagnostics(program_4.getSourceFile("f2.ts")); + assert(program_4Diagnostics.length === expectedErrors, `a1.ts was unused, so diagnostics should be unaffected.`); + + assert.deepEqual(program_4.host.getTrace(), [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], "program_4: reuse module resolutions in f2 since it is unchanged"); + } + + const program_5 = updateProgram(program_4, program_4.getRootFileNames(), options, f => { + const newSourceText = f[indexOfF1].text.updateImportsAndExports(`import { B } from './b1';`); + f[indexOfF1] = { name: "f1.ts", text: newSourceText }; + }); + + { + const program_5Diagnostics = program_5.getSemanticDiagnostics(program_5.getSourceFile("f2.ts")); + assert(program_5Diagnostics.length === ++expectedErrors, `import of BB in f1 fails. BB is of type any. Add one error`); + + assert.deepEqual(program_5.host.getTrace(), [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========" + ], "program_5: exports do not affect program structure, so f2's resolutions are silently reused."); + } + + const program_6 = updateProgram(program_5, program_5.getRootFileNames(), options, f => { + const newSourceText = f[indexOfF1].text.updateProgram(""); + f[indexOfF1] = { name: "f1.ts", text: newSourceText }; + }); + + { + const program_6Diagnostics = program_6.getSemanticDiagnostics(program_6.getSourceFile("f2.ts")); + assert(program_6Diagnostics.length === expectedErrors, `import of BB in f1 fails.`); + + assert.deepEqual(program_6.host.getTrace(), [ + "======== Resolving module './b1' from 'f1.ts'. ========", + "Explicitly specified module resolution kind: 'Classic'.", + "File 'b1.ts' exist - use it as a name resolution result.", + "======== Module name './b1' was successfully resolved to 'b1.ts'. ========", + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], "program_6: reuse module resolutions in f2 since it is unchanged"); + } + + const program_7 = updateProgram(program_6, program_6.getRootFileNames(), options, f => { + const newSourceText = f[indexOfF1].text.updateImportsAndExports(""); + f[indexOfF1] = { name: "f1.ts", text: newSourceText }; + }); + + { + const program_7Diagnostics = program_7.getSemanticDiagnostics(program_7.getSourceFile("f2.ts")); + assert(program_7Diagnostics.length === expectedErrors, `removing import is noop with respect to program, so no change in diagnostics.`); + + assert.deepEqual(program_7.host.getTrace(), [ + "======== Resolving type reference directive 'typerefs2', containing file 'f2.ts', root directory 'node_modules/@types'. ========", + "Resolving with primary search path 'node_modules/@types'.", + "File 'node_modules/@types/typerefs2/package.json' does not exist.", + "File 'node_modules/@types/typerefs2/index.d.ts' exist - use it as a name resolution result.", + "======== Type reference directive 'typerefs2' was successfully resolved to 'node_modules/@types/typerefs2/index.d.ts', primary: true. ========", + "Reusing resolution of module './b2' to file 'f2.ts' from old program.", + "Reusing resolution of module './f1' to file 'f2.ts' from old program." + ], "program_7 should reuse module resolutions in f2 since it is unchanged"); + } }); }); diff --git a/src/harness/unittests/transform.ts b/src/harness/unittests/transform.ts index ae2caf4f23b..deee352ebf1 100644 --- a/src/harness/unittests/transform.ts +++ b/src/harness/unittests/transform.ts @@ -3,41 +3,77 @@ namespace ts { describe("TransformAPI", () => { - function transformsCorrectly(name: string, source: string, transformers: TransformerFactory[]) { - it(name, () => { - Harness.Baseline.runBaseline(`transformApi/transformsCorrectly.${name}.js`, () => { - const transformed = transform(createSourceFile("source.ts", source, ScriptTarget.ES2015), transformers); - const printer = createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed }, { - onEmitNode: transformed.emitNodeWithNotification, - substituteNode: transformed.substituteNode - }); - const result = printer.printBundle(createBundle(transformed.transformed)); - transformed.dispose(); - return result; - }); + function replaceUndefinedWithVoid0(context: ts.TransformationContext) { + const previousOnSubstituteNode = context.onSubstituteNode; + context.enableSubstitution(SyntaxKind.Identifier); + context.onSubstituteNode = (hint, node) => { + node = previousOnSubstituteNode(hint, node); + if (hint === EmitHint.Expression && node.kind === SyntaxKind.Identifier && (node).text === "undefined") { + node = createPartiallyEmittedExpression( + addSyntheticTrailingComment( + setTextRange( + createVoidZero(), + node), + SyntaxKind.MultiLineCommentTrivia, "undefined")); + } + return node; + }; + return (file: ts.SourceFile) => file; + } + + function replaceIdentifiersNamedOldNameWithNewName(context: ts.TransformationContext) { + const previousOnSubstituteNode = context.onSubstituteNode; + context.enableSubstitution(SyntaxKind.Identifier); + context.onSubstituteNode = (hint, node) => { + node = previousOnSubstituteNode(hint, node); + if (node.kind === SyntaxKind.Identifier && (node).text === "oldName") { + node = setTextRange(createIdentifier("newName"), node); + } + return node; + }; + return (file: ts.SourceFile) => file; + } + + function transformSourceFile(sourceText: string, transformers: TransformerFactory[]) { + const transformed = transform(createSourceFile("source.ts", sourceText, ScriptTarget.ES2015), transformers); + const printer = createPrinter({ newLine: NewLineKind.CarriageReturnLineFeed }, { + onEmitNode: transformed.emitNodeWithNotification, + substituteNode: transformed.substituteNode + }); + const result = printer.printBundle(createBundle(transformed.transformed)); + transformed.dispose(); + return result; + } + + function testBaseline(testName: string, test: () => string) { + it(testName, () => { + Harness.Baseline.runBaseline(`transformApi/transformsCorrectly.${testName}.js`, test); }); } - transformsCorrectly("substitution", ` - var a = undefined; - `, [ - context => { - const previousOnSubstituteNode = context.onSubstituteNode; - context.enableSubstitution(SyntaxKind.Identifier); - context.onSubstituteNode = (hint, node) => { - node = previousOnSubstituteNode(hint, node); - if (hint === EmitHint.Expression && node.kind === SyntaxKind.Identifier && (node).text === "undefined") { - node = createPartiallyEmittedExpression( - addSyntheticTrailingComment( - setTextRange( - createVoidZero(), - node), - SyntaxKind.MultiLineCommentTrivia, "undefined")); - } - return node; - }; - return file => file; - } - ]); + testBaseline("substitution", () => { + return transformSourceFile(`var a = undefined;`, [replaceUndefinedWithVoid0]); + }); + + testBaseline("types", () => { + return transformSourceFile(`let a: () => void`, [ + context => file => visitNode(file, function visitor(node: Node): VisitResult { + return visitEachChild(node, visitor, context); + }) + ]); + }); + + testBaseline("fromTranspileModule", () => { + return ts.transpileModule(`var oldName = undefined;`, { + transformers: { + before: [replaceUndefinedWithVoid0], + after: [replaceIdentifiersNamedOldNameWithNewName] + }, + compilerOptions: { + newLine: NewLineKind.CarriageReturnLineFeed + } + }).outputText; + }); }); } + diff --git a/src/lib/es2015.iterable.d.ts b/src/lib/es2015.iterable.d.ts index 2f8a1efba76..049b1898b9b 100644 --- a/src/lib/es2015.iterable.d.ts +++ b/src/lib/es2015.iterable.d.ts @@ -32,17 +32,17 @@ interface Array { [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array + * Returns an iterable of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, T]>; /** - * Returns an list of keys in the array + * Returns an iterable of keys in the array */ keys(): IterableIterator; /** - * Returns an list of values in the array + * Returns an iterable of values in the array */ values(): IterableIterator; } @@ -66,21 +66,21 @@ interface ArrayConstructor { } interface ReadonlyArray { - /** Iterator */ + /** Iterator of values in the array. */ [Symbol.iterator](): IterableIterator; /** - * Returns an array of key, value pairs for every entry in the array + * Returns an iterable of key, value pairs for every entry in the array */ entries(): IterableIterator<[number, T]>; /** - * Returns an list of keys in the array + * Returns an iterable of keys in the array */ keys(): IterableIterator; /** - * Returns an list of values in the array + * Returns an iterable of values in the array */ values(): IterableIterator; } @@ -91,9 +91,42 @@ interface IArguments { } interface Map { + /** Returns an iterable of entries in the map. */ [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ + values(): IterableIterator; +} + +interface ReadonlyMap { + /** Returns an iterable of entries in the map. */ + [Symbol.iterator](): IterableIterator<[K, V]>; + + /** + * Returns an iterable of key, value pairs for every entry in the map. + */ + entries(): IterableIterator<[K, V]>; + + /** + * Returns an iterable of keys in the map + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the map + */ values(): IterableIterator; } @@ -108,9 +141,40 @@ interface WeakMapConstructor { } interface Set { + /** Iterates over values in the set. */ [Symbol.iterator](): IterableIterator; + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ entries(): IterableIterator<[T, T]>; + /** + * Despite its name, returns an iterable of the values in the set, + */ keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ + values(): IterableIterator; +} + +interface ReadonlySet { + /** Iterates over values in the set. */ + [Symbol.iterator](): IterableIterator; + + /** + * Returns an iterable of [v,v] pairs for every value `v` in the set. + */ + entries(): IterableIterator<[T, T]>; + + /** + * Despite its name, returns an iterable of the values in the set, + */ + keys(): IterableIterator; + + /** + * Returns an iterable of values in the set. + */ values(): IterableIterator; } diff --git a/src/lib/es2015.proxy.d.ts b/src/lib/es2015.proxy.d.ts index c1b7805bbcf..50671aedcce 100644 --- a/src/lib/es2015.proxy.d.ts +++ b/src/lib/es2015.proxy.d.ts @@ -3,7 +3,7 @@ interface ProxyHandler { setPrototypeOf? (target: T, v: any): boolean; isExtensible? (target: T): boolean; preventExtensions? (target: T): boolean; - getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor; + getOwnPropertyDescriptor? (target: T, p: PropertyKey): PropertyDescriptor | undefined; has? (target: T, p: PropertyKey): boolean; get? (target: T, p: PropertyKey, receiver: any): any; set? (target: T, p: PropertyKey, value: any, receiver: any): boolean; diff --git a/src/lib/es2017.sharedmemory.d.ts b/src/lib/es2017.sharedmemory.d.ts index e18390a5591..b9a9b0f7e10 100644 --- a/src/lib/es2017.sharedmemory.d.ts +++ b/src/lib/es2017.sharedmemory.d.ts @@ -23,5 +23,96 @@ interface SharedArrayBufferConstructor { readonly prototype: SharedArrayBuffer; new (byteLength: number): SharedArrayBuffer; } +declare var SharedArrayBuffer: SharedArrayBufferConstructor; -declare var SharedArrayBuffer: SharedArrayBufferConstructor; \ No newline at end of file +interface ArrayBufferTypes { + SharedArrayBuffer: SharedArrayBuffer; +} + +interface Atomics { + /** + * Adds a value to the value at the given position in the array, returning the original value. + * Until this atomic operation completes, any other read or write operation against the array + * will block. + */ + add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + /** + * Stores the bitwise AND of a value with the value at the given position in the array, + * returning the original value. Until this atomic operation completes, any other read or + * write operation against the array will block. + */ + and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + /** + * Replaces the value at the given position in the array if the original value equals the given + * expected value, returning the original value. Until this atomic operation completes, any + * other read or write operation against the array will block. + */ + compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number; + + /** + * Replaces the value at the given position in the array, returning the original value. Until + * this atomic operation completes, any other read or write operation against the array will + * block. + */ + exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + /** + * Returns a value indicating whether high-performance algorithms can use atomic operations + * (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed + * array. + */ + isLockFree(size: number): boolean; + + /** + * Returns the value at the given position in the array. Until this atomic operation completes, + * any other read or write operation against the array will block. + */ + load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number; + + /** + * Stores the bitwise OR of a value with the value at the given position in the array, + * returning the original value. Until this atomic operation completes, any other read or write + * operation against the array will block. + */ + or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + /** + * Stores a value at the given position in the array, returning the new value. Until this + * atomic operation completes, any other read or write operation against the array will block. + */ + store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + /** + * Subtracts a value from the value at the given position in the array, returning the original + * value. Until this atomic operation completes, any other read or write operation against the + * array will block. + */ + sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + /** + * If the value at the given position in the array is equal to the provided value, the current + * agent is put to sleep causing execution to suspend until the timeout expires (returning + * `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns + * `"not-equal"`. + */ + wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out"; + + /** + * Wakes up sleeping agents that are waiting on the given index of the array, returning the + * number of agents that were awoken. + */ + wake(typedArray: Int32Array, index: number, count: number): number; + + /** + * Stores the bitwise XOR of a value with the value at the given position in the array, + * returning the original value. Until this atomic operation completes, any other read or write + * operation against the array will block. + */ + xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number; + + readonly [Symbol.toStringTag]: "Atomics"; +} + +declare var Atomics: Atomics; \ No newline at end of file diff --git a/src/lib/es5.d.ts b/src/lib/es5.d.ts index 23805495b69..3a85f4ddad9 100644 --- a/src/lib/es5.d.ts +++ b/src/lib/es5.d.ts @@ -1386,6 +1386,14 @@ interface ArrayBuffer { slice(begin: number, end?: number): ArrayBuffer; } +/** + * Allowed ArrayBuffer types for the buffer of an ArrayBufferView and related Typed Arrays. + */ +interface ArrayBufferTypes { + ArrayBuffer: ArrayBuffer; +} +type ArrayBufferLike = ArrayBufferTypes[keyof ArrayBufferTypes]; + interface ArrayBufferConstructor { readonly prototype: ArrayBuffer; new (byteLength: number): ArrayBuffer; @@ -1397,7 +1405,7 @@ interface ArrayBufferView { /** * The ArrayBuffer instance referenced by the array. */ - buffer: ArrayBuffer; + buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -1539,7 +1547,7 @@ interface DataView { } interface DataViewConstructor { - new (buffer: ArrayBuffer, byteOffset?: number, byteLength?: number): DataView; + new (buffer: ArrayBufferLike, byteOffset?: number, byteLength?: number): DataView; } declare const DataView: DataViewConstructor; @@ -1556,7 +1564,7 @@ interface Int8Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -1799,7 +1807,7 @@ interface Int8ArrayConstructor { readonly prototype: Int8Array; new (length: number): Int8Array; new (array: ArrayLike): Int8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int8Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int8Array; /** * The size in bytes of each element in the array. @@ -1840,7 +1848,7 @@ interface Uint8Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -2084,7 +2092,7 @@ interface Uint8ArrayConstructor { readonly prototype: Uint8Array; new (length: number): Uint8Array; new (array: ArrayLike): Uint8Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8Array; /** * The size in bytes of each element in the array. @@ -2125,7 +2133,7 @@ interface Uint8ClampedArray { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -2369,7 +2377,7 @@ interface Uint8ClampedArrayConstructor { readonly prototype: Uint8ClampedArray; new (length: number): Uint8ClampedArray; new (array: ArrayLike): Uint8ClampedArray; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint8ClampedArray; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint8ClampedArray; /** * The size in bytes of each element in the array. @@ -2409,7 +2417,7 @@ interface Int16Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -2653,7 +2661,7 @@ interface Int16ArrayConstructor { readonly prototype: Int16Array; new (length: number): Int16Array; new (array: ArrayLike): Int16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int16Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int16Array; /** * The size in bytes of each element in the array. @@ -2694,7 +2702,7 @@ interface Uint16Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -2938,7 +2946,7 @@ interface Uint16ArrayConstructor { readonly prototype: Uint16Array; new (length: number): Uint16Array; new (array: ArrayLike): Uint16Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint16Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array; /** * The size in bytes of each element in the array. @@ -2978,7 +2986,7 @@ interface Int32Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -3222,7 +3230,7 @@ interface Int32ArrayConstructor { readonly prototype: Int32Array; new (length: number): Int32Array; new (array: ArrayLike): Int32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Int32Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Int32Array; /** * The size in bytes of each element in the array. @@ -3262,7 +3270,7 @@ interface Uint32Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -3506,7 +3514,7 @@ interface Uint32ArrayConstructor { readonly prototype: Uint32Array; new (length: number): Uint32Array; new (array: ArrayLike): Uint32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Uint32Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint32Array; /** * The size in bytes of each element in the array. @@ -3546,7 +3554,7 @@ interface Float32Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -3790,7 +3798,7 @@ interface Float32ArrayConstructor { readonly prototype: Float32Array; new (length: number): Float32Array; new (array: ArrayLike): Float32Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float32Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float32Array; /** * The size in bytes of each element in the array. @@ -3831,7 +3839,7 @@ interface Float64Array { /** * The ArrayBuffer instance referenced by the array. */ - readonly buffer: ArrayBuffer; + readonly buffer: ArrayBufferLike; /** * The length in bytes of the array. @@ -4075,7 +4083,7 @@ interface Float64ArrayConstructor { readonly prototype: Float64Array; new (length: number): Float64Array; new (array: ArrayLike): Float64Array; - new (buffer: ArrayBuffer, byteOffset?: number, length?: number): Float64Array; + new (buffer: ArrayBufferLike, byteOffset?: number, length?: number): Float64Array; /** * The size in bytes of each element in the array. diff --git a/src/server/project.ts b/src/server/project.ts index 09c8d74c8c7..56c394379a0 100644 --- a/src/server/project.ts +++ b/src/server/project.ts @@ -552,7 +552,7 @@ namespace ts.server { // bump up the version if // - oldProgram is not set - this is a first time updateGraph is called // - newProgram is different from the old program and structure of the old program was not reused. - if (!oldProgram || (this.program !== oldProgram && !oldProgram.structureIsReused)) { + if (!oldProgram || (this.program !== oldProgram && !(oldProgram.structureIsReused & StructureIsReused.Completely))) { hasChanges = true; if (oldProgram) { for (const f of oldProgram.getSourceFiles()) { diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 428b69027c7..c4c9ecece2b 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -2267,6 +2267,7 @@ namespace ts.server.protocol { insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces?: boolean; insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces?: boolean; + insertSpaceAfterTypeAssertion?: boolean; insertSpaceBeforeFunctionParenthesis?: boolean; placeOpenBraceOnNewLineForFunctions?: boolean; placeOpenBraceOnNewLineForControlBlocks?: boolean; diff --git a/src/server/server.ts b/src/server/server.ts index 79cfc3882ae..67640e430d8 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -708,12 +708,11 @@ namespace ts.server { } sys.require = (initialDir: string, moduleName: string): RequireResult => { - const result = nodeModuleNameResolverWorker(moduleName, initialDir + "/program.ts", { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, sys, /*cache*/ undefined, /*jsOnly*/ true); try { - return { module: require(result.resolvedModule.resolvedFileName), error: undefined }; + return { module: require(resolveJavaScriptModule(moduleName, initialDir, sys)), error: undefined }; } - catch (e) { - return { module: undefined, error: e }; + catch (error) { + return { module: undefined, error }; } }; diff --git a/src/server/typingsInstaller/nodeTypingsInstaller.ts b/src/server/typingsInstaller/nodeTypingsInstaller.ts index 895a4e17cc7..1182450ce81 100644 --- a/src/server/typingsInstaller/nodeTypingsInstaller.ts +++ b/src/server/typingsInstaller/nodeTypingsInstaller.ts @@ -96,6 +96,9 @@ namespace ts.server.typingsInstaller { this.log.writeLine(`Updating ${TypesRegistryPackageName} npm package...`); } this.execSync(`${this.npmPath} install ${TypesRegistryPackageName}`, { cwd: globalTypingsCacheLocation, stdio: "ignore" }); + if (this.log.isEnabled()) { + this.log.writeLine(`Updated ${TypesRegistryPackageName} npm package`); + } } catch (e) { if (this.log.isEnabled()) { diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 8e1d0ac2f29..346cdaaaf19 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -1,7 +1,8 @@ /* @internal */ namespace ts.codefix { registerCodeFix({ - errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code], + errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1.code, + Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code], getCodeActions: getActionsForAddMissingMember }); @@ -110,16 +111,16 @@ namespace ts.codefix { if (!isStatic) { const stringTypeNode = createKeywordTypeNode(SyntaxKind.StringKeyword); const indexingParameter = createParameter( - /*decorators*/ undefined, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, + /*decorators*/ undefined, + /*modifiers*/ undefined, + /*dotDotDotToken*/ undefined, "x", - /*questionToken*/ undefined, + /*questionToken*/ undefined, stringTypeNode, - /*initializer*/ undefined); - const indexSignature = createIndexSignatureDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, + /*initializer*/ undefined); + const indexSignature = createIndexSignature( + /*decorators*/ undefined, + /*modifiers*/ undefined, [indexingParameter], typeNode); @@ -135,4 +136,4 @@ namespace ts.codefix { return actions; } } -} \ No newline at end of file +} diff --git a/src/services/codefixes/fixSpelling.ts b/src/services/codefixes/fixSpelling.ts new file mode 100644 index 00000000000..b58dab95002 --- /dev/null +++ b/src/services/codefixes/fixSpelling.ts @@ -0,0 +1,53 @@ +/* @internal */ +namespace ts.codefix { + registerCodeFix({ + errorCodes: [Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_1.code], + getCodeActions: getActionsForCorrectSpelling + }); + + function getActionsForCorrectSpelling(context: CodeFixContext): CodeAction[] | undefined { + const sourceFile = context.sourceFile; + + // This is the identifier of the misspelled word. eg: + // this.speling = 1; + // ^^^^^^^ + const node = getTokenAtPosition(sourceFile, context.span.start); + const checker = context.program.getTypeChecker(); + let suggestion: string; + if (node.kind === SyntaxKind.Identifier && isPropertyAccessExpression(node.parent)) { + const containingType = checker.getTypeAtLocation(node.parent.expression); + suggestion = checker.getSuggestionForNonexistentProperty(node as Identifier, containingType); + } + else { + const meaning = getMeaningFromLocation(node); + suggestion = checker.getSuggestionForNonexistentSymbol(node, getTextOfNode(node), convertSemanticMeaningToSymbolFlags(meaning)); + } + if (suggestion) { + return [{ + description: formatStringFromArgs(getLocaleSpecificMessage(Diagnostics.Change_spelling_to_0), [suggestion]), + changes: [{ + fileName: sourceFile.fileName, + textChanges: [{ + span: { start: node.getStart(), length: node.getWidth() }, + newText: suggestion + }], + }], + }]; + } + } + + function convertSemanticMeaningToSymbolFlags(meaning: SemanticMeaning): SymbolFlags { + let flags = 0; + if (meaning & SemanticMeaning.Namespace) { + flags |= SymbolFlags.Namespace; + } + if (meaning & SemanticMeaning.Type) { + flags |= SymbolFlags.Type; + } + if (meaning & SemanticMeaning.Value) { + flags |= SymbolFlags.Value; + } + return flags; + } +} diff --git a/src/services/codefixes/fixes.ts b/src/services/codefixes/fixes.ts index ae1643dfa3b..c2e2509a28e 100644 --- a/src/services/codefixes/fixes.ts +++ b/src/services/codefixes/fixes.ts @@ -1,5 +1,6 @@ /// /// +/// /// /// /// diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 0de04d7a9b9..39d8e13dde9 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -63,7 +63,7 @@ namespace ts.codefix { const declaration = declarations[0] as Declaration; // Clone name to remove leading trivia. - const name = getSynthesizedClone(declaration.name); + const name = getSynthesizedClone(getNameOfDeclaration(declaration)) as PropertyName; const visibilityModifier = createVisibilityModifier(getModifierFlags(declaration)); const modifiers = visibilityModifier ? createNodeArray([visibilityModifier]) : undefined; const type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration)); @@ -130,7 +130,7 @@ namespace ts.codefix { } function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) { - const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); + const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration, NodeBuilderFlags.SuppressAnyReturnType); if (signatureDeclaration) { signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; @@ -200,7 +200,7 @@ namespace ts.codefix { } export function createStubbedMethod(modifiers: Modifier[], name: PropertyName, optional: boolean, typeParameters: TypeParameterDeclaration[] | undefined, parameters: ParameterDeclaration[], returnType: TypeNode | undefined) { - return createMethodDeclaration( + return createMethod( /*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, @@ -231,4 +231,4 @@ namespace ts.codefix { } return undefined; } -} \ No newline at end of file +} diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index 78c27a1276b..aaf7b535add 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1,5 +1,14 @@ /* @internal */ namespace ts.codefix { + registerCodeFix({ + errorCodes: [ + Diagnostics.Cannot_find_name_0.code, + Diagnostics.Cannot_find_name_0_Did_you_mean_1.code, + Diagnostics.Cannot_find_namespace_0.code, + Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code + ], + getCodeActions: getImportCodeActions + }); type ImportCodeActionKind = "CodeChange" | "InsertingIntoExistingImport" | "NewImport"; interface ImportCodeAction extends CodeAction { @@ -113,465 +122,458 @@ namespace ts.codefix { } } - registerCodeFix({ - errorCodes: [ - Diagnostics.Cannot_find_name_0.code, - Diagnostics.Cannot_find_namespace_0.code, - Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code - ], - getCodeActions: (context: CodeFixContext) => { - const sourceFile = context.sourceFile; - const checker = context.program.getTypeChecker(); - const allSourceFiles = context.program.getSourceFiles(); - const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false; + function getImportCodeActions(context: CodeFixContext): ImportCodeAction[] { + const sourceFile = context.sourceFile; + const checker = context.program.getTypeChecker(); + const allSourceFiles = context.program.getSourceFiles(); + const useCaseSensitiveFileNames = context.host.useCaseSensitiveFileNames ? context.host.useCaseSensitiveFileNames() : false; - const token = getTokenAtPosition(sourceFile, context.span.start); - const name = token.getText(); - const symbolIdActionMap = new ImportCodeActionMap(); + const token = getTokenAtPosition(sourceFile, context.span.start); + const name = token.getText(); + const symbolIdActionMap = new ImportCodeActionMap(); - // this is a module id -> module import declaration map - const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; - let lastImportDeclaration: Node; + // this is a module id -> module import declaration map + const cachedImportDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[][] = []; + let lastImportDeclaration: Node; - const currentTokenMeaning = getMeaningFromLocation(token); - if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { - const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); - return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + const currentTokenMeaning = getMeaningFromLocation(token); + if (context.errorCode === Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) { + const symbol = checker.getAliasedSymbol(checker.getSymbolAtLocation(token)); + return getCodeActionForImport(symbol, /*isDefault*/ false, /*isNamespaceImport*/ true); + } + + const candidateModules = checker.getAmbientModules(); + for (const otherSourceFile of allSourceFiles) { + if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { + candidateModules.push(otherSourceFile.symbol); } + } - const candidateModules = checker.getAmbientModules(); - for (const otherSourceFile of allSourceFiles) { - if (otherSourceFile !== sourceFile && isExternalOrCommonJsModule(otherSourceFile)) { - candidateModules.push(otherSourceFile.symbol); + for (const moduleSymbol of candidateModules) { + context.cancellationToken.throwIfCancellationRequested(); + + // check the default export + const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); + if (defaultExport) { + const localSymbol = getLocalSymbolForExportDefault(defaultExport); + if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { + // check if this symbol is already used + const symbolId = getUniqueSymbolId(localSymbol); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true)); } } - for (const moduleSymbol of candidateModules) { - context.cancellationToken.throwIfCancellationRequested(); + // check exports with the same name + const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol); + if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { + const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName); + symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol)); + } + } - // check the default export - const defaultExport = checker.tryGetMemberInModuleExports("default", moduleSymbol); - if (defaultExport) { - const localSymbol = getLocalSymbolForExportDefault(defaultExport); - if (localSymbol && localSymbol.name === name && checkSymbolHasMeaning(localSymbol, currentTokenMeaning)) { - // check if this symbol is already used - const symbolId = getUniqueSymbolId(localSymbol); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol, /*isDefault*/ true)); + return symbolIdActionMap.getAllActions(); + + function getImportDeclarations(moduleSymbol: Symbol) { + const moduleSymbolId = getUniqueSymbolId(moduleSymbol); + + const cached = cachedImportDeclarations[moduleSymbolId]; + if (cached) { + return cached; + } + + const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; + for (const importModuleSpecifier of sourceFile.imports) { + const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); + if (importSymbol === moduleSymbol) { + existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); + } + } + cachedImportDeclarations[moduleSymbolId] = existingDeclarations; + return existingDeclarations; + + function getImportDeclaration(moduleSpecifier: LiteralExpression) { + let node: Node = moduleSpecifier; + while (node) { + if (node.kind === SyntaxKind.ImportDeclaration) { + return node; } + if (node.kind === SyntaxKind.ImportEqualsDeclaration) { + return node; + } + node = node.parent; } + return undefined; + } + } - // check exports with the same name - const exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExports(name, moduleSymbol); - if (exportSymbolWithIdenticalName && checkSymbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) { - const symbolId = getUniqueSymbolId(exportSymbolWithIdenticalName); - symbolIdActionMap.addActions(symbolId, getCodeActionForImport(moduleSymbol)); - } + function getUniqueSymbolId(symbol: Symbol) { + if (symbol.flags & SymbolFlags.Alias) { + return getSymbolId(checker.getAliasedSymbol(symbol)); + } + return getSymbolId(symbol); + } + + function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) { + const declarations = symbol.getDeclarations(); + return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false; + } + + function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] { + const existingDeclarations = getImportDeclarations(moduleSymbol); + if (existingDeclarations.length > 0) { + // With an existing import statement, there are more than one actions the user can do. + return getCodeActionsForExistingImport(existingDeclarations); + } + else { + return [getCodeActionForNewImport()]; } - return symbolIdActionMap.getAllActions(); + function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] { + const actions: ImportCodeAction[] = []; - function getImportDeclarations(moduleSymbol: Symbol) { - const moduleSymbolId = getUniqueSymbolId(moduleSymbol); - - const cached = cachedImportDeclarations[moduleSymbolId]; - if (cached) { - return cached; - } - - const existingDeclarations: (ImportDeclaration | ImportEqualsDeclaration)[] = []; - for (const importModuleSpecifier of sourceFile.imports) { - const importSymbol = checker.getSymbolAtLocation(importModuleSpecifier); - if (importSymbol === moduleSymbol) { - existingDeclarations.push(getImportDeclaration(importModuleSpecifier)); - } - } - cachedImportDeclarations[moduleSymbolId] = existingDeclarations; - return existingDeclarations; - - function getImportDeclaration(moduleSpecifier: LiteralExpression) { - let node: Node = moduleSpecifier; - while (node) { - if (node.kind === SyntaxKind.ImportDeclaration) { - return node; + // It is possible that multiple import statements with the same specifier exist in the file. + // e.g. + // + // import * as ns from "foo"; + // import { member1, member2 } from "foo"; + // + // member3/**/ <-- cusor here + // + // in this case we should provie 2 actions: + // 1. change "member3" to "ns.member3" + // 2. add "member3" to the second import statement's import list + // and it is up to the user to decide which one fits best. + let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration; + let namedImportDeclaration: ImportDeclaration; + let existingModuleSpecifier: string; + for (const declaration of declarations) { + if (declaration.kind === SyntaxKind.ImportDeclaration) { + const namedBindings = declaration.importClause && declaration.importClause.namedBindings; + if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { + // case: + // import * as ns from "foo" + namespaceImportDeclaration = declaration; } - if (node.kind === SyntaxKind.ImportEqualsDeclaration) { - return node; + else { + // cases: + // import default from "foo" + // import { bar } from "foo" or combination with the first one + // import "foo" + namedImportDeclaration = declaration; } - node = node.parent; + existingModuleSpecifier = declaration.moduleSpecifier.getText(); + } + else { + // case: + // import foo = require("foo") + namespaceImportDeclaration = declaration; + existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration); } - return undefined; } - } - function getUniqueSymbolId(symbol: Symbol) { - if (symbol.flags & SymbolFlags.Alias) { - return getSymbolId(checker.getAliasedSymbol(symbol)); + if (namespaceImportDeclaration) { + actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); } - return getSymbolId(symbol); - } - function checkSymbolHasMeaning(symbol: Symbol, meaning: SemanticMeaning) { - const declarations = symbol.getDeclarations(); - return declarations ? some(symbol.declarations, decl => !!(getMeaningFromDeclaration(decl) & meaning)) : false; - } - - function getCodeActionForImport(moduleSymbol: Symbol, isDefault?: boolean, isNamespaceImport?: boolean): ImportCodeAction[] { - const existingDeclarations = getImportDeclarations(moduleSymbol); - if (existingDeclarations.length > 0) { - // With an existing import statement, there are more than one actions the user can do. - return getCodeActionsForExistingImport(existingDeclarations); + if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && + (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { + /** + * If the existing import declaration already has a named import list, just + * insert the identifier into that list. + */ + const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); + const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); + actions.push(createCodeAction( + Diagnostics.Add_0_to_existing_import_declaration_from_1, + [name, moduleSpecifierWithoutQuotes], + fileTextChanges, + "InsertingIntoExistingImport", + moduleSpecifierWithoutQuotes + )); } else { - return [getCodeActionForNewImport()]; + // we need to create a new import statement, but the existing module specifier can be reused. + actions.push(getCodeActionForNewImport(existingModuleSpecifier)); + } + return actions; + + function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) { + if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) { + return declaration.moduleReference.expression.getText(); + } + return declaration.moduleReference.getText(); } - function getCodeActionsForExistingImport(declarations: (ImportDeclaration | ImportEqualsDeclaration)[]): ImportCodeAction[] { - const actions: ImportCodeAction[] = []; - - // It is possible that multiple import statements with the same specifier exist in the file. - // e.g. - // - // import * as ns from "foo"; - // import { member1, member2 } from "foo"; - // - // member3/**/ <-- cusor here - // - // in this case we should provie 2 actions: - // 1. change "member3" to "ns.member3" - // 2. add "member3" to the second import statement's import list - // and it is up to the user to decide which one fits best. - let namespaceImportDeclaration: ImportDeclaration | ImportEqualsDeclaration; - let namedImportDeclaration: ImportDeclaration; - let existingModuleSpecifier: string; - for (const declaration of declarations) { - if (declaration.kind === SyntaxKind.ImportDeclaration) { - const namedBindings = declaration.importClause && declaration.importClause.namedBindings; - if (namedBindings && namedBindings.kind === SyntaxKind.NamespaceImport) { - // case: - // import * as ns from "foo" - namespaceImportDeclaration = declaration; - } - else { - // cases: - // import default from "foo" - // import { bar } from "foo" or combination with the first one - // import "foo" - namedImportDeclaration = declaration; - } - existingModuleSpecifier = declaration.moduleSpecifier.getText(); - } - else { - // case: - // import foo = require("foo") - namespaceImportDeclaration = declaration; - existingModuleSpecifier = getModuleSpecifierFromImportEqualsDeclaration(declaration); - } + function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { + const importList = importClause.namedBindings; + const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); + // case 1: + // original text: import default from "module" + // change to: import default, { name } from "module" + // case 2: + // original text: import {} from "module" + // change to: import { name } from "module" + if (!importList || importList.elements.length === 0) { + const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier])); + return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); } - if (namespaceImportDeclaration) { - actions.push(getCodeActionForNamespaceImport(namespaceImportDeclaration)); - } - - if (!isNamespaceImport && namedImportDeclaration && namedImportDeclaration.importClause && - (namedImportDeclaration.importClause.name || namedImportDeclaration.importClause.namedBindings)) { - /** - * If the existing import declaration already has a named import list, just - * insert the identifier into that list. - */ - const fileTextChanges = getTextChangeForImportClause(namedImportDeclaration.importClause); - const moduleSpecifierWithoutQuotes = stripQuotes(namedImportDeclaration.moduleSpecifier.getText()); - actions.push(createCodeAction( - Diagnostics.Add_0_to_existing_import_declaration_from_1, - [name, moduleSpecifierWithoutQuotes], - fileTextChanges, - "InsertingIntoExistingImport", - moduleSpecifierWithoutQuotes - )); - } - else { - // we need to create a new import statement, but the existing module specifier can be reused. - actions.push(getCodeActionForNewImport(existingModuleSpecifier)); - } - return actions; - - function getModuleSpecifierFromImportEqualsDeclaration(declaration: ImportEqualsDeclaration) { - if (declaration.moduleReference && declaration.moduleReference.kind === SyntaxKind.ExternalModuleReference) { - return declaration.moduleReference.expression.getText(); - } - return declaration.moduleReference.getText(); - } - - function getTextChangeForImportClause(importClause: ImportClause): FileTextChanges[] { - const importList = importClause.namedBindings; - const newImportSpecifier = createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name)); - // case 1: - // original text: import default from "module" - // change to: import default, { name } from "module" - // case 2: - // original text: import {} from "module" - // change to: import { name } from "module" - if (!importList || importList.elements.length === 0) { - const newImportClause = createImportClause(importClause.name, createNamedImports([newImportSpecifier])); - return createChangeTracker().replaceNode(sourceFile, importClause, newImportClause).getChanges(); - } - - /** - * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element - * import { - * foo - * } from "./module"; - */ - return createChangeTracker().insertNodeInListAfter( - sourceFile, - importList.elements[importList.elements.length - 1], - newImportSpecifier).getChanges(); - } - - function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { - let namespacePrefix: string; - if (declaration.kind === SyntaxKind.ImportDeclaration) { - namespacePrefix = (declaration.importClause.namedBindings).name.getText(); - } - else { - namespacePrefix = declaration.name.getText(); - } - namespacePrefix = stripQuotes(namespacePrefix); - - /** - * Cases: - * import * as ns from "mod" - * import default, * as ns from "mod" - * import ns = require("mod") - * - * Because there is no import list, we alter the reference to include the - * namespace instead of altering the import declaration. For example, "foo" would - * become "ns.foo" - */ - return createCodeAction( - Diagnostics.Change_0_to_1, - [name, `${namespacePrefix}.${name}`], - createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(), - "CodeChange" - ); - } + /** + * If the import list has one import per line, preserve that. Otherwise, insert on same line as last element + * import { + * foo + * } from "./module"; + */ + return createChangeTracker().insertNodeInListAfter( + sourceFile, + importList.elements[importList.elements.length - 1], + newImportSpecifier).getChanges(); } - function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { - if (!lastImportDeclaration) { - // insert after any existing imports - for (let i = sourceFile.statements.length - 1; i >= 0; i--) { - const statement = sourceFile.statements[i]; - if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) { - lastImportDeclaration = statement; - break; - } - } - } - - const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); - const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); - const changeTracker = createChangeTracker(); - const importClause = isDefault - ? createImportClause(createIdentifier(name), /*namedBindings*/ undefined) - : isNamespaceImport - ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name))) - : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))])); - const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes)); - if (!lastImportDeclaration) { - changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` }); + function getCodeActionForNamespaceImport(declaration: ImportDeclaration | ImportEqualsDeclaration): ImportCodeAction { + let namespacePrefix: string; + if (declaration.kind === SyntaxKind.ImportDeclaration) { + namespacePrefix = (declaration.importClause.namedBindings).name.getText(); } else { - changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + namespacePrefix = declaration.name.getText(); } + namespacePrefix = stripQuotes(namespacePrefix); - // if this file doesn't have any import statements, insert an import statement and then insert a new line - // between the only import statement and user code. Otherwise just insert the statement because chances - // are there are already a new line seperating code and import statements. + /** + * Cases: + * import * as ns from "mod" + * import default, * as ns from "mod" + * import ns = require("mod") + * + * Because there is no import list, we alter the reference to include the + * namespace instead of altering the import declaration. For example, "foo" would + * become "ns.foo" + */ return createCodeAction( - Diagnostics.Import_0_from_1, - [name, `"${moduleSpecifierWithoutQuotes}"`], - changeTracker.getChanges(), - "NewImport", - moduleSpecifierWithoutQuotes + Diagnostics.Change_0_to_1, + [name, `${namespacePrefix}.${name}`], + createChangeTracker().replaceNode(sourceFile, token, createPropertyAccess(createIdentifier(namespacePrefix), name)).getChanges(), + "CodeChange" ); + } + } - function getModuleSpecifierForNewImport() { - const fileName = sourceFile.fileName; - const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; - const sourceDirectory = getDirectoryPath(fileName); - const options = context.program.getCompilerOptions(); - - return tryGetModuleNameFromAmbientModule() || - tryGetModuleNameFromTypeRoots() || - tryGetModuleNameAsNodeModule() || - tryGetModuleNameFromBaseUrl() || - tryGetModuleNameFromRootDirs() || - removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); - - function tryGetModuleNameFromAmbientModule(): string { - if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) { - return moduleSymbol.name; - } + function getCodeActionForNewImport(moduleSpecifier?: string): ImportCodeAction { + if (!lastImportDeclaration) { + // insert after any existing imports + for (let i = sourceFile.statements.length - 1; i >= 0; i--) { + const statement = sourceFile.statements[i]; + if (statement.kind === SyntaxKind.ImportEqualsDeclaration || statement.kind === SyntaxKind.ImportDeclaration) { + lastImportDeclaration = statement; + break; } + } + } - function tryGetModuleNameFromBaseUrl() { - if (!options.baseUrl) { - return undefined; - } + const getCanonicalFileName = createGetCanonicalFileName(useCaseSensitiveFileNames); + const moduleSpecifierWithoutQuotes = stripQuotes(moduleSpecifier || getModuleSpecifierForNewImport()); + const changeTracker = createChangeTracker(); + const importClause = isDefault + ? createImportClause(createIdentifier(name), /*namedBindings*/ undefined) + : isNamespaceImport + ? createImportClause(/*name*/ undefined, createNamespaceImport(createIdentifier(name))) + : createImportClause(/*name*/ undefined, createNamedImports([createImportSpecifier(/*propertyName*/ undefined, createIdentifier(name))])); + const importDecl = createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, importClause, createLiteral(moduleSpecifierWithoutQuotes)); + if (!lastImportDeclaration) { + changeTracker.insertNodeAt(sourceFile, sourceFile.getStart(), importDecl, { suffix: `${context.newLineCharacter}${context.newLineCharacter}` }); + } + else { + changeTracker.insertNodeAfter(sourceFile, lastImportDeclaration, importDecl, { suffix: context.newLineCharacter }); + } - let relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); - if (!relativeName) { - return undefined; - } + // if this file doesn't have any import statements, insert an import statement and then insert a new line + // between the only import statement and user code. Otherwise just insert the statement because chances + // are there are already a new line seperating code and import statements. + return createCodeAction( + Diagnostics.Import_0_from_1, + [name, `"${moduleSpecifierWithoutQuotes}"`], + changeTracker.getChanges(), + "NewImport", + moduleSpecifierWithoutQuotes + ); - const relativeNameWithIndex = removeFileExtension(relativeName); - relativeName = removeExtensionAndIndexPostFix(relativeName); + function getModuleSpecifierForNewImport() { + const fileName = sourceFile.fileName; + const moduleFileName = moduleSymbol.valueDeclaration.getSourceFile().fileName; + const sourceDirectory = getDirectoryPath(fileName); + const options = context.program.getCompilerOptions(); - if (options.paths) { - for (const key in options.paths) { - for (const pattern of options.paths[key]) { - const indexOfStar = pattern.indexOf("*"); - if (indexOfStar === 0 && pattern.length === 1) { - continue; - } - else if (indexOfStar !== -1) { - const prefix = pattern.substr(0, indexOfStar); - const suffix = pattern.substr(indexOfStar + 1); - if (relativeName.length >= prefix.length + suffix.length && - startsWith(relativeName, prefix) && - endsWith(relativeName, suffix)) { - const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length); - return key.replace("\*", matchedStar); - } - } - else if (pattern === relativeName || pattern === relativeNameWithIndex) { - return key; - } - } - } - } + return tryGetModuleNameFromAmbientModule() || + tryGetModuleNameFromTypeRoots() || + tryGetModuleNameAsNodeModule() || + tryGetModuleNameFromBaseUrl() || + tryGetModuleNameFromRootDirs() || + removeFileExtension(getRelativePath(moduleFileName, sourceDirectory)); - return relativeName; + function tryGetModuleNameFromAmbientModule(): string { + if (moduleSymbol.valueDeclaration.kind !== SyntaxKind.SourceFile) { + return moduleSymbol.name; } + } - function tryGetModuleNameFromRootDirs() { - if (options.rootDirs) { - const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); - const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); - if (normalizedTargetPath !== undefined) { - const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; - return removeFileExtension(relativePath); - } - } + function tryGetModuleNameFromBaseUrl() { + if (!options.baseUrl) { return undefined; } - function tryGetModuleNameFromTypeRoots() { - const typeRoots = getEffectiveTypeRoots(options, context.host); - if (typeRoots) { - const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName)); - for (const typeRoot of normalizedTypeRoots) { - if (startsWith(moduleFileName, typeRoot)) { - const relativeFileName = moduleFileName.substring(typeRoot.length + 1); - return removeExtensionAndIndexPostFix(relativeFileName); - } - } - } + let relativeName = getRelativePathIfInDirectory(moduleFileName, options.baseUrl); + if (!relativeName) { + return undefined; } - function tryGetModuleNameAsNodeModule() { - if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { - // nothing to do here - return undefined; - } + const relativeNameWithIndex = removeFileExtension(relativeName); + relativeName = removeExtensionAndIndexPostFix(relativeName); - const indexOfNodeModules = moduleFileName.indexOf("node_modules"); - if (indexOfNodeModules < 0) { - return undefined; - } - - let relativeFileName: string; - if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) { - // if node_modules folder is in this folder or any of its parent folder, no need to keep it. - relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */); - } - else { - relativeFileName = getRelativePath(moduleFileName, sourceDirectory); - } - - relativeFileName = removeFileExtension(relativeFileName); - if (endsWith(relativeFileName, "/index")) { - relativeFileName = getDirectoryPath(relativeFileName); - } - else { - try { - const moduleDirectory = getDirectoryPath(moduleFileName); - const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json"))); - if (packageJsonContent) { - const mainFile = packageJsonContent.main || packageJsonContent.typings; - if (mainFile) { - const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName); - if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) { - relativeFileName = getDirectoryPath(relativeFileName); - } + if (options.paths) { + for (const key in options.paths) { + for (const pattern of options.paths[key]) { + const indexOfStar = pattern.indexOf("*"); + if (indexOfStar === 0 && pattern.length === 1) { + continue; + } + else if (indexOfStar !== -1) { + const prefix = pattern.substr(0, indexOfStar); + const suffix = pattern.substr(indexOfStar + 1); + if (relativeName.length >= prefix.length + suffix.length && + startsWith(relativeName, prefix) && + endsWith(relativeName, suffix)) { + const matchedStar = relativeName.substr(prefix.length, relativeName.length - suffix.length); + return key.replace("\*", matchedStar); } } + else if (pattern === relativeName || pattern === relativeNameWithIndex) { + return key; + } } - catch (e) { } } - - return relativeFileName; } + + return relativeName; } - function getPathRelativeToRootDirs(path: string, rootDirs: string[]) { - for (const rootDir of rootDirs) { - const relativeName = getRelativePathIfInDirectory(path, rootDir); - if (relativeName !== undefined) { - return relativeName; + function tryGetModuleNameFromRootDirs() { + if (options.rootDirs) { + const normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, options.rootDirs); + const normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, options.rootDirs); + if (normalizedTargetPath !== undefined) { + const relativePath = normalizedSourcePath !== undefined ? getRelativePath(normalizedTargetPath, normalizedSourcePath) : normalizedTargetPath; + return removeFileExtension(relativePath); } } return undefined; } - function removeExtensionAndIndexPostFix(fileName: string) { - fileName = removeFileExtension(fileName); - if (endsWith(fileName, "/index")) { - fileName = fileName.substr(0, fileName.length - 6/* "/index".length */); + function tryGetModuleNameFromTypeRoots() { + const typeRoots = getEffectiveTypeRoots(options, context.host); + if (typeRoots) { + const normalizedTypeRoots = map(typeRoots, typeRoot => toPath(typeRoot, /*basePath*/ undefined, getCanonicalFileName)); + for (const typeRoot of normalizedTypeRoots) { + if (startsWith(moduleFileName, typeRoot)) { + const relativeFileName = moduleFileName.substring(typeRoot.length + 1); + return removeExtensionAndIndexPostFix(relativeFileName); + } + } } - return fileName; } - function getRelativePathIfInDirectory(path: string, directoryPath: string) { - const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath; - } + function tryGetModuleNameAsNodeModule() { + if (getEmitModuleResolutionKind(options) !== ModuleResolutionKind.NodeJs) { + // nothing to do here + return undefined; + } - function getRelativePath(path: string, directoryPath: string) { - const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); - return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; + const indexOfNodeModules = moduleFileName.indexOf("node_modules"); + if (indexOfNodeModules < 0) { + return undefined; + } + + let relativeFileName: string; + if (sourceDirectory.indexOf(moduleFileName.substring(0, indexOfNodeModules - 1)) === 0) { + // if node_modules folder is in this folder or any of its parent folder, no need to keep it. + relativeFileName = moduleFileName.substring(indexOfNodeModules + 13 /* "node_modules\".length */); + } + else { + relativeFileName = getRelativePath(moduleFileName, sourceDirectory); + } + + relativeFileName = removeFileExtension(relativeFileName); + if (endsWith(relativeFileName, "/index")) { + relativeFileName = getDirectoryPath(relativeFileName); + } + else { + try { + const moduleDirectory = getDirectoryPath(moduleFileName); + const packageJsonContent = JSON.parse(context.host.readFile(combinePaths(moduleDirectory, "package.json"))); + if (packageJsonContent) { + const mainFile = packageJsonContent.main || packageJsonContent.typings; + if (mainFile) { + const mainExportFile = toPath(mainFile, moduleDirectory, getCanonicalFileName); + if (removeFileExtension(mainExportFile) === removeFileExtension(moduleFileName)) { + relativeFileName = getDirectoryPath(relativeFileName); + } + } + } + } + catch (e) { } + } + + return relativeFileName; } } + function getPathRelativeToRootDirs(path: string, rootDirs: string[]) { + for (const rootDir of rootDirs) { + const relativeName = getRelativePathIfInDirectory(path, rootDir); + if (relativeName !== undefined) { + return relativeName; + } + } + return undefined; + } + + function removeExtensionAndIndexPostFix(fileName: string) { + fileName = removeFileExtension(fileName); + if (endsWith(fileName, "/index")) { + fileName = fileName.substr(0, fileName.length - 6/* "/index".length */); + } + return fileName; + } + + function getRelativePathIfInDirectory(path: string, directoryPath: string) { + const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + return isRootedDiskPath(relativePath) || startsWith(relativePath, "..") ? undefined : relativePath; + } + + function getRelativePath(path: string, directoryPath: string) { + const relativePath = getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false); + return moduleHasNonRelativeName(relativePath) ? "./" + relativePath : relativePath; + } } - function createChangeTracker() { - return textChanges.ChangeTracker.fromCodeFixContext(context); - } - - function createCodeAction( - description: DiagnosticMessage, - diagnosticArgs: string[], - changes: FileTextChanges[], - kind: ImportCodeActionKind, - moduleSpecifier?: string): ImportCodeAction { - return { - description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), - changes, - kind, - moduleSpecifier - }; - } } - }); + + function createChangeTracker() { + return textChanges.ChangeTracker.fromCodeFixContext(context); + } + + function createCodeAction( + description: DiagnosticMessage, + diagnosticArgs: string[], + changes: FileTextChanges[], + kind: ImportCodeActionKind, + moduleSpecifier?: string): ImportCodeAction { + return { + description: formatMessage.apply(undefined, [undefined, description].concat(diagnosticArgs)), + changes, + kind, + moduleSpecifier + }; + } + } } diff --git a/src/services/codefixes/unusedIdentifierFixes.ts b/src/services/codefixes/unusedIdentifierFixes.ts index e1debfa4ffb..422a28098a6 100644 --- a/src/services/codefixes/unusedIdentifierFixes.ts +++ b/src/services/codefixes/unusedIdentifierFixes.ts @@ -18,142 +18,150 @@ namespace ts.codefix { switch (token.kind) { case ts.SyntaxKind.Identifier: - switch (token.parent.kind) { - case ts.SyntaxKind.VariableDeclaration: - switch (token.parent.parent.parent.kind) { - case SyntaxKind.ForStatement: - const forStatement = token.parent.parent.parent; - const forInitializer = forStatement.initializer; - if (forInitializer.declarations.length === 1) { - return deleteNode(forInitializer); - } - else { - return deleteNodeInList(token.parent); - } - - case SyntaxKind.ForOfStatement: - const forOfStatement = token.parent.parent.parent; - if (forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList) { - const forOfInitializer = forOfStatement.initializer; - return replaceNode(forOfInitializer.declarations[0], createObjectLiteral()); - } - break; - - case SyntaxKind.ForInStatement: - // There is no valid fix in the case of: - // for .. in - return undefined; - - case SyntaxKind.CatchClause: - const catchClause = token.parent.parent; - const parameter = catchClause.variableDeclaration.getChildren()[0]; - return deleteNode(parameter); - - default: - const variableStatement = token.parent.parent.parent; - if (variableStatement.declarationList.declarations.length === 1) { - return deleteNode(variableStatement); - } - else { - return deleteNodeInList(token.parent); - } - } - // TODO: #14885 - // falls through - - case SyntaxKind.TypeParameter: - const typeParameters = (token.parent.parent).typeParameters; - if (typeParameters.length === 1) { - const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1); - if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) { - return deleteRange(typeParameters); - } - const nextToken = getTokenAtPosition(sourceFile, typeParameters.end); - if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) { - return deleteRange(typeParameters); - } - return deleteNodeRange(previousToken, nextToken); - } - else { - return deleteNodeInList(token.parent); - } - - case ts.SyntaxKind.Parameter: - const functionDeclaration = token.parent.parent; - if (functionDeclaration.parameters.length === 1) { - return deleteNode(token.parent); - } - else { - return deleteNodeInList(token.parent); - } - - // handle case where 'import a = A;' - case SyntaxKind.ImportEqualsDeclaration: - const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration); - return deleteNode(importEquals); - - case SyntaxKind.ImportSpecifier: - const namedImports = token.parent.parent; - if (namedImports.elements.length === 1) { - // Only 1 import and it is unused. So the entire declaration should be removed. - const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration); - return deleteNode(importSpec); - } - else { - // delete import specifier - return deleteNodeInList(token.parent); - } - - // handle case where "import d, * as ns from './file'" - // or "'import {a, b as ns} from './file'" - case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' - const importClause = token.parent; - if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| - const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); - return deleteNode(importDecl); - } - else { - // import |d,| * as ns from './file' - const start = importClause.name.getStart(sourceFile); - const nextToken = getTokenAtPosition(sourceFile, importClause.name.end); - if (nextToken && nextToken.kind === SyntaxKind.CommaToken) { - // shift first non-whitespace position after comma to the start position of the node - return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) }); - } - else { - return deleteNode(importClause.name); - } - } - - case SyntaxKind.NamespaceImport: - const namespaceImport = token.parent; - if (namespaceImport.name === token && !(namespaceImport.parent).name) { - const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); - return deleteNode(importDecl); - } - else { - const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1); - if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { - const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart); - return deleteRange({ pos: startPosition, end: namespaceImport.end }); - } - return deleteRange(namespaceImport); - } - } - break; + return deleteIdentifier(); case SyntaxKind.PropertyDeclaration: case SyntaxKind.NamespaceImport: return deleteNode(token.parent); + + default: + return deleteDefault(); } - if (isDeclarationName(token)) { - return deleteNode(token.parent); + + function deleteDefault() { + if (isDeclarationName(token)) { + return deleteNode(token.parent); + } + else if (isLiteralComputedPropertyDeclarationName(token)) { + return deleteNode(token.parent.parent); + } + else { + return undefined; + } } - else if (isLiteralComputedPropertyDeclarationName(token)) { - return deleteNode(token.parent.parent); + + function deleteIdentifier(): CodeAction[] | undefined { + switch (token.parent.kind) { + case ts.SyntaxKind.VariableDeclaration: + return deleteVariableDeclaration(token.parent); + + case SyntaxKind.TypeParameter: + const typeParameters = (token.parent.parent).typeParameters; + if (typeParameters.length === 1) { + const previousToken = getTokenAtPosition(sourceFile, typeParameters.pos - 1); + if (!previousToken || previousToken.kind !== SyntaxKind.LessThanToken) { + return deleteRange(typeParameters); + } + const nextToken = getTokenAtPosition(sourceFile, typeParameters.end); + if (!nextToken || nextToken.kind !== SyntaxKind.GreaterThanToken) { + return deleteRange(typeParameters); + } + return deleteNodeRange(previousToken, nextToken); + } + else { + return deleteNodeInList(token.parent); + } + + case ts.SyntaxKind.Parameter: + const functionDeclaration = token.parent.parent; + if (functionDeclaration.parameters.length === 1) { + return deleteNode(token.parent); + } + else { + return deleteNodeInList(token.parent); + } + + // handle case where 'import a = A;' + case SyntaxKind.ImportEqualsDeclaration: + const importEquals = getAncestor(token, SyntaxKind.ImportEqualsDeclaration); + return deleteNode(importEquals); + + case SyntaxKind.ImportSpecifier: + const namedImports = token.parent.parent; + if (namedImports.elements.length === 1) { + // Only 1 import and it is unused. So the entire declaration should be removed. + const importSpec = getAncestor(token, SyntaxKind.ImportDeclaration); + return deleteNode(importSpec); + } + else { + // delete import specifier + return deleteNodeInList(token.parent); + } + + // handle case where "import d, * as ns from './file'" + // or "'import {a, b as ns} from './file'" + case SyntaxKind.ImportClause: // this covers both 'import |d|' and 'import |d,| *' + const importClause = token.parent; + if (!importClause.namedBindings) { // |import d from './file'| or |import * as ns from './file'| + const importDecl = getAncestor(importClause, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); + } + else { + // import |d,| * as ns from './file' + const start = importClause.name.getStart(sourceFile); + const nextToken = getTokenAtPosition(sourceFile, importClause.name.end); + if (nextToken && nextToken.kind === SyntaxKind.CommaToken) { + // shift first non-whitespace position after comma to the start position of the node + return deleteRange({ pos: start, end: skipTrivia(sourceFile.text, nextToken.end, /*stopAfterLineBreaks*/ false, /*stopAtComments*/ true) }); + } + else { + return deleteNode(importClause.name); + } + } + + case SyntaxKind.NamespaceImport: + const namespaceImport = token.parent; + if (namespaceImport.name === token && !(namespaceImport.parent).name) { + const importDecl = getAncestor(namespaceImport, SyntaxKind.ImportDeclaration); + return deleteNode(importDecl); + } + else { + const previousToken = getTokenAtPosition(sourceFile, namespaceImport.pos - 1); + if (previousToken && previousToken.kind === SyntaxKind.CommaToken) { + const startPosition = textChanges.getAdjustedStartPosition(sourceFile, previousToken, {}, textChanges.Position.FullStart); + return deleteRange({ pos: startPosition, end: namespaceImport.end }); + } + return deleteRange(namespaceImport); + } + + default: + return deleteDefault(); + } } - else { - return undefined; + + // token.parent is a variableDeclaration + function deleteVariableDeclaration(varDecl: ts.VariableDeclaration): CodeAction[] | undefined { + switch (varDecl.parent.parent.kind) { + case SyntaxKind.ForStatement: + const forStatement = varDecl.parent.parent; + const forInitializer = forStatement.initializer; + if (forInitializer.declarations.length === 1) { + return deleteNode(forInitializer); + } + else { + return deleteNodeInList(varDecl); + } + + case SyntaxKind.ForOfStatement: + const forOfStatement = varDecl.parent.parent; + Debug.assert(forOfStatement.initializer.kind === SyntaxKind.VariableDeclarationList); + const forOfInitializer = forOfStatement.initializer; + return replaceNode(forOfInitializer.declarations[0], createObjectLiteral()); + + case SyntaxKind.ForInStatement: + // There is no valid fix in the case of: + // for .. in + return undefined; + + default: + const variableStatement = varDecl.parent.parent; + if (variableStatement.declarationList.declarations.length === 1) { + return deleteNode(variableStatement); + } + else { + return deleteNodeInList(varDecl); + } + } } function deleteNode(n: Node) { diff --git a/src/services/completions.ts b/src/services/completions.ts index 93f690c90f2..d6772447f5f 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -18,7 +18,7 @@ namespace ts.Completions { return undefined; } - const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag } = completionData; + const { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords } = completionData; if (requestJsDocTagName) { // If the current position is a jsDoc tag name, only tag names should be provided for completion @@ -52,7 +52,7 @@ namespace ts.Completions { sortText: "0", }); } - else { + else if (!hasFilteredClassMemberKeywords) { return undefined; } } @@ -60,8 +60,11 @@ namespace ts.Completions { getCompletionEntriesFromSymbols(symbols, entries, location, /*performCharacterChecks*/ true, typeChecker, compilerOptions.target, log); } + if (hasFilteredClassMemberKeywords) { + addRange(entries, classMemberKeywordCompletions); + } // Add keywords if this is not a member completion list - if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) { + else if (!isMemberCompletion && !requestJsDocTag && !requestJsDocTagName) { addRange(entries, keywordCompletions); } @@ -221,11 +224,12 @@ namespace ts.Completions { function getStringLiteralCompletionEntriesFromCallExpression(argumentInfo: SignatureHelp.ArgumentListInfo, typeChecker: TypeChecker): CompletionInfo | undefined { const candidates: Signature[] = []; const entries: CompletionEntry[] = []; + const uniques = createMap(); typeChecker.getResolvedSignature(argumentInfo.invocation, candidates); for (const candidate of candidates) { - addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker); + addStringLiteralCompletionsFromType(typeChecker.getParameterType(candidate, argumentInfo.argumentIndex), entries, typeChecker, uniques); } if (entries.length) { @@ -258,25 +262,29 @@ namespace ts.Completions { return undefined; } - function addStringLiteralCompletionsFromType(type: Type, result: Push, typeChecker: TypeChecker): void { + function addStringLiteralCompletionsFromType(type: Type, result: Push, typeChecker: TypeChecker, uniques = createMap()): void { if (type && type.flags & TypeFlags.TypeParameter) { - type = typeChecker.getApparentType(type); + type = typeChecker.getBaseConstraintOfType(type); } if (!type) { return; } if (type.flags & TypeFlags.Union) { for (const t of (type).types) { - addStringLiteralCompletionsFromType(t, result, typeChecker); + addStringLiteralCompletionsFromType(t, result, typeChecker, uniques); } } else if (type.flags & TypeFlags.StringLiteral) { - result.push({ - name: (type).value, - kindModifiers: ScriptElementKindModifier.none, - kind: ScriptElementKind.variableElement, - sortText: "0" - }); + const name = (type).value; + if (!uniques.has(name)) { + uniques.set(name, true); + result.push({ + name, + kindModifiers: ScriptElementKindModifier.none, + kind: ScriptElementKind.variableElement, + sortText: "0" + }); + } } } @@ -351,7 +359,7 @@ namespace ts.Completions { start = timestamp(); // Completion not allowed inside comments, bail out if this is the case - const insideComment = isInsideComment(sourceFile, currentToken, position); + const insideComment = isInComment(sourceFile, position, currentToken); log("getCompletionData: Is inside comment: " + (timestamp() - start)); if (insideComment) { @@ -406,7 +414,7 @@ namespace ts.Completions { } if (requestJsDocTagName || requestJsDocTag) { - return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName, requestJsDocTag }; + return { symbols: undefined, isGlobalCompletion: false, isMemberCompletion: false, isNewIdentifierLocation: false, location: undefined, isRightOfDot: false, requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords: false }; } if (!insideJsDocTagExpression) { @@ -505,6 +513,7 @@ namespace ts.Completions { let isGlobalCompletion = false; let isMemberCompletion: boolean; let isNewIdentifierLocation: boolean; + let hasFilteredClassMemberKeywords = false; let symbols: Symbol[] = []; if (isRightOfDot) { @@ -542,7 +551,7 @@ namespace ts.Completions { log("getCompletionData: Semantic work: " + (timestamp() - semanticStart)); - return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName, requestJsDocTag }; + return { symbols, isGlobalCompletion, isMemberCompletion, isNewIdentifierLocation, location, isRightOfDot: (isRightOfDot || isRightOfOpenTag), requestJsDocTagName, requestJsDocTag, hasFilteredClassMemberKeywords }; function getTypeScriptMemberSymbols(): void { // Right of dot member completion list @@ -599,6 +608,7 @@ namespace ts.Completions { function tryGetGlobalSymbols(): boolean { let objectLikeContainer: ObjectLiteralExpression | BindingPattern; let namedImportsOrExports: NamedImportsOrExports; + let classLikeContainer: ClassLikeDeclaration; let jsxContainer: JsxOpeningLikeElement; if (objectLikeContainer = tryGetObjectLikeCompletionContainer(contextToken)) { @@ -611,6 +621,12 @@ namespace ts.Completions { return tryGetImportOrExportClauseCompletionSymbols(namedImportsOrExports); } + if (classLikeContainer = tryGetClassLikeCompletionContainer(contextToken)) { + // cursor inside class declaration + getGetClassLikeCompletionSymbols(classLikeContainer); + return true; + } + if (jsxContainer = tryGetContainingJsxElement(contextToken)) { let attrsType: Type; if ((jsxContainer.kind === SyntaxKind.JsxSelfClosingElement) || (jsxContainer.kind === SyntaxKind.JsxOpeningElement)) { @@ -813,19 +829,16 @@ namespace ts.Completions { // We're looking up possible property names from contextual/inferred/declared type. isMemberCompletion = true; - let typeForObject: Type; + let typeMembers: Symbol[]; let existingMembers: Declaration[]; if (objectLikeContainer.kind === SyntaxKind.ObjectLiteralExpression) { // We are completing on contextual types, but may also include properties // other than those within the declared type. isNewIdentifierLocation = true; - - // If the object literal is being assigned to something of type 'null | { hello: string }', - // it clearly isn't trying to satisfy the 'null' type. So we grab the non-nullable type if possible. - typeForObject = typeChecker.getContextualType(objectLikeContainer); - typeForObject = typeForObject && typeForObject.getNonNullableType(); - + const typeForObject = typeChecker.getContextualType(objectLikeContainer); + if (!typeForObject) return false; + typeMembers = typeChecker.getAllPossiblePropertiesOfType(typeForObject); existingMembers = (objectLikeContainer).properties; } else if (objectLikeContainer.kind === SyntaxKind.ObjectBindingPattern) { @@ -849,7 +862,10 @@ namespace ts.Completions { } } if (canGetType) { - typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + const typeForObject = typeChecker.getTypeAtLocation(objectLikeContainer); + if (!typeForObject) return false; + // In a binding pattern, get only known properties. Everywhere else we will get all possible properties. + typeMembers = typeChecker.getPropertiesOfType(typeForObject); existingMembers = (objectLikeContainer).elements; } } @@ -861,11 +877,6 @@ namespace ts.Completions { Debug.fail("Expected object literal or binding pattern, got " + objectLikeContainer.kind); } - if (!typeForObject) { - return false; - } - - const typeMembers = typeChecker.getPropertiesOfType(typeForObject); if (typeMembers && typeMembers.length > 0) { // Add filtered items to the completion list symbols = filterObjectMembersList(typeMembers, existingMembers); @@ -913,6 +924,62 @@ namespace ts.Completions { return true; } + /** + * Aggregates relevant symbols for completion in class declaration + * Relevant symbols are stored in the captured 'symbols' variable. + */ + function getGetClassLikeCompletionSymbols(classLikeDeclaration: ClassLikeDeclaration) { + // We're looking up possible property names from parent type. + isMemberCompletion = true; + // Declaring new property/method/accessor + isNewIdentifierLocation = true; + // Has keywords for class elements + hasFilteredClassMemberKeywords = true; + + const baseTypeNode = getClassExtendsHeritageClauseElement(classLikeDeclaration); + const implementsTypeNodes = getClassImplementsHeritageClauseElements(classLikeDeclaration); + if (baseTypeNode || implementsTypeNodes) { + const classElement = contextToken.parent; + let classElementModifierFlags = isClassElement(classElement) && getModifierFlags(classElement); + // If this is context token is not something we are editing now, consider if this would lead to be modifier + if (contextToken.kind === SyntaxKind.Identifier && !isCurrentlyEditingNode(contextToken)) { + switch (contextToken.getText()) { + case "private": + classElementModifierFlags = classElementModifierFlags | ModifierFlags.Private; + break; + case "static": + classElementModifierFlags = classElementModifierFlags | ModifierFlags.Static; + break; + } + } + + // No member list for private methods + if (!(classElementModifierFlags & ModifierFlags.Private)) { + let baseClassTypeToGetPropertiesFrom: Type; + if (baseTypeNode) { + baseClassTypeToGetPropertiesFrom = typeChecker.getTypeAtLocation(baseTypeNode); + if (classElementModifierFlags & ModifierFlags.Static) { + // Use static class to get property symbols from + baseClassTypeToGetPropertiesFrom = typeChecker.getTypeOfSymbolAtLocation( + baseClassTypeToGetPropertiesFrom.symbol, classLikeDeclaration); + } + } + const implementedInterfaceTypePropertySymbols = (classElementModifierFlags & ModifierFlags.Static) ? + undefined : + flatMap(implementsTypeNodes, typeNode => typeChecker.getPropertiesOfType(typeChecker.getTypeAtLocation(typeNode))); + + // List of property symbols of base type that are not private and already implemented + symbols = filterClassMembersList( + baseClassTypeToGetPropertiesFrom ? + typeChecker.getPropertiesOfType(baseClassTypeToGetPropertiesFrom) : + undefined, + implementedInterfaceTypePropertySymbols, + classLikeDeclaration.members, + classElementModifierFlags); + } + } + } + /** * Returns the immediate owning object literal or binding pattern of a context token, * on the condition that one exists and that the context implies completion should be given. @@ -953,6 +1020,49 @@ namespace ts.Completions { return undefined; } + function isFromClassElementDeclaration(node: Node) { + return isClassElement(node.parent) && isClassLike(node.parent.parent); + } + + /** + * Returns the immediate owning class declaration of a context token, + * on the condition that one exists and that the context implies completion should be given. + */ + function tryGetClassLikeCompletionContainer(contextToken: Node): ClassLikeDeclaration { + if (contextToken) { + switch (contextToken.kind) { + case SyntaxKind.OpenBraceToken: // class c { | + if (isClassLike(contextToken.parent)) { + return contextToken.parent; + } + break; + + // class c {getValue(): number; | } + case SyntaxKind.CommaToken: + case SyntaxKind.SemicolonToken: + // class c { method() { } | } + case SyntaxKind.CloseBraceToken: + if (isClassLike(location)) { + return location; + } + break; + + default: + if (isFromClassElementDeclaration(contextToken) && + (isClassMemberCompletionKeyword(contextToken.kind) || + isClassMemberCompletionKeywordText(contextToken.getText()))) { + return contextToken.parent.parent as ClassLikeDeclaration; + } + } + } + + // class c { method() { } | method2() { } } + if (location && location.kind === SyntaxKind.SyntaxList && isClassLike(location.parent)) { + return location.parent; + } + return undefined; + } + function tryGetContainingJsxElement(contextToken: Node): JsxOpeningLikeElement { if (contextToken) { const parent = contextToken.parent; @@ -1081,7 +1191,7 @@ namespace ts.Completions { isFunction(containingNodeKind); case SyntaxKind.StaticKeyword: - return containingNodeKind === SyntaxKind.PropertyDeclaration; + return containingNodeKind === SyntaxKind.PropertyDeclaration && !isClassLike(contextToken.parent.parent); case SyntaxKind.DotDotDotToken: return containingNodeKind === SyntaxKind.Parameter || @@ -1098,13 +1208,17 @@ namespace ts.Completions { containingNodeKind === SyntaxKind.ExportSpecifier || containingNodeKind === SyntaxKind.NamespaceImport; + case SyntaxKind.GetKeyword: + case SyntaxKind.SetKeyword: + if (isFromClassElementDeclaration(contextToken)) { + return false; + } + // falls through case SyntaxKind.ClassKeyword: case SyntaxKind.EnumKeyword: case SyntaxKind.InterfaceKeyword: case SyntaxKind.FunctionKeyword: case SyntaxKind.VarKeyword: - case SyntaxKind.GetKeyword: - case SyntaxKind.SetKeyword: case SyntaxKind.ImportKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.ConstKeyword: @@ -1113,6 +1227,13 @@ namespace ts.Completions { return true; } + // If the previous token is keyword correspoding to class member completion keyword + // there will be completion available here + if (isClassMemberCompletionKeywordText(contextToken.getText()) && + isFromClassElementDeclaration(contextToken)) { + return false; + } + // Previous token may have been a keyword that was converted to an identifier. switch (contextToken.getText()) { case "abstract": @@ -1159,7 +1280,7 @@ namespace ts.Completions { for (const element of namedImportsOrExports) { // If this is the current item we are editing right now, do not filter it out - if (element.getStart() <= position && position <= element.getEnd()) { + if (isCurrentlyEditingNode(element)) { continue; } @@ -1198,7 +1319,7 @@ namespace ts.Completions { } // If this is the current item we are editing right now, do not filter it out - if (m.getStart() <= position && position <= m.getEnd()) { + if (isCurrentlyEditingNode(m)) { continue; } @@ -1214,7 +1335,7 @@ namespace ts.Completions { // TODO(jfreeman): Account for computed property name // NOTE: if one only performs this step when m.name is an identifier, // things like '__proto__' are not filtered out. - existingName = (m.name).text; + existingName = (getNameOfDeclaration(m) as Identifier).text; } existingMemberNames.set(existingName, true); @@ -1223,6 +1344,58 @@ namespace ts.Completions { return filter(contextualMemberSymbols, m => !existingMemberNames.get(m.name)); } + /** + * Filters out completion suggestions for class elements. + * + * @returns Symbols to be suggested in an class element depending on existing memebers and symbol flags + */ + function filterClassMembersList(baseSymbols: Symbol[], implementingTypeSymbols: Symbol[], existingMembers: ClassElement[], currentClassElementModifierFlags: ModifierFlags): Symbol[] { + const existingMemberNames = createMap(); + for (const m of existingMembers) { + // Ignore omitted expressions for missing members + if (m.kind !== SyntaxKind.PropertyDeclaration && + m.kind !== SyntaxKind.MethodDeclaration && + m.kind !== SyntaxKind.GetAccessor && + m.kind !== SyntaxKind.SetAccessor) { + continue; + } + + // If this is the current item we are editing right now, do not filter it out + if (isCurrentlyEditingNode(m)) { + continue; + } + + // Dont filter member even if the name matches if it is declared private in the list + if (hasModifier(m, ModifierFlags.Private)) { + continue; + } + + // do not filter it out if the static presence doesnt match + const mIsStatic = hasModifier(m, ModifierFlags.Static); + const currentElementIsStatic = !!(currentClassElementModifierFlags & ModifierFlags.Static); + if ((mIsStatic && !currentElementIsStatic) || + (!mIsStatic && currentElementIsStatic)) { + continue; + } + + const existingName = getPropertyNameForPropertyNameNode(m.name); + if (existingName) { + existingMemberNames.set(existingName, true); + } + } + + return concatenate( + filter(baseSymbols, baseProperty => isValidProperty(baseProperty, ModifierFlags.Private)), + filter(implementingTypeSymbols, implementingProperty => isValidProperty(implementingProperty, ModifierFlags.NonPublicAccessibilityModifier)) + ); + + function isValidProperty(propertySymbol: Symbol, inValidModifierFlags: ModifierFlags) { + return !existingMemberNames.get(propertySymbol.name) && + propertySymbol.getDeclarations() && + !(getDeclarationModifierFlagsFromSymbol(propertySymbol) & inValidModifierFlags); + } + } + /** * Filters out completion suggestions from 'symbols' according to existing JSX attributes. * @@ -1233,7 +1406,7 @@ namespace ts.Completions { const seenNames = createMap(); for (const attr of attributes) { // If this is the current item we are editing right now, do not filter it out - if (attr.getStart() <= position && position <= attr.getEnd()) { + if (isCurrentlyEditingNode(attr)) { continue; } @@ -1244,6 +1417,10 @@ namespace ts.Completions { return filter(symbols, a => !seenNames.get(a.name)); } + + function isCurrentlyEditingNode(node: Node): boolean { + return node.getStart() <= position && position <= node.getEnd(); + } } /** @@ -1306,6 +1483,29 @@ namespace ts.Completions { }); } + function isClassMemberCompletionKeyword(kind: SyntaxKind) { + switch (kind) { + case SyntaxKind.PublicKeyword: + case SyntaxKind.ProtectedKeyword: + case SyntaxKind.PrivateKeyword: + case SyntaxKind.AbstractKeyword: + case SyntaxKind.StaticKeyword: + case SyntaxKind.ConstructorKeyword: + case SyntaxKind.ReadonlyKeyword: + case SyntaxKind.GetKeyword: + case SyntaxKind.SetKeyword: + case SyntaxKind.AsyncKeyword: + return true; + } + } + + function isClassMemberCompletionKeywordText(text: string) { + return isClassMemberCompletionKeyword(stringToToken(text)); + } + + const classMemberKeywordCompletions = filter(keywordCompletions, entry => + isClassMemberCompletionKeywordText(entry.name)); + function isEqualityExpression(node: Node): node is BinaryExpression { return isBinaryExpression(node) && isEqualityOperatorKind(node.operatorToken.kind); } diff --git a/src/services/findAllReferences.ts b/src/services/findAllReferences.ts index fd717fc546e..d9deaef9e56 100644 --- a/src/services/findAllReferences.ts +++ b/src/services/findAllReferences.ts @@ -108,10 +108,6 @@ namespace ts.FindAllReferences { switch (def.type) { case "symbol": { const { symbol, node } = def; - const declarations = symbol.declarations; - if (!declarations || declarations.length === 0) { - return undefined; - } const { displayParts, kind } = getDefinitionKindAndDisplayParts(symbol, node, checker); const name = displayParts.map(p => p.text).join(""); return { node, name, kind, displayParts }; @@ -285,11 +281,6 @@ namespace ts.FindAllReferences.Core { return undefined; } - // The symbol was an internal symbol and does not have a declaration e.g. undefined symbol - if (!symbol.declarations || !symbol.declarations.length) { - return undefined; - } - return getReferencedSymbolsForSymbol(symbol, node, sourceFiles, checker, cancellationToken, options); } @@ -559,7 +550,7 @@ namespace ts.FindAllReferences.Core { } function isObjectBindingPatternElementWithoutPropertyName(symbol: Symbol): boolean { - const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); return bindingElement && bindingElement.parent.kind === SyntaxKind.ObjectBindingPattern && !bindingElement.propertyName; @@ -567,7 +558,7 @@ namespace ts.FindAllReferences.Core { function getPropertySymbolOfObjectBindingPatternWithoutPropertyName(symbol: Symbol, checker: TypeChecker): Symbol | undefined { if (isObjectBindingPatternElementWithoutPropertyName(symbol)) { - const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); + const bindingElement = getDeclarationOfKind(symbol, SyntaxKind.BindingElement); const typeOfPattern = checker.getTypeAtLocation(bindingElement.parent); return typeOfPattern && checker.getPropertyOfType(typeOfPattern, (bindingElement.name).text); } @@ -646,7 +637,9 @@ namespace ts.FindAllReferences.Core { return parent ? scope.getSourceFile() : scope; } - function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, start: number, end: number): number[] { + function getPossibleSymbolReferencePositions(sourceFile: SourceFile, symbolName: string, container: Node = sourceFile, fullStart = false): number[] { + const start = fullStart ? container.getFullStart() : container.getStart(sourceFile); + const end = container.getEnd(); const positions: number[] = []; /// TODO: Cache symbol existence for files to save text search @@ -685,16 +678,11 @@ namespace ts.FindAllReferences.Core { const references: Entry[] = []; const sourceFile = container.getSourceFile(); const labelName = targetLabel.text; - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container.getStart(), container.getEnd()); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, labelName, container); for (const position of possiblePositions) { const node = getTouchingWord(sourceFile, position); - if (!node || node.getWidth() !== labelName.length) { - continue; - } - // Only pick labels that are either the target label, or have a target that is the target label - if (node === targetLabel || - (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel)) { + if (node && (node === targetLabel || (isJumpStatementTarget(node) && getTargetLabel(node, labelName) === targetLabel))) { references.push(nodeEntry(node)); } } @@ -706,15 +694,14 @@ namespace ts.FindAllReferences.Core { // Compare the length so we filter out strict superstrings of the symbol we are looking for switch (node && node.kind) { case SyntaxKind.Identifier: - return node.getWidth() === searchSymbolName.length; + return unescapeIdentifier((node as Identifier).text).length === searchSymbolName.length; case SyntaxKind.StringLiteral: return (isLiteralNameOfPropertyDeclarationOrIndexAccess(node) || isNameOfExternalModuleImportOrDeclaration(node)) && - // For string literals we have two additional chars for the quotes - node.getWidth() === searchSymbolName.length + 2; + (node as StringLiteral).text.length === searchSymbolName.length; case SyntaxKind.NumericLiteral: - return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && node.getWidth() === searchSymbolName.length; + return isLiteralNameOfPropertyDeclarationOrIndexAccess(node) && (node as NumericLiteral).text.length === searchSymbolName.length; default: return false; @@ -731,7 +718,7 @@ namespace ts.FindAllReferences.Core { } function addReferencesForKeywordInFile(sourceFile: SourceFile, kind: SyntaxKind, searchText: string, references: Push): void { - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText, sourceFile.getStart(), sourceFile.getEnd()); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, searchText); for (const position of possiblePositions) { const referenceLocation = getTouchingPropertyName(sourceFile, position); if (referenceLocation.kind === kind) { @@ -755,9 +742,7 @@ namespace ts.FindAllReferences.Core { return; } - const start = state.findInComments ? container.getFullStart() : container.getStart(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, search.text, start, container.getEnd()); - for (const position of possiblePositions) { + for (const position of getPossibleSymbolReferencePositions(sourceFile, search.text, container, /*fullStart*/ state.findInComments)) { getReferencesAtLocation(sourceFile, position, search, state); } } @@ -908,7 +893,7 @@ namespace ts.FindAllReferences.Core { * position of property accessing, the referenceEntry of such position will be handled in the first case. */ if (!(flags & SymbolFlags.Transient) && search.includes(shorthandValueSymbol)) { - addReference(valueDeclaration.name, shorthandValueSymbol, search.location, state); + addReference(getNameOfDeclaration(valueDeclaration), shorthandValueSymbol, search.location, state); } } @@ -1201,7 +1186,7 @@ namespace ts.FindAllReferences.Core { const references: Entry[] = []; const sourceFile = searchSpaceNode.getSourceFile(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "super", searchSpaceNode); for (const position of possiblePositions) { const node = getTouchingWord(sourceFile, position); @@ -1263,13 +1248,13 @@ namespace ts.FindAllReferences.Core { if (searchSpaceNode.kind === SyntaxKind.SourceFile) { forEach(sourceFiles, sourceFile => { cancellationToken.throwIfCancellationRequested(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", sourceFile.getStart(), sourceFile.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this"); getThisReferencesInFile(sourceFile, sourceFile, possiblePositions, references); }); } else { const sourceFile = searchSpaceNode.getSourceFile(); - possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode.getStart(), searchSpaceNode.getEnd()); + possiblePositions = getPossibleSymbolReferencePositions(sourceFile, "this", searchSpaceNode); getThisReferencesInFile(sourceFile, searchSpaceNode, possiblePositions, references); } @@ -1323,7 +1308,7 @@ namespace ts.FindAllReferences.Core { for (const sourceFile of sourceFiles) { cancellationToken.throwIfCancellationRequested(); - const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text, sourceFile.getStart(), sourceFile.getEnd()); + const possiblePositions = getPossibleSymbolReferencePositions(sourceFile, node.text); getReferencesForStringLiteralInFile(sourceFile, node.text, possiblePositions, references); } diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index d7c32da5e8d..d5bd33e33cc 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -362,7 +362,7 @@ namespace ts.formatting { sourceFile: SourceFileLike): TextChange[] { // formatting context is used by rules provider - const formattingContext = new FormattingContext(sourceFile, requestKind); + const formattingContext = new FormattingContext(sourceFile, requestKind, options); let previousRangeHasError: boolean; let previousRange: TextRangeWithKind; let previousParent: Node; @@ -487,7 +487,7 @@ namespace ts.formatting { // falls through case SyntaxKind.PropertyDeclaration: case SyntaxKind.Parameter: - return (node).name.kind; + return getNameOfDeclaration(node).kind; } } diff --git a/src/services/formatting/formattingContext.ts b/src/services/formatting/formattingContext.ts index 26b538dfc5e..043df72f434 100644 --- a/src/services/formatting/formattingContext.ts +++ b/src/services/formatting/formattingContext.ts @@ -15,7 +15,7 @@ namespace ts.formatting { private contextNodeBlockIsOnOneLine: boolean; private nextNodeBlockIsOnOneLine: boolean; - constructor(public readonly sourceFile: SourceFileLike, public formattingRequestKind: FormattingRequestKind) { + constructor(public readonly sourceFile: SourceFileLike, public formattingRequestKind: FormattingRequestKind, public options: ts.FormatCodeSettings) { } public updateContext(currentRange: TextRangeWithKind, currentTokenParent: Node, nextRange: TextRangeWithKind, nextTokenParent: Node, commonParent: Node) { diff --git a/src/services/formatting/ruleOperationContext.ts b/src/services/formatting/ruleOperationContext.ts index 6c368dcc617..6a19e23d57d 100644 --- a/src/services/formatting/ruleOperationContext.ts +++ b/src/services/formatting/ruleOperationContext.ts @@ -12,12 +12,11 @@ namespace ts.formatting { static Any: RuleOperationContext = new RuleOperationContext(); - public IsAny(): boolean { return this === RuleOperationContext.Any; } - public InContext(context: FormattingContext): boolean { + public InContext(context: FormattingContext): boolean { if (this.IsAny()) { return true; } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index fb99a2a4675..2c1becb8dd1 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -84,6 +84,7 @@ namespace ts.formatting { public NoSpaceBeforeComma: Rule; public SpaceAfterCertainKeywords: Rule; + public NoSpaceAfterNewKeywordOnConstructorSignature: Rule; public SpaceAfterLetConstInVariableDeclaration: Rule; public NoSpaceBeforeOpenParenInFuncCall: Rule; public SpaceAfterFunctionInFuncDecl: Rule; @@ -147,6 +148,9 @@ namespace ts.formatting { // These rules are higher in priority than user-configurable rules. public HighPriorityCommonRules: Rule[]; + // These rules are applied after high priority rules. + public UserConfigurableRules: Rule[]; + // These rules are lower in priority than user-configurable rules. public LowPriorityCommonRules: Rule[]; @@ -279,7 +283,9 @@ namespace ts.formatting { this.NoSpaceAfterDot = new Rule(RuleDescriptor.create3(SyntaxKind.DotToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); // No space before and after indexer - this.NoSpaceBeforeOpenBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceBeforeOpenBracket = new Rule( + RuleDescriptor.create2(Shared.TokenRange.AnyExcept(SyntaxKind.AsyncKeyword), SyntaxKind.OpenBracketToken), + RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); this.NoSpaceAfterCloseBracket = new Rule(RuleDescriptor.create3(SyntaxKind.CloseBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNotBeforeBlockInFunctionDeclarationContext), RuleAction.Delete)); // Place a space before open brace in a function declaration @@ -295,10 +301,10 @@ namespace ts.formatting { this.SpaceBeforeOpenBraceInControl = new Rule(RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext, Rules.IsNotFormatOnEnter, Rules.IsSameLineTokenOrBeforeMultilineBlockContext), RuleAction.Space), RuleFlags.CanDeleteNewLines); // Insert a space after { and before } in single-line contexts, but remove space from empty object literals {}. - this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Space)); - this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsBraceWrappedContext), RuleAction.Space)); - this.NoSpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), Rules.IsBraceWrappedContext), RuleAction.Space)); + this.SpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), Rules.IsBraceWrappedContext), RuleAction.Space)); + this.NoSpaceAfterOpenBrace = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseBrace = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); this.NoSpaceBetweenEmptyBraceBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBraceToken, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsObjectContext), RuleAction.Delete)); // Insert new line after { and before } in multi-line contexts. @@ -331,11 +337,12 @@ namespace ts.formatting { this.NoSpaceBeforeComma = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CommaToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); this.SpaceAfterCertainKeywords = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.VarKeyword, SyntaxKind.ThrowKeyword, SyntaxKind.NewKeyword, SyntaxKind.DeleteKeyword, SyntaxKind.ReturnKeyword, SyntaxKind.TypeOfKeyword, SyntaxKind.AwaitKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterNewKeywordOnConstructorSignature = new Rule(RuleDescriptor.create1(SyntaxKind.NewKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsConstructorSignatureContext), RuleAction.Delete)); this.SpaceAfterLetConstInVariableDeclaration = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.LetKeyword, SyntaxKind.ConstKeyword]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsStartOfVariableDeclarationList), RuleAction.Space)); this.NoSpaceBeforeOpenParenInFuncCall = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionCallOrNewContext, Rules.IsPreviousTokenNotComma), RuleAction.Delete)); this.SpaceAfterFunctionInFuncDecl = new Rule(RuleDescriptor.create3(SyntaxKind.FunctionKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); - this.SpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Space)); - this.NoSpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Delete)); + this.SpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceBeforeFunctionParenthesis"), Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Space)); + this.NoSpaceBeforeOpenParenInFuncDecl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceBeforeFunctionParenthesis"), Rules.IsNonJsxSameLineTokenContext, Rules.IsFunctionDeclContext), RuleAction.Delete)); this.SpaceAfterVoidOperator = new Rule(RuleDescriptor.create3(SyntaxKind.VoidKeyword, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsVoidOpContext), RuleAction.Space)); this.NoSpaceBetweenReturnAndSemicolon = new Rule(RuleDescriptor.create1(SyntaxKind.ReturnKeyword, SyntaxKind.SemicolonToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); @@ -357,9 +364,8 @@ namespace ts.formatting { // TypeScript-specific higher priority rules - // Treat constructor as an identifier in a function declaration, and remove spaces between constructor and following left parentheses - this.SpaceAfterConstructor = new Rule(RuleDescriptor.create1(SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.NoSpaceAfterConstructor = new Rule(RuleDescriptor.create1(SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterConstructor = new Rule(RuleDescriptor.create1(SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterConstructor"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.NoSpaceAfterConstructor = new Rule(RuleDescriptor.create1(SyntaxKind.ConstructorKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterConstructor"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); // Use of module as a function call. e.g.: import m2 = module("m2"); this.NoSpaceAfterModuleImport = new Rule(RuleDescriptor.create2(Shared.TokenRange.FromTokens([SyntaxKind.ModuleKeyword, SyntaxKind.RequireKeyword]), SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); @@ -416,6 +422,72 @@ namespace ts.formatting { // No space before non-null assertion operator this.NoSpaceBeforeNonNullAssertionOperator = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.ExclamationToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonNullAssertionContext), RuleAction.Delete)); + /// + /// Rules controlled by user options + /// + + // Insert space after comma delimiter + this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterCommaDelimiter"), Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space)); + this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterCommaDelimiter"), Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), RuleAction.Delete)); + + // Insert space before and after binary operators + this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space)); + this.SpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceBeforeAndAfterBinaryOperators"), Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space)); + this.NoSpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete)); + this.NoSpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceBeforeAndAfterBinaryOperators"), Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete)); + + // Insert space after keywords in control flow statements + this.SpaceAfterKeywordInControl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Keywords, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterKeywordsInControlFlowStatements"), Rules.IsControlDeclContext), RuleAction.Space)); + this.NoSpaceAfterKeywordInControl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Keywords, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterKeywordsInControlFlowStatements"), Rules.IsControlDeclContext), RuleAction.Delete)); + + // Open Brace braces after function + // TypeScript: Function can have return types, which can be made of tons of different token kinds + this.NewLineBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("placeOpenBraceOnNewLineForFunctions"), Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines); + + // Open Brace braces after TypeScript module/class/interface + this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("placeOpenBraceOnNewLineForFunctions"), Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines); + + // Open Brace braces after control block + this.NewLineBeforeOpenBraceInControl = new Rule(RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("placeOpenBraceOnNewLineForControlBlocks"), Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines); + + // Insert space after semicolon in for statement + this.SpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterSemicolonInForStatements"), Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), RuleAction.Space)); + this.NoSpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterSemicolonInForStatements"), Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), RuleAction.Delete)); + + // Insert space after opening and before closing nonempty parenthesis + this.SpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.SpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenParens = new Rule(RuleDescriptor.create1(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + + // Insert space after opening and before closing nonempty brackets + this.SpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.SpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBetweenBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + + // Insert space after opening and before closing template string braces + this.NoSpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.SpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); + this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces"), Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); + + // No space after { and before } in JSX expression + this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Delete)); + this.SpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Space)); + this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Delete)); + this.SpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces"), Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Space)); + + // Insert space after function keyword for anonymous functions + this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), Rules.IsFunctionDeclContext), RuleAction.Space)); + this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterFunctionKeywordForAnonymousFunctions"), Rules.IsFunctionDeclContext), RuleAction.Delete)); + + // No space after type assertion + this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionDisabledOrUndefined("insertSpaceAfterTypeAssertion"), Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete)); + this.SpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsOptionEnabled("insertSpaceAfterTypeAssertion"), Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Space)); + // These rules are higher in priority than user-configurable rules. this.HighPriorityCommonRules = [ this.IgnoreBeforeComment, this.IgnoreAfterLineComment, @@ -462,7 +534,27 @@ namespace ts.formatting { this.SpaceBeforeAt, this.NoSpaceAfterAt, this.SpaceAfterDecorator, - this.NoSpaceBeforeNonNullAssertionOperator + this.NoSpaceBeforeNonNullAssertionOperator, + this.NoSpaceAfterNewKeywordOnConstructorSignature + ]; + + // These rules are applied after high priority rules. + this.UserConfigurableRules = [ + this.SpaceAfterConstructor, this.NoSpaceAfterConstructor, + this.SpaceAfterComma, this.NoSpaceAfterComma, + this.SpaceAfterAnonymousFunctionKeyword, this.NoSpaceAfterAnonymousFunctionKeyword, + this.SpaceAfterKeywordInControl, this.NoSpaceAfterKeywordInControl, + this.SpaceAfterOpenParen, this.SpaceBeforeCloseParen, this.NoSpaceBetweenParens, this.NoSpaceAfterOpenParen, this.NoSpaceBeforeCloseParen, + this.SpaceAfterOpenBracket, this.SpaceBeforeCloseBracket, this.NoSpaceBetweenBrackets, this.NoSpaceAfterOpenBracket, this.NoSpaceBeforeCloseBracket, + this.SpaceAfterOpenBrace, this.SpaceBeforeCloseBrace, this.NoSpaceBetweenEmptyBraceBrackets, this.NoSpaceAfterOpenBrace, this.NoSpaceBeforeCloseBrace, + this.SpaceAfterTemplateHeadAndMiddle, this.SpaceBeforeTemplateMiddleAndTail, this.NoSpaceAfterTemplateHeadAndMiddle, this.NoSpaceBeforeTemplateMiddleAndTail, + this.SpaceAfterOpenBraceInJsxExpression, this.SpaceBeforeCloseBraceInJsxExpression, this.NoSpaceAfterOpenBraceInJsxExpression, this.NoSpaceBeforeCloseBraceInJsxExpression, + this.SpaceAfterSemicolonInFor, this.NoSpaceAfterSemicolonInFor, + this.SpaceBeforeBinaryOperator, this.SpaceAfterBinaryOperator, this.NoSpaceBeforeBinaryOperator, this.NoSpaceAfterBinaryOperator, + this.SpaceBeforeOpenParenInFuncDecl, this.NoSpaceBeforeOpenParenInFuncDecl, + this.NewLineBeforeOpenBraceInControl, + this.NewLineBeforeOpenBraceInFunction, this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock, + this.SpaceAfterTypeAssertion, this.NoSpaceAfterTypeAssertion ]; // These rules are lower in priority than user-configurable rules. @@ -475,79 +567,28 @@ namespace ts.formatting { this.SpaceAfterSemicolon, this.SpaceBetweenStatements, this.SpaceAfterTryFinally ]; - - /// - /// Rules controlled by user options - /// - - // Insert space after comma delimiter - this.SpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext, Rules.IsNextTokenNotCloseBracket), RuleAction.Space)); - this.NoSpaceAfterComma = new Rule(RuleDescriptor.create3(SyntaxKind.CommaToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsNonJsxElementContext), RuleAction.Delete)); - - // Insert space before and after binary operators - this.SpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space)); - this.SpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Space)); - this.NoSpaceBeforeBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.BinaryOperators), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete)); - this.NoSpaceAfterBinaryOperator = new Rule(RuleDescriptor.create4(Shared.TokenRange.BinaryOperators, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsBinaryOpContext), RuleAction.Delete)); - - // Insert space after keywords in control flow statements - this.SpaceAfterKeywordInControl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Keywords, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext), RuleAction.Space)); - this.NoSpaceAfterKeywordInControl = new Rule(RuleDescriptor.create2(Shared.TokenRange.Keywords, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext), RuleAction.Delete)); - - // Open Brace braces after function - // TypeScript: Function can have return types, which can be made of tons of different token kinds - this.NewLineBeforeOpenBraceInFunction = new Rule(RuleDescriptor.create2(this.FunctionOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines); - - // Open Brace braces after TypeScript module/class/interface - this.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock = new Rule(RuleDescriptor.create2(this.TypeScriptOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsTypeScriptDeclWithBlockContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines); - - // Open Brace braces after control block - this.NewLineBeforeOpenBraceInControl = new Rule(RuleDescriptor.create2(this.ControlOpenBraceLeftTokenRange, SyntaxKind.OpenBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsControlDeclContext, Rules.IsBeforeMultilineBlockContext), RuleAction.NewLine), RuleFlags.CanDeleteNewLines); - - // Insert space after semicolon in for statement - this.SpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), RuleAction.Space)); - this.NoSpaceAfterSemicolonInFor = new Rule(RuleDescriptor.create3(SyntaxKind.SemicolonToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsForContext), RuleAction.Delete)); - - // Insert space after opening and before closing nonempty parenthesis - this.SpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.SpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBetweenParens = new Rule(RuleDescriptor.create1(SyntaxKind.OpenParenToken, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceAfterOpenParen = new Rule(RuleDescriptor.create3(SyntaxKind.OpenParenToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseParen = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - - // Insert space after opening and before closing nonempty brackets - this.SpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.SpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBetweenBrackets = new Rule(RuleDescriptor.create1(SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceAfterOpenBracket = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBracketToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.NoSpaceBeforeCloseBracket = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBracketToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - - // Insert space after opening and before closing template string braces - this.NoSpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.SpaceAfterTemplateHeadAndMiddle = new Rule(RuleDescriptor.create4(Shared.TokenRange.FromTokens([SyntaxKind.TemplateHead, SyntaxKind.TemplateMiddle]), Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - this.NoSpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Delete)); - this.SpaceBeforeTemplateMiddleAndTail = new Rule(RuleDescriptor.create4(Shared.TokenRange.Any, Shared.TokenRange.FromTokens([SyntaxKind.TemplateMiddle, SyntaxKind.TemplateTail])), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext), RuleAction.Space)); - - // No space after { and before } in JSX expression - this.NoSpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Delete)); - this.SpaceAfterOpenBraceInJsxExpression = new Rule(RuleDescriptor.create3(SyntaxKind.OpenBraceToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Space)); - this.NoSpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Delete)); - this.SpaceBeforeCloseBraceInJsxExpression = new Rule(RuleDescriptor.create2(Shared.TokenRange.Any, SyntaxKind.CloseBraceToken), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsJsxExpressionContext), RuleAction.Space)); - - // Insert space after function keyword for anonymous functions - this.SpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Space)); - this.NoSpaceAfterAnonymousFunctionKeyword = new Rule(RuleDescriptor.create1(SyntaxKind.FunctionKeyword, SyntaxKind.OpenParenToken), RuleOperation.create2(new RuleOperationContext(Rules.IsFunctionDeclContext), RuleAction.Delete)); - - // No space after type assertion - this.NoSpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Delete)); - this.SpaceAfterTypeAssertion = new Rule(RuleDescriptor.create3(SyntaxKind.GreaterThanToken, Shared.TokenRange.Any), RuleOperation.create2(new RuleOperationContext(Rules.IsNonJsxSameLineTokenContext, Rules.IsTypeAssertionContext), RuleAction.Space)); - } /// /// Contexts /// + static IsOptionEnabled(optionName: keyof FormatCodeSettings): (context: FormattingContext) => boolean { + return (context) => context.options && context.options.hasOwnProperty(optionName) && !!context.options[optionName]; + } + + static IsOptionDisabled(optionName: keyof FormatCodeSettings): (context: FormattingContext) => boolean { + return (context) => context.options && context.options.hasOwnProperty(optionName) && !context.options[optionName]; + } + + static IsOptionDisabledOrUndefined(optionName: keyof FormatCodeSettings): (context: FormattingContext) => boolean { + return (context) => !context.options || !context.options.hasOwnProperty(optionName) || !context.options[optionName]; + } + + static IsOptionEnabledOrUndefined(optionName: keyof FormatCodeSettings): (context: FormattingContext) => boolean { + return (context) => !context.options || !context.options.hasOwnProperty(optionName) || !!context.options[optionName]; + } + static IsForContext(context: FormattingContext): boolean { return context.contextNode.kind === SyntaxKind.ForStatement; } @@ -845,6 +886,10 @@ namespace ts.formatting { return context.contextNode.kind === SyntaxKind.TypeLiteral; // && context.contextNode.parent.kind !== SyntaxKind.InterfaceDeclaration; } + static IsConstructorSignatureContext(context: FormattingContext): boolean { + return context.contextNode.kind === SyntaxKind.ConstructSignature; + } + static IsTypeArgumentOrParameterOrAssertion(token: TextRangeWithKind, parent: Node): boolean { if (token.kind !== SyntaxKind.LessThanToken && token.kind !== SyntaxKind.GreaterThanToken) { return false; diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index cd6f2e539d6..5b4eacd2c2a 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -41,8 +41,7 @@ namespace ts.formatting { } private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void { - const specificRule = rule.Descriptor.LeftTokenRange !== Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange !== Shared.TokenRange.Any; + const specificRule = rule.Descriptor.LeftTokenRange.isSpecific() && rule.Descriptor.RightTokenRange.isSpecific(); rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => { rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => { diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index 660d5f34a0e..790bce054b0 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -5,11 +5,12 @@ namespace ts.formatting { export class RulesProvider { private globalRules: Rules; private options: ts.FormatCodeSettings; - private activeRules: Rule[]; private rulesMap: RulesMap; constructor() { this.globalRules = new Rules(); + const activeRules = this.globalRules.HighPriorityCommonRules.slice(0).concat(this.globalRules.UserConfigurableRules).concat(this.globalRules.LowPriorityCommonRules); + this.rulesMap = RulesMap.create(activeRules); } public getRuleName(rule: Rule): string { @@ -30,141 +31,8 @@ namespace ts.formatting { public ensureUpToDate(options: ts.FormatCodeSettings) { if (!this.options || !ts.compareDataObjects(this.options, options)) { - const activeRules = this.createActiveRules(options); - const rulesMap = RulesMap.create(activeRules); - - this.activeRules = activeRules; - this.rulesMap = rulesMap; this.options = ts.clone(options); } } - - private createActiveRules(options: ts.FormatCodeSettings): Rule[] { - let rules = this.globalRules.HighPriorityCommonRules.slice(0); - - if (options.insertSpaceAfterConstructor) { - rules.push(this.globalRules.SpaceAfterConstructor); - } - else { - rules.push(this.globalRules.NoSpaceAfterConstructor); - } - - if (options.insertSpaceAfterCommaDelimiter) { - rules.push(this.globalRules.SpaceAfterComma); - } - else { - rules.push(this.globalRules.NoSpaceAfterComma); - } - - if (options.insertSpaceAfterFunctionKeywordForAnonymousFunctions) { - rules.push(this.globalRules.SpaceAfterAnonymousFunctionKeyword); - } - else { - rules.push(this.globalRules.NoSpaceAfterAnonymousFunctionKeyword); - } - - if (options.insertSpaceAfterKeywordsInControlFlowStatements) { - rules.push(this.globalRules.SpaceAfterKeywordInControl); - } - else { - rules.push(this.globalRules.NoSpaceAfterKeywordInControl); - } - - if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis) { - rules.push(this.globalRules.SpaceAfterOpenParen); - rules.push(this.globalRules.SpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenParen); - rules.push(this.globalRules.NoSpaceBeforeCloseParen); - rules.push(this.globalRules.NoSpaceBetweenParens); - } - - if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets) { - rules.push(this.globalRules.SpaceAfterOpenBracket); - rules.push(this.globalRules.SpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBracket); - rules.push(this.globalRules.NoSpaceBeforeCloseBracket); - rules.push(this.globalRules.NoSpaceBetweenBrackets); - } - - // The default value of InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces is true - // so if the option is undefined, we should treat it as true as well - if (options.insertSpaceAfterOpeningAndBeforeClosingNonemptyBraces !== false) { - rules.push(this.globalRules.SpaceAfterOpenBrace); - rules.push(this.globalRules.SpaceBeforeCloseBrace); - rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBrace); - rules.push(this.globalRules.NoSpaceBeforeCloseBrace); - rules.push(this.globalRules.NoSpaceBetweenEmptyBraceBrackets); - } - - if (options.insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces) { - rules.push(this.globalRules.SpaceAfterTemplateHeadAndMiddle); - rules.push(this.globalRules.SpaceBeforeTemplateMiddleAndTail); - } - else { - rules.push(this.globalRules.NoSpaceAfterTemplateHeadAndMiddle); - rules.push(this.globalRules.NoSpaceBeforeTemplateMiddleAndTail); - } - - if (options.insertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces) { - rules.push(this.globalRules.SpaceAfterOpenBraceInJsxExpression); - rules.push(this.globalRules.SpaceBeforeCloseBraceInJsxExpression); - } - else { - rules.push(this.globalRules.NoSpaceAfterOpenBraceInJsxExpression); - rules.push(this.globalRules.NoSpaceBeforeCloseBraceInJsxExpression); - } - - if (options.insertSpaceAfterSemicolonInForStatements) { - rules.push(this.globalRules.SpaceAfterSemicolonInFor); - } - else { - rules.push(this.globalRules.NoSpaceAfterSemicolonInFor); - } - - if (options.insertSpaceBeforeAndAfterBinaryOperators) { - rules.push(this.globalRules.SpaceBeforeBinaryOperator); - rules.push(this.globalRules.SpaceAfterBinaryOperator); - } - else { - rules.push(this.globalRules.NoSpaceBeforeBinaryOperator); - rules.push(this.globalRules.NoSpaceAfterBinaryOperator); - } - - if (options.insertSpaceBeforeFunctionParenthesis) { - rules.push(this.globalRules.SpaceBeforeOpenParenInFuncDecl); - } - else { - rules.push(this.globalRules.NoSpaceBeforeOpenParenInFuncDecl); - } - - if (options.placeOpenBraceOnNewLineForControlBlocks) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInControl); - } - - if (options.placeOpenBraceOnNewLineForFunctions) { - rules.push(this.globalRules.NewLineBeforeOpenBraceInFunction); - rules.push(this.globalRules.NewLineBeforeOpenBraceInTypeScriptDeclWithBlock); - } - - if (options.insertSpaceAfterTypeAssertion) { - rules.push(this.globalRules.SpaceAfterTypeAssertion); - } - else { - rules.push(this.globalRules.NoSpaceAfterTypeAssertion); - } - - rules = rules.concat(this.globalRules.LowPriorityCommonRules); - - return rules; - } } } \ No newline at end of file diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index 01feaf39081..18b0479c85a 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -341,10 +341,7 @@ namespace ts.formatting { return Value.Unknown; } - if (node.parent && ( - node.parent.kind === SyntaxKind.CallExpression || - node.parent.kind === SyntaxKind.NewExpression) && - (node.parent).expression !== node) { + if (node.parent && isCallOrNewExpression(node.parent) && (node.parent).expression !== node) { const fullCallOrNewExpression = (node.parent).expression; const startingExpression = getStartingExpression(fullCallOrNewExpression); diff --git a/src/services/formatting/tokenRange.ts b/src/services/formatting/tokenRange.ts index 05d7369e77f..29855279e25 100644 --- a/src/services/formatting/tokenRange.ts +++ b/src/services/formatting/tokenRange.ts @@ -3,22 +3,13 @@ /* @internal */ namespace ts.formatting { export namespace Shared { - export interface ITokenAccess { - GetTokens(): SyntaxKind[]; - Contains(token: SyntaxKind): boolean; + const allTokens: SyntaxKind[] = []; + for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) { + allTokens.push(token); } - export class TokenRangeAccess implements ITokenAccess { - private tokens: SyntaxKind[]; - - constructor(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[]) { - this.tokens = []; - for (let token = from; token <= to; token++) { - if (ts.indexOf(except, token) < 0) { - this.tokens.push(token); - } - } - } + class TokenValuesAccess implements TokenRange { + constructor(private readonly tokens: SyntaxKind[] = []) { } public GetTokens(): SyntaxKind[] { return this.tokens; @@ -27,27 +18,12 @@ namespace ts.formatting { public Contains(token: SyntaxKind): boolean { return this.tokens.indexOf(token) >= 0; } + + public isSpecific() { return true; } } - export class TokenValuesAccess implements ITokenAccess { - private tokens: SyntaxKind[]; - - constructor(tks: SyntaxKind[]) { - this.tokens = tks && tks.length ? tks : []; - } - - public GetTokens(): SyntaxKind[] { - return this.tokens; - } - - public Contains(token: SyntaxKind): boolean { - return this.tokens.indexOf(token) >= 0; - } - } - - export class TokenSingleValueAccess implements ITokenAccess { - constructor(public token: SyntaxKind) { - } + class TokenSingleValueAccess implements TokenRange { + constructor(private readonly token: SyntaxKind) {} public GetTokens(): SyntaxKind[] { return [this.token]; @@ -56,15 +32,13 @@ namespace ts.formatting { public Contains(tokenValue: SyntaxKind): boolean { return tokenValue === this.token; } + + public isSpecific() { return true; } } - export class TokenAllAccess implements ITokenAccess { + class TokenAllAccess implements TokenRange { public GetTokens(): SyntaxKind[] { - const result: SyntaxKind[] = []; - for (let token = SyntaxKind.FirstToken; token <= SyntaxKind.LastToken; token++) { - result.push(token); - } - return result; + return allTokens; } public Contains(): boolean { @@ -74,53 +48,76 @@ namespace ts.formatting { public toString(): string { return "[allTokens]"; } + + public isSpecific() { return false; } } - export class TokenRange { - constructor(public tokenAccess: ITokenAccess) { - } - - static FromToken(token: SyntaxKind): TokenRange { - return new TokenRange(new TokenSingleValueAccess(token)); - } - - static FromTokens(tokens: SyntaxKind[]): TokenRange { - return new TokenRange(new TokenValuesAccess(tokens)); - } - - static FromRange(f: SyntaxKind, to: SyntaxKind, except: SyntaxKind[] = []): TokenRange { - return new TokenRange(new TokenRangeAccess(f, to, except)); - } - - static AllTokens(): TokenRange { - return new TokenRange(new TokenAllAccess()); - } + class TokenAllExceptAccess implements TokenRange { + constructor(private readonly except: SyntaxKind) {} public GetTokens(): SyntaxKind[] { - return this.tokenAccess.GetTokens(); + return allTokens.filter(t => t !== this.except); } public Contains(token: SyntaxKind): boolean { - return this.tokenAccess.Contains(token); + return token !== this.except; } - public toString(): string { - return this.tokenAccess.toString(); + public isSpecific() { return false; } + } + + export interface TokenRange { + GetTokens(): SyntaxKind[]; + Contains(token: SyntaxKind): boolean; + isSpecific(): boolean; + } + + export namespace TokenRange { + export function FromToken(token: SyntaxKind): TokenRange { + return new TokenSingleValueAccess(token); } - static Any: TokenRange = TokenRange.AllTokens(); - static AnyIncludingMultilineComments = TokenRange.FromTokens(TokenRange.Any.GetTokens().concat([SyntaxKind.MultiLineCommentTrivia])); - static Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword); - static BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator); - static BinaryKeywordOperators = TokenRange.FromTokens([SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]); - static UnaryPrefixOperators = TokenRange.FromTokens([SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]); - static UnaryPrefixExpressions = TokenRange.FromTokens([SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); - static UnaryPreincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); - static UnaryPostincrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]); - static UnaryPredecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); - static UnaryPostdecrementExpressions = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]); - static Comments = TokenRange.FromTokens([SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia]); - static TypeNames = TokenRange.FromTokens([SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]); + export function FromTokens(tokens: SyntaxKind[]): TokenRange { + return new TokenValuesAccess(tokens); + } + + export function FromRange(from: SyntaxKind, to: SyntaxKind, except: SyntaxKind[] = []): TokenRange { + const tokens: SyntaxKind[] = []; + for (let token = from; token <= to; token++) { + if (ts.indexOf(except, token) < 0) { + tokens.push(token); + } + } + return new TokenValuesAccess(tokens); + } + + export function AnyExcept(token: SyntaxKind): TokenRange { + return new TokenAllExceptAccess(token); + } + + export const Any: TokenRange = new TokenAllAccess(); + export const AnyIncludingMultilineComments = TokenRange.FromTokens([...allTokens, SyntaxKind.MultiLineCommentTrivia]); + export const Keywords = TokenRange.FromRange(SyntaxKind.FirstKeyword, SyntaxKind.LastKeyword); + export const BinaryOperators = TokenRange.FromRange(SyntaxKind.FirstBinaryOperator, SyntaxKind.LastBinaryOperator); + export const BinaryKeywordOperators = TokenRange.FromTokens([ + SyntaxKind.InKeyword, SyntaxKind.InstanceOfKeyword, SyntaxKind.OfKeyword, SyntaxKind.AsKeyword, SyntaxKind.IsKeyword]); + export const UnaryPrefixOperators = TokenRange.FromTokens([ + SyntaxKind.PlusPlusToken, SyntaxKind.MinusMinusToken, SyntaxKind.TildeToken, SyntaxKind.ExclamationToken]); + export const UnaryPrefixExpressions = TokenRange.FromTokens([ + SyntaxKind.NumericLiteral, SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.OpenBracketToken, + SyntaxKind.OpenBraceToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); + export const UnaryPreincrementExpressions = TokenRange.FromTokens([ + SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); + export const UnaryPostincrementExpressions = TokenRange.FromTokens([ + SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]); + export const UnaryPredecrementExpressions = TokenRange.FromTokens([ + SyntaxKind.Identifier, SyntaxKind.OpenParenToken, SyntaxKind.ThisKeyword, SyntaxKind.NewKeyword]); + export const UnaryPostdecrementExpressions = TokenRange.FromTokens([ + SyntaxKind.Identifier, SyntaxKind.CloseParenToken, SyntaxKind.CloseBracketToken, SyntaxKind.NewKeyword]); + export const Comments = TokenRange.FromTokens([SyntaxKind.SingleLineCommentTrivia, SyntaxKind.MultiLineCommentTrivia]); + export const TypeNames = TokenRange.FromTokens([ + SyntaxKind.Identifier, SyntaxKind.NumberKeyword, SyntaxKind.StringKeyword, SyntaxKind.BooleanKeyword, + SyntaxKind.SymbolKeyword, SyntaxKind.VoidKeyword, SyntaxKind.AnyKeyword]); } } } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index f2602903be3..d0901de9a47 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -50,19 +50,10 @@ namespace ts.GoToDefinition { // get the aliased symbol instead. This allows for goto def on an import e.g. // import {A, B} from "mod"; // to jump to the implementation directly. - if (symbol.flags & SymbolFlags.Alias) { - const declaration = symbol.declarations[0]; - - // 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 === SyntaxKind.Identifier && - (node.parent === declaration || - (declaration.kind === SyntaxKind.ImportSpecifier && declaration.parent && declaration.parent.kind === SyntaxKind.NamedImports))) { - - symbol = typeChecker.getAliasedSymbol(symbol); + if (symbol.flags & SymbolFlags.Alias && shouldSkipAlias(node, symbol.declarations[0])) { + const aliased = typeChecker.getAliasedSymbol(symbol); + if (aliased.declarations) { + symbol = aliased; } } @@ -85,17 +76,6 @@ namespace ts.GoToDefinition { declaration => createDefinitionInfo(declaration, shorthandSymbolKind, shorthandSymbolName, shorthandContainerName)); } - if (isJsxOpeningLikeElement(node.parent)) { - // If there are errors when trying to figure out stateless component function, just return the first declaration - // For example: - // declare function /*firstSource*/MainButton(buttonProps: ButtonProps): JSX.Element; - // declare function /*secondSource*/MainButton(linkProps: LinkProps): JSX.Element; - // declare function /*thirdSource*/MainButton(props: ButtonProps | LinkProps): JSX.Element; - // let opt =
; // Error - We get undefined for resolved signature indicating an error, then just return the first declaration - const {symbolName, symbolKind, containerName} = getSymbolInfo(typeChecker, symbol, node); - return [createDefinitionInfo(symbol.valueDeclaration, symbolKind, symbolName, containerName)]; - } - // If the current location we want to find its definition is in an object literal, try to get the contextual type for the // object literal, lookup the property symbol in the contextual type, and use this for goto-definition. // For example @@ -106,15 +86,9 @@ namespace ts.GoToDefinition { // function Foo(arg: Props) {} // Foo( { pr/*1*/op1: 10, prop2: true }) const element = getContainingObjectLiteralElement(node); - if (element) { - if (typeChecker.getContextualType(element.parent as Expression)) { - const result: DefinitionInfo[] = []; - const propertySymbols = getPropertySymbolsFromContextualType(typeChecker, element); - for (const propertySymbol of propertySymbols) { - result.push(...getDefinitionFromSymbol(typeChecker, propertySymbol, node)); - } - return result; - } + if (element && typeChecker.getContextualType(element.parent as Expression)) { + return flatMap(getPropertySymbolsFromContextualType(typeChecker, element), propertySymbol => + getDefinitionFromSymbol(typeChecker, propertySymbol, node)); } return getDefinitionFromSymbol(typeChecker, symbol, node); } @@ -153,6 +127,29 @@ namespace ts.GoToDefinition { return getDefinitionFromSymbol(typeChecker, type.symbol, node); } + // 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 an import. + // + function shouldSkipAlias(node: Node, declaration: Node): boolean { + if (node.kind !== SyntaxKind.Identifier) { + return false; + } + if (node.parent === declaration) { + return true; + } + switch (declaration.kind) { + case SyntaxKind.ImportClause: + case SyntaxKind.ImportEqualsDeclaration: + return true; + case SyntaxKind.ImportSpecifier: + return declaration.parent.kind === SyntaxKind.NamedImports; + default: + return false; + } + } + function getDefinitionFromSymbol(typeChecker: TypeChecker, symbol: Symbol, node: Node): DefinitionInfo[] { const result: DefinitionInfo[] = []; const declarations = symbol.getDeclarations(); @@ -235,7 +232,7 @@ namespace ts.GoToDefinition { /** Creates a DefinitionInfo from a Declaration, using the declaration's name if possible. */ function createDefinitionInfo(node: Declaration, symbolKind: string, symbolName: string, containerName: string): DefinitionInfo { - return createDefinitionInfoFromName(node.name || node, symbolKind, symbolName, containerName); + return createDefinitionInfoFromName(getNameOfDeclaration(node) || node, symbolKind, symbolName, containerName); } /** Creates a DefinitionInfo directly from the name of a declaration. */ diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index 0108d830dd1..c540c44620a 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -212,6 +212,10 @@ namespace ts.FindAllReferences { return; } + if (!decl.importClause) { + return; + } + const { importClause } = decl; const { namedBindings } = importClause; @@ -326,7 +330,7 @@ namespace ts.FindAllReferences { /** Calls `action` for each import, re-export, or require() in a file. */ function forEachImport(sourceFile: SourceFile, action: (importStatement: ImporterOrCallExpression, imported: StringLiteral) => void): void { - if (sourceFile.externalModuleIndicator) { + if (sourceFile.externalModuleIndicator || sourceFile.imports !== undefined) { for (const moduleSpecifier of sourceFile.imports) { action(importerFromModuleSpecifier(moduleSpecifier), moduleSpecifier); } @@ -354,27 +358,21 @@ namespace ts.FindAllReferences { } } }); - - if (sourceFile.flags & NodeFlags.JavaScriptFile) { - // Find all 'require()' calls. - sourceFile.forEachChild(function recur(node: Node): void { - if (isRequireCall(node, /*checkArgumentIsStringLiteral*/ true)) { - action(node, node.arguments[0] as StringLiteral); - } else { - node.forEachChild(recur); - } - }); - } } } - function importerFromModuleSpecifier(moduleSpecifier: StringLiteral): Importer { + function importerFromModuleSpecifier(moduleSpecifier: StringLiteral): ImporterOrCallExpression { const decl = moduleSpecifier.parent; - if (decl.kind === SyntaxKind.ImportDeclaration || decl.kind === SyntaxKind.ExportDeclaration) { - return decl as ImportDeclaration | ExportDeclaration; + switch (decl.kind) { + case SyntaxKind.CallExpression: + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ExportDeclaration: + return decl as ImportDeclaration | ExportDeclaration | CallExpression; + case SyntaxKind.ExternalModuleReference: + return (decl as ExternalModuleReference).parent; + default: + Debug.assert(false); } - Debug.assert(decl.kind === SyntaxKind.ExternalModuleReference); - return (decl as ExternalModuleReference).parent; } export interface ImportedSymbol { @@ -528,14 +526,18 @@ namespace ts.FindAllReferences { return isExternalModuleSymbol(exportingModuleSymbol) ? { exportingModuleSymbol, exportKind } : undefined; } - function symbolName(symbol: Symbol): string { + function symbolName(symbol: Symbol): string | undefined { if (symbol.name !== "default") { return symbol.name; } - const name = forEach(symbol.declarations, ({ name }) => name && name.kind === SyntaxKind.Identifier && name.text); - Debug.assert(!!name); - return name; + return forEach(symbol.declarations, decl => { + if (isExportAssignment(decl)) { + return isIdentifier(decl.expression) ? decl.expression.text : undefined; + } + const name = getNameOfDeclaration(decl); + return name && name.kind === SyntaxKind.Identifier && name.text; + }); } /** If at an export specifier, go to the symbol it refers to. */ diff --git a/src/services/jsDoc.ts b/src/services/jsDoc.ts index 37c22b4352c..4422aab7156 100644 --- a/src/services/jsDoc.ts +++ b/src/services/jsDoc.ts @@ -28,6 +28,7 @@ namespace ts.JsDoc { "namespace", "param", "private", + "prop", "property", "public", "requires", @@ -38,8 +39,6 @@ namespace ts.JsDoc { "throws", "type", "typedef", - "property", - "prop", "version" ]; let jsDocTagNameCompletionEntries: CompletionEntry[]; diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 2c8d43b535b..2fdc567b9bb 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -52,7 +52,7 @@ namespace ts.NavigateTo { rawItems = filter(rawItems, item => { const decl = item.declaration; if (decl.kind === SyntaxKind.ImportClause || decl.kind === SyntaxKind.ImportSpecifier || decl.kind === SyntaxKind.ImportEqualsDeclaration) { - const importer = checker.getSymbolAtLocation(decl.name); + const importer = checker.getSymbolAtLocation((decl as NamedDeclaration).name); const imported = checker.getAliasedSymbol(importer); return importer.name !== imported.name; } @@ -97,17 +97,20 @@ namespace ts.NavigateTo { } function tryAddSingleDeclarationName(declaration: Declaration, containers: string[]) { - if (declaration && declaration.name) { - const text = getTextOfIdentifierOrLiteral(declaration.name); - if (text !== undefined) { - containers.unshift(text); - } - else if (declaration.name.kind === SyntaxKind.ComputedPropertyName) { - return tryAddComputedPropertyName((declaration.name).expression, containers, /*includeLastPortion*/ true); - } - else { - // Don't know how to add this. - return false; + if (declaration) { + const name = getNameOfDeclaration(declaration); + if (name) { + const text = getTextOfIdentifierOrLiteral(name); + if (text !== undefined) { + containers.unshift(text); + } + else if (name.kind === SyntaxKind.ComputedPropertyName) { + return tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ true); + } + else { + // Don't know how to add this. + return false; + } } } @@ -143,8 +146,9 @@ namespace ts.NavigateTo { // First, if we started with a computed property name, then add all but the last // portion into the container array. - if (declaration.name.kind === SyntaxKind.ComputedPropertyName) { - if (!tryAddComputedPropertyName((declaration.name).expression, containers, /*includeLastPortion*/ false)) { + const name = getNameOfDeclaration(declaration); + if (name.kind === SyntaxKind.ComputedPropertyName) { + if (!tryAddComputedPropertyName((name).expression, containers, /*includeLastPortion*/ false)) { return undefined; } } @@ -190,6 +194,7 @@ namespace ts.NavigateTo { function createNavigateToItem(rawItem: RawNavigateToItem): NavigateToItem { const declaration = rawItem.declaration; const container = getContainerNode(declaration); + const containerName = container && getNameOfDeclaration(container); return { name: rawItem.name, kind: getNodeKind(declaration), @@ -199,9 +204,9 @@ namespace ts.NavigateTo { fileName: rawItem.fileName, textSpan: createTextSpanFromNode(declaration), // TODO(jfreeman): What should be the containerName when the container has a computed name? - containerName: container && container.name ? (container.name).text : "", - containerKind: container && container.name ? getNodeKind(container) : "" + containerName: containerName ? (containerName).text : "", + containerKind: containerName ? getNodeKind(container) : "" }; } } -} \ No newline at end of file +} diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 7a2508fcfd6..819202ff6f4 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -279,8 +279,8 @@ namespace ts.NavigationBar { function mergeChildren(children: NavigationBarNode[]): void { const nameToItems = createMap(); filterMutate(children, child => { - const decl = child.node; - const name = decl.name && nodeText(decl.name); + const declName = getNameOfDeclaration(child.node); + const name = declName && nodeText(declName); if (!name) { // Anonymous items are never merged. return true; @@ -378,9 +378,9 @@ namespace ts.NavigationBar { return getModuleName(node); } - const decl = node; - if (decl.name) { - return getPropertyNameForPropertyNameNode(decl.name); + const declName = getNameOfDeclaration(node); + if (declName) { + return getPropertyNameForPropertyNameNode(declName); } switch (node.kind) { case SyntaxKind.FunctionExpression: @@ -399,7 +399,7 @@ namespace ts.NavigationBar { return getModuleName(node); } - const name = (node).name; + const name = getNameOfDeclaration(node); if (name) { const text = nodeText(name); if (text.length > 0) { diff --git a/src/services/services.ts b/src/services/services.ts index 8f2cbb22379..fdacf9bf9e4 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -31,6 +31,9 @@ namespace ts { /** The version of the language service API */ export const servicesVersion = "0.5"; + /* @internal */ + let ruleProvider: formatting.RulesProvider; + function createNode(kind: TKind, pos: number, end: number, parent?: Node): NodeObject | TokenObject | IdentifierObject { const node = kind >= SyntaxKind.FirstNode ? new NodeObject(kind, pos, end) : kind === SyntaxKind.Identifier ? new IdentifierObject(SyntaxKind.Identifier, pos, end) : @@ -357,6 +360,7 @@ namespace ts { _incrementExpressionBrand: any; _unaryExpressionBrand: any; _expressionBrand: any; + /*@internal*/typeArguments: NodeArray; constructor(_kind: SyntaxKind.Identifier, pos: number, end: number) { super(pos, end); } @@ -575,14 +579,15 @@ namespace ts { } function getDeclarationName(declaration: Declaration) { - if (declaration.name) { - const result = getTextOfIdentifierOrLiteral(declaration.name); + const name = getNameOfDeclaration(declaration); + if (name) { + const result = getTextOfIdentifierOrLiteral(name); if (result !== undefined) { return result; } - if (declaration.name.kind === SyntaxKind.ComputedPropertyName) { - const expr = (declaration.name).expression; + if (name.kind === SyntaxKind.ComputedPropertyName) { + const expr = (name).expression; if (expr.kind === SyntaxKind.PropertyAccessExpression) { return (expr).name.text; } @@ -1040,10 +1045,9 @@ namespace ts { documentRegistry: DocumentRegistry = createDocumentRegistry(host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(), host.getCurrentDirectory())): LanguageService { const syntaxTreeCache: SyntaxTreeCache = new SyntaxTreeCache(host); - let ruleProvider: formatting.RulesProvider; + ruleProvider = ruleProvider || new formatting.RulesProvider(); let program: Program; let lastProjectVersion: string; - let lastTypesRootVersion = 0; const useCaseSensitivefileNames = host.useCaseSensitiveFileNames && host.useCaseSensitiveFileNames(); @@ -1072,11 +1076,6 @@ namespace ts { } function getRuleProvider(options: FormatCodeSettings) { - // Ensure rules are initialized and up to date wrt to formatting options - if (!ruleProvider) { - ruleProvider = new formatting.RulesProvider(); - } - ruleProvider.ensureUpToDate(options); return ruleProvider; } @@ -1855,8 +1854,8 @@ namespace ts { // OK, we have found a match in the file. This is only an acceptable match if // it is contained within a comment. - const token = getTokenAtPosition(sourceFile, matchPosition); - if (!isInsideComment(sourceFile, token, matchPosition)) { + + if (!isInComment(sourceFile, matchPosition)) { continue; } diff --git a/src/services/shims.ts b/src/services/shims.ts index 7588e16f3dc..498c1834a60 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -1038,7 +1038,11 @@ namespace ts { return this.forwardJSONCall(`resolveModuleName('${fileName}')`, () => { const compilerOptions = JSON.parse(compilerOptionsJson); const result = resolveModuleName(moduleName, normalizeSlashes(fileName), compilerOptions, this.host); - const resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + let resolvedFileName = result.resolvedModule ? result.resolvedModule.resolvedFileName : undefined; + if (result.resolvedModule && result.resolvedModule.extension !== Extension.Ts && result.resolvedModule.extension !== Extension.Tsx && result.resolvedModule.extension !== Extension.Dts) { + resolvedFileName = undefined; + } + return { resolvedFileName, failedLookupLocations: result.failedLookupLocations @@ -1244,4 +1248,4 @@ namespace TypeScript.Services { // TODO: it should be moved into a namespace though. /* @internal */ -const toolsVersion = "2.3"; \ No newline at end of file +const toolsVersion = "2.4"; \ No newline at end of file diff --git a/src/services/signatureHelp.ts b/src/services/signatureHelp.ts index 1487bb410a5..b250ad49467 100644 --- a/src/services/signatureHelp.ts +++ b/src/services/signatureHelp.ts @@ -1,168 +1,6 @@ /// /* @internal */ namespace ts.SignatureHelp { - - // A partially written generic type expression is not guaranteed to have the correct syntax tree. the expression could be parsed as less than/greater than expression or a comma expression - // or some other combination depending on what the user has typed so far. For the purposes of signature help we need to consider any location after "<" as a possible generic type reference. - // To do this, the method will back parse the expression starting at the position required. it will try to parse the current expression as a generic type expression, if it did succeed it - // will return the generic identifier that started the expression (e.g. "foo" in "foonode.parent; // There are 3 cases to handle: // 1. The token introduces a list, and should begin a signature help session diff --git a/src/services/symbolDisplay.ts b/src/services/symbolDisplay.ts index 43eb07b343b..67bacaeadd0 100644 --- a/src/services/symbolDisplay.ts +++ b/src/services/symbolDisplay.ts @@ -120,7 +120,7 @@ namespace ts.SymbolDisplay { // try get the call/construct signature from the type if it matches let callExpressionLike: CallExpression | NewExpression | JsxOpeningLikeElement; - if (location.kind === SyntaxKind.CallExpression || location.kind === SyntaxKind.NewExpression) { + if (isCallOrNewExpression(location)) { callExpressionLike = location; } else if (isCallExpressionTarget(location) || isNewExpressionTarget(location)) { @@ -200,27 +200,33 @@ namespace ts.SymbolDisplay { (location.kind === SyntaxKind.ConstructorKeyword && location.parent.kind === SyntaxKind.Constructor)) { // At constructor keyword of constructor declaration // get the signature from the declaration and write it const functionDeclaration = location.parent; - const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); - if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { - signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); - } - else { - signature = allSignatures[0]; - } + // Use function declaration to write the signatures only if the symbol corresponding to this declaration + const locationIsSymbolDeclaration = findDeclaration(symbol, declaration => + declaration === (location.kind === SyntaxKind.ConstructorKeyword ? functionDeclaration.parent : functionDeclaration)); - if (functionDeclaration.kind === SyntaxKind.Constructor) { - // show (constructor) Type(...) signature - symbolKind = ScriptElementKind.constructorImplementationElement; - addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); - } - else { - // (function/method) symbol(..signature) - addPrefixForAnyFunctionOrVar(functionDeclaration.kind === SyntaxKind.CallSignature && - !(type.symbol.flags & SymbolFlags.TypeLiteral || type.symbol.flags & SymbolFlags.ObjectLiteral) ? type.symbol : symbol, symbolKind); - } + if (locationIsSymbolDeclaration) { + const allSignatures = functionDeclaration.kind === SyntaxKind.Constructor ? type.getNonNullableType().getConstructSignatures() : type.getNonNullableType().getCallSignatures(); + if (!typeChecker.isImplementationOfOverload(functionDeclaration)) { + signature = typeChecker.getSignatureFromDeclaration(functionDeclaration); + } + else { + signature = allSignatures[0]; + } - addSignatureDisplayParts(signature, allSignatures); - hasAddedSymbolInfo = true; + if (functionDeclaration.kind === SyntaxKind.Constructor) { + // show (constructor) Type(...) signature + symbolKind = ScriptElementKind.constructorImplementationElement; + addPrefixForAnyFunctionOrVar(type.symbol, symbolKind); + } + else { + // (function/method) symbol(..signature) + addPrefixForAnyFunctionOrVar(functionDeclaration.kind === SyntaxKind.CallSignature && + !(type.symbol.flags & SymbolFlags.TypeLiteral || type.symbol.flags & SymbolFlags.ObjectLiteral) ? type.symbol : symbol, symbolKind); + } + + addSignatureDisplayParts(signature, allSignatures); + hasAddedSymbolInfo = true; + } } } } @@ -269,7 +275,7 @@ namespace ts.SymbolDisplay { } if (symbolFlags & SymbolFlags.Module) { addNewLineIfDisplayPartsExist(); - const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); + const declaration = getDeclarationOfKind(symbol, SyntaxKind.ModuleDeclaration); const isNamespace = declaration && declaration.name && declaration.name.kind === SyntaxKind.Identifier; displayParts.push(keywordPart(isNamespace ? SyntaxKind.NamespaceKeyword : SyntaxKind.ModuleKeyword)); displayParts.push(spacePart()); @@ -290,9 +296,9 @@ namespace ts.SymbolDisplay { } else { // Method/function type parameter - let declaration = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter); - Debug.assert(declaration !== undefined); - declaration = declaration.parent; + const decl = getDeclarationOfKind(symbol, SyntaxKind.TypeParameter); + Debug.assert(decl !== undefined); + const declaration = decl.parent; if (declaration) { if (isFunctionLikeKind(declaration.kind)) { diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 7ff0c37fa93..5a1aaa21bcd 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -497,8 +497,8 @@ namespace ts.textChanges { readonly node: Node; } - export function getNonformattedText(node: Node, sourceFile: SourceFile, newLine: NewLineKind): NonFormattedText { - const options = { newLine, target: sourceFile.languageVersion }; + export function getNonformattedText(node: Node, sourceFile: SourceFile | undefined, newLine: NewLineKind): NonFormattedText { + const options = { newLine, target: sourceFile && sourceFile.languageVersion }; const writer = new Writer(getNewLineCharacter(options)); const printer = createPrinter(options, writer); printer.writeNode(EmitHint.Unspecified, node, sourceFile, writer); @@ -528,26 +528,6 @@ namespace ts.textChanges { return skipTrivia(s, 0) === s.length; } - const nullTransformationContext: TransformationContext = { - enableEmitNotification: noop, - enableSubstitution: noop, - endLexicalEnvironment: () => undefined, - getCompilerOptions: notImplemented, - getEmitHost: notImplemented, - getEmitResolver: notImplemented, - hoistFunctionDeclaration: noop, - hoistVariableDeclaration: noop, - isEmitNotificationEnabled: notImplemented, - isSubstitutionEnabled: notImplemented, - onEmitNode: noop, - onSubstituteNode: notImplemented, - readEmitHelpers: notImplemented, - requestEmitHelper: noop, - resumeLexicalEnvironment: noop, - startLexicalEnvironment: noop, - suspendLexicalEnvironment: noop - }; - function assignPositionsToNode(node: Node): Node { const visited = visitEachChild(node, assignPositionsToNode, nullTransformationContext, assignPositionsToNodeArray, assignPositionsToNode); // create proxy node for non synthesized nodes diff --git a/src/services/transpile.ts b/src/services/transpile.ts index 89ddb887809..e10fcc70a64 100644 --- a/src/services/transpile.ts +++ b/src/services/transpile.ts @@ -5,6 +5,7 @@ namespace ts { reportDiagnostics?: boolean; moduleName?: string; renamedDependencies?: MapLike; + transformers?: CustomTransformers; } export interface TranspileOutput { @@ -103,7 +104,7 @@ namespace ts { addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics()); } // Emit - program.emit(); + program.emit(/*targetSourceFile*/ undefined, /*writeFile*/ undefined, /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ undefined, transpileOptions.transformers); Debug.assert(outputText !== undefined, "Output generation failed"); diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 978195a31f6..fd7269d46dd 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -82,6 +82,7 @@ "formatting/tokenRange.ts", "codeFixProvider.ts", "codefixes/fixAddMissingMember.ts", + "codefixes/fixSpelling.ts", "codefixes/fixExtendsInterfaceBecomesImplements.ts", "codefixes/fixClassIncorrectlyImplementsInterface.ts", "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", @@ -94,4 +95,4 @@ "codefixes/unusedIdentifierFixes.ts", "codefixes/disableJsDiagnostics.ts" ] -} \ No newline at end of file +} diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 1e9d4c52654..c8b710789ad 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -21,7 +21,6 @@ namespace ts { case SyntaxKind.PropertySignature: case SyntaxKind.PropertyAssignment: case SyntaxKind.ShorthandPropertyAssignment: - case SyntaxKind.EnumMember: case SyntaxKind.MethodDeclaration: case SyntaxKind.MethodSignature: case SyntaxKind.Constructor: @@ -40,10 +39,13 @@ namespace ts { case SyntaxKind.TypeLiteral: return SemanticMeaning.Type; + case SyntaxKind.EnumMember: case SyntaxKind.ClassDeclaration: - case SyntaxKind.EnumDeclaration: return SemanticMeaning.Value | SemanticMeaning.Type; + case SyntaxKind.EnumDeclaration: + return SemanticMeaning.All; + case SyntaxKind.ModuleDeclaration: if (isAmbientModule(node)) { return SemanticMeaning.Namespace | SemanticMeaning.Value; @@ -61,7 +63,7 @@ namespace ts { case SyntaxKind.ImportDeclaration: case SyntaxKind.ExportAssignment: case SyntaxKind.ExportDeclaration: - return SemanticMeaning.Value | SemanticMeaning.Type | SemanticMeaning.Namespace; + return SemanticMeaning.All; // An external module can be a Value case SyntaxKind.SourceFile: @@ -238,7 +240,7 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: case SyntaxKind.ModuleDeclaration: - return (node.parent).name === node; + return getNameOfDeclaration(node.parent) === node; case SyntaxKind.ElementAccessExpression: return (node.parent).argumentExpression === node; case SyntaxKind.ComputedPropertyName: @@ -254,37 +256,6 @@ namespace ts { getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node; } - /** Returns true if the position is within a comment */ - export function isInsideComment(sourceFile: SourceFile, token: Node, position: number): boolean { - // The position has to be: 1. in the leading trivia (before token.getStart()), and 2. within a comment - return position <= token.getStart(sourceFile) && - (isInsideCommentRange(getTrailingCommentRanges(sourceFile.text, token.getFullStart())) || - isInsideCommentRange(getLeadingCommentRanges(sourceFile.text, token.getFullStart()))); - - function isInsideCommentRange(comments: CommentRange[]): boolean { - return forEach(comments, comment => { - // either we are 1. completely inside the comment, or 2. at the end of the comment - if (comment.pos < position && position < comment.end) { - return true; - } - else if (position === comment.end) { - const text = sourceFile.text; - const width = comment.end - comment.pos; - // is single line comment or just /* - if (width <= 2 || text.charCodeAt(comment.pos + 1) === CharacterCodes.slash) { - return true; - } - else { - // is unterminated multi-line comment - return !(text.charCodeAt(comment.end - 1) === CharacterCodes.slash && - text.charCodeAt(comment.end - 2) === CharacterCodes.asterisk); - } - } - return false; - }); - } - } - export function getContainerNode(node: Node): Declaration { while (true) { node = node.parent; @@ -649,44 +620,26 @@ namespace ts { return current; } - if (includeJsDocComment) { - const jsDocChildren = ts.filter(current.getChildren(), isJSDocNode); - for (const jsDocChild of jsDocChildren) { - const start = allowPositionInLeadingTrivia ? jsDocChild.getFullStart() : jsDocChild.getStart(sourceFile, includeJsDocComment); - if (start <= position) { - const end = jsDocChild.getEnd(); - if (position < end || (position === end && jsDocChild.kind === SyntaxKind.EndOfFileToken)) { - current = jsDocChild; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - const previousToken = findPrecedingToken(position, sourceFile, jsDocChild); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } - } - } - } - } - // find the child that contains 'position' for (const child of current.getChildren()) { - // all jsDocComment nodes were already visited - if (isJSDocNode(child)) { + if (isJSDocNode(child) && !includeJsDocComment) { continue; } + const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); - if (start <= position) { - const end = child.getEnd(); - if (position < end || (position === end && child.kind === SyntaxKind.EndOfFileToken)) { - current = child; - continue outer; - } - else if (includeItemAtEndPosition && end === position) { - const previousToken = findPrecedingToken(position, sourceFile, child); - if (previousToken && includeItemAtEndPosition(previousToken)) { - return previousToken; - } + if (start > position) { + continue; + } + + const end = child.getEnd(); + if (position < end || (position === end && child.kind === SyntaxKind.EndOfFileToken)) { + current = child; + continue outer; + } + else if (includeItemAtEndPosition && end === position) { + const previousToken = findPrecedingToken(position, sourceFile, child); + if (previousToken && includeItemAtEndPosition(previousToken)) { + return previousToken; } } } @@ -832,10 +785,6 @@ namespace ts { return false; } - export function isInComment(sourceFile: SourceFile, position: number) { - return isInCommentHelper(sourceFile, position, /*predicate*/ undefined); - } - /** * returns true if the position is in between the open and close elements of an JSX expression. */ @@ -881,15 +830,26 @@ namespace ts { } /** - * Returns true if the cursor at position in sourceFile is within a comment that additionally - * satisfies predicate, and false otherwise. + * Returns true if the cursor at position in sourceFile is within a comment. + * + * @param tokenAtPosition Must equal `getTokenAtPosition(sourceFile, position) + * @param predicate Additional predicate to test on the comment range. */ - export function isInCommentHelper(sourceFile: SourceFile, position: number, predicate?: (c: CommentRange) => boolean): boolean { - const token = getTokenAtPosition(sourceFile, position); + export function isInComment(sourceFile: SourceFile, position: number, tokenAtPosition = getTokenAtPosition(sourceFile, position), predicate?: (c: CommentRange) => boolean): boolean { + return position <= tokenAtPosition.getStart(sourceFile) && + (isInCommentRange(getLeadingCommentRanges(sourceFile.text, tokenAtPosition.pos)) || + isInCommentRange(getTrailingCommentRanges(sourceFile.text, tokenAtPosition.pos))); - if (token && position <= token.getStart(sourceFile)) { - const commentRanges = getLeadingCommentRanges(sourceFile.text, token.pos); + function isInCommentRange(commentRanges: CommentRange[]): boolean { + return forEach(commentRanges, c => isPositionInCommentRange(c, position, sourceFile.text) && (!predicate || predicate(c))); + } + } + function isPositionInCommentRange({ pos, end, kind }: ts.CommentRange, position: number, text: string): boolean { + if (pos < position && position < end) { + return true; + } + else if (position === end) { // The end marker of a single-line comment does not include the newline character. // In the following case, we are inside a comment (^ denotes the cursor position): // @@ -900,15 +860,13 @@ namespace ts { // /* asdf */^ // // Internally, we represent the end of the comment at the newline and closing '/', respectively. - return predicate ? - forEach(commentRanges, c => c.pos < position && - (c.kind === SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end) && - predicate(c)) : - forEach(commentRanges, c => c.pos < position && - (c.kind === SyntaxKind.SingleLineCommentTrivia ? position <= c.end : position < c.end)); + return kind === SyntaxKind.SingleLineCommentTrivia || + // true for unterminated multi-line comment + !(text.charCodeAt(end - 1) === CharacterCodes.slash && text.charCodeAt(end - 2) === CharacterCodes.asterisk); + } + else { + return false; } - - return false; } export function hasDocComment(sourceFile: SourceFile, position: number) { @@ -1036,6 +994,10 @@ namespace ts { } export function compareDataObjects(dst: any, src: any): boolean { + if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) { + return false; + } + for (const e in dst) { if (typeof dst[e] === "object") { if (!compareDataObjects(dst[e], src[e])) { @@ -1087,21 +1049,17 @@ namespace ts { } export function isInReferenceComment(sourceFile: SourceFile, position: number): boolean { - return isInCommentHelper(sourceFile, position, isReferenceComment); - - function isReferenceComment(c: CommentRange): boolean { + return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, c => { const commentText = sourceFile.text.substring(c.pos, c.end); return tripleSlashDirectivePrefixRegex.test(commentText); - } + }); } export function isInNonReferenceComment(sourceFile: SourceFile, position: number): boolean { - return isInCommentHelper(sourceFile, position, isNonReferenceComment); - - function isNonReferenceComment(c: CommentRange): boolean { + return isInComment(sourceFile, position, /*tokenAtPosition*/ undefined, c => { const commentText = sourceFile.text.substring(c.pos, c.end); return !tripleSlashDirectivePrefixRegex.test(commentText); - } + }); } export function createTextSpanFromNode(node: Node, sourceFile?: SourceFile): TextSpan { diff --git a/tests/baselines/reference/APISample_compile.js b/tests/baselines/reference/APISample_compile.js index c2617b2a6c6..35d49350457 100644 --- a/tests/baselines/reference/APISample_compile.js +++ b/tests/baselines/reference/APISample_compile.js @@ -1,6 +1,6 @@ //// [APISample_compile.ts] /* - * Note: This test is a public API sample. The sample sources can be found + * Note: This test is a public API sample. The sample sources can be found at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#a-minimal-compiler * Please log a "breaking change" issue for any API breaking change affecting this issue */ @@ -18,8 +18,12 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void var allDiagnostics = ts.getPreEmitDiagnostics(program); allDiagnostics.forEach(diagnostic => { - var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + if (!diagnostic.file) { + console.log(message); + return; + } + var { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); console.log(`${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); }); @@ -31,7 +35,8 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void compile(process.argv.slice(2), { noEmitOnError: true, noImplicitAny: true, target: ts.ScriptTarget.ES5, module: ts.ModuleKind.CommonJS -}); +}); + //// [APISample_compile.js] "use strict"; @@ -47,8 +52,12 @@ function compile(fileNames, options) { var emitResult = program.emit(); var allDiagnostics = ts.getPreEmitDiagnostics(program); allDiagnostics.forEach(function (diagnostic) { - var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character; var message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'); + if (!diagnostic.file) { + console.log(message); + return; + } + var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character; console.log(diagnostic.file.fileName + " (" + (line + 1) + "," + (character + 1) + "): " + message); }); var exitCode = emitResult.emitSkipped ? 1 : 0; diff --git a/tests/baselines/reference/APISample_watcher.js b/tests/baselines/reference/APISample_watcher.js index f06f9ced73f..b813a44f53e 100644 --- a/tests/baselines/reference/APISample_watcher.js +++ b/tests/baselines/reference/APISample_watcher.js @@ -1,6 +1,6 @@ //// [APISample_watcher.ts] /* - * Note: This test is a public API sample. The sample sources can be found + * Note: This test is a public API sample. The sample sources can be found at: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#incremental-build-support-using-the-language-services * Please log a "breaking change" issue for any API breaking change affecting this issue */ @@ -91,7 +91,7 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) { allDiagnostics.forEach(diagnostic => { let message = ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"); if (diagnostic.file) { - let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); + let { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!); console.log(` Error ${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`); } else { @@ -106,7 +106,8 @@ const currentDirectoryFiles = fs.readdirSync(process.cwd()). filter(fileName=> fileName.length >= 3 && fileName.substr(fileName.length - 3, 3) === ".ts"); // Start the watcher -watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); +watch(currentDirectoryFiles, { module: ts.ModuleKind.CommonJS }); + //// [APISample_watcher.js] "use strict"; diff --git a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js index 71f633a41e3..9187c99c840 100644 --- a/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js +++ b/tests/baselines/reference/ClassAndModuleWithSameNameAndCommonRootES6.js @@ -59,7 +59,7 @@ var X; (function (X) { var Y; (function (Y) { - var Point; + let Point; (function (Point) { Point.Origin = new Point(0, 0); })(Point = Y.Point || (Y.Point = {})); diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json new file mode 100644 index 00000000000..064a040c58f --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argSynonymForParamTag.json @@ -0,0 +1,49 @@ +{ + "kind": "JSDocComment", + "pos": 0, + "end": 44, + "tags": { + "0": { + "kind": "JSDocParameterTag", + "pos": 8, + "end": 27, + "atToken": { + "kind": "AtToken", + "pos": 8, + "end": 9 + }, + "tagName": { + "kind": "Identifier", + "pos": 9, + "end": 12, + "text": "arg" + }, + "typeExpression": { + "kind": "JSDocTypeExpression", + "pos": 13, + "end": 21, + "type": { + "kind": "NumberKeyword", + "pos": 14, + "end": 20 + } + }, + "postParameterName": { + "kind": "Identifier", + "pos": 22, + "end": 27, + "text": "name1" + }, + "parameterName": { + "kind": "Identifier", + "pos": 22, + "end": 27, + "text": "name1" + }, + "comment": "Description" + }, + "length": 1, + "pos": 8, + "end": 27 + } +} \ No newline at end of file diff --git a/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json new file mode 100644 index 00000000000..264b5850223 --- /dev/null +++ b/tests/baselines/reference/JSDocParsing/DocComments.parsesCorrectly.argumentSynonymForParamTag.json @@ -0,0 +1,49 @@ +{ + "kind": "JSDocComment", + "pos": 0, + "end": 49, + "tags": { + "0": { + "kind": "JSDocParameterTag", + "pos": 8, + "end": 32, + "atToken": { + "kind": "AtToken", + "pos": 8, + "end": 9 + }, + "tagName": { + "kind": "Identifier", + "pos": 9, + "end": 17, + "text": "argument" + }, + "typeExpression": { + "kind": "JSDocTypeExpression", + "pos": 18, + "end": 26, + "type": { + "kind": "NumberKeyword", + "pos": 19, + "end": 25 + } + }, + "postParameterName": { + "kind": "Identifier", + "pos": 27, + "end": 32, + "text": "name1" + }, + "parameterName": { + "kind": "Identifier", + "pos": 27, + "end": 32, + "text": "name1" + }, + "comment": "Description" + }, + "length": 1, + "pos": 8, + "end": 32 + } +} \ No newline at end of file diff --git a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt index 96528577cbc..96864565d85 100644 --- a/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt +++ b/tests/baselines/reference/ModuleWithExportedAndNonExportedFunctions.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts(28,13): error TS2339: Property 'fn2' does not exist on type 'typeof A'. -tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts(29,14): error TS2339: Property 'fng2' does not exist on type 'typeof A'. +tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts(29,14): error TS2551: Property 'fng2' does not exist on type 'typeof A'. Did you mean 'fng'? ==== tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAndNonExportedFunctions.ts (2 errors) ==== @@ -35,4 +35,4 @@ tests/cases/conformance/internalModules/exportDeclarations/ModuleWithExportedAnd !!! error TS2339: Property 'fn2' does not exist on type 'typeof A'. var fng2 = A.fng2; ~~~~ -!!! error TS2339: Property 'fng2' does not exist on type 'typeof A'. \ No newline at end of file +!!! error TS2551: Property 'fng2' does not exist on type 'typeof A'. Did you mean 'fng'? \ No newline at end of file diff --git a/tests/baselines/reference/anonymousClassExpression2.errors.txt b/tests/baselines/reference/anonymousClassExpression2.errors.txt index c9b59ae9c4d..6bc858bc542 100644 --- a/tests/baselines/reference/anonymousClassExpression2.errors.txt +++ b/tests/baselines/reference/anonymousClassExpression2.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/anonymousClassExpression2.ts(13,18): error TS2339: Property 'methodA' does not exist on type 'B'. +tests/cases/compiler/anonymousClassExpression2.ts(13,18): error TS2551: Property 'methodA' does not exist on type 'B'. Did you mean 'methodB'? ==== tests/cases/compiler/anonymousClassExpression2.ts (1 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/anonymousClassExpression2.ts(13,18): error TS2339: Property methodB() { this.methodA; // error ~~~~~~~ -!!! error TS2339: Property 'methodA' does not exist on type 'B'. +!!! error TS2551: Property 'methodA' does not exist on type 'B'. Did you mean 'methodB'? this.methodB; // ok } } diff --git a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt index 080aca5a7ac..ff79716cab8 100644 --- a/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt +++ b/tests/baselines/reference/assignmentRestElementWithErrorSourceType.errors.txt @@ -1,5 +1,5 @@ tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,5): error TS2304: Cannot find name 'c'. -tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,10): error TS2304: Cannot find name 'tupel'. +tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,10): error TS2552: Cannot find name 'tupel'. Did you mean 'tuple'? ==== tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts (2 errors) ==== @@ -8,4 +8,4 @@ tests/cases/compiler/assignmentRestElementWithErrorSourceType.ts(2,10): error TS ~ !!! error TS2304: Cannot find name 'c'. ~~~~~ -!!! error TS2304: Cannot find name 'tupel'. \ No newline at end of file +!!! error TS2552: Cannot find name 'tupel'. Did you mean 'tuple'? \ No newline at end of file diff --git a/tests/baselines/reference/autoLift2.errors.txt b/tests/baselines/reference/autoLift2.errors.txt index 9af3d59420f..63d1c2c3548 100644 --- a/tests/baselines/reference/autoLift2.errors.txt +++ b/tests/baselines/reference/autoLift2.errors.txt @@ -1,9 +1,9 @@ tests/cases/compiler/autoLift2.ts(5,14): error TS2339: Property 'foo' does not exist on type 'A'. tests/cases/compiler/autoLift2.ts(5,17): error TS1005: ';' expected. -tests/cases/compiler/autoLift2.ts(5,19): error TS2304: Cannot find name 'any'. +tests/cases/compiler/autoLift2.ts(5,19): error TS2693: 'any' only refers to a type, but is being used as a value here. tests/cases/compiler/autoLift2.ts(6,14): error TS2339: Property 'bar' does not exist on type 'A'. tests/cases/compiler/autoLift2.ts(6,17): error TS1005: ';' expected. -tests/cases/compiler/autoLift2.ts(6,19): error TS2304: Cannot find name 'any'. +tests/cases/compiler/autoLift2.ts(6,19): error TS2693: 'any' only refers to a type, but is being used as a value here. tests/cases/compiler/autoLift2.ts(12,11): error TS2339: Property 'foo' does not exist on type 'A'. tests/cases/compiler/autoLift2.ts(14,11): error TS2339: Property 'bar' does not exist on type 'A'. tests/cases/compiler/autoLift2.ts(16,33): error TS2339: Property 'foo' does not exist on type 'A'. @@ -21,14 +21,14 @@ tests/cases/compiler/autoLift2.ts(18,33): error TS2339: Property 'bar' does not ~ !!! error TS1005: ';' expected. ~~~ -!!! error TS2304: Cannot find name 'any'. +!!! error TS2693: 'any' only refers to a type, but is being used as a value here. this.bar: any; ~~~ !!! error TS2339: Property 'bar' does not exist on type 'A'. ~ !!! error TS1005: ';' expected. ~~~ -!!! error TS2304: Cannot find name 'any'. +!!! error TS2693: 'any' only refers to a type, but is being used as a value here. } diff --git a/tests/baselines/reference/badArrayIndex.errors.txt b/tests/baselines/reference/badArrayIndex.errors.txt index 4830ff1f693..decfebeeac7 100644 --- a/tests/baselines/reference/badArrayIndex.errors.txt +++ b/tests/baselines/reference/badArrayIndex.errors.txt @@ -1,10 +1,10 @@ -tests/cases/compiler/badArrayIndex.ts(1,15): error TS2304: Cannot find name 'number'. +tests/cases/compiler/badArrayIndex.ts(1,15): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/compiler/badArrayIndex.ts(1,22): error TS1109: Expression expected. ==== tests/cases/compiler/badArrayIndex.ts (2 errors) ==== var results = number[]; ~~~~~~ -!!! error TS2304: Cannot find name 'number'. +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. ~ !!! error TS1109: Expression expected. \ No newline at end of file diff --git a/tests/baselines/reference/baseCheck.errors.txt b/tests/baselines/reference/baseCheck.errors.txt index 1f267f55301..1353d6e1a08 100644 --- a/tests/baselines/reference/baseCheck.errors.txt +++ b/tests/baselines/reference/baseCheck.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/baseCheck.ts(9,18): error TS2304: Cannot find name 'loc'. +tests/cases/compiler/baseCheck.ts(9,18): error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'? tests/cases/compiler/baseCheck.ts(17,53): error TS2346: Supplied parameters do not match any signature of call target. tests/cases/compiler/baseCheck.ts(17,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/baseCheck.ts(18,62): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. @@ -20,7 +20,7 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'. constructor(x: number) { super(0, loc); ~~~ -!!! error TS2304: Cannot find name 'loc'. +!!! error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'? } m() { diff --git a/tests/baselines/reference/bases.errors.txt b/tests/baselines/reference/bases.errors.txt index a61d35f664e..3069f977fe1 100644 --- a/tests/baselines/reference/bases.errors.txt +++ b/tests/baselines/reference/bases.errors.txt @@ -1,13 +1,13 @@ tests/cases/compiler/bases.ts(7,14): error TS2339: Property 'y' does not exist on type 'B'. tests/cases/compiler/bases.ts(7,15): error TS1005: ';' expected. -tests/cases/compiler/bases.ts(7,17): error TS2304: Cannot find name 'any'. +tests/cases/compiler/bases.ts(7,17): error TS2693: 'any' only refers to a type, but is being used as a value here. tests/cases/compiler/bases.ts(11,7): error TS2420: Class 'C' incorrectly implements interface 'I'. Property 'x' is missing in type 'C'. tests/cases/compiler/bases.ts(12,5): error TS2377: Constructors for derived classes must contain a 'super' call. tests/cases/compiler/bases.ts(13,9): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class. tests/cases/compiler/bases.ts(13,14): error TS2339: Property 'x' does not exist on type 'C'. tests/cases/compiler/bases.ts(13,15): error TS1005: ';' expected. -tests/cases/compiler/bases.ts(13,17): error TS2304: Cannot find name 'any'. +tests/cases/compiler/bases.ts(13,17): error TS2693: 'any' only refers to a type, but is being used as a value here. tests/cases/compiler/bases.ts(17,9): error TS2339: Property 'x' does not exist on type 'C'. tests/cases/compiler/bases.ts(18,9): error TS2339: Property 'y' does not exist on type 'C'. @@ -25,7 +25,7 @@ tests/cases/compiler/bases.ts(18,9): error TS2339: Property 'y' does not exist o ~ !!! error TS1005: ';' expected. ~~~ -!!! error TS2304: Cannot find name 'any'. +!!! error TS2693: 'any' only refers to a type, but is being used as a value here. } } @@ -44,7 +44,7 @@ tests/cases/compiler/bases.ts(18,9): error TS2339: Property 'y' does not exist o ~ !!! error TS1005: ';' expected. ~~~ -!!! error TS2304: Cannot find name 'any'. +!!! error TS2693: 'any' only refers to a type, but is being used as a value here. } ~~~~~ !!! error TS2377: Constructors for derived classes must contain a 'super' call. diff --git a/tests/baselines/reference/blockScopedNamespaceDifferentFile.js b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js new file mode 100644 index 00000000000..3eab7477c09 --- /dev/null +++ b/tests/baselines/reference/blockScopedNamespaceDifferentFile.js @@ -0,0 +1,35 @@ +//// [tests/cases/compiler/blockScopedNamespaceDifferentFile.ts] //// + +//// [test.ts] +// #15734 failed when test.ts comes before typings.d.ts +namespace C { + export class Name { + static funcData = A.AA.func(); + static someConst = A.AA.foo; + + constructor(parameters) {} + } +} + +//// [typings.d.ts] +declare namespace A { + namespace AA { + function func(): number; + const foo = ""; + } +} + + +//// [out.js] +// #15734 failed when test.ts comes before typings.d.ts +var C; +(function (C) { + var Name = (function () { + function Name(parameters) { + } + return Name; + }()); + Name.funcData = A.AA.func(); + Name.someConst = A.AA.foo; + C.Name = Name; +})(C || (C = {})); diff --git a/tests/baselines/reference/blockScopedNamespaceDifferentFile.symbols b/tests/baselines/reference/blockScopedNamespaceDifferentFile.symbols new file mode 100644 index 00000000000..b7192d0e12b --- /dev/null +++ b/tests/baselines/reference/blockScopedNamespaceDifferentFile.symbols @@ -0,0 +1,44 @@ +=== tests/cases/compiler/test.ts === +// #15734 failed when test.ts comes before typings.d.ts +namespace C { +>C : Symbol(C, Decl(test.ts, 0, 0)) + + export class Name { +>Name : Symbol(Name, Decl(test.ts, 1, 13)) + + static funcData = A.AA.func(); +>funcData : Symbol(Name.funcData, Decl(test.ts, 2, 23)) +>A.AA.func : Symbol(A.AA.func, Decl(typings.d.ts, 1, 18)) +>A.AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21)) +>A : Symbol(A, Decl(typings.d.ts, 0, 0)) +>AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21)) +>func : Symbol(A.AA.func, Decl(typings.d.ts, 1, 18)) + + static someConst = A.AA.foo; +>someConst : Symbol(Name.someConst, Decl(test.ts, 3, 38)) +>A.AA.foo : Symbol(A.AA.foo, Decl(typings.d.ts, 3, 13)) +>A.AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21)) +>A : Symbol(A, Decl(typings.d.ts, 0, 0)) +>AA : Symbol(A.AA, Decl(typings.d.ts, 0, 21)) +>foo : Symbol(A.AA.foo, Decl(typings.d.ts, 3, 13)) + + constructor(parameters) {} +>parameters : Symbol(parameters, Decl(test.ts, 6, 20)) + } +} + +=== tests/cases/compiler/typings.d.ts === +declare namespace A { +>A : Symbol(A, Decl(typings.d.ts, 0, 0)) + + namespace AA { +>AA : Symbol(AA, Decl(typings.d.ts, 0, 21)) + + function func(): number; +>func : Symbol(func, Decl(typings.d.ts, 1, 18)) + + const foo = ""; +>foo : Symbol(foo, Decl(typings.d.ts, 3, 13)) + } +} + diff --git a/tests/baselines/reference/blockScopedNamespaceDifferentFile.types b/tests/baselines/reference/blockScopedNamespaceDifferentFile.types new file mode 100644 index 00000000000..c03d51d2bc4 --- /dev/null +++ b/tests/baselines/reference/blockScopedNamespaceDifferentFile.types @@ -0,0 +1,46 @@ +=== tests/cases/compiler/test.ts === +// #15734 failed when test.ts comes before typings.d.ts +namespace C { +>C : typeof C + + export class Name { +>Name : Name + + static funcData = A.AA.func(); +>funcData : number +>A.AA.func() : number +>A.AA.func : () => number +>A.AA : typeof A.AA +>A : typeof A +>AA : typeof A.AA +>func : () => number + + static someConst = A.AA.foo; +>someConst : string +>A.AA.foo : "" +>A.AA : typeof A.AA +>A : typeof A +>AA : typeof A.AA +>foo : "" + + constructor(parameters) {} +>parameters : any + } +} + +=== tests/cases/compiler/typings.d.ts === +declare namespace A { +>A : typeof A + + namespace AA { +>AA : typeof AA + + function func(): number; +>func : () => number + + const foo = ""; +>foo : "" +>"" : "" + } +} + diff --git a/tests/baselines/reference/callExpressionWithMissingTypeArgument1.errors.txt b/tests/baselines/reference/callExpressionWithMissingTypeArgument1.errors.txt index aef540d958a..9ac8c650e00 100644 --- a/tests/baselines/reference/callExpressionWithMissingTypeArgument1.errors.txt +++ b/tests/baselines/reference/callExpressionWithMissingTypeArgument1.errors.txt @@ -1,10 +1,16 @@ tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts(1,1): error TS2304: Cannot find name 'Foo'. +tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts(1,5): error TS2304: Cannot find name 'a'. tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts(1,7): error TS1110: Type expected. +tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts(1,8): error TS2304: Cannot find name 'b'. -==== tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts (2 errors) ==== +==== tests/cases/compiler/callExpressionWithMissingTypeArgument1.ts (4 errors) ==== Foo(); ~~~ !!! error TS2304: Cannot find name 'Foo'. + ~ +!!! error TS2304: Cannot find name 'a'. ~ -!!! error TS1110: Type expected. \ No newline at end of file +!!! error TS1110: Type expected. + ~ +!!! error TS2304: Cannot find name 'b'. \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread2.errors.txt b/tests/baselines/reference/callWithSpread2.errors.txt new file mode 100644 index 00000000000..cfea427a2a7 --- /dev/null +++ b/tests/baselines/reference/callWithSpread2.errors.txt @@ -0,0 +1,81 @@ +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(30,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(31,5): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(32,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(33,13): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(34,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(35,11): error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. + Type 'string' is not assignable to type 'number'. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(36,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(37,1): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts(38,1): error TS2346: Supplied parameters do not match any signature of call target. + + +==== tests/cases/conformance/expressions/functionCalls/callWithSpread2.ts (9 errors) ==== + declare function all(a?: number, b?: number): void; + declare function weird(a?: number | string, b?: number | string): void; + declare function prefix(s: string, a?: number, b?: number): void; + declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void; + declare function normal(s: string): void; + declare function thunk(): string; + + declare var ns: number[]; + declare var mixed: (number | string)[]; + declare var tuple: [number, string]; + + // good + all(...ns) + weird(...ns) + weird(...mixed) + weird(...tuple) + prefix("a", ...ns) + rest("d", ...ns) + + + // this covers the arguments case + normal("g", ...ns) + normal("h", ...mixed) + normal("i", ...tuple) + thunk(...ns) + thunk(...mixed) + thunk(...tuple) + + // bad + all(...mixed) + ~~~~~~~~ +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + all(...tuple) + ~~~~~~~~ +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + prefix("b", ...mixed) + ~~~~~~~~ +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + prefix("c", ...tuple) + ~~~~~~~~ +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + rest("e", ...mixed) + ~~~~~~~~ +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + rest("f", ...tuple) + ~~~~~~~~ +!!! error TS2345: Argument of type 'string | number' is not assignable to parameter of type 'number'. +!!! error TS2345: Type 'string' is not assignable to type 'number'. + prefix(...ns) // required parameters are required + ~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + prefix(...mixed) + ~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + prefix(...tuple) + ~~~~~~~~~~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + \ No newline at end of file diff --git a/tests/baselines/reference/callWithSpread2.js b/tests/baselines/reference/callWithSpread2.js new file mode 100644 index 00000000000..55296d924f7 --- /dev/null +++ b/tests/baselines/reference/callWithSpread2.js @@ -0,0 +1,66 @@ +//// [callWithSpread2.ts] +declare function all(a?: number, b?: number): void; +declare function weird(a?: number | string, b?: number | string): void; +declare function prefix(s: string, a?: number, b?: number): void; +declare function rest(s: string, a?: number, b?: number, ...rest: number[]): void; +declare function normal(s: string): void; +declare function thunk(): string; + +declare var ns: number[]; +declare var mixed: (number | string)[]; +declare var tuple: [number, string]; + +// good +all(...ns) +weird(...ns) +weird(...mixed) +weird(...tuple) +prefix("a", ...ns) +rest("d", ...ns) + + +// this covers the arguments case +normal("g", ...ns) +normal("h", ...mixed) +normal("i", ...tuple) +thunk(...ns) +thunk(...mixed) +thunk(...tuple) + +// bad +all(...mixed) +all(...tuple) +prefix("b", ...mixed) +prefix("c", ...tuple) +rest("e", ...mixed) +rest("f", ...tuple) +prefix(...ns) // required parameters are required +prefix(...mixed) +prefix(...tuple) + + +//// [callWithSpread2.js] +// good +all.apply(void 0, ns); +weird.apply(void 0, ns); +weird.apply(void 0, mixed); +weird.apply(void 0, tuple); +prefix.apply(void 0, ["a"].concat(ns)); +rest.apply(void 0, ["d"].concat(ns)); +// this covers the arguments case +normal.apply(void 0, ["g"].concat(ns)); +normal.apply(void 0, ["h"].concat(mixed)); +normal.apply(void 0, ["i"].concat(tuple)); +thunk.apply(void 0, ns); +thunk.apply(void 0, mixed); +thunk.apply(void 0, tuple); +// bad +all.apply(void 0, mixed); +all.apply(void 0, tuple); +prefix.apply(void 0, ["b"].concat(mixed)); +prefix.apply(void 0, ["c"].concat(tuple)); +rest.apply(void 0, ["e"].concat(mixed)); +rest.apply(void 0, ["f"].concat(tuple)); +prefix.apply(void 0, ns); // required parameters are required +prefix.apply(void 0, mixed); +prefix.apply(void 0, tuple); diff --git a/tests/baselines/reference/cannotInvokeNewOnIndexExpression.errors.txt b/tests/baselines/reference/cannotInvokeNewOnIndexExpression.errors.txt index 7be5a1f086c..dbd10d775d9 100644 --- a/tests/baselines/reference/cannotInvokeNewOnIndexExpression.errors.txt +++ b/tests/baselines/reference/cannotInvokeNewOnIndexExpression.errors.txt @@ -1,7 +1,7 @@ -tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts(1,23): error TS2304: Cannot find name 'any'. +tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts(1,23): error TS2693: 'any' only refers to a type, but is being used as a value here. ==== tests/cases/compiler/cannotInvokeNewOnIndexExpression.ts (1 errors) ==== var test: any[] = new any[1]; ~~~ -!!! error TS2304: Cannot find name 'any'. \ No newline at end of file +!!! error TS2693: 'any' only refers to a type, but is being used as a value here. \ No newline at end of file diff --git a/tests/baselines/reference/capturedVarInLoop.js b/tests/baselines/reference/capturedVarInLoop.js new file mode 100644 index 00000000000..303c18eda2d --- /dev/null +++ b/tests/baselines/reference/capturedVarInLoop.js @@ -0,0 +1,17 @@ +//// [capturedVarInLoop.ts] +for (var i = 0; i < 10; i++) { + var str = 'x', len = str.length; + let lambda1 = (y) => { }; + let lambda2 = () => lambda1(len); +} + +//// [capturedVarInLoop.js] +var _loop_1 = function () { + str = 'x', len = str.length; + var lambda1 = function (y) { }; + var lambda2 = function () { return lambda1(len); }; +}; +var str, len; +for (var i = 0; i < 10; i++) { + _loop_1(); +} diff --git a/tests/baselines/reference/capturedVarInLoop.symbols b/tests/baselines/reference/capturedVarInLoop.symbols new file mode 100644 index 00000000000..9f218154fd8 --- /dev/null +++ b/tests/baselines/reference/capturedVarInLoop.symbols @@ -0,0 +1,22 @@ +=== tests/cases/compiler/capturedVarInLoop.ts === +for (var i = 0; i < 10; i++) { +>i : Symbol(i, Decl(capturedVarInLoop.ts, 0, 8)) +>i : Symbol(i, Decl(capturedVarInLoop.ts, 0, 8)) +>i : Symbol(i, Decl(capturedVarInLoop.ts, 0, 8)) + + var str = 'x', len = str.length; +>str : Symbol(str, Decl(capturedVarInLoop.ts, 1, 7)) +>len : Symbol(len, Decl(capturedVarInLoop.ts, 1, 18)) +>str.length : Symbol(String.length, Decl(lib.d.ts, --, --)) +>str : Symbol(str, Decl(capturedVarInLoop.ts, 1, 7)) +>length : Symbol(String.length, Decl(lib.d.ts, --, --)) + + let lambda1 = (y) => { }; +>lambda1 : Symbol(lambda1, Decl(capturedVarInLoop.ts, 2, 7)) +>y : Symbol(y, Decl(capturedVarInLoop.ts, 2, 19)) + + let lambda2 = () => lambda1(len); +>lambda2 : Symbol(lambda2, Decl(capturedVarInLoop.ts, 3, 7)) +>lambda1 : Symbol(lambda1, Decl(capturedVarInLoop.ts, 2, 7)) +>len : Symbol(len, Decl(capturedVarInLoop.ts, 1, 18)) +} diff --git a/tests/baselines/reference/capturedVarInLoop.types b/tests/baselines/reference/capturedVarInLoop.types new file mode 100644 index 00000000000..37d78df8ba3 --- /dev/null +++ b/tests/baselines/reference/capturedVarInLoop.types @@ -0,0 +1,30 @@ +=== tests/cases/compiler/capturedVarInLoop.ts === +for (var i = 0; i < 10; i++) { +>i : number +>0 : 0 +>i < 10 : boolean +>i : number +>10 : 10 +>i++ : number +>i : number + + var str = 'x', len = str.length; +>str : string +>'x' : "x" +>len : number +>str.length : number +>str : string +>length : number + + let lambda1 = (y) => { }; +>lambda1 : (y: any) => void +>(y) => { } : (y: any) => void +>y : any + + let lambda2 = () => lambda1(len); +>lambda2 : () => void +>() => lambda1(len) : () => void +>lambda1(len) : void +>lambda1 : (y: any) => void +>len : number +} diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt new file mode 100644 index 00000000000..d90e6d506ff --- /dev/null +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.errors.txt @@ -0,0 +1,29 @@ +tests/cases/compiler/weird.js(1,1): error TS2304: Cannot find name 'someFunction'. +tests/cases/compiler/weird.js(1,23): error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. +tests/cases/compiler/weird.js(6,13): error TS2346: Supplied parameters do not match any signature of call target. +tests/cases/compiler/weird.js(9,17): error TS7006: Parameter 'error' implicitly has an 'any' type. + + +==== tests/cases/compiler/weird.js (4 errors) ==== + someFunction(function(BaseClass) { + ~~~~~~~~~~~~ +!!! error TS2304: Cannot find name 'someFunction'. + ~~~~~~~~~ +!!! error TS7006: Parameter 'BaseClass' implicitly has an 'any' type. + 'use strict'; + const DEFAULT_MESSAGE = "nop!"; + class Hello extends BaseClass { + constructor() { + super(); + ~~~~~~~ +!!! error TS2346: Supplied parameters do not match any signature of call target. + this.foo = "bar"; + } + _render(error) { + ~~~~~ +!!! error TS7006: Parameter 'error' implicitly has an 'any' type. + const message = error.message || DEFAULT_MESSAGE; + } + } + }); + \ No newline at end of file diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols new file mode 100644 index 00000000000..c9ee830a9a5 --- /dev/null +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.symbols @@ -0,0 +1,17 @@ +=== tests/cases/compiler/weird.js === +someFunction(function(BaseClass) { +>BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) + + class Hello extends BaseClass { +>Hello : Symbol(Hello, Decl(weird.js, 0, 34)) +>BaseClass : Symbol(BaseClass, Decl(weird.js, 0, 22)) + + constructor() { + this.foo = "bar"; +>this.foo : Symbol(Hello.foo, Decl(weird.js, 2, 17)) +>this : Symbol(Hello, Decl(weird.js, 0, 34)) +>foo : Symbol(Hello.foo, Decl(weird.js, 2, 17)) + } + } +}); + diff --git a/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types new file mode 100644 index 00000000000..6a0a5ad1479 --- /dev/null +++ b/tests/baselines/reference/checkIndexConstraintOfJavascriptClassExpression.types @@ -0,0 +1,22 @@ +=== tests/cases/compiler/weird.js === +someFunction(function(BaseClass) { +>someFunction(function(BaseClass) { class Hello extends BaseClass { constructor() { this.foo = "bar"; } }}) : any +>someFunction : any +>function(BaseClass) { class Hello extends BaseClass { constructor() { this.foo = "bar"; } }} : (BaseClass: any) => void +>BaseClass : any + + class Hello extends BaseClass { +>Hello : Hello +>BaseClass : any + + constructor() { + this.foo = "bar"; +>this.foo = "bar" : "bar" +>this.foo : string +>this : this +>foo : string +>"bar" : "bar" + } + } +}); + diff --git a/tests/baselines/reference/checkJsFiles7.symbols b/tests/baselines/reference/checkJsFiles7.symbols new file mode 100644 index 00000000000..a8214483b86 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles7.symbols @@ -0,0 +1,20 @@ +=== tests/cases/compiler/a.js === +class C { +>C : Symbol(C, Decl(a.js, 0, 0)) + + constructor() { + /** @type {boolean} */ + this.a = true; +>this.a : Symbol(C.a, Decl(a.js, 1, 16), Decl(a.js, 3, 16)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>a : Symbol(C.a, Decl(a.js, 1, 16), Decl(a.js, 3, 16)) + + this.a = !!this.a; +>this.a : Symbol(C.a, Decl(a.js, 1, 16), Decl(a.js, 3, 16)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>a : Symbol(C.a, Decl(a.js, 1, 16), Decl(a.js, 3, 16)) +>this.a : Symbol(C.a, Decl(a.js, 1, 16), Decl(a.js, 3, 16)) +>this : Symbol(C, Decl(a.js, 0, 0)) +>a : Symbol(C.a, Decl(a.js, 1, 16), Decl(a.js, 3, 16)) + } +} diff --git a/tests/baselines/reference/checkJsFiles7.types b/tests/baselines/reference/checkJsFiles7.types new file mode 100644 index 00000000000..a86767b5e44 --- /dev/null +++ b/tests/baselines/reference/checkJsFiles7.types @@ -0,0 +1,25 @@ +=== tests/cases/compiler/a.js === +class C { +>C : C + + constructor() { + /** @type {boolean} */ + this.a = true; +>this.a = true : true +>this.a : boolean +>this : this +>a : boolean +>true : true + + this.a = !!this.a; +>this.a = !!this.a : boolean +>this.a : boolean +>this : this +>a : boolean +>!!this.a : boolean +>!this.a : boolean +>this.a : true +>this : this +>a : true + } +} diff --git a/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt b/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt index 758b295a49d..d9104608284 100644 --- a/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt +++ b/tests/baselines/reference/checkJsFiles_noErrorLocation.errors.txt @@ -1,4 +1,4 @@ -tests/cases/compiler/a.js(14,5): error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property. +tests/cases/compiler/a.js(14,10): error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property. ==== tests/cases/compiler/a.js (1 errors) ==== @@ -16,7 +16,7 @@ tests/cases/compiler/a.js(14,5): error TS2424: Class 'A' defines instance member constructor() { super(); this.foo = () => 3; - ~~~~~~~~~~~~~~~~~~ + ~~~ !!! error TS2424: Class 'A' defines instance member function 'foo', but extended class 'B' defines it as instance member property. } } diff --git a/tests/baselines/reference/checkJsxChildrenProperty12.js b/tests/baselines/reference/checkJsxChildrenProperty12.js new file mode 100644 index 00000000000..0030d87483f --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty12.js @@ -0,0 +1,76 @@ +//// [file.tsx] +import React = require('react'); + +interface ButtonProp { + a: number, + b: string, + children: Button; +} + +class Button extends React.Component { + render() { + let condition: boolean; + if (condition) { + return + } + else { + return ( +
Hello World
+
); + } + } +} + +interface InnerButtonProp { + a: number +} + +class InnerButton extends React.Component { + render() { + return (); + } +} + + +//// [file.jsx] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var React = require("react"); +var Button = (function (_super) { + __extends(Button, _super); + function Button() { + return _super !== null && _super.apply(this, arguments) || this; + } + Button.prototype.render = function () { + var condition; + if (condition) { + return ; + } + else { + return ( +
Hello World
+
); + } + }; + return Button; +}(React.Component)); +var InnerButton = (function (_super) { + __extends(InnerButton, _super); + function InnerButton() { + return _super !== null && _super.apply(this, arguments) || this; + } + InnerButton.prototype.render = function () { + return (); + }; + return InnerButton; +}(React.Component)); diff --git a/tests/baselines/reference/checkJsxChildrenProperty12.symbols b/tests/baselines/reference/checkJsxChildrenProperty12.symbols new file mode 100644 index 00000000000..ccfb4b18875 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty12.symbols @@ -0,0 +1,80 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : Symbol(React, Decl(file.tsx, 0, 0)) + +interface ButtonProp { +>ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32)) + + a: number, +>a : Symbol(ButtonProp.a, Decl(file.tsx, 2, 22)) + + b: string, +>b : Symbol(ButtonProp.b, Decl(file.tsx, 3, 14)) + + children: Button; +>children : Symbol(ButtonProp.children, Decl(file.tsx, 4, 14)) +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) +} + +class Button extends React.Component { +>Button : Symbol(Button, Decl(file.tsx, 6, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>ButtonProp : Symbol(ButtonProp, Decl(file.tsx, 0, 32)) + + render() { +>render : Symbol(Button.render, Decl(file.tsx, 8, 55)) + + let condition: boolean; +>condition : Symbol(condition, Decl(file.tsx, 10, 5)) + + if (condition) { +>condition : Symbol(condition, Decl(file.tsx, 10, 5)) + + return +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>this : Symbol(Button, Decl(file.tsx, 6, 1)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) + } + else { + return ( +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) +>this.props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) +>this : Symbol(Button, Decl(file.tsx, 6, 1)) +>props : Symbol(React.Component.props, Decl(react.d.ts, 166, 37)) + +
Hello World
+>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) +>div : Symbol(JSX.IntrinsicElements.div, Decl(react.d.ts, 2399, 45)) + +
); +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) + } + } +} + +interface InnerButtonProp { +>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1)) + + a: number +>a : Symbol(InnerButtonProp.a, Decl(file.tsx, 22, 27)) +} + +class InnerButton extends React.Component { +>InnerButton : Symbol(InnerButton, Decl(file.tsx, 24, 1)) +>React.Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>React : Symbol(React, Decl(file.tsx, 0, 0)) +>Component : Symbol(React.Component, Decl(react.d.ts, 158, 55)) +>InnerButtonProp : Symbol(InnerButtonProp, Decl(file.tsx, 20, 1)) + + render() { +>render : Symbol(InnerButton.render, Decl(file.tsx, 26, 65)) + + return (); +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) + } +} + diff --git a/tests/baselines/reference/checkJsxChildrenProperty12.types b/tests/baselines/reference/checkJsxChildrenProperty12.types new file mode 100644 index 00000000000..93a7d0f9be1 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty12.types @@ -0,0 +1,86 @@ +=== tests/cases/conformance/jsx/file.tsx === +import React = require('react'); +>React : typeof React + +interface ButtonProp { +>ButtonProp : ButtonProp + + a: number, +>a : number + + b: string, +>b : string + + children: Button; +>children : Button +>Button : Button +} + +class Button extends React.Component { +>Button : Button +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>ButtonProp : ButtonProp + + render() { +>render : () => JSX.Element + + let condition: boolean; +>condition : boolean + + if (condition) { +>condition : boolean + + return +> : JSX.Element +>InnerButton : typeof InnerButton +>this.props : ButtonProp & { children?: React.ReactNode; } +>this : this +>props : ButtonProp & { children?: React.ReactNode; } + } + else { + return ( +>(
Hello World
) : JSX.Element +>
Hello World
: JSX.Element +>InnerButton : typeof InnerButton +>this.props : ButtonProp & { children?: React.ReactNode; } +>this : this +>props : ButtonProp & { children?: React.ReactNode; } + +
Hello World
+>
Hello World
: JSX.Element +>div : any +>div : any + +
); +>InnerButton : typeof InnerButton + } + } +} + +interface InnerButtonProp { +>InnerButtonProp : InnerButtonProp + + a: number +>a : number +} + +class InnerButton extends React.Component { +>InnerButton : InnerButton +>React.Component : React.Component +>React : typeof React +>Component : typeof React.Component +>InnerButtonProp : InnerButtonProp + + render() { +>render : () => JSX.Element + + return (); +>() : JSX.Element +> : JSX.Element +>button : any +>button : any + } +} + diff --git a/tests/baselines/reference/checkJsxChildrenProperty13.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty13.errors.txt new file mode 100644 index 00000000000..c926980cab1 --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty13.errors.txt @@ -0,0 +1,33 @@ +tests/cases/conformance/jsx/file.tsx(12,30): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten. + + +==== tests/cases/conformance/jsx/file.tsx (1 errors) ==== + import React = require('react'); + + interface ButtonProp { + a: number, + b: string, + children: Button; + } + + class Button extends React.Component { + render() { + // Error children are specified twice + return ( + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten. +
Hello World
+
); + } + } + + interface InnerButtonProp { + a: number + } + + class InnerButton extends React.Component { + render() { + return (); + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/checkJsxChildrenProperty13.js b/tests/baselines/reference/checkJsxChildrenProperty13.js new file mode 100644 index 00000000000..8947e6b211f --- /dev/null +++ b/tests/baselines/reference/checkJsxChildrenProperty13.js @@ -0,0 +1,66 @@ +//// [file.tsx] +import React = require('react'); + +interface ButtonProp { + a: number, + b: string, + children: Button; +} + +class Button extends React.Component { + render() { + // Error children are specified twice + return ( +
Hello World
+
); + } +} + +interface InnerButtonProp { + a: number +} + +class InnerButton extends React.Component { + render() { + return (); + } +} + + +//// [file.jsx] +"use strict"; +var __extends = (this && this.__extends) || (function () { + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; + return function (d, b) { + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +exports.__esModule = true; +var React = require("react"); +var Button = (function (_super) { + __extends(Button, _super); + function Button() { + return _super !== null && _super.apply(this, arguments) || this; + } + Button.prototype.render = function () { + // Error children are specified twice + return ( +
Hello World
+
); + }; + return Button; +}(React.Component)); +var InnerButton = (function (_super) { + __extends(InnerButton, _super); + function InnerButton() { + return _super !== null && _super.apply(this, arguments) || this; + } + InnerButton.prototype.render = function () { + return (); + }; + return InnerButton; +}(React.Component)); diff --git a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt index 6bb91bd6385..aeeceb8652e 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty2.errors.txt @@ -2,7 +2,6 @@ tests/cases/conformance/jsx/file.tsx(14,15): error TS2322: Type '{ a: 10; b: "hi Type '{ a: 10; b: "hi"; }' is not assignable to type 'Prop'. Property 'children' is missing in type '{ a: 10; b: "hi"; }'. tests/cases/conformance/jsx/file.tsx(17,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten. -tests/cases/conformance/jsx/file.tsx(25,11): error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten. tests/cases/conformance/jsx/file.tsx(31,11): error TS2322: Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'IntrinsicAttributes & Prop'. Type '{ a: 10; b: "hi"; children: (Element | ((name: string) => Element))[]; }' is not assignable to type 'Prop'. Types of property 'children' are incompatible. @@ -29,7 +28,7 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi Property 'type' is missing in type 'Element[]'. -==== tests/cases/conformance/jsx/file.tsx (7 errors) ==== +==== tests/cases/conformance/jsx/file.tsx (6 errors) ==== import React = require('react'); interface Prop { @@ -61,8 +60,6 @@ tests/cases/conformance/jsx/file.tsx(49,11): error TS2322: Type '{ a: 10; b: "hi } let k1 = - ~~~~~~~~~~~~~~~~~~~~ -!!! error TS2710: 'children' are specified twice. The attribute named 'children' will be overwritten. hi hi hi! ; diff --git a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt index d12c557102c..399b159f482 100644 --- a/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt +++ b/tests/baselines/reference/checkJsxChildrenProperty4.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/jsx/file.tsx(24,28): error TS2339: Property 'NAme' does not exist on type 'IUser'. +tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'? tests/cases/conformance/jsx/file.tsx(32,9): error TS2322: Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & IFetchUserProps & { children?: ReactNode; }'. Type '{ children: ((user: IUser) => Element)[]; }' is not assignable to type 'IFetchUserProps'. Types of property 'children' are incompatible. @@ -32,7 +32,7 @@ tests/cases/conformance/jsx/file.tsx(32,9): error TS2322: Type '{ children: ((us { user => (

{ user.NAme }

~~~~ -!!! error TS2339: Property 'NAme' does not exist on type 'IUser'. +!!! error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'? ) }
); diff --git a/tests/baselines/reference/classBlockScoping.js b/tests/baselines/reference/classBlockScoping.js new file mode 100644 index 00000000000..76d0dd892de --- /dev/null +++ b/tests/baselines/reference/classBlockScoping.js @@ -0,0 +1,71 @@ +//// [classBlockScoping.ts] +function f(b: boolean) { + let Foo: any; + if (b) { + Foo = class Foo { + static y = new Foo(); + + static x() { + new Foo(); + } + + m() { + new Foo(); + } + }; + + new Foo(); + } + else { + class Foo { + static y = new Foo(); + + static x() { + new Foo(); + } + + m() { + new Foo(); + } + } + + new Foo(); + } +} + +//// [classBlockScoping.js] +function f(b) { + var Foo; + if (b) { + Foo = (_a = (function () { + function Foo() { + } + Foo.x = function () { + new Foo(); + }; + Foo.prototype.m = function () { + new Foo(); + }; + return Foo; + }()), + _a.y = new _a(), + _a); + new Foo(); + } + else { + var Foo_1 = (function () { + function Foo() { + } + Foo.x = function () { + new Foo(); + }; + Foo.prototype.m = function () { + new Foo(); + }; + return Foo; + }()); + Foo_1.y = new Foo_1(); + new Foo_1(); + } + var _a; +} diff --git a/tests/baselines/reference/classBlockScoping.symbols b/tests/baselines/reference/classBlockScoping.symbols new file mode 100644 index 00000000000..571d54f2d8e --- /dev/null +++ b/tests/baselines/reference/classBlockScoping.symbols @@ -0,0 +1,64 @@ +=== tests/cases/compiler/classBlockScoping.ts === +function f(b: boolean) { +>f : Symbol(f, Decl(classBlockScoping.ts, 0, 0)) +>b : Symbol(b, Decl(classBlockScoping.ts, 0, 11)) + + let Foo: any; +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 1, 5)) + + if (b) { +>b : Symbol(b, Decl(classBlockScoping.ts, 0, 11)) + + Foo = class Foo { +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 1, 5)) +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 3, 9)) + + static y = new Foo(); +>y : Symbol(Foo.y, Decl(classBlockScoping.ts, 3, 21)) +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 3, 9)) + + static x() { +>x : Symbol(Foo.x, Decl(classBlockScoping.ts, 4, 27)) + + new Foo(); +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 3, 9)) + } + + m() { +>m : Symbol(Foo.m, Decl(classBlockScoping.ts, 8, 7)) + + new Foo(); +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 3, 9)) + } + }; + + new Foo(); +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 1, 5)) + } + else { + class Foo { +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 17, 8)) + + static y = new Foo(); +>y : Symbol(Foo.y, Decl(classBlockScoping.ts, 18, 15)) +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 17, 8)) + + static x() { +>x : Symbol(Foo.x, Decl(classBlockScoping.ts, 19, 27)) + + new Foo(); +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 17, 8)) + } + + m() { +>m : Symbol(Foo.m, Decl(classBlockScoping.ts, 23, 7)) + + new Foo(); +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 17, 8)) + } + } + + new Foo(); +>Foo : Symbol(Foo, Decl(classBlockScoping.ts, 17, 8)) + } +} diff --git a/tests/baselines/reference/classBlockScoping.types b/tests/baselines/reference/classBlockScoping.types new file mode 100644 index 00000000000..a54499d7400 --- /dev/null +++ b/tests/baselines/reference/classBlockScoping.types @@ -0,0 +1,74 @@ +=== tests/cases/compiler/classBlockScoping.ts === +function f(b: boolean) { +>f : (b: boolean) => void +>b : boolean + + let Foo: any; +>Foo : any + + if (b) { +>b : boolean + + Foo = class Foo { +>Foo = class Foo { static y = new Foo(); static x() { new Foo(); } m() { new Foo(); } } : typeof Foo +>Foo : any +>class Foo { static y = new Foo(); static x() { new Foo(); } m() { new Foo(); } } : typeof Foo +>Foo : typeof Foo + + static y = new Foo(); +>y : Foo +>new Foo() : Foo +>Foo : typeof Foo + + static x() { +>x : () => void + + new Foo(); +>new Foo() : Foo +>Foo : typeof Foo + } + + m() { +>m : () => void + + new Foo(); +>new Foo() : Foo +>Foo : typeof Foo + } + }; + + new Foo(); +>new Foo() : any +>Foo : any + } + else { + class Foo { +>Foo : Foo + + static y = new Foo(); +>y : Foo +>new Foo() : Foo +>Foo : typeof Foo + + static x() { +>x : () => void + + new Foo(); +>new Foo() : Foo +>Foo : typeof Foo + } + + m() { +>m : () => void + + new Foo(); +>new Foo() : Foo +>Foo : typeof Foo + } + } + + new Foo(); +>new Foo() : Foo +>Foo : typeof Foo + } +} diff --git a/tests/baselines/reference/classConstructorAccessibility.js b/tests/baselines/reference/classConstructorAccessibility.js index 46a548d0b54..4d120a3980f 100644 --- a/tests/baselines/reference/classConstructorAccessibility.js +++ b/tests/baselines/reference/classConstructorAccessibility.js @@ -89,7 +89,7 @@ declare class C { } declare class D { x: number; - private constructor(x); + private constructor(); } declare class E { x: number; diff --git a/tests/baselines/reference/classConstructorAccessibility2.js b/tests/baselines/reference/classConstructorAccessibility2.js index 7297af11a4e..76c8ea19110 100644 --- a/tests/baselines/reference/classConstructorAccessibility2.js +++ b/tests/baselines/reference/classConstructorAccessibility2.js @@ -135,7 +135,7 @@ declare class BaseB { } declare class BaseC { x: number; - private constructor(x); + private constructor(); createInstance(): void; static staticInstance(): void; } diff --git a/tests/baselines/reference/classConstructorAccessibility3.js b/tests/baselines/reference/classConstructorAccessibility3.js index 3e024970bcf..d1bd8f38c40 100644 --- a/tests/baselines/reference/classConstructorAccessibility3.js +++ b/tests/baselines/reference/classConstructorAccessibility3.js @@ -90,7 +90,7 @@ declare class Baz { } declare class Qux { x: number; - private constructor(x); + private constructor(); } declare let a: typeof Foo; declare let b: typeof Baz; diff --git a/tests/baselines/reference/classConstructorOverloadsAccessibility.js b/tests/baselines/reference/classConstructorOverloadsAccessibility.js index 7fef7443c62..2a173966d5d 100644 --- a/tests/baselines/reference/classConstructorOverloadsAccessibility.js +++ b/tests/baselines/reference/classConstructorOverloadsAccessibility.js @@ -59,7 +59,7 @@ var D = (function () { declare class A { constructor(a: boolean); protected constructor(a: number); - private constructor(a); + private constructor(); } declare class B { protected constructor(a: number); diff --git a/tests/baselines/reference/classDeclarationBlockScoping1.js b/tests/baselines/reference/classDeclarationBlockScoping1.js index ac3195af696..03c6254d9ea 100644 --- a/tests/baselines/reference/classDeclarationBlockScoping1.js +++ b/tests/baselines/reference/classDeclarationBlockScoping1.js @@ -15,8 +15,8 @@ var C = (function () { }()); { var C_1 = (function () { - function C_1() { + function C() { } - return C_1; + return C; }()); } diff --git a/tests/baselines/reference/classDeclarationBlockScoping2.js b/tests/baselines/reference/classDeclarationBlockScoping2.js index c3e3a89677a..7cc8a064a0c 100644 --- a/tests/baselines/reference/classDeclarationBlockScoping2.js +++ b/tests/baselines/reference/classDeclarationBlockScoping2.js @@ -19,9 +19,9 @@ function f() { var c1 = C; { var C_1 = (function () { - function C_1() { + function C() { } - return C_1; + return C; }()); var c2 = C_1; } diff --git a/tests/baselines/reference/classExtendingPrimitive.errors.txt b/tests/baselines/reference/classExtendingPrimitive.errors.txt index 554e0fbecbc..32a3e68cb3e 100644 --- a/tests/baselines/reference/classExtendingPrimitive.errors.txt +++ b/tests/baselines/reference/classExtendingPrimitive.errors.txt @@ -1,11 +1,11 @@ -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(3,17): error TS2304: Cannot find name 'number'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(4,18): error TS2304: Cannot find name 'string'. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(5,18): error TS2304: Cannot find name 'boolean'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(3,17): error TS2693: 'number' only refers to a type, but is being used as a value here. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(4,18): error TS2693: 'string' only refers to a type, but is being used as a value here. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(5,18): error TS2693: 'boolean' only refers to a type, but is being used as a value here. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(6,18): error TS2304: Cannot find name 'Void'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(7,19): error TS1109: Expression expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(8,18): error TS2304: Cannot find name 'Null'. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(10,18): error TS2507: Type 'undefined' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(11,18): error TS2304: Cannot find name 'Undefined'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(11,18): error TS2552: Cannot find name 'Undefined'. Did you mean 'undefined'? tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendingPrimitive.ts(14,18): error TS2507: Type 'typeof E' is not a constructor function type. @@ -14,13 +14,13 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla class C extends number { } ~~~~~~ -!!! error TS2304: Cannot find name 'number'. +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. class C2 extends string { } ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. class C3 extends boolean { } ~~~~~~~ -!!! error TS2304: Cannot find name 'boolean'. +!!! error TS2693: 'boolean' only refers to a type, but is being used as a value here. class C4 extends Void { } ~~~~ !!! error TS2304: Cannot find name 'Void'. @@ -36,7 +36,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla !!! error TS2507: Type 'undefined' is not a constructor function type. class C7 extends Undefined { } ~~~~~~~~~ -!!! error TS2304: Cannot find name 'Undefined'. +!!! error TS2552: Cannot find name 'Undefined'. Did you mean 'undefined'? enum E { A } class C8 extends E { } diff --git a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt index e1c5137e3a9..b4e8aa7360e 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType.errors.txt @@ -1,6 +1,6 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(4,17): error TS2689: Cannot extend an interface 'I'. Did you mean 'implements'? tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,18): error TS2507: Type '{ foo: any; }' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,25): error TS2304: Cannot find name 'string'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,25): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(6,31): error TS1005: ',' expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(8,18): error TS2507: Type '{ foo: string; }' is not a constructor function type. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType.ts(11,18): error TS2507: Type 'typeof M' is not a constructor function type. @@ -20,7 +20,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla ~~~~~~~~~~~~~~~~ !!! error TS2507: Type '{ foo: any; }' is not a constructor function type. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ',' expected. var x: { foo: string; } diff --git a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt index af52a248b54..bbaac166582 100644 --- a/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt +++ b/tests/baselines/reference/classExtendsEveryObjectType2.errors.txt @@ -1,5 +1,5 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,18): error TS2507: Type '{ foo: any; }' is not a constructor function type. -tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,25): error TS2304: Cannot find name 'string'. +tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,25): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(1,31): error TS1005: ',' expected. tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classExtendsEveryObjectType2.ts(3,18): error TS2507: Type 'undefined[]' is not a constructor function type. @@ -9,7 +9,7 @@ tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/cla ~~~~~~~~~~~~~~~~ !!! error TS2507: Type '{ foo: any; }' is not a constructor function type. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ',' expected. diff --git a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt index b21e062e3b0..9854a115aa6 100644 --- a/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt +++ b/tests/baselines/reference/classMemberWithMissingIdentifier2.errors.txt @@ -2,7 +2,7 @@ tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,11): error TS1146: D tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,12): error TS1005: '=' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,14): error TS2304: Cannot find name 'name'. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,18): error TS1005: ']' expected. -tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2304: Cannot find name 'string'. +tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,19): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,25): error TS1005: ',' expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,26): error TS1136: Property assignment expected. tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: Cannot find name 'VariableDeclaration'. @@ -20,7 +20,7 @@ tests/cases/compiler/classMemberWithMissingIdentifier2.ts(2,27): error TS2304: C ~ !!! error TS1005: ']' expected. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ',' expected. ~ diff --git a/tests/baselines/reference/collisionArgumentsClassConstructor.errors.txt b/tests/baselines/reference/collisionArgumentsClassConstructor.errors.txt index 03bf4f9e38b..a7066fb1fbe 100644 --- a/tests/baselines/reference/collisionArgumentsClassConstructor.errors.txt +++ b/tests/baselines/reference/collisionArgumentsClassConstructor.errors.txt @@ -13,9 +13,6 @@ tests/cases/compiler/collisionArgumentsClassConstructor.ts(30,24): error TS1210: tests/cases/compiler/collisionArgumentsClassConstructor.ts(31,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(35,24): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(36,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(41,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(44,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(47,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(51,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(52,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(53,25): error TS2396: Duplicate identifier 'arguments'. Compiler uses 'arguments' to initialize rest parameters. @@ -30,15 +27,9 @@ tests/cases/compiler/collisionArgumentsClassConstructor.ts(67,17): error TS1210: tests/cases/compiler/collisionArgumentsClassConstructor.ts(68,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(69,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassConstructor.ts(70,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(75,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(76,31): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(79,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(80,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(84,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassConstructor.ts(85,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -==== tests/cases/compiler/collisionArgumentsClassConstructor.ts (38 errors) ==== +==== tests/cases/compiler/collisionArgumentsClassConstructor.ts (29 errors) ==== // Constructors class c1 { constructor(i: number, ...arguments) { // error @@ -110,18 +101,12 @@ tests/cases/compiler/collisionArgumentsClassConstructor.ts(85,17): error TS1210: declare class c4 { constructor(i: number, ...arguments); // No error - no code gen - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } declare class c42 { constructor(arguments: number, ...rest); // No error - no code gen - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } declare class c4NoError { constructor(arguments: number); // no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } class c5 { @@ -178,26 +163,14 @@ tests/cases/compiler/collisionArgumentsClassConstructor.ts(85,17): error TS1210: declare class c6 { constructor(i: number, ...arguments); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. constructor(i: string, ...arguments); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } declare class c62 { constructor(arguments: number, ...rest); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. constructor(arguments: string, ...rest); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } declare class c6NoError { constructor(arguments: number); // no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. constructor(arguments: string); // no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } \ No newline at end of file diff --git a/tests/baselines/reference/collisionArgumentsClassMethod.errors.txt b/tests/baselines/reference/collisionArgumentsClassMethod.errors.txt index ea699414f17..ec0562f57ca 100644 --- a/tests/baselines/reference/collisionArgumentsClassMethod.errors.txt +++ b/tests/baselines/reference/collisionArgumentsClassMethod.errors.txt @@ -20,20 +20,11 @@ tests/cases/compiler/collisionArgumentsClassMethod.ts(21,22): error TS1210: Inva tests/cases/compiler/collisionArgumentsClassMethod.ts(22,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassMethod.ts(23,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassMethod.ts(24,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(29,30): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(30,17): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(31,23): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(33,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(34,29): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(35,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(36,16): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(37,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -tests/cases/compiler/collisionArgumentsClassMethod.ts(38,22): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassMethod.ts(43,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. tests/cases/compiler/collisionArgumentsClassMethod.ts(46,13): error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. -==== tests/cases/compiler/collisionArgumentsClassMethod.ts (33 errors) ==== +==== tests/cases/compiler/collisionArgumentsClassMethod.ts (24 errors) ==== class c1 { public foo(i: number, ...arguments) { //arguments is error ~~~~~~~~~~~~ @@ -107,33 +98,15 @@ tests/cases/compiler/collisionArgumentsClassMethod.ts(46,13): error TS1210: Inva declare class c2 { public foo(i: number, ...arguments); // No error - no code gen - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public foo1(arguments: number, ...rest); // No error - no code gen - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public fooNoError(arguments: number); // No error - no code gen - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public f4(i: number, ...arguments); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public f4(i: string, ...arguments); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public f41(arguments: number, ...rest); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public f41(arguments: string, ...rest); // no codegen no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public f4NoError(arguments: number); // no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. public f4NoError(arguments: string); // no error - ~~~~~~~~~ -!!! error TS1210: Invalid use of 'arguments'. Class definitions are automatically in strict mode. } class c3 { diff --git a/tests/baselines/reference/complicatedPrivacy.errors.txt b/tests/baselines/reference/complicatedPrivacy.errors.txt index c81605a5a83..661b0693807 100644 --- a/tests/baselines/reference/complicatedPrivacy.errors.txt +++ b/tests/baselines/reference/complicatedPrivacy.errors.txt @@ -1,6 +1,6 @@ tests/cases/compiler/complicatedPrivacy.ts(11,24): error TS1054: A 'get' accessor cannot have parameters. tests/cases/compiler/complicatedPrivacy.ts(35,5): error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. -tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2304: Cannot find name 'number'. +tests/cases/compiler/complicatedPrivacy.ts(35,6): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo5' has no exported member 'i6'. @@ -45,7 +45,7 @@ tests/cases/compiler/complicatedPrivacy.ts(73,55): error TS2694: Namespace 'mglo ~~~~~~~~ !!! error TS1170: A computed property name in a type literal must directly refer to a built-in symbol. ~~~~~~ -!!! error TS2304: Cannot find name 'number'. +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. }) { } diff --git a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt index a572e0b34c8..1d37b20a3b3 100644 --- a/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt +++ b/tests/baselines/reference/constructorWithIncompleteTypeAnnotation.errors.txt @@ -52,13 +52,13 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,9): error TS tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,16): error TS2304: Cannot find name 'method1'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,24): error TS2304: Cannot find name 'val'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,27): error TS1005: ',' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error TS2304: Cannot find name 'number'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,28): error TS2693: 'number' only refers to a type, but is being used as a value here. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(235,36): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,9): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,16): error TS2304: Cannot find name 'method2'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(238,26): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(241,5): error TS1128: Declaration or statement expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(246,25): error TS2339: Property 'method1' does not exist on type 'B'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(246,25): error TS2551: Property 'method1' does not exist on type 'B'. Did you mean 'method2'? tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,9): error TS2390: Constructor implementation is missing. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,21): error TS2369: A parameter property is only allowed in a constructor implementation. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(254,44): error TS2369: A parameter property is only allowed in a constructor implementation. @@ -67,14 +67,14 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,9): error TS tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,16): error TS2304: Cannot find name 'Overloads'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,26): error TS2304: Cannot find name 'value'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,31): error TS1005: ',' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,33): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(256,33): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,9): error TS1128: Declaration or statement expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,16): error TS2304: Cannot find name 'Overloads'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,27): error TS1135: Argument expression expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,33): error TS1005: '(' expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,35): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,35): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,43): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,52): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,52): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,60): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(257,65): error TS1109: Expression expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,9): error TS2304: Cannot find name 'public'. @@ -82,7 +82,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error T tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,16): error TS2304: Cannot find name 'DefaultValue'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,29): error TS2304: Cannot find name 'value'. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,35): error TS1109: Expression expected. -tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2304: Cannot find name 'string'. +tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,37): error TS2693: 'string' only refers to a type, but is being used as a value here. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(259,55): error TS1005: ';' expected. tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS1128: Declaration or statement expected. @@ -435,7 +435,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS ~ !!! error TS1005: ',' expected. ~~~~~~ -!!! error TS2304: Cannot find name 'number'. +!!! error TS2693: 'number' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ';' expected. return val; @@ -458,7 +458,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS public method2() { return this.method1(2); ~~~~~~~ -!!! error TS2339: Property 'method1' does not exist on type 'B'. +!!! error TS2551: Property 'method1' does not exist on type 'B'. Did you mean 'method2'? } } @@ -486,7 +486,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS ~ !!! error TS1005: ',' expected. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. public Overloads( while : string, ...rest: string[]) { & ~~~~~~ !!! error TS1128: Declaration or statement expected. @@ -497,11 +497,11 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS ~ !!! error TS1005: '(' expected. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~~~ !!! error TS1109: Expression expected. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ';' expected. ~ @@ -519,7 +519,7 @@ tests/cases/compiler/constructorWithIncompleteTypeAnnotation.ts(261,1): error TS ~ !!! error TS1109: Expression expected. ~~~~~~ -!!! error TS2304: Cannot find name 'string'. +!!! error TS2693: 'string' only refers to a type, but is being used as a value here. ~ !!! error TS1005: ';' expected. } diff --git a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt index 28c550ccda1..ccf56532bc4 100644 --- a/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt +++ b/tests/baselines/reference/contextuallyTypedStringLiteralsInJsxAttributes02.errors.txt @@ -1,15 +1,13 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(27,24): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. - Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'LinkProps'. + Property 'goTo' is missing in type '{ extra: true; onClick: (k: "left" | "right") => void; }'. tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(28,24): error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. - Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,24): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. - Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,24): error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. - Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,25): error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. - Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. -tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,25): error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. - Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'LinkProps'. + Property 'goTo' is missing in type '{ onClick: (k: "left" | "right") => void; extra: true; }'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(29,43): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(30,36): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(33,65): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. +tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,44): error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. ==== tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx (6 errors) ==== @@ -42,29 +40,27 @@ tests/cases/conformance/types/contextualTypes/jsxAttributes/file.tsx(36,25): err const b0 = {console.log(k)}}} extra />; // k has type "left" | "right" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. -!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'LinkProps'. +!!! error TS2322: Property 'goTo' is missing in type '{ extra: true; onClick: (k: "left" | "right") => void; }'. const b2 = {console.log(k)}} extra />; // k has type "left" | "right" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. -!!! error TS2322: Property 'onClick' does not exist on type 'IntrinsicAttributes & LinkProps'. +!!! error TS2322: Type '{ onClick: (k: "left" | "right") => void; extra: true; }' is not assignable to type 'LinkProps'. +!!! error TS2322: Property 'goTo' is missing in type '{ onClick: (k: "left" | "right") => void; extra: true; }'. const b3 = ; // goTo has type"home" | "contact" - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. -!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + ~~~~~ +!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. const b4 = ; // goTo has type "home" | "contact" - ~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ goTo: "home"; extra: true; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. -!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + ~~~~~ +!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. export function NoOverload(buttonProps: ButtonProps): JSX.Element { return undefined } const c1 = {console.log(k)}}} extra />; // k has type any - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ extra: true; onClick: (k: "left" | "right") => void; }' is not assignable to type 'IntrinsicAttributes & ButtonProps'. -!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. + ~~~~~ +!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & ButtonProps'. export function NoOverload1(linkProps: LinkProps): JSX.Element { return undefined } const d1 = ; // goTo has type "home" | "contact" - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2322: Type '{ extra: true; goTo: "home"; }' is not assignable to type 'IntrinsicAttributes & LinkProps'. -!!! error TS2322: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. + ~~~~~ +!!! error TS2339: Property 'extra' does not exist on type 'IntrinsicAttributes & LinkProps'. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences1.js b/tests/baselines/reference/correctlyMarkAliasAsReferences1.js new file mode 100644 index 00000000000..7816881f4a2 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences1.js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/jsx/correctlyMarkAliasAsReferences1.tsx] //// + +//// [declaration.d.ts] +declare module "classnames"; + +//// [0.tsx] +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps; // any +let k = ; + + +//// [0.js] +/// +import * as cx from 'classnames'; +import * as React from "react"; +let buttonProps; // any +let k = React.createElement("button", Object.assign({}, buttonProps), + React.createElement("span", { className: cx('class1', { class2: true }) })); diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols new file mode 100644 index 00000000000..3267a29050e --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences1.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/0.tsx === +/// +import * as cx from 'classnames'; +>cx : Symbol(cx, Decl(0.tsx, 1, 6)) + +import * as React from "react"; +>React : Symbol(React, Decl(0.tsx, 2, 6)) + +let buttonProps; // any +>buttonProps : Symbol(buttonProps, Decl(0.tsx, 4, 3)) + +let k = ; +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) + +=== tests/cases/conformance/jsx/declaration.d.ts === +declare module "classnames"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences1.types b/tests/baselines/reference/correctlyMarkAliasAsReferences1.types new file mode 100644 index 00000000000..dbcad2fdc3c --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences1.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsx/0.tsx === +/// +import * as cx from 'classnames'; +>cx : any + +import * as React from "react"; +>React : typeof React + +let buttonProps; // any +>buttonProps : any + +let k = : JSX.Element +>button : any +>buttonProps : any + + +> : JSX.Element +>span : any +>className : any +>cx('class1', { class2: true }) : any +>cx : any +>'class1' : "class1" +>{ class2: true } : { class2: boolean; } +>class2 : boolean +>true : true + + ; +>button : any + +=== tests/cases/conformance/jsx/declaration.d.ts === +declare module "classnames"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences2.js b/tests/baselines/reference/correctlyMarkAliasAsReferences2.js new file mode 100644 index 00000000000..7af59b017a8 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences2.js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/jsx/correctlyMarkAliasAsReferences2.tsx] //// + +//// [declaration.d.ts] +declare module "classnames"; + +//// [0.tsx] +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps : {[attributeName: string]: ''} +let k = ; + + +//// [0.js] +/// +import * as cx from 'classnames'; +import * as React from "react"; +let buttonProps; +let k = React.createElement("button", Object.assign({}, buttonProps), + React.createElement("span", { className: cx('class1', { class2: true }) })); diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols new file mode 100644 index 00000000000..76d9b8cdfe0 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences2.symbols @@ -0,0 +1,30 @@ +=== tests/cases/conformance/jsx/0.tsx === +/// +import * as cx from 'classnames'; +>cx : Symbol(cx, Decl(0.tsx, 1, 6)) + +import * as React from "react"; +>React : Symbol(React, Decl(0.tsx, 2, 6)) + +let buttonProps : {[attributeName: string]: ''} +>buttonProps : Symbol(buttonProps, Decl(0.tsx, 4, 3)) +>attributeName : Symbol(attributeName, Decl(0.tsx, 4, 20)) + +let k = ; +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) + +=== tests/cases/conformance/jsx/declaration.d.ts === +declare module "classnames"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences2.types b/tests/baselines/reference/correctlyMarkAliasAsReferences2.types new file mode 100644 index 00000000000..cfaba960da2 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences2.types @@ -0,0 +1,36 @@ +=== tests/cases/conformance/jsx/0.tsx === +/// +import * as cx from 'classnames'; +>cx : any + +import * as React from "react"; +>React : typeof React + +let buttonProps : {[attributeName: string]: ''} +>buttonProps : { [attributeName: string]: ""; } +>attributeName : string + +let k = : JSX.Element +>button : any +>buttonProps : { [attributeName: string]: ""; } + + +> : JSX.Element +>span : any +>className : any +>cx('class1', { class2: true }) : any +>cx : any +>'class1' : "class1" +>{ class2: true } : { class2: boolean; } +>class2 : boolean +>true : true + + ; +>button : any + +=== tests/cases/conformance/jsx/declaration.d.ts === +declare module "classnames"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences3.js b/tests/baselines/reference/correctlyMarkAliasAsReferences3.js new file mode 100644 index 00000000000..166e29d56db --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences3.js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/jsx/correctlyMarkAliasAsReferences3.tsx] //// + +//// [declaration.d.ts] +declare module "classnames"; + +//// [0.tsx] +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps; +let k = ; + + +//// [0.js] +/// +import * as cx from 'classnames'; +import * as React from "react"; +let buttonProps; +let k = React.createElement("button", Object.assign({}, buttonProps), + React.createElement("span", { className: cx('class1', { class2: true }) })); diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols b/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols new file mode 100644 index 00000000000..088f553baa4 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences3.symbols @@ -0,0 +1,29 @@ +=== tests/cases/conformance/jsx/0.tsx === +/// +import * as cx from 'classnames'; +>cx : Symbol(cx, Decl(0.tsx, 1, 6)) + +import * as React from "react"; +>React : Symbol(React, Decl(0.tsx, 2, 6)) + +let buttonProps; +>buttonProps : Symbol(buttonProps, Decl(0.tsx, 4, 3)) + +let k = ; +>button : Symbol(JSX.IntrinsicElements.button, Decl(react.d.ts, 2385, 43)) + +=== tests/cases/conformance/jsx/declaration.d.ts === +declare module "classnames"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences3.types b/tests/baselines/reference/correctlyMarkAliasAsReferences3.types new file mode 100644 index 00000000000..cca59ae2f5e --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences3.types @@ -0,0 +1,35 @@ +=== tests/cases/conformance/jsx/0.tsx === +/// +import * as cx from 'classnames'; +>cx : any + +import * as React from "react"; +>React : typeof React + +let buttonProps; +>buttonProps : any + +let k = : JSX.Element +>button : any +>buttonProps : undefined + + +> : JSX.Element +>span : any +>className : any +>cx('class1', { class2: true }) : any +>cx : any +>'class1' : "class1" +>{ class2: true } : { class2: boolean; } +>class2 : boolean +>true : true + + ; +>button : any + +=== tests/cases/conformance/jsx/declaration.d.ts === +declare module "classnames"; +No type information for this code. +No type information for this code. \ No newline at end of file diff --git a/tests/baselines/reference/correctlyMarkAliasAsReferences4.js b/tests/baselines/reference/correctlyMarkAliasAsReferences4.js new file mode 100644 index 00000000000..631d06cc5b3 --- /dev/null +++ b/tests/baselines/reference/correctlyMarkAliasAsReferences4.js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/jsx/correctlyMarkAliasAsReferences4.tsx] //// + +//// [declaration.d.ts] +declare module "classnames"; + +//// [0.tsx] +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps : {[attributeName: string]: ''} +let k = ); + } +} diff --git a/tests/cases/conformance/jsx/checkJsxChildrenProperty13.tsx b/tests/cases/conformance/jsx/checkJsxChildrenProperty13.tsx new file mode 100644 index 00000000000..1584bf43159 --- /dev/null +++ b/tests/cases/conformance/jsx/checkJsxChildrenProperty13.tsx @@ -0,0 +1,31 @@ +// @filename: file.tsx +// @jsx: preserve +// @noLib: true +// @libFiles: react.d.ts,lib.d.ts + +import React = require('react'); + +interface ButtonProp { + a: number, + b: string, + children: Button; +} + +class Button extends React.Component { + render() { + // Error children are specified twice + return ( +
Hello World
+
); + } +} + +interface InnerButtonProp { + a: number +} + +class InnerButton extends React.Component { + render() { + return (); + } +} diff --git a/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences1.tsx b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences1.tsx new file mode 100644 index 00000000000..a074b3b8086 --- /dev/null +++ b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences1.tsx @@ -0,0 +1,17 @@ +// @target: es2017 +// @jsx: react +// @moduleResolution: node +// @libFiles: react.d.ts,lib.d.ts + +// @filename: declaration.d.ts +declare module "classnames"; + +// @filename: 0.tsx +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps; // any +let k = ; diff --git a/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences2.tsx b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences2.tsx new file mode 100644 index 00000000000..9755c624fc5 --- /dev/null +++ b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences2.tsx @@ -0,0 +1,17 @@ +// @target: es2017 +// @jsx: react +// @moduleResolution: node +// @libFiles: react.d.ts,lib.d.ts + +// @filename: declaration.d.ts +declare module "classnames"; + +// @filename: 0.tsx +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps : {[attributeName: string]: ''} +let k = ; diff --git a/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences3.tsx b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences3.tsx new file mode 100644 index 00000000000..c3bfb0c8a47 --- /dev/null +++ b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences3.tsx @@ -0,0 +1,18 @@ +// @target: es2017 +// @jsx: react +// @moduleResolution: node +// @noImplicitAny: true +// @libFiles: react.d.ts,lib.d.ts + +// @filename: declaration.d.ts +declare module "classnames"; + +// @filename: 0.tsx +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps; +let k = ; diff --git a/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences4.tsx b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences4.tsx new file mode 100644 index 00000000000..edb9f75f87b --- /dev/null +++ b/tests/cases/conformance/jsx/correctlyMarkAliasAsReferences4.tsx @@ -0,0 +1,15 @@ +// @target: es2017 +// @jsx: react +// @moduleResolution: node +// @libFiles: react.d.ts,lib.d.ts + +// @filename: declaration.d.ts +declare module "classnames"; + +// @filename: 0.tsx +/// +import * as cx from 'classnames'; +import * as React from "react"; + +let buttonProps : {[attributeName: string]: ''} +let k =